x86/aperfmperf: Replace arch_freq_get_on_cpu()
authorThomas Gleixner <tglx@linutronix.de>
Fri, 15 Apr 2022 19:20:04 +0000 (21:20 +0200)
committerThomas Gleixner <tglx@linutronix.de>
Wed, 27 Apr 2022 18:22:19 +0000 (20:22 +0200)
commitf3eca381bd49d708073ba1a9af4fa6ea5d5810a6
treef5ab8f6ff5babeaa6edb0b6f9dd74d41fe21fa33
parent7d84c1ebf9ddafca27b481e6da7d24a023dacaa2
x86/aperfmperf: Replace arch_freq_get_on_cpu()

Reading the current CPU frequency from /sys/..../scaling_cur_freq involves
in the worst case two IPIs due to the ad hoc sampling.

The frequency invariance infrastructure provides the APERF/MPERF samples
already. Utilize them and consolidate this with the /proc/cpuinfo readout.

The sample is considered valid for 20ms. So for idle or isolated NOHZ full
CPUs the function returns 0, which is matching the previous behaviour.

The resulting text size vs. the original APERF/MPERF plus the separate
frequency invariance code:

  text: 2411 ->   723
  init.text:    0 ->   767

Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Tested-by: Eric Dumazet <edumazet@google.com>
Reviewed-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
Acked-by: Peter Zijlstra (Intel) <peterz@infradead.org>
Acked-by: Paul E. McKenney <paulmck@kernel.org>
Link: https://lore.kernel.org/r/20220415161206.934040006@linutronix.de
arch/x86/kernel/cpu/aperfmperf.c
arch/x86/kernel/cpu/proc.c