mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Peter Zijlstra <peterz@infradead.org>
To: K Prateek Nayak <kprateek.nayak@amd.com>
Cc: paulmck@kernel.org, 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>,
	Joel Fernandes <joelagnelf@nvidia.com>,
	linux-kernel@vger.kernel.org, kernel-team@meta.com
Subject: Re: [BUG] Apparent lost wakeups
Date: Tue, 13 Oct 2026 12:06:25 +0200	[thread overview]
Message-ID: <20261013100625.GF2009045@noisy.programming.kicks-ass.net> (raw)
In-Reply-To: <69622916-cc8a-44d5-b776-6e25f79aceda@amd.com>

On Tue, Oct 13, 2026 at 12:16:11PM +0530, K Prateek Nayak wrote:
> On 10/13/2026 11:36 AM, K Prateek Nayak wrote:
> >> The following command reproduces the lost-wakeup problem, which shows
> >> up as RCU CPU stall warnings caused by rcu_torture_reader() kthreads:
> >>
> >> tools/testing/selftests/rcutorture/bin/kvm.sh --allcpus --duration 20m --configs '19*TREE01' --bootargs "nohz=off rcutorture.onoff_interval=0 rcutorture.nocbs_nthreads=0 rcutorture.shuffle_interval=0" --trust-make
> > 
> > tl;dr
> > 
> > I could hit that WARN_ON() from your debug patch with the above test
> > even under rq_lock. Seemed like a missing resched_curr() but it
> > turned out to also be related to rq->next_class interaction.
> > 
> > I haven't been able to hit the warnings with the below diff. Could
> > you please try this:
> > 
> > diff --git a/kernel/sched/core.c b/kernel/sched/core.c
> > index 0f63c30b4324..f2f8af3cdfb5 100644
> > --- a/kernel/sched/core.c
> > +++ b/kernel/sched/core.c
> > @@ -11239,6 +11245,11 @@ void sched_change_end(struct sched_change_ctx *ctx)
> >  		if (p->sched_class->switched_to)
> >  			p->sched_class->switched_to(rq, p);
> >  
> > +		if (ctx->queued && sched_class_above(p->sched_class, rq->next_class)) {
> > +			rq->next_class = p->sched_class;
> > +			resched_curr(rq);
> > +		}
> > +
> >  		if (ctx->running) {
> >  			/*
> >  			 * If this was a class promotion; let the old class
> > ---
> 
> And now that I've finally woken up just like that task, it can be
> simplified to:
> 
> diff --git a/kernel/sched/core.c b/kernel/sched/core.c
> index 0f63c30b4324..b37c771c41ad 100644
> --- a/kernel/sched/core.c
> +++ b/kernel/sched/core.c
> @@ -11256,6 +11262,9 @@ void sched_change_end(struct sched_change_ctx *ctx)
>  			 */
>  			if (sched_class_above(ctx->class, p->sched_class))
>  				resched_curr(rq);
> +		} else if (ctx->queued) {
> +			/* Check if we need can preempt the current task. */
> +			wakeup_preempt(rq, p, 0);
>  		}
>  	} else {
>  		p->sched_class->prio_changed(rq, p, ctx->prio);
> ---
> 
> Peter, what do you think?

I am confused is what.

So a non-running, but queued task is changing class and then somehow its
not getting scheduled?

So I perhaps see why the whole if (ctx->running) thing might be too
strong; I mean if a queued task gets promoted from OTHER to FIFO, we
need a preemption, but that's not the case at hand, is it?

Somehow we're getting stuck in IDLE with runnable tasks on; and I'm just
not seeing how we get there.

  parent reply	other threads:[~2026-10-13 10:06 UTC|newest]

Thread overview: 24+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
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 [this message]
2026-10-13 15:24 ` [PATCH] sched/core: Call wakeup_preempt() for queued tasks during class change K Prateek Nayak
2026-10-13 16:45   ` Vincent Guittot
2026-10-13 17:57   ` Paul E. McKenney
2026-10-13 19:55     ` Paul E. McKenney
2026-10-13 20:06       ` Paul E. McKenney
2026-10-14  0:13         ` Paul E. McKenney
2026-10-14 12:59           ` Paul E. McKenney
2026-10-14 13:03             ` Peter Zijlstra
2026-10-14  6:37   ` K Prateek Nayak
2026-10-14 10:59   ` Phil Auld
2026-10-14 13:12   ` [tip: sched/urgent] " tip-bot2 for K Prateek Nayak
2026-10-13 12:49 [BUG] Apparent lost wakeups Joel Fernandes
2026-10-13 14:00 ` 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=20261013100625.GF2009045@noisy.programming.kicks-ass.net \
    --to=peterz@infradead.org \
    --cc=bsegall@google.com \
    --cc=dietmar.eggemann@arm.com \
    --cc=joelagnelf@nvidia.com \
    --cc=juri.lelli@redhat.com \
    --cc=kernel-team@meta.com \
    --cc=kprateek.nayak@amd.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mgorman@suse.de \
    --cc=mingo@redhat.com \
    --cc=paulmck@kernel.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®