From patchwork Sun Jul 4 07:16:34 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Leo Yan X-Patchwork-Id: 12357225 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=-13.2 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,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 308F6C07E96 for ; Sun, 4 Jul 2021 07:20: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 E0CDD61879 for ; Sun, 4 Jul 2021 07:20:06 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org E0CDD61879 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: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:In-Reply-To:References: List-Owner; bh=cDprIvswjr0P4LvvdtQ4ud9SKxCazs1ibSIR9Ny5TIw=; b=si6APPF363+Sda /qxNl/TPBP89hNegF7VVkQIkJ5OJGi/tnZLKiJKbXyGX1C/lHQSDsuWBTBlw+GxEtNRxOE4bv6I2J GcDsKHtYb/3R2/7xiCuenQNX+chiCkqFABKxw4KHwXiUGk3sgYSxgj/TXLtYGTYp7ytA6o8M7qRf1 XzdW9tjXbVwTkHw++bKc/NxHasmsKqfREkeGXPhXK0rfIw8ro6jUNqxEPtd2ekFKiIcxa2GuotBSz KOgLyevteLz5qtp0xU+W5Jzj7cjak8yfIy+/z7D5IrSxJK6w5kfmAW8apjdNsfkyCH1HR8ThqwQjy pLJGrRQw21s8sEOYybig==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1lzwNN-005rLR-KQ; Sun, 04 Jul 2021 07:17:13 +0000 Received: from mail-pj1-x1031.google.com ([2607:f8b0:4864:20::1031]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1lzwNJ-005rJp-NN for linux-arm-kernel@lists.infradead.org; Sun, 04 Jul 2021 07:17:11 +0000 Received: by mail-pj1-x1031.google.com with SMTP id cx9-20020a17090afd89b0290170a3e085edso9420190pjb.0 for ; Sun, 04 Jul 2021 00:17:07 -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:mime-version :content-transfer-encoding; bh=KRbg9p2vbCl+er+gUJXwktP/Keb1bUuPjxMHf1K9hqI=; b=zHbowTD9YUbL0suwxG3+QDGgODWVtKvECn0sVqD0RcwXz23Ge5tFD0JQIPWQD9eEM5 s241NCR6rR9UB3/lYt5LzyczGFyATjzBPT+YtnC/PIq6jNuDw0XqQuUXKFlRFoIn/Do5 +7jWo6cYV1p88e9bu+BEz4JjA2Lv6JpPsA1LUz+ptS4qUSTIq3ap1PAonsPdJr9yrMfo JYNmMTU/1wEMhq2xtx+krJrFj9R5BM14vsUHaHHUglyOIQPquRn2E7hMd1sXqK3asIcO AesLdY4kbq5zW7j+vsSU2oC2sfAUIq6DHZiv6fRqKLHt4I/T/knutLaBaBszbnedUN/7 nzlw== 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:mime-version :content-transfer-encoding; bh=KRbg9p2vbCl+er+gUJXwktP/Keb1bUuPjxMHf1K9hqI=; b=oCKI3Hl4k+VjgvUdUnxgzQYcRWKnVGGX4PammQOaumzyX05qxx0Eex4YNLf/biOSyo CWTVZ9JoemQoickoQsmcppFZyXANWzE9uwdI2/wAv6zNsj8mmNdm4EOfvBGcobvDn/N3 mfwaQ86eI2YfV7jH47rh6ikSmVwdAxfz21y++YGWx3Fc2eAKno1B3XIxBmC0Wo7397u+ 0Iw/6lPIINFvRgf6REH37F3hr5BGaBvixfnu1iexwTKHhGozGcI4c0GP8ufKY37J1Hb8 AGsP3v0A1I+q3T/+V8chreHcj9gpwPN0P2nB1QqWzHINX5uxLFd0QqjSzSQMi6J1qc9Y s9+A== X-Gm-Message-State: AOAM533CZ0TCgiLurorD9AiinFKfrNRICp2KttXUcB9mLzspaIQKK3yP VDw4w/Zk73HBme1QX9eqAov9Ew== X-Google-Smtp-Source: ABdhPJzcaOKYIxTWXBxt0w5aoD7ycQZHn1CfQDS3U8eB4obSA+HUhexWu9WHUnbSdTYYVa4prYOQbQ== X-Received: by 2002:a17:902:6e02:b029:128:977c:217d with SMTP id u2-20020a1709026e02b0290128977c217dmr7187748plk.44.1625383026382; Sun, 04 Jul 2021 00:17:06 -0700 (PDT) Received: from localhost ([103.207.71.35]) by smtp.gmail.com with ESMTPSA id w14sm7217964pjb.3.2021.07.04.00.17.05 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 04 Jul 2021 00:17:05 -0700 (PDT) From: Leo Yan To: Arnaldo Carvalho de Melo , Peter Zijlstra , Adrian Hunter , 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 v3 00/10] perf: Refine barriers for AUX ring buffer Date: Sun, 4 Jul 2021 15:16:34 +0800 Message-Id: <20210704071644.107397-1-leo.yan@linaro.org> X-Mailer: git-send-email 2.25.1 MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20210704_001709_841257_2A4EC4A3 X-CRM114-Status: GOOD ( 18.52 ) 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 This patch series is to refine the memory barriers for AUX ring buffer. Patches 01 ~ 04 to address the barriers usage in the kernel. The first patch is to make clear comment for how to use the barriers between the data store and aux_head store, this asks the driver to make sure the data is visible. Patches 02 ~ 04 is to refine the drivers for barriers after the data store. Patches 05 ~ 07 is to drop the legacy __sync functions, and polish for duplicate code and cleanup the build after SYNC_COMPARE_AND_SWAP is not used. Patch 08 is to use WRITE_ONCE() for updating aux_tail. Since the 64-bit value's atomicity is not promised on 32-bit perf, the last two patches tries to fixup for perf tool when it runs in compat mode. Patch 09 introduces a new global variable to indicate the kernel runs in 64-bit mode which can be used to confirm if in compat mode; patch 10 introduces variant functions for accessing AUX head/tail, it can resolve the aotmicity issue for reading head pointer, and for the tail write overflow issue it returns error to notify the tool to exit. Have testes the patches on Arm64 Juno platform. Changes from v2: - Removed auxtrace_mmap__read_snapshot_head(), which has the duplicated code with auxtrace_mmap__read_head(); - Cleanuped the build for HAVE_SYNC_COMPARE_AND_SWAP_SUPPORT (Adrian); - Added global variable "kernel_is_64_bit" (Adrian); - Added compat variants compat_auxtrace_mmap__{read_head|write_tail} (Adrian). Leo Yan (10): perf/ring_buffer: Add comment for barriers on AUX ring buffer coresight: tmc-etr: Add barrier after updating AUX ring buffer coresight: tmc-etf: Add comment for store ordering perf/x86: Add barrier after updating bts perf auxtrace: Drop legacy __sync functions perf auxtrace: Remove auxtrace_mmap__read_snapshot_head() perf: Cleanup for HAVE_SYNC_COMPARE_AND_SWAP_SUPPORT perf auxtrace: Use WRITE_ONCE() for updating aux_tail perf env: Set kernel bit mode perf auxtrace: Add compat_auxtrace_mmap__{read_head|write_tail} arch/x86/events/intel/bts.c | 3 + .../hwtracing/coresight/coresight-tmc-etf.c | 6 + .../hwtracing/coresight/coresight-tmc-etr.c | 8 ++ kernel/events/ring_buffer.c | 9 ++ tools/perf/Makefile.config | 4 - tools/perf/util/auxtrace.c | 19 ++- tools/perf/util/auxtrace.h | 109 ++++++++++++++---- tools/perf/util/env.c | 17 ++- tools/perf/util/env.h | 1 + 9 files changed, 136 insertions(+), 40 deletions(-)