From: Peter Zijlstra <peterz@infradead.org>
To: Kuba Piecuch <jpiecuch@google.com>
Cc: Ingo Molnar <mingo@redhat.com>,
Juri Lelli <juri.lelli@redhat.com>,
Vincent Guittot <vincent.guittot@linaro.org>,
Dietmar Eggemann <dietmar.eggemann@arm.com>,
Steven Rostedt <rostedt@goodmis.org>,
Ben Segall <bsegall@google.com>, Mel Gorman <mgorman@suse.de>,
Valentin Schneider <vschneid@redhat.com>,
K Prateek Nayak <kprateek.nayak@amd.com>,
linux-kernel@vger.kernel.org
Subject: Re: [PATCH] sched/core: Skip empty source rqs in try_steal_cookie()
Date: Fri, 27 Nov 2026 10:48:40 +0100 [thread overview]
Message-ID: <20261127094840.GR49833@noisy.programming.kicks-ass.net> (raw)
In-Reply-To: <20261126182255.4146389-1-jpiecuch@google.com>
On Thu, Nov 26, 2026 at 06:24:26PM +0000, Kuba Piecuch wrote:
> sched_core_balance() walks each CPU of each sched domain of a forced-idle
> CPU via steal_cookie_task() -> try_steal_cookie() until a matching-cookie
> task is stolen or need_resched() is set.
>
> try_steal_cookie() disables IRQs and acquires double_rq_lock(dst, src)
> before inspecting @src, even when src->core_tree is empty and no task can
> be stolen from @src. On large machines, a forced-idle balance pass incurs
> many IRQ-off double_rq_lock() rounds and remote rq lock contention for
> nothing.
>
> Return early if src->core_tree is empty via a lockless data_race() peek
> before disabling IRQs and locking both runqueues. Missing a task enqueued
> just after the peek is equivalent to missing one enqueued right after
> releasing the locks; all remaining checks stay under double_rq_lock().
>
> Signed-off-by: Kuba Piecuch <jpiecuch@google.com>
> ---
> This patch was written with the help of an AI coding assistant. I have
> reviewed the patch and verified the tests run by the tool.
*sigh*, so we need AI to write effectively single line patches these
days :-(
Anyway, the whole thing seems sane enough. Thanks!
>
> kernel/sched/core.c | 7 +++++++
> 1 file changed, 7 insertions(+)
>
> diff --git a/kernel/sched/core.c b/kernel/sched/core.c
> index ea89471d4743..dfff7756465f 100644
> --- a/kernel/sched/core.c
> +++ b/kernel/sched/core.c
> @@ -6591,6 +6591,13 @@ static bool try_steal_cookie(int this, int that)
> unsigned long cookie;
> bool success = false;
>
> + /*
> + * Lockless hint: a missed concurrent enqueue is like arriving after
> + * unlock; a concurrent dequeue is caught under double_rq_lock().
> + */
> + if (data_race(RB_EMPTY_ROOT(&src->core_tree)))
> + return false;
> +
> guard(irq)();
> guard(double_rq_lock)(dst, src);
>
>
> base-commit: c47af85667065c6dd5b79564203c2d29948ef60e
> --
> 2.56.1.839.g22a8290db9-goog
>
prev parent reply other threads:[~2026-11-27 9:48 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-26 18:24 [PATCH] sched/core: Skip empty source rqs in try_steal_cookie() Kuba Piecuch
2026-11-27 9:48 ` Peter Zijlstra [this message]
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=20261127094840.GR49833@noisy.programming.kicks-ass.net \
--to=peterz@infradead.org \
--cc=bsegall@google.com \
--cc=dietmar.eggemann@arm.com \
--cc=jpiecuch@google.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=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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.