From: Chengming Zhou <chengming.zhou@linux.dev>
To: Tejun Heo <tj@kernel.org>, Peter Zijlstra <peterz@infradead.org>
Cc: Ingo Molnar <mingo@redhat.com>,
linux-kernel@vger.kernel.org, kernel-team@meta.com,
David Vernet <void@manifault.com>,
K Prateek Nayak <kprateek.nayak@amd.com>
Subject: Re: [PATCH v2 sched_ext/for-6.12] sched/fair: Make balance_fair() test sched_fair_runnable() instead of rq->nr_running
Date: Tue, 6 Aug 2024 09:37:53 +0800 [thread overview]
Message-ID: <cfadf3c5-f504-49ef-b3fc-123e8959d21e@linux.dev> (raw)
In-Reply-To: <ZrFUjlCf7x3TNXB8@slm.duckdns.org>
On 2024/8/6 06:39, Tejun Heo wrote:
> balance_fair() skips newidle balancing if rq->nr_running - there are already
> tasks on the rq, so no need to try to pull tasks. This tests the total
> number of queued tasks on the CPU instead of only the fair class, but is
> still correct as the rq can currently only have fair class tasks while
> balance_fair() is running.
>
> However, with the addition of sched_ext below the fair class, this will not
> hold anymore and make put_prev_task_balance() skip sched_ext's balance()
> incorrectly as, when a CPU has only lower priority class tasks,
> rq->nr_running would still be positive and balance_fair() would return 1
> even when fair doesn't have any tasks to run.
>
> Update balance_fair() to use sched_fair_runnable() which tests
> rq->cfs.nr_running which is updated by bandwidth throttling. Note that
> pick_next_task_fair() already uses sched_fair_runnable() in its optimized
> path for the same purpose.
>
> v2: K Prateek Nayak pointed out that the bw control issue described in v1
> was incorrect. Patch description updated. As this makes the patch only
> relevant for sched_ext, I'll carry this through the sched_ext tree
> unless there are objections.
>
> Signed-off-by: Tejun Heo <tj@kernel.org>
> Reported-by: Peter Zijlstra <peterz@infradead.org>
> Cc: K Prateek Nayak <kprateek.nayak@amd.com>
Looks good to me.
Reviewed-by: Chengming Zhou <chengming.zhou@linux.dev>
Thanks.
> ---
> kernel/sched/fair.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> --- a/kernel/sched/fair.c
> +++ b/kernel/sched/fair.c
> @@ -8323,7 +8323,7 @@ static void set_cpus_allowed_fair(struct
> static int
> balance_fair(struct rq *rq, struct task_struct *prev, struct rq_flags *rf)
> {
> - if (rq->nr_running)
> + if (sched_fair_runnable(rq))
> return 1;
>
> return sched_balance_newidle(rq, rf) != 0;
next prev parent reply other threads:[~2024-08-06 1:38 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-08-03 1:21 [PATCH tip/sched/core] sched/fair: Make balance_fair() test sched_fair_runnable() instead of rq->nr_running Tejun Heo
2024-08-05 3:21 ` K Prateek Nayak
2024-08-05 18:03 ` Tejun Heo
2024-08-05 22:39 ` [PATCH v2 sched_ext/for-6.12] " Tejun Heo
2024-08-06 1:37 ` Chengming Zhou [this message]
2024-08-06 5:26 ` K Prateek Nayak
2024-08-07 10:51 ` [tip: sched/core] " tip-bot2 for Tejun Heo
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=cfadf3c5-f504-49ef-b3fc-123e8959d21e@linux.dev \
--to=chengming.zhou@linux.dev \
--cc=kernel-team@meta.com \
--cc=kprateek.nayak@amd.com \
--cc=linux-kernel@vger.kernel.org \
--cc=mingo@redhat.com \
--cc=peterz@infradead.org \
--cc=tj@kernel.org \
--cc=void@manifault.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