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

x86/aperfmperf: Store aperf/mperf data for cpu frequency reads

Now that the MSR readout is unconditional, store the results in the per CPU
data structure along with a jiffies timestamp for the CPU frequency readout
code.

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

+13 -1
+13 -1
arch/x86/kernel/cpu/aperfmperf.c
··· 24 24 #include "cpu.h" 25 25 26 26 struct aperfmperf { 27 + seqcount_t seq; 28 + unsigned long last_update; 29 + u64 acnt; 30 + u64 mcnt; 27 31 u64 aperf; 28 32 u64 mperf; 29 33 }; 30 34 31 - static DEFINE_PER_CPU_SHARED_ALIGNED(struct aperfmperf, cpu_samples); 35 + static DEFINE_PER_CPU_SHARED_ALIGNED(struct aperfmperf, cpu_samples) = { 36 + .seq = SEQCNT_ZERO(cpu_samples.seq) 37 + }; 32 38 33 39 struct aperfmperf_sample { 34 40 unsigned int khz; ··· 520 514 521 515 s->aperf = aperf; 522 516 s->mperf = mperf; 517 + 518 + raw_write_seqcount_begin(&s->seq); 519 + s->last_update = jiffies; 520 + s->acnt = acnt; 521 + s->mcnt = mcnt; 522 + raw_write_seqcount_end(&s->seq); 523 523 524 524 scale_freq_tick(acnt, mcnt); 525 525 }