lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date:	Fri, 5 Mar 2010 18:15:48 -0800
From:	Josh Triplett <josh@...htriplett.org>
To:	Steven Rostedt <rostedt@...dmis.org>
Cc:	"Paul E. McKenney" <paulmck@...ux.vnet.ibm.com>,
	linux-kernel@...r.kernel.org, mingo@...e.hu, laijs@...fujitsu.com,
	dipankar@...ibm.com, akpm@...ux-foundation.org,
	mathieu.desnoyers@...ymtl.ca, dvhltc@...ibm.com, niv@...ibm.com,
	tglx@...utronix.de, peterz@...radead.org, Valdis.Kletnieks@...edu,
	dhowells@...hat.com, Frederic Weisbecker <fweisbec@...il.com>,
	Ingo Molnar <mingo@...hat.com>
Subject: Re: [PATCH tip/core/rcu 1/3] ftrace: replace
 read_barrier_depends() with rcu_dereference_raw()

On Fri, Mar 05, 2010 at 08:57:49PM -0500, Steven Rostedt wrote:
> On Fri, 2010-03-05 at 17:45 -0800, Josh Triplett wrote:
> 
> > > #define rcu_assign_pointer(p, v) \
> > > 	({ \
> > > 		if (!__builtin_constant_p(v) || \
> > > 		    ((v) != NULL)) \
> > > 			smp_wmb(); \
> > > 		(p) = (v); \
> > > 	})
> > > 
> > > My question is, why that crazy if? The only time that will fail is if we
> > > are assigning the constant NULL to p. What makes NULL so important here?
> > > Can't there be a case when assigning NULL to p will require that wmb()?
> > 
> > The barrier ensures that the reader can't see the new p and the old
> > *p.  Since you can't look at *NULL, that concern doesn't apply.
> 
> Thanks for the explanation.
> 
> 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.

- Josh Triplett
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