Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1VinGk-0001og-Bi for pgsql-hackers@arkaria.postgresql.org; Tue, 19 Nov 2013 15:31:14 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.80) (envelope-from ) id 1VinGj-0002hj-Ql for pgsql-hackers@arkaria.postgresql.org; Tue, 19 Nov 2013 15:31:13 +0000 Received: from makus.postgresql.org ([2001:4800:7903:4::125]) by malur.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1VinGh-0002fJ-Bi for pgsql-hackers@postgresql.org; Tue, 19 Nov 2013 15:31:11 +0000 Received: from mail.anarazel.de ([217.115.131.40]) by makus.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1VinGe-0007YA-Cz for pgsql-hackers@postgresql.org; Tue, 19 Nov 2013 15:31:10 +0000 Received: from intern.anarazel.de (p5DDC736E.dip0.t-ipconnect.de [93.220.115.110]) (Authenticated sender: andres@anarazel.de) by mail.anarazel.de (Postfix) with ESMTPSA id 6D5154F0001; Tue, 19 Nov 2013 16:31:07 +0100 (CET) Date: Tue, 19 Nov 2013 16:31:06 +0100 From: Andres Freund To: Robert Haas Cc: Tom Lane , Peter Eisentraut , Peter Geoghegan , Pg Hackers , Ants Aasma Subject: Re: better atomics - v0.2 Message-ID: <20131119153106.GA19293@alap2.anarazel.de> References: <20131115200416.GH5489@awork2.anarazel.de> <8392.1384873040@sss.pgh.pa.us> <20131119151646.GD10498@alap2.anarazel.de> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: 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 2013-11-19 10:23:57 -0500, Robert Haas wrote: > > The only fundamental thing that I don't immediately see how we can > > support is the spinlock based memory barrier since that introduces a > > circularity (atomics need barrier, barrier needs spinlocks, spinlock > > needs atomics). > > We've been pretty much assuming for a long time that calling a > function in another translation unit acts as a compiler barrier. > There's a lot of code that isn't actually safe against global > optimization; we assume, for example, that memory accesses can't move > over an LWLockAcquire(), but that's just using spinlocks internally, > and those aren't guaranteed to be compiler barriers, per previous > discussion. So one idea for a compiler barrier is just to define a > function call pg_compiler_barrier() in a file by itself, and make that > the fallback implementation. That will of course fail if someone uses > a globally optimizing compiler, but I think it'd be OK to say that if > you want to do that, you'd better have a real barrier implementation. That works for compiler, but not for memory barriers :/ > Right now, it's probably unsafe regardless. Yes, I have pretty little trust in the current state. Both from the infrastructure perspective (spinlocks, barriers) as from individual pieces of code. To a good part we're probably primarily protected by x86's black magic and the fact that everyone with sufficient concurrency to see problems uses x86. Greetings, Andres Freund -- Andres Freund http://www.2ndQuadrant.com/ PostgreSQL Development, 24x7 Support, Training & Services -- Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-hackers