Received: by 2002:a05:6a10:c604:0:0:0:0 with SMTP id y4csp3026367pxt; Mon, 9 Aug 2021 15:04:32 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxGEdSAfG5/uuO8euOecbH2/5Tz9NseYnitBgsxNIrieHEo+z+mEnrXjcdKTrnt3anL25J3 X-Received: by 2002:a05:6e02:1107:: with SMTP id u7mr530933ilk.39.1628546672647; Mon, 09 Aug 2021 15:04:32 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1628546672; cv=none; d=google.com; s=arc-20160816; b=xEqhsOemGcw0OU9sv2LbHjVVry0HWYpLoomlwypq/6Ky8O22bcf1lBef0dbGmxPWYL /3wUP8wGVWxmrSDfhCA8oCUGNIh9ktGSKMsElF0X3qBpWxIOxR3IoMkDUY7HU8aC6yvY ywBAPNHb5Ukeflt2Virx+vdj5zxMD6qlRqPvC+C0iHBBTCRcpNK5wplsOnEOPoCY6o/f YEL2IRHdOH8WMPd2kfKlwCwUphoVu8irYWexE4oc0D5vYRZxN0b3bf4Zkv2ibf4H7IA+ q57rQHiuKKn62xoqYy4xFJNLLey1IWbYD2Og+0mmoobyss8QgWBS7dgay8j1eN7DvVGB w/Lg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=Z34g/DrIvbE8i7oGFOMhQSmugKh2MbnusvAVAxVPzfU=; b=KUL3kohOu27Yxq8cfTOELdG9xBESYbLYNeqNk8ntNzAYMb/obzq5bMzQgYcUthEfxh 0SZVSmTgUHLTbzEHn8lh4P/Pp3V4FVd+70o9Fz4YIy/Z1bhCdvPdNcKsTiQYwhsFADlV UGkxvcQzeI82+6WX75M48MpwH6G+aP5Vj/VbMgwbA7ysuhIFlwQZxBwhaqEZ8VmgUIaH a8vdB3gV6kNNdnYozAGy58idcEvAed7ADtmtD8wcBAM4wDj82qR73gBxEVwrSbZJ9c54 E0tvfkSL+eB0IAUdf0zi8pQziuxX8Ye1/pEN+8a8zUtuzF3zAFu7AjzNE7cTsXLGvV7n gesw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=dBHO6Uax; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id p4si4248200ilq.160.2021.08.09.15.04.20; Mon, 09 Aug 2021 15:04:32 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=dBHO6Uax; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234873AbhHIUAv (ORCPT + 99 others); Mon, 9 Aug 2021 16:00:51 -0400 Received: from mail.kernel.org ([198.145.29.99]:57288 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233496AbhHIUAu (ORCPT ); Mon, 9 Aug 2021 16:00:50 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id DC16A61004; Mon, 9 Aug 2021 20:00:29 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1628539230; bh=TW5Z07X1gH/zM2GID6GiUFMpFybiFvmvsv9FOxzh5o0=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=dBHO6UaxxzJVdReLbDg484WhhgWTM1F/t1GqhCijWvk1radTKDstUpHIpmJOqDWVL 9I2+V39XpMc+FrgUUTwCW0yXE3K81rY/ZYJiSxUl3zZcNOpoFy/nd45gkMqrI/fcoR +hYCvSxD5vjKQpnkVVsDmaJkHCtsa8eiy2nk144pg71cMUiQiDxs9ORIeIJTD4GTzc PtckQdCGzBNoaCBK5C4cutSccsNpwI1ut/44l9gb587+Ouh+7iRzYssGZch6UOfIUj 6dxur5Db9oN8w6RAUIWrEAKNdz3EkMLBRBHYFL+/8zTlQ7BCACu7fQidW295SpLvZA N2Un9nK7SJpGA== Received: by quaco.ghostprotocols.net (Postfix, from userid 1000) id 86626403F2; Mon, 9 Aug 2021 17:00:27 -0300 (-03) Date: Mon, 9 Aug 2021 17:00:27 -0300 From: Arnaldo Carvalho de Melo To: Leo Yan Cc: Peter Zijlstra , Adrian Hunter , Ingo Molnar , Mark Rutland , Alexander Shishkin , Jiri Olsa , Namhyung Kim , Thomas Gleixner , Borislav Petkov , "H. Peter Anvin" , Mathieu Poirier , Suzuki K Poulose , Mike Leach , Michael Petlan , "Frank Ch. Eigler" , Song Liu , x86@kernel.org, Daniel =?iso-8859-1?Q?D=EDaz?= , Andrii Nakryiko , Alexei Starovoitov , Sedat Dilek , Andi Kleen , linux-perf-users@vger.kernel.org, linux-kernel@vger.kernel.org, coresight@lists.linaro.org Subject: Re: [PATCH v5 6/9] perf auxtrace: Drop legacy __sync functions Message-ID: References: <20210809111407.596077-1-leo.yan@linaro.org> <20210809111407.596077-7-leo.yan@linaro.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20210809111407.596077-7-leo.yan@linaro.org> X-Url: http://acmel.wordpress.com Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Em Mon, Aug 09, 2021 at 07:14:04PM +0800, Leo Yan escreveu: > The main purpose for using __sync built-in functions is to support > compat mode for 32-bit perf with 64-bit kernel. But using these > built-in functions might cause potential issues. > > __sync functions originally support Intel Itanium processoer [1] > but it cannot promise to support all 32-bit archs. Now these > functions have become the legacy functions. > > Considering __sync functions cannot really fix the 64-bit value > atomicity on 32-bit archs, thus this patch drops __sync functions. > > Credits to Peter for detailed analysis. Thanks, applied to perf/core. - Arnaldo > [1] https://gcc.gnu.org/onlinedocs/gcc/_005f_005fsync-Builtins.html#g_t_005f_005fsync-Builtins > > Suggested-by: Peter Zijlstra > Signed-off-by: Leo Yan > --- > tools/perf/util/auxtrace.h | 19 ------------------- > 1 file changed, 19 deletions(-) > > diff --git a/tools/perf/util/auxtrace.h b/tools/perf/util/auxtrace.h > index 79227b8864cd..4f9176368134 100644 > --- a/tools/perf/util/auxtrace.h > +++ b/tools/perf/util/auxtrace.h > @@ -440,12 +440,6 @@ struct auxtrace_cache; > > #ifdef HAVE_AUXTRACE_SUPPORT > > -/* > - * In snapshot mode the mmapped page is read-only which makes using > - * __sync_val_compare_and_swap() problematic. However, snapshot mode expects > - * the buffer is not updated while the snapshot is made (e.g. Intel PT disables > - * the event) so there is not a race anyway. > - */ > static inline u64 auxtrace_mmap__read_snapshot_head(struct auxtrace_mmap *mm) > { > struct perf_event_mmap_page *pc = mm->userpg; > @@ -459,11 +453,7 @@ static inline u64 auxtrace_mmap__read_snapshot_head(struct auxtrace_mmap *mm) > static inline u64 auxtrace_mmap__read_head(struct auxtrace_mmap *mm) > { > struct perf_event_mmap_page *pc = mm->userpg; > -#if BITS_PER_LONG == 64 || !defined(HAVE_SYNC_COMPARE_AND_SWAP_SUPPORT) > u64 head = READ_ONCE(pc->aux_head); > -#else > - u64 head = __sync_val_compare_and_swap(&pc->aux_head, 0, 0); > -#endif > > /* Ensure all reads are done after we read the head */ > smp_rmb(); > @@ -473,19 +463,10 @@ static inline u64 auxtrace_mmap__read_head(struct auxtrace_mmap *mm) > static inline void auxtrace_mmap__write_tail(struct auxtrace_mmap *mm, u64 tail) > { > struct perf_event_mmap_page *pc = mm->userpg; > -#if BITS_PER_LONG != 64 && defined(HAVE_SYNC_COMPARE_AND_SWAP_SUPPORT) > - u64 old_tail; > -#endif > > /* Ensure all reads are done before we write the tail out */ > smp_mb(); > -#if BITS_PER_LONG == 64 || !defined(HAVE_SYNC_COMPARE_AND_SWAP_SUPPORT) > WRITE_ONCE(pc->aux_tail, tail); > -#else > - do { > - old_tail = __sync_val_compare_and_swap(&pc->aux_tail, 0, 0); > - } while (!__sync_bool_compare_and_swap(&pc->aux_tail, old_tail, tail)); > -#endif > } > > int auxtrace_mmap__mmap(struct auxtrace_mmap *mm, > -- > 2.25.1 > -- - Arnaldo