From: K Prateek Nayak <kprateek.nayak@amd.com>
To: John Stultz <jstultz@google.com>
Cc: Suleiman Souhlal <suleiman@google.com>,
Ingo Molnar <mingo@redhat.com>,
Peter Zijlstra <peterz@infradead.org>,
Juri Lelli <juri.lelli@redhat.com>,
Vincent Guittot <vincent.guittot@linaro.org>,
Will Deacon <will@kernel.org>, Boqun Feng <boqun@kernel.org>,
Andrea Righi <arighi@nvidia.com>, <linux-kernel@vger.kernel.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>,
Waiman Long <longman@redhat.com>
Subject: Re: [RFC PATCH 09/16] sched/core: Track CPU where the task was blocked on
Date: Wed, 16 Sep 2026 11:59:29 +0530 [thread overview]
Message-ID: <a43db121-1a12-49c5-8df1-574f57af6d01@amd.com> (raw)
In-Reply-To: <CANDhNCrWKd_p5H2Cc0uEooD9-kU0a4e=GrFhpVA1cDyz9M2mOw@mail.gmail.com>
Hello John,
On 9/16/2026 11:22 AM, John Stultz wrote:
> On Tue, Aug 25, 2026 at 11:32 PM K Prateek Nayak <kprateek.nayak@amd.com> wrote:
>>
>> Track the CPU where task was blocked on when running with
>> sched_proxy_exec().
>>
>> This is used to re-direct the activation of blocked donors queued on the
>> blocked_head via the said CPU in the activation slowpath that will be
>> added in the subsequent patches.
>
> I'm a little confused on this, as the cpu the task was blocked on
> doesn't intuitively have much bearing on where we'd want to activate
> it, when a sleeping owner wakes up.
>
> When a lock owner sleeps, all the chains of tasks waiting on that lock
> (directly or not), will be enqueued on that sleeping owner.
>
> In my patch, when the sleeping owner wakes up, it may or may not wake
> up on the cpu it was dequeued from. It seems we would want to enqueue
> all of those blocked tasks onto the same runqueue where we activated
> the owner, so they are all present on the same rq to be selected as a
> donor to potentially run the owner and release the lock.
>
> Since its like there is a likely chance the sleeping owner will wake
> elsewhere (It looks like proxy_activate_blocked_task() in the later
> patch effectively overrides the activation on the given rq and instead
> wakes the tasks on the blocked_cpu), won't this end up activating the
> chain of blocked waiters on the wrong cpu (forcing them all to be
> immediately proxy migrated over)?
The base concept is this: When the task is blocked and is queued on a
sleeping owner (p->is_linked = 1), the whole chain is linked to one
CPU (p->blocked_cpu).
This is why, later, in Patch 13, we block with (SLEEP | MIGRATING),
and do __set_task_cpu() to owner->blocked_cpu before we transition
p->on_rq to 0.
Entire chain is linked to the p->blocked_cpu of the top level sleeping
owner.
p->wake_cpu can change (more on that below) when task is fully blocked
(p->on_rq = 0) but we *need* to have one unified CPU for the entire
chain to resume wakeup from which is why we need a second variable.
For ->is_linked tasks, any state transition (p->on_rq transitions) are
guarded by p->blocked_cpu's rq_lock() and that *cannot* change until
the owner's wakeup in proxy_activate_task() is finished.
Any external wakeup in ttwu_runnable() for p->on_rq = 0 &&
p->is_linked = 1 should go via "p->blocked_cpu". Same for all the
guard(sched_change) stuff.
Also since we do a:
set_task_cpu(owner, cpu);
ttwu_do_activate(rq, owner, flags);
we cannot simply look at task_cpu(owner) in ttwu_do_activate() to
know where the donor-chain resides. We need the p->blocked_cpu.
>> p->wake_cpu or task_cpu() is not sufficient for this purpose since
>> p->wake_cpu is not stable when !task_on_rq_queued() and there is a
>> window between set_task_cpu() and activet_blocked_task() in the wakeup
>> path that needs to be plugged in.
>
> Sorry if I'm being dim here.
>
> Do you have more details on this? Was my patch prone to the same issue
> you're avoiding in the second item here?
I think NUMA balancing and workqueue have cases where only p->wake_cpu
can be manipulated to direct wakeup of a blocked task but it is only
done when p->on_rq is 0 and p->wake_cpu is always changed to a CPU
within the task's affinity boundary so your series does not have a
problem.
Only because this RFC's approach needs to track which CPU has the
ownership of the entire chain, I need a second variable.
--
Thanks and Regards,
Prateek
next prev parent reply other threads:[~2026-09-16 6:29 UTC|newest]
Thread overview: 34+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-08-26 6:28 [RFC PATCH 00/16][PoC] sched/core: Alternate approach to sleeping-owner handling in PROXY_EXEC K Prateek Nayak
2026-08-26 6:28 ` [RFC PATCH 01/16] sched/core: Break activation of blocked task into a separate helper K Prateek Nayak
2026-08-26 6:28 ` [RFC PATCH 02/16] sched/core: Use enqueue/dequeue flags instead of task_on_rq_migrating() K Prateek Nayak
2026-08-26 6:28 ` [RFC PATCH 03/16] sched/fair: Use enqueue flags for DO_ATTACH in update_load_avg() K Prateek Nayak
2026-08-26 15:36 ` Andrea Righi
2026-08-26 6:28 ` [RFC PATCH 04/16] sched/core: Activate blocked donor when no owner is found K Prateek Nayak
2026-08-26 15:56 ` Andrea Righi
2026-08-26 17:20 ` K Prateek Nayak
2026-08-28 6:04 ` K Prateek Nayak
2026-08-31 15:07 ` Andrea Righi
2026-09-16 4:16 ` K Prateek Nayak
2026-09-16 3:29 ` John Stultz
2026-09-16 4:16 ` K Prateek Nayak
2026-08-26 6:28 ` [RFC PATCH 05/16] sched/core: Do not queue blocked donor on a delayed owner K Prateek Nayak
2026-08-26 6:28 ` [RFC PATCH 06/16] sched/core: Queue blocked donor onto sleeping owner for chain-wakeup K Prateek Nayak
2026-08-26 16:20 ` Andrea Righi
2026-08-27 3:51 ` K Prateek Nayak
2026-08-26 6:28 ` [RFC PATCH 07/16] sched/core: Avoid delaying blocked donors queued on sleeping owner K Prateek Nayak
2026-08-26 6:28 ` [RFC PATCH 08/16] sched/deadline: Prepare for blocking and proxy activation with MIGRATING flag K Prateek Nayak
2026-08-26 6:28 ` [RFC PATCH 09/16] sched/core: Track CPU where the task was blocked on K Prateek Nayak
2026-09-16 5:52 ` John Stultz
2026-09-16 6:29 ` K Prateek Nayak [this message]
2026-08-26 6:28 ` [RFC PATCH 10/16] sched/core: Introduce p->is_linked to track if task is queued on sleeping owner K Prateek Nayak
2026-08-26 6:28 ` [RFC PATCH 11/16] sched/core: Prepare to inspect ->is_linked alongside ->on_rq during wakeup K Prateek Nayak
2026-08-26 6:28 ` [RFC PATCH 12/16] sched:core: Add MIGRATING flags when blocking and activating linked donors K Prateek Nayak
2026-08-26 6:28 ` [RFC PATCH 13/16] sched/core: Use p->is_linked state to unlink from sleeping owner early K Prateek Nayak
2026-08-26 6:28 ` [RFC PATCH 14/16] sched/core: Introduce chain-wakeup to activate blocked donors K Prateek Nayak
2026-09-15 5:48 ` John Stultz
2026-08-26 6:28 ` [RFC PATCH 15/16] locking/mutex: Track locks owned by a task in a per-task counter K Prateek Nayak
2026-08-26 6:29 ` [RFC PATCH 16/16] sched/core: Set activation of non lock-holders to fast-path K Prateek Nayak
2026-09-16 5:22 ` [RFC PATCH 00/16][PoC] sched/core: Alternate approach to sleeping-owner handling in PROXY_EXEC John Stultz
2026-09-16 6:10 ` K Prateek Nayak
2026-09-16 6:23 ` John Stultz
2026-09-16 6:59 ` K Prateek Nayak
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=a43db121-1a12-49c5-8df1-574f57af6d01@amd.com \
--to=kprateek.nayak@amd.com \
--cc=arighi@nvidia.com \
--cc=boqun@kernel.org \
--cc=bsegall@google.com \
--cc=dietmar.eggemann@arm.com \
--cc=jstultz@google.com \
--cc=juri.lelli@redhat.com \
--cc=linux-kernel@vger.kernel.org \
--cc=longman@redhat.com \
--cc=mgorman@suse.de \
--cc=mingo@redhat.com \
--cc=peterz@infradead.org \
--cc=rostedt@goodmis.org \
--cc=suleiman@google.com \
--cc=vincent.guittot@linaro.org \
--cc=vschneid@redhat.com \
--cc=will@kernel.org \
/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®