From: Eric Anholt on
On Mon, 26 Apr 2010 10:26:52 +0100, "Jan Beulich" <JBeulich(a)novell.com> wrote:
> Eric, Brice,
>
> what is the point of issuing wbinvd() on all CPUs here if clflush isn't
> available, but using clflush() (if available) only on the current CPU?

From the IA-32 architecture manuals:

WBINVD: "Writes back all modified cache lines in the processor’s
internal cache to main memory and invalidates (flushes) the
internal caches. The instruction then issues a special-
function bus cycle that directs external caches to also write
back modified data and another bus cycle to indicate that the
external caches should be invalidated.

CLFLUSH: "Invalidates the cache line that contains the linear address
specified with the source operand from all levels of the
processor cache hierarchy (data and instruction). The
invalidation is broadcast throughout the cache coherence
domain. If, at any level of the cache hierarchy, the line is
inconsistent with memory (dirty) it is written to memory
before invalidation. The source operand is a byte memory
location.

My reading of these two is that wbinvd affects this processor's cache
lines, while clflush affects the cacheline regardless of which CPU owns
it since they all share the same coherence domain.

Given that on many systems without CLFLUSH (8xx chipsets), we have
issues with getting coherence to external memory successfully (note how
neither of those instructions provide that!), I'm not sure it's a good
time to be worrying about how to improve cache flushing performance on them!