From nobody Sat Feb 7 06:09:58 2026 Received: from mail-wm1-f43.google.com (mail-wm1-f43.google.com [209.85.128.43]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id A7A3F248F5D for ; Thu, 5 Jun 2025 10:50:13 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.43 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1749120616; cv=none; b=JDYEufyS+oAqyqRW+PxIeEUd/UClc9JsiBd2fu+feXhX/BV2ZRSjHG3xECbGeuHfHFHdDkJcFaOKHWMmtIz31tIoplBWXN24JZQGZh5M6z6H7x8/Lfuzu+wtj2MChnGMXYNp16ONT5Ry6B+PQih8Evu4DF97haxB+OrFNtsdcdU= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1749120616; c=relaxed/simple; bh=KCuaBrpctJvVyuO7lqsXVmFOYYJR2IE7xgkIFt7pAtM=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=pFoNd0UvUm/m7/8hLExDDKKyYnJSZLKCCegd9Y0KdckEMreA46sksfwdTmKrptUtxQtEBUEfK6pu4E2nTG2FQGnzIWNGvKQEvf05Q1njE367gc1NUI6PHa4hekt6feX/Og74vheYHVCUZobUET8U6P5nJE7SC3WVyizci9GNAPI= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linaro.org; spf=pass smtp.mailfrom=linaro.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b=TfMBGpCZ; arc=none smtp.client-ip=209.85.128.43 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linaro.org Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="TfMBGpCZ" Received: by mail-wm1-f43.google.com with SMTP id 5b1f17b1804b1-450d37d4699so4839375e9.0 for ; Thu, 05 Jun 2025 03:50:13 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1749120612; x=1749725412; darn=vger.kernel.org; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:from:to:cc:subject:date:message-id :reply-to; bh=C0KLZ2ZCTkHcHktyLYkkFUXE6vwjX72niSxA55rUHHU=; b=TfMBGpCZjSfsqhH4NWqt9438+/9a5RdKB/w5oOdr/r9tbgP18PJpdBeAAiT3pDIReM xnL25El/UfQkIEwlX3XtYcahGeVnrVu5y5FaMkP8hTGnSwo+15Xqr2c1BSpceOijCefG bujQxKGu0I4MJXPQZ1vIjVpElnaQTJBXpkcCpE85jrqBo06uaEvHklNfGesK6LJVsNUV DrrHdP/KpjiPzBgRl3c/Cpvbw26/SqMaOqnH1DfJoKtg/HZZ9N6/Fw0a/qS4/k4vHwdb NvIXmc+m5zWJ8Hz7qqghw+iX7Ua5lPhopXBgAXV8f7Mz4lVaV/ZQsu08P1AP/1LqPwMX WmKg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1749120612; x=1749725412; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=C0KLZ2ZCTkHcHktyLYkkFUXE6vwjX72niSxA55rUHHU=; b=WU0g60D5FZLC+uwpi6iTy7TrzjMeOrERW3KeyNLLX59fMxAk48XPTSoX4c9JmfDJtq gJNZqme9/lx/sCVVrSep+oTaivFwYwel23F+Wa7tNukaNe+sF5BPvjkafaTNnazZUQh7 hTnRX4aIzR+fMJ6vKZrkXBmQtxoVwFNYg/d6cAOlBuFypk/9KAUtkitm1Gm8j3iJQA5p ntFPl0KbE7YG3RSbKuEU6oU3DAQD9C85to3F59QPYhr7JA63SeRY56a5ywo5FIFv0xk/ 1xlpf48YLpQIuXagkZxDivlGAeWpJ1YnFTOw9HukpbldfPCfcOrEHYtIpPyJHAB1B1O/ 9QsA== X-Forwarded-Encrypted: i=1; AJvYcCViXcPMnW+LXswzOKwz4uJPia4MiEV/13nil1DnQdv1vgf1JrCECC6vBHhwq/S4U4JfdENUNzu6ujCz3zo=@vger.kernel.org X-Gm-Message-State: AOJu0Yzv6iF/6mCj0PVWEFsVTQCcEiMXjblPCBkPWbT7rNRVqZLhTf7c eWJVHGk+ohxh9ZyGwBjhH21804IfHP57Ojml7CcRvBTBh6j1WQLNLfUlYsjuNWFtTDo= X-Gm-Gg: ASbGncvAkMhdXAf7/My6AVcYOauB/PxOJ6S/bGeYJypkz8w6AHI89JdCZ0ZQYFAsjh/ 3VeF+UJh7gLLKpeTURhTTsII1ZpUG9CyIth7TyszGb6VSQ30ZizdbZgHK71uZFOlh90xEo1i8cG rLu57VEdd3dlV4dpZqwbXQn5K99X5KEJe8fyPNDwiB2gIhUdwy9EIFza2SJNDOihia1Q1mLad/+ S6VBXVTLR9h9Z0YQOlLpJp5eKWgSDSPfHUo0eK/ZMOg0nKA5m+wwX0HQbcVGj0sEhfzwjjaP4wP KvpFcMUN1tQYG2HXzd29ARB+H7XnnoLWttSaxK8g5rfeWkhkt8HALb1y1cxk X-Google-Smtp-Source: AGHT+IGbcO/a1eXK3R6X6dBhodfAwBOpm98OebpBQCErhJ5FZL5kwhqpZKRhnlTn8gwmnZUGlYp8jg== X-Received: by 2002:a05:600c:b96:b0:441:d43d:4f68 with SMTP id 5b1f17b1804b1-451f0f4f1c5mr58624695e9.15.1749120611973; Thu, 05 Jun 2025 03:50:11 -0700 (PDT) Received: from ho-tower-lan.lan ([37.18.136.128]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-451f990cfe3sm20629965e9.23.2025.06.05.03.50.10 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 05 Jun 2025 03:50:11 -0700 (PDT) From: James Clark Date: Thu, 05 Jun 2025 11:49:05 +0100 Subject: [PATCH v3 07/10] perf: arm_spe: Add support for filtering on data source Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20250605-james-perf-feat_spe_eft-v3-7-71b0c9f98093@linaro.org> References: <20250605-james-perf-feat_spe_eft-v3-0-71b0c9f98093@linaro.org> In-Reply-To: <20250605-james-perf-feat_spe_eft-v3-0-71b0c9f98093@linaro.org> To: Catalin Marinas , Will Deacon , Mark Rutland , Jonathan Corbet , Marc Zyngier , Oliver Upton , Joey Gouly , Suzuki K Poulose , Zenghui Yu , Peter Zijlstra , Ingo Molnar , Arnaldo Carvalho de Melo , Namhyung Kim , Alexander Shishkin , Jiri Olsa , Ian Rogers , Adrian Hunter , leo.yan@arm.com Cc: linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, linux-perf-users@vger.kernel.org, linux-doc@vger.kernel.org, kvmarm@lists.linux.dev, James Clark X-Mailer: b4 0.14.0 SPE_FEAT_FDS adds the ability to filter on the data source of packets. Like the other existing filters, enable filtering with PMSFCR_EL1.FDS when any of the filter bits are set. Each bit maps to data sources 0-63 described by bits[0:5] in the data source packet (although the full range of data source is 16 bits so higher value data sources can't be filtered on). The filter is an OR of all the bits, so for example setting bits 0 and 3 filters packets from data sources 0 OR 3. Reviewed-by: Leo Yan Tested-by: Leo Yan Signed-off-by: James Clark --- drivers/perf/arm_spe_pmu.c | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) diff --git a/drivers/perf/arm_spe_pmu.c b/drivers/perf/arm_spe_pmu.c index 9309b846f642..d04318411f77 100644 --- a/drivers/perf/arm_spe_pmu.c +++ b/drivers/perf/arm_spe_pmu.c @@ -87,6 +87,7 @@ struct arm_spe_pmu { #define SPE_PMU_FEAT_INV_FILT_EVT (1UL << 6) #define SPE_PMU_FEAT_DISCARD (1UL << 7) #define SPE_PMU_FEAT_EFT (1UL << 8) +#define SPE_PMU_FEAT_FDS (1UL << 9) #define SPE_PMU_FEAT_DEV_PROBED (1UL << 63) u64 features; =20 @@ -232,6 +233,10 @@ static const struct attribute_group arm_spe_pmu_cap_gr= oup =3D { #define ATTR_CFG_FLD_inv_event_filter_LO 0 #define ATTR_CFG_FLD_inv_event_filter_HI 63 =20 +#define ATTR_CFG_FLD_data_src_filter_CFG config4 /* PMSDSFR_EL1 */ +#define ATTR_CFG_FLD_data_src_filter_LO 0 +#define ATTR_CFG_FLD_data_src_filter_HI 63 + GEN_PMU_FORMAT_ATTR(ts_enable); GEN_PMU_FORMAT_ATTR(pa_enable); GEN_PMU_FORMAT_ATTR(pct_enable); @@ -248,6 +253,7 @@ GEN_PMU_FORMAT_ATTR(float_filter); GEN_PMU_FORMAT_ATTR(float_filter_mask); GEN_PMU_FORMAT_ATTR(event_filter); GEN_PMU_FORMAT_ATTR(inv_event_filter); +GEN_PMU_FORMAT_ATTR(data_src_filter); GEN_PMU_FORMAT_ATTR(min_latency); GEN_PMU_FORMAT_ATTR(discard); =20 @@ -268,6 +274,7 @@ static struct attribute *arm_spe_pmu_formats_attr[] =3D= { &format_attr_float_filter_mask.attr, &format_attr_event_filter.attr, &format_attr_inv_event_filter.attr, + &format_attr_data_src_filter.attr, &format_attr_min_latency.attr, &format_attr_discard.attr, NULL, @@ -286,6 +293,9 @@ static umode_t arm_spe_pmu_format_attr_is_visible(struc= t kobject *kobj, if (attr =3D=3D &format_attr_inv_event_filter.attr && !(spe_pmu->features= & SPE_PMU_FEAT_INV_FILT_EVT)) return 0; =20 + if (attr =3D=3D &format_attr_data_src_filter.attr && !(spe_pmu->features = & SPE_PMU_FEAT_FDS)) + return 0; + if ((attr =3D=3D &format_attr_branch_filter_mask.attr || attr =3D=3D &format_attr_load_filter_mask.attr || attr =3D=3D &format_attr_store_filter_mask.attr || @@ -406,6 +416,9 @@ static u64 arm_spe_event_to_pmsfcr(struct perf_event *e= vent) if (ATTR_CFG_GET_FLD(attr, inv_event_filter)) reg |=3D PMSFCR_EL1_FnE; =20 + if (ATTR_CFG_GET_FLD(attr, data_src_filter)) + reg |=3D PMSFCR_EL1_FDS; + if (ATTR_CFG_GET_FLD(attr, min_latency)) reg |=3D PMSFCR_EL1_FL; =20 @@ -430,6 +443,12 @@ static u64 arm_spe_event_to_pmslatfr(struct perf_event= *event) return FIELD_PREP(PMSLATFR_EL1_MINLAT, ATTR_CFG_GET_FLD(attr, min_latency= )); } =20 +static u64 arm_spe_event_to_pmsdsfr(struct perf_event *event) +{ + struct perf_event_attr *attr =3D &event->attr; + return ATTR_CFG_GET_FLD(attr, data_src_filter); +} + static void arm_spe_pmu_pad_buf(struct perf_output_handle *handle, int len) { struct arm_spe_pmu_buf *buf =3D perf_get_aux(handle); @@ -788,6 +807,10 @@ static int arm_spe_pmu_event_init(struct perf_event *e= vent) if (arm_spe_event_to_pmsnevfr(event) & arm_spe_pmsevfr_res0(spe_pmu->pmsv= er)) return -EOPNOTSUPP; =20 + if (arm_spe_event_to_pmsdsfr(event) && + !(spe_pmu->features & SPE_PMU_FEAT_FDS)) + return -EOPNOTSUPP; + if (attr->exclude_idle) return -EOPNOTSUPP; =20 @@ -857,6 +880,11 @@ static void arm_spe_pmu_start(struct perf_event *event= , int flags) write_sysreg_s(reg, SYS_PMSNEVFR_EL1); } =20 + if (spe_pmu->features & SPE_PMU_FEAT_FDS) { + reg =3D arm_spe_event_to_pmsdsfr(event); + write_sysreg_s(reg, SYS_PMSDSFR_EL1); + } + reg =3D arm_spe_event_to_pmslatfr(event); write_sysreg_s(reg, SYS_PMSLATFR_EL1); =20 @@ -1116,6 +1144,9 @@ static void __arm_spe_pmu_dev_probe(void *info) if (FIELD_GET(PMSIDR_EL1_EFT, reg)) spe_pmu->features |=3D SPE_PMU_FEAT_EFT; =20 + if (FIELD_GET(PMSIDR_EL1_FDS, reg)) + spe_pmu->features |=3D SPE_PMU_FEAT_FDS; + /* This field has a spaced out encoding, so just use a look-up */ fld =3D FIELD_GET(PMSIDR_EL1_INTERVAL, reg); switch (fld) { --=20 2.34.1