Re: [PATCH tip/core/rcu 1/3] ftrace: replaceread_barrier_depends() with rcu_dereference_raw()

From: Steven Rostedt
Date: Fri Mar 05 2010 - 21:32:20 EST

On Fri, 2010-03-05 at 18:15 -0800, Josh Triplett wrote:

> > Question 2)
> >
> > Then why the !__builtin_constant_p(v)?
> >
> > If v is NULL, then the same should apply even if it is not a constant?
> > What am I missing?
> Checking for __builtin_constant_p(v) ensures that this test happens at
> compile time, and thus no conditional occurs at runtime. Together with
> the assumption of compiler constant folding and dead code elimination,
> this test means "if you can tell at compile time that the call assigns
> NULL, emit no barrier, otherwise emit a barrier". Under no
> circumstances will this macro actually emit conditional code.

Ah OK!

So the benefit of not doing a smb_wmb() when a variable is NULL is
outweighed by the benefits of removing branches and extra code.

Yes it now makes sense. Only remove the wmb() when we can guarantee that
it is never needed, and avoid unnecessary branches when it may not be

Thanks for clarifying!

-- Steve

To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at
Please read the FAQ at