mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: K Prateek Nayak <kprateek.nayak@amd.com>
To: Joel Fernandes <joelagnelf@nvidia.com>
Cc: Peter Zijlstra <peterz@infradead.org>,
	Vincent Guittot <vincent.guittot@linaro.org>,
	"paulmck@kernel.org" <paulmck@kernel.org>,
	Ingo Molnar <mingo@redhat.com>,
	Juri Lelli <juri.lelli@redhat.com>,
	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>,
	"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
	"kernel-team@meta.com" <kernel-team@meta.com>
Subject: Re: [BUG] Apparent lost wakeups
Date: Tue, 13 Oct 2026 19:30:53 +0530	[thread overview]
Message-ID: <0007c8a5-7175-487b-a927-37ae7a52094c@amd.com> (raw)
In-Reply-To: <41BA40C2-AC25-4339-8607-4A45BD4ED87C@nvidia.com>

Hello Joel,

On 10/13/2026 6:19 PM, Joel Fernandes wrote:
> Quick question - with that fix, is there a possibility of a live lock if the sched loop keeps restarting because another CPU kept toggling RT?

__schedule() only drops rq_lock for two activities:

1. Within sched class' balance callback: This is done from all classes
   from donor's sched class to below. Once a task is found by the
   balance callback, we break out of prev_balance() and jump straight
   to pick so something is guaranteed to be there.

   All balance callbacks use double_rq_lock() so we are guaranteed to
   move the task from a source rq.

2. For newidle balance: When no tasks exists on rq, fair class will do
   a newidle balance to try find a task and prevent the need to switch
   to idle tasks.

   If a fair task is found or woken up, the retry is limited to idle
   class. If a higher priority task is woken up, we do a full re-pick
   starting from top.


Now, in theory, there is a possibility where:

1. rq->donor is a high priority RT task that went to sleep.

2. Lower priority RT tasks (>= 2) wakeup on the same CPU during
   newidle balance. A retry is triggered.

3. balance_rt() triggers a pull because the newly woken tasks have a
   lower priority than rq->donor which went to sleep.

4. pull_rt_task() drops rq_lock during double_rq_lock_balance()

5. A different rq gets lock first and moves the RT tasks away.

6. double_rq_lock_balance() returns, finds no task to push, and
   eventually __schedule() goes to pick.

7. Fair class' pick triggers newidle balance and jump to step 2.


I'm not sure if there is a safeguard for this case where the CPU
can get stuck looping in pick_next_task() but chances of triggering
it is small (albeit not zero). This can happen even without the
changes from this patch.

Maybe I'm missing something and Peter can enlighten why this is
all impossible :-)

-- 
Thanks and Regards,
Prateek


  reply	other threads:[~2026-10-13 14:01 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-10-13 12:49 Joel Fernandes
2026-10-13 14:00 ` K Prateek Nayak [this message]
  -- strict thread matches above, loose matches on Subject: below --
2026-10-12 18:41 Paul E. McKenney
2026-10-13  6:06 ` K Prateek Nayak
2026-10-13  6:46   ` K Prateek Nayak
2026-10-13  7:58     ` Vincent Guittot
2026-10-13  8:30       ` K Prateek Nayak
2026-10-13  8:36         ` Vincent Guittot
2026-10-13 10:14       ` Peter Zijlstra
2026-10-13 10:29         ` K Prateek Nayak
2026-10-13 10:37           ` Peter Zijlstra
2026-10-13 10:43             ` K Prateek Nayak
2026-10-13 10:06     ` Peter Zijlstra

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=0007c8a5-7175-487b-a927-37ae7a52094c@amd.com \
    --to=kprateek.nayak@amd.com \
    --cc=bsegall@google.com \
    --cc=dietmar.eggemann@arm.com \
    --cc=joelagnelf@nvidia.com \
    --cc=juri.lelli@redhat.com \
    --cc=kernel-team@meta.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mgorman@suse.de \
    --cc=mingo@redhat.com \
    --cc=paulmck@kernel.org \
    --cc=peterz@infradead.org \
    --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 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®