mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
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 00/16][PoC] sched/core: Alternate approach to sleeping-owner handling in PROXY_EXEC
Date: Wed, 16 Sep 2026 11:40:40 +0530	[thread overview]
Message-ID: <a367d70f-a095-419f-83e8-5d7458204f3d@amd.com> (raw)
In-Reply-To: <CANDhNCpEYgckCPYhjL8oQGYv9r8joP_1tBps4bGQFD3vWDCetA@mail.gmail.com>

Hello John,

On 9/16/2026 10:52 AM, John Stultz wrote:
> On Tue, Aug 25, 2026 at 11:29 PM K Prateek Nayak <kprateek.nayak@amd.com> wrote:
>>
>> I had promised John I would share an insane idea if I got it
>> working(ish) so this RFC presents an alternate approach to handle
>> enqueued donor wakeup vs owner's chain-wakeup race via ttwu_runnable()
>> path and make the activate path as light as possible for tasks that
>> don't need to do a chain wakeup.
>>
>> The series essentially breaks down John's large patch at
>> https://lore.kernel.org/lkml/20260807035232.1881495-9-jstultz@google.com/
>> into smaller chunks while introducing the new approach and fixing a few
>> snags encountered along the way (Patch 1 - Patch 4 are fixes that can be
>> discussed without getting into the rest of the RFC).
>>
>> Disclaimer: Series in not bisectible in any way at the moment - related
>> bits are introduced together at and intermediate builds may fail.
>>
>> Introduction
>> ============
>>
>> Handling sleeping owner requires proxy-chains to queue on the said owner
>> and perform a chain activation when the blocked owner wakes up.
>>
>> Since a blocked donor can be woken up by another concurrent wake event,
>> the activation path becomes complicated and wakeup has to take an extra
>> lock (p->blocked_lock) to prevent any modifications to "p->blocked_head"
>> and miss activating any blocked donors.
>>
> ...
>> Trade-off
>> =========
>>
>> Advantages:
>>
>> o Only need to juggle blocked_lock(s) under a single rq_lock().
>> o Re-use ttwu_runnable bit to handle removal of proxy donor.
>> o No need to do get_task_stuct() / put_task_struct() juggling.
>>
>> Disadvantages:
>>
>> o Possible increased rq_lock contention on the chain-wakeup path but
>>   those events are generally rare.
>> o Lack of delayed task handling since the src_rq need to be locked
>>   separately to migrate it.
>>
>> For the delayed handling, it is possible to use proxy_migrate_task() to
>> move the task after blocking. Series does not implement this yet to
>> limit the number of bad ideas.
>>
> 
> Sorry again for being so slow to respond here!
> 
> The series definitely looks interesting, and it seems to be holding up
> ok in testing.  Though figuring out how to refactor them so that they
> are also bisectable looks like a real challenge (part of why my
> sleeping-owner enqueuing is basically one big patch)!
> 
> That said, I can't say I've truly gotten my head fully around your
> series yet. I've definitely had way more time with my change, so I'm a
> little biased in feeling its somewhat more bounded (even though the
> activate_blocked_waiters() function and the multiple lists of tasks
> are very complicated).
> 
> My initial sense of the downsides here with your series are: It adds a
> lot of new per-task state (blocked_cpu, is_linked/needs_rq_sync,
> sched_migrated_on_blocking, lock_nesting) to keep track of, and some
> of rules for the new state have dependencies
> (sched_migrated_on_blocking is tied to is_linked), and leveraging the
> ENQUEUE/DEQUEUE_MIGRATING flags feels a little subtle (I have often
> gotten the ENQUEUE/DEQUEUE flags wrong in my patch series, and
> unfortunately the general documentation around those flags is lagging
> a bit, so this adds to it).
> 
> The locking being simpler is a clear benefit and definitely sound
> appealing - though I do agree the rq_lock hold time in
> proxy_activate_blocked_task() seems like it might be an issue.

Ack! My original thinking was it is only done in the slow-path and
is only held for a few ->on_rq and list manipulations so I might be
able to get away with that small overhead.

> 
> I've got a few more questions on specific patches, so I'll reply there.

Looking forward to those.

> Again, it definitely is interesting and appears to be more integrated
> into the scheduler logic, so I'd expect that will give us better
> results then my maybe more isolated and tacked on activation logic.
> 
> Have you gotten a sense of what Peter thinks of it?

I think Peter is slowly getting through the more stable stuff first
and may arrive at this at some point but I'll try to get a word in
at LPC if he is planning on attending.

That said, knowing Peter, I have a hunch he might like your approach
better since it handles delayed tasks too (tasks may be eligible at the
time of chain-wakeup), does not add stuff into ttwu_runnable(), and does
not have the insane (DEQUEUE_SLEEP | DEQUEUE_MIGRATING) behavior which
has larger implications for PELT tracking and SCHED_DEADLINE.

I sent out the RFC since it makes for an interesting discussion but I
have a feeling lot more things need ironing out if w go this way but
I can always do it later after the stuff from you and Suleiman lands
once I can prove some benefit.

-- 
Thanks and Regards,
Prateek


  reply	other threads:[~2026-09-16  6:10 UTC|newest]

Thread overview: 35+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-08-26  6:28 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
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 [this message]
2026-09-16  6:23     ` John Stultz
2026-09-16  6:59       ` K Prateek Nayak
2026-09-16 17:57   ` John Stultz

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=a367d70f-a095-419f-83e8-5d7458204f3d@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®