Re: [PATCH] Fix WARN_ON / WARN_ON_ONCE regression

From: Andrew James Wade
Date: Fri Oct 06 2006 - 12:11:53 EST


On Thursday 05 October 2006 17:37, Andrew Morton wrote:
>
> So how's this look?
>
> I worry a bit that someone's hardware might go and prefetch that static
> variable even when we didn't ask it to. Can that happen?

Branch mispredictions might cause spurious fetches. But the
unlikely() should take care of that for the (presumably common)
!__warned case.

> ...
>
> It would seem logical to mark the static variable as __read_mostly too. But
> it would be wrong, because that would put it back into the vmlinux image, and
> the kernel will never read from this variable in normal operation anyway.

And if that's the case they should probably be in amongst write-hot
variables so as to reduce cache-line ping-ponging. __read_mostly should
probably be called __read_hot_write_cold, see
http://lkml.org/lkml/2006/6/26/290 .

> Unless the compiler or hardware go and do some prefetching on us?

The compiler doesn't, at least not GCC 4. I wouldn't expect it to
hoist loads out of non-loop blocks.

> For some reason this patch shrinks softirq.o text by 40 bytes.

The compiler optimizes out __ret_warn_once; it didn't do that before.

The patch looks good to me, though I am still baffled as to why the
cache misses were occurring.

Andrew Wade
-
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/