public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: K Prateek Nayak <kprateek.nayak@amd.com>
To: John Stultz <jstultz@google.com>, Peter Zijlstra <peterz@infradead.org>
Cc: LKML <linux-kernel@vger.kernel.org>,
	Vineeth Pillai <vineethrp@google.com>,
	Sonam Sanju <sonam.sanju@intel.com>,
	"Sean Christopherson" <seanjc@google.com>,
	Kunwu Chan <kunwu.chan@linux.dev>, "Tejun Heo" <tj@kernel.org>,
	Joel Fernandes <joelagnelf@nvidia.com>,
	Qais Yousef <qyousef@layalina.io>, Ingo Molnar <mingo@redhat.com>,
	Juri Lelli <juri.lelli@redhat.com>,
	Vincent Guittot <vincent.guittot@linaro.org>,
	Dietmar Eggemann <dietmar.eggemann@arm.com>,
	Valentin Schneider <vschneid@redhat.com>,
	Steven Rostedt <rostedt@goodmis.org>,
	Will Deacon <will@kernel.org>, Waiman Long <longman@redhat.com>,
	Boqun Feng <boqun.feng@gmail.com>,
	"Paul E. McKenney" <paulmck@kernel.org>,
	Metin Kaya <Metin.Kaya@arm.com>,
	Xuewen Yan <xuewen.yan94@gmail.com>,
	Thomas Gleixner <tglx@linutronix.de>,
	Daniel Lezcano <daniel.lezcano@linaro.org>,
	"Suleiman Souhlal" <suleiman@google.com>,
	kuyo chang <kuyo.chang@mediatek.com>, hupu <hupu.gm@gmail.com>,
	<kernel-team@android.com>
Subject: Re: [PATCH 1/2] sched: proxy-exec: Close race causing workqueue work being delayed
Date: Fri, 1 May 2026 11:27:21 +0530	[thread overview]
Message-ID: <9f39560d-c4f5-407a-9afe-48a78ad69159@amd.com> (raw)
In-Reply-To: <CANDhNCrBSNeX6-YDJ-xpvQ4Z093=Qy53cQySRFWrE__oW9uQUw@mail.gmail.com>

Hello John,

On 5/1/2026 2:10 AM, John Stultz wrote:
>> Any wait for non-special states that is not a loop is fundamentally
>> broken, since many of the lock wake-up paths are explicitly racy in that
>> they can cause spurious wakeups (which is the safe side of the race,
>> since insufficient wakeups is bad etc.).
>>
>> OTOH special states, are special, esp. because they cannot handle
>> spurious wakeups.
>>
>> Eg, consider something like:
>>
>>         set_current_state(TASK_FROZEN)
>>         <PREEMPT>
>>           current->__state = TASK_RUNNING
>>         </PREEMPT/
>>         schedule();
>>
>> is all sorts of broken. Now, obiously special states must never have
>> blocked_on set, so this can be fudged about. But still, touching __state
>> from schedule seems wrong.
> 
> Hey Peter,
>   Thanks again for the background here and the alternative proposal
> that K Prateek and I have iterated on.
> 
> I did want to clarify one case here just for my understanding. The
> approach in this first proposal was sort of leaning on the similar
> pattern in the signal_pending_state() case in try_to_block_task().  Is
> that just a hard exception to the rule here?

signal_pending_state() looks at the task_state only at a SM_NONE /
SM_RTLOCK_WAIT preemption point before making a call and only sets to
TASK_RUNNING if the state is (TASK_INTERRUPTIBLE | TASK_WAKEKILL) and
there is a signal pending. All the wakeups for that are routed through

Everything outside that state and coming from a SM_PREEMPT path will
leave the task state untouched in __schedule() until it hits the
natural SM_NONE / SM_RTLOCK_WAIT preemption point.

Only looking at ->blocked_on, and not the prev_state to set prev to
TASK_RUNNING can be dangerous. That said, it would be stupid for a
task to sets a special state and decide to grab a mutex which
overrides the state.

With the latch design, we are more or less aligned with something
similar to signal_pending_state() that looks at the tasks state from
a safe preemption point.

-- 
Thanks and Regards,
Prateek


  reply	other threads:[~2026-05-01  5:57 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-04-27 18:38 [PATCH 0/2] Proxy Execution fixes for v7.1-rc John Stultz
2026-04-27 18:38 ` [PATCH 1/2] sched: proxy-exec: Close race causing workqueue work being delayed John Stultz
2026-04-28  8:06   ` K Prateek Nayak
2026-04-28  9:43   ` Peter Zijlstra
2026-04-28 11:18     ` Peter Zijlstra
2026-04-28 13:15       ` K Prateek Nayak
2026-04-28 14:12         ` K Prateek Nayak
2026-04-28 16:50         ` Peter Zijlstra
2026-04-29  2:27         ` John Stultz
2026-04-29  8:59           ` K Prateek Nayak
2026-04-30  5:44             ` John Stultz
2026-04-30  5:47               ` John Stultz
2026-04-30  7:25               ` K Prateek Nayak
2026-04-30 21:05                 ` John Stultz
2026-04-30 20:40       ` John Stultz
2026-05-01  5:57         ` K Prateek Nayak [this message]
2026-04-27 18:38 ` [PATCH 2/2] locking: mutex: Fix proxy-exec potentially deactivating tasks marked TASK_RUNNING John Stultz
2026-04-28  8:16   ` K Prateek Nayak
2026-04-28 19:50     ` John Stultz
2026-04-30  9:56 ` [PATCH 0/2] Proxy Execution fixes for v7.1-rc Kunwu Chan

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=9f39560d-c4f5-407a-9afe-48a78ad69159@amd.com \
    --to=kprateek.nayak@amd.com \
    --cc=Metin.Kaya@arm.com \
    --cc=boqun.feng@gmail.com \
    --cc=daniel.lezcano@linaro.org \
    --cc=dietmar.eggemann@arm.com \
    --cc=hupu.gm@gmail.com \
    --cc=joelagnelf@nvidia.com \
    --cc=jstultz@google.com \
    --cc=juri.lelli@redhat.com \
    --cc=kernel-team@android.com \
    --cc=kunwu.chan@linux.dev \
    --cc=kuyo.chang@mediatek.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=longman@redhat.com \
    --cc=mingo@redhat.com \
    --cc=paulmck@kernel.org \
    --cc=peterz@infradead.org \
    --cc=qyousef@layalina.io \
    --cc=rostedt@goodmis.org \
    --cc=seanjc@google.com \
    --cc=sonam.sanju@intel.com \
    --cc=suleiman@google.com \
    --cc=tglx@linutronix.de \
    --cc=tj@kernel.org \
    --cc=vincent.guittot@linaro.org \
    --cc=vineethrp@google.com \
    --cc=vschneid@redhat.com \
    --cc=will@kernel.org \
    --cc=xuewen.yan94@gmail.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