x86 / CPU: Add cpu isolation flag for avoiding disturbance from aperfmperf IPI
Subsystems (3)
RFC PATCH 1/1 x86 / CPU: Add cpu isolation flag for avoiding disturbance from aperfmperf IPI
Sensitive workloads like DPDK polling do not like any interrupts.
This patch adds flag 'freq' for boot option 'isolcpu': isolcpu=freq,<cpus>.
Users like show_cpuinfo() fallback to frequency from generic cpufreq policy if arch-specific requesting method returns 0.
--- Documentation/admin-guide/kernel-parameters.txt | 3 +++ arch/x86/kernel/cpu/aperfmperf.c | 12 +++++++++++- include/linux/sched/isolation.h | 1 + kernel/sched/isolation.c | 6 ++++++ 4 files changed, 21 insertions(+), 1 deletion(-)
Documentation/admin-guide/kernel-parameters.txt +3 -0
@@ -1900,6 +1900,9 @@ <cpu number> begins at 0 and the maximum value is "number of CPUs in system - 1". + freq + Do not request current cpu frequency via IPI. + The format of <cpu-list> is described above.
arch/x86/kernel/cpu/aperfmperf.c +11 -1
@@ -14,6 +14,7 @@#include <linux/percpu.h> #include <linux/cpufreq.h> #include <linux/smp.h> +#include <linux/sched/isolation.h> #include "cpu.h"
@@ -86,6 +87,9 @@ unsigned int aperfmperf_get_khz(int cpu)if (!static_cpu_has (X86_FEATURE_APERFMPERF ))return 0 ; +if (!housekeeping_cpu (cpu,HK_FLAG_FREQ )) +return 0 ; +aperfmperf_snapshot_cpu (cpu,ktime_get (), true);return per_cpu (samples.khz, cpu); }
@@ -102,9 +106,12 @@ void arch_freq_prepare_all(void)if (!static_cpu_has (X86_FEATURE_APERFMPERF ))return ; -for_each_online_cpu (cpu) +for_each_online_cpu (cpu) { +if (!housekeeping_cpu (cpu,HK_FLAG_FREQ )) +continue ;if (!aperfmperf_snapshot_cpu (cpu, now, false)) wait = true; + }if (wait)msleep (APERFMPERF_REFRESH_DELAY_MS );
@@ -118,6 +125,9 @@ unsigned int arch_freq_get_on_cpu(int cpu)if (!static_cpu_has (X86_FEATURE_APERFMPERF ))return 0 ; +if (!housekeeping_cpu (cpu,HK_FLAG_FREQ )) +return 0 ; +if (aperfmperf_snapshot_cpu (cpu,ktime_get (), true))return per_cpu (samples.khz, cpu);
include/linux/sched/isolation.h +1 -0
@@ -13,6 +13,7 @@ enum hk_flags {HK_FLAG_TICK = (1 <<4 ),HK_FLAG_DOMAIN = (1 <<5 ),HK_FLAG_WQ = (1 <<6 ), + HK_FLAG_FREQ = (1 << 7), };#ifdef CONFIG_CPU_ISOLATION
kernel/sched/isolation.c +6 -0
@@ -140,6 +140,12 @@ static int __init housekeeping_isolcpus_setup(char *str)continue ; } +if (!strncmp (str,"freq," ,5 )) { + str +=5 ; + flags |=HK_FLAG_FREQ ; +continue ; + } +pr_warn ("isolcpus: Error, unknown flag\n" );return 0 ; }
Peter Zijlstra
maintainerQuoted 6 lines · Konstantin Khlebnikov
Sensitive workloads like DPDK polling do not like any interrupts.
This patch adds flag 'freq' for boot option 'isolcpu': isolcpu=freq,<cpus>.
Users like
show_cpuinfo()fallback to frequency from generic cpufreq policy if arch-specific requesting method returns 0.
Then don't touch that sysfs file?
I really hate having an option for just this.
Quoted 9 lines · Peter Zijlstra
Quoted 6 lines · Konstantin Khlebnikov
Sensitive workloads like DPDK polling do not like any interrupts.
This patch adds flag 'freq' for boot option 'isolcpu': isolcpu=freq,<cpus>.
Users like
show_cpuinfo()fallback to frequency from generic cpufreq policy if arch-specific requesting method returns 0.Then don't touch that sysfs file?
What sysfs file?
I mean many applications read /proc/cpuinfo and this triggers IPI to all cpus.
Quoted 3 lines
I really hate having an option for just this.
This could be generalized to 'isolate cpu from unnecessary IPI'. Something like mm pagevec drain also could be avoided.
Peter Zijlstra
maintainerQuoted 4 lines · Konstantin Khlebnikov
Quoted 3 lines · Peter Zijlstra
Quoted 2 lines · Konstantin Khlebnikov
Sensitive workloads like DPDK polling do not like any interrupts.
Quoted 8 lines
Quoted 6 lines
Quoted 4 lines
This patch adds flag 'freq' for boot option 'isolcpu': isolcpu=freq,<cpus>.
Users like
show_cpuinfo()fallback to frequency from generic cpufreq policy if arch-specific requesting method returns 0.Then don't touch that sysfs file?
What sysfs file?
/sys/devices/system/cpu/cpu*/cpufreq/scaling_cur_freq
Quoted 1 line
I mean many applications read
/proc/cpuinfoand this triggers IPI to all cpus.
Argh, I missed it was wired into that too :/
Quoted 5 lines
Quoted 2 lines
I really hate having an option for just this.
This could be generalized to 'isolate cpu from unnecessary IPI'. Something like mm pagevec drain also could be avoided.
Well, that should be a default feature of nohz full, no additional flags required.