From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752996AbbEHO5d (ORCPT ); Fri, 8 May 2015 10:57:33 -0400 Received: from mail.kernel.org ([198.145.29.136]:38114 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752165AbbEHO5c (ORCPT ); Fri, 8 May 2015 10:57:32 -0400 Date: Fri, 8 May 2015 11:57:01 -0300 From: Arnaldo Carvalho de Melo To: Will Deacon Cc: Peter Zijlstra , Ingo Molnar , David Ahern , Jiri Olsa , Namhyung Kim , Linux Kernel Mailing List Subject: Re: Question about barriers for ARM on tools/perf/ Message-ID: <20150508145701.GL7862@kernel.org> References: <20150508140459.GI7862@kernel.org> <20150508142107.GA25587@arm.com> <20150508142513.GM27504@twins.programming.kicks-ass.net> <20150508143729.GJ7862@kernel.org> <20150508144820.GD25587@arm.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20150508144820.GD25587@arm.com> X-Url: http://acmel.wordpress.com User-Agent: Mutt/1.5.23 (2014-03-12) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Em Fri, May 08, 2015 at 03:48:20PM +0100, Will Deacon escreveu: > On Fri, May 08, 2015 at 03:37:29PM +0100, Arnaldo Carvalho de Melo wrote: > > Em Fri, May 08, 2015 at 04:25:13PM +0200, Peter Zijlstra escreveu: > > > He wants to do smp refcounting, which needs atomic_inc() / > > > atomic_inc_non_zero() / atomic_dec_return() etc.. > > > > Right, Will concentrated on what we use those barriers for right now in > > tools/perf. > > > > What I am doing right now is to expose what we use in perf to a wider > > audience, i.e. code being developed in tools/, with the current intent > > of implementing referece counting for multithreaded tools/perf/ tools, > > right now only 'perf top', but there are patches floating to load a > > perf.data file using as many CPUs as one would like, IIRC initially one > > per available CPU. > > > > I am using as a fallback the gcc intrinsics (), but I've heard I rather > > should not use those, albeit they seemed to work well for x86_64 and > > sparc64: > > Do you know what the objection to the intrinsics was? I believe that > the __sync versions are deprecated in favour of the C11-like __atomic > flavours, so if that was all the objection was about then we could use > one or the other depending on what the compiler supports. Peter? Ingo? > > One of my hopes for a byproduct was to take advantage of improvements > > made to that code in the kernel, etc. > > > > At least using the same API, i.e. barrier(), mb(), rmb(), wmb(), > > atomic_{inc,dec_and_test,read_init} I will, the whole shebang would be > > even cooler. > > Perhaps, but including atomic.h sounds pretty fragile to me. Sure, if we > define the right set of macros we may get it to work today, but we could > easily get subtle breakages as the kernel sources move forward and we might > not easily notice/diagnose the failures in the perf tool. Ok, that is a good argument not to share the same source code and instead do what I am doing now, use it as the starting point, keep the source code as much as possible the same, so that doing a: diff -u arch/$ARCH/include/asm/barrier.h tools/arch/$ARCH/include/asm/barrier.h Would help in figuring out differences that may or may be desired, while tracking what the kernel does would help keep the tools/ version in the best possible shape. This could even make it more likely that the kernel developers would help having the best possible implementation in tools/ for that subset of their work... :-) - Arnaldo