diff mbox series

[01/10] x86/aperfmperf: Dont wake idle CPUs in arch_freq_get_on_cpu()

Message ID 20220415161206.419880163@linutronix.de
State New
Headers show
Series x86/cpu: Consolidate APERF/MPERF code | expand

Commit Message

Thomas Gleixner April 15, 2022, 7:19 p.m. UTC
aperfmperf_get_khz() already excludes idle CPUs from APERF/MPERF sampling
and that's a reasonable decision. There is no point in sending up to two
IPIs to an idle CPU just because someone reads a sysfs file.

Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
---
 arch/x86/kernel/cpu/aperfmperf.c |    3 +++
 1 file changed, 3 insertions(+)

Comments

Rafael J. Wysocki April 19, 2022, 3:34 p.m. UTC | #1
On Fri, Apr 15, 2022 at 9:19 PM Thomas Gleixner <tglx@linutronix.de> wrote:
>
> aperfmperf_get_khz() already excludes idle CPUs from APERF/MPERF sampling
> and that's a reasonable decision. There is no point in sending up to two
> IPIs to an idle CPU just because someone reads a sysfs file.
>
> Signed-off-by: Thomas Gleixner <tglx@linutronix.de>

Acked-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>

> ---
>  arch/x86/kernel/cpu/aperfmperf.c |    3 +++
>  1 file changed, 3 insertions(+)
>
> --- a/arch/x86/kernel/cpu/aperfmperf.c
> +++ b/arch/x86/kernel/cpu/aperfmperf.c
> @@ -139,6 +139,9 @@ unsigned int arch_freq_get_on_cpu(int cp
>         if (!housekeeping_cpu(cpu, HK_TYPE_MISC))
>                 return 0;
>
> +       if (rcu_is_idle_cpu(cpu))
> +               return 0;
> +
>         if (aperfmperf_snapshot_cpu(cpu, ktime_get(), true))
>                 return per_cpu(samples.khz, cpu);
>
>
diff mbox series

Patch

--- a/arch/x86/kernel/cpu/aperfmperf.c
+++ b/arch/x86/kernel/cpu/aperfmperf.c
@@ -139,6 +139,9 @@  unsigned int arch_freq_get_on_cpu(int cp
 	if (!housekeeping_cpu(cpu, HK_TYPE_MISC))
 		return 0;
 
+	if (rcu_is_idle_cpu(cpu))
+		return 0;
+
 	if (aperfmperf_snapshot_cpu(cpu, ktime_get(), true))
 		return per_cpu(samples.khz, cpu);