From: "Aiqun(Maria) Yu" <aiqun.yu@oss.qualcomm.com>
To: Xin Zhao <jackzxcui1989@163.com>, vschneid@redhat.com
Cc: bsegall@google.com, dietmar.eggemann@arm.com,
juri.lelli@redhat.com, kprateek.nayak@amd.com,
linux-kernel@vger.kernel.org, mgorman@suse.de, mingo@redhat.com,
peterz@infradead.org, rostedt@goodmis.org,
vincent.guittot@linaro.org
Subject: Re: [PATCH v3 1/2] sched/fair: Don't trigger active lb if src_rq->curr is CFS and not on_rq
Date: Tue, 16 Jun 2026 11:06:54 +0800 [thread overview]
Message-ID: <ea5aedcb-487d-4f4e-98fd-f98e83f0fe32@oss.qualcomm.com> (raw)
In-Reply-To: <20260615140900.3913018-1-jackzxcui1989@163.com>
On 6/15/2026 10:09 PM, Xin Zhao wrote:
> On Mon, 15 Jun 2026 15:39:22 +0200 Valentin Schneider <vschneid@redhat.com> wrote:
>
>>> @@ -13436,7 +13436,9 @@ static int sched_balance_rq(int this_cpu, struct rq *this_rq,
>>> * ->active_balance_work. Once set, it's cleared
>>> * only after active load balance is finished.
>>> */
>>> - if (!busiest->active_balance) {
>>> + if (!busiest->active_balance &&
>>> + !(busiest->curr->sched_class == &fair_sched_class &&
>>> + !busiest->curr->on_rq)) {
>>
>> This should be commented; I restructured this a little, it's one more label
>> but it reads better to me, what do you think?
>
> :) Thank you for your changes; it looks much better now, and the necessary
> comments have been added.
This format looks better.
>
>> ---
>> diff --git a/kernel/sched/fair.c b/kernel/sched/fair.c
>> index d78467ec6ee13..a0ac31a3be988 100644
>> --- a/kernel/sched/fair.c
>> +++ b/kernel/sched/fair.c
>> @@ -13482,12 +13482,22 @@ static int sched_balance_rq(int this_cpu, struct rq *this_rq,
>> * ->active_balance_work. Once set, it's cleared
>> * only after active load balance is finished.
>> */
>> - if (!busiest->active_balance) {
>> - busiest->active_balance = 1;
>> - busiest->push_cpu = this_cpu;
>> - active_balance = 1;
>> - }
>> + if (busiest->active_balance)
>> + goto no_active_balance;
>>
>> + /*
>> + * @busiest dropped its rq_lock in the middle of
>> + * scheduling out its ->curr task (->on_rq := 0), no
>> + * need to forcefully punt it away with active balance.
>> + */
>> + if ((busiest->curr->sched_class == &fair_sched_class) &&
>> + !busiest->curr->on_rq)
Still have the doubt why need to do active load balance when the current
is not CFS. And busiest->curr->on_rq==0 case only.
Is it should be like:
if ((busiest->curr->sched_class == &fair_sched_class) ||
unlikely(!task_on_rq_queued(busiest->curr)));
if busiest->curr->on_rq==2 (TASK_ON_RQ_MIGRATING), it is no need to do
active_balance as well.
>> + goto no_active_balance;
>> +
>> + busiest->active_balance = 1;
>> + busiest->push_cpu = this_cpu;
>> + active_balance = 1;
>> +no_active_balance:
>> preempt_disable();
>> raw_spin_rq_unlock_irqrestore(busiest, flags);
>> if (active_balance) {
>
> Thanks
> Xin Zhao
>
--
Thx and BRs,
Aiqun(Maria) Yu
next prev parent reply other threads:[~2026-06-16 3:07 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-06-15 5:38 [PATCH v3 0/2] sched/fair: Optimize some active balance logic Xin Zhao
2026-06-15 5:38 ` [PATCH v3 1/2] sched/fair: Don't trigger active lb if src_rq->curr is CFS and not on_rq Xin Zhao
2026-06-15 13:39 ` Valentin Schneider
2026-06-15 13:57 ` Phil Auld
2026-06-15 14:09 ` Xin Zhao
2026-06-16 3:06 ` Aiqun(Maria) Yu [this message]
2026-06-16 4:07 ` Xin Zhao
2026-06-15 5:38 ` [PATCH v3 2/2] sched/fair: Simplify balance_interval reset logic in sched_balance_rq() Xin Zhao
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=ea5aedcb-487d-4f4e-98fd-f98e83f0fe32@oss.qualcomm.com \
--to=aiqun.yu@oss.qualcomm.com \
--cc=bsegall@google.com \
--cc=dietmar.eggemann@arm.com \
--cc=jackzxcui1989@163.com \
--cc=juri.lelli@redhat.com \
--cc=kprateek.nayak@amd.com \
--cc=linux-kernel@vger.kernel.org \
--cc=mgorman@suse.de \
--cc=mingo@redhat.com \
--cc=peterz@infradead.org \
--cc=rostedt@goodmis.org \
--cc=vincent.guittot@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
all inboxes | Powered by JetHome®