Skip to content

Commit cd8c0e1

Browse files
committed
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
1 parent bb6e89d commit cd8c0e1

1 file changed

Lines changed: 13 additions & 1 deletion

File tree

arch/x86/kernel/cpu/aperfmperf.c

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,11 +24,17 @@
2424
#include "cpu.h"
2525

2626
struct aperfmperf {
27+
seqcount_t seq;
28+
unsigned long last_update;
29+
u64 acnt;
30+
u64 mcnt;
2731
u64 aperf;
2832
u64 mperf;
2933
};
3034

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+
};
3238

3339
struct aperfmperf_sample {
3440
unsigned int khz;
@@ -515,6 +521,12 @@ void arch_scale_freq_tick(void)
515521
s->aperf = aperf;
516522
s->mperf = mperf;
517523

524+
raw_write_seqcount_begin(&s->seq);
525+
s->last_update = jiffies;
526+
s->acnt = acnt;
527+
s->mcnt = mcnt;
528+
raw_write_seqcount_end(&s->seq);
529+
518530
scale_freq_tick(acnt, mcnt);
519531
}
520532

0 commit comments

Comments
 (0)