Date: Tue, 18 Sep 2012 16:44:08 +0100 From: Attilio Rao <attilio@freebsd.org> To: Poul-Henning Kamp <phk@phk.freebsd.dk> Cc: arch@freebsd.org Subject: Re: Aliasing issue with TAILQ on ppc64 ? Message-ID: <CAJ-FndCsf2Xsn=1ioHyr_tn3-yAFOE7E9-wrjp4rcQJajhZvpg@mail.gmail.com> In-Reply-To: <95608.1347973160@critter.freebsd.dk> References: <95608.1347973160@critter.freebsd.dk>
next in thread | previous in thread | raw e-mail | index | archive | help
On 9/18/12, Poul-Henning Kamp <phk@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
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?CAJ-FndCsf2Xsn=1ioHyr_tn3-yAFOE7E9-wrjp4rcQJajhZvpg>