From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753176AbbEHOgt (ORCPT ); Fri, 8 May 2015 10:36:49 -0400 Received: from mail-ig0-f182.google.com ([209.85.213.182]:34359 "EHLO mail-ig0-f182.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751340AbbEHOgs (ORCPT ); Fri, 8 May 2015 10:36:48 -0400 Message-ID: <554CC9FE.7030509@gmail.com> Date: Fri, 08 May 2015 08:36:46 -0600 From: David Ahern User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.10; rv:31.0) Gecko/20100101 Thunderbird/31.6.0 MIME-Version: 1.0 To: Will Deacon , Peter Zijlstra CC: Arnaldo Carvalho de Melo , Ingo Molnar , Jiri Olsa , Namhyung Kim , Linux Kernel Mailing List Subject: Re: Question about barriers for ARM on tools/perf/ References: <20150508140459.GI7862@kernel.org> <20150508142107.GA25587@arm.com> <20150508142513.GM27504@twins.programming.kicks-ass.net> <20150508142711.GC25587@arm.com> In-Reply-To: <20150508142711.GC25587@arm.com> Content-Type: text/plain; charset=windows-1252; format=flowed Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 5/8/15 8:27 AM, Will Deacon wrote: > On Fri, May 08, 2015 at 03:25:13PM +0100, Peter Zijlstra wrote: >> On Fri, May 08, 2015 at 03:21:08PM +0100, Will Deacon wrote: >>> Wouldn't it be better to go the other way, and use compiler builtins for >>> the memory barriers instead of relying on the kernel? It looks like the >>> perf_mmap__{read,write}_head functions are basically just acquire/release >>> operations and could therefore be implemented using something like >>> __atomic_load_n(&pc->data_head, __ATOMIC_ACQUIRE) and >>> __atomic_store_n(&pc->data_tail, tail, __ATOMIC_RELEASE). >> >> He wants to do smp refcounting, which needs atomic_inc() / >> atomic_inc_non_zero() / atomic_dec_return() etc.. > > Right, of course, but GCC has those too: > > https://gcc.gnu.org/onlinedocs/gcc/_005f_005fatomic-Builtins.html And we need a solution that works from RHEL5 forward. Not sure what gcc version that is; RHEL6 uses 4.4.7. We have done a prototype with the __sync functions and it worked nicely. David