On Wed, Sep 30, 2026 at 09:35:26AM +0900, Masami Hiramatsu wrote:
> On Mon, 28 Sep 2026 17:41:57 -0700
> "Paul E. McKenney" <[email protected]> wrote:
> 
> > > > > Thanks for the clarification!
> > > > > So I think we can replace rcu_read_lock() with 
> > > > > rcu_read_lock_sched_notrace()?
> > > > > (also, maybe we need to add rcu_is_watching() check)
> > > >
> > > > That would work, and yes, you are quite right that if 
> > > > !rcu_is_watching(),
> > > > RCU is studiously ignoring you completely, no matter what your 
> > > > preemption
> > > > state is.
> > > >
> > > > > Current code may involves lockdep in fprobe, that is not good.
> > > >
> > > > Agreed, that could be problematic in any number of contexts.  ;-)
> > > >
> > > > > BTW, if we want to trace some code in extended quiescent state, do we
> > > > > still need this Tasks-Rude RCU?
> > > >
> > > > Well, you need something other than vanilla RCU, anyway.  And Tasks Rude
> > > > RCU is one candidate, though it is also a candidate that might annoy
> > > > people wishing to minimize IPIs.
> > > 
> > > Would RCU Tasks Trace be a better candidate given uprobes and
> > > sleepable BPF depends on it? Would it work here?
> 
> Hmm, those can be sleepable, but this is not. fprobe is based on ftrace
> so the callbacks are non preemptive.
> 
> > 
> > Quite possibly!  Of course, there might be corner-case ftrace/BPF issues
> > that you and Masami would know better than would I.
> > 
> > David Woodhouse suggests the new Atomic SRCU for a vaguely similar
> > purpose:
> > 
> > https://lore.kernel.org/all/[email protected]/
> > 
> > Now that Tasks Trace RCU is implemented in terms of SRCU-fast, there
> > might not be all that much air between David's suggestion and yours.
> 
> OK, let me check it. But at a glance, this atomic SRCU is still a bit
> heavier than rcu_sched_notrace, for fprobe. It involves smp_mb and lockdep. 

True, it is heavier weight.

> So if all of these rcu_read_lock() in fprobe are replaced with
> rcu_read_lock_sched_notrace(), isn't it enough to switch the
> synchronize_rcu() to synchronize_rcu_tasks_rude() for avoiding
> `if (!rcu_is_watching()) return;` ?

Yes, for all fprobes where rcu_is_watching(), agreed.

                                                        Thanx, Paul

> (Note, most of replacement will be done by [1])
> [1] 
> https://lore.kernel.org/all/179064115227.394389.16910234241400391996.stgit@devnote2/
> 
> Thank you,
> 
> -- 
> Masami Hiramatsu (Google) <[email protected]>

Reply via email to