Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

x86/aperfmperf: Put frequency invariance aperf/mperf data into a struct

Preparation for sharing code with the CPU frequency portion of the
aperf/mperf code.

No functional change.

Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
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.648485667@linutronix.de

+15 -11
+15 -11
arch/x86/kernel/cpu/aperfmperf.c
··· 22 22 23 23 #include "cpu.h" 24 24 25 + struct aperfmperf { 26 + u64 aperf; 27 + u64 mperf; 28 + }; 29 + 30 + static DEFINE_PER_CPU_SHARED_ALIGNED(struct aperfmperf, cpu_samples); 31 + 25 32 struct aperfmperf_sample { 26 33 unsigned int khz; 27 34 atomic_t scfpending; ··· 201 194 202 195 DEFINE_STATIC_KEY_FALSE(arch_scale_freq_key); 203 196 204 - static DEFINE_PER_CPU(u64, arch_prev_aperf); 205 - static DEFINE_PER_CPU(u64, arch_prev_mperf); 206 197 static u64 arch_turbo_freq_ratio = SCHED_CAPACITY_SCALE; 207 198 static u64 arch_max_freq_ratio = SCHED_CAPACITY_SCALE; 208 199 ··· 412 407 rdmsrl(MSR_IA32_APERF, aperf); 413 408 rdmsrl(MSR_IA32_MPERF, mperf); 414 409 415 - this_cpu_write(arch_prev_aperf, aperf); 416 - this_cpu_write(arch_prev_mperf, mperf); 410 + this_cpu_write(cpu_samples.aperf, aperf); 411 + this_cpu_write(cpu_samples.mperf, mperf); 417 412 } 418 413 419 414 #ifdef CONFIG_PM_SLEEP ··· 479 474 480 475 void arch_scale_freq_tick(void) 481 476 { 482 - u64 freq_scale; 483 - u64 aperf, mperf; 484 - u64 acnt, mcnt; 477 + struct aperfmperf *s = this_cpu_ptr(&cpu_samples); 478 + u64 aperf, mperf, acnt, mcnt, freq_scale; 485 479 486 480 if (!arch_scale_freq_invariant()) 487 481 return; ··· 488 484 rdmsrl(MSR_IA32_APERF, aperf); 489 485 rdmsrl(MSR_IA32_MPERF, mperf); 490 486 491 - acnt = aperf - this_cpu_read(arch_prev_aperf); 492 - mcnt = mperf - this_cpu_read(arch_prev_mperf); 487 + acnt = aperf - s->aperf; 488 + mcnt = mperf - s->mperf; 493 489 494 - this_cpu_write(arch_prev_aperf, aperf); 495 - this_cpu_write(arch_prev_mperf, mperf); 490 + s->aperf = aperf; 491 + s->mperf = mperf; 496 492 497 493 if (check_shl_overflow(acnt, 2*SCHED_CAPACITY_SHIFT, &acnt)) 498 494 goto error;