Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1X0AhD-0005QF-VU for pgsql-hackers@arkaria.postgresql.org; Thu, 26 Jun 2014 14:30:40 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.80) (envelope-from ) id 1X0AhC-0001Te-9c for pgsql-hackers@arkaria.postgresql.org; Thu, 26 Jun 2014 14:30:38 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.2:DHE_RSA_AES_256_CBC_SHA256:256) (Exim 4.80) (envelope-from ) id 1X0AhA-0001TP-UO for pgsql-hackers@postgresql.org; Thu, 26 Jun 2014 14:30:36 +0000 Received: from mail-qc0-f178.google.com ([209.85.216.178]) by magus.postgresql.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:256) (Exim 4.80) (envelope-from ) id 1X0Ah6-00031V-5T for pgsql-hackers@postgresql.org; Thu, 26 Jun 2014 14:30:35 +0000 Received: by mail-qc0-f178.google.com with SMTP id c9so3252016qcz.9 for ; Thu, 26 Jun 2014 07:30:29 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-type:content-disposition:in-reply-to :user-agent; bh=IWOMZtZE4XDf395xpOUywypcfvx+P5UR101ihcnyOdg=; b=lb/tTQrJvDTmO6Y6YSwUdnF51QawflBMeNs0ENm0+yap+7jMnbQaPvtqy3DNtj6Tye us8t54HldemLkY9kKVVK4IXfJEYIMA4TvaM70T3bx/kSmKWPXbW/pss51AQzZCOhd5Te BWJ7WKvBeMmY8PhrZjJM47YlFUQBcH0udmMslrukLKA1WsUcvw5Bc0Cb/bZYe0u7t5ug QJ8/HvzmItwRB6COnJZzGiWXmarsi2Zocr3wLEKBEAeT3h7DOj9i3AzyoVIJZJ+NLp25 0aay/t45YunrgGIbOS+SdF/nL4mTgAReh+pDfxjlbRNFPj0rNQ0YwKB22LOhMiZHvE3k gMuw== X-Gm-Message-State: ALoCoQldsI5k6kdguxdxv+PW2KFTSU4dNkvvLhL/BqGNpTDGrLRYAiwi0jk9s97PMZyaUapW6mtz X-Received: by 10.140.33.200 with SMTP id j66mr21435778qgj.81.1403793029337; Thu, 26 Jun 2014 07:30:29 -0700 (PDT) Received: from tornado.leadboat.com (c-107-4-219-91.hsd1.va.comcast.net. [107.4.219.91]) by mx.google.com with ESMTPSA id g2sm11488715qaz.21.2014.06.26.07.30.28 for (version=TLSv1 cipher=RC4-SHA bits=128/128); Thu, 26 Jun 2014 07:30:28 -0700 (PDT) Date: Thu, 26 Jun 2014 10:30:27 -0400 From: Noah Misch To: Andres Freund Cc: Robert Haas , Tom Lane , Peter Geoghegan , Pg Hackers , Ants Aasma Subject: Re: better atomics - v0.5 Message-ID: <20140626143027.GA1338311@tornado.leadboat.com> References: <20140625171434.GG24114@awork2.anarazel.de> <20140625203635.GJ24114@awork2.anarazel.de> <20140626102006.GB1926@awork2.anarazel.de> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20140626102006.GB1926@awork2.anarazel.de> User-Agent: Mutt/1.5.21 (2010-09-15) X-Pg-Spam-Score: -2.6 (--) List-Archive: List-Help: List-ID: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: X-Mailing-List: pgsql-hackers Precedence: bulk Sender: pgsql-hackers-owner@postgresql.org On Thu, Jun 26, 2014 at 12:20:06PM +0200, Andres Freund wrote: > On 2014-06-25 20:16:08 -0400, Robert Haas wrote: > > On Wed, Jun 25, 2014 at 4:36 PM, Andres Freund wrote: > > > Since it better be legal to manipulate a atomic variable while holding a > > > spinlock we cannot simply use an arbitrary spinlock as backing for > > > atomics. That'd possibly cause us to wait on ourselves or cause > > > deadlocks. > > > > I think that's going to fall afoul of Tom's previously-articulated "no > > loops inside spinlocks" rule. Most atomics, by nature, are > > loop-until-it-works. > > Well, so is TAS itself :). > > More seriously, I think we're not going to have much fun if we're making > up the rule that you can't do an atomic add/sub while a spinlock is > held. That just precludes to many use cases and will make the code much > harder to understand. I don't think we're going to end up having many > problems if we allow atomic read/add/sub/write in there. I agree it's valuable to have a design that permits invoking an atomic operation while holding a spinlock. > > > I added the x86 inline assembler because a fair number of buildfarm > > > animals use ancient gcc's and because I could easily test it. It's also > > > more efficient for gcc < 4.6. I'm not wedded to keeping it. > > > > Hmm. gcc 4.6 is only just over a year old, so if pre-4.6 > > implementations aren't that good, that's a pretty good argument for > > keeping our own implementations around. :-( GCC 4.6 was released 2011-03-25, though that doesn't change the bottom line. -- Noah Misch EnterpriseDB http://www.enterprisedb.com -- Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-hackers