[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
Re: Why does membar_consumer() do anything on x86_64?
On 11.07.2010 07:59, Dennis Ferguson wrote:
> I'm sure you are right that loads can be reordered with respect to stores,
> so I'd expect membar_enter() and membar_sync(), and maybe membar_exit(), to
> actually do something since (according to the man page) those functions
> worry about the ordering of loads against stores.
> I don't need these, though. I have one write-only guy running concurrently
> with N read-only guys, so the write-only guy only cares about the ordering
> of stores while the read-only guys only care about the ordering of loads.
> Since membar_consumer() (according to the man page) protects against
> the reordering of loads alone, and membar_producer() protects against
> the reordering of stores alone, these seem to be the functions I need
> to use. Since load-only and store-only order are also things that Intel
> processors guarantee will happen if you don't do anything at all (other
> architectures don't guarantee that, though, which is why I might want to
> call these functions anyway), it still doesn't make sense to me why
> membar_consumer() and membar_producer() in particular would need to do
> anything at all on Intel CPUs.
Agreed, although notice that membar_enter() is aliased to
membar_consumer() in atomic.S, for amd64.
Any store preceeding membar_enter() will reach global visibility
before all loads and stores following it.
The lock is needed, or else the loads that could follow may get
reordered (when writing to different locations, of course), and be
visible before the store.
For the rest:
- I don't know why membar_consumer and membar_enter are aliased
- for i386, Solaris adds a lock for all memory barriers, while Linux
only does that for its rmb() (it seems to provide less membar_ops than
Solaris or NetBSD). The wmb is ~ a noop, except for x86 OOSTORE.
- According to anandtech, P6 (and P-M) may reorder loads, via the ROB
Main Index |
Thread Index |