Re: [PATCH rcu/next 3/3] rcu: Call trace_rcu_callback() also for bypass queuing (v2)

From: Joel Fernandes
Date: Sat Sep 17 2022 - 17:43:42 EST


On Sat, Sep 17, 2022 at 3:58 PM Frederic Weisbecker <frederic@xxxxxxxxxx> wrote:
>
> On Sat, Sep 17, 2022 at 04:42:00PM +0000, Joel Fernandes (Google) wrote:
> > @@ -2809,17 +2825,15 @@ void call_rcu(struct rcu_head *head, rcu_callback_t func)
> > }
> >
> > check_cb_ovld(rdp);
> > - if (rcu_nocb_try_bypass(rdp, head, &was_alldone, flags))
> > +
> > + if (rcu_nocb_try_bypass(rdp, head, &was_alldone, flags)) {
> > + __trace_rcu_callback(head, rdp);
> > return; // Enqueued onto ->nocb_bypass, so just leave.
> > + }
>
> I think the bypass enqueues should be treated differently. Either with extending
> the current trace_rcu_callback/trace_rcu_kvfree_callback (might break tools)
>
> or
> with creating a new trace_rcu_callback_bypass()/trace_rcu_kvfree_callback_bypass().
>
> Those could later be paired with a trace_rcu_bypass_flush().

I am having a hard time seeing why it should be treated differently.
We already increment the length of the main segcblist even when
bypassing. Why not just call the trace point instead of omitting it?
Otherwise it becomes a bit confusing IMO (say someone does not enable
your proposed new bypass tracepoint and only enables the existing one,
then they would see weird traces where call_rcu is called but their
traces are missing trace_rcu_callback). Not to mention - your
suggestion will also complicate writing tools that use the existing
rcu_callback tracepoint to monitor call_rcu().

Also if you see the definition of rcu_callback, "Tracepoint for the
registration of a single RCU callback function.". That pretty much
fits the usage here.

As for tracing of the flushing, I don’t care about tracing that at the
moment using tracepoints, but I don’t mind if it is added later.

Maybe let’s let Paul help resolve our disagreement on this one? :)

thanks,

- Joel

>
>
> Thanks.
>
>
> > +
> > // If no-CBs CPU gets here, rcu_nocb_try_bypass() acquired ->nocb_lock.
> > rcu_segcblist_enqueue(&rdp->cblist, head);
> > - if (__is_kvfree_rcu_offset((unsigned long)func))
> > - trace_rcu_kvfree_callback(rcu_state.name, head,
> > - (unsigned long)func,
> > - rcu_segcblist_n_cbs(&rdp->cblist));
> > - else
> > - trace_rcu_callback(rcu_state.name, head,
> > - rcu_segcblist_n_cbs(&rdp->cblist));
> > + __trace_rcu_callback(head, rdp);
> >
> > trace_rcu_segcb_stats(&rdp->cblist, TPS("SegCBQueued"));
> >
> > --
> > 2.37.3.968.ga6b4b080e4-goog
> >