From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 31243 invoked by alias); 28 Mar 2016 17:36:38 -0000 Mailing-List: contact libc-alpha-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: libc-alpha-owner@sourceware.org Received: (qmail 31031 invoked by uid 89); 28 Mar 2016 17:36:37 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-1.9 required=5.0 tests=BAYES_00,KAM_LAZY_DOMAIN_SECURITY,RP_MATCHES_RCVD autolearn=ham version=3.3.2 spammy=synthetic, 5-10, exchange, our X-HELO: e24smtp01.br.ibm.com X-IBM-Helo: d24dlp02.br.ibm.com X-IBM-MailFrom: tuliom@linux.vnet.ibm.com X-IBM-RcptTo: libc-alpha@sourceware.org From: "Tulio Magno Quites Machado Filho" To: libc-alpha@sourceware.org Cc: adhemerval.zanella@linaro.org, munroesj@linux.vnet.ibm.com Cc: Subject: Re: [PING][PATCH v3] PowerPC: libc single-thread lock optimization In-Reply-To: <1457721337-30897-1-git-send-email-tuliom@linux.vnet.ibm.com> References: <540080DF.6030205@linux.vnet.ibm.com> <1457721337-30897-1-git-send-email-tuliom@linux.vnet.ibm.com> User-Agent: Notmuch/0.20.2 (http://notmuchmail.org) Emacs/24.4.51.1 (x86_64-unknown-linux-gnu) Date: Mon, 28 Mar 2016 17:36:00 -0000 Message-ID: <87zitia4j5.fsf@totoro.br.ibm.com> MIME-Version: 1.0 Content-Type: text/plain X-TM-AS-MML: disable X-Content-Scanned: Fidelis XPS MAILER x-cbid: 16032817-1524-0000-0000-00000B451F26 X-SW-Source: 2016-03/txt/msg00673.txt.bz2 Ping! Tulio Magno Quites Machado Filho writes: > I continued the work started by Adhemerval. The discussion around version 2 > of this patch is available at http://patchwork.sourceware.org/patch/2516/ > > Nowadays, we already require GCC 4.7, so we can safely rely on compiler > built-ins for most of our atomic primitives. > > Changes since v2: > - Updated ChangeLog and commit message. > - Replaced the following atomic primitives by compiler built-ins: > exchange*, and* and or*. > > ---8<--- > > Add relaxed atomics as a lock optimization. Addressing the concerns > raised in previous discussions, the primitives are still signal-safe > (although not thread-safe), so if future implementations relying on > this code (e.g. malloc) is changed to be async-safe, it won't require to > adjust powerpc atomics. > > For catomic_and and catomic_or I follow the definition at 'include/atomic.h' > (which powerpc is currently using) and implemented the atomics with acquire > semantics. The new implementation is based on compiler built-ins. > > On synthetic benchmarks it shows an improvement of 5-10% for malloc > calls and a performance increase of 7-8% in 483.xalancbmk from > speccpu2006 (number from a POWER8 machine). > > Checked on powerpc32, powerpc64 and powerpc64le. > > 2016-03-11 Adhemerval Zanella Netto > Tulio Magno Quites Machado Filho > > * malloc/malloc.c (malloc_consolidate): Replace 0 by NULL in > order to match the type of p when calling atomic_exchange_acq(). > * sysdeps/powerpc/atomic-machine.h > (__arch_atomic_exchange_32_acq): Removed. > (__arch_atomic_exchange_32_rel): Likewise > (__arch_compare_and_exchange_val_32_relaxed): New macro: atomic compare > and exchange with relaxed semantic. > (atomic_compare_and_exchange_val_relaxed): Likewise. > (__atomic_is_single_thread): New macro: check if program is > single-thread. > (atomic_compare_and_exchange_val_acq): Add relaxed operation for > single-thread. > (atomic_compare_and_exchange_val_rel): Likewise. > (atomic_exchange_acq): Likewise. > (atomic_exchange_rel): Likewise. > (catomic_and): Add relaxed operation and use compiler built-ins. > (catomic_or): Likewise. > (atomic_exchange_acq): Modify to use compiler built-ins. > (atomic_exchange_rel): Likewise. > * sysdeps/powerpc/powerpc32/atomic-machine.h > (__arch_compare_and_exchange_val_64_relaxed): New macro: add empty > implementation. > (__arch_atomic_exchange_64_relaxed): Likewise. > * sysdeps/powerpc/powerpc64/atomic-machine.h > (__arch_compare_and_exchange_val_64_relaxed): New macro: atomic compare > and exchange with relaxed semantics. > (__arch_atomic_exchange_64_acq): Removed. > (__arch_atomic_exchange_64_rel): Removed. -- Tulio Magno