Linux Power Management development
 help / color / mirror / Atom feed
From: Christian Loehle <christian.loehle@arm.com>
To: Kaushlendra Kumar <kaushlendra.kumar@intel.com>,
	rafael@kernel.org, viresh.kumar@linaro.org, mingo@redhat.com,
	peterz@infradead.org, juri.lelli@redhat.com,
	vincent.guittot@linaro.org, dietmar.eggemann@arm.com,
	bsegall@google.com, mgorman@suse.de, vschneid@redhat.com
Cc: linux-pm@vger.kernel.org,
	Beata Michalska <Beata.Michalska@arm.com>,
	Ionela Voinescu <Ionela.Voinescu@arm.com>
Subject: Re: [PATCH] sched/cpufreq: Fix capacity calc in shared policy update
Date: Tue, 25 Nov 2025 08:37:24 +0000	[thread overview]
Message-ID: <4f5ee76e-1409-4064-b765-3c9aed25cf0e@arm.com> (raw)
In-Reply-To: <20251125032437.2056626-1-kaushlendra.kumar@intel.com>

On 11/25/25 03:24, Kaushlendra Kumar wrote:
> In sugov_next_freq_shared(), the CPU capacity is retrieved only
> for the CPU that triggered the update (sg_cpu->cpu) and then
> incorrectly applied to all CPUs in the shared frequency domain
> during the loop.On heterogeneous systems with CPUs of different
> capacities sharing a frequency domain, this causes incorrect
> frequency selection.

Then this needs a fixes tag?
Maybe even the intel_pstate setup changes? I think the
policy <=> capacity assumption made here was true before that?

> 
> Calculate per-CPU capacity in the loop and track maximum across
> all CPUs for proper frequency calculation.

s/all CPUs/all policy CPUs/ maybe?

> 
> Signed-off-by: Kaushlendra Kumar <kaushlendra.kumar@intel.com>
> ---
>  kernel/sched/cpufreq_schedutil.c | 8 ++++----
>  1 file changed, 4 insertions(+), 4 deletions(-)
> 
> diff --git a/kernel/sched/cpufreq_schedutil.c b/kernel/sched/cpufreq_schedutil.c
> index 0ab5f9d4bc59..9fdbc7a6063d 100644
> --- a/kernel/sched/cpufreq_schedutil.c
> +++ b/kernel/sched/cpufreq_schedutil.c
> @@ -492,15 +492,15 @@ static unsigned int sugov_next_freq_shared(struct sugov_cpu *sg_cpu, u64 time)
>  {
>  	struct sugov_policy *sg_policy = sg_cpu->sg_policy;
>  	struct cpufreq_policy *policy = sg_policy->policy;
> -	unsigned long util = 0, max_cap;
> +	unsigned long util = 0, max_cap = 0;
>  	unsigned int j;
>  
> -	max_cap = arch_scale_cpu_capacity(sg_cpu->cpu);
> -
>  	for_each_cpu(j, policy->cpus) {
>  		struct sugov_cpu *j_sg_cpu = &per_cpu(sugov_cpu, j);
> -		unsigned long boost;
> +		unsigned long boost, j_max_cap;
>  
> +		j_max_cap = arch_scale_cpu_capacity(j);

nit: j_max_cap is only used once...

> +		max_cap = max(max_cap, j_max_cap);
>  		boost = sugov_iowait_apply(j_sg_cpu, time, max_cap);

I find this a bit strange, you might as well argue that this
sets the wrong frequency with your patch (boost being determined by the
highest frequency seen in this loop so far?)
My understanding was that this "different capacity, same cluster" was just
a technicality and because the capacities are still really close (1-2%?) we
essentially don't care about the difference. Why do we care here/now?

>  		sugov_get_util(j_sg_cpu, boost);
>  

  reply	other threads:[~2025-11-25  8:37 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-11-25  3:24 [PATCH] sched/cpufreq: Fix capacity calc in shared policy update Kaushlendra Kumar
2025-11-25  8:37 ` Christian Loehle [this message]
2025-11-25  9:28   ` Kumar, Kaushlendra
2025-11-25  9:04 ` Lukasz Luba
2025-11-25  9:23   ` Kumar, Kaushlendra
2025-11-25  9:38     ` Vincent Guittot
2025-11-25  9:46       ` Christian Loehle
2025-11-25  9:57         ` Vincent Guittot
2025-11-25 12:41         ` Rafael J. Wysocki
2025-11-25 14:05           ` Kumar, Kaushlendra
2025-11-25 12:09 ` Rafael J. Wysocki

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=4f5ee76e-1409-4064-b765-3c9aed25cf0e@arm.com \
    --to=christian.loehle@arm.com \
    --cc=Beata.Michalska@arm.com \
    --cc=Ionela.Voinescu@arm.com \
    --cc=bsegall@google.com \
    --cc=dietmar.eggemann@arm.com \
    --cc=juri.lelli@redhat.com \
    --cc=kaushlendra.kumar@intel.com \
    --cc=linux-pm@vger.kernel.org \
    --cc=mgorman@suse.de \
    --cc=mingo@redhat.com \
    --cc=peterz@infradead.org \
    --cc=rafael@kernel.org \
    --cc=vincent.guittot@linaro.org \
    --cc=viresh.kumar@linaro.org \
    --cc=vschneid@redhat.com \
    /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