From patchwork Sun Jul 11 10:40:54 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Leo Yan X-Patchwork-Id: 12369083 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=-12.5 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,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 DDD12C07E96 for ; Sun, 11 Jul 2021 10:43: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 A21F6610D2 for ; Sun, 11 Jul 2021 10:43:19 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org A21F6610D2 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=sL7Fgyl/PeUHzY+xqpa2uXQDImqCF/6sbe46/TnpTnw=; b=3FZRXCsMDqYSjr 8XR1Nqnm/K3gkkfLx/oCpg21S6bcP8Da4x7SuakSMQURucyBm9jvrGDTS2kns+nrnfqdlJoPc4D0V qLP21EIA17onCCJqlDWIAL5CO3ePDxq+VoNc5ye5jUF3kKHN4PZhyodhgWutlmVYA6VNJUR7pcyKD TwV9mWo2Twh3huQ9Cj1LxNMku/wDSDqUCO9HVDUAOJj5rf9IR3VnQOjvAInXGVWkiHPvn8cLLsibx BnoYS6v8OG7vBNrSFE+dapDQV/EByiiEAfLsIuOMI4tRH/tnVeaw1BAePzYBHm7fw8a15dTdMuWed koPpdbdDfon35NFfXLbA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1m2Wtm-004s9g-I9; Sun, 11 Jul 2021 10:41:23 +0000 Received: from mail-pg1-x534.google.com ([2607:f8b0:4864:20::534]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1m2Wtg-004s6q-KU for linux-arm-kernel@lists.infradead.org; Sun, 11 Jul 2021 10:41:18 +0000 Received: by mail-pg1-x534.google.com with SMTP id w15so14950806pgk.13 for ; Sun, 11 Jul 2021 03:41:16 -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=autL+G6wNOJhX+2XA6qCLFYkzemigzI9rlpwicEf3/0=; b=qmxcjU7pcuXli6awXmV/nZtxDOtEBwFxPrj6N1DIcmTZdtfhFAaPT/AsX3g3YYrZpV v0vqF6jyLC1EKqz3YRS5wITXbvMjNmUjKEO/jPb/MUVroPlelu6xOA3qI6A8xxFvWTU4 VvqkBRJCNqFxVw3CURKvgtoZ0eqJHJQ8cXVfHnNNbbJMGcTwrfYAhoArao6DPawblPS9 5GWtOB/TnbTOefACYg8WKfeecai7diFsc//80s9+oLet10sngwTlOVNqRw0Wb9tTSmC/ ShsFIkXwaJ8HMSzv2XvXXMYiu0/ScBCknf3Syxq1FYijVXpl6wjR3VpHN4oEcSL1xKyp TQnQ== 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=autL+G6wNOJhX+2XA6qCLFYkzemigzI9rlpwicEf3/0=; b=rPjGgYtpd1SsDZAtCjKganNzxakVyeEFxPvyXQofXqCy+O1LP0b/r7WeUfLnzvozT3 iFjMR6LWzD+si3vWWeBzS6ZWkiIMZKY/Srzq8J3CNZBy0zhapkf+6nQ5j1yN5qz5k4eX 75nw/83N6IJWTfF0dCUYH/kxHPxT64jly1QDVxVFTW+HKUx/aWk/AswqXXfbYiVUcHXb SdhL9xlhf0RKTBAZE0kmsbYrY9+3+9Ah37rGoD8y5b/hvdIxdo8FL/91qToN+blU9BGS ApT+ZB2l+eJR/NlHbRdftzQSOBxBA9AATohm+6/Ops2uoq6QUsNsYXLdInDxfy5nVsN2 TE8w== X-Gm-Message-State: AOAM532aBpkzCHCgFWCjQ/5sAOih2RSJLhFi1C14+D6flgkh9AK1hUag ZYr3CPJ6JKfgcSUAf32HqOCE0A== X-Google-Smtp-Source: ABdhPJx6JaA27RaGLvgVyJTKnzik6HHN9J9xNcylnEcWBb6V6DAIk/u/8UHFXFG/VZOrnguSvrwVlA== X-Received: by 2002:a62:888d:0:b029:329:b081:128 with SMTP id l135-20020a62888d0000b0290329b0810128mr8217397pfd.70.1626000075775; Sun, 11 Jul 2021 03:41:15 -0700 (PDT) Received: from localhost ([103.127.241.250]) by smtp.gmail.com with ESMTPSA id d3sm10152263pjo.31.2021.07.11.03.41.14 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 11 Jul 2021 03:41:15 -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 00/11] perf: Refine barriers for AUX ring buffer Date: Sun, 11 Jul 2021 18:40:54 +0800 Message-Id: <20210711104105.505728-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-20210711_034116_724213_BFA2D7EA X-CRM114-Status: GOOD ( 19.00 ) 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. Patch 05 is to use WRITE_ONCE() for updating aux_tail. Patches 06 ~ 09 is to drop the legacy __sync functions, and polish for duplicate code and cleanup the build and feature test after SYNC_COMPARE_AND_SWAP is not used. Patch 10 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 11 introduces variant functions for accessing AUX head/tail, it resolves the aotmicity for reading head pointer, and returns error for the tail is bigger than 4GB. Have testes the patches on Arm64 Juno platform. Changes from v3: - Removed the inapprocate paragraph in the commit log for patch "perf auxtrace: Drop legacy __sync functions" (Adrian); - Added new patch to remove feature-sync-compare-and-swap test (Adrian); - Th patch for "perf auxtrace: Use WRITE_ONCE() for updating aux_tail", is a standlone and simple change, so moved it ahead in the patch set for better ordering; - Minor improvement for commit logs in the last two patches. 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 (11): 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: Use WRITE_ONCE() for updating aux_tail perf auxtrace: Drop legacy __sync functions perf auxtrace: Remove auxtrace_mmap__read_snapshot_head() perf: Cleanup for HAVE_SYNC_COMPARE_AND_SWAP_SUPPORT tools: Remove feature-sync-compare-and-swap feature detection perf env: Set flag for kernel is 64-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/build/Makefile.feature | 1 - tools/build/feature/Makefile | 4 - tools/build/feature/test-all.c | 4 - .../feature/test-sync-compare-and-swap.c | 15 --- 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 + 13 files changed, 136 insertions(+), 64 deletions(-) delete mode 100644 tools/build/feature/test-sync-compare-and-swap.c