mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Lukasz Luba <lukasz.luba@arm.com>
To: Vincent Guittot <vincent.guittot@linaro.org>
Cc: conor.dooley@microchip.com, linux-arm-kernel@lists.infradead.org,
	suagrfillet@gmail.com, juri.lelli@redhat.com,
	sudeep.holla@arm.com, palmer@dabbelt.com,
	linux-riscv@lists.infradead.org, ajones@ventanamicro.com,
	lftan@kernel.org, linux-kernel@vger.kernel.org,
	linux-pm@vger.kernel.org, linux@armlinux.org.uk,
	bristot@redhat.com, catalin.marinas@arm.com, bsegall@google.com,
	will@kernel.org, vschneid@redhat.com, rostedt@goodmis.org,
	rafael@kernel.org, dietmar.eggemann@arm.com,
	aou@eecs.berkeley.edu, mingo@redhat.com,
	paul.walmsley@sifive.com, mgorman@suse.de,
	gregkh@linuxfoundation.org, peterz@infradead.org,
	viresh.kumar@linaro.org
Subject: Re: [PATCH 2/4] topology: add a new arch_scale_freq_reference
Date: Mon, 4 Sep 2023 13:35:05 +0100	[thread overview]
Message-ID: <840cb103-8ffb-9798-05a3-a557f78f7f7a@arm.com> (raw)
In-Reply-To: <20230901130312.247719-3-vincent.guittot@linaro.org>

Hi Vincent,


On 9/1/23 14:03, Vincent Guittot wrote:
> Create a new method to get a unique and fixed max frequency. Currently
> cpuinfo.max_freq or last item of performance domain are used as the max
> frequency when computing the frequency for a level of utilization but:
> - cpuinfo_max_freq can change at runtime. boost is one example of
>    such change.
> - cpuinfo.max_freq and last item of the PD can be different leading to
>    different results betwen cpufreq and energy model.
> 
> We need to save the max frequency that has been used when computing the
> CPUs capacity and use this fixed and coherent value to convert between
> frequency and CPU's capacity.
> 
> In fact, we already save the frequency that has been used when computing
> the capacity of each CPU. We extend the precision to save khZ instead of
> Mhz currently and we modify the type to be aligned with other variables
> used when converting frequency to capacity and the other way.

I do like this 'kHz' change. We also use kHz in the EM, so better
aligned now.

> 
> Signed-off-by: Vincent Guittot <vincent.guittot@linaro.org>
> ---
>   arch/arm/include/asm/topology.h   | 1 +
>   arch/arm64/include/asm/topology.h | 1 +
>   arch/riscv/include/asm/topology.h | 1 +
>   drivers/base/arch_topology.c      | 9 +++------
>   include/linux/arch_topology.h     | 7 +++++++
>   5 files changed, 13 insertions(+), 6 deletions(-)
> 
> diff --git a/arch/arm/include/asm/topology.h b/arch/arm/include/asm/topology.h
> index c7d2510e5a78..853c4f81ba4a 100644
> --- a/arch/arm/include/asm/topology.h
> +++ b/arch/arm/include/asm/topology.h
> @@ -13,6 +13,7 @@
>   #define arch_set_freq_scale topology_set_freq_scale
>   #define arch_scale_freq_capacity topology_get_freq_scale
>   #define arch_scale_freq_invariant topology_scale_freq_invariant
> +#define arch_scale_freq_ref topology_get_freq_ref
>   #endif
>   
>   /* Replace task scheduler's default cpu-invariant accounting */
> diff --git a/arch/arm64/include/asm/topology.h b/arch/arm64/include/asm/topology.h
> index 9fab663dd2de..a323b109b9c4 100644
> --- a/arch/arm64/include/asm/topology.h
> +++ b/arch/arm64/include/asm/topology.h
> @@ -23,6 +23,7 @@ void update_freq_counters_refs(void);
>   #define arch_set_freq_scale topology_set_freq_scale
>   #define arch_scale_freq_capacity topology_get_freq_scale
>   #define arch_scale_freq_invariant topology_scale_freq_invariant
> +#define arch_scale_freq_ref topology_get_freq_ref
>   
>   #ifdef CONFIG_ACPI_CPPC_LIB
>   #define arch_init_invariance_cppc topology_init_cpu_capacity_cppc
> diff --git a/arch/riscv/include/asm/topology.h b/arch/riscv/include/asm/topology.h
> index e316ab3b77f3..61183688bdd5 100644
> --- a/arch/riscv/include/asm/topology.h
> +++ b/arch/riscv/include/asm/topology.h
> @@ -9,6 +9,7 @@
>   #define arch_set_freq_scale		topology_set_freq_scale
>   #define arch_scale_freq_capacity	topology_get_freq_scale
>   #define arch_scale_freq_invariant	topology_scale_freq_invariant
> +#define arch_scale_freq_ref		topology_get_freq_ref
>   
>   /* Replace task scheduler's default cpu-invariant accounting */
>   #define arch_scale_cpu_capacity	topology_get_cpu_scale
> diff --git a/drivers/base/arch_topology.c b/drivers/base/arch_topology.c
> index b741b5ba82bd..75fa67477a9d 100644
> --- a/drivers/base/arch_topology.c
> +++ b/drivers/base/arch_topology.c
> @@ -26,7 +26,7 @@
>   static DEFINE_PER_CPU(struct scale_freq_data __rcu *, sft_data);
>   static struct cpumask scale_freq_counters_mask;
>   static bool scale_freq_invariant;
> -static DEFINE_PER_CPU(u32, freq_factor) = 1;
> +DEFINE_PER_CPU(unsigned long, freq_factor) = 1;

