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>,
Clark Williams <clrkwllms@kernel.org>,
Sebastian Andrzej Siewior <bigeasy@linutronix.de>,
linux-kernel@vger.kernel.org, linux-rt-devel@lists.linux.dev,
kernel-team@meta.com
Subject: Re: Mapping from preempted task to running task on same CPU
Date: Fri, 16 Oct 2026 09:25:00 +0200 [thread overview]
Message-ID: <20261016072500.GX4120091@noisy.programming.kicks-ass.net> (raw)
In-Reply-To: <a92f4a71-614f-44e4-b4f1-38e92deffae2@amd.com>
On Fri, Oct 16, 2026 at 10:14:27AM +0530, K Prateek Nayak wrote:
> > @@ -372,17 +381,24 @@ static int rcu_print_task_stall(struct rcu_node *rnp, unsigned long flags)
> > raw_spin_unlock_irqrestore_rcu_node(rnp, flags);
> > while (i) {
> > t = ts[--i];
> > - if (task_call_func(t, check_slow_task, &rscr))
> > + if (task_call_func(t, check_slow_task, &rscr)) {
> > pr_cont(" P%d", t->pid);
> > - else
> > - pr_cont(" P%d/%d:%c%c%c%c%c%c",
> > + } else {
> > + tc = rscr.rcu_rdr_cpu_task;
> > + pr_cont(" P%d/%d:%c%c%c%c%c%c CPU %d%s %s (%d)%s",
> > t->pid, rscr.nesting,
> > ".b"[rscr.rs.b.blocked],
> > ".q"[rscr.rs.b.need_qs],
> > ".e"[rscr.rs.b.exp_hint],
> > ".l"[rscr.on_blkd_list],
> > ".R"[rscr.rcu_rdr_running],
> > - ".B?"[rscr.rcu_rdr_boosted]);
> > + ".B?"[rscr.rcu_rdr_boosted],
> > + rscr.rcu_rdr_cpu,
> > + rscr.rcu_rdr_cpu_offline ? "!" : "",
> > + tc ? tc->comm : "???",
> > + tc ? tc->pid : -1,
> > + tc ? (is_idle_task(tc) ? " (idle!)" : "") : " (no task)");
> > + }
> > lockdep_assert_irqs_disabled();
>
> ... since you are IRQs disabled, it should be fine to use it here.
>
> If you don't want to take the overhead of rq_lock() + barrier,
> you can perhaps define a cpu_curr_snapshot_rcu() like:
>
> struct task_struct *cpu_curr_snapshot_rcu(int cpu)
> {
> return rcu_dereference_all(cpu_curr(cpu));
> }
>
> in kernel/sched/core.c and expose it similar to
> cpu_curr_snapshot().
>
> I'll let Peter comment if he hates it or not ;-)
I would much rather do this than expose rq_lock().
next prev parent reply other threads:[~2026-10-16 7:25 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-10-15 17:41 Paul E. McKenney
2026-10-16 4:44 ` K Prateek Nayak
2026-10-16 7:25 ` Peter Zijlstra [this message]
2026-10-16 16:08 ` Paul E. McKenney
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=20261016072500.GX4120091@noisy.programming.kicks-ass.net \
--to=peterz@infradead.org \
--cc=bigeasy@linutronix.de \
--cc=bsegall@google.com \
--cc=clrkwllms@kernel.org \
--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=linux-rt-devel@lists.linux.dev \
--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®