Re: [PATCH] Immunize rcu_dereference() against crazy compiler writers
From: Andi Kleen
Date: Thu Jul 12 2007 - 09:08:32 EST
"Paul E. McKenney" <paulmck@xxxxxxxxxxxxxxxxxx> writes:
> Turns out that compiler writers are a bit more aggressive about optimizing
> than one might expect. This patch prevents a number of such optimizations
> from messing up rcu_deference(). This is not merely a theoretical
> problem, as evidenced by the rmb() in mce_log().
Don't think that's an improvement. rmb() at least is known to work
reliable to prevent such reordering. Memory barriers are well
documented in the gcc documentation. Who knows about volatile? The
volatile semantics have been traditionally unclear and shakey.
The C standard doesn't make much guarantees and i don't think
gcc does either.
If anything you might want to embedd rmb(); in a statement expression
in rcu_deference instead.
-Andi
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/