Why it's not static now?

>   
>   static bool supports_scale_freq_counters(const struct cpumask *cpus)
>   {
> @@ -183,10 +183,7 @@ void topology_update_thermal_pressure(const struct cpumask *cpus,
>   
>   	cpu = cpumask_first(cpus);
>   	max_capacity = arch_scale_cpu_capacity(cpu);
> -	max_freq = per_cpu(freq_factor, cpu);
> -
> -	/* Convert to MHz scale which is used in 'freq_factor' */
> -	capped_freq /= 1000;
> +	max_freq = arch_scale_freq_ref(cpu);
>   
>   	/*
>   	 * Handle properly the boost frequencies, which should simply clean
> @@ -411,7 +408,7 @@ init_cpu_capacity_callback(struct notifier_block *nb,
>   	cpumask_andnot(cpus_to_visit, cpus_to_visit, policy->related_cpus);
>   
>   	for_each_cpu(cpu, policy->related_cpus)
> -		per_cpu(freq_factor, cpu) = policy->cpuinfo.max_freq / 1000;
> +		per_cpu(freq_factor, cpu) = policy->cpuinfo.max_freq;
>   
>   	if (cpumask_empty(cpus_to_visit)) {
>   		topology_normalize_cpu_scale();
> diff --git a/include/linux/arch_topology.h b/include/linux/arch_topology.h
> index a07b510e7dc5..7a2dba9c3dc0 100644
> --- a/include/linux/arch_topology.h
> +++ b/include/linux/arch_topology.h
> @@ -27,6 +27,13 @@ static inline unsigned long topology_get_cpu_scale(int cpu)
>   
>   void topology_set_cpu_scale(unsigned int cpu, unsigned long capacity);
>   
> +DECLARE_PER_CPU(unsigned long, freq_factor);
> +
> +static inline unsigned long topology_get_freq_ref(int cpu)
> +{
> +	return per_cpu(freq_factor, cpu);
> +}
> +
>   DECLARE_PER_CPU(unsigned long, arch_freq_scale);
>   
>   static inline unsigned long topology_get_freq_scale(int cpu)

Apart from that 'static' missing, that looks good.

Regards,
Lukasz

  reply	other threads:[~2023-09-04 12:34 UTC|newest]

Thread overview: 29+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-09-01 13:03 [PATCH 0/4] consolidate and cleanup CPU capacity Vincent Guittot
2023-09-01 13:03 ` [PATCH 1/4] sched: consolidate and cleanup access to CPU's max compute capacity Vincent Guittot
2023-09-05 11:25   ` Peter Zijlstra
2023-09-14 20:45   ` Dietmar Eggemann
2023-09-15 13:20     ` Vincent Guittot
2023-09-01 13:03 ` [PATCH 2/4] topology: add a new arch_scale_freq_reference Vincent Guittot
2023-09-04 12:35   ` Lukasz Luba [this message]
2023-09-18 11:23     ` Vincent Guittot
2023-09-14 21:01   ` Dietmar Eggemann
2023-09-21  9:00   ` Ionela Voinescu
2023-09-25 12:06     ` Vincent Guittot
2023-09-01 13:03 ` [PATCH 3/4] cpufreq/schedutil: use a fixed reference frequency Vincent Guittot
2023-09-02 10:57   ` Conor Dooley
2023-09-02 12:49     ` Vincent Guittot
2023-09-05 11:24   ` Peter Zijlstra
2023-09-05 13:50     ` Vincent Guittot
2023-09-21  9:19   ` Ionela Voinescu
2023-09-25 12:06     ` Vincent Guittot
2023-09-01 13:03 ` [PATCH 4/4] energy_model: " Vincent Guittot
2023-09-04 12:40   ` Lukasz Luba
2023-09-05 10:05   ` Pierre Gondois
2023-09-05 11:33     ` Peter Zijlstra
2023-09-05 13:16     ` Vincent Guittot
2023-09-14 21:07   ` Dietmar Eggemann
2023-09-15 13:35     ` Vincent Guittot
2023-09-18 20:46       ` Dietmar Eggemann
2023-09-21 10:12   ` Ionela Voinescu
2023-09-21 10:12 ` [PATCH 0/4] consolidate and cleanup CPU capacity Ionela Voinescu
2023-09-25 12:05   ` Vincent Guittot

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=840cb103-8ffb-9798-05a3-a557f78f7f7a@arm.com \
    --to=lukasz.luba@arm.com \
    --cc=ajones@ventanamicro.com \
    --cc=aou@eecs.berkeley.edu \
    --cc=bristot@redhat.com \
    --cc=bsegall@google.com \
    --cc=catalin.marinas@arm.com \
    --cc=conor.dooley@microchip.com \
    --cc=dietmar.eggemann@arm.com \
    --cc=gregkh@linuxfoundation.org \
    --cc=juri.lelli@redhat.com \
    --cc=lftan@kernel.org \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-pm@vger.kernel.org \
    --cc=linux-riscv@lists.infradead.org \
    --cc=linux@armlinux.org.uk \
    --cc=mgorman@suse.de \
    --cc=mingo@redhat.com \
    --cc=palmer@dabbelt.com \
    --cc=paul.walmsley@sifive.com \
    --cc=peterz@infradead.org \
    --cc=rafael@kernel.org \
    --cc=rostedt@goodmis.org \
    --cc=suagrfillet@gmail.com \
    --cc=sudeep.holla@arm.com \
    --cc=vincent.guittot@linaro.org \
    --cc=viresh.kumar@linaro.org \
    --cc=vschneid@redhat.com \
    --cc=will@kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®