From patchwork Sun Jul 11 10:40:55 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Leo Yan X-Patchwork-Id: 12369085 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=ham 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 7F4A5C07E96 for ; Sun, 11 Jul 2021 10:44:03 +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 45581610D2 for ; Sun, 11 Jul 2021 10:44:03 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 45581610D2 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=Umq2exi3lbU77HMZf7Gh9xA6qWF7amTbsrGZKsJjwGQ=; b=Xa+fBU1Twriqzg RrmSxqYShQe1Wfa2iCr/1r2kJSbFo/sLQj4lZ8fPiwuhU/d+B81/0jY1KYeSqk5Mjg3l/G3NhbJYq 1oJPib2drX7vGD7r75/hwY2q9xfTDQCO2krAUzJnp2Rec++e0HoQKVigwH2xejDru0ms8p60M2a4Q oQXpuJ7C7M8X3O0GihRt+S/Y+0nQqb0dDWP9A/YYcpyAE9/wVVA5EuBN5lTfM2dcdBKY8yHS6bLU9 RvDIQh6H3LwvMy0SDLivLNl13M9GujaQTM/z3ZmRYRWEC0W3Jr38GOpb+dD4cY4OC650joqyippTf Q8ugTCv/5i4EI4WOMMYA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1m2WuZ-004sUJ-WC; Sun, 11 Jul 2021 10:42:12 +0000 Received: from mail-pl1-x633.google.com ([2607:f8b0:4864:20::633]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1m2Wtk-004s8i-2N for linux-arm-kernel@lists.infradead.org; Sun, 11 Jul 2021 10:41:21 +0000 Received: by mail-pl1-x633.google.com with SMTP id j3so5564812plx.7 for ; Sun, 11 Jul 2021 03:41:19 -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=mUfdU9WBYmi8/NBmndyLWLFFhQ6mqBUwjCh/GuP5qb8=; b=RtX0qI4MGvgBvDGGTerEq7GxtH+wniuNEW7utX4Sj0O4q4Q26d6jcMwwestxzCiHzf QNREUyk2x12NqOorPsbS3FoidmVIpuT/X9x1hAaaDwk5vvIg5bJeUN/xIvP+5jXZxRNx u/oWY3EUWzmjc8kBz9+LguNLGpCx88gDP2zAl34xnTCTXim7dSVTNN4jzMPHY5CZfNP3 rQ+MsT5YTP5b2k71mOiwnmQObvk5ATNEF1tVHNUWlJA56zt5qd8az7VglCncXoOBA7Zf bgX5cPJFk47D0smGeeKZxFnYCvrVO30Dz7ypy3OlOpHsT0reQULiqgBvOOWyCoycLp+D xZDA== 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=mUfdU9WBYmi8/NBmndyLWLFFhQ6mqBUwjCh/GuP5qb8=; b=q25HBIkZNwVLMvJnd9cAYrx2F2h/txwNop+c+9E80lwUs80KVoJ/tGeE+y4DvvZb47 s7LOQrJ5GuwZbR8Wf6eCjOGKXGD+GgEfF+HmnbqpSFZTayk/tQfEpfbfWJz6S+RkLT9o OJN6+DycTMM5qLERYQM34oD/twIx46qxdOhkW0L+4P5XAv46c0ejXFT7/XIyezmoSYRM WGdZK5IQyx9X98mLIyshPVDNMDEVt7Wb9OuTPA9i3c3yodMIiY4l5NRV76YPfIRg19vV fsyfI9qdI9ylMHro4Fm61QGTVbaSpzueXo9eZbP55yR5MH7Qpp7MwfgOFoEW2Oo/N9Ot Myhw== X-Gm-Message-State: AOAM533/qL6TPlF0lAYlZHIsIKesHUKnSRneH2HRfFBmPsZjvJjkGbMt 0WjHAuH2qmlnCwoCTggSkFuVew== X-Google-Smtp-Source: ABdhPJyQ8XxCLn1vu+B0STHNwIFTAWH9uvWnYEj6A61rhx5yfvxHRMAmDfZWPGYHsUsY0F9uNVDSvg== X-Received: by 2002:a17:90a:9511:: with SMTP id t17mr48277859pjo.108.1626000079190; Sun, 11 Jul 2021 03:41:19 -0700 (PDT) Received: from localhost ([103.127.241.250]) by smtp.gmail.com with ESMTPSA id t2sm16735752pjq.0.2021.07.11.03.41.18 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 11 Jul 2021 03:41:18 -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 01/11] perf/ring_buffer: Add comment for barriers on AUX ring buffer Date: Sun, 11 Jul 2021 18:40:55 +0800 Message-Id: <20210711104105.505728-2-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_034120_160951_D965B684 X-CRM114-Status: GOOD ( 15.46 ) 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: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org AUX ring buffer applies almost the same barriers as perf ring buffer, but there has an exception for ordering between writing the AUX trace data and updating user_page::aux_head. This patch adds comment for how to use the barriers on AUX ring buffer, and gives comment to ask the drivers to flush the trace data into AUX ring buffer prior to updating user_page::aux_head. Signed-off-by: Leo Yan Acked-by: Peter Zijlstra (Intel) --- kernel/events/ring_buffer.c | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/kernel/events/ring_buffer.c b/kernel/events/ring_buffer.c index 52868716ec35..5cf6579be05e 100644 --- a/kernel/events/ring_buffer.c +++ b/kernel/events/ring_buffer.c @@ -509,6 +509,15 @@ void perf_aux_output_end(struct perf_output_handle *handle, unsigned long size) perf_event_aux_event(handle->event, aux_head, size, handle->aux_flags); + /* + * See perf_output_put_handle(), AUX ring buffer applies the same + * barrier pairing as the perf ring buffer; except for B, since + * AUX ring buffer is written by hardware trace, we cannot simply + * use the generic memory barrier (like smp_wmb()) prior to update + * user_page::aux_head, the hardware trace driver takes the + * responsibility to ensure the trace data has been flushed into + * the AUX buffer before calling perf_aux_output_end(). + */ WRITE_ONCE(rb->user_page->aux_head, rb->aux_head); if (rb_need_aux_wakeup(rb)) wakeup = true; From patchwork Sun Jul 11 10:40:56 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Leo Yan X-Patchwork-Id: 12369087 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=ham 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 ED20CC07E96 for ; Sun, 11 Jul 2021 10:44:19 +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 AE1D961159 for ; Sun, 11 Jul 2021 10:44:19 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org AE1D961159 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=LBGHnhE+zRJI1qPjd2jcqywIU2jUE5MQeyFi9Wr7E+c=; b=yc+RG05b+pDl77 1oir7raVJG8EU0lRKakLXVL/6zmC4hJwrFTDVAgRq5/6Ncy3rD98QAuWceoa9DfWAPbGGOdRMnZvv ohfgY8d9taIRodPNhczN3KTROwoyrHZ4nhisAQhgRHpWOTVGGlzjZgpjj4Qxt94g5jdkdeQBn9vpx DWAb9qtVp3rD+CgCoANddeSUt1VfTq+h+PvSI7tqr4G36S6f9VRFpbClvC9GaEhfq1igKPjRTmUD3 s7IgK5tqxhsb5RJGrWrCBWefbF8R6oRSaFiqLdscJvd5yVOrg8yLrGDapvlYhLprffEzZxe+F/XSO zyyQc88XNnUFb4ePC4tw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1m2Wuy-004scT-VY; Sun, 11 Jul 2021 10:42:37 +0000 Received: from mail-pl1-x62e.google.com ([2607:f8b0:4864:20::62e]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1m2Wtm-004sA7-QH for linux-arm-kernel@lists.infradead.org; Sun, 11 Jul 2021 10:41:24 +0000 Received: by mail-pl1-x62e.google.com with SMTP id c15so7471258pls.13 for ; Sun, 11 Jul 2021 03:41:22 -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=tvAJvuDnRJDe9YMY5R2L+q2C0nSKQeIr4jFz4M7hp0E=; b=er914k1odHGQXFxKzwCAlSjDGT1lEhzg/54+63PQydsGFVX2c9kqX4DPnaoiLiqnTP Sw261DSe/328/xnD6Q0ZHboHc2K56SXChdQ8gad+HDOsfl/dCd/Zkfda9mRDkkuz4V/F PxnXcnEgmWJSCgPt0zXCAszYveUShnZMGHu5vn5yxmAVcIC0pjjHzjY1X6lRErUI/oa6 PbqT1IFNUz5O3YrANKzyUQ/XhuAG3SdAY3lRCQzDVoUvMMdrEFpLSQw1ENZ9znLkXwvM wM6qimqRDCqFO3Wq2+eZ1BIfH/Im3aalssq5IIu+S5UCtJLL58kuPYMZwjGiJfUrW15c 73jA== 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=tvAJvuDnRJDe9YMY5R2L+q2C0nSKQeIr4jFz4M7hp0E=; b=l/BNP20TsoveeoXl5smD4Cer9d7MT3g3F3hSZ3jhILbzUFg1p4Y+lOe3vlVMRjTrGK pbtBhPniXGerVrKmrCC/8YGo38aFle+vH1IDh98NktBgo8+a1GdNNFl7rceWV1ylNqZu xCYwPOJXipLnir++fiUARlOjVCAzmqmjV5eUww//ECd3mQUgXeYayAvQEU7Fqf7OL9uO Kz5M32tr8ngMZBVtz/+5S2ZudSK1lbb8ZaoaxAL1hy3+VmJbfMMpTzKIa8zZn5XfQS7Y urpuiGi3xeZc/8iQ9BY2FM9ZXKfBn2TgCh6eoa6WhYsUIrXzNV6Efx/3i5PARfv+WzUf ofMQ== X-Gm-Message-State: AOAM5308b2+Z23+vGxfikT99bmgDTsm1PlK8R/+Dwr7i8hwtPKtyynXZ 7M+3LEHY7h6eHuxPh0Zdm4rk2g== X-Google-Smtp-Source: ABdhPJx3EsK700CJoPDmV2uQscNMM5W/vzqGJIPYWH/E+Oq8jMLYvmO+fUcusoi8LDNTAkzV9oH4bg== X-Received: by 2002:a17:90a:4681:: with SMTP id z1mr7368243pjf.156.1626000082010; Sun, 11 Jul 2021 03:41:22 -0700 (PDT) Received: from localhost ([103.127.241.250]) by smtp.gmail.com with ESMTPSA id d191sm13945165pga.27.2021.07.11.03.41.21 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 11 Jul 2021 03:41:21 -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 02/11] coresight: tmc-etr: Add barrier after updating AUX ring buffer Date: Sun, 11 Jul 2021 18:40:56 +0800 Message-Id: <20210711104105.505728-3-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_034122_898213_B91645AA X-CRM114-Status: GOOD ( 13.11 ) 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: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org Since a memory barrier is required between AUX trace data store and aux_head store, and the AUX trace data is filled with memcpy(), it's sufficient to use smp_wmb() so can ensure the trace data is visible prior to updating aux_head. Signed-off-by: Leo Yan Reviewed-by: Suzuki K Poulose --- drivers/hwtracing/coresight/coresight-tmc-etr.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/drivers/hwtracing/coresight/coresight-tmc-etr.c b/drivers/hwtracing/coresight/coresight-tmc-etr.c index acdb59e0e661..713205db15a1 100644 --- a/drivers/hwtracing/coresight/coresight-tmc-etr.c +++ b/drivers/hwtracing/coresight/coresight-tmc-etr.c @@ -1563,6 +1563,14 @@ tmc_update_etr_buffer(struct coresight_device *csdev, */ if (etr_perf->snapshot) handle->head += size; + + /* + * It requires the ordering between the AUX trace data and aux_head + * store, below smp_wmb() ensures the AUX trace data is visible prior + * to updating aux_head. + */ + smp_wmb(); + out: /* * Don't set the TRUNCATED flag in snapshot mode because 1) the From patchwork Sun Jul 11 10:40:57 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Leo Yan X-Patchwork-Id: 12369089 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=ham 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 4B82FC07E96 for ; Sun, 11 Jul 2021 10:44:47 +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 1CF9E61159 for ; Sun, 11 Jul 2021 10:44:47 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 1CF9E61159 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=VTIDxAXKVOF15iKPwM7JwRWuhlgvoW+b79dVI1gb3p8=; b=E4EyZllMABd9Qk tX1F9NFTZDrhFJhGe2pYYjR+YVMa/NtNs5itWCd733PssaODoijPDD+8AuZd1Hl0FEzt5IyDiQtz5 1jjjcPsPFY8tb9WnihOIUpMaqmkruxyAJj0P8K9gXxbQPsbWwrccP6q8KLe0X+GypGzisxfm+wg75 ucBdkpfS9/6xQhwfeOeM6fQXBhXmpWXq7xaWiWCLsork3XEhPLAC9ILtN3mENA0H9STpwYMSrIZu9 l6HhkvRoyrstQHp4Wra2CbTOxxyhq/yW/k7krW/8DqRuFhiXAP2jN6Lvf+xcFn9I4SenJAZc9cdyd IykObxyewwIbNIYvinTg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1m2WvQ-004snP-9Q; Sun, 11 Jul 2021 10:43:04 +0000 Received: from mail-pj1-x102a.google.com ([2607:f8b0:4864:20::102a]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1m2Wtq-004sC1-6D for linux-arm-kernel@lists.infradead.org; Sun, 11 Jul 2021 10:41:29 +0000 Received: by mail-pj1-x102a.google.com with SMTP id b8-20020a17090a4888b02901725eedd346so8725810pjh.4 for ; Sun, 11 Jul 2021 03:41:25 -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=MxgwZHP/NxGkiYvHiVeQZZDAd7piMTreovHUTu3tJE4=; b=JnuDDQXdPNRWlCR6EUfqkyGZnRvs0mSk1aPj/Uw0zb9ip1uVoMooO0nZVAE95eQfnv kfCjTMTDJ/fMr+7C5yf8Okx2Jjki94LXLE+IyjUJpC3C8ekWoOjmhx2ZET2xjTshaek8 SE+r8bWo5Ny0o+tjd21vcqXk6NLBsdwYVnC+XePA7mrnPJ+wc29/fqwkhDczXnHsjWiz DzKbhXhthyWAdTC7z+XEpYoprPi+T5VTVvRX4KOGes1D9ZtC1iuAOxJ1Odpy27OSUcLk k1egAO/BrwnfRXozDkX5tpWtT+FL1XQ86ru3oeKW8+VurrYCqZzm2B5Xiw0IFu6PyEyV cVqw== 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=MxgwZHP/NxGkiYvHiVeQZZDAd7piMTreovHUTu3tJE4=; b=kiqcHKlGkmFptyzb36EeUQ64IGSZzcV6EbRC3HMZQ/EaGcw+fpD91ngff4s1Rnngal wmVSy7UcO/Yfi7LGhSHBOEqYmwXLpCHuAiT26eZlf/9CFU3C66jF2LK8bUdfbWxYjPy6 Oh84z+0zCBGWDBltbF8wlCjG9tHhlL35b0xeyUncVPoS/3jQAlpb/0zmdqOQuMdBWMML QPBkXxewlX3TfUtqwze5WWbJCpPQzHginwnHR7JGaMZRAVbtbt564xfmaXUqxyMbzUr6 wsD1WhG8/9Zk3C9f+Ir/AIxk/m+mP4ZlMyDE9OwkBbyIZhoqt1cti7tAYirCkA3dzmJ0 s4Rg== X-Gm-Message-State: AOAM532w8ezsXmybYRErJ7nooIOHNx1Mf+zK+NJe4xNWoebFRatmfIeJ C/DJdfwU0FDT0AM6p56IXEBYGw== X-Google-Smtp-Source: ABdhPJzNZQip/BwALlXE7Z7NBJGyg6SKSf+M0vJ6RYGbUSs5QT+KzgE2IUOJho/3zqy/j8F/SKOUnA== X-Received: by 2002:a17:90b:3844:: with SMTP id nl4mr8431143pjb.78.1626000085273; Sun, 11 Jul 2021 03:41:25 -0700 (PDT) Received: from localhost ([103.127.241.250]) by smtp.gmail.com with ESMTPSA id j6sm10570265pji.23.2021.07.11.03.41.24 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 11 Jul 2021 03:41:24 -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 03/11] coresight: tmc-etf: Add comment for store ordering Date: Sun, 11 Jul 2021 18:40:57 +0800 Message-Id: <20210711104105.505728-4-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_034126_368249_2C7433EC X-CRM114-Status: GOOD ( 13.82 ) 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: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org AUX ring buffer is required to separate the data store and aux_head store, since the function CS_LOCK() has contained memory barrier mb(), mb() is a more conservative barrier than smp_wmb() on Arm32/Arm64, thus it's needless to add any explicit barrier anymore. Add comment to make clear for the barrier usage for ETF. Signed-off-by: Leo Yan --- drivers/hwtracing/coresight/coresight-tmc-etf.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/drivers/hwtracing/coresight/coresight-tmc-etf.c b/drivers/hwtracing/coresight/coresight-tmc-etf.c index 45b85edfc690..9a42ee689921 100644 --- a/drivers/hwtracing/coresight/coresight-tmc-etf.c +++ b/drivers/hwtracing/coresight/coresight-tmc-etf.c @@ -553,6 +553,12 @@ static unsigned long tmc_update_etf_buffer(struct coresight_device *csdev, if (buf->snapshot) handle->head += to_read; + /* + * AUX ring buffer requires to use memory barrier to separate the trace + * data store and aux_head store, because CS_LOCK() contains mb() which + * gives more heavy barrier than smp_wmb(), it's not necessary to + * explicitly invoke any barrier. + */ CS_LOCK(drvdata->base); out: spin_unlock_irqrestore(&drvdata->spinlock, flags); From patchwork Sun Jul 11 10:40:58 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Leo Yan X-Patchwork-Id: 12369091 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=ham 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 D46F4C07E96 for ; Sun, 11 Jul 2021 10:45:29 +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 8FCD261184 for ; Sun, 11 Jul 2021 10:45:29 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 8FCD261184 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=fDxD3wdzpM0hp2cxqHu4CtfvR2D32UTPe7gtfPEVSYE=; b=e32aOEe4NE3Mdb cOEE6D9uBspLaxK8z8REl745YAk0MJX46hX6T9C1Hdhe0vrJaFR0SY+QbaNDxNOILx7eKxVLsdZeM Cd30q6tVj3HX8Z7hrydFe0nevYz5/gi5xZFZFlH33zV8jgHE9/gTCmFEA3/vLLr18y8C/z5cjI9T5 FwY8CDqt+dlLNF7S8ANPxXDtw1TMXl1+JmV4CBHFn5nj8CuVmgG36GbCOV13U1qmZWujWPb/9AcAs dkO4ZBwomdTz+anPaS6IFD6Ufa7r0QDj+NE7uw4Ml3NDaGUUS0lWgKVtWTX+/ODdEgc4ulJXovY3i GEHiofj7GwrE6KFVV40Q==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1m2Wvx-004t1E-Dz; Sun, 11 Jul 2021 10:43:38 +0000 Received: from mail-pf1-x42a.google.com ([2607:f8b0:4864:20::42a]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1m2Wts-004sDT-VL for linux-arm-kernel@lists.infradead.org; Sun, 11 Jul 2021 10:41:30 +0000 Received: by mail-pf1-x42a.google.com with SMTP id y4so13325247pfi.9 for ; Sun, 11 Jul 2021 03:41:28 -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=Q5Wf8ghZ23c6vSvSmNVjb2NVOeSumBPmpt+tM4X+4G0=; b=lyx0w/3i2J+y8CQc61EkPiIT6/dGLPzkaz7rfy+3+zdS2LKYhCN3ohFbBOQVnkr5vo c2QSHAkUQmYjofvTN++VJ8GVQlmbwsW/LHW82wh4QnkGR8pye+CS6TAQDUQUnd3Cwogk HNhZAvfFkccsVf++cXdroo8L9TMDDQzJTJjkuzpuz3Ysh+WXgzQzQ6cEsgs387G+liSe 0YRNVEQJyrH8s6PyNWZ7gQnmGD8BwkOHe0yOdZVXvAz+26Tjns4lpRZQVkZqrmNMKMvL JNEzSOgyosIHx1ZjVZlafGpAY1c22KJvTAf946Df3Ic2yJcQdUgzaA1UwDVMSsHL+VyA 5j1A== 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=Q5Wf8ghZ23c6vSvSmNVjb2NVOeSumBPmpt+tM4X+4G0=; b=PUXxT0aoEicSgnMqltu/ZVolDqaq0dHlYc+ApdTzvjbGT4XpPZLSMTh2yjKmsU8iSD V4okJ5K9lnxxduYO3Z+7YPji9Qbq5I1D6T9vnphvYnuCvqSQ5a6paU4nuAQur3F9kz+Y C/iOGr+XLYVWSMt0APTvMLzyVJsaTLOppDT4DHJZTDn3vIZ9ZA3tbTzZFqNReuxZu7ud 76175OkVk/sUlDLYF/AdKHsEgQ7lE6zLJxS4B/EPbvGPWdjx84CI73jZP4+u2CNfvLR5 rLnf0eUR+taNc2sv/BM51gtIxcpb+lehYtMlQHjPqdm/2gv2sBKPmpnHxqO1Y5soL/Hw nk8A== X-Gm-Message-State: AOAM532Tg8cuWZFeTRqy8hkiBJQ4QqyLVo+raBfydfFSrxihYS6ehxLv tRP+gMqLJx7j2fJa+BkPdQF/nQ== X-Google-Smtp-Source: ABdhPJy7rSDkFVxHKzcS361rBBVWk82TUHhXPNVEgieYnRflyQ2XrW4SpdiE8S9LYx0A8Mr01spdNA== X-Received: by 2002:a63:e211:: with SMTP id q17mr25685112pgh.363.1626000088096; Sun, 11 Jul 2021 03:41:28 -0700 (PDT) Received: from localhost ([103.127.241.250]) by smtp.gmail.com with ESMTPSA id x13sm10181726pjh.30.2021.07.11.03.41.27 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 11 Jul 2021 03:41:27 -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 04/11] perf/x86: Add barrier after updating bts Date: Sun, 11 Jul 2021 18:40:58 +0800 Message-Id: <20210711104105.505728-5-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_034129_104415_4161271D X-CRM114-Status: GOOD ( 12.53 ) 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: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org Add barrier wmb() to separate the AUX data store and aux_head store. Signed-off-by: Leo Yan --- arch/x86/events/intel/bts.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/arch/x86/events/intel/bts.c b/arch/x86/events/intel/bts.c index 6320d2cfd9d3..4a015d160bc5 100644 --- a/arch/x86/events/intel/bts.c +++ b/arch/x86/events/intel/bts.c @@ -209,6 +209,9 @@ static void bts_update(struct bts_ctx *bts) } else { local_set(&buf->data_size, head); } + + /* The WMB separates data store and aux_head store matches. */ + wmb(); } static int From patchwork Sun Jul 11 10:40:59 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Leo Yan X-Patchwork-Id: 12369093 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=ham 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 D5895C07E96 for ; Sun, 11 Jul 2021 10:46:12 +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 9DBEE61159 for ; Sun, 11 Jul 2021 10:46:12 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 9DBEE61159 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=uB+wBDH8xYbL2qVVBqOflermyf+mks3LaXja+AdxeGE=; b=HShgVcEsrnGZVG VBB6F6xedCoFCOgYVEgPuB4OKIYdupQ1tXhzXyfnPGcz/EJyOB9eMkY4rJWadYV3aGQckZaIwYnu0 1zf32XMsCORHK/3BQAMH3/jUNmya4nGgYgzkcSDN4ySd7ch5hnUiUiqW5hPgoYBsei6c2JAGo0kQG KbCrPxGYAAt17YhC/evmN6DsYDvgnY1uStTk41F3oyTNncPCt6kAxr2QyivWjN19mbykob4IgS+el PWXZOcEA19SY8dzbONLKFNNbkhYclU3WhPy9ew/vr3qD4NaFTgv9sV08Gq6YDVs0846HpEI2syzIa n+HsxnAsdqxStLGclwug==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1m2Wwh-004tMP-91; Sun, 11 Jul 2021 10:44:23 +0000 Received: from mail-pl1-x62c.google.com ([2607:f8b0:4864:20::62c]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1m2Wtv-004sF5-Pb for linux-arm-kernel@lists.infradead.org; Sun, 11 Jul 2021 10:41:34 +0000 Received: by mail-pl1-x62c.google.com with SMTP id a14so7491542pls.4 for ; Sun, 11 Jul 2021 03:41:31 -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=u/h6y01vhaIboCmoU5QTv0ntWs0BLu7zaNEJjRy0DS4=; b=Zj4Ser95niZXysKWnByhPGn7HehGVUfl7nnW2uuuLdWtt8FvTDn1DJtkiYlqAnXvOM 7WCBS51r0hic0n23bnvsFNPevM4yPDsBKiSvWwSn6nKFqz0PWzZv+RJRknCjQCOzsDPP EuyR+YEhdCXDh2knglL4Cu/TkXTQyTnW1vqwwxc/d4uqpucKLc+vqGtouhD/lHT+TTI8 VT+K2XW6Icb+WrhYViyqeM+3Tm37FrkfBGFycyasGrpZuIa2WUVlspB/+2NUJDmRWuX8 jQypzUWDQ7ynkeWluJoJvOUOLYONU5hyByk9uTPe4CWIvrRD31gehKnInez5iF2XZ4z3 OnKQ== 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=u/h6y01vhaIboCmoU5QTv0ntWs0BLu7zaNEJjRy0DS4=; b=A5f3XiFoRnXUorDi/E08P135yS6RfOei0xS/+XmkdVlB75uD+8FQJSvGxDXKSY5dsJ upd5QzFr4lWjWwgTNcha5NEkfBSmc/dxkKYUMw+GgTkbZpk5/hCh11176bS/HCye90Yd s+0KLmp+faPLS38UFQo5NiCGYZfByRjyY/+WMo3/zcWskwK9sa9HqOAcW/pcC6mF78Eb 8VNTfOsKkUpEBZxefE+4nktx6KTop60OABiE+uTE2LPKx6hiozS4KGzsGvS4HDiY3q5o SIlJNL8Iz5lwjl8YE7bAhyEhhTREEAQdgsrIZolNhrRVKoZ+FVCZKJ1L5g+yeYs8HPfV oF3Q== X-Gm-Message-State: AOAM531T3bkkAAR0NdLHJLy60aZkff1fDj2uy1CCrO4JZmFOrC61hOJA xdndykDMLissGRzC7CWzh3CFMw== X-Google-Smtp-Source: ABdhPJx2ZkD3Ke+xwOEnTb++Cdto4iZATSeueTetnce3xcHV5VkEW1GhkVilI+3vLAFjAjrNQ7Ftgw== X-Received: by 2002:a17:903:1243:b029:ed:8298:7628 with SMTP id u3-20020a1709031243b02900ed82987628mr38413186plh.11.1626000090951; Sun, 11 Jul 2021 03:41:30 -0700 (PDT) Received: from localhost ([103.127.241.250]) by smtp.gmail.com with ESMTPSA id w6sm14036962pgh.56.2021.07.11.03.41.30 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 11 Jul 2021 03:41:30 -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 05/11] perf auxtrace: Use WRITE_ONCE() for updating aux_tail Date: Sun, 11 Jul 2021 18:40:59 +0800 Message-Id: <20210711104105.505728-6-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_034131_888051_71147338 X-CRM114-Status: GOOD ( 14.16 ) 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: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org Use WRITE_ONCE() for updating aux_tail, so can avoid unexpected memory behaviour. Signed-off-by: Leo Yan Acked-by: Adrian Hunter Acked-by: Peter Zijlstra (Intel) --- tools/perf/util/auxtrace.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/perf/util/auxtrace.h b/tools/perf/util/auxtrace.h index cc1c1b9cec9c..79227b8864cd 100644 --- a/tools/perf/util/auxtrace.h +++ b/tools/perf/util/auxtrace.h @@ -480,7 +480,7 @@ static inline void auxtrace_mmap__write_tail(struct auxtrace_mmap *mm, u64 tail) /* 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) - pc->aux_tail = tail; + WRITE_ONCE(pc->aux_tail, tail); #else do { old_tail = __sync_val_compare_and_swap(&pc->aux_tail, 0, 0); From patchwork Sun Jul 11 10:41:00 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Leo Yan X-Patchwork-Id: 12369095 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: , 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, From patchwork Sun Jul 11 10:41:01 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Leo Yan X-Patchwork-Id: 12369097 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=ham 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 AA875C07E96 for ; Sun, 11 Jul 2021 10:47:48 +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 7069561159 for ; Sun, 11 Jul 2021 10:47:48 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 7069561159 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=+PJ0ZLFS9dIUD63Oj+L7GNSd0jqNFo91uFXWX2p98Fg=; b=a++UKhjg8sbmzW OOuLv3SI1FuZjnnf4IWUJZSsjWzJGtHBejcoMxXHCDUQ2vEqppo+pNFrSfOUtQJvSBYyFwXNO0cp8 FNXlQFXSAWx0TNYJZeS1SHKaVih4fHPjaqXOWUmupVJUNmmaOwpnWXf/8jaOCKxFCYe3e6aYOJFfC GeMjn1cgHbgJkY6Z+icsXsW2jf3XT47bG6NO811JPd3KgBFV+pTEZlMIlWrxlM5Gso9r46RkoPkS/ +cgwgKpFbKCHoiE2eEgdI89OY1iHtkgyy0gm+WjgwgOtvvUg+AdLKLroLTSv3MHmoY3t5VpxcUIkN FK/zWU1jr48KnAQP0qvQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1m2WyQ-004u1H-Qj; Sun, 11 Jul 2021 10:46:11 +0000 Received: from mail-pf1-x42f.google.com ([2607:f8b0:4864:20::42f]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1m2Wu1-004sI6-GB for linux-arm-kernel@lists.infradead.org; Sun, 11 Jul 2021 10:41:39 +0000 Received: by mail-pf1-x42f.google.com with SMTP id 21so13364619pfp.3 for ; Sun, 11 Jul 2021 03:41:37 -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=kkEOllshRjQL/AsgC277Y/O2zCWNhcoUJsl5iahG6Xw=; b=r3t5DXxk87nwQDHus4OE2UYk3L5lCMZPuk8LKYFoc2efl9wNS9ahDC8vcfVXCH6fVj 6V+uMPygEXUnDeQIEvQEMj7fhKp7NlQXmZgMoh9X6ey1cmg7qJ5++ls9gWmrPjbx8C2b u2HG3UdYr+xEPTOzSxdnMs+/TbdQPbonvkfHLbsdeAmFNZND59AZiAzS1U0H391JBMsE YDiP6hK5my9hr1FDYdY4ITiDcKPzHd6ehrfma3b0WEgKveWAopvImUn7C6m45mhiBn0D nxt8Xm1idtUpe96NCmnHMlvFUfOX+RoveJfFZ3DxaOD0RRh/s2uutrWWDUWkuZAgpAnE I+Xg== 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=kkEOllshRjQL/AsgC277Y/O2zCWNhcoUJsl5iahG6Xw=; b=dCtWjdA7ou2h/RNG8ihQ9EUXrJYNI13Kex/1Tq9GQ9EHHDS+kM3WvNFwyEUlnyB/yX wBAi6lxHOUWQiK7rmJcAs7hHO2UT1pkAKAVPZ25t61fzb1MSnU9RyRoBuqtghFFtVAvB cU72S7o05UrOeH4QZjocvxYcjnkIMU9ROOV7oLLngry5xL+cOQhEWGOzNSFW+gHfmut1 LA9sxpZ7YRbHpbdVAcB5xv/P6JCr8WeJZWxyLIjD2rJJu0kPFnwT+oXHmI+hD23h3eD6 Nf0gEywO0MBNvMaXn6b1QYY4tEnVjeQ9nNCEZxkktNHP7/OQ5g2VJbxH1SSk37jYWVj6 pV7w== X-Gm-Message-State: AOAM530nTns+s8LpxvPR3OAVd6RjD8iL8hIYtAuDMQ2NZErVPzIiO51I d5ByNH+bubgpdNxALz0ql6D5fA== X-Google-Smtp-Source: ABdhPJyrTBXR/XJLZhNLxu4wpVEIzMB1TraRsWe2fJghWktdvMaDePg5OxUllSODwoErCx4C+msgGw== X-Received: by 2002:a63:170b:: with SMTP id x11mr20913040pgl.253.1626000096511; Sun, 11 Jul 2021 03:41:36 -0700 (PDT) Received: from localhost ([103.127.241.250]) by smtp.gmail.com with ESMTPSA id g9sm8281997pfr.133.2021.07.11.03.41.35 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 11 Jul 2021 03:41:36 -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 07/11] perf auxtrace: Remove auxtrace_mmap__read_snapshot_head() Date: Sun, 11 Jul 2021 18:41:01 +0800 Message-Id: <20210711104105.505728-8-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_034137_603346_668D284F X-CRM114-Status: GOOD ( 15.69 ) 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: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org Since the function auxtrace_mmap__read_snapshot_head() is exactly same with auxtrace_mmap__read_head(), whether the session is in snapshot mode or not, it's unified to use function auxtrace_mmap__read_head() for reading AUX buffer head. And the function auxtrace_mmap__read_snapshot_head() is unused so this patch removes it. Signed-off-by: Leo Yan --- tools/perf/util/auxtrace.c | 5 ++--- tools/perf/util/auxtrace.h | 10 ---------- 2 files changed, 2 insertions(+), 13 deletions(-) diff --git a/tools/perf/util/auxtrace.c b/tools/perf/util/auxtrace.c index cb19669d2a5b..7958e17229ea 100644 --- a/tools/perf/util/auxtrace.c +++ b/tools/perf/util/auxtrace.c @@ -1686,13 +1686,12 @@ static int __auxtrace_mmap__read(struct mmap *map, union perf_event ev; void *data1, *data2; + head = auxtrace_mmap__read_head(mm); + if (snapshot) { - head = auxtrace_mmap__read_snapshot_head(mm); if (auxtrace_record__find_snapshot(itr, mm->idx, mm, data, &head, &old)) return -1; - } else { - head = auxtrace_mmap__read_head(mm); } if (old == head) diff --git a/tools/perf/util/auxtrace.h b/tools/perf/util/auxtrace.h index 4f9176368134..d68a5e80b217 100644 --- a/tools/perf/util/auxtrace.h +++ b/tools/perf/util/auxtrace.h @@ -440,16 +440,6 @@ struct auxtrace_cache; #ifdef HAVE_AUXTRACE_SUPPORT -static inline u64 auxtrace_mmap__read_snapshot_head(struct auxtrace_mmap *mm) -{ - struct perf_event_mmap_page *pc = mm->userpg; - u64 head = READ_ONCE(pc->aux_head); - - /* Ensure all reads are done after we read the head */ - smp_rmb(); - return head; -} - static inline u64 auxtrace_mmap__read_head(struct auxtrace_mmap *mm) { struct perf_event_mmap_page *pc = mm->userpg; From patchwork Sun Jul 11 10:41:02 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Leo Yan X-Patchwork-Id: 12369099 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=ham 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 40570C07E96 for ; Sun, 11 Jul 2021 10:48:34 +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 0B33961184 for ; Sun, 11 Jul 2021 10:48:34 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 0B33961184 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=aZVXbtuEIFjcWJGAk+nrZbQASoGazY7GBjXkIk65ciU=; b=X8lgt6sHbuURb4 abSBMAmrYlXE+wNTSBM1IRZsGuWltSKy1Xt+63dhfFRpZD5IZ6uRXVpFo0uB90DcjQd70f2gGDc2n awzhWjMNKfOReHtPiEf0S0yuQRdQnzuFuZ0sRfWuSrDLhFBUNyv6VQBPsAmrMfxtq5YYrwDMRub0G 4JLAZahJwbS8jcn/udJ2mgW39yw1POkIZqHjIwLr7ZokObpiwOachYwO/XKRMsIKjfH3z5UDqvrUD UWYNs8SLucJriaty91IJeHlxouca9uBHCOYkTbqQOzoJVt4tuSpQv3WanzS8oL1D56i6AUgF8S8Jz 6eZGprvbo6/8ARRcfNIA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1m2Wyy-004uCm-Tm; Sun, 11 Jul 2021 10:46:45 +0000 Received: from mail-pl1-x636.google.com ([2607:f8b0:4864:20::636]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1m2Wu4-004sJk-S6 for linux-arm-kernel@lists.infradead.org; Sun, 11 Jul 2021 10:41:42 +0000 Received: by mail-pl1-x636.google.com with SMTP id a14so7491633pls.4 for ; Sun, 11 Jul 2021 03:41:40 -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=tg4kPboEv8a50CVYTi4+9WCNhiUYVPJPPco+6cKmUZQ=; b=HBfB6xTheoC7W0jGr+IND8Dc+xf45Pl4OcIdBANA/8KAHA40loCVDsuKThFnuNVIC7 pA/NI+MDKq0puehth94k8+z1drCCyeoV1PmoRIyjWyWvj9nvm6GXUcW6fDpJighzoIlT 8DNU7dA3WPIM53WaZJ1WKak++KVGOOxwkUAXcmi7TFuFQF3/mbU5iUrYg25rx2h4R4Vr flb/MSUKIaa0ViTcqMILHNZG6Kt3yd3xu7Y7PtF3RfIDN4X4wp9r7TJSmtTz+SS7v5j5 U+FdXE3TVXoaJ7t+b9WQebJgHR1J8YvydRO071Ht0duDxCxp2Kp57hz4UUuvTQcEAA9A Wm+w== 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=tg4kPboEv8a50CVYTi4+9WCNhiUYVPJPPco+6cKmUZQ=; b=hRm/YaldgzFU21U/3urxMXsdjJ2oOp8isr77JehJ7EMb2Fy3r7ha+3nZ7rDzVh38Q+ 5MEsa94bDIMjYDXZJL5QeOS1dZ136Ffd4kOObsHUkLca7OQ8KZklzvp4l+GHBi+14IQU tDWVbTPM96QtTGH1Vz6xFK9vE590Bc4lZ+8eR6uR9xDhUZx0JP5+zLJ47Qbsgx3c3ZpR Tr9bHXIFXMiZF6P9yuySakGSLx3YbBXysKcgj/oOoAiOrxlJEmFqs4l/q5L+ANA/t9ff V3o7uo3NP9MratrEg3LLIAlxsk4FnvzPZEVvj5zKQaTrpzUoUG/qW8rNrlzxBlf3wnn4 iEvA== X-Gm-Message-State: AOAM533Nh22EPkaN6M1N8CESUComP8L94tpXmxXMDQ2mWpIJ+5+rnsIl gqwBAQohwcMnSwrJXM2N+XBAwA== X-Google-Smtp-Source: ABdhPJyFP2IA4WrbAagQhrSQ1fhtt8nGm2nPWr+r4ifwYH2PuGscAo8Lee8kFXCZKI3R9atYNv+UiA== X-Received: by 2002:a17:902:8d98:b029:129:18e5:8c31 with SMTP id v24-20020a1709028d98b029012918e58c31mr38737450plo.3.1626000100000; Sun, 11 Jul 2021 03:41:40 -0700 (PDT) Received: from localhost ([103.127.241.250]) by smtp.gmail.com with ESMTPSA id c136sm12182066pfc.201.2021.07.11.03.41.38 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 11 Jul 2021 03:41:39 -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 08/11] perf: Cleanup for HAVE_SYNC_COMPARE_AND_SWAP_SUPPORT Date: Sun, 11 Jul 2021 18:41:02 +0800 Message-Id: <20210711104105.505728-9-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_034141_001977_1B17322D X-CRM114-Status: GOOD ( 12.46 ) 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: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org Since the __sync functions have been dropped, This patch removes unused build and checking for HAVE_SYNC_COMPARE_AND_SWAP_SUPPORT in perf tool. Signed-off-by: Leo Yan --- tools/perf/Makefile.config | 4 ---- tools/perf/util/auxtrace.c | 5 ----- 2 files changed, 9 deletions(-) diff --git a/tools/perf/Makefile.config b/tools/perf/Makefile.config index eb8e487ef90b..4a0d9a6defc7 100644 --- a/tools/perf/Makefile.config +++ b/tools/perf/Makefile.config @@ -349,10 +349,6 @@ CXXFLAGS += $(INC_FLAGS) LIBPERF_CFLAGS := $(CORE_CFLAGS) $(EXTRA_CFLAGS) -ifeq ($(feature-sync-compare-and-swap), 1) - CFLAGS += -DHAVE_SYNC_COMPARE_AND_SWAP_SUPPORT -endif - ifeq ($(feature-pthread-attr-setaffinity-np), 1) CFLAGS += -DHAVE_PTHREAD_ATTR_SETAFFINITY_NP endif diff --git a/tools/perf/util/auxtrace.c b/tools/perf/util/auxtrace.c index 7958e17229ea..6a63be8b2430 100644 --- a/tools/perf/util/auxtrace.c +++ b/tools/perf/util/auxtrace.c @@ -130,11 +130,6 @@ int auxtrace_mmap__mmap(struct auxtrace_mmap *mm, return 0; } -#if BITS_PER_LONG != 64 && !defined(HAVE_SYNC_COMPARE_AND_SWAP_SUPPORT) - pr_err("Cannot use AUX area tracing mmaps\n"); - return -1; -#endif - pc->aux_offset = mp->offset; pc->aux_size = mp->len; From patchwork Sun Jul 11 10:41:03 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Leo Yan X-Patchwork-Id: 12369101 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 13D53C07E96 for ; Sun, 11 Jul 2021 10:49:34 +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 CF22F61185 for ; Sun, 11 Jul 2021 10:49:33 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org CF22F61185 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=hoz/QTh6f6k2EWYcQ6HsS9gtlaWh5lQMw2+6VcR+4QA=; b=Vo0FM+/RmtjCjh VkrvYFToYfyE3wi0HhDmuXKeLFJEfHzzRSSB/kPu6KLNv/bfTh3xXe6uAlccx/brU2gp+FU0spoYt STUzZUoPcvICWRmPtBEZyEYO8A+AaHJaVKQz2xJ3goIpwj1OBGqm3BlKzhSIjRnxVvPtVWvsxylqx MxzRiyx9Y8lWFaIengv0tGf/+pDVmKxK6ev/KDCDdWpmwY9teRLJi4zHJqnZ9bxlbQ0ByP53WCO9g tiaFBt8odr0fZDbPJRQWL/7k1NYEpZ4360S0tUUsrleaKOd4NIsF1y0JPA63z+9xj9uKEggpJo3LL alAWfWYiqnNUOIz10/cw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1m2Wzi-004uSO-6o; Sun, 11 Jul 2021 10:47:30 +0000 Received: from mail-pf1-x42b.google.com ([2607:f8b0:4864:20::42b]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1m2Wu7-004sLS-PQ for linux-arm-kernel@lists.infradead.org; Sun, 11 Jul 2021 10:41:45 +0000 Received: by mail-pf1-x42b.google.com with SMTP id j199so13357418pfd.7 for ; Sun, 11 Jul 2021 03:41:43 -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=LPazFJ4r8q67LCTGt2fdXct+L4YxBkcY5QLx/BSTmrQ=; b=POvLLo4cHkWQlMAsLQ4Y9JpAuqI1FU+6UmXnb8T6wONYc1quoDbOal1BKMsRaoWMLI 2tU94Nw0RiwIvRb/uzrwla4KSNUP6QXgiL38agwG8J9ly8dMUFKHoUriKWWqhaLB+PFO ytG8fe+mo/Oe8BpVaJGb6cJhRkKD4ik9TOh8sNDaAGk9s21p/NXV+hNuym5T+ZxE3utr M2WKoakee71J8E43t7Bm0OPLCu+Nu4aa61gEpmo3UvvF9L7oUjB0/V172k6hpVVytFF6 IlyYSVjs3Q8DjFrN6tqXry+5+YMnMwpJ7+rf3HMf6AwRpQImiztGNS0pe/7xwueIOiGY wBIw== 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=LPazFJ4r8q67LCTGt2fdXct+L4YxBkcY5QLx/BSTmrQ=; b=Xm5eASGmQnaMP7od2+7wlnqUqgXaZjMZ6sWhUySs0ItsXY7nSCgNlgf5kMnMErRh1T 6sQ3RrF0SVt0GbppZfz8PFmY4eH7Y0h+MyyAvHG5WmXdpaB/qx//Z4H2gygGAe69QU8j lkorh3G55PPQY7kHvCcXTMOYNMwkrcOzEu8k5T0g4X1lQRmU6oZLM4/+X/Ga3rIuZ5Zi hejjiuL/gBV2h+MD8MwMo1sz+MkLRbMMJrGPe2KKpAP0yegaQlQlduX5kYsmmxsi3f4o 2ENIt2iu6f/5KPj0z9i10McEAyYtkayPkwZXutbd7EOyyHxpNUsqBgPof2b3rPRKY1ms FX3g== X-Gm-Message-State: AOAM531jV+FVwPKqO5k1quZCgs5ATD6uSuFAm0H9utVrM0kqx7nYw6Ei wVWMRm1oodVO/mTeC1Xq+i2yXA== X-Google-Smtp-Source: ABdhPJxB9gRNxabK5m9zDDqBPjCJQYStcE6pZh/+2ENwklS8HlAU8vKuEB6cKafXlP6K7pQJO8CTHQ== X-Received: by 2002:a63:cc0c:: with SMTP id x12mr46939866pgf.1.1626000102841; Sun, 11 Jul 2021 03:41:42 -0700 (PDT) Received: from localhost ([103.127.241.250]) by smtp.gmail.com with ESMTPSA id e16sm14171739pgl.54.2021.07.11.03.41.42 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 11 Jul 2021 03:41:42 -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 09/11] tools: Remove feature-sync-compare-and-swap feature detection Date: Sun, 11 Jul 2021 18:41:03 +0800 Message-Id: <20210711104105.505728-10-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_034143_873576_A9AD37DD X-CRM114-Status: GOOD ( 15.55 ) 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: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org Since the __sync functions have been removed from perf, it's needless for perf tool to test the feature sync-compare-and-swap. The feature test is not used by any other components, remove it. Signed-off-by: Leo Yan --- tools/build/Makefile.feature | 1 - tools/build/feature/Makefile | 4 ---- tools/build/feature/test-all.c | 4 ---- tools/build/feature/test-sync-compare-and-swap.c | 15 --------------- 4 files changed, 24 deletions(-) delete mode 100644 tools/build/feature/test-sync-compare-and-swap.c diff --git a/tools/build/Makefile.feature b/tools/build/Makefile.feature index 04a8e3db8a54..3dd2f68366f9 100644 --- a/tools/build/Makefile.feature +++ b/tools/build/Makefile.feature @@ -34,7 +34,6 @@ FEATURE_TESTS_BASIC := \ dwarf_getlocations \ eventfd \ fortify-source \ - sync-compare-and-swap \ get_current_dir_name \ gettid \ glibc \ diff --git a/tools/build/feature/Makefile b/tools/build/feature/Makefile index ec203e28407f..eff55d287db1 100644 --- a/tools/build/feature/Makefile +++ b/tools/build/feature/Makefile @@ -9,7 +9,6 @@ FILES= \ test-dwarf_getlocations.bin \ test-eventfd.bin \ test-fortify-source.bin \ - test-sync-compare-and-swap.bin \ test-get_current_dir_name.bin \ test-glibc.bin \ test-gtk2.bin \ @@ -260,9 +259,6 @@ $(OUTPUT)test-libdw-dwarf-unwind.bin: $(OUTPUT)test-libbabeltrace.bin: $(BUILD) # -lbabeltrace provided by $(FEATURE_CHECK_LDFLAGS-libbabeltrace) -$(OUTPUT)test-sync-compare-and-swap.bin: - $(BUILD) - $(OUTPUT)test-compile-32.bin: $(CC) -m32 -o $@ test-compile.c diff --git a/tools/build/feature/test-all.c b/tools/build/feature/test-all.c index 464873883396..920439527291 100644 --- a/tools/build/feature/test-all.c +++ b/tools/build/feature/test-all.c @@ -106,10 +106,6 @@ # include "test-libdw-dwarf-unwind.c" #undef main -#define main main_test_sync_compare_and_swap -# include "test-sync-compare-and-swap.c" -#undef main - #define main main_test_zlib # include "test-zlib.c" #undef main diff --git a/tools/build/feature/test-sync-compare-and-swap.c b/tools/build/feature/test-sync-compare-and-swap.c deleted file mode 100644 index 3bc6b0768a53..000000000000 --- a/tools/build/feature/test-sync-compare-and-swap.c +++ /dev/null @@ -1,15 +0,0 @@ -// SPDX-License-Identifier: GPL-2.0 -#include - -volatile uint64_t x; - -int main(int argc, char *argv[]) -{ - uint64_t old, new = argc; - - (void)argv; - do { - old = __sync_val_compare_and_swap(&x, 0, 0); - } while (!__sync_bool_compare_and_swap(&x, old, new)); - return old == new; -} From patchwork Sun Jul 11 10:41:04 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Leo Yan X-Patchwork-Id: 12369103 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 18B7AC07E96 for ; Sun, 11 Jul 2021 10:50:29 +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 D8699611AF for ; Sun, 11 Jul 2021 10:50:28 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org D8699611AF 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=wwpSVY3RVitMhPI+MsjI9o32AG6fHfUH8k3vZTvgWrg=; b=2+6Y+KQsT847nZ cniE6JMvFw620GRD9fqmoTquCQomod23S3NDYyj41CPlPleh9DfXjOkArZEw7vSD1Kx8dAS2SAc0I 0o9a4ratKfLhuflKiapUpTwLJJ08BdjIapab3XsO6Eg0HN4GYDSTLW2f4CWV1wwSYThjm1aGYTxCU kEfJikm24w3m7uYtbnfHqfzH8G36uNRB86TVuog301mLnRdtt6kbghRUnZq5Ess9E3EosoidE8AAA 1QuXeBbNnaCbEzOm4HRIQ92wto7WQYxPTScSe7aH9hSzQ3VKvCQ5qM5MHIVFRi/eujvhbY1bUihvq rqu6livP5xA0jVgOdMcQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1m2X0g-004unV-1G; Sun, 11 Jul 2021 10:48:31 +0000 Received: from mail-pl1-x632.google.com ([2607:f8b0:4864:20::632]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1m2WuA-004sMm-Kg for linux-arm-kernel@lists.infradead.org; Sun, 11 Jul 2021 10:41:48 +0000 Received: by mail-pl1-x632.google.com with SMTP id z2so4581089plg.8 for ; Sun, 11 Jul 2021 03:41:46 -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=8WBHdMiNLmIcoS32XEem64SidgwwayFr5+ViHTdRenk=; b=EIaNg9j2rZ8VjBp2Ru1d3pbSkzhH1TZGwMBQfIAMo9StPWmImfULZiZbCEhoWb80D6 XOmzRSfywoys3eaekT+MNj07FnSbXjLmmR+V4CDh3S+xj3o4EupJ9UczuEBvfnd7YRde C7FZRp0gPB/eZP5ESKYFs99ZO7tLuYCoVo5mHJJDHYpS1VOjOBu5GucU0deXi/4U+Get FxjvDcGB16CkxYN1fOQS7M9bh0zYZ5K6IpDa3npaZI3HVhNIGq2dVIUKujKcwqKJ+Edv vFJ620Ba68Mpo5Lp2x9xkmUh2VQ/LtGD5W9KcTVpZrS3FI8Fh9EM0aryln9sT8/fWGc+ QhnA== 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=8WBHdMiNLmIcoS32XEem64SidgwwayFr5+ViHTdRenk=; b=fqFUhWR+cUY9xGpQqWpnQDUEHDtyW2FnoK6kAu+YO5beSUe5kNPJSulVspfQEQ1jmL vnJhMW3CO9RDuz25rM/v2RzS9fmvRE0P6Vamvd21xHwftiB8eHq7XLs29mDFWhhrGF+c f2opdh69stK0QUNUjT1Bbn9jiGNgPpfTIukeApuRUANJWs5+vlwrlb1bgF46KMNH7ezZ +82afnDD/Nl5dXhkouG87DyRpsyMKlI8wDTtCsQAo8m6C01RvrPX7j+Utmnq0459RxAa EzDAQjdamuY2kyiqNOSpeKD+idPauOlfy3oSPmOzy48YyJaxm/TwGFv0jdiiBjSmOE58 mf+A== X-Gm-Message-State: AOAM533Gq6SIajjsqaAl3+mRnpFQkbQ0QlQG5aSDnfCm0UPwKOHkfe2T dSYxuu7pLqZYT0JBxyXNLtOdMw== X-Google-Smtp-Source: ABdhPJx0+4d0Te0gQRwFPbMZtMfjEw0kaMwmkcHx5kjHd/IOrs6YQeaGRm41Sxs2ZCcCMa4F7kj8ow== X-Received: by 2002:a17:90b:4a90:: with SMTP id lp16mr47619927pjb.137.1626000105798; Sun, 11 Jul 2021 03:41:45 -0700 (PDT) Received: from localhost ([103.127.241.250]) by smtp.gmail.com with ESMTPSA id 3sm4169592pfm.25.2021.07.11.03.41.44 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 11 Jul 2021 03:41:45 -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 10/11] perf env: Set flag for kernel is 64-bit mode Date: Sun, 11 Jul 2021 18:41:04 +0800 Message-Id: <20210711104105.505728-11-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_034146_809511_3CA4B302 X-CRM114-Status: GOOD ( 17.32 ) 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: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org It's useful to know that the kernel is running in 32-bit or 64-bit mode. E.g. We can decide if perf tool is running in compat mode from this info. This patch adds a global variable "kernel_is_64_bit", it's initialized when a session setups environment, its value is decided by checking the architecture string. Signed-off-by: Leo Yan --- tools/perf/util/env.c | 17 ++++++++++++++++- tools/perf/util/env.h | 1 + 2 files changed, 17 insertions(+), 1 deletion(-) diff --git a/tools/perf/util/env.c b/tools/perf/util/env.c index ebc5e9ad35db..345635a2e842 100644 --- a/tools/perf/util/env.c +++ b/tools/perf/util/env.c @@ -11,6 +11,7 @@ #include #include +int kernel_is_64_bit; struct perf_env perf_env; #ifdef HAVE_LIBBPF_SUPPORT @@ -172,6 +173,19 @@ static void perf_env__purge_bpf(struct perf_env *env __maybe_unused) } #endif // HAVE_LIBBPF_SUPPORT +static void perf_env__init_kernel_mode(struct perf_env *env) +{ + const char *arch = perf_env__raw_arch(env); + + if (!strncmp(arch, "x86_64", 6) || !strncmp(arch, "aarch64", 7) || + !strncmp(arch, "arm64", 5) || !strncmp(arch, "mips64", 6) || + !strncmp(arch, "parisc64", 8) || !strncmp(arch, "riscv64", 7) || + !strncmp(arch, "s390x", 5) || !strncmp(arch, "sparc64", 7)) + kernel_is_64_bit = 1; + else + kernel_is_64_bit = 0; +} + void perf_env__exit(struct perf_env *env) { int i; @@ -217,13 +231,14 @@ void perf_env__exit(struct perf_env *env) zfree(&env->hybrid_cpc_nodes); } -void perf_env__init(struct perf_env *env __maybe_unused) +void perf_env__init(struct perf_env *env) { #ifdef HAVE_LIBBPF_SUPPORT env->bpf_progs.infos = RB_ROOT; env->bpf_progs.btfs = RB_ROOT; init_rwsem(&env->bpf_progs.lock); #endif + perf_env__init_kernel_mode(env); } int perf_env__set_cmdline(struct perf_env *env, int argc, const char *argv[]) diff --git a/tools/perf/util/env.h b/tools/perf/util/env.h index 6824a7423a2d..cc989ff49740 100644 --- a/tools/perf/util/env.h +++ b/tools/perf/util/env.h @@ -139,6 +139,7 @@ enum perf_compress_type { struct bpf_prog_info_node; struct btf_node; +extern int kernel_is_64_bit; extern struct perf_env perf_env; void perf_env__exit(struct perf_env *env); From patchwork Sun Jul 11 10:41:05 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Leo Yan X-Patchwork-Id: 12369105 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 C5686C07E96 for ; Sun, 11 Jul 2021 10:51:33 +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 89FC061179 for ; Sun, 11 Jul 2021 10:51:33 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 89FC061179 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=B+p/3nGSAHj7znlY9NZNInWBorvZNJW4BLNtb5VNl0I=; b=uYDoovKUcmiL7f CCT4qmQmpiPNKS5mx9rL9sKBUkSRwGI3o4v4XqXSo7fR74lFjkaSZJimXgNBCg21I+1CobLs4YCPu cSi8oYZ2PflBWykifrRzdDHv2G0A0RsbsO0IygCWqPK7/knCl3u5KgAi4ugCmc2R+JZB4mpg66m8n 6VnHJBEzR21OgrGBj+QBaNXjg6iAJWhPoTwAKLniIyBQd4UrVY1bZzju5sl3hqozhQkRAkzsMV5f+ j5NqtW7ssM5mbEdswKZPK8y2ZuNE8fql4mIT67BfVeulLNYcunwztLSduM4ovKofGea037SGito69 UVewd5GD2OJLGFUKSuAg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1m2X1l-004vDl-7a; Sun, 11 Jul 2021 10:49:38 +0000 Received: from mail-pg1-x530.google.com ([2607:f8b0:4864:20::530]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1m2WuD-004sOM-Dw for linux-arm-kernel@lists.infradead.org; Sun, 11 Jul 2021 10:41:51 +0000 Received: by mail-pg1-x530.google.com with SMTP id h4so14969322pgp.5 for ; Sun, 11 Jul 2021 03:41:49 -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=r/tGyqhrBoK91o4eCemyjadg6GlA9KSC6VamX5cgheU=; b=eFEcv+8r6OlhUaVPY7jy/IUCvqioh3wDxBp8UB6a6cxPKtq2AdIghdUkDBI7pMTDI3 TO7wKKfEWqmjQyPzh1I4DEb30+sVaHqfj09ksvynYZUN/MzRCXr85cfRBwcvxLLUUtOC /dEn3LUrOo/nwNUROrdfcv+59/VVU7n/na/fhM2NQyLGzuu6Ew2c4VmIHf5Pq3yGX9tL FNPEcwlIo62hlmuLXdC43OE5EISgH4eEuH1xQJl12c6awQWoU8pIDHbhlvXoHtFed/9O CTdA0E+i+/5szy48J0ZDSi+/EBH9urStYc3kjpb/c+uocuCAcE8wadWo35FWION6VQlp XXuQ== 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=r/tGyqhrBoK91o4eCemyjadg6GlA9KSC6VamX5cgheU=; b=mIoZojGN/Iar2lkdvDsJS0Y6qHIq0RPaeTd5xfC4LQRjUJNxLcTWbe02fr3NxCnion P3FA9bLAKtz95W9X7weuogMu7Pp7o9B7iKDa7oyFXMkvqOwgFdShf7n9YpjQTG3wlKzX dB0FEczqDIBNDbCn9bpMksECvSqGsOWqLrUuS9yjw5Cnso9MAoFypZPa8jYBVK7jFji1 KliiriyvCCMAw+4+WB3H/rE62np8K/IwxDd3zMnxO0bGefl8DswYpJ4IoDBQFVgYIkd9 NIBcjQ7lxz2+pgK0djU9MZ91OPSxGUWmlZXwoIv+r1zBx5Z1I4QSchYi/VjpFIoeUkO2 olGQ== X-Gm-Message-State: AOAM533SuCLjC6EEsrAUfU3Em1zg1LfiAkJcBn6zfPls7U0CpqM5idB5 RX7fkUL8chTe9W90S8YGTzv7jg== X-Google-Smtp-Source: ABdhPJwAoXkLeUcaQpHcDt4kwAI6BVMAiNJjmO8p0o2fJKXs7tVEnzR/EhPW0ZB3udHnBB5QMHLlNw== X-Received: by 2002:a63:515f:: with SMTP id r31mr47275292pgl.406.1626000108577; Sun, 11 Jul 2021 03:41:48 -0700 (PDT) Received: from localhost ([103.127.241.250]) by smtp.gmail.com with ESMTPSA id s33sm1628476pfw.158.2021.07.11.03.41.47 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 11 Jul 2021 03:41:48 -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 11/11] perf auxtrace: Add compat_auxtrace_mmap__{read_head|write_tail} Date: Sun, 11 Jul 2021 18:41:05 +0800 Message-Id: <20210711104105.505728-12-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_034149_535545_AAC97708 X-CRM114-Status: GOOD ( 31.23 ) 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: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org When perf runs in compat mode (kernel in 64-bit mode and the perf is in 32-bit mode), the 64-bit value atomicity in the user space cannot be assured, E.g. on some architectures, the 64-bit value accessing is split into two instructions, one is for the low 32-bit word accessing and another is for the high 32-bit word. This patch introduces two functions compat_auxtrace_mmap__read_head() and compat_auxtrace_mmap__write_tail(), as their naming indicates, when perf tool works in compat mode, it uses these two functions to access the AUX head and tail. These two functions can allow the perf tool to work properly in certain conditions, e.g. when perf tool works in snapshot mode with only using AUX head pointer, or perf tool uses the AUX buffer and the incremented tail is not bigger than 4GB. When perf tool cannot handle the case when the AUX tail is bigger than 4GB, the function compat_auxtrace_mmap__write_tail() returns -1 and tells the caller to bail out for the error. Suggested-by: Adrian Hunter Signed-off-by: Leo Yan --- tools/perf/util/auxtrace.c | 9 ++-- tools/perf/util/auxtrace.h | 94 +++++++++++++++++++++++++++++++++++++- 2 files changed, 98 insertions(+), 5 deletions(-) diff --git a/tools/perf/util/auxtrace.c b/tools/perf/util/auxtrace.c index 6a63be8b2430..d6fc250fbf97 100644 --- a/tools/perf/util/auxtrace.c +++ b/tools/perf/util/auxtrace.c @@ -1766,10 +1766,13 @@ static int __auxtrace_mmap__read(struct mmap *map, mm->prev = head; if (!snapshot) { - auxtrace_mmap__write_tail(mm, head); - if (itr->read_finish) { - int err; + int err; + err = auxtrace_mmap__write_tail(mm, head); + if (err < 0) + return err; + + if (itr->read_finish) { err = itr->read_finish(itr, mm->idx); if (err < 0) return err; diff --git a/tools/perf/util/auxtrace.h b/tools/perf/util/auxtrace.h index d68a5e80b217..66de7b6e65ec 100644 --- a/tools/perf/util/auxtrace.h +++ b/tools/perf/util/auxtrace.h @@ -18,6 +18,8 @@ #include #include +#include "env.h" + union perf_event; struct perf_session; struct evlist; @@ -440,23 +442,111 @@ struct auxtrace_cache; #ifdef HAVE_AUXTRACE_SUPPORT +/* + * In the compat mode kernel runs in 64-bit and perf tool runs in 32-bit mode, + * 32-bit perf tool cannot access 64-bit value atomically, which might lead to + * the issues caused by the below sequence on multiple CPUs: when perf tool + * accesses either the load operation or the store operation for 64-bit value, + * on some architectures the operation is divided into two instructions, one + * is for accessing the low 32-bit value and another is for the high 32-bit; + * thus these two user operations can give the kernel chances to access the + * 64-bit value, and thus leads to the unexpected load values. + * + * kernel (64-bit) user (32-bit) + * + * if (LOAD ->aux_tail) { --, LOAD ->aux_head_lo + * STORE $aux_data | ,---> + * FLUSH $aux_data | | LOAD ->aux_head_hi + * STORE ->aux_head --|-------` smp_rmb() + * } | LOAD $data + * | smp_mb() + * | STORE ->aux_tail_lo + * `-----------> + * STORE ->aux_tail_hi + * + * For this reason, it's impossible for the perf tool to work correctly when + * the AUX head or tail is bigger than 4GB (more than 32 bits length); and we + * can not simply limit the AUX ring buffer to less than 4GB, the reason is + * the pointers can be increased monotonically (e.g in snapshot mode), whatever + * the buffer size it is, at the end the head and tail can be bigger than 4GB + * and carry out to the high 32-bit. + * + * To mitigate the issues and improve the user experience, we can allow the + * perf tool working in certain conditions and bail out with error if detect + * any overflow cannot be handled. + * + * For reading the AUX head, it reads out the values for three times, and + * compares the high 4 bytes of the values between the first time and the last + * time, if there has no change for high 4 bytes injected by the kernel during + * the user reading sequence, it's safe for use the second value. + * + * When update the AUX tail and detects any carrying in the high 32 bits, it + * means there have two store operations in user space and it cannot promise + * the atomicity for 64-bit write, so return '-1' in this case to tell the + * caller an overflow error has happened. + */ +static inline u64 compat_auxtrace_mmap__read_head(struct auxtrace_mmap *mm) +{ + struct perf_event_mmap_page *pc = mm->userpg; + u64 first, second, last; + u64 mask = (u64)(UINT32_MAX) << 32; + + do { + first = READ_ONCE(pc->aux_head); + /* Ensure all reads are done after we read the head */ + smp_rmb(); + second = READ_ONCE(pc->aux_head); + /* Ensure all reads are done after we read the head */ + smp_rmb(); + last = READ_ONCE(pc->aux_head); + } while ((first & mask) != (last & mask)); + + return second; +} + +static inline int compat_auxtrace_mmap__write_tail(struct auxtrace_mmap *mm, + u64 tail) +{ + struct perf_event_mmap_page *pc = mm->userpg; + u64 mask = (u64)(UINT32_MAX) << 32; + + if (tail & mask) + return -1; + + /* Ensure all reads are done before we write the tail out */ + smp_mb(); + WRITE_ONCE(pc->aux_tail, tail); + return 0; +} + static inline u64 auxtrace_mmap__read_head(struct auxtrace_mmap *mm) { struct perf_event_mmap_page *pc = mm->userpg; - u64 head = READ_ONCE(pc->aux_head); + u64 head; + +#if BITS_PER_LONG == 32 + if (kernel_is_64_bit) + return compat_auxtrace_mmap__read_head(mm); +#endif + head = READ_ONCE(pc->aux_head); /* Ensure all reads are done after we read the head */ smp_rmb(); return head; } -static inline void auxtrace_mmap__write_tail(struct auxtrace_mmap *mm, u64 tail) +static inline int auxtrace_mmap__write_tail(struct auxtrace_mmap *mm, u64 tail) { struct perf_event_mmap_page *pc = mm->userpg; +#if BITS_PER_LONG == 32 + if (kernel_is_64_bit) + return compat_auxtrace_mmap__write_tail(mm, tail); +#endif /* Ensure all reads are done before we write the tail out */ smp_mb(); WRITE_ONCE(pc->aux_tail, tail); + return 0; } int auxtrace_mmap__mmap(struct auxtrace_mmap *mm,