From: Hongyan Xia <hongyan.xia2@arm.com>
To: Dietmar Eggemann <dietmar.eggemann@arm.com>,
Xuewen Yan <xuewen.yan94@gmail.com>
Cc: Ingo Molnar <mingo@redhat.com>,
Peter Zijlstra <peterz@infradead.org>,
Vincent Guittot <vincent.guittot@linaro.org>,
Morten Rasmussen <morten.rasmussen@arm.com>,
Lukasz Luba <lukasz.luba@arm.com>,
Christian Loehle <christian.loehle@arm.com>,
Pierre Gondois <pierre.gondois@arm.com>,
linux-kernel@vger.kernel.org, Xuewen Yan <xuewen.yan@unisoc.com>
Subject: Re: [PATCH v2 0/8] uclamp sum aggregation
Date: Mon, 10 Mar 2025 12:54:58 +0000 [thread overview]
Message-ID: <4a8ed999-2ee5-478c-a759-fec1c496cba9@arm.com> (raw)
In-Reply-To: <13ea9f62-e373-4248-997c-47c15e024c02@arm.com>
On 10/03/2025 11:34, Dietmar Eggemann wrote:
> On 06/03/2025 12:38, Xuewen Yan wrote:
>> On Thu, Mar 6, 2025 at 7:32 PM Hongyan Xia <hongyan.xia2@arm.com> wrote:
>>>
>>> Hi Xuewen,
>>>
>>> On 06/03/2025 11:12, Xuewen Yan wrote:
>>>> Hi Hongyan,
>>>>
>>>> On Tue, Mar 4, 2025 at 10:26 PM Hongyan Xia <hongyan.xia2@arm.com> wrote:
>
> [...]
>
>>>> Subject: [PATCH] sched/uclamp: Update the rq's uclamp before enqueue task
>>>>
>>>> When task's uclamp is set, we hope that the CPU frequency
>>>> can increase as quickly as possible when the task is enqueued.
>>>> Because the cpu frequency updating happens during the enqueue_task(),
>>>> so the rq's uclamp needs to be updated before the task is enqueued.
>>>> For sched-delayed tasks, the rq uclamp should only be updated
>>>> when they are enqueued upon being awakened.
>>>>
>>>> Signed-off-by: Xuewen Yan <xuewen.yan@unisoc.com>
>>>> ---
>>>> kernel/sched/core.c | 14 ++++++--------
>>>> 1 file changed, 6 insertions(+), 8 deletions(-)
>>>>
>>>> diff --git a/kernel/sched/core.c b/kernel/sched/core.c
>>>> index 67189907214d..b07e78910221 100644
>>>> --- a/kernel/sched/core.c
>>>> +++ b/kernel/sched/core.c
>>>> @@ -1747,7 +1747,7 @@ static inline void uclamp_rq_dec_id(struct rq
>>>> *rq, struct task_struct *p,
>>>> }
>>>> }
>>>>
>>>> -static inline void uclamp_rq_inc(struct rq *rq, struct task_struct *p)
>>>> +static inline void uclamp_rq_inc(struct rq *rq, struct task_struct
>>>> *p, int flags)
>>>> {
>>>> enum uclamp_id clamp_id;
>>>>
>>>> @@ -1763,7 +1763,8 @@ static inline void uclamp_rq_inc(struct rq *rq,
>>>> struct task_struct *p)
>>>> if (unlikely(!p->sched_class->uclamp_enabled))
>>>> return;
>>>>
>>>> - if (p->se.sched_delayed)
>>>> + /* Only inc the delayed task which is being woken up. */
>>>> + if (p->se.sched_delayed && !(flags & ENQUEUE_DELAYED))
>>>> return;
>>>>
>>>> for_each_clamp_id(clamp_id)
>>>> @@ -2031,7 +2032,7 @@ static void __init init_uclamp(void)
>>>> }
>>>>
>>>> #else /* !CONFIG_UCLAMP_TASK */
>>>> -static inline void uclamp_rq_inc(struct rq *rq, struct task_struct *p) { }
>>>> +static inline void uclamp_rq_inc(struct rq *rq, struct task_struct
>>>> *p, int flags) { }
>>>> static inline void uclamp_rq_dec(struct rq *rq, struct task_struct *p) { }
>>>> static inline void uclamp_fork(struct task_struct *p) { }
>>>> static inline void uclamp_post_fork(struct task_struct *p) { }
>>>> @@ -2067,12 +2068,9 @@ void enqueue_task(struct rq *rq, struct
>>>> task_struct *p, int flags)
>>>> if (!(flags & ENQUEUE_NOCLOCK))
>>>> update_rq_clock(rq);
>>>>
>>>> + uclamp_rq_inc(rq, p, flags);
>>>> +
>>>> p->sched_class->enqueue_task(rq, p, flags);
>>>> - /*
>>>> - * Must be after ->enqueue_task() because ENQUEUE_DELAYED can clear
>>>> - * ->sched_delayed.
>>>> - */
>>>> - uclamp_rq_inc(rq, p);
>>>>
>>>> psi_enqueue(p, flags);
>
> Like I mentioned already in the original thread:
>
> https://lkml.kernel.org/r/65365ec7-6a16-4e66-8005-e78788cbedfa@arm.com
>
> I would prefer that uclamp stays in core.c. ENQUEUE_DELAYED among all
> the other flags is already used there (ttwu_runnable()).
>
> task_struct contains sched_{,rt_,dl_}entity}. We just have to be
> careful when switching policies.
>
> --
>
> Could you also incorporate the changes in {en,de}queue_task_fair()
> ((task_on_rq_migrating(p) || (flags & {RESTORE,DEQUEUE}_SAVE))) vs.
> (!p->se.sched_delayed || (flags & ENQUEUE_DELAYED)) and
> (!p->se.sched_delayed) so the uclamp-util_est relation is easier to spot?
>
> [...]
At the moment we can't do this. Sum aggregation was designed before
delayed dequeue and it syncs with p->se.on_rq. If we sync with something
else and take care of delayed dequeue cases (like util_est) then I have
to rewrite part of the series.
next prev parent reply other threads:[~2025-03-10 12:55 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-03-04 14:23 Hongyan Xia
2025-03-04 14:23 ` [PATCH v2 1/8] Revert "sched/uclamp: Set max_spare_cap_cpu even if max_spare_cap is 0" Hongyan Xia
2025-03-04 14:23 ` [PATCH v2 2/8] sched/uclamp: Track a new util_avg_bias signal Hongyan Xia
2025-03-04 14:23 ` [PATCH v2 3/8] sched/uclamp: Add util_est_uclamp Hongyan Xia
2025-03-04 14:23 ` [PATCH v2 4/8] sched/fair: Use util biases for utilization and frequency Hongyan Xia
2025-03-04 14:23 ` [PATCH v2 5/8] sched/uclamp: Remove all uclamp bucket logic Hongyan Xia
2025-03-04 14:23 ` [PATCH v2 6/8] sched/uclamp: Simplify uclamp_eff_value() Hongyan Xia
2025-03-04 14:23 ` [PATCH v2 7/8] sched/uclamp: Propagate negative bias Hongyan Xia
2025-03-04 14:23 ` [PATCH v2 8/8] sched/uclamp: Solve under-utilization problem Hongyan Xia
2025-03-06 11:12 ` [PATCH v2 0/8] uclamp sum aggregation Xuewen Yan
2025-03-06 11:32 ` Hongyan Xia
2025-03-06 11:38 ` Xuewen Yan
2025-03-10 11:34 ` Dietmar Eggemann
2025-03-10 12:54 ` Hongyan Xia [this message]
2025-03-10 15:37 ` Dietmar Eggemann
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=4a8ed999-2ee5-478c-a759-fec1c496cba9@arm.com \
--to=hongyan.xia2@arm.com \
--cc=christian.loehle@arm.com \
--cc=dietmar.eggemann@arm.com \
--cc=linux-kernel@vger.kernel.org \
--cc=lukasz.luba@arm.com \
--cc=mingo@redhat.com \
--cc=morten.rasmussen@arm.com \
--cc=peterz@infradead.org \
--cc=pierre.gondois@arm.com \
--cc=vincent.guittot@linaro.org \
--cc=xuewen.yan94@gmail.com \
--cc=xuewen.yan@unisoc.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
all inboxes | Powered by JetHome®