RE: [PATCH] Fix WARN_ON / WARN_ON_ONCE regression

Steven Rostedt
2006-10-10T21:18:09Z

On Wed, 11 Oct 2006, Ananiev, Leonid I wrote:

> Steven Rostedt wrote:
> > Holy crap! I wonder where else in the kernel gcc is doing this.
> Jeremy Fitzhardinge wrote:
> > annotation which makes gcc consider writes to the variable relatively
> expensive
>
> I should underline that cache miss is a result of invalidating of cache
> line with __warn_once in each other CPUs performed by hw for cache
> coherence.
> __warn_once is a common data. It is costly to test-and-modify it just in
> SMP. But it is not costly to write to the variable in memory just after
> reading it. As a compiler have understood source code.
> A read-and-modify for common variable are performed under lock usually.
>

In todays world, SMP is becoming more and more common (still waiting to
get that DualCore cell phone). So that means that writing to a variable
is going to carry more weight than it use to, and gcc needs to take note
of this. So, to avoid a short condition jump by adding a write to
memory, is not going to save anying.

Maybe gcc just needs to have an option to "optimize" for SMP.

-- Steve