aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorThomas Gleixner <tglx@linutronix.de>2022-04-15 21:20:01 +0200
committerThomas Gleixner <tglx@linutronix.de>2022-04-27 20:22:19 +0200
commitcd8c0e142daf9de9ce594e61b75509b0af7bfb26 (patch)
tree7eb324208afbd0ffc895b75113a5ba1fc77fd294
parentx86/aperfmperf: Make parts of the frequency invariance code unconditional (diff)
downloadlinux-dev-cd8c0e142daf9de9ce594e61b75509b0af7bfb26.tar.xz
linux-dev-cd8c0e142daf9de9ce594e61b75509b0af7bfb26.zip
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
-rw-r--r--arch/x86/kernel/cpu/aperfmperf.c14
1 files changed, 13 insertions, 1 deletions
diff --git a/arch/x86/kernel/cpu/aperfmperf.c b/arch/x86/kernel/cpu/aperfmperf.c
index df528a4f6de3..963c0697a92b 100644
--- a/arch/x86/kernel/cpu/aperfmperf.c
+++ b/arch/x86/kernel/cpu/aperfmperf.c
@@ -24,11 +24,17 @@
#include "cpu.h"
struct aperfmperf {
+ seqcount_t seq;
+ unsigned long last_update;
+ u64 acnt;
+ u64 mcnt;
u64 aperf;
u64 mperf;
};
-static DEFINE_PER_CPU_SHARED_ALIGNED(struct aperfmperf, cpu_samples);
+static DEFINE_PER_CPU_SHARED_ALIGNED(struct aperfmperf, cpu_samples) = {
+ .seq = SEQCNT_ZERO(cpu_samples.seq)
+};
struct aperfmperf_sample {
unsigned int khz;
@@ -515,6 +521,12 @@ void arch_scale_freq_tick(void)
s->aperf = aperf;
s->mperf = mperf;
+ raw_write_seqcount_begin(&s->seq);
+ s->last_update = jiffies;
+ s->acnt = acnt;
+ s->mcnt = mcnt;
+ raw_write_seqcount_end(&s->seq);
+
scale_freq_tick(acnt, mcnt);
}