From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-18.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id BE1B3C07E9E for ; Sun, 11 Jul 2021 10:41:40 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id AA0B0611CC for ; Sun, 11 Jul 2021 10:41:40 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232580AbhGKKoZ (ORCPT ); Sun, 11 Jul 2021 06:44:25 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48568 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232566AbhGKKoV (ORCPT ); Sun, 11 Jul 2021 06:44:21 -0400 Received: from mail-pg1-x532.google.com (mail-pg1-x532.google.com [IPv6:2607:f8b0:4864:20::532]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 41CB4C0613F0 for ; Sun, 11 Jul 2021 03:41:34 -0700 (PDT) Received: by mail-pg1-x532.google.com with SMTP id a2so14968552pgi.6 for ; Sun, 11 Jul 2021 03:41:34 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=KBSuwCB1b/ChF6VSdcQNyQNSh8bYSwVqW8B8R0ec9VE=; b=xhWgw3iFr8/U4uX5kgVIqi8ul9JY2MhFFBYkxejz8PQMqDSEorI99wAJunU2RdzZ17 eYWXhkgmQawPN+JFA7m1t9Zs7Rxy5NuMFnh1eVuGqL4/Z0kZUTyn7EiTQkruZ1fSAydf zqhl+pqNfYK0nR/RmO8sdSNY7xRcAiEUdSy475K10ur+gTOGBArHJbFf/sTAbwSZveUp 8LnNyciIcuw0hYKnFxxfrH+0Waxw7J/EyRD3eU1XfcPJo3Yra1honTD2gKKT1uRRBQma 4ibgvKdwYo9P3NTwKRwIvrcKgQYTOV4xF4MksP53rfQLPa6WM1ZKJoO1N08B7KGpIC7m 5hPA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=KBSuwCB1b/ChF6VSdcQNyQNSh8bYSwVqW8B8R0ec9VE=; b=P62Pq0rC/F42vc2h+evR5EHB6pqa+qTOTlA929H3D6WjbjNjry3c0Qo4elDNVvgIrx gIaRgccrJETRXl/FLcyZQOK2aUTW5elYSv8IbF8huZmXMpK0gDQ7vY4MHJr3VfYCNDSo FQmAJVhLPOjMtVG0657u8XNIFdZ262jpOE3mq4k3Tta5y7dDvtis7/QtWn9VOiJnKCdx E8htpFbZ0e159n/ae+r3FdRqEkgwxP1e6mCWNHsiK58imj2vgMlvXv1QxGUfc9qhB3lM rYSv7M4Rz6yLV4rKHEEbYY7r16lwsxgrM1HQBO9ncXFChVzmHu3zBGXa7h+mQXu/pABE zfhw== X-Gm-Message-State: AOAM531Y3o0sEznMhHsLdd3kvlII91dNPP6WwDAoQ1Yr6n5JS8xFzZFA lSZFnMl8b8H4sfsuWQYZZ2G0fA== X-Google-Smtp-Source: ABdhPJwC8GIL92CJjSBM4G2vFFafsb76iiIzhffr9ihFZpGjdy5CpBKQnHtopqY2sy/WZ55qhKoINA== X-Received: by 2002:a65:56ca:: with SMTP id w10mr39995173pgs.107.1626000093757; Sun, 11 Jul 2021 03:41:33 -0700 (PDT) Received: from localhost ([103.127.241.250]) by smtp.gmail.com with ESMTPSA id d23sm10206682pjd.25.2021.07.11.03.41.32 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 11 Jul 2021 03:41:33 -0700 (PDT) From: Leo Yan To: Arnaldo Carvalho de Melo , Adrian Hunter , Peter Zijlstra , Ingo Molnar , Mark Rutland , Alexander Shishkin , Jiri Olsa , Namhyung Kim , Thomas Gleixner , Borislav Petkov , x86@kernel.org, "H. Peter Anvin" , Mathieu Poirier , Suzuki K Poulose , Mike Leach , linux-perf-users@vger.kernel.org, linux-kernel@vger.kernel.org, coresight@lists.linaro.org, linux-arm-kernel@lists.infradead.org Cc: Leo Yan Subject: [PATCH v4 06/11] perf auxtrace: Drop legacy __sync functions Date: Sun, 11 Jul 2021 18:41:00 +0800 Message-Id: <20210711104105.505728-7-leo.yan@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210711104105.505728-1-leo.yan@linaro.org> References: <20210711104105.505728-1-leo.yan@linaro.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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. [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 From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-17.5 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 9A4C3C07E96 for ; Sun, 11 Jul 2021 10:47:07 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 53AA561184 for ; Sun, 11 Jul 2021 10:47:07 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 53AA561184 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=linaro.org Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=Zj1YHVFbnv+tpAVmwsmU1Kachnq4zZuIPl0BtyFEcA8=; b=WDD32NJDNyFjW9 2UytPPRFaLpJYeKTIWwCZxaQBg7RrOwQK48l31RRrcwLTaMrx//VxCKMDVa883FmsxtBvgGGY5+0F 8TEwfs/Up3e3xO9JaOMnaqsCn7cj0x34BqdxqbQES5m90giyS2Ox1uzFN5Orco6WSVCDMmRnpeUfH PjOrMP/OIVDVHyM5JgwsN23W7l+mu3/VKCVeGmGb1up1lZBfv/nXQ9FCvdaQsXUid67jYJR6LpH0T UnpzBWTaqs4DcMkEvzNup/YmSIqgIBTra8FO5SHQI/6y98W9KQ/eHsc8GsjYkI4jKBeRdrKJCQzJs /g/lZK+MDo+DAXIi7d6g==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1m2Wxe-004tjV-IA; Sun, 11 Jul 2021 10:45:22 +0000 Received: from mail-pg1-x52f.google.com ([2607:f8b0:4864:20::52f]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1m2Wty-004sGl-Jh for linux-arm-kernel@lists.infradead.org; Sun, 11 Jul 2021 10:41:36 +0000 Received: by mail-pg1-x52f.google.com with SMTP id y17so14943688pgf.12 for ; Sun, 11 Jul 2021 03:41:34 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=KBSuwCB1b/ChF6VSdcQNyQNSh8bYSwVqW8B8R0ec9VE=; b=xhWgw3iFr8/U4uX5kgVIqi8ul9JY2MhFFBYkxejz8PQMqDSEorI99wAJunU2RdzZ17 eYWXhkgmQawPN+JFA7m1t9Zs7Rxy5NuMFnh1eVuGqL4/Z0kZUTyn7EiTQkruZ1fSAydf zqhl+pqNfYK0nR/RmO8sdSNY7xRcAiEUdSy475K10ur+gTOGBArHJbFf/sTAbwSZveUp 8LnNyciIcuw0hYKnFxxfrH+0Waxw7J/EyRD3eU1XfcPJo3Yra1honTD2gKKT1uRRBQma 4ibgvKdwYo9P3NTwKRwIvrcKgQYTOV4xF4MksP53rfQLPa6WM1ZKJoO1N08B7KGpIC7m 5hPA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=KBSuwCB1b/ChF6VSdcQNyQNSh8bYSwVqW8B8R0ec9VE=; b=mC7NeXpDiRcmDXSyIUb0v8VzAndRtbvRSgLo7HbPS9u4K66oFb9LCWj8KCbdcgqo+m UpupOcKqGB0fyi+PVZgx5LJNsktPcPlkCXfRvRn487kilG5gzsjThSi5P0kw+C20neul 6IdRJwGhbkp2Uc42tl2LeyrwRQqp5yLZWnsMbT+mO5I+2R8yHDE7UEEqySwMy2eCDNzH gmHaPGFlvQOEIjxjjAMGaj+EBF3S4bYGJ7+F4XoX5gzKraw+ViHUkJqT+8h37mMRAH4l rDKy9uodqMlxaQ9SRU8KB2630DqO8harCYSYALwQMbKPviRs5haVkx2qSfp83AYHOK7d /Hmw== X-Gm-Message-State: AOAM531HBB83r+dbc5P62ucgRrZv+NbiViEuEaEKlgKX+Rm7cWxUbYRm ffShbl6tKELgpgyYB6Vlnm6iGw== X-Google-Smtp-Source: ABdhPJwC8GIL92CJjSBM4G2vFFafsb76iiIzhffr9ihFZpGjdy5CpBKQnHtopqY2sy/WZ55qhKoINA== X-Received: by 2002:a65:56ca:: with SMTP id w10mr39995173pgs.107.1626000093757; Sun, 11 Jul 2021 03:41:33 -0700 (PDT) Received: from localhost ([103.127.241.250]) by smtp.gmail.com with ESMTPSA id d23sm10206682pjd.25.2021.07.11.03.41.32 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 11 Jul 2021 03:41:33 -0700 (PDT) From: Leo Yan To: Arnaldo Carvalho de Melo , Adrian Hunter , Peter Zijlstra , Ingo Molnar , Mark Rutland , Alexander Shishkin , Jiri Olsa , Namhyung Kim , Thomas Gleixner , Borislav Petkov , x86@kernel.org, "H. Peter Anvin" , Mathieu Poirier , Suzuki K Poulose , Mike Leach , linux-perf-users@vger.kernel.org, linux-kernel@vger.kernel.org, coresight@lists.linaro.org, linux-arm-kernel@lists.infradead.org Cc: Leo Yan Subject: [PATCH v4 06/11] perf auxtrace: Drop legacy __sync functions Date: Sun, 11 Jul 2021 18:41:00 +0800 Message-Id: <20210711104105.505728-7-leo.yan@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210711104105.505728-1-leo.yan@linaro.org> References: <20210711104105.505728-1-leo.yan@linaro.org> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20210711_034134_758107_C2C606CC X-CRM114-Status: GOOD ( 16.24 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org 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. [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 _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel