From owner-freebsd-arch@FreeBSD.ORG Tue Sep 18 15:44:10 2012 Return-Path: Delivered-To: arch@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id 31DE21065673 for ; Tue, 18 Sep 2012 15:44:10 +0000 (UTC) (envelope-from asmrookie@gmail.com) Received: from mail-lb0-f182.google.com (mail-lb0-f182.google.com [209.85.217.182]) by mx1.freebsd.org (Postfix) with ESMTP id A5E138FC0C for ; Tue, 18 Sep 2012 15:44:09 +0000 (UTC) Received: by lbbgg13 with SMTP id gg13so132505lbb.13 for ; Tue, 18 Sep 2012 08:44:08 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:reply-to:sender:in-reply-to:references:date :x-google-sender-auth:message-id:subject:from:to:cc:content-type; bh=TdqfaalkL2suRX6Q3RymfxaFTOECdCCoGAFkiU3/kp0=; b=Pvia/RmTF6FoMGXFIZLSNBS82AXCrT13RNiPZ+6BLG9OEwwXsuWqzKCtJoPhBM8FzR JwrcRw0L/XtiI9qJcJAn9upvZT/YxL2HItYT2mx3Nt6GopYd35UsVpN60mJ1IuyGbgvC H6jGpRH+jC3wA+kuIo6RNCyNXkyG5e+9R3hCEADAAkvdgnuc6ws2JVRzpbS4oocTzeLi C1+sKFgCgiJ+ZorL9kPy3lWUzuHNlbx3GhLR3TQhpMWQ//N5YvtFk8qKC2Hklilrfubd V19lwE7bQj+Z6A8n4auU0PHIjp1B5aP5bHBfU6zYk6qNAjQm6tT/Rt9AfUGIzlsjev2N zwnA== MIME-Version: 1.0 Received: by 10.112.30.34 with SMTP id p2mr67464lbh.85.1347983048248; Tue, 18 Sep 2012 08:44:08 -0700 (PDT) Sender: asmrookie@gmail.com Received: by 10.112.102.39 with HTTP; Tue, 18 Sep 2012 08:44:08 -0700 (PDT) In-Reply-To: <95608.1347973160@critter.freebsd.dk> References: <95608.1347973160@critter.freebsd.dk> Date: Tue, 18 Sep 2012 16:44:08 +0100 X-Google-Sender-Auth: PUYKh0CrEgM-lbOY3MS-h1ix4DU Message-ID: From: Attilio Rao To: Poul-Henning Kamp Content-Type: text/plain; charset=UTF-8 Cc: arch@freebsd.org Subject: Re: Aliasing issue with TAILQ on ppc64 ? X-BeenThere: freebsd-arch@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list Reply-To: attilio@FreeBSD.org List-Id: Discussion related to FreeBSD architecture List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 18 Sep 2012 15:44:10 -0000 On 9/18/12, Poul-Henning Kamp wrote: > > In Varnish I have adopted 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