Re: Semantics of smp_mb()

From: Roland Dreier
Date: Thu Dec 15 2005 - 16:15:38 EST


Keith> Why does mmiowb() map to empty on most systems, including
Keith> Alpha? Should it not map to wmb() for everything except
Keith> IA64 and MIPS?

I think the intention (as spelled out in Documentation/DocBook/deviceiobook.tmpl)
is that mmiowb() must be used in conjunction with spinlocks or some
other SMP synchronization mechanism. The locks themselves are
sufficient ordering on the archs where mmiowb() is a NOP.

One way of thinking about this is that the usually barrier operations
like wmb() affect the order of a single CPU's operations -- that is,
wmb() is saying that all writes from the current thread of execution
before the wmb() become visible before any of the writes from the
current after the wmb(). But wmb() doesn't say anything about how one
CPU's writes are ordered against anything a different CPU does.

mmiowb() is something else -- it controls the visibility of writes
from different CPUs. It says that all writes before the mmiowb()
become visible before any writes from any CPU after the mmiowb().
However, this isn't sensible unless we can order the writes between
CPUs, and that only makes sense if there's a lock that lets us say
that one CPU is executing something after the mmiowb().

- R.
-
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/