2022-04-16 01:10:25

by Thomas Gleixner

[permalink] [raw]
Subject: [patch 08/10] 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 <[email protected]>
---
arch/x86/kernel/cpu/aperfmperf.c | 14 +++++++++++++-
1 file changed, 13 insertions(+), 1 deletion(-)

--- 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);
}



2022-04-19 18:24:22

by Rafael J. Wysocki

[permalink] [raw]
Subject: Re: [patch 08/10] x86/aperfmperf: Store aperf/mperf data for cpu frequency reads

On Fri, Apr 15, 2022 at 9:20 PM Thomas Gleixner <[email protected]> wrote:
>
> 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 <[email protected]>

Acked-by: Rafael J. Wysocki <[email protected]>

> ---
> arch/x86/kernel/cpu/aperfmperf.c | 14 +++++++++++++-
> 1 file changed, 13 insertions(+), 1 deletion(-)
>
> --- 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);
> }
>
>

Subject: [tip: x86/cleanups] x86/aperfmperf: Store aperf/mperf data for cpu frequency reads

The following commit has been merged into the x86/cleanups branch of tip:

Commit-ID: 3b1fc17f635164d74934f67d3bb46cdf877fb67f
Gitweb: https://git.kernel.org/tip/3b1fc17f635164d74934f67d3bb46cdf877fb67f
Author: Thomas Gleixner <[email protected]>
AuthorDate: Fri, 15 Apr 2022 21:20:01 +02:00
Committer: Thomas Gleixner <[email protected]>
CommitterDate: Wed, 27 Apr 2022 15:51:08 +02:00

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 <[email protected]>
Acked-by: Rafael J. Wysocki <[email protected]>
Acked-by: Peter Zijlstra (Intel) <[email protected]>
Acked-by: Paul E. McKenney <[email protected]>
Link: https://lore.kernel.org/r/[email protected]

---
arch/x86/kernel/cpu/aperfmperf.c | 14 +++++++++++++-
1 file changed, 13 insertions(+), 1 deletion(-)

diff --git a/arch/x86/kernel/cpu/aperfmperf.c b/arch/x86/kernel/cpu/aperfmperf.c
index df528a4..963c069 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);
}

Subject: [tip: x86/cleanups] x86/aperfmperf: Store aperf/mperf data for cpu frequency reads

The following commit has been merged into the x86/cleanups branch of tip:

Commit-ID: cd8c0e142daf9de9ce594e61b75509b0af7bfb26
Gitweb: https://git.kernel.org/tip/cd8c0e142daf9de9ce594e61b75509b0af7bfb26
Author: Thomas Gleixner <[email protected]>
AuthorDate: Fri, 15 Apr 2022 21:20:01 +02:00
Committer: Thomas Gleixner <[email protected]>
CommitterDate: Wed, 27 Apr 2022 20:22:19 +02:00

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 <[email protected]>
Acked-by: Rafael J. Wysocki <[email protected]>
Acked-by: Peter Zijlstra (Intel) <[email protected]>
Acked-by: Paul E. McKenney <[email protected]>
Link: https://lore.kernel.org/r/[email protected]

---
arch/x86/kernel/cpu/aperfmperf.c | 14 +++++++++++++-
1 file changed, 13 insertions(+), 1 deletion(-)

diff --git a/arch/x86/kernel/cpu/aperfmperf.c b/arch/x86/kernel/cpu/aperfmperf.c
index df528a4..963c069 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);
}