public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Hongyan Xia <hongyan.xia2@arm.com>
To: Dietmar Eggemann <dietmar.eggemann@arm.com>,
	Ingo Molnar <mingo@redhat.com>,
	Peter Zijlstra <peterz@infradead.org>,
	Vincent Guittot <vincent.guittot@linaro.org>,
	Juri Lelli <juri.lelli@redhat.com>,
	Steven Rostedt <rostedt@goodmis.org>,
	Ben Segall <bsegall@google.com>, Mel Gorman <mgorman@suse.de>,
	Daniel Bristot de Oliveira <bristot@redhat.com>,
	Valentin Schneider <vschneid@redhat.com>,
	"Rafael J. Wysocki" <rafael@kernel.org>,
	Viresh Kumar <viresh.kumar@linaro.org>
Cc: Qais Yousef <qyousef@layalina.io>,
	Morten Rasmussen <morten.rasmussen@arm.com>,
	Lukasz Luba <lukasz.luba@arm.com>,
	Christian Loehle <christian.loehle@arm.com>,
	linux-kernel@vger.kernel.org, David Dai <davidai@google.com>,
	Saravana Kannan <saravanak@google.com>,
	linux-pm@vger.kernel.org
Subject: Re: [RFC PATCH v2 4/7] sched/fair: Use CFS util_avg_uclamp for utilization and frequency
Date: Fri, 15 Mar 2024 19:47:29 +0000	[thread overview]
Message-ID: <4300a3e5-061d-4daf-b277-631bfc16ff85@arm.com> (raw)
In-Reply-To: <5bb38524-fd13-477f-adde-0a9ac01bfeae@arm.com>

On 15/03/2024 12:31, Dietmar Eggemann wrote:
> On 01/02/2024 14:12, Hongyan Xia wrote:
> 
> [...]
> 
>> @@ -7685,11 +7697,13 @@ static int select_idle_sibling(struct task_struct *p, int prev, int target)
>>   static unsigned long
>>   cpu_util(int cpu, struct task_struct *p, int dst_cpu, int boost)
>>   {
>> -	struct cfs_rq *cfs_rq = &cpu_rq(cpu)->cfs;
>> -	unsigned long util = READ_ONCE(cfs_rq->avg.util_avg);
>> +	struct rq *rq = cpu_rq(cpu);
>> +	struct cfs_rq *cfs_rq = &rq->cfs;
>> +	unsigned long util = root_cfs_util(rq);
>> +	bool capped = uclamp_rq_is_capped(rq);
> 
> I try to rerun your tests in your 2 ipynbs (cover letter) but this let's
> the sum aggr stack go sideways ...
> 
> if 'sched_uclamp_used' then uclamp_rq_is_capped() will call
> cpu_util_cfs()->cpu_util() which then calls uclamp_rq_is_capped()
> recursively resulting in a stack overflow.
> 
> Do you have a fix for that you can share? For the time I remove the call
> to uclamp_rq_is_capped() in cpu_util().

My apologies. This has long ago been fixed and here is the diff:

diff --git a/kernel/sched/sched.h b/kernel/sched/sched.h
index 1ebdd0b9ebca..d5dcda036e0d 100644
--- a/kernel/sched/sched.h
+++ b/kernel/sched/sched.h
@@ -3018,9 +3018,8 @@ static inline bool uclamp_rq_is_capped(struct rq *rq)
         if (!static_branch_likely(&sched_uclamp_used))
                 return false;

-       rq_uclamp_util = cpu_util_cfs(cpu_of(rq)) + cpu_util_rt(rq);
-       rq_real_util = READ_ONCE(rq->cfs.avg.util_avg) +
-                      READ_ONCE(rq->avg_rt.util_avg);
+       rq_uclamp_util = READ_ONCE(rq->root_cfs_util_uclamp);
+       rq_real_util = READ_ONCE(rq->cfs.avg.util_avg);

         return rq_uclamp_util < SCHED_CAPACITY_SCALE &&
                rq_real_util > rq_uclamp_util;

> [...]
> 

  reply	other threads:[~2024-03-15 19:47 UTC|newest]

Thread overview: 22+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-02-01 13:11 [RFC PATCH v2 0/7] uclamp sum aggregation Hongyan Xia
2024-02-01 13:11 ` [RFC PATCH v2 1/7] Revert "sched/uclamp: Set max_spare_cap_cpu even if max_spare_cap is 0" Hongyan Xia
2024-03-19 15:34   ` Dietmar Eggemann
2024-03-19 17:05     ` Hongyan Xia
2024-02-01 13:11 ` [RFC PATCH v2 2/7] sched/uclamp: Track uclamped util_avg in sched_avg Hongyan Xia
2024-02-01 13:11 ` [RFC PATCH v2 3/7] sched/uclamp: Introduce root_cfs_util_uclamp for rq Hongyan Xia
2024-03-18 18:21   ` Dietmar Eggemann
2024-03-19 11:50     ` Hongyan Xia
2024-03-20 15:27       ` Dietmar Eggemann
2024-03-20 17:22         ` Hongyan Xia
2024-02-01 13:12 ` [RFC PATCH v2 4/7] sched/fair: Use CFS util_avg_uclamp for utilization and frequency Hongyan Xia
2024-03-15 12:31   ` Dietmar Eggemann
2024-03-15 19:47     ` Hongyan Xia [this message]
2024-02-01 13:12 ` [RFC PATCH v2 5/7] sched/fair: Massively simplify util_fits_cpu() Hongyan Xia
2024-02-01 13:12 ` [RFC PATCH v2 6/7] sched/uclamp: Remove all uclamp bucket logic Hongyan Xia
2024-02-01 13:12 ` [RFC PATCH v2 7/7] sched/uclamp: Simplify uclamp_eff_value() Hongyan Xia
2024-02-06 15:20 ` [RFC PATCH v2 0/7] uclamp sum aggregation Qais Yousef
2024-02-06 17:32   ` Hongyan Xia
2024-02-20 15:47     ` Qais Yousef
2024-02-20 22:42       ` Hongyan Xia
2024-02-12  9:16 ` Vincent Guittot
2024-02-12 13:56   ` Hongyan Xia

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=4300a3e5-061d-4daf-b277-631bfc16ff85@arm.com \
    --to=hongyan.xia2@arm.com \
    --cc=bristot@redhat.com \
    --cc=bsegall@google.com \
    --cc=christian.loehle@arm.com \
    --cc=davidai@google.com \
    --cc=dietmar.eggemann@arm.com \
    --cc=juri.lelli@redhat.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-pm@vger.kernel.org \
    --cc=lukasz.luba@arm.com \
    --cc=mgorman@suse.de \
    --cc=mingo@redhat.com \
    --cc=morten.rasmussen@arm.com \
    --cc=peterz@infradead.org \
    --cc=qyousef@layalina.io \
    --cc=rafael@kernel.org \
    --cc=rostedt@goodmis.org \
    --cc=saravanak@google.com \
    --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