Received: from magus.postgresql.org (magus.postgresql.org [87.238.57.229]) by mail.postgresql.org (Postfix) with ESMTP id B891C14E23D3 for ; Wed, 21 Dec 2011 11:55:35 -0400 (AST) Received: from sss.pgh.pa.us ([66.207.139.130]) by magus.postgresql.org with esmtp (Exim 4.72) (envelope-from ) id 1RdOVw-0004yz-SF for pgsql-bugs@postgresql.org; Wed, 21 Dec 2011 15:55:35 +0000 Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) by sss.pgh.pa.us (8.14.2/8.14.2) with ESMTP id pBLFtGA0005644; Wed, 21 Dec 2011 10:55:17 -0500 (EST) To: Martin Pitt cc: pgsql-bugs@postgresql.org Subject: Re: [PATCH v2] Use CC atomic builtins as a fallback In-reply-to: <20111221080940.GB2743@piware.de> References: <4EEB1C77.1000309@enterprisedb.com> <20111218224203.GA2950@piware.de> <20111219171145.GN2972@piware.de> <23930.1324433689@sss.pgh.pa.us> <20111221080940.GB2743@piware.de> Comments: In-reply-to Martin Pitt message dated "Wed, 21 Dec 2011 09:09:41 +0100" Date: Wed, 21 Dec 2011 10:55:16 -0500 Message-ID: <5642.1324482916@sss.pgh.pa.us> From: Tom Lane X-Pg-Spam-Score: -4.5 (----) X-Archive-Number: 201112/188 X-Sequence-Number: 31999 Martin Pitt writes: > Tom Lane [2011-12-20 21:14 -0500]: >> Another thing that is bothering me is that according to the gcc >> manual, eg here, >> http://gcc.gnu.org/onlinedocs/gcc-4.1.2/gcc/Atomic-Builtins.html >> __sync_lock_test_and_set is nominally provided for datatypes 1, 2, >> 4, or 8 bytes in length, but the underlying hardware doesn't >> necessarily support all those widths natively. If you pick the >> wrong width then you don't get an inline operation at all, but a >> call to some possibly inefficient library subroutine. > It's even worse. Our original version of the patch used a char, and > while that worked fine on the older Babbage board, it completely broke > at runtime on e. g. a Panda board. It wasn't just slow, it caused > hangs and test failures all over the place. With int it works > flawlessly. Yeah, that was another thing I found worrisome while googling: there were a disturbingly large number of claims that __sync_lock_test_and_set and/or __sync_lock_release were flat-out broken on various combinations of gcc version and platform. After reading that, there is no way at all that I'd accept your original patch to use these functions everywhere. For the moment I'm inclined to consider using these functions *only* on ARM, so as to limit our exposure to such bugs. That would also limit the risk of using an inappropriate choice of lock width. regards, tom lane