RE: [PATCH V2] MIPS: implement smp_cond_load_acquire() for Loongson-3

David Laight
2018-07-11T10:03:34Z

From: Paul Burton
> Sent: 10 July 2018 18:11
...
> I'm not sure which is the intent (I can ask if someone's interested),
> but you could either:
>
> 1) Consider the store buffer a cache, in which case loads need to
> check all store buffers from all CPUs because of the "all caches"
> part of the first quoted sentence.
>
> or
>
> 2) Decide store buffers aren't covered by the MIPS architecture
> documentation at all in which case the only sane thing to do would
> be to make it transparent to software (and here Loongson's isn't)
...

Store buffers are common and are never transparent to multi-threaded code.
They are largely why you need locks.

At least on (early) sparc systems they were between the execution unit
and the data cache.

I also suspect that 'write starvation' is also common - after all the
purpose of the store buffer is to do reads in preference to writes in
order to reduce the cpu stalls waiting for the memory bus (probably
the cpu to cache interface).

I think your example is just:
*(volatile int *)xxx = 1;
while (!*(volatile int *)yyy) continue;
running on two cpu with xxx and yyy swapped?

You need a stronger bus cycle in there somewhere.

David