From: Lukasz Luba <lukasz.luba@arm.com>
To: Vincent Guittot <vincent.guittot@linaro.org>
Cc: conor.dooley@microchip.com, suagrfillet@gmail.com,
linux-pm@vger.kernel.org, linux-arm-kernel@lists.infradead.org,
vschneid@redhat.com, bsegall@google.com,
dietmar.eggemann@arm.com, juri.lelli@redhat.com,
peterz@infradead.org, rafael@kernel.org,
gregkh@linuxfoundation.org, ajones@ventanamicro.com,
linux-riscv@lists.infradead.org, linux-kernel@vger.kernel.org,
sudeep.holla@arm.com, ionela.voinescu@arm.com,
viresh.kumar@linaro.org, mgorman@suse.de, palmer@dabbelt.com,
will@kernel.org, bristot@redhat.com, lftan@kernel.org,
rostedt@goodmis.org, linux@armlinux.org.uk,
paul.walmsley@sifive.com, aou@eecs.berkeley.edu,
mingo@redhat.com, catalin.marinas@arm.com,
pierre.gondois@arm.com
Subject: Re: [PATCH v2 4/6] cpufreq/schedutil: use a fixed reference frequency
Date: Wed, 18 Oct 2023 12:21:52 +0100 [thread overview]
Message-ID: <368c8a9f-b137-47a9-9468-ebeb04d4bab5@arm.com> (raw)
In-Reply-To: <20231009103621.374412-5-vincent.guittot@linaro.org>
On 10/9/23 11:36, Vincent Guittot wrote:
> cpuinfo.max_freq can change at runtime because of boost as an example. This
> implies that the value could be different than the one that has been
> used when computing the capacity of a CPU.
>
> The new arch_scale_freq_ref() returns a fixed and coherent reference
> frequency that can be used when computing a frequency based on utilization.
>
> Use this arch_scale_freq_ref() when available and fallback to
> policy otherwise.
>
> Signed-off-by: Vincent Guittot <vincent.guittot@linaro.org>
> ---
> kernel/sched/cpufreq_schedutil.c | 26 ++++++++++++++++++++++++--
> 1 file changed, 24 insertions(+), 2 deletions(-)
>
> diff --git a/kernel/sched/cpufreq_schedutil.c b/kernel/sched/cpufreq_schedutil.c
> index 4492608b7d7f..1fa7e74add8f 100644
> --- a/kernel/sched/cpufreq_schedutil.c
> +++ b/kernel/sched/cpufreq_schedutil.c
> @@ -114,6 +114,28 @@ static void sugov_deferred_update(struct sugov_policy *sg_policy)
> }
> }
>
> +/**
> + * cpufreq_get_capacity_ref_freq - get the reference frequency of a given CPU that
> + * has been used to correlate frequency and compute capacity.
> + * @policy: the cpufreq policy of the CPU in question.
> + * @use_current: Fallback to current freq instead of policy->cpuinfo.max_freq.
> + *
> + * Return: the reference CPU frequency to compute a capacity.
> + */
> +static __always_inline
> +unsigned long get_capacity_ref_freq(struct cpufreq_policy *policy)
> +{
> + unsigned int freq = arch_scale_freq_ref(policy->cpu);
> +
> + if (freq)
> + return freq;
Looks good, for the platforms having this inline function returning 0,
this will be optimized out.
> +
> + if (arch_scale_freq_invariant())
> + return policy->cpuinfo.max_freq;
> +
> + return policy->cur;
> +}
> +
> /**
> * get_next_freq - Compute a new frequency for a given cpufreq policy.
> * @sg_policy: schedutil policy object to compute the new frequency for.
> @@ -140,10 +162,10 @@ static unsigned int get_next_freq(struct sugov_policy *sg_policy,
> unsigned long util, unsigned long max)
> {
> struct cpufreq_policy *policy = sg_policy->policy;
> - unsigned int freq = arch_scale_freq_invariant() ?
> - policy->cpuinfo.max_freq : policy->cur;
> + unsigned int freq;
>
> util = map_util_perf(util);
> + freq = get_capacity_ref_freq(policy);
> freq = map_util_freq(util, freq, max);
>
> if (freq == sg_policy->cached_raw_freq && !sg_policy->need_freq_update)
Reviewed-by: Lukasz Luba <lukasz.luba@arm.com>
_______________________________________________
linux-riscv mailing list
linux-riscv@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-riscv
next prev parent reply other threads:[~2023-10-18 11:21 UTC|newest]
Thread overview: 22+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-10-09 10:36 [PATCH v2 0/6] consolidate and cleanup CPU capacity Vincent Guittot
2023-10-09 10:36 ` [PATCH v2 1/6] sched: consolidate and cleanup access to CPU's max compute capacity Vincent Guittot
2023-10-09 11:01 ` Ingo Molnar
2023-10-09 10:36 ` [PATCH v2 2/6] topology: add a new arch_scale_freq_reference Vincent Guittot
2023-10-11 10:27 ` Pierre Gondois
2023-10-11 13:48 ` Vincent Guittot
2023-10-18 11:06 ` Lukasz Luba
2023-10-09 10:36 ` [PATCH v2 3/6] cpufreq: use the fixed and coherent frequency for scaling capacity Vincent Guittot
2023-10-09 11:01 ` Viresh Kumar
2023-10-18 11:16 ` Lukasz Luba
2023-10-09 10:36 ` [PATCH v2 4/6] cpufreq/schedutil: use a fixed reference frequency Vincent Guittot
2023-10-18 11:21 ` Lukasz Luba [this message]
2023-10-09 10:36 ` [PATCH v2 5/6] energy_model: " Vincent Guittot
2023-10-18 9:16 ` Lukasz Luba
2023-10-09 10:36 ` [PATCH v2 6/6] cpufreq/cppc: set the frequency used for capacity computation Vincent Guittot
2023-10-11 10:27 ` Pierre Gondois
2023-10-11 14:25 ` Vincent Guittot
2023-10-16 12:12 ` Ionela Voinescu
2023-10-16 15:32 ` Vincent Guittot
2023-10-17 9:02 ` Ionela Voinescu
2023-10-17 13:41 ` Vincent Guittot
2023-10-18 11:27 ` [PATCH v2 0/6] consolidate and cleanup CPU capacity Lukasz Luba
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=368c8a9f-b137-47a9-9468-ebeb04d4bab5@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=ionela.voinescu@arm.com \
--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=pierre.gondois@arm.com \
--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