Re: [PATCH v3 tip/core/rcu 05/40] rcu: Semicolon inside RCU_TRACE() for rcu.h

From: Paul E. McKenney
Date: Tue Apr 25 2017 - 17:27:50 EST


On Tue, Apr 25, 2017 at 05:13:50PM -0400, Steven Rostedt wrote:
> On Wed, 19 Apr 2017 09:58:02 -0700
> "Paul E. McKenney" <paulmck@xxxxxxxxxxxxxxxxxx> wrote:
>
> > The current use of "RCU_TRACE(statement);" can cause odd bugs, especially
> > where "statement" is a local-variable declaration, as it can leave a
> > misplaced ";" in the source code. This commit therefore converts these
> > to "RCU_TRACE(statement;)", which avoids the misplaced ";".
> >
> > Reported-by: Josh Triplett <josh@xxxxxxxxxxxxxxxx>
> > Signed-off-by: Paul E. McKenney <paulmck@xxxxxxxxxxxxxxxxxx>
> > ---
> > kernel/rcu/rcu.h | 4 ++--
> > 1 file changed, 2 insertions(+), 2 deletions(-)
> >
> > diff --git a/kernel/rcu/rcu.h b/kernel/rcu/rcu.h
> > index 0d6ff3e471be..8700a81daf56 100644
> > --- a/kernel/rcu/rcu.h
> > +++ b/kernel/rcu/rcu.h
> > @@ -109,12 +109,12 @@ static inline bool __rcu_reclaim(const char *rn, struct rcu_head *head)
> >
> > rcu_lock_acquire(&rcu_callback_map);
> > if (__is_kfree_rcu_offset(offset)) {
> > - RCU_TRACE(trace_rcu_invoke_kfree_callback(rn, head, offset));
> > + RCU_TRACE(trace_rcu_invoke_kfree_callback(rn, head, offset);)
>
> I have to ask. Why is this a RCU_TRACE() anyway? tracepoints use jump
> labels, and this is basically a nop here when tracing is off.

Because otherwise the build breaks if CONFIG_RCU_TRACE=n. So it is
not the tracepoints themselves, but their helper functions. Worse,
the variables declared for them. Even worse, in Tiny RCU, the fields
in structures that are used only for tracing.

I freely admit that there might be a better way to structure this,
give or take the Tiny RCU structure fields.

Thanx, Paul

> -- Steve
>
>
> > kfree((void *)head - offset);
> > rcu_lock_release(&rcu_callback_map);
> > return true;
> > } else {
> > - RCU_TRACE(trace_rcu_invoke_callback(rn, head));
> > + RCU_TRACE(trace_rcu_invoke_callback(rn, head);)
> > head->func(head);
> > rcu_lock_release(&rcu_callback_map);
> > return false;
>