From: Frederic Weisbecker <frederic@kernel.org>
To: "Paul E. McKenney" <paulmck@kernel.org>
Cc: Valentin Schneider <vschneid@redhat.com>,
rcu@vger.kernel.org, linux-kernel@vger.kernel.org,
Peter Zijlstra <peterz@infradead.org>,
Neeraj Upadhyay <quic_neeraju@quicinc.com>,
Joel Fernandes <joel@joelfernandes.org>,
Josh Triplett <josh@joshtriplett.org>,
Boqun Feng <boqun.feng@gmail.com>,
Steven Rostedt <rostedt@goodmis.org>,
Mathieu Desnoyers <mathieu.desnoyers@efficios.com>,
Lai Jiangshan <jiangshanlai@gmail.com>,
Zqiang <qiang.zhang1211@gmail.com>
Subject: Re: RCU-Task[-Trace] VS EQS (was Re: [PATCH v3 13/25] context_tracking, rcu: Rename rcu_dynticks_task*() into rcu_task*())
Date: Wed, 31 Jul 2024 14:28:16 +0200 [thread overview]
Message-ID: <Zqot4NpepOORtNzv@localhost.localdomain> (raw)
In-Reply-To: <30c6d4aa-7598-4dc1-8592-7533d64714c2@paulmck-laptop>
Le Tue, Jul 30, 2024 at 03:39:44PM -0700, Paul E. McKenney a écrit :
> On Wed, Jul 31, 2024 at 12:17:49AM +0200, Frederic Weisbecker wrote:
> > Le Tue, Jul 30, 2024 at 07:23:58AM -0700, Paul E. McKenney a écrit :
> > > On Thu, Jul 25, 2024 at 04:32:46PM +0200, Frederic Weisbecker wrote:
> > > > Le Wed, Jul 24, 2024 at 04:43:13PM +0200, Valentin Schneider a écrit :
> > > > > -/* Turn on heavyweight RCU tasks trace readers on idle/user entry. */
> > > > > -static __always_inline void rcu_dynticks_task_trace_enter(void)
> > > > > +/* Turn on heavyweight RCU tasks trace readers on kernel exit. */
> > > > > +static __always_inline void rcu_task_trace_exit(void)
> > > >
> > > > Before I proceed on this last one, a few questions for Paul and others:
> > > >
> > > > 1) Why is rcu_dynticks_task_exit() not called while entering in NMI?
> > > > Does that mean that NMIs aren't RCU-Task read side critical sections?
> > >
> > > Because Tasks RCU Rude handles that case currently. So good catch,
> > > because this might need adjustment when we get rid of Tasks RCU Rude.
> > > And both rcu_dynticks_task_enter() and rcu_dynticks_task_exit() look safe
> > > to invoke from NMI handlers. Memory ordering needs checking, of course.
> > >
> > > Except that on architectures defining CONFIG_ARCH_WANTS_NO_INSTR, Tasks
> > > RCU should instead check the ct_kernel_enter_state(RCU_DYNTICKS_IDX)
> > > state, right? And on those architectures, I believe that
> > > rcu_dynticks_task_enter() and rcu_dynticks_task_exit() can just be no-ops.
> > > Or am I missing something here?
> >
> > I think rcu_dynticks_task_enter() and rcu_dynticks_task_exit() are
> > still needed anyway because the target task can migrate. So unless the rq is locked,
> > it's hard to match a stable task_cpu() with the corresponding RCU_DYNTICKS_IDX.
>
> Can it really migrate while in entry/exit or deep idle code? Or am I
> missing a trick here?
No but it can migrate before or after EQS. So we need to handle situations like:
== CPU 0 == == CPU 1 ==
// TASK A is on rq
set_task_cpu(TASK A, 0)
// TASK B runs
ct_user_enter()
ct_user_exit()
//TASK A runs
It could be something like the following:
int rcu_tasks_nohz_full_holdout(struct task_struct *t)
{
int cpu;
int snap;
cpu = task_cpu(t);
/* Don't miss EQS exit if the task migrated out and in */
smp_rmb()
snap = ct_dynticks_cpu(cpu);
if (snap & RCU_DYNTICKS_IDX)
return true;
/* Check if it's the actual task running */
smp_rmb()
if (rcu_dereference_raw(cpu_curr(cpu)) != t)
return true;
/* Make sure the task hasn't migrated in after the above EQS */
smp_rmb()
return ct_dynticks_cpu(cpu) != snap;
}
But there is still a risk that ct_dynticks wraps before the last test. So
we would need task_call_func() if task_cpu() is in nohz_full mode.
>
> > > > 2) Looking further into CONFIG_TASKS_TRACE_RCU_READ_MB=y, it seems to
> > > > allow for uses of rcu_read_[un]lock_trace() while RCU is not watching
> > > > (EQS). Is it really a good idea to support that? Are we aware of any
> > > > such potential usecase?
> > >
> > > I hope that in the longer term, there will be no reason to support this.
> > > Right now, architectures not defining CONFIG_ARCH_WANTS_NO_INSTR must
> > > support this because tracers really can attach probes where RCU is
> > > not watching.
> > >
> > > And even now, in architectures defining CONFIG_ARCH_WANTS_NO_INSTR, I
> > > am not convinced that the early incoming and late outgoing CPU-hotplug
> > > paths are handled correctly. RCU is not watching them, but I am not so
> > > sure that they are all marked noinstr as needed.
> >
> > Ok I see...
>
> If need be, the outgoing-CPU transition to RCU-not-watching could be
> delayed into arch-specific code. We already allow this for the incoming
> transition.
That's a lot of scary architectures code to handle :-)
And how do we determine which place is finally safe to stop watching?
Thanks.
>
> Thanx, Paul
next prev parent reply other threads:[~2024-07-31 12:28 UTC|newest]
Thread overview: 58+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-07-24 14:43 [PATCH v3 00/25] context_tracking, rcu: Spring cleaning of dynticks references Valentin Schneider
2024-07-24 14:43 ` [PATCH v3 01/25] treewide: context_tracking: Rename CONTEXT_* into CT_STATE_* Valentin Schneider
2024-07-26 17:41 ` Thomas Gleixner
2024-07-24 14:43 ` [PATCH v3 02/25] context_tracking, rcu: Rename RCU_DYNTICKS_IDX into CT_RCU_WATCHING Valentin Schneider
2024-07-26 17:43 ` Thomas Gleixner
2024-07-24 14:43 ` [PATCH v3 03/25] context_tracking, rcu: Rename ct_dynticks() into ct_rcu_watching() Valentin Schneider
2024-07-24 14:43 ` [PATCH v3 04/25] context_tracking, rcu: Rename ct_dynticks_cpu() into ct_rcu_watching_cpu() Valentin Schneider
2024-07-24 14:43 ` [PATCH v3 05/25] context_tracking, rcu: Rename ct_dynticks_cpu_acquire() into ct_rcu_watching_cpu_acquire() Valentin Schneider
2024-07-24 20:20 ` Frederic Weisbecker
2024-07-24 14:43 ` [PATCH v3 06/25] context_tracking, rcu: Rename struct context_tracking .dynticks_nesting into .nesting Valentin Schneider
2024-07-24 14:43 ` [PATCH v3 07/25] context_tracking, rcu: Rename ct_dynticks_nesting() into ct_nesting() Valentin Schneider
2024-07-24 14:43 ` [PATCH v3 08/25] context_tracking, rcu: Rename ct_dynticks_nesting_cpu() into ct_nesting_cpu() Valentin Schneider
2024-07-24 14:43 ` [PATCH v3 09/25] context_tracking, rcu: Rename struct context_tracking .dynticks_nmi_nesting into .nmi_nesting Valentin Schneider
2024-07-24 14:43 ` [PATCH v3 10/25] context_tracking, rcu: Rename ct_dynticks_nmi_nesting() into ct_nmi_nesting() Valentin Schneider
2024-07-24 14:43 ` [PATCH v3 11/25] context_tracking, rcu: Rename ct_dynticks_nmi_nesting_cpu() into ct_nmi_nesting_cpu() Valentin Schneider
2024-07-24 14:43 ` [PATCH v3 12/25] context_tracking, rcu: Rename DYNTICK_IRQ_NONIDLE into CT_NESTING_IRQ_NONIDLE Valentin Schneider
2024-07-24 14:43 ` [PATCH v3 13/25] context_tracking, rcu: Rename rcu_dynticks_task*() into rcu_task*() Valentin Schneider
2024-07-25 14:32 ` RCU-Task[-Trace] VS EQS (was Re: [PATCH v3 13/25] context_tracking, rcu: Rename rcu_dynticks_task*() into rcu_task*()) Frederic Weisbecker
2024-07-30 14:23 ` Paul E. McKenney
2024-07-30 22:17 ` Frederic Weisbecker
2024-07-30 22:39 ` Paul E. McKenney
2024-07-31 12:28 ` Frederic Weisbecker [this message]
2024-08-03 4:32 ` Paul E. McKenney
2024-08-05 9:01 ` Peter Zijlstra
2024-08-05 12:18 ` Frederic Weisbecker
2024-08-05 13:26 ` Frederic Weisbecker
2024-08-05 17:04 ` Paul E. McKenney
2024-07-31 16:07 ` [PATCH v3 13/25] context_tracking, rcu: Rename rcu_dynticks_task*() into rcu_task*() Frederic Weisbecker
2024-08-14 12:06 ` Neeraj Upadhyay
2024-08-15 14:14 ` Frederic Weisbecker
2024-08-16 10:19 ` Valentin Schneider
2024-07-24 14:43 ` [PATCH v3 14/25] context_tracking, rcu: Rename rcu_dynticks_curr_cpu_in_eqs() into rcu_watching_curr_cpu() Valentin Schneider
2024-07-25 12:10 ` Frederic Weisbecker
2024-07-25 14:46 ` Valentin Schneider
2024-07-24 14:43 ` [PATCH v3 15/25] rcu: Rename rcu_dynticks_eqs_online() into rcu_watching_online() Valentin Schneider
2024-07-25 12:12 ` Frederic Weisbecker
2024-07-24 14:43 ` [PATCH v3 16/25] rcu: Rename rcu_dynticks_in_eqs() into rcu_watching_snap_in_eqs() Valentin Schneider
2024-07-24 14:43 ` [PATCH v3 17/25] rcu: Rename rcu_dynticks_in_eqs_since() into rcu_watching_snap_stopped_since() Valentin Schneider
2024-07-25 12:18 ` Frederic Weisbecker
2024-07-24 14:43 ` [PATCH v3 18/25] rcu: Rename rcu_dynticks_zero_in_eqs() into rcu_watching_zero_in_eqs() Valentin Schneider
2024-07-24 14:43 ` [PATCH v3 19/25] rcu: Rename struct rcu_data .dynticks_snap into .watching_snap Valentin Schneider
2024-07-25 12:21 ` Frederic Weisbecker
2024-07-24 14:43 ` [PATCH v3 20/25] rcu: Rename struct rcu_data .exp_dynticks_snap into .exp_watching_snap Valentin Schneider
2024-07-24 14:43 ` [PATCH v3 21/25] rcu: Rename dyntick_save_progress_counter() into rcu_watching_snap_save() Valentin Schneider
2024-07-25 12:24 ` Frederic Weisbecker
2024-07-24 14:43 ` [PATCH v3 22/25] rcu: Rename rcu_implicit_dynticks_qs() into rcu_implicit_eqs() Valentin Schneider
2024-07-25 12:27 ` Frederic Weisbecker
2024-07-24 14:43 ` [PATCH v3 23/25] rcu: Rename rcu_momentary_dyntick_idle() into rcu_momentary_eqs() Valentin Schneider
2024-07-24 14:43 ` [PATCH v3 24/25] rcu: Update stray documentation references to rcu_dynticks_eqs_{enter, exit}() Valentin Schneider
2024-07-25 12:32 ` Frederic Weisbecker
2024-07-24 14:43 ` [PATCH v3 25/25] context_tracking, rcu: Rename rcu_dyntick trace event into rcu_watching Valentin Schneider
2024-07-25 12:39 ` Frederic Weisbecker
2024-07-25 14:47 ` Valentin Schneider
2024-07-25 15:22 ` [PATCH v3 00/25] context_tracking, rcu: Spring cleaning of dynticks references Neeraj Upadhyay
2024-07-25 16:07 ` Valentin Schneider
2024-07-25 16:44 ` Paul E. McKenney
2024-07-26 14:43 ` Valentin Schneider
2024-07-29 2:42 ` Neeraj Upadhyay
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=Zqot4NpepOORtNzv@localhost.localdomain \
--to=frederic@kernel.org \
--cc=boqun.feng@gmail.com \
--cc=jiangshanlai@gmail.com \
--cc=joel@joelfernandes.org \
--cc=josh@joshtriplett.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mathieu.desnoyers@efficios.com \
--cc=paulmck@kernel.org \
--cc=peterz@infradead.org \
--cc=qiang.zhang1211@gmail.com \
--cc=quic_neeraju@quicinc.com \
--cc=rcu@vger.kernel.org \
--cc=rostedt@goodmis.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