From patchwork Tue Dec 24 10:44:08 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: James Clark X-Patchwork-Id: 13919931 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org 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 smtp.lore.kernel.org (Postfix) with ESMTPS id 4E25AE77188 for ; Tue, 24 Dec 2024 10:48:33 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:List-Subscribe:List-Help :List-Post:List-Archive:List-Unsubscribe:List-Id:Content-Transfer-Encoding: MIME-Version:References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From: Reply-To:Content-Type:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=zHAl/iVdRpFZ4l6Mby+FrJoyVvI8kLZuzTqR3xsa9gY=; b=0wKCncNEdcudbRjtoOpxn2buor JTVp4+iXNDhfGP2qhuZQQxhIfY9bYJHFNryyrGUD4X3ClOv4plLiawCwloCep4xyG7RpVtSEiC38Z rSWA2yUfkz2EWGxY4uCD7Dj65Uwwah1D6wgSo82Pr0fgk6bPWBKJQHWWgeG2MkiVKUf7lnS3m1fbH GOSqClyedEfnqUN2Gw2HQSDh8qvQjstJHJdNSD3HY/IExSHHozWBMVmfbbjYziTjAhCe2U+SoQV2z oWPIKq4dWVtCF/E7YTVRRrENVtB2/AIn76X5sbw7slpB9i0vDLejSlklqD4lhV7CRr1ng/awHr/At 5KkLOKkg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.98 #2 (Red Hat Linux)) id 1tQ2SY-0000000Bnyq-3MJb; Tue, 24 Dec 2024 10:48:18 +0000 Received: from mail-wr1-x432.google.com ([2a00:1450:4864:20::432]) by bombadil.infradead.org with esmtps (Exim 4.98 #2 (Red Hat Linux)) id 1tQ2P1-0000000Bn9u-1Yy8 for linux-arm-kernel@lists.infradead.org; Tue, 24 Dec 2024 10:44:41 +0000 Received: by mail-wr1-x432.google.com with SMTP id ffacd0b85a97d-385df53e559so4002252f8f.3 for ; Tue, 24 Dec 2024 02:44:38 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1735037077; x=1735641877; darn=lists.infradead.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=zHAl/iVdRpFZ4l6Mby+FrJoyVvI8kLZuzTqR3xsa9gY=; b=OtqJtOLykQE9b9FJH8tEde8E3CqbXUn0nAyu+FE7jEco8qzHSUKkzpkxRN/3Vgztaq 67/0IRmVNNNNPZlKnoZnqtVp6VU0ubws5/OTfsYa6ADRFWMXrgLghYRs4Wii6qcf7bGE xbQ+KVZXTriewVvFidUDR8gRlDjJYFnvJfMNsSl2RbL+3lIeTcHyaAQFxGPHo6GI8gqc taRR3AXMXehVtdW3fj3lKxiLahOSzJ7R30BRM6pJMwZv8m6uZlFSYwyNQZF9+Djy1EsR NsAgYSYNjNTEegjHW1qk+TA53eUvIirG+eT6wcTQadiDrr/V2GxV5d/ZfKYCjnYgwRr0 l2Ew== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1735037077; x=1735641877; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=zHAl/iVdRpFZ4l6Mby+FrJoyVvI8kLZuzTqR3xsa9gY=; b=kB0egfYgS/NBg5KXdRHXCvAknl3xOzzDJZgaq8Mzq7G6aMtC6wWtM25HgWbJwRFJf5 BmtFSUiJ9IqMcK3CFTGkz4z7OGSh0zj54dsAKoDzEmx5ayUwpZmykkE+GxrgQrn1bcdg ltO9Gj8uT9zvYcPaQ/6M5hC+XjHbp7GYd79mzOiwjrSgUJF8CD80iysig9jKxpPvz1Y6 B1dmKK8oIJpI4lfQlTGCp/l3F185yCx57IgD9bq/lQ2a8pDewrUL65ErdW5c9dvOJffC 8BdDJ4VHMQOiHd+ciEH+RpaYxeANrdqprWOBP/vIDzzGKS25yxnfjgq25OopRRwJaJJA zItw== X-Gm-Message-State: AOJu0Yx8nwkV9lr9i5fvYifqftg1aIgMoUWr0gny1Yx+RNcg7+/rvx2x eNMtrdehgK6xduMy51VQS2rQXEimlsIYE8rxc9Hbm/JF18XvzZh8YJMTpWrKSoNugEznqYfcowh D X-Gm-Gg: ASbGnctQbGdM5JQQa4ZZ/CDgLsXZ1MmZAyJ02gI+tZmWHsD+hWc6Apjrs3EVs/BJvYM VxoDmbEdTrw29iBVzorIj3yH5EXTPwW3j/CjlzYcAHiM3wzS6EMrsz/gaLDQWxRgJ0ohu9xFoYO kIWY/hvPPV6QEXT39/vnssGEFVd6kuDzjFf4tjlmB+QHGQEV+Ft9bXsxrTREqWaEobch6IpBdWc Fgf6PPRygJV0kZJwiVtcdzmr0DjmyWYrIr7iasB15InLsIW1pSDo2Q= X-Google-Smtp-Source: AGHT+IH7n+am9veH0sjuso0VQt6cOhLb48Ywipt9+tQpA2guKm2WC+9l0VoxKlK8wBiZB7S6GwshiQ== X-Received: by 2002:a05:6000:154f:b0:385:eeb9:a5bb with SMTP id ffacd0b85a97d-38a221f698amr13901717f8f.17.1735037077544; Tue, 24 Dec 2024 02:44:37 -0800 (PST) Received: from pop-os.. ([145.224.66.70]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-38a1c847714sm13938184f8f.54.2024.12.24.02.44.36 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 24 Dec 2024 02:44:37 -0800 (PST) From: James Clark To: linux-arm-kernel@lists.infradead.org, linux-perf-users@vger.kernel.org, irogers@google.com, yeoreum.yun@arm.com, will@kernel.org, mark.rutland@arm.com Cc: robh@kernel.org, James Clark , Peter Zijlstra , Ingo Molnar , Arnaldo Carvalho de Melo , Namhyung Kim , Alexander Shishkin , Jiri Olsa , Adrian Hunter , "Liang, Kan" , John Garry , Mike Leach , Leo Yan , Graham Woodward , linux-kernel@vger.kernel.org, bpf@vger.kernel.org Subject: [PATCH v2 1/5] perf: arm_spe: Add format option for discard mode Date: Tue, 24 Dec 2024 10:44:08 +0000 Message-Id: <20241224104414.179365-2-james.clark@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20241224104414.179365-1-james.clark@linaro.org> References: <20241224104414.179365-1-james.clark@linaro.org> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20241224_024439_419509_DE11493C X-CRM114-Status: GOOD ( 18.85 ) 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 FEAT_SPEv1p2 (optional from Armv8.6) adds a discard mode that allows all SPE data to be discarded rather than written to memory. Add a format bit for this mode. If the mode isn't supported, the format bit isn't published and attempts to use it will result in -EOPNOTSUPP. Allocating an aux buffer is still allowed even though it won't be written to so that old tools continue to work, but updated tools can choose to skip this step. Reviewed-by: Yeoreum Yun Signed-off-by: James Clark --- drivers/perf/arm_spe_pmu.c | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/drivers/perf/arm_spe_pmu.c b/drivers/perf/arm_spe_pmu.c index fd5b78732603..9aaf3f98e6f5 100644 --- a/drivers/perf/arm_spe_pmu.c +++ b/drivers/perf/arm_spe_pmu.c @@ -193,6 +193,9 @@ static const struct attribute_group arm_spe_pmu_cap_group = { #define ATTR_CFG_FLD_store_filter_CFG config /* PMSFCR_EL1.ST */ #define ATTR_CFG_FLD_store_filter_LO 34 #define ATTR_CFG_FLD_store_filter_HI 34 +#define ATTR_CFG_FLD_discard_CFG config /* PMBLIMITR_EL1.FM = DISCARD */ +#define ATTR_CFG_FLD_discard_LO 35 +#define ATTR_CFG_FLD_discard_HI 35 #define ATTR_CFG_FLD_event_filter_CFG config1 /* PMSEVFR_EL1 */ #define ATTR_CFG_FLD_event_filter_LO 0 @@ -216,6 +219,7 @@ GEN_PMU_FORMAT_ATTR(store_filter); GEN_PMU_FORMAT_ATTR(event_filter); GEN_PMU_FORMAT_ATTR(inv_event_filter); GEN_PMU_FORMAT_ATTR(min_latency); +GEN_PMU_FORMAT_ATTR(discard); static struct attribute *arm_spe_pmu_formats_attr[] = { &format_attr_ts_enable.attr, @@ -228,9 +232,15 @@ static struct attribute *arm_spe_pmu_formats_attr[] = { &format_attr_event_filter.attr, &format_attr_inv_event_filter.attr, &format_attr_min_latency.attr, + &format_attr_discard.attr, NULL, }; +static bool discard_unsupported(struct arm_spe_pmu *spe_pmu) +{ + return spe_pmu->pmsver < ID_AA64DFR0_EL1_PMSVer_V1P2; +} + static umode_t arm_spe_pmu_format_attr_is_visible(struct kobject *kobj, struct attribute *attr, int unused) @@ -238,6 +248,9 @@ static umode_t arm_spe_pmu_format_attr_is_visible(struct kobject *kobj, struct device *dev = kobj_to_dev(kobj); struct arm_spe_pmu *spe_pmu = dev_get_drvdata(dev); + if (attr == &format_attr_discard.attr && discard_unsupported(spe_pmu)) + return 0; + if (attr == &format_attr_inv_event_filter.attr && !(spe_pmu->features & SPE_PMU_FEAT_INV_FILT_EVT)) return 0; @@ -502,6 +515,12 @@ static void arm_spe_perf_aux_output_begin(struct perf_output_handle *handle, u64 base, limit; struct arm_spe_pmu_buf *buf; + if (ATTR_CFG_GET_FLD(&event->attr, discard)) { + limit = FIELD_PREP(PMBLIMITR_EL1_FM, PMBLIMITR_EL1_FM_DISCARD); + limit |= PMBLIMITR_EL1_E; + goto out_write_limit; + } + /* Start a new aux session */ buf = perf_aux_output_begin(handle, event); if (!buf) { @@ -743,6 +762,10 @@ static int arm_spe_pmu_event_init(struct perf_event *event) !(spe_pmu->features & SPE_PMU_FEAT_FILT_LAT)) return -EOPNOTSUPP; + if (ATTR_CFG_GET_FLD(&event->attr, discard) && + discard_unsupported(spe_pmu)) + return -EOPNOTSUPP; + set_spe_event_has_cx(event); reg = arm_spe_event_to_pmscr(event); if (reg & (PMSCR_EL1_PA | PMSCR_EL1_PCT)) From patchwork Tue Dec 24 10:44:09 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: James Clark X-Patchwork-Id: 13919933 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org 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 smtp.lore.kernel.org (Postfix) with ESMTPS id AE027E77188 for ; Tue, 24 Dec 2024 10:49:40 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:List-Subscribe:List-Help :List-Post:List-Archive:List-Unsubscribe:List-Id:Content-Transfer-Encoding: MIME-Version:References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From: Reply-To:Content-Type:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=I2Qn39K4UzsLsLGtfNH0/R87UIS/L19Vs2Fn7/eQxwo=; b=ReXv3mIaBaBbdw78f+elQR3lqP Qxl0rVRWCwTj5QQrFMsgpfs0dt4BHi08GtUZkqExYhIOm0rGbHXytO3pBbHej25Yzu3bHDcoL4OOE 4GNqv6WQNGI0D34AmqRUPfcLA3Cg0nv4MCEJgNewFK1TMw1d7qm1h00/ukO92qrNnIXXl6S/bI519 cBDxrVKwPKSs09TyMDW0eRWhmeE8Hz32wAa3iRa+CH3xMXyaarTba25zGPj00YOTvmAeaVi5oGUHP zf+1hBA8nl3W4Q5zuMS+TFpVNgH/fKaXvKuFTGn9q0IldkuFOBr+70fkNcqdTk+Umj4oUmrSMdw8J 6eRLHSdA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.98 #2 (Red Hat Linux)) id 1tQ2Th-0000000BoAc-2F0T; Tue, 24 Dec 2024 10:49:29 +0000 Received: from mail-wm1-x32d.google.com ([2a00:1450:4864:20::32d]) by bombadil.infradead.org with esmtps (Exim 4.98 #2 (Red Hat Linux)) id 1tQ2P5-0000000BnBV-1Ojo for linux-arm-kernel@lists.infradead.org; Tue, 24 Dec 2024 10:44:44 +0000 Received: by mail-wm1-x32d.google.com with SMTP id 5b1f17b1804b1-4362bae4d7dso36397995e9.1 for ; Tue, 24 Dec 2024 02:44:42 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1735037082; x=1735641882; darn=lists.infradead.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=I2Qn39K4UzsLsLGtfNH0/R87UIS/L19Vs2Fn7/eQxwo=; b=tAk61A024DZhQmm/APjGpfUUwtd66DSB/AcmRhuuTYou3Op6W1nPXz9HUKUTukTifd kgP6lSXW9jNJvqVt7SJcJscpcId0izjSjXkXf+7sB6tBegmYGrSk5pa2E+7rgpQUU/4C IuPajcjBXlBEkTL4tq7YPa80m2eLlrJlitzDiRWXe3RiOILEYIQZkmT9hJSXgUdU4nOn lPWuFnuzlu7XaeW4UCEBdb6GbYGrYlH4XlFW5k85bwMNas8cLNYkYzxagqOInmspK2p9 Xwxuq7WGSZG/fCdK4l1pDfgsEV9O22BTkRhcaSyWSQH7f9WIyYNyX+07LIkfz0YP/Jbz AB7A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1735037082; x=1735641882; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=I2Qn39K4UzsLsLGtfNH0/R87UIS/L19Vs2Fn7/eQxwo=; b=uWezZ/F6JPzH0cP/V3uzW3+O8gaGgfv+hYZn4LhIkhkwX0PSZ49oRIoDkBBUer3pI4 KSnRv2QL6wi+gcwZuFCjFkW/RsytWcAo8wLeK+kAPXF9e+cqLu2GdHWPcUClOG71U4Q1 7RuWpaYU/ReNebK9LQ0kGb78VgxOm4XssjC9FOfnpRwcVggGC4howAKK664x1vugJ7lH ExcyZubz08j0XXARuHeDvSkqLctv7s4bMNdOV89Qp+rS9QL5OELrhajFNCKYcHcfg0Nh Hk2W2Jry1W0A1uJR+G6C5IKsAKDD4xHD49aqydTHy7mdZuzfN6fu8HfcQeF48A+vUTmN urpQ== X-Gm-Message-State: AOJu0Yw/a/Hkv6NiIv2o4PgrvtOURpjB+lfB1rI3UglKAoV+lVXO/roW nVT/AMUO4dE/hzQOVcNc/MbMicd2IJ+QdzDMjKcfOkiDz5J9hoD9yE9wU0vuVtOJR5WnngGM13s B X-Gm-Gg: ASbGncueDuICkMhMQY9y7vtSzLLjw9xCsaeuleAMHJyQMlYIEr8IYbWuEiepirI35hv xTY11fapU+ijbH6F1zEfJioH7CdVQiObQJM99vxwN3zm/bvyskLvMWg3YKd4WtvSsmxoYW12DNQ ksxbDMghnLZGKqjJa8F/LGDJV4B9WVoC89pAXC/Twy5QWZ95zUDC4MJLCNwFZi5WgmwjXwip87Y GOZ9oCN9TEn1+twwRqVbsQCcOXjzn5iezuI7a0eec7zvyKK92ekDfk= X-Google-Smtp-Source: AGHT+IEPwGkn3TrrCW7UYR3VV36eBnjzsw1wNAbjqFQScWTBytZf17+BoI5sSqfPq7qT3qahHgFAcw== X-Received: by 2002:a05:6000:184e:b0:385:ed1e:2105 with SMTP id ffacd0b85a97d-38a221f2f0cmr14225299f8f.26.1735037081570; Tue, 24 Dec 2024 02:44:41 -0800 (PST) Received: from pop-os.. ([145.224.66.70]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-38a1c847714sm13938184f8f.54.2024.12.24.02.44.40 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 24 Dec 2024 02:44:41 -0800 (PST) From: James Clark To: linux-arm-kernel@lists.infradead.org, linux-perf-users@vger.kernel.org, irogers@google.com, yeoreum.yun@arm.com, will@kernel.org, mark.rutland@arm.com Cc: robh@kernel.org, James Clark , Peter Zijlstra , Ingo Molnar , Arnaldo Carvalho de Melo , Namhyung Kim , Alexander Shishkin , Jiri Olsa , Adrian Hunter , "Liang, Kan" , John Garry , Mike Leach , Leo Yan , Graham Woodward , linux-kernel@vger.kernel.org, bpf@vger.kernel.org Subject: [PATCH v2 2/5] perf tool: arm-spe: Pull out functions for aux buffer and tracking setup Date: Tue, 24 Dec 2024 10:44:09 +0000 Message-Id: <20241224104414.179365-3-james.clark@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20241224104414.179365-1-james.clark@linaro.org> References: <20241224104414.179365-1-james.clark@linaro.org> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20241224_024443_379354_896D07A2 X-CRM114-Status: GOOD ( 16.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 These won't be used in the next commit in discard mode, so put them in their own functions. No functional changes intended. Reviewed-by: Yeoreum Yun Signed-off-by: James Clark --- tools/perf/arch/arm64/util/arm-spe.c | 83 +++++++++++++++++----------- 1 file changed, 51 insertions(+), 32 deletions(-) diff --git a/tools/perf/arch/arm64/util/arm-spe.c b/tools/perf/arch/arm64/util/arm-spe.c index 22b19dcc6beb..1b543855f206 100644 --- a/tools/perf/arch/arm64/util/arm-spe.c +++ b/tools/perf/arch/arm64/util/arm-spe.c @@ -274,33 +274,9 @@ static void arm_spe_setup_evsel(struct evsel *evsel, struct perf_cpu_map *cpus) evsel__set_sample_bit(evsel, PHYS_ADDR); } -static int arm_spe_recording_options(struct auxtrace_record *itr, - struct evlist *evlist, - struct record_opts *opts) +static int arm_spe_setup_aux_buffer(struct record_opts *opts) { - struct arm_spe_recording *sper = - container_of(itr, struct arm_spe_recording, itr); - struct evsel *evsel, *tmp; - struct perf_cpu_map *cpus = evlist->core.user_requested_cpus; bool privileged = perf_event_paranoid_check(-1); - struct evsel *tracking_evsel; - int err; - - sper->evlist = evlist; - - evlist__for_each_entry(evlist, evsel) { - if (evsel__is_aux_event(evsel)) { - if (!strstarts(evsel->pmu->name, ARM_SPE_PMU_NAME)) { - pr_err("Found unexpected auxtrace event: %s\n", - evsel->pmu->name); - return -EINVAL; - } - opts->full_auxtrace = true; - } - } - - if (!opts->full_auxtrace) - return 0; /* * we are in snapshot mode. @@ -330,6 +306,9 @@ static int arm_spe_recording_options(struct auxtrace_record *itr, pr_err("Failed to calculate default snapshot size and/or AUX area tracing mmap pages\n"); return -EINVAL; } + + pr_debug2("%sx snapshot size: %zu\n", ARM_SPE_PMU_NAME, + opts->auxtrace_snapshot_size); } /* We are in full trace mode but '-m,xyz' wasn't specified */ @@ -355,14 +334,15 @@ static int arm_spe_recording_options(struct auxtrace_record *itr, } } - if (opts->auxtrace_snapshot_mode) - pr_debug2("%sx snapshot size: %zu\n", ARM_SPE_PMU_NAME, - opts->auxtrace_snapshot_size); + return 0; +} - evlist__for_each_entry_safe(evlist, tmp, evsel) { - if (evsel__is_aux_event(evsel)) - arm_spe_setup_evsel(evsel, cpus); - } +static int arm_spe_setup_tracking_event(struct evlist *evlist, + struct record_opts *opts) +{ + int err; + struct evsel *tracking_evsel; + struct perf_cpu_map *cpus = evlist->core.user_requested_cpus; /* Add dummy event to keep tracking */ err = parse_event(evlist, "dummy:u"); @@ -388,6 +368,45 @@ static int arm_spe_recording_options(struct auxtrace_record *itr, return 0; } +static int arm_spe_recording_options(struct auxtrace_record *itr, + struct evlist *evlist, + struct record_opts *opts) +{ + struct arm_spe_recording *sper = + container_of(itr, struct arm_spe_recording, itr); + struct evsel *evsel, *tmp; + struct perf_cpu_map *cpus = evlist->core.user_requested_cpus; + + int err; + + sper->evlist = evlist; + + evlist__for_each_entry(evlist, evsel) { + if (evsel__is_aux_event(evsel)) { + if (!strstarts(evsel->pmu->name, ARM_SPE_PMU_NAME)) { + pr_err("Found unexpected auxtrace event: %s\n", + evsel->pmu->name); + return -EINVAL; + } + opts->full_auxtrace = true; + } + } + + if (!opts->full_auxtrace) + return 0; + + evlist__for_each_entry_safe(evlist, tmp, evsel) { + if (evsel__is_aux_event(evsel)) + arm_spe_setup_evsel(evsel, cpus); + } + + err = arm_spe_setup_aux_buffer(opts); + if (err) + return err; + + return arm_spe_setup_tracking_event(evlist, opts); +} + static int arm_spe_parse_snapshot_options(struct auxtrace_record *itr __maybe_unused, struct record_opts *opts, const char *str) From patchwork Tue Dec 24 10:44:10 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: James Clark X-Patchwork-Id: 13919934 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org 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 smtp.lore.kernel.org (Postfix) with ESMTPS id 77491E77188 for ; Tue, 24 Dec 2024 10:50:55 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:List-Subscribe:List-Help :List-Post:List-Archive:List-Unsubscribe:List-Id:Content-Transfer-Encoding: MIME-Version:References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From: Reply-To:Content-Type:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=wmWclsqjoRWfqPrE0WD8+jPpX9G+TTRqhb+EOtWuV1I=; b=Gdin0PRK9pmBL/BQXv7jLfedla StJN1ZgdkqmEc0P6WL8Td12Gk1hfHpkl11MdoviGtzJy9b8K9cuD2xzcWRQDMmvdxEAIdwrwQhN6J TVutO5WgTvn5ZUSwqmN5O+nRFoMUrVhEN7c9l6DEJ4kwIrbozGuFViUnwXgnAAwQUA6e48y0jIXI8 irDCi6shKOov57ezqjUtNkiYlK4BdiDqsCVZY1o4qINPbB4WkQS8pGW+phXwu95E2QCrBkEF4XGGf FfxoL9Wj52CQNHV/haklsBGaD51IzHPiptCK72eDjV8AD7RtRXvGkbSmbxjLbygM+UmGJYLO4Jsde QHCnD7tg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.98 #2 (Red Hat Linux)) id 1tQ2Ur-0000000BoLC-1ERz; Tue, 24 Dec 2024 10:50:41 +0000 Received: from mail-wr1-x435.google.com ([2a00:1450:4864:20::435]) by bombadil.infradead.org with esmtps (Exim 4.98 #2 (Red Hat Linux)) id 1tQ2P8-0000000BnCb-39xX for linux-arm-kernel@lists.infradead.org; Tue, 24 Dec 2024 10:44:47 +0000 Received: by mail-wr1-x435.google.com with SMTP id ffacd0b85a97d-385dece873cso1929637f8f.0 for ; Tue, 24 Dec 2024 02:44:46 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1735037085; x=1735641885; darn=lists.infradead.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=wmWclsqjoRWfqPrE0WD8+jPpX9G+TTRqhb+EOtWuV1I=; b=OBN9a6f3s+BOMrUs3Q4xATvxC5HIGeJq7ECprL3X68//eBroUo0LZ7i3uq2AnkWL9D JZFbUBnF662bP4hU5K2aj4PFm0BxjxbHysfQ48mKEuAnDRwuTvf7gDdlUClbxcvEkJrx Bi8zxOHAeZQEsJKmMMr6tfcRTrDBVN+g7tRpkKa6Q182o4+UlMiK3KD8+GjKQhDt1Uvh jHy8I18zcDxRIpdZ7TX0dJUQLP076Mq1Vlfl6HXM95nNGbhNI+rTN+UiAwJhnyQc0D2z A4JMPxcCNibvhqH4fotDvMZzSoEgpgrspikfdTpZWgGhnHS93vsY1CpqtsP15BJWOFpj 0OWQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1735037085; x=1735641885; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=wmWclsqjoRWfqPrE0WD8+jPpX9G+TTRqhb+EOtWuV1I=; b=mllMqS4TwbyjmKN4SliN+21L1xfyGBtK4RxloXWQkhQA9IAkD498xhtFhLu0+RWTq+ nY6EurGVht3H5dJ0WGa1dhbMjAeyParBAOOGTjX01Vou2Pe3g+RPb/wZm/keLThPNSY2 QQOwIHxN9PSK1XjOG0chIi8qZtPXDSDegpYtd02i9AijkBxu29qVJK3ip8cKsmA45qHf n0YwiM4hYPrNAh+L7/3WfS6E/QbtqDrxSKki8JvSd/0to308CfE/+aJHoxIJO18/VUmu tHUxl2UdyHS0wua1ljPJmJoGuAMdMQNDpe1gkdFAQ+V42kyWrLe0jZYxZZLxNQnV2pnP MbVg== X-Gm-Message-State: AOJu0Yydnt1267l6hJn22KXzqZUmYQOlFftigd9vnARIeE2r9tto2Hu9 qZsgqkCtySGaMzupfzztJ2GQVx09l0e9ouMvKKPCoajbbtYXmVQAM+b2T+RQfjLG0tE879pG7uM v X-Gm-Gg: ASbGncuY9L3Xc8ELmD7PYUrzhySoR8B2EpzSCljSRy4UbGl7NhbW0H+WvdIQl8XiJNY qKn07nlIYgonYe8lV9Hrpifyy6rNzJqTVDCUGF1KIkpwHi8jwUsggfhYrxIfLdU6FXFA3fXBT7b /ozK2wzFOLQqdThpgf2pn40vsrny67qUJAkep7G++c84ARl7UPWbPPaHP/JWouspNEjHSa6h16z meAH2IZStDfpbysD6/JeW8Rwn9vFSaoXbs4Gtm4G2OWAqLBhMSwV6Q= X-Google-Smtp-Source: AGHT+IHaBv3kwmR23DfMiPkW/ULQn6dCN6owu8F2AwgaW5A6C+1/Tsu2gsMP3xZT9UiCfrjTvu25qA== X-Received: by 2002:a05:6000:490e:b0:385:fc97:9c63 with SMTP id ffacd0b85a97d-38a221f16d6mr14526536f8f.9.1735037085301; Tue, 24 Dec 2024 02:44:45 -0800 (PST) Received: from pop-os.. ([145.224.66.70]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-38a1c847714sm13938184f8f.54.2024.12.24.02.44.43 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 24 Dec 2024 02:44:44 -0800 (PST) From: James Clark To: linux-arm-kernel@lists.infradead.org, linux-perf-users@vger.kernel.org, irogers@google.com, yeoreum.yun@arm.com, will@kernel.org, mark.rutland@arm.com Cc: robh@kernel.org, James Clark , Peter Zijlstra , Ingo Molnar , Arnaldo Carvalho de Melo , Namhyung Kim , Alexander Shishkin , Jiri Olsa , Adrian Hunter , "Liang, Kan" , John Garry , Mike Leach , Leo Yan , Graham Woodward , linux-kernel@vger.kernel.org, bpf@vger.kernel.org Subject: [PATCH v2 3/5] perf tool: arm-spe: Don't allocate buffer or tracking event in discard mode Date: Tue, 24 Dec 2024 10:44:10 +0000 Message-Id: <20241224104414.179365-4-james.clark@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20241224104414.179365-1-james.clark@linaro.org> References: <20241224104414.179365-1-james.clark@linaro.org> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20241224_024446_803833_0D826A98 X-CRM114-Status: GOOD ( 13.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 The buffer will never be written to so don't bother allocating it. The tracking event is also not required. Reviewed-by: Yeoreum Yun Signed-off-by: James Clark --- tools/perf/arch/arm64/util/arm-spe.c | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/tools/perf/arch/arm64/util/arm-spe.c b/tools/perf/arch/arm64/util/arm-spe.c index 1b543855f206..4301181b8e45 100644 --- a/tools/perf/arch/arm64/util/arm-spe.c +++ b/tools/perf/arch/arm64/util/arm-spe.c @@ -376,7 +376,7 @@ static int arm_spe_recording_options(struct auxtrace_record *itr, container_of(itr, struct arm_spe_recording, itr); struct evsel *evsel, *tmp; struct perf_cpu_map *cpus = evlist->core.user_requested_cpus; - + bool discard = false; int err; sper->evlist = evlist; @@ -396,10 +396,17 @@ static int arm_spe_recording_options(struct auxtrace_record *itr, return 0; evlist__for_each_entry_safe(evlist, tmp, evsel) { - if (evsel__is_aux_event(evsel)) + if (evsel__is_aux_event(evsel)) { arm_spe_setup_evsel(evsel, cpus); + if (evsel->core.attr.config & + perf_pmu__format_bits(evsel->pmu, "discard")) + discard = true; + } } + if (discard) + return 0; + err = arm_spe_setup_aux_buffer(opts); if (err) return err; From patchwork Tue Dec 24 10:44:11 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: James Clark X-Patchwork-Id: 13919935 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org 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 smtp.lore.kernel.org (Postfix) with ESMTPS id A5402E77188 for ; Tue, 24 Dec 2024 10:52:05 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:List-Subscribe:List-Help :List-Post:List-Archive:List-Unsubscribe:List-Id:Content-Transfer-Encoding: MIME-Version:References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From: Reply-To:Content-Type:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=r1j+BIbB70BfH6p+H3D0C/f2KwCH22I9fsAuqIEouAI=; b=DCtVGmB6qKiIeHtwIXvw9RG9TW ZT9whbOyvtwY9rRKOwnT/c+/q4qQ2ZQTNnoY4wE5EjrOyJx+snPvTtKf9z4yqtJf7lJsN2JCFieD4 4LjIkehJb47tgALILdaPo9BElumRC1N+N2JWqRsqqnitD9o8EdrATMbSKQUI6HpdTcZVbaYQK0/zQ B3lSKFgzR+PX19+BOUhnObbCepnr2obSPPQTMzbD2MTLMj+DEcBuji+3pg9L7p/h5wtV2tlHWZ4UU I2CzjSG4hZ0lAavldEROF/Md6dajSMh3LiC3TPll02VOcAaX2MdgeD9uoPT5gU9OSYTKHstqQ5F8o iEnR1tMQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.98 #2 (Red Hat Linux)) id 1tQ2W0-0000000BobG-3qTW; Tue, 24 Dec 2024 10:51:52 +0000 Received: from mail-wr1-x431.google.com ([2a00:1450:4864:20::431]) by bombadil.infradead.org with esmtps (Exim 4.98 #2 (Red Hat Linux)) id 1tQ2PC-0000000BnEa-3QnI for linux-arm-kernel@lists.infradead.org; Tue, 24 Dec 2024 10:44:52 +0000 Received: by mail-wr1-x431.google.com with SMTP id ffacd0b85a97d-385d7f19f20so2383326f8f.1 for ; Tue, 24 Dec 2024 02:44:50 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1735037089; x=1735641889; darn=lists.infradead.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=r1j+BIbB70BfH6p+H3D0C/f2KwCH22I9fsAuqIEouAI=; b=rzztVL5A5LQ4RFlKbPgOffcretxYTbblJmisyg1Iq0GK/IIGi/zcSKenr4V8a7y7N4 Jn+Zz8joxrPJ2vBNhYvbWas0K31Zaov1XPn+bM6TJxLekyA7NJiFP2iRr5gI6e1/4Scu dlGK1FhGkhGnZa1Z9GVn08jH8qnTlMxeSp+vvbZsd+32XbZ0xvBC5IEBo98Ze3+ZBKdL srxicBgx+GTyFl0oy4kChSEqhHPHE6HGqjRefNpriXLy2D4SrKJs0lC0qJs6SVIH+vAi j4hZJfId2TPqUzVXxbkxK1+dY9zqS/iqAF2/xzJoXhTyzDJKXPJFWPcB2ODy9vekdfu7 9Muw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1735037089; x=1735641889; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=r1j+BIbB70BfH6p+H3D0C/f2KwCH22I9fsAuqIEouAI=; b=rQWunSDJZ1yy4oQPJNougxajvqyA2Nz1LVs6yHZpV2dn+b5AxkcpNPTDPTil0Rv0/N gmPZKV/cJ+DpQY3KKaCAA7KVkinSZeuaNAEomkXvcE8nz+AdVTgKhcsriqXMBd9fIU5g IG2fUs3g2LqtF0Hol4PuQ8sj7JIiX8yKPO28ZL5yYfcZbN352h3mEBrvnff32+W+hfBc k1pKVAeQeuQ1AAeSpWkdWuKKM7buO+m2LVdwOcmvCYvUYlczhgNYoI79fvrh5hcJ2CqZ ThgxfufMsA+n+37akHDWn/D54jn6O6/E7/f7U5jTfsEYDeCMnPyuFho8WLLP61IyS7G6 7pDQ== X-Gm-Message-State: AOJu0Yw2J8zajj9EfYZZ7iBRBsbrp489PnyUSSBf/rhlRUIwwPLhX6VP oaKO1cYuBcktJdI49zDO+Wi93rGpMy8ftNta/YBdqsADYKamNqTV8QU02QDrYz77wG5RUVHrDZe q X-Gm-Gg: ASbGncs4XjZxupo4IG7sBH0e5MrPc21ercAY2GN/V3PtGXL4E8AeGRPW3xdPP7+vzhD PQgOU828J6LgkNwP61wcM2tI2/3ZtNZFALC7YK5eGo+bc1GMl5RSTaVxKXYSaz4m1/DCNavJ4fI Kmdz+/+rjRrIQXVrPEjPYaitwsDJ/ZhXYoAG803FOcJPCj4zZ+oCIvCZjPqxRiV7z03jU375S/P 6D/53IyIZQnzTeCk+Bw33fN/gYIBhClx3z5WiD7ACV0Pw7PLIFEoJk= X-Google-Smtp-Source: AGHT+IH+dfpgTuFz+C7tBaq/J7Dc+pyrOC6X4KjPHRcroZadLExb0vNcsLRnA0H4zbAjsKClBUrHAA== X-Received: by 2002:a5d:64ad:0:b0:385:e67d:9e0 with SMTP id ffacd0b85a97d-38a221ffe1bmr13551020f8f.29.1735037089043; Tue, 24 Dec 2024 02:44:49 -0800 (PST) Received: from pop-os.. ([145.224.66.70]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-38a1c847714sm13938184f8f.54.2024.12.24.02.44.47 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 24 Dec 2024 02:44:48 -0800 (PST) From: James Clark To: linux-arm-kernel@lists.infradead.org, linux-perf-users@vger.kernel.org, irogers@google.com, yeoreum.yun@arm.com, will@kernel.org, mark.rutland@arm.com Cc: robh@kernel.org, James Clark , Peter Zijlstra , Ingo Molnar , Arnaldo Carvalho de Melo , Namhyung Kim , Alexander Shishkin , Jiri Olsa , Adrian Hunter , "Liang, Kan" , John Garry , Mike Leach , Leo Yan , Graham Woodward , linux-kernel@vger.kernel.org, bpf@vger.kernel.org Subject: [PATCH v2 4/5] perf test: arm_spe: Add test for discard mode Date: Tue, 24 Dec 2024 10:44:11 +0000 Message-Id: <20241224104414.179365-5-james.clark@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20241224104414.179365-1-james.clark@linaro.org> References: <20241224104414.179365-1-james.clark@linaro.org> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20241224_024450_867271_13F882AC X-CRM114-Status: GOOD ( 12.73 ) 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 a test that checks that there were no AUX or AUXTRACE events recorded when discard mode is used. Reviewed-by: Yeoreum Yun Signed-off-by: James Clark --- tools/perf/tests/shell/test_arm_spe.sh | 30 ++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/tools/perf/tests/shell/test_arm_spe.sh b/tools/perf/tests/shell/test_arm_spe.sh index 3258368634f7..a69aab70dd8a 100755 --- a/tools/perf/tests/shell/test_arm_spe.sh +++ b/tools/perf/tests/shell/test_arm_spe.sh @@ -107,7 +107,37 @@ arm_spe_system_wide_test() { arm_spe_report "SPE system-wide testing" $err } +arm_spe_discard_test() { + echo "SPE discard mode" + + for f in /sys/bus/event_source/devices/arm_spe_*; do + if [ -e "$f/format/discard" ]; then + cpu=$(cut -c -1 "$f/cpumask") + break + fi + done + + if [ -z $cpu ]; then + arm_spe_report "SPE discard mode not present" 2 + return + fi + + # Test can use wildcard SPE instance and Perf will only open the event + # on instances that have that format flag. But make sure the target + # runs on an instance with discard mode otherwise we're not testing + # anything. + perf record -o ${perfdata} -e arm_spe/discard/ -N -B --no-bpf-event \ + -- taskset --cpu-list $cpu true + + if perf report -i ${perfdata} --stats | grep 'AUX events\|AUXTRACE events'; then + arm_spe_report "SPE discard mode found unexpected data" 1 + else + arm_spe_report "SPE discard mode" 0 + fi +} + arm_spe_snapshot_test arm_spe_system_wide_test +arm_spe_discard_test exit $glb_err From patchwork Tue Dec 24 10:44:12 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: James Clark X-Patchwork-Id: 13919936 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org 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 smtp.lore.kernel.org (Postfix) with ESMTPS id 30893E77188 for ; Tue, 24 Dec 2024 10:53:17 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:List-Subscribe:List-Help :List-Post:List-Archive:List-Unsubscribe:List-Id:Content-Transfer-Encoding: MIME-Version:References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From: Reply-To:Content-Type:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=BwyNoR0SnuVGySQmrh3vEyVb1ET66P1aG6x3YnivKGw=; b=BQlz8NqfA/QMyZynxvU1YqTlw0 3crfGq5J9qbAn6/Eqz0efb/5IuptWFuACdCP7JeNQUADTPP8roJOh/g+cNLE+eHFEQpu6TFWh9QVa wTnFvI8o8nJl/DGm++FxUctsh3OVN2UsuxTz4yqcdtQpJjVF6pYfTO8jVzRbTfTxdmJIpoTr5XTNd BBz3yxoQ2m2Neh12uqI8qY8i+f9WJVG2i0QX0NXnadPRXtrSf3+fSoeKSqMTZrMxQ1gjeyeCkW0m5 S1IRK8FqjryyVU2FT7Zzc0o34cVz4aj0w8e5XWEUo3wYlYm/y5Fh30RhOr7DFln1FLScfYxut8HeT 8IiwqStQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.98 #2 (Red Hat Linux)) id 1tQ2X9-0000000BonR-2j6n; Tue, 24 Dec 2024 10:53:03 +0000 Received: from mail-wr1-x435.google.com ([2a00:1450:4864:20::435]) by bombadil.infradead.org with esmtps (Exim 4.98 #2 (Red Hat Linux)) id 1tQ2PF-0000000BnG8-47QE for linux-arm-kernel@lists.infradead.org; Tue, 24 Dec 2024 10:44:55 +0000 Received: by mail-wr1-x435.google.com with SMTP id ffacd0b85a97d-385f07cd1a4so3176013f8f.1 for ; Tue, 24 Dec 2024 02:44:53 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1735037093; x=1735641893; darn=lists.infradead.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=BwyNoR0SnuVGySQmrh3vEyVb1ET66P1aG6x3YnivKGw=; b=XfWBDBgoHeFfHAdMData8VXzmFPiUXWEEFeQ+e3+nVd79Q5fSVE22jUKYYBDZKE5Eg s51WNXVQlgtriwEKphuFcf4fnwm+Qb/H3ycMXIOsU1wwwMNuh/vSaaRJgiR46WwFJXGS sHw59oNGzVMT6mVGq2Iknq7rxQ/OuZz++zB0iRaqoc224n45brdXk7mSg+o0aohFOLle k/kF9YSay2yeBSTQ8QjEW/8NVzi968Pf7bmyYkK32x+P2Mq+ouHy2kiPxMSjljLQOIx9 siWPjNTTD1YzlcSPfPt/gRyxnOtdtjafuuBb3UQp/FmipDFI+4zi6GgR4NP5ML6At41d b36Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1735037093; x=1735641893; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=BwyNoR0SnuVGySQmrh3vEyVb1ET66P1aG6x3YnivKGw=; b=DleCEYGo0Un6KYbCu4HsNBEY767eFvPtiBtsbdD82oQcXZQgB8J3W0aYcSuFi/PaDL xDH6SbRMbGMNqm4EFCu720a0zWd4xA6r3k5RJzUinVE9/XeJNUKLnfbydoz3o3tnefE0 fkTlCqCiI9zmeobZtcTBztA5mwZ3j5b2rpW82jtIIfJfLzxKwgeFiiGnfVlNbmjV2Wlt OfJUl96nGpJVEhM6oMn9JDG8vOng30PCZSEiBqjOhbZHudgIEhbk5b3vZE6mkOOSjHwT hq8d+dQQh50IRP0VzIWDf/O+vWhgo/NLWjyORnsMpBs6/hggODG/SyoeI9Pim2bOQGGH gEbg== X-Gm-Message-State: AOJu0Yyq7CLoauYmqiCGucwn8NbbEdU30/YsuyjXR6ZRKIontuzvNf+E zRh6itZGotTVazRntqW8I2I3P4ePme9lURqfD8qM5KwqKsmvUFSPI+BqqvLf6b7ZgTHnAWcpIAv 0 X-Gm-Gg: ASbGncsqTmGzGFemg890mv7dDDSz52vrlyF0+MYlVMBAYQw3YLqs/7MxiwQosCLTu0N wHXq3NRNiEoIMGd0o2Mu9a+L7jbeu+WfifDp3RrByeaVNU8tt90aJNJ4cM2xuijoFaq39D20GYC 3gFNZrwo3QcnTi/19c3N3oKDC2EaE1F4ecYO8j8E9KCHQn7LOCG2qb8AoD3CBzreA7qj8Orl24u HOirM1aoFf63bFkuZhx0L3E6QlwP1UMVdmYWknUIaaSNGHzmTYCxCA= X-Google-Smtp-Source: AGHT+IEHX62hM4cRXueG3YQu6eg84405e7WqgYcT9lFPGrHLB17v7HhSKT3GSKfbXrWS+gmH7kk2Dw== X-Received: by 2002:a05:6000:794:b0:385:e013:b842 with SMTP id ffacd0b85a97d-38a221ea331mr12569563f8f.14.1735037092689; Tue, 24 Dec 2024 02:44:52 -0800 (PST) Received: from pop-os.. ([145.224.66.70]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-38a1c847714sm13938184f8f.54.2024.12.24.02.44.51 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 24 Dec 2024 02:44:52 -0800 (PST) From: James Clark To: linux-arm-kernel@lists.infradead.org, linux-perf-users@vger.kernel.org, irogers@google.com, yeoreum.yun@arm.com, will@kernel.org, mark.rutland@arm.com Cc: robh@kernel.org, James Clark , Peter Zijlstra , Ingo Molnar , Arnaldo Carvalho de Melo , Namhyung Kim , Alexander Shishkin , Jiri Olsa , Adrian Hunter , "Liang, Kan" , John Garry , Mike Leach , Leo Yan , Graham Woodward , linux-kernel@vger.kernel.org, bpf@vger.kernel.org Subject: [PATCH v2 5/5] perf docs: arm_spe: Document new discard mode Date: Tue, 24 Dec 2024 10:44:12 +0000 Message-Id: <20241224104414.179365-6-james.clark@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20241224104414.179365-1-james.clark@linaro.org> References: <20241224104414.179365-1-james.clark@linaro.org> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20241224_024454_022123_67811033 X-CRM114-Status: GOOD ( 16.13 ) 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 Document the flag along with PMU events to hint what it's used for and give an example with other useful options to get minimal output. Reviewed-by: Yeoreum Yun Signed-off-by: James Clark --- tools/perf/Documentation/perf-arm-spe.txt | 26 +++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/tools/perf/Documentation/perf-arm-spe.txt b/tools/perf/Documentation/perf-arm-spe.txt index de2b0b479249..37afade4f1b2 100644 --- a/tools/perf/Documentation/perf-arm-spe.txt +++ b/tools/perf/Documentation/perf-arm-spe.txt @@ -150,6 +150,7 @@ arm_spe/load_filter=1,min_latency=10/' pct_enable=1 - collect physical timestamp instead of virtual timestamp (PMSCR.PCT) - requires privilege store_filter=1 - collect stores only (PMSFCR.ST) ts_enable=1 - enable timestamping with value of generic timer (PMSCR.TS) + discard=1 - enable SPE PMU events but don't collect sample data - see 'Discard mode' (PMBLIMITR.FM = DISCARD) +++*+++ Latency is the total latency from the point at which sampling started on that instruction, rather than only the execution latency. @@ -220,6 +221,31 @@ Common errors Increase sampling interval (see above) +PMU events +~~~~~~~~~~ + +SPE has events that can be counted on core PMUs. These are prefixed with +SAMPLE_, for example SAMPLE_POP, SAMPLE_FEED, SAMPLE_COLLISION and +SAMPLE_FEED_BR. + +These events will only count when an SPE event is running on the same core that +the PMU event is opened on, otherwise they read as 0. There are various ways to +ensure that the PMU event and SPE event are scheduled together depending on the +way the event is opened. For example opening both events as per-process events +on the same process, although it's not guaranteed that the PMU event is enabled +first when context switching. For that reason it may be better to open the PMU +event as a systemwide event and then open SPE on the process of interest. + +Discard mode +~~~~~~~~~~~~ + +SPE related (SAMPLE_* etc) core PMU events can be used without the overhead of +collecting sample data if discard mode is supported (optional from Armv8.6). +First run a system wide SPE session (or on the core of interest) using options +to minimize output. Then run perf stat: + + perf record -e arm_spe/discard/ -a -N -B --no-bpf-event -o - > /dev/null & + perf stat -e SAMPLE_FEED_LD SEE ALSO --------