2022-04-16 01:29:30

by Thomas Gleixner

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

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 <[email protected]>
---
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);



2022-04-22 21:50:20

by Rafael J. Wysocki

[permalink] [raw]
Subject: Re: [patch 01/10] x86/aperfmperf: Dont wake idle CPUs in arch_freq_get_on_cpu()

On Fri, Apr 15, 2022 at 9:19 PM Thomas Gleixner <[email protected]> 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 <[email protected]>

Acked-by: Rafael J. Wysocki <[email protected]>

> ---
> 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);
>
>

Subject: [tip: x86/cleanups] x86/aperfmperf: Dont wake idle CPUs in arch_freq_get_on_cpu()

The following commit has been merged into the x86/cleanups branch of tip:

Commit-ID: 6d108c96bf23598cc3b4f91d60e9b7694abcd2a7
Gitweb: https://git.kernel.org/tip/6d108c96bf23598cc3b4f91d60e9b7694abcd2a7
Author: Thomas Gleixner <[email protected]>
AuthorDate: Fri, 15 Apr 2022 21:19:50 +02:00
Committer: Thomas Gleixner <[email protected]>
CommitterDate: Wed, 27 Apr 2022 15:51:08 +02:00

x86/aperfmperf: Dont wake idle CPUs in arch_freq_get_on_cpu()

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 <[email protected]>
Acked-by: Rafael J. Wysocki <[email protected]>
Acked-by: Peter Zijlstra (Intel) <[email protected]>
Acked-by: Paul E. McKenney <[email protected]>
Link: https://lore.kernel.org/r/[email protected]

---
arch/x86/kernel/cpu/aperfmperf.c | 3 +++
1 file changed, 3 insertions(+)

diff --git a/arch/x86/kernel/cpu/aperfmperf.c b/arch/x86/kernel/cpu/aperfmperf.c
index 9ca008f..ea9160f 100644
--- 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 cpu)
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);