Aliasing issue with TAILQ on ppc64 ?

Attilio Rao attilio at freebsd.org
Tue Sep 18 15:44:10 UTC 2012


On 9/18/12, Poul-Henning Kamp <phk at phk.freebsd.dk> wrote:
>
> In Varnish I have adopted <sys/queue.h> and today I saw a weird issue
> on a PPC64 platform, which makes me wonder if we have a potential
> aliasing issue with TAILQs.

I think that our queue.h (and then TAILQs too) are not guaranteed at
all to be SMP safe from a CPU perspective. More importantly, being
macros makes them very subjective to also compiler reordering and
optimization, and this is perfectly fine. The only way I can see this
code is safe is, infact, to lock it with proper locks around the
operations. Even having control over the whole operation is impossible
without rewriting accordingly the TAILQ operations directly to take
into account memory models.

If you want a lock-less implementation of TAILQs I'm afraid you need
to work on your own one, using hw memory barriers where needed.

Attilio


-- 
Peace can only be achieved by understanding - A. Einstein


More information about the freebsd-arch mailing list