From nobody Tue Feb 10 09:45:02 2026 Received: from mail-wr1-f48.google.com (mail-wr1-f48.google.com [209.85.221.48]) (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 2AC002741CB for ; Fri, 8 Aug 2025 11:23:47 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.221.48 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1754652229; cv=none; b=f4s1VgIomDWnns2G3ecB4PWeTgsoHH/lo3s70Bnp6c/D2pL8Jq0fFlpqx+2iLFphVfiC7ND/vhI9lGSIdZ56TJSMiAKYP1C8QzMYs5ZqmtEVn0AVHgtTPkUCQlaDIzh+CASp3/udj4JKtKMoM5yI7cVyjUvkkbQG7s9uT3F/aaI= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1754652229; c=relaxed/simple; bh=51vdVVrDG2YLBYS3Pf8NCD6LBuxxPOs+8V116Ol8P34=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=FcDx+EYeV3tl0OQ7NaELsbYQ0xrS9fF4ZvZDRMneiZqHu9qW//ICt7ryKKLj4/OHgclA6YeTSG7s9TTQL3N2m10C5pFOZqC7yE+TIZMRwkrBqGrOqMlES0I5QADfslnoSwnHBvk6l6yEhKWtB/sNRta9hPQWDxfMGRG7mEznRKw= 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=omJWWZUz; arc=none smtp.client-ip=209.85.221.48 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="omJWWZUz" Received: by mail-wr1-f48.google.com with SMTP id ffacd0b85a97d-3b7910123a0so1778446f8f.1 for ; Fri, 08 Aug 2025 04:23:46 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1754652225; x=1755257025; 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=CE9jiANI0cz/l/cDSr25IEHnZ3OQaeUcRCYLlwFZaDU=; b=omJWWZUzdcFut4gg0WYJ+7sTVTNsy45LpZZYfw9yGhUcPO02RcfstVFxNLL7WnUuxM TsZAk2a6ck0VKlFRqp2N00Dipo9HlnD7hqve8iZpZ3uFJRkwpEZW1gUP0THmSoMIqINv q5Exza0HwePNCIjnoBfvZSfy3hDMfNpcvCvfulzLkiVT9mnNs9AukNg67RFcm2yc5tNS F5ZunCkDvQO0eL3dEYkBDee04z+cWvDyZWV9W7CAPO72P+3SpiollnpCoc4akehWQkXH xrpyHF+BzP+ZUPHSm+Q5PvX2ag1GkIOZ/+WypxXwu0drJz9xYLYj8vVZr8vhWJUZP4y+ r7FA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1754652225; x=1755257025; 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=CE9jiANI0cz/l/cDSr25IEHnZ3OQaeUcRCYLlwFZaDU=; b=QC/vuj1imEkbIXFs8WlH4bL09IaCYd30x98/ZtPi4uNczXzDvwH0kes/wotwGH++qu bKxzxQ301HNVCQe/5zjNFZPQwMBdia2mdfJWaooTarxX/p47IlYaipOtKeKuzxhJPxAX /PAqHB7wsVYaz5b4uQCAXm0FmSnzvMDP5zmyuP8BOUIg/dWZLtpjLKvDW0BUlzk4yZOE Gx1pWp+i7d7gVEABpMQcmeXXLKMzGvIzelFMR3JCd9zIAteA3coyKKncvsD6vgK+Jfzv MLVCT9TWc7zentsWn8aFXg4rZR8vTR2HcdP6quII3PybjmaAMWlmbf5GAk7WTMu+9KGf gr+g== X-Forwarded-Encrypted: i=1; AJvYcCVoB6PPgMuWq7N0x5k2ywzhxSEvR+YWIjYS/Nt9H3bzD+/uvJmRbVy3UDWzO5DnSvD6qF52o50HoAngddU=@vger.kernel.org X-Gm-Message-State: AOJu0Yy2JtFgB2EzPiBiQVS7ojxiTimtcvRBlolkQRSKHdspZSd+oRu3 SETRf5ydYdjpFqkme38Y6Qlpvgk82wauf2AqDWewW9Fm51xkxvqq1nmgT20TXOHCn1g= X-Gm-Gg: ASbGncstoNdnGpxlnmbyTTNeqbOwMNn/f7eYqATF0t7oR4Aex0zg3LCcMlcjc8i1zVv vOjkn1RSriWzWdd7h4xAX+XUZrh+Gyp94+iJFd/Jyr3EHjly/aKmWARKT4o3Jn+LuX1zkCjscGu I9WnycS7DuMoIftqNRPtNEh5RXtjZNzQxAXDDxRYKxP58sJakFRn71Gf4ApcMhPS0rJtlF0xl3A 6CkTV5db3/JghW9fhk3ypHYrgpeRadmhSrYNqw02Q3TJbpLjT0k2iLwOV97uFocmKv6H+g8PH0J RSwmk7stvJXeUm/wLk+Fl98Qnn8nKxzlJtrHTyz1eIW980VaxA1TOtD+SQCeJputsPJSZWlJQd9 DGoAPh6qyj/dezixoS32qAKNL1ArEckI= X-Google-Smtp-Source: AGHT+IFB5Rhb7EHeEiI/ams6KhI9UuNHFiZtaUNiO/aRfCno9CNSrWB+oIrGqone/4N7uev3L98hjA== X-Received: by 2002:a05:6000:2083:b0:3b8:d493:31f4 with SMTP id ffacd0b85a97d-3b900b83c8bmr1969857f8f.48.1754652225356; Fri, 08 Aug 2025 04:23:45 -0700 (PDT) Received: from ho-tower-lan.lan ([185.48.76.109]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-45923c34af8sm233482635e9.24.2025.08.08.04.23.44 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 08 Aug 2025 04:23:44 -0700 (PDT) From: James Clark Date: Fri, 08 Aug 2025 12:22:58 +0100 Subject: [PATCH v6 01/12] arm64: sysreg: Add new PMSFCR_EL1 fields and PMSDSFR_EL1 register 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: <20250808-james-perf-feat_spe_eft-v6-1-6daf498578c8@linaro.org> References: <20250808-james-perf-feat_spe_eft-v6-0-6daf498578c8@linaro.org> In-Reply-To: <20250808-james-perf-feat_spe_eft-v6-0-6daf498578c8@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 , Anshuman Khandual 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 Add new fields and register that are introduced for the features FEAT_SPE_EFT (extended filtering) and FEAT_SPE_FDS (data source filtering). Tested-by: Leo Yan Reviewed-by: Anshuman Khandual Acked-by: Will Deacon Signed-off-by: James Clark --- arch/arm64/tools/sysreg | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/arch/arm64/tools/sysreg b/arch/arm64/tools/sysreg index 696ab1f32a67..b743fc8ffe5d 100644 --- a/arch/arm64/tools/sysreg +++ b/arch/arm64/tools/sysreg @@ -2994,11 +2994,20 @@ Field 0 RND EndSysreg =20 Sysreg PMSFCR_EL1 3 0 9 9 4 -Res0 63:19 +Res0 63:53 +Field 52 SIMDm +Field 51 FPm +Field 50 STm +Field 49 LDm +Field 48 Bm +Res0 47:21 +Field 20 SIMD +Field 19 FP Field 18 ST Field 17 LD Field 16 B -Res0 15:4 +Res0 15:5 +Field 4 FDS Field 3 FnE Field 2 FL Field 1 FT --=20 2.34.1 From nobody Tue Feb 10 09:45:02 2026 Received: from mail-wm1-f45.google.com (mail-wm1-f45.google.com [209.85.128.45]) (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 A149F2749D1 for ; Fri, 8 Aug 2025 11:23:48 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.45 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1754652231; cv=none; b=FTTaoZeEhk2H7T15v4i9xSl6PD15pJVfYqWaH6jwB21Lv7y+OmsPQVaRtk2vNfUglIRIsVkK7jEHvv7pXVXAbYERV31hbAk8fFlFSfuOZFQ66xsQaqWSEpEkYGjbFDKgWs7vVndqsQK2QSNPxX3TRUwCKQwvFBYZpuQik779rrk= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1754652231; c=relaxed/simple; bh=I2wprAUjGVDo+AtRM54DvcrrnAQqpHskVecGi0/r7N0=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=cqFYs8uxcHCtHoOt8OYdhsTLc4RczAttCOvQ1Y/GLGGWRLUyD+XXB8u1zCzC8SNNlByGpxrPTCZ/cNQkcj2ZcDf5WgKT+SMOoMd2l82X5jZr5F9gMFvKgkXbaq3ugdYd7F+whQyzXcy25cNRVPK2LoqETDh2kcJmw5EZxf2i+/c= 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=JbLINEHX; arc=none smtp.client-ip=209.85.128.45 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="JbLINEHX" Received: by mail-wm1-f45.google.com with SMTP id 5b1f17b1804b1-459e39ee7ccso19562155e9.2 for ; Fri, 08 Aug 2025 04:23:48 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1754652227; x=1755257027; 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=ZKNrcZ2inN0dkigrfPU+4VDLBHMGjNs6FZWiUZEa0EE=; b=JbLINEHXatyjJogdBZhU8DfvWWU3uVy6m4jIh+XqNXyvt+2kHIuxlKs/IeHww70s4H NCd+nUd3YUZ1sJWm3VMNH8m7H+KUvjqpUVtYmO359R3humMoX+vYJlNPqFL4r9eJ2Oev WkMjfsAwyKqBjI1gCM4/FDF14h6OvMSZvTv1sORF0W+yNchwmq2AqyC6VNGDtHoFiVA4 nVaQzaMrYwjBY8WsMdkjUSdXivDW66lkkR9XzMiFVqSdIO9fB/+kOpeV9Tvcsj3gt/Nw cdU/l5UqBVkUhwVCINZOVADGJ5EIbsPqCSoV603lzHRL26nuRn7uyNvJNPBd3jswOVqw FYLA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1754652227; x=1755257027; 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=ZKNrcZ2inN0dkigrfPU+4VDLBHMGjNs6FZWiUZEa0EE=; b=rybCZcJKwAqqxtZjRHxulC49uteJu1C2LtpMC6fNU36bd+D5dWbyE/LE66Bjskf6ky YgbOgIcSGl1620UZnOPGGCYRvlevqcAshNHAhnSwcAojJKnSxQl3+G3LYAN71AdJIyjL /aRVicze7lv7GbrKD2N3xnFaWWTdkA5xFgqn5F0NNlOcNGHIXwXXwwLs7GdZ5UYu9kpe U+6ENAH9NoYD0HBvKFk/ydGhUVdxI139rgTJIVPJfMLS0E+/elHWp2CALxV8g/e/rXro cC3vD4Wy0MVPTJ2wzLevCXau/jJmbxjTQpW3GMwUkh7X8dlxWss9bFq329fnbIb55Cy4 31+g== X-Forwarded-Encrypted: i=1; AJvYcCWP3Akma8LMr/JqSyQ/rQYskcarC515WRRoUEsw3pWg8Mb6R3hgdZ+TqrNz/NZMWSR7TYMLorB85Tcd0Nc=@vger.kernel.org X-Gm-Message-State: AOJu0YzYN9b2ikGcszqvZYmst63YjO2Roqpto5BmlR/uuYS92hU2gAVO 55dUBJPWaDPz7skG+OwItrJmW0yV4ztvl/eA1SdvJqDLtXoWcCZoJ4O185p71Q4c/8k= X-Gm-Gg: ASbGncsbvxHqUm7dlVzFhd6IJPN0KzdDxdTLHAbXajkVql4WEDNHit8zyAjhMzuYGRg OrK8sr2uHJF5bKeBaUlW3JfLkBmxc1XOduiEsZW6wlCQufMvtdF6JUj4Kbx6R1FUHAu9pNmjjkU PhG7AJP1DZ/IMW/W0nByrIMtDL+Jxzge2PscKXRqHX6yndBS18FA3LbSCLpb8sgEVDAOvkpkJBN EdB9bmBf0mVB58oxMLrZWhLxE3u99XVpYRobPMFFSgM6Gdy6RFF9bTwKXNS1ObZnJodEmaK8LAb 1Vr+OaZ/VAWwb96SLLYX6b146DGGWV0c6x0N3y09fZj5j4PEqD8I1cQpmcErwQM/APvUoBs7lrW 9FojE4ysZLUN/sG0Vwudids4+z00Y+rgGWdmIfDkiHA== X-Google-Smtp-Source: AGHT+IEtGnKsBCIt/bHJOIS9ohOXGTF7i3Bn62tMY3vsP7Ew4XXFQhJGD0FnbE4+ZBqeRgof8LyUmw== X-Received: by 2002:a05:600c:3b10:b0:459:10de:551e with SMTP id 5b1f17b1804b1-459f4faf9b9mr19984585e9.27.1754652226748; Fri, 08 Aug 2025 04:23:46 -0700 (PDT) Received: from ho-tower-lan.lan ([185.48.76.109]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-45923c34af8sm233482635e9.24.2025.08.08.04.23.45 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 08 Aug 2025 04:23:46 -0700 (PDT) From: James Clark Date: Fri, 08 Aug 2025 12:22:59 +0100 Subject: [PATCH v6 02/12] perf: arm_spe: Support FEAT_SPEv1p4 filters 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: <20250808-james-perf-feat_spe_eft-v6-2-6daf498578c8@linaro.org> References: <20250808-james-perf-feat_spe_eft-v6-0-6daf498578c8@linaro.org> In-Reply-To: <20250808-james-perf-feat_spe_eft-v6-0-6daf498578c8@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 , Anshuman Khandual 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 FEAT_SPEv1p4 (optional from Armv8.8) adds some new filter bits and also makes some previously available bits unavailable again e.g: E[30], bit [30] When FEAT_SPEv1p4 is _not_ implemented ... Continuing to hard code the valid filter bits for each version isn't scalable, and it also doesn't work for filter bits that aren't related to SPE version. For example most bits have a further condition: E[15], bit [15] When ... and filtering on event 15 is supported: Whether "filtering on event 15" is implemented or not is only discoverable from the TRM of that specific CPU or by probing PMSEVFR_EL1. Instead of hard coding them, write all 1s to the PMSEVFR_EL1 register and read it back to discover the RES0 bits. Unsupported bits are RAZ/WI so should read as 0s. For any hardware that doesn't strictly follow RAZ/WI for unsupported filters: Any bits that should have been supported in a specific SPE version but now incorrectly appear to be RES0 wouldn't have worked anyway, so it's better to fail to open events that request them rather than behaving unexpectedly. Bits that aren't implemented but also aren't RAZ/WI will be incorrectly reported as supported, but allowing them to be used is harmless. Testing on N1SDP shows the probed RES0 bits to be the same as the hard coded ones. The FVP with SPEv1p4 shows only additional new RES0 bits, i.e. no previously hard coded RES0 bits are missing. Signed-off-by: James Clark Tested-by: Leo Yan --- arch/arm64/include/asm/sysreg.h | 9 --------- drivers/perf/arm_spe_pmu.c | 23 +++++++---------------- 2 files changed, 7 insertions(+), 25 deletions(-) diff --git a/arch/arm64/include/asm/sysreg.h b/arch/arm64/include/asm/sysre= g.h index d5b5f2ae1afa..20cbd9860c8f 100644 --- a/arch/arm64/include/asm/sysreg.h +++ b/arch/arm64/include/asm/sysreg.h @@ -344,15 +344,6 @@ #define SYS_PAR_EL1_ATTR GENMASK_ULL(63, 56) #define SYS_PAR_EL1_F0_RES0 (GENMASK_ULL(6, 1) | GENMASK_ULL(55, 52)) =20 -/*** Statistical Profiling Extension ***/ -#define PMSEVFR_EL1_RES0_IMP \ - (GENMASK_ULL(47, 32) | GENMASK_ULL(23, 16) | GENMASK_ULL(11, 8) |\ - BIT_ULL(6) | BIT_ULL(4) | BIT_ULL(2) | BIT_ULL(0)) -#define PMSEVFR_EL1_RES0_V1P1 \ - (PMSEVFR_EL1_RES0_IMP & ~(BIT_ULL(18) | BIT_ULL(17) | BIT_ULL(11))) -#define PMSEVFR_EL1_RES0_V1P2 \ - (PMSEVFR_EL1_RES0_V1P1 & ~BIT_ULL(6)) - /* Buffer error reporting */ #define PMBSR_EL1_FAULT_FSC_SHIFT PMBSR_EL1_MSS_SHIFT #define PMBSR_EL1_FAULT_FSC_MASK PMBSR_EL1_MSS_MASK diff --git a/drivers/perf/arm_spe_pmu.c b/drivers/perf/arm_spe_pmu.c index 369e77ad5f13..86c9948ab5a0 100644 --- a/drivers/perf/arm_spe_pmu.c +++ b/drivers/perf/arm_spe_pmu.c @@ -89,6 +89,7 @@ struct arm_spe_pmu { #define SPE_PMU_FEAT_DEV_PROBED (1UL << 63) u64 features; =20 + u64 pmsevfr_res0; u16 max_record_sz; u16 align; struct perf_output_handle __percpu *handle; @@ -697,20 +698,6 @@ static irqreturn_t arm_spe_pmu_irq_handler(int irq, vo= id *dev) return IRQ_HANDLED; } =20 -static u64 arm_spe_pmsevfr_res0(u16 pmsver) -{ - switch (pmsver) { - case ID_AA64DFR0_EL1_PMSVer_IMP: - return PMSEVFR_EL1_RES0_IMP; - case ID_AA64DFR0_EL1_PMSVer_V1P1: - return PMSEVFR_EL1_RES0_V1P1; - case ID_AA64DFR0_EL1_PMSVer_V1P2: - /* Return the highest version we support in default */ - default: - return PMSEVFR_EL1_RES0_V1P2; - } -} - /* Perf callbacks */ static int arm_spe_pmu_event_init(struct perf_event *event) { @@ -726,10 +713,10 @@ static int arm_spe_pmu_event_init(struct perf_event *= event) !cpumask_test_cpu(event->cpu, &spe_pmu->supported_cpus)) return -ENOENT; =20 - if (arm_spe_event_to_pmsevfr(event) & arm_spe_pmsevfr_res0(spe_pmu->pmsve= r)) + if (arm_spe_event_to_pmsevfr(event) & spe_pmu->pmsevfr_res0) return -EOPNOTSUPP; =20 - if (arm_spe_event_to_pmsnevfr(event) & arm_spe_pmsevfr_res0(spe_pmu->pmsv= er)) + if (arm_spe_event_to_pmsnevfr(event) & spe_pmu->pmsevfr_res0) return -EOPNOTSUPP; =20 if (attr->exclude_idle) @@ -1107,6 +1094,10 @@ static void __arm_spe_pmu_dev_probe(void *info) spe_pmu->counter_sz =3D 16; } =20 + /* Write all 1s and then read back. Unsupported filter bits are RAZ/WI. */ + write_sysreg_s(U64_MAX, SYS_PMSEVFR_EL1); + spe_pmu->pmsevfr_res0 =3D ~read_sysreg_s(SYS_PMSEVFR_EL1); + dev_info(dev, "probed SPEv1.%d for CPUs %*pbl [max_record_sz %u, align %u, features 0= x%llx]\n", spe_pmu->pmsver - 1, cpumask_pr_args(&spe_pmu->supported_cpus), --=20 2.34.1 From nobody Tue Feb 10 09:45:02 2026 Received: from mail-wr1-f49.google.com (mail-wr1-f49.google.com [209.85.221.49]) (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 3F0AC274B2E for ; Fri, 8 Aug 2025 11:23:50 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.221.49 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1754652232; cv=none; b=FmoBbHkW/UQbY1Nn1ZRH66+7TKL9Wy8c+pba5zQMqFueuP6d0b+dHmQ8Gn5QHRkMpE6DfQuHLEG+ex1nmekTRXSoqmnbLlQBaAmdrL5XuuKWnfCD5YAjX+VeQhk1HnfD01PkNiqul9apdqdcJzaB/vlaqALcOHfGXbWtmhZXQUU= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1754652232; c=relaxed/simple; bh=6LM6jJAX7/wRjLu63PFJ21YibPN4QtHqwn0zElm0y7w=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=tGhPqv5BTeBZ+QsZMZgl76RJJQHYcFHSs+bNMUWMQSh6ng3DFt8ekdSMUyk5llrk92SWXLwkKQMpGlHMXuSmDVGem2/Ih538icaJl6ON4hVbFH6lsSjBsr0sbQpd5C95mc5hLf15LhH6419bBVzchGKkvyt7jkgwjdE0N53cAnc= 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=RBltHVdX; arc=none smtp.client-ip=209.85.221.49 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="RBltHVdX" Received: by mail-wr1-f49.google.com with SMTP id ffacd0b85a97d-3b7920354f9so1642093f8f.2 for ; Fri, 08 Aug 2025 04:23:49 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1754652228; x=1755257028; 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=xMesWcHoEa33KjF/J2eeIl0BbZ+P5s/S1CfPVNJYZ2s=; b=RBltHVdXnmEF79bpRX0FD1JKX9WlPxiIJAMiRmIfRuDqiGq+SOaXizqXzXlUSSEwOD ZvCFc1rH34Amkpng5nL5JE55EzlpDTa0SdcLc21FACPVMHzPvuqEKwA9MsD2aWYN1GCj bCiPfP3G/uTdjLeNjYQyT9Xo9Rne0QXLpG7ZmRuv97P49X0mbgpLvLJUIWaT5OhRYaN1 dY/yYKQvVNZvEKnCZyZlAgD4bAZ3RG55X8Z6/zl4e+QJ8IEBqH0O+mFC1yvRW4fAe5Sr n17WlfNpheUYCL8TMvtjLX098IR71NsQ6/g2eJTGyDkaFrdf3bQYy+2FwVN3xbDNOfXx 1uRw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1754652228; x=1755257028; 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=xMesWcHoEa33KjF/J2eeIl0BbZ+P5s/S1CfPVNJYZ2s=; b=rz9pnQZRsCz7ar6xTfh2PU0OVTVzTV9zGo4VaEwKPnqinbv3oeICPD6CinMhN2fZY2 O0TuAOHu3vrzTCxwu4C33ccA8+6W/zM2Ljf27xQgf7MjjbaZf8MvfuEjuS80xfRd/GEf gcQok7VmSeD958PFD8EtxjZzqfRXEjAyvttKBlPO0qGdFB/3C5ByeF9lj1YSmCu92GX/ qo2cJGp3kXfigLsVxn/vLkSb2bHz+FsPORKSvlbiq1hQzAlYuKi6JQqe+s0QaaWbQvRl G5qzOtvoM3rV1ENtmBPPnHgdcGuRhVKOYDYNMhSJaOz+ZYZjj7pA66fpJAB1VIlJ5FDo q1uw== X-Forwarded-Encrypted: i=1; AJvYcCVnarFNE4i45tswHlfy7ujFtMdWkuWVse3XdfW5XOjpJlp+CfG2is55zDcga0vnVTh0AcjiuzJKl6CVInI=@vger.kernel.org X-Gm-Message-State: AOJu0YyzfIZRtvNpoLfJnMdQETTFqGtYSa+rHh+zeXWsHOd+2BqWXWE5 nQXQEl4t4OySaMOpvFgklxWX5Mj+1rWiKSpVu66Et2DJ1hXgGbqdkTyWZI9T9/d331M= X-Gm-Gg: ASbGncu7O+34XfniRpH6+vsV4UiHDN9/Eg6h37nw1cdYgpkxbRuRWzptjb4VD2FBhc0 6M9BXAsBS326DdG1u1XTaruxzmoOkIG1Xa8D9wGIbblLOs90QRLuWjfSSMFKCYI8P5cX9LPl5lT sgBrFHizJGEW200AhuIwT56f9DOHpTNJIh4ITnH2axkHqvHRdZKu3Q365258PfVCji4Sck4qgQP KaB/eDMGxEZuFqo9enJSwdi8b+XeuyKdoaYLm94WHxL1fgorJaBo04ZxQS35cb7QHR7YtClIyDP yjC+35Ds9Z2+ywCeQjRnNkpcNTsQzdIJYyU1gx6gs9nCLnXK454cXXJCzbWEW/bT08yrfT4bYUu u+wtdmFhmho0ywZdxO8o74KBVK37xfHo= X-Google-Smtp-Source: AGHT+IG3KhpqmqY9mPCdYHy2kQ4dmK3mleBKR4K9YT1Bk9x07Zhf4VDQvqcJSmZgyy16+lcV/chGew== X-Received: by 2002:a05:6000:2483:b0:3b7:8146:463c with SMTP id ffacd0b85a97d-3b900b8bde2mr2125187f8f.59.1754652228218; Fri, 08 Aug 2025 04:23:48 -0700 (PDT) Received: from ho-tower-lan.lan ([185.48.76.109]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-45923c34af8sm233482635e9.24.2025.08.08.04.23.46 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 08 Aug 2025 04:23:47 -0700 (PDT) From: James Clark Date: Fri, 08 Aug 2025 12:23:00 +0100 Subject: [PATCH v6 03/12] perf: arm_spe: Expose event filter 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: <20250808-james-perf-feat_spe_eft-v6-3-6daf498578c8@linaro.org> References: <20250808-james-perf-feat_spe_eft-v6-0-6daf498578c8@linaro.org> In-Reply-To: <20250808-james-perf-feat_spe_eft-v6-0-6daf498578c8@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 , Anshuman Khandual 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 From: Leo Yan Expose an "event_filter" entry in the caps folder to inform user space about which events can be filtered. Change the return type of arm_spe_pmu_cap_get() from u32 to u64 to accommodate the added event filter entry. Signed-off-by: Leo Yan Signed-off-by: James Clark Tested-by: Leo Yan --- drivers/perf/arm_spe_pmu.c | 22 ++++++++++++++++++++-- 1 file changed, 20 insertions(+), 2 deletions(-) diff --git a/drivers/perf/arm_spe_pmu.c b/drivers/perf/arm_spe_pmu.c index 86c9948ab5a0..ba55bc3db708 100644 --- a/drivers/perf/arm_spe_pmu.c +++ b/drivers/perf/arm_spe_pmu.c @@ -116,6 +116,7 @@ enum arm_spe_pmu_capabilities { SPE_PMU_CAP_FEAT_MAX, SPE_PMU_CAP_CNT_SZ =3D SPE_PMU_CAP_FEAT_MAX, SPE_PMU_CAP_MIN_IVAL, + SPE_PMU_CAP_EVENT_FILTER, }; =20 static int arm_spe_pmu_feat_caps[SPE_PMU_CAP_FEAT_MAX] =3D { @@ -123,7 +124,7 @@ static int arm_spe_pmu_feat_caps[SPE_PMU_CAP_FEAT_MAX] = =3D { [SPE_PMU_CAP_ERND] =3D SPE_PMU_FEAT_ERND, }; =20 -static u32 arm_spe_pmu_cap_get(struct arm_spe_pmu *spe_pmu, int cap) +static u64 arm_spe_pmu_cap_get(struct arm_spe_pmu *spe_pmu, int cap) { if (cap < SPE_PMU_CAP_FEAT_MAX) return !!(spe_pmu->features & arm_spe_pmu_feat_caps[cap]); @@ -133,6 +134,8 @@ static u32 arm_spe_pmu_cap_get(struct arm_spe_pmu *spe_= pmu, int cap) return spe_pmu->counter_sz; case SPE_PMU_CAP_MIN_IVAL: return spe_pmu->min_period; + case SPE_PMU_CAP_EVENT_FILTER: + return ~spe_pmu->pmsevfr_res0; default: WARN(1, "unknown cap %d\n", cap); } @@ -149,7 +152,19 @@ static ssize_t arm_spe_pmu_cap_show(struct device *dev, container_of(attr, struct dev_ext_attribute, attr); int cap =3D (long)ea->var; =20 - return sysfs_emit(buf, "%u\n", arm_spe_pmu_cap_get(spe_pmu, cap)); + return sysfs_emit(buf, "%llu\n", arm_spe_pmu_cap_get(spe_pmu, cap)); +} + +static ssize_t arm_spe_pmu_cap_show_hex(struct device *dev, + struct device_attribute *attr, + char *buf) +{ + struct arm_spe_pmu *spe_pmu =3D dev_get_drvdata(dev); + struct dev_ext_attribute *ea =3D + container_of(attr, struct dev_ext_attribute, attr); + int cap =3D (long)ea->var; + + return sysfs_emit(buf, "0x%llx\n", arm_spe_pmu_cap_get(spe_pmu, cap)); } =20 #define SPE_EXT_ATTR_ENTRY(_name, _func, _var) \ @@ -159,12 +174,15 @@ static ssize_t arm_spe_pmu_cap_show(struct device *de= v, =20 #define SPE_CAP_EXT_ATTR_ENTRY(_name, _var) \ SPE_EXT_ATTR_ENTRY(_name, arm_spe_pmu_cap_show, _var) +#define SPE_CAP_EXT_ATTR_ENTRY_HEX(_name, _var) \ + SPE_EXT_ATTR_ENTRY(_name, arm_spe_pmu_cap_show_hex, _var) =20 static struct attribute *arm_spe_pmu_cap_attr[] =3D { SPE_CAP_EXT_ATTR_ENTRY(arch_inst, SPE_PMU_CAP_ARCH_INST), SPE_CAP_EXT_ATTR_ENTRY(ernd, SPE_PMU_CAP_ERND), SPE_CAP_EXT_ATTR_ENTRY(count_size, SPE_PMU_CAP_CNT_SZ), SPE_CAP_EXT_ATTR_ENTRY(min_interval, SPE_PMU_CAP_MIN_IVAL), + SPE_CAP_EXT_ATTR_ENTRY_HEX(event_filter, SPE_PMU_CAP_EVENT_FILTER), NULL, }; =20 --=20 2.34.1 From nobody Tue Feb 10 09:45:02 2026 Received: from mail-wm1-f45.google.com (mail-wm1-f45.google.com [209.85.128.45]) (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 6BB7E274B55 for ; Fri, 8 Aug 2025 11:23:51 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.45 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1754652234; cv=none; b=hOoBpBWHa1Zlu2OLpPICztwkNqHkEerjEulbGmXuuZW0xY6MfSGGija7ziMlgXhi9F1EdLh8BDVFHds23fjyEGWvFyeX3wMqey6mUakuhWuSP6OfdEKMN0MD1e7FwAFeDWk3gylksEurdfQsFTmGjtT0BAanDn/RUyhkXdjcun8= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1754652234; c=relaxed/simple; bh=amxfcIwk9CPU6fVzRnT+1Y2WxFhNVG4dD8O25j9WGOo=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=tHjX70nAdKJTYo7LVil8HndgCZHQaGuPNbt66EumjYxOexO50B9E+JWkFtQQW53vKjSsOdahqQhetPsBM0yrlCAOvMFTUH+d0QYmShTlZDKh+R3iiX6NtXzYoLuB7hCAlKiUIqs4bQsRO2iUa5wNleaMQ5OK0dCbX1mibJOVxfM= 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=Z9qgm/yN; arc=none smtp.client-ip=209.85.128.45 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="Z9qgm/yN" Received: by mail-wm1-f45.google.com with SMTP id 5b1f17b1804b1-458baf449cbso19137565e9.0 for ; Fri, 08 Aug 2025 04:23:51 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1754652230; x=1755257030; 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=bqDXfRMF96Zx+Uai2DOOReiNYXmUoTa9f4yVdbBVPio=; b=Z9qgm/yNWXcgSvMlCSvyCHLtItzizLYGlUxagMpA9IVHhz1QQ9BS4xJtAuHQIs2Wt4 oGTEokBN4HVpEotyS4c5ZvV2etXJ/VbpXZVKDGBsBfoVz0K1c/79w9nAYRCz5kcZ7hFb 6rr6A9uxXlt1XT5t8UDL8Ynmm2s5zIMQoaLL+WYFKAR8dqc7TS4ruLM6MoYEn4/d5h/V 1DUfNomSs4nOM611yvIhZauU16sJ3ePh626DZupVPoPlzhjzThDWJkn4c3pjC22NVd14 94l5chf5Opbnp7Q2g4s0nRjc4rYXmOzfM7g57eQJsHOx8rhSl5NpUeL+MsgdPSI95UKM xn3Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1754652230; x=1755257030; 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=bqDXfRMF96Zx+Uai2DOOReiNYXmUoTa9f4yVdbBVPio=; b=hRWz3EoQXGwVJsuk6kb0NjU93V88CMNbknERiWZdd9YA29LuBHXBd0LXX3ikAhV9gR 775nji4Ta8xbakLiV3Hdc9JCn5JGqZXBflLzIzJ2f+VscqJTcmRJbR9hHNeWLCIGQLTT ZtUZWLkoalA/ngpgXzfvbb/XZb5e8hXtW7ilZ40PjK9556YTyFwdsz4cY9CE1di8V+hT Eptl6/BGJG4uEzrUcSf5obwMGZz2fNFqgu8+pfSgp45mKObDtCBmMbcYlJncYXmRP2fl HQ2bx4M7qDiXTCe2N53KPeVuRemRv4Q24KDQCFefGF8n0mrXcDgP4BPXocO0xgpZkdt3 HVYA== X-Forwarded-Encrypted: i=1; AJvYcCX1SSJT6zFwrYCF2GntzAL1owpKm0slNfVUYXnd2EuIcqHyfRh0Tf6NSnIJ85PW+xtwdxapltRasyAr28A=@vger.kernel.org X-Gm-Message-State: AOJu0YzRdUB2+FehG46o6qRr2k2vHh2PD38CWbQEfiNHObJBr81TT4Jt RGidVNLLSc3qdZ3I7YxnUzGcGe4Nus1erGVPH+47SDp7VQjKwhP5abub53JWAPoUJyw= X-Gm-Gg: ASbGncuZRjsUGcJVtQ7giwoT+bqnUNFLncqbXNJgi/4o7WTsEQWqLSIyLlQh2oiyVyY KnvHyxCVJZKtAOVdhT3udeT6C9C+0z/H0KgjYZ+uIZeSWHuYspBO/b4p9+63H4lXFLHtEV5julu pbkYFha67KRPGuARMKGV2ips4a37AK+74YvffYPQ2fiMi/AZNMdUG8sxV+aB7V4EDfc6uieiRpM H/0eu5nbdQqenwSUzcpkGUBOMrUyzLbWvLgDkal1nk3tMAIdy42x5DQSyaGsTAcTkiX4aK5fviA fS/wLLLj1/kWHpZzMs0z8e71VR+y8U2HKzYHHNhNSj1cvjgvASwks8B7oSCHRgZcD4o3hMOtcZc RgK0JYI3tLQzg46PaCKr08G2UPAlpy5I= X-Google-Smtp-Source: AGHT+IHowdxZHjgH6bK7OIH/nXQ5aiavdpvaNKG8jnVSTD7lTm87fiBZ7lvMLO6xgDiJMSCjDqL77A== X-Received: by 2002:a05:600c:1c0e:b0:459:d9a2:e927 with SMTP id 5b1f17b1804b1-459f4f3ced4mr22526035e9.5.1754652229721; Fri, 08 Aug 2025 04:23:49 -0700 (PDT) Received: from ho-tower-lan.lan ([185.48.76.109]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-45923c34af8sm233482635e9.24.2025.08.08.04.23.48 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 08 Aug 2025 04:23:49 -0700 (PDT) From: James Clark Date: Fri, 08 Aug 2025 12:23:01 +0100 Subject: [PATCH v6 04/12] perf: arm_spe: Add support for FEAT_SPE_EFT extended filtering 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: <20250808-james-perf-feat_spe_eft-v6-4-6daf498578c8@linaro.org> References: <20250808-james-perf-feat_spe_eft-v6-0-6daf498578c8@linaro.org> In-Reply-To: <20250808-james-perf-feat_spe_eft-v6-0-6daf498578c8@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 , Anshuman Khandual 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 FEAT_SPE_EFT (optional from Armv9.4) adds mask bits for the existing load, store and branch filters. It also adds two new filter bits for SIMD and floating point with their own associated mask bits. The current filters only allow OR filtering on samples that are load OR store etc, and the new mask bits allow setting part of the filter to an AND, for example filtering samples that are store AND SIMD. With mask bits set to 0, the OR behavior is preserved, so the unless any masks are explicitly set old filters will behave the same. Add them all and make them behave the same way as existing format bits, hidden and return EOPNOTSUPP if set when the feature doesn't exist. Reviewed-by: Leo Yan Tested-by: Leo Yan Signed-off-by: James Clark --- drivers/perf/arm_spe_pmu.c | 66 ++++++++++++++++++++++++++++++++++++++++++= ++++ 1 file changed, 66 insertions(+) diff --git a/drivers/perf/arm_spe_pmu.c b/drivers/perf/arm_spe_pmu.c index ba55bc3db708..591f72fa0327 100644 --- a/drivers/perf/arm_spe_pmu.c +++ b/drivers/perf/arm_spe_pmu.c @@ -86,6 +86,7 @@ struct arm_spe_pmu { #define SPE_PMU_FEAT_ERND (1UL << 5) #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_DEV_PROBED (1UL << 63) u64 features; =20 @@ -216,6 +217,27 @@ static const struct attribute_group arm_spe_pmu_cap_gr= oup =3D { #define ATTR_CFG_FLD_discard_CFG config /* PMBLIMITR_EL1.FM =3D DISCARD */ #define ATTR_CFG_FLD_discard_LO 35 #define ATTR_CFG_FLD_discard_HI 35 +#define ATTR_CFG_FLD_branch_filter_mask_CFG config /* PMSFCR_EL1.Bm */ +#define ATTR_CFG_FLD_branch_filter_mask_LO 36 +#define ATTR_CFG_FLD_branch_filter_mask_HI 36 +#define ATTR_CFG_FLD_load_filter_mask_CFG config /* PMSFCR_EL1.LDm */ +#define ATTR_CFG_FLD_load_filter_mask_LO 37 +#define ATTR_CFG_FLD_load_filter_mask_HI 37 +#define ATTR_CFG_FLD_store_filter_mask_CFG config /* PMSFCR_EL1.STm */ +#define ATTR_CFG_FLD_store_filter_mask_LO 38 +#define ATTR_CFG_FLD_store_filter_mask_HI 38 +#define ATTR_CFG_FLD_simd_filter_CFG config /* PMSFCR_EL1.SIMD */ +#define ATTR_CFG_FLD_simd_filter_LO 39 +#define ATTR_CFG_FLD_simd_filter_HI 39 +#define ATTR_CFG_FLD_simd_filter_mask_CFG config /* PMSFCR_EL1.SIMDm */ +#define ATTR_CFG_FLD_simd_filter_mask_LO 40 +#define ATTR_CFG_FLD_simd_filter_mask_HI 40 +#define ATTR_CFG_FLD_float_filter_CFG config /* PMSFCR_EL1.FP */ +#define ATTR_CFG_FLD_float_filter_LO 41 +#define ATTR_CFG_FLD_float_filter_HI 41 +#define ATTR_CFG_FLD_float_filter_mask_CFG config /* PMSFCR_EL1.FPm */ +#define ATTR_CFG_FLD_float_filter_mask_LO 42 +#define ATTR_CFG_FLD_float_filter_mask_HI 42 =20 #define ATTR_CFG_FLD_event_filter_CFG config1 /* PMSEVFR_EL1 */ #define ATTR_CFG_FLD_event_filter_LO 0 @@ -234,8 +256,15 @@ GEN_PMU_FORMAT_ATTR(pa_enable); GEN_PMU_FORMAT_ATTR(pct_enable); GEN_PMU_FORMAT_ATTR(jitter); GEN_PMU_FORMAT_ATTR(branch_filter); +GEN_PMU_FORMAT_ATTR(branch_filter_mask); GEN_PMU_FORMAT_ATTR(load_filter); +GEN_PMU_FORMAT_ATTR(load_filter_mask); GEN_PMU_FORMAT_ATTR(store_filter); +GEN_PMU_FORMAT_ATTR(store_filter_mask); +GEN_PMU_FORMAT_ATTR(simd_filter); +GEN_PMU_FORMAT_ATTR(simd_filter_mask); +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(min_latency); @@ -247,8 +276,15 @@ static struct attribute *arm_spe_pmu_formats_attr[] = =3D { &format_attr_pct_enable.attr, &format_attr_jitter.attr, &format_attr_branch_filter.attr, + &format_attr_branch_filter_mask.attr, &format_attr_load_filter.attr, + &format_attr_load_filter_mask.attr, &format_attr_store_filter.attr, + &format_attr_store_filter_mask.attr, + &format_attr_simd_filter.attr, + &format_attr_simd_filter_mask.attr, + &format_attr_float_filter.attr, + &format_attr_float_filter_mask.attr, &format_attr_event_filter.attr, &format_attr_inv_event_filter.attr, &format_attr_min_latency.attr, @@ -269,6 +305,16 @@ static umode_t arm_spe_pmu_format_attr_is_visible(stru= ct 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_branch_filter_mask.attr || + attr =3D=3D &format_attr_load_filter_mask.attr || + attr =3D=3D &format_attr_store_filter_mask.attr || + attr =3D=3D &format_attr_simd_filter.attr || + attr =3D=3D &format_attr_simd_filter_mask.attr || + attr =3D=3D &format_attr_float_filter.attr || + attr =3D=3D &format_attr_float_filter_mask.attr) && + !(spe_pmu->features & SPE_PMU_FEAT_EFT)) + return 0; + return attr->mode; } =20 @@ -364,8 +410,15 @@ static u64 arm_spe_event_to_pmsfcr(struct perf_event *= event) u64 reg =3D 0; =20 reg |=3D FIELD_PREP(PMSFCR_EL1_LD, ATTR_CFG_GET_FLD(attr, load_filter)); + reg |=3D FIELD_PREP(PMSFCR_EL1_LDm, ATTR_CFG_GET_FLD(attr, load_filter_ma= sk)); reg |=3D FIELD_PREP(PMSFCR_EL1_ST, ATTR_CFG_GET_FLD(attr, store_filter)); + reg |=3D FIELD_PREP(PMSFCR_EL1_STm, ATTR_CFG_GET_FLD(attr, store_filter_m= ask)); reg |=3D FIELD_PREP(PMSFCR_EL1_B, ATTR_CFG_GET_FLD(attr, branch_filter)); + reg |=3D FIELD_PREP(PMSFCR_EL1_Bm, ATTR_CFG_GET_FLD(attr, branch_filter_m= ask)); + reg |=3D FIELD_PREP(PMSFCR_EL1_SIMD, ATTR_CFG_GET_FLD(attr, simd_filter)); + reg |=3D FIELD_PREP(PMSFCR_EL1_SIMDm, ATTR_CFG_GET_FLD(attr, simd_filter_= mask)); + reg |=3D FIELD_PREP(PMSFCR_EL1_FP, ATTR_CFG_GET_FLD(attr, float_filter)); + reg |=3D FIELD_PREP(PMSFCR_EL1_FPm, ATTR_CFG_GET_FLD(attr, float_filter_m= ask)); =20 if (reg) reg |=3D PMSFCR_EL1_FT; @@ -767,6 +820,16 @@ static int arm_spe_pmu_event_init(struct perf_event *e= vent) !(spe_pmu->features & SPE_PMU_FEAT_FILT_LAT)) return -EOPNOTSUPP; =20 + if ((FIELD_GET(PMSFCR_EL1_LDm, reg) || + FIELD_GET(PMSFCR_EL1_STm, reg) || + FIELD_GET(PMSFCR_EL1_Bm, reg) || + FIELD_GET(PMSFCR_EL1_SIMD, reg) || + FIELD_GET(PMSFCR_EL1_SIMDm, reg) || + FIELD_GET(PMSFCR_EL1_FP, reg) || + FIELD_GET(PMSFCR_EL1_FPm, reg)) && + !(spe_pmu->features & SPE_PMU_FEAT_EFT)) + return -EOPNOTSUPP; + if (ATTR_CFG_GET_FLD(&event->attr, discard) && !(spe_pmu->features & SPE_PMU_FEAT_DISCARD)) return -EOPNOTSUPP; @@ -1058,6 +1121,9 @@ static void __arm_spe_pmu_dev_probe(void *info) if (spe_pmu->pmsver >=3D ID_AA64DFR0_EL1_PMSVer_V1P2) spe_pmu->features |=3D SPE_PMU_FEAT_DISCARD; =20 + if (FIELD_GET(PMSIDR_EL1_EFT, reg)) + spe_pmu->features |=3D SPE_PMU_FEAT_EFT; + /* 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 From nobody Tue Feb 10 09:45:02 2026 Received: from mail-wm1-f48.google.com (mail-wm1-f48.google.com [209.85.128.48]) (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 3291F274FED for ; Fri, 8 Aug 2025 11:23:53 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.48 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1754652235; cv=none; b=Z7lO/ChGYam897Itz4OeDT+/EfVCkwv8kRTQJveE89jYZ6qRB1lt+ywAYohM+3Ut9ACoXzx5eQt/csDZiYSkFH9yQfA1c7vsbuDYtPeGcGdICPQODayf9Whe3UbEyqwMNijoZEZINeo5bBBr0TTuG+B13ZeoqDy1rC00h5B2kSk= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1754652235; c=relaxed/simple; bh=2M6WcB6KkvvOnu9SyMhbI08CMGWnnDOzfm+WTNCBqlk=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=fzi86Sw1kwRS1QVQk5VlRcbcnbKIHFWPjSM8iPXm3x2aZk0ZOYAB5/AnBhITZHirD38IDJRCzkSxSkfxlJjgNUz6eNPXPhmVbN74QloDs9M7RfXJ0GbDI4lYzEfX/VcSiS+v8rvaL5Uwxu5p0QZ35qZtK+lnQtjMADbzzwKOJo4= 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=ymSeUHxw; arc=none smtp.client-ip=209.85.128.48 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="ymSeUHxw" Received: by mail-wm1-f48.google.com with SMTP id 5b1f17b1804b1-458baf449cbso19137845e9.0 for ; Fri, 08 Aug 2025 04:23:52 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1754652231; x=1755257031; 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=pXydwqwRaP7AXP8zkgHzJDBJPfnaYLIQgQCT9Y2uDB4=; b=ymSeUHxwTMKi3VaTYQhTpCgbrrKehNqptGeCmEF0wpl4H8IfvJrneTlgWYbtZNxDcz kEtIE7Lhbm0T5A0TrF/xfPFd7V0SMZi2GSmmNI9NxpySw7dLwhZj4ezjZ1evdndqd35f fmXVX48v57T+bYYhuELBV0Qhv+Iyn95M09g9LrQOtSXWhLig1+0Jx61oGCLHVtJ047F4 x6PUcRTpxia53eP6MeiScdh4olyJ8DqXQsXU+pUKS4TMtOG310ngaVMigN+RnVWYiaIX LFP9p2yJUtb0n69fLebWucJ/K47rqZ+Kyj92odk+KiPOgEBkYKXMccNaJiClg3YWiH1g y3JA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1754652231; x=1755257031; 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=pXydwqwRaP7AXP8zkgHzJDBJPfnaYLIQgQCT9Y2uDB4=; b=oyN/omXG+A5GUfM4hSa2K73vzKGCA9U2Pk2BkbcGLU4NLnKMFMYo7P0mR11GE3zsXi CFE8RUT9EKECy1yTp0Q9G9R9B4ouo5GYPe+Q//YDPhv7EMSpnI/AQ0eP/yN76k75dW/P 3P28yU7qU+bn0foKjrZVQYvcoH4pxJHfFyJhAMRw4rhhrVo+PRqFh6dGNwRx1mtfW26h MXP3tQzU1BOgmT8YShgDJuixocCI55Ip59ACqP9roA1FWjkJxw/vK+irXx+wD91CR8/p dC+jc5Tsf9r/3jmMWxC6M1hlQNUC3VIlcrq/YIH1ZNiZzzO/26YraB8YXXK9ou7gMsp3 +Yog== X-Forwarded-Encrypted: i=1; AJvYcCWoFw3RbYrfvTVHywC6tlvOswBZ5hOQxrJEsT9eXJFu09Vr0XaZYbAgxA2/DMqW2kscjxWEjxdCAN3EAgQ=@vger.kernel.org X-Gm-Message-State: AOJu0Yx8bH8lxGnZJgXjxKxguPHm8Ylscg9VqBdQBqlzLxshTCQpZrXM mh7dyfhWkJOjpZyNRPesK6yIJLi672t49LMtoA/VC4wOm1vmePcK8SLB5C2WmmIYPoo= X-Gm-Gg: ASbGncuGdML0z4Tqr/dM4E3MP69xHrrgEmNW/UE/qgyEL1cLDT8LaDzpQp8U/yZWB6P ggQB3k++MiqIKcSapMcg1emRfoTUcunwv7+MtLdhQq3mveBy6i07YYL0get/7oBlT1Zka7oL8Zv weOYgAMTbb89VRto8A4cU/P6K+f5bea1vHwtAcFHAK9OpTupHlUixzk565M4On62qX8mJ12nBH2 BnvLORhrhHDo+PljregHY3FY9ljINxqzv4saLQRyg9U2CWmkMAUjuwUgbs4nLZ+Zur56U0WJfSo iojlsZWA3CyC1var5+ikHahXaxxoYrKJH2CKlpwQwYBc2J1PYoKV1SWPyLcz27Ox8rytSnvg+2R w/8q15sD88zecL7bWDO2bwAzuMBQwSpE= X-Google-Smtp-Source: AGHT+IGZt07Gv/AHxus95QP1UL0e334J3rp5xUM7DnDTXPfXeFD0bRifb9xINgGQEjtvNdHSQjLqQA== X-Received: by 2002:a05:600c:154d:b0:459:d780:3604 with SMTP id 5b1f17b1804b1-459f4f3cf5dmr26410715e9.3.1754652231142; Fri, 08 Aug 2025 04:23:51 -0700 (PDT) Received: from ho-tower-lan.lan ([185.48.76.109]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-45923c34af8sm233482635e9.24.2025.08.08.04.23.49 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 08 Aug 2025 04:23:50 -0700 (PDT) From: James Clark Date: Fri, 08 Aug 2025 12:23:02 +0100 Subject: [PATCH v6 05/12] arm64/boot: Factor out a macro to check SPE version 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: <20250808-james-perf-feat_spe_eft-v6-5-6daf498578c8@linaro.org> References: <20250808-james-perf-feat_spe_eft-v6-0-6daf498578c8@linaro.org> In-Reply-To: <20250808-james-perf-feat_spe_eft-v6-0-6daf498578c8@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 , Anshuman Khandual 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 We check the version of SPE twice, and we'll add one more check in the next commit so factor out a macro to do this. Change the #3 magic number to the actual SPE version define (V1p2) to make it more readable. No functional changes intended. Signed-off-by: James Clark Tested-by: Leo Yan --- arch/arm64/include/asm/el2_setup.h | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/arch/arm64/include/asm/el2_setup.h b/arch/arm64/include/asm/el= 2_setup.h index 46033027510c..3a4ca7f9acfb 100644 --- a/arch/arm64/include/asm/el2_setup.h +++ b/arch/arm64/include/asm/el2_setup.h @@ -103,8 +103,7 @@ csel x2, xzr, x0, eq // all PMU counters from EL1 =20 /* Statistical profiling */ - ubfx x0, x1, #ID_AA64DFR0_EL1_PMSVer_SHIFT, #4 - cbz x0, .Lskip_spe_\@ // Skip if SPE not present + __spe_vers_imp .Lskip_spe_\@, ID_AA64DFR0_EL1_PMSVer_IMP, x0 // Skip if S= PE not present =20 mrs_s x0, SYS_PMBIDR_EL1 // If SPE available at EL2, and x0, x0, #(1 << PMBIDR_EL1_P_SHIFT) @@ -255,6 +254,14 @@ .Lskip_brbe_\@: .endm =20 +/* Branch to skip_label if SPE version is less than given version */ +.macro __spe_vers_imp skip_label, version, tmp + mrs \tmp, id_aa64dfr0_el1 + ubfx \tmp, \tmp, #ID_AA64DFR0_EL1_PMSVer_SHIFT, #4 + cmp \tmp, \version + b.lt \skip_label +.endm + /* Disable any fine grained traps */ .macro __init_el2_fgt mrs x1, id_aa64mmfr0_el1 @@ -263,10 +270,8 @@ =20 mov x0, xzr mov x2, xzr - mrs x1, id_aa64dfr0_el1 - ubfx x1, x1, #ID_AA64DFR0_EL1_PMSVer_SHIFT, #4 - cmp x1, #3 - b.lt .Lskip_spe_fgt_\@ + /* If SPEv1p2 is implemented, */ + __spe_vers_imp .Lskip_spe_fgt_\@, #ID_AA64DFR0_EL1_PMSVer_V1P2, x1 /* Disable PMSNEVFR_EL1 read and write traps */ orr x0, x0, #HDFGRTR_EL2_nPMSNEVFR_EL1_MASK orr x2, x2, #HDFGWTR_EL2_nPMSNEVFR_EL1_MASK --=20 2.34.1 From nobody Tue Feb 10 09:45:02 2026 Received: from mail-wr1-f47.google.com (mail-wr1-f47.google.com [209.85.221.47]) (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 6EA39274FEE for ; Fri, 8 Aug 2025 11:23:54 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.221.47 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1754652236; cv=none; b=mLm9aexjartLI2a81aQfiXcnaS1H4T9UwKFpdD8DtekmSb9BXtKaWZxf2Fdb4YGHAEk72dOybJQKB8hxLU16oFvALO0y8bL1M7/wlUiY69AvsIkTEGnWZylz5Vc8Q+wR1u7ydwgCovrAFu1G3G/Z0xzqsbzOhMTDLpupvPcF1z4= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1754652236; c=relaxed/simple; bh=+jA3Ncis4HX5+y5SYS2TqC8tE0E6O8ym2X0vV73LTxM=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=SMb0bZfrZbqGbcZ+6VSPF3x/RYsj9ed7afzBZE/zK7nsFZioPd1kHpGREf9Ei83pYXDadJ+tVZyou1WRZMc5aj8vriJui7o/FSfiy39o+518YgZ939iLE+cyMgBup3WRAtuWOQxqoJifHpxLL1NocUgqhrC+aymyX5b/PpBcZZg= 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=puixu1OU; arc=none smtp.client-ip=209.85.221.47 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="puixu1OU" Received: by mail-wr1-f47.google.com with SMTP id ffacd0b85a97d-3b79bd3b1f7so1002958f8f.1 for ; Fri, 08 Aug 2025 04:23:54 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1754652233; x=1755257033; 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=XzFFhgGYuB4xjedzO7rx53MXxPvJ8n/ZLwqm/7UkgOI=; b=puixu1OU81PFNutFaE9ziePdV2eCVjqJ6z6sW3SoocDnQKeUwua4qYqdECwHiHRJry /h9QMhHPgX5Ql8fllkeF174rg6WO2ARxmip3vno0CyV/SGH/FugVukGQTOSYRqwNVyqn +g+PixDqbRU3q7BzEuG45gVRR0tAgLuG93/qeT90ZY+h5NpTc0dkKqcaRJTJSJDfNoYj udniaaFjK++mfxK/AA5/CO6/7YvDjmWL9Vu27HyfpSST9nGyzgB8Dk5sHZ2FsYpW1049 nid00XEgWTnQMEa6WT5G9C6ZYPNAC9qKMwnU76z2jw3YHRg4mkevxgHPR3nBW0X15jMb 5e2Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1754652233; x=1755257033; 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=XzFFhgGYuB4xjedzO7rx53MXxPvJ8n/ZLwqm/7UkgOI=; b=YtSxyTZWkpCH9FyZQ2rVfJ1aUWiVW7NW69O5xRTQZduZKhJUTdhpYNrUXqGfkwPZ0P UFVGXkvvX8/ffvwRIa18aViF+L1R9ND4vCWa5ttlHcSHUnTX1xOlrXCYCbzzYUymTRl+ kPrrjJ+SCWMlLNx9ATK6cL/GRTa1iWZCh0/OczBvJUpF8wYa2vqUx0WUJwlb38f6R2vK v6pHTvKwoIz8ZomFO1iL2TKTPnkadpipSYZ6jg/6QRfnwndAIlks0l8e8S/AHoNj+sHB lHmeGrzO8H2z7EEgsKJfhz/HLuSBn9VmbvPPcqEBhlzZI8hzHKblIkKfOqBCM/zd8lj3 judw== X-Forwarded-Encrypted: i=1; AJvYcCVChiA2TrdWFE2zdVqXaTrBnTMh0Jo3heMfzxZIKzYu0jdBJ/08Ehoh7BDjhHxKrF6Xw/XSdSjOly0XN9M=@vger.kernel.org X-Gm-Message-State: AOJu0YyWGxSiLMBwpr0dUADtUf3p1BkVw017V74oDqubg2T6AaoMbB0N 4Jot1EO9IFft8D1TDebJOLKLD1Ov3eaUkIQvYT8HOJxpai7eXpSEyf4P01xBhKYE8Jk= X-Gm-Gg: ASbGncsfRZRU9chTVuTe44rYbmAnuhdihA3/DlW2TH65jIl4J+gxnXgbpUtBA3ObXYy Oq/aH6KUCXBkRKpBDVa3qKhJjycM2kJ+SIAJd1/W0ZBzS9fov5ChKAzLbkZMhEiLlWyTuEifux/ Y+3LaB2awjrQdVsZ3gjQRzwbXEh6XqcT6hm7enK3lZVLxJYJbXGHmHK/6jtuJ5YVrI8CwPKEq+z MomCgW7qYo/kQ8M3UgzWdYDd3Y5aX+MJm/6JaIV2BpwQkQtYe3MziBPYmKXCGwky4pK3DbMzv6X Yg+rseM0fWSmUtMiOepfdodsed0A+QW07SE0Iji5JL6rCykuQ431Ehtcjm9QOjTP8tSJw8dzzv0 c9ZlaneTxtSgClihC3O3FfHDRKZnNuBoKyQNGrArCcg== X-Google-Smtp-Source: AGHT+IFA08gaH/PE8BI7LMp8YziJ1EgstGveIjmcsXTetOJTEOPbmTHS6Iwam90twv6fI5T7D1HpPA== X-Received: by 2002:a5d:64c3:0:b0:3b8:d337:cc33 with SMTP id ffacd0b85a97d-3b900b5026dmr2094550f8f.28.1754652232546; Fri, 08 Aug 2025 04:23:52 -0700 (PDT) Received: from ho-tower-lan.lan ([185.48.76.109]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-45923c34af8sm233482635e9.24.2025.08.08.04.23.51 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 08 Aug 2025 04:23:52 -0700 (PDT) From: James Clark Date: Fri, 08 Aug 2025 12:23:03 +0100 Subject: [PATCH v6 06/12] arm64/boot: Enable EL2 requirements for SPE_FEAT_FDS 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: <20250808-james-perf-feat_spe_eft-v6-6-6daf498578c8@linaro.org> References: <20250808-james-perf-feat_spe_eft-v6-0-6daf498578c8@linaro.org> In-Reply-To: <20250808-james-perf-feat_spe_eft-v6-0-6daf498578c8@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 , Anshuman Khandual 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 data source filtering (optional from Armv8.8) requires that traps to the filter register PMSDSFR be disabled. Document the requirements and disable the traps if the feature is present. Signed-off-by: James Clark Tested-by: Leo Yan --- Documentation/arch/arm64/booting.rst | 11 +++++++++++ arch/arm64/include/asm/el2_setup.h | 11 +++++++++++ 2 files changed, 22 insertions(+) diff --git a/Documentation/arch/arm64/booting.rst b/Documentation/arch/arm6= 4/booting.rst index 2f666a7c303c..e4f953839f71 100644 --- a/Documentation/arch/arm64/booting.rst +++ b/Documentation/arch/arm64/booting.rst @@ -466,6 +466,17 @@ Before jumping into the kernel, the following conditio= ns must be met: - HDFGWTR2_EL2.nPMICFILTR_EL0 (bit 3) must be initialised to 0b1. - HDFGWTR2_EL2.nPMUACR_EL1 (bit 4) must be initialised to 0b1. =20 + For CPUs with SPE data source filtering (FEAT_SPE_FDS): + + - If EL3 is present: + + - MDCR_EL3.EnPMS3 (bit 42) must be initialised to 0b1. + + - If the kernel is entered at EL1 and EL2 is present: + + - HDFGRTR2_EL2.nPMSDSFR_EL1 (bit 19) must be initialised to 0b1. + - HDFGWTR2_EL2.nPMSDSFR_EL1 (bit 19) must be initialised to 0b1. + For CPUs with Memory Copy and Memory Set instructions (FEAT_MOPS): =20 - If the kernel is entered at EL1 and EL2 is present: diff --git a/arch/arm64/include/asm/el2_setup.h b/arch/arm64/include/asm/el= 2_setup.h index 3a4ca7f9acfb..a0361ddcdca4 100644 --- a/arch/arm64/include/asm/el2_setup.h +++ b/arch/arm64/include/asm/el2_setup.h @@ -392,6 +392,17 @@ orr x0, x0, #HDFGRTR2_EL2_nPMICFILTR_EL0 orr x0, x0, #HDFGRTR2_EL2_nPMUACR_EL1 .Lskip_pmuv3p9_\@: + /* If SPE is implemented, */ + __spe_vers_imp .Lskip_spefds_\@, ID_AA64DFR0_EL1_PMSVer_IMP, x1 + /* we can read PMSIDR and */ + mrs_s x1, SYS_PMSIDR_EL1 + and x1, x1, #PMSIDR_EL1_FDS + /* if FEAT_SPE_FDS is implemented, */ + cbz x1, .Lskip_spefds_\@ + /* disable traps to PMSDSFR. */ + orr x0, x0, #HDFGRTR2_EL2_nPMSDSFR_EL1 + +.Lskip_spefds_\@: msr_s SYS_HDFGRTR2_EL2, x0 msr_s SYS_HDFGWTR2_EL2, x0 msr_s SYS_HFGRTR2_EL2, xzr --=20 2.34.1 From nobody Tue Feb 10 09:45:02 2026 Received: from mail-wr1-f53.google.com (mail-wr1-f53.google.com [209.85.221.53]) (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 9FBDE275865 for ; Fri, 8 Aug 2025 11:23:55 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.221.53 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1754652237; cv=none; b=pkogg72ILSGTWT+JvYud6ZAdhHqf1vhE/V3XP3bDq8+kkjfy2/4z2YHSR3DSupS+bUHshfnA2wd5Y+ZtsV0/fF5eWH+pr+1kTk/Er7TVbZ+uvJKyU1CbbzuPbW63C4HO0LP9s8E0tA9OTuytFT+DPxF6XPUTeyfYXuQgeyTYLIE= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1754652237; c=relaxed/simple; bh=+2GYlOZHwCZ0lRFJU17Kz/6XYFxNBVKE33Il+Q5Ltpo=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=CHrDBrc3b0+4B2MHGyyyuNNtruZYBj4rUERtfqeycMsnMbwy7Oet3uzTr5avKvj4Opb2pll3OI0YhAmWXSu2zwvAqzcrEOSppTOzi2tSan2eBeTlo5qU5h8uGlCqcLPz5a1sn+x99f7416sXXI35EshzQpKvnt5UipnOXTpPGIw= 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=e/Gs44vQ; arc=none smtp.client-ip=209.85.221.53 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="e/Gs44vQ" Received: by mail-wr1-f53.google.com with SMTP id ffacd0b85a97d-3b7961cf660so1650515f8f.1 for ; Fri, 08 Aug 2025 04:23:55 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1754652234; x=1755257034; 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=tCkPGBMU9cuxNuxHQvLapYjmFGObKhPk55g8w7OjRxY=; b=e/Gs44vQS6XqDUlpse74/TptHOfjxJxFtj2RcxZmdmXKFiJRK55dsddDwgQiJzhkuT znEsLZFnlXrgSsGF6HEBUWS8/DR1k3y0eA97HLXElduQxWBMS46X/J+D4B9MjmA2lbIH wlr81QJj4nUjy0AKmvHRmK30Fwa471gprd4fZPIYH2MBCHIqUucy/yqoirr7+SZ+EBjF 91dSxhjXI8h2wX6A5g/mqJzYhMleeUidLu9weuDEQ5fJYB8dZeK4IDdIGmM23wjy1a+t P769y3srJpmZU0Met5M6M1YiUU4ZmHSgJXcDeAtNXfErMeulfqOvjsIYCfgBfFNMJ082 FwVw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1754652234; x=1755257034; 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=tCkPGBMU9cuxNuxHQvLapYjmFGObKhPk55g8w7OjRxY=; b=I2FWTdGT2C3/bRqfeA2GuvL++Cn1raFGng/T9CypaMd0oZHOJly7NHqGEvh0fjzCq5 giJQPhBnq5vEpWAA7nUgv+zyrFQNYgK9s0lDoL9yUbPdZc4YiGEs3HdHWOFipuv6xoGy yGlOSWR2zevvCbKE0XRkPc91RqD9tKI73hjhH+7HCGJdY6RRcEiahwNU5yA7Z4xIFliL BH9nJaWp5ZZKiYkhHQgR3blMJ4ZNr+yHXX6Z4PhveE0yk2iOXdjoQJrwf2dPhxBWzsTl RSy2MP9GHWAbYi3EDSjwO1rvpWV5h4WCTvaZVI5mSGvdXv/dShjCj7me2IYgyqDDQiYi ypAw== X-Forwarded-Encrypted: i=1; AJvYcCWRAVfl6VHcCs8QcEWzBADFRN9EEWzUvjjsDp9J/8lagCM69KMIeCycbpP0+bhJeQQeY3RMFnSNeW6uQHs=@vger.kernel.org X-Gm-Message-State: AOJu0Yxb7MdckCCTOlZ75TldBb3vTzCtjbQPk3P6kLXO+FNqy7siO4tR 08fvZLYirRG5j7MdGwDWnu3GjNH48KeB6O9YVqe3D+cDw2+Ztq3WxuQ3qZB3HS8bzzk= X-Gm-Gg: ASbGncukQyUBOEnEdHlQHlFOMyCCd/aDFKieJvNREpKkeBPZZYvvb9U5rEt0kWZ6F/A AdJyffAEyuibwa71tz8b4YUHB2471Dhyzqw9o+uUrfVOIPu1+7ZNLfA82S/ViuP9nnKv/9Kuscr 53zAMPJtS4bnXoKSEWbvvvsZAmenbKrNVRMn1EyF+eQO9NADmkBW5Z4HNW/2+SqCb13Rb5UyyVj W9XJ1h1X5KrMCl0DUX1Aiu8RLbe8pEwpsl/c5ljnQ3UFCvtVV6wEhL+kfD5ZSVDte+tfmD4p/o6 HEjEOBc8ugQO/moyDk6+nBzx85HRpSMFGymCfuFWExz1mHfivvMuhhgtHuln2VBL48/kk4g/TeR GGf0vs/u3T0+bK9h3OWIKXP3vj+aNrNA= X-Google-Smtp-Source: AGHT+IHbD1rxZ+hael7UI+V4nWIH1JBGIhGROdLFUhD8+vK/+XpzNrjCzw2lcwqBQ5oIfEeaFLVqCQ== X-Received: by 2002:a05:6000:288b:b0:3b5:f0aa:b1e5 with SMTP id ffacd0b85a97d-3b900b4dac6mr1921081f8f.19.1754652233967; Fri, 08 Aug 2025 04:23:53 -0700 (PDT) Received: from ho-tower-lan.lan ([185.48.76.109]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-45923c34af8sm233482635e9.24.2025.08.08.04.23.52 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 08 Aug 2025 04:23:53 -0700 (PDT) From: James Clark Date: Fri, 08 Aug 2025 12:23:04 +0100 Subject: [PATCH v6 07/12] KVM: arm64: Add trap configs for PMSDSFR_EL1 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: <20250808-james-perf-feat_spe_eft-v6-7-6daf498578c8@linaro.org> References: <20250808-james-perf-feat_spe_eft-v6-0-6daf498578c8@linaro.org> In-Reply-To: <20250808-james-perf-feat_spe_eft-v6-0-6daf498578c8@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 , Anshuman Khandual 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 data source filtering (SPE_FEAT_FDS) adds a new register PMSDSFR_EL1, add the trap configs for it. PMSNEVFR_EL1 was also missing its VNCR offset so add it along with PMSDSFR_EL1. Signed-off-by: James Clark Tested-by: Leo Yan --- arch/arm64/include/asm/vncr_mapping.h | 2 ++ arch/arm64/kvm/emulate-nested.c | 1 + arch/arm64/kvm/sys_regs.c | 1 + 3 files changed, 4 insertions(+) diff --git a/arch/arm64/include/asm/vncr_mapping.h b/arch/arm64/include/asm= /vncr_mapping.h index f6ec500ad3fa..c2485a862e69 100644 --- a/arch/arm64/include/asm/vncr_mapping.h +++ b/arch/arm64/include/asm/vncr_mapping.h @@ -94,6 +94,8 @@ #define VNCR_PMSICR_EL1 0x838 #define VNCR_PMSIRR_EL1 0x840 #define VNCR_PMSLATFR_EL1 0x848 +#define VNCR_PMSNEVFR_EL1 0x850 +#define VNCR_PMSDSFR_EL1 0x858 #define VNCR_TRFCR_EL1 0x880 #define VNCR_MPAM1_EL1 0x900 #define VNCR_MPAMHCR_EL2 0x930 diff --git a/arch/arm64/kvm/emulate-nested.c b/arch/arm64/kvm/emulate-neste= d.c index 90cb4b7ae0ff..aeaba7813275 100644 --- a/arch/arm64/kvm/emulate-nested.c +++ b/arch/arm64/kvm/emulate-nested.c @@ -1185,6 +1185,7 @@ static const struct encoding_to_trap_config encoding_= to_cgt[] __initconst =3D { SR_TRAP(SYS_PMSIRR_EL1, CGT_MDCR_TPMS), SR_TRAP(SYS_PMSLATFR_EL1, CGT_MDCR_TPMS), SR_TRAP(SYS_PMSNEVFR_EL1, CGT_MDCR_TPMS), + SR_TRAP(SYS_PMSDSFR_EL1, CGT_MDCR_TPMS), SR_TRAP(SYS_TRFCR_EL1, CGT_MDCR_TTRF), SR_TRAP(SYS_TRBBASER_EL1, CGT_MDCR_E2TB), SR_TRAP(SYS_TRBLIMITR_EL1, CGT_MDCR_E2TB), diff --git a/arch/arm64/kvm/sys_regs.c b/arch/arm64/kvm/sys_regs.c index 82ffb3b3b3cf..d1a55cf589b7 100644 --- a/arch/arm64/kvm/sys_regs.c +++ b/arch/arm64/kvm/sys_regs.c @@ -3083,6 +3083,7 @@ static const struct sys_reg_desc sys_reg_descs[] =3D { { SYS_DESC(SYS_PMBLIMITR_EL1), undef_access }, { SYS_DESC(SYS_PMBPTR_EL1), undef_access }, { SYS_DESC(SYS_PMBSR_EL1), undef_access }, + { SYS_DESC(SYS_PMSDSFR_EL1), undef_access }, /* PMBIDR_EL1 is not trapped */ =20 { PMU_SYS_REG(PMINTENSET_EL1), --=20 2.34.1 From nobody Tue Feb 10 09:45:02 2026 Received: from mail-wm1-f54.google.com (mail-wm1-f54.google.com [209.85.128.54]) (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 119C3275B00 for ; Fri, 8 Aug 2025 11:23:56 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.54 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1754652238; cv=none; b=m8DwB/HUXxevqN2ORgsOFZrvP3RKbqHZbHxo60VdPhmhWhpqPLyKnH0O/kJChYgOxwRNpY7CUeVCx4yn2UCQVsNYvEkz8FgGEJhk8LOi6RHAfHOyVSTX00lpb9/yqBCvdYi9VPUB+dKuRnHkP9v8nCiREu7P5IBbxZS0WKgqQ0g= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1754652238; c=relaxed/simple; bh=3yjrpHkX+aMdTK90nxuOJyMh4ajXQ8n+rTYB1GAa/ak=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=iKXCDcGDZtb6pEVYuXBXQqHwdMj3AE8sNhe7MaOWi2pu5ltXzlyzVIX53OU1Yhfst3e8u+Q5uC7HU6RMuak3OO5qMIyJ1zwxsVsL7C9A9+uxGE2BWWjXWbaiaUAD3s8WrtrTKHBYOAS5bzU3I/u82O2SBPOToHTFz2+I2p0gKC8= 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=RaH50ZvG; arc=none smtp.client-ip=209.85.128.54 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="RaH50ZvG" Received: by mail-wm1-f54.google.com with SMTP id 5b1f17b1804b1-459ebb6bbdfso13287615e9.0 for ; Fri, 08 Aug 2025 04:23:56 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1754652235; x=1755257035; 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=45z9IaVf3DvIHNyRK9bNlm2YHb8XHVPseevdKZOW65I=; b=RaH50ZvGPhQ8bMszL2JExGwns8Ohq4uLiS7Fwao37U496oSk0c/4gs2SAbUq/TY86c ux459xL4OGPmGMoDDCArqmhbE+SHf+5SS5RYAgoiY319JSiHokUYptKbbwn+zEhx+zXO 84et9TN4ZeRQA5G9xecY/5qPI2Al1ojBoK6nGGmlV1wwor87U7oLKNFo7xKpVWcbr9SQ RdZ21JDLFeQYw/jxDx815vU4FWNO0kMhFG1lY1uPkyrZJWpgzWhuUyWVLAWrBnCULUro f7PskndpE27012BDb29GDh0Xn39gqPJoFjp4tJCnzKtiHJ4cj6sOtRVUIYRotOqInBSn 3r/w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1754652235; x=1755257035; 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=45z9IaVf3DvIHNyRK9bNlm2YHb8XHVPseevdKZOW65I=; b=WCwIFRbXhiK+MVV3GJpH9eR7eWV2LldDVsd3U7oLIgas8wLatmlzuo5qQQ8V8THfaw X2wxxTRJZjJwrAPZQFkRr8qCkr8xgLFXsAtjCJq7rwrOKuQLRV9r6FvlV8Gzcu2AUScn 7oWi+8dCFxTNUMSADOCCO8R+JznV56+raLfp7MaCP7Id38udBOI7c3vvIkhMQQJeY39Z z50k8hDtIlMJnjQR49UCdu2Ydc7gYDNUt0nJ1DQMP+8+QkSMDjIZjQsPkZCt9Q4Swyw1 eDc4P/Xl7tzMsEBAQRWUFs+5jp4QnrSwwU1pPNSaaC1vbxItcdR0vHXwk714aSiC04DL zMaQ== X-Forwarded-Encrypted: i=1; AJvYcCXImuE6aKthR039F9fioCzakH57HyoRpLVaad1oQzkwPGUwNBhPmgkEBIkOvxKwF8tMPiD4ke4cXGOBE+U=@vger.kernel.org X-Gm-Message-State: AOJu0YyRo/8EeaX9BU5LGRvfcVmSeZn/bCps6eoGnO3+6hM011JMyqQs Mxs1Dxc1RgdKE9UmfsvuJCcUCVfV/GM0UswVf0OTZrVv2yIylBV29FfmJj7+hcuXamM= X-Gm-Gg: ASbGncuCZeHPY8XWrR8O7h/ZWCJv7ANpPkXpA/tp3LsSQsq41qmpu5iG0FZ7+28kQL0 f0z9j9nbkIwPfLw6Cvr6qwc8zIxmlohpsPjfOYXIPNA6Pf8pxda+RYY3oVuaWjyKlVhZ40+W2/5 J370ARSaboszk+hxXvx9h3LRe5oPVQ9FH+8uTKK70bEDnYZcknAZ1TONLgbRBIATagheneBlOsl VzdMJ1q+IOd01bcvOiZKYCJyLjbhfhv50fatqtbpHEXZxV6HwTStMtzWOBf1KVWRHMN5TagTAHD Dk45tIFycDRWhP1eGTCXF1W16QB/Zi8rvs5b0J0ghl1GFx87ihLM6I53MOlYuuKYO7ogIyYIM6K wsCCiL2R4klHtDsZQoCX9mVKuBpCmR0Y= X-Google-Smtp-Source: AGHT+IHOQ18gbVsDEVyKCfZAIEJklPYVqKw1aZ8vUXtA3WE+OW7IGcXWNxJyWSMYhUVtrh63ytt5Fg== X-Received: by 2002:a05:600c:198c:b0:456:13b6:4b18 with SMTP id 5b1f17b1804b1-459f4fc3a9emr26503515e9.31.1754652235388; Fri, 08 Aug 2025 04:23:55 -0700 (PDT) Received: from ho-tower-lan.lan ([185.48.76.109]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-45923c34af8sm233482635e9.24.2025.08.08.04.23.54 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 08 Aug 2025 04:23:55 -0700 (PDT) From: James Clark Date: Fri, 08 Aug 2025 12:23:05 +0100 Subject: [PATCH v6 08/12] perf: Add perf_event_attr::config4 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: <20250808-james-perf-feat_spe_eft-v6-8-6daf498578c8@linaro.org> References: <20250808-james-perf-feat_spe_eft-v6-0-6daf498578c8@linaro.org> In-Reply-To: <20250808-james-perf-feat_spe_eft-v6-0-6daf498578c8@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 , Anshuman Khandual 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 Arm FEAT_SPE_FDS adds the ability to filter on the data source of a packet using another 64-bits of event filtering control. As the existing perf_event_attr::configN fields are all used up for SPE PMU, an additional field is needed. Add a new 'config4' field. Reviewed-by: Leo Yan Tested-by: Leo Yan Reviewed-by: Ian Rogers Signed-off-by: James Clark --- include/uapi/linux/perf_event.h | 2 ++ 1 file changed, 2 insertions(+) diff --git a/include/uapi/linux/perf_event.h b/include/uapi/linux/perf_even= t.h index 78a362b80027..0d0ed85ad8cb 100644 --- a/include/uapi/linux/perf_event.h +++ b/include/uapi/linux/perf_event.h @@ -382,6 +382,7 @@ enum perf_event_read_format { #define PERF_ATTR_SIZE_VER6 120 /* Add: aux_sample_size */ #define PERF_ATTR_SIZE_VER7 128 /* Add: sig_data */ #define PERF_ATTR_SIZE_VER8 136 /* Add: config3 */ +#define PERF_ATTR_SIZE_VER9 144 /* add: config4 */ =20 /* * 'struct perf_event_attr' contains various attributes that define @@ -543,6 +544,7 @@ struct perf_event_attr { __u64 sig_data; =20 __u64 config3; /* extension of config2 */ + __u64 config4; /* extension of config3 */ }; =20 /* --=20 2.34.1 From nobody Tue Feb 10 09:45:02 2026 Received: from mail-wm1-f53.google.com (mail-wm1-f53.google.com [209.85.128.53]) (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 86913276038 for ; Fri, 8 Aug 2025 11:23:58 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.53 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1754652242; cv=none; b=QvJtANTJKv3tbXZM+KoYgTD0R/hvcrR+BzeN5kEDbQKAIUPhmmCL6lvamR2NUptm1rwo30SIqKJ5tR2EVbguT6hccVJXy1pX8WvYp0XJmln/bb5Xq4kNlWpG4WpBtm5d5TKdaEIZnyIpmRbjrSrF3sd3zA7TVHY/jBqQVVlEYd8= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1754652242; c=relaxed/simple; bh=d51etX9Wtlt64/Vo/esdCKX1y9gVFH3rYLjiUdWOlVs=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=HgvFwd3wngusx3c1a+WyEiKQUBlsx+CDyBHUMYYBxHDyQ8POkRVilqBl75yGX/KVc2PI+iFWRRVPjsTAVukDKSk06Rr0qcAmraGZJk0vw4U4Igq6QNzBVq9D1AQVaYuLDAieIEZHlp0PzjogquZFuBY2/Ok6a0Simt7AIrFz3IY= 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=jj6g5t8v; arc=none smtp.client-ip=209.85.128.53 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="jj6g5t8v" Received: by mail-wm1-f53.google.com with SMTP id 5b1f17b1804b1-455b00339c8so12893365e9.3 for ; Fri, 08 Aug 2025 04:23:58 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1754652237; x=1755257037; 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=P3kTEULZc8sJ7phkXJvTPn2PvqxIKdhSpNCE5Vha7IE=; b=jj6g5t8vWQRhb9y/CDxG9qtD2+rEDGFtaJjVJtaf+iMEUh/8gCgBMeSNak3eONjmAb eg4IZFj8DSRp3yIxxzwlLko6hV7ecWscvxWa/fJtP0GtKOuHi6G8MkNBks6dCCme/L53 IMZWGgz9Fsp50I/WsIlOLExF7QZ31gY/q0Lk9blwuazaLLK87E+prvjgv0xAyA+scRtQ nAFkUF917208xjt9+JHQ23LJiYH1ewVeVQCrvgqoimKdBeu74bo7dbW0hAawqrbrRPrQ X8TDwqtJK77hZF7sYQSlC6/qSjXVGjRKXwRN1ZQaIqkKENX6xsgBmqQXxDBieFWzUfn8 EXUA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1754652237; x=1755257037; 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=P3kTEULZc8sJ7phkXJvTPn2PvqxIKdhSpNCE5Vha7IE=; b=Jmt9gp41Q1AixtiZcvHetB8u9cHp4bPhxOlr8wvtO7M93p+NXrMZeM5j8Kb2BYKtPl oadf8zE4e/G9SlfD8cH1VEiXxUvuLGu02tirrUV9PVG7vbCbhCxNuuHiZEh2rSjVW5Ak G0JAJkKpZ8r4O94x13Ur/52ENfWmNbE9lUOkKG46Q8t9ZE9Wa3aDtfSNiVnak8huOO8s sAK52nDVLxERsjS9o1F/dn+A6ULV9Lwpu7iUedus0NeZPr9sYHu7y+8t6/+67XNTzoXE Fitp8XNNVMtQ9noxW8NXgIXW1xt8lyQcSM9qdO77/joZPcBEFZ99D/j/AzE156QYD9Og oHGw== X-Forwarded-Encrypted: i=1; AJvYcCWGQ4gf5sdhoHr9winqkMucpO2C9onKvq0ImC1lbfaoTU28L/rI64Dd1C+/BCKzME6xarkzotGsuWJcgPY=@vger.kernel.org X-Gm-Message-State: AOJu0Yy3QsJrADro6gI+4FKkkCTRy098b7nmZTuOVSjqCFoGAl2PdVNg HgQnbUNS9WOVpHIFNEvwgx0cTJDtAEmPz0qfpyfS4DsZ5jBr9eZpauHbDDgDJzx5o+M= X-Gm-Gg: ASbGncsOlPjxg9wVVLeBpwC/rohdolDOE1scbGMAyUivNrhiSxxtcYknR84auwpAKC3 gGeU9XHuDhQkfh5GXO5Zt7QI8cLDgKHBHNhQkNRaVFwLDTtQpB4xhZ5hZstLfNLXVxdh0IxwDzs AtIwr5MjdPVlPHpuTIwdbjKPc36KPDJS15AluXNTXfzZOlX25J8gK1k/wuRumoxm+NCPHCm2Oas 8HQ3hYoFoblLDiYzTQ7/ZQ1oH9FSNZtZs+NMCVqhCWW7oF/RH1l9w/KYTwmFkmoqWzOf86kvdfi lrYud8HOOxvCRUHiU82S8+0OHU06AQkdZsk/j8YwdvV6VEFLrQOtnWvUeSFywhkYoriNGOmeLXL MiMFcsj4goQjMzXechS9y4Jo8yKhIYc8g+hyaJXQuFQ== X-Google-Smtp-Source: AGHT+IHGDlpxTqvU8x6CY6HSrShTz3PSFbXeB0d760uYkAX/1NVAzKqdZtpMjiV1FNq3jgKsDT7ssg== X-Received: by 2002:a05:600c:468d:b0:456:fdd:6030 with SMTP id 5b1f17b1804b1-459f4f98174mr23233005e9.19.1754652236850; Fri, 08 Aug 2025 04:23:56 -0700 (PDT) Received: from ho-tower-lan.lan ([185.48.76.109]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-45923c34af8sm233482635e9.24.2025.08.08.04.23.55 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 08 Aug 2025 04:23:56 -0700 (PDT) From: James Clark Date: Fri, 08 Aug 2025 12:23:06 +0100 Subject: [PATCH v6 09/12] 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: <20250808-james-perf-feat_spe_eft-v6-9-6daf498578c8@linaro.org> References: <20250808-james-perf-feat_spe_eft-v6-0-6daf498578c8@linaro.org> In-Reply-To: <20250808-james-perf-feat_spe_eft-v6-0-6daf498578c8@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 , Anshuman Khandual 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 clearing bits 0 and 3 only includes packets from data sources 0 OR 3. Invert the filter given by userspace so that the default value of 0 is equivalent to including all values (no filtering). This allows us to skip adding a new format bit to enable filtering and still support excluding all data sources which would have been a filter value of 0 if not for the inversion. Signed-off-by: James Clark Tested-by: Leo Yan --- drivers/perf/arm_spe_pmu.c | 37 +++++++++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) diff --git a/drivers/perf/arm_spe_pmu.c b/drivers/perf/arm_spe_pmu.c index 591f72fa0327..e5b36ab90786 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 @@ -251,6 +252,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_inv_data_src_filter_CFG config4 /* inverse of PMSDSFR= _EL1 */ +#define ATTR_CFG_FLD_inv_data_src_filter_LO 0 +#define ATTR_CFG_FLD_inv_data_src_filter_HI 63 + GEN_PMU_FORMAT_ATTR(ts_enable); GEN_PMU_FORMAT_ATTR(pa_enable); GEN_PMU_FORMAT_ATTR(pct_enable); @@ -267,6 +272,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(inv_data_src_filter); GEN_PMU_FORMAT_ATTR(min_latency); GEN_PMU_FORMAT_ATTR(discard); =20 @@ -287,6 +293,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_inv_data_src_filter.attr, &format_attr_min_latency.attr, &format_attr_discard.attr, NULL, @@ -305,6 +312,10 @@ static umode_t arm_spe_pmu_format_attr_is_visible(stru= ct 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_inv_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 || @@ -429,6 +440,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, inv_data_src_filter)) + reg |=3D PMSFCR_EL1_FDS; + if (ATTR_CFG_GET_FLD(attr, min_latency)) reg |=3D PMSFCR_EL1_FL; =20 @@ -453,6 +467,17 @@ 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; + + /* + * Data src filter is inverted so that the default value of 0 is + * equivalent to no filtering. + */ + return ~ATTR_CFG_GET_FLD(attr, inv_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); @@ -790,6 +815,10 @@ static int arm_spe_pmu_event_init(struct perf_event *e= vent) if (arm_spe_event_to_pmsnevfr(event) & spe_pmu->pmsevfr_res0) return -EOPNOTSUPP; =20 + if (arm_spe_event_to_pmsdsfr(event) !=3D U64_MAX && + !(spe_pmu->features & SPE_PMU_FEAT_FDS)) + return -EOPNOTSUPP; + if (attr->exclude_idle) return -EOPNOTSUPP; =20 @@ -865,6 +894,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 @@ -1124,6 +1158,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 From nobody Tue Feb 10 09:45:02 2026 Received: from mail-wm1-f53.google.com (mail-wm1-f53.google.com [209.85.128.53]) (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 E279727702B for ; Fri, 8 Aug 2025 11:23:59 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.53 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1754652241; cv=none; b=U2uKhmaVN3OXT1jwKttf/cUSDOrZ6sGGSP0Wq4sou6oxbJ/rVicd6Khx1bnB/Xs6tvTbgzmPaxyxCJAFGHRpoD1T8w2rcX40oxy7PmfDMbozTnNNc5soy7jHYe9K/s8bjFIlFcD8E0Xw5NJaVnYiptZPwc+AAxn0GiPqiE8L2vY= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1754652241; c=relaxed/simple; bh=b/ttJae4xiEHONrSB61gWYPCVcnCnqIpQyNKL5V/Pqw=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=s7izez6rPwNBYtkSPrK5y6oF58x6W3irnfeqHd3me3AJQugoI/A/pGOQVwRckVzK7zaz7UWQnFX8D5QKXx2cieGuG/JyoSHkKJk+ICwyNzzu/1GxrxpKtc8VVH35P6KaGIylBLJWhvEkc7QupmQiFS+LDq0isoai2ywkIZPUSqM= 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=JBtHhOof; arc=none smtp.client-ip=209.85.128.53 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="JBtHhOof" Received: by mail-wm1-f53.google.com with SMTP id 5b1f17b1804b1-459e210bd2dso10268635e9.1 for ; Fri, 08 Aug 2025 04:23:59 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1754652238; x=1755257038; 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=YGtpCZfgBTuGsyBPIkbeq53HmntuKbontBvcg3TVESk=; b=JBtHhOofcVjoTYV6PD3M0k9FrHm+wDXRzf2YLVUKHCz72i8QHvy3x2brGh94EoosHX 1MAAYLVmUMm4lGJQPuB/4rE8av8lhqLr6v9F6jmUfrCSixjoQl3nHw+YuC6HCr9S52HR pwHWh1zXw3CV0B1t2xjyNsMzZRsROUmbta0V2tkxrOHG1P8uhJ7ux7R5jnT9gFNuiSdG 93wIlJnYgmlcaOHSbmm+KpjJWwRNxA3+2i4PYG/vG9hyZLzAokZH9IV8IfeHWlXm7hva a+Ug5R/uB+GaThtRxDk12Gtjpkpg+HXWAsSqpXGOa2ptWPzSoLFSplh/6ZqoQfSf6497 nhxQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1754652238; x=1755257038; 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=YGtpCZfgBTuGsyBPIkbeq53HmntuKbontBvcg3TVESk=; b=m4ZXyOmOb1KXIOl5sTRKRPK89OJWLQssRbNmuSDackyKFheAx0fJkrwzvObMaUwYeo DpNEc12lEXEYQUnDELiP2wYEHqeljAU1t+4wuy4DzqnRSzQn//IKlKflMlzOu+FWcf7m SsGXCGwW5JD3/84t3K7N9spIaGiTO+ENNo6rPyXMkNJPIefNgIO/nDJ+JkkasgS6CyKi 9JzuqjOf6YC9GzUrds24quPvHp2Y33qLBkMVoAg8/W93ezWtPqoTL+DI23PzVZEyMMyP g/3ripIlsPQZY2FhESAn33Hd8qGF2U5v10DgI2GY+8Cn/z2Mc7CxairESK4wzzeD3dda vfxA== X-Forwarded-Encrypted: i=1; AJvYcCU87mdIepYUOZQ4O9HbA4MjcQ1+a9YNy6Wmo5MDdkfaAfdLppllGxCmROFAS7Vlkxoyr/fUpGWASYyh+KU=@vger.kernel.org X-Gm-Message-State: AOJu0YyoPruPoKVupZ3Kj3SqommQZ/ANIY5Bit0Bi6L7T4GR18pMqt5e oK4AEgGlkKcku9c7bWOKjkz3mv5kmpmw7L9FtMc4SGA6rm5Lu4EfRLbwrKsdrworMWs= X-Gm-Gg: ASbGncsGgmdNmYEALM0oXefgZm3xNZOovLkB8bSP71X0oWtmN21fsOrEKeyllWohkzV UHQdCKTKWBYYyqNDwpu6Nu0JoIjqJF4bEPZfEJIE7e/urtFTJtydaYHJUxDYsKQeD7VSNboA057 ZMWRKxBZkQkas6obXy/wMvLZvWcMICh2XhZJ23TuJpVxTAn6pxgwxGAM3qqS0C9vrvs4TxHDwWy IvmoKxIDxF5AHvXfHUcxb/C5VVv5MUZcNTZgYRg6jDxR11jSHkgbHUnKrhitqYCymWTUpUq+5Lb +XPhy57TvBdSC0x/2EewW0rnUCmeF+vroupOwuqwpgsjZ5aeHa/24Zc8LlerkD0kZ0hB6YmptyV qM0LLEQqg0/o5C5bsFuKYXAtm5Tj9CZk= X-Google-Smtp-Source: AGHT+IGoaBQKmBj6KMNMQL0VdWvV/9kYUe2OiKjmu5rnVVRKChL318TYjODlxCnVcHM6lZ386h3kaQ== X-Received: by 2002:a05:6000:4383:b0:3b6:d0d:79c1 with SMTP id ffacd0b85a97d-3b8f97c49afmr6128407f8f.10.1754652238270; Fri, 08 Aug 2025 04:23:58 -0700 (PDT) Received: from ho-tower-lan.lan ([185.48.76.109]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-45923c34af8sm233482635e9.24.2025.08.08.04.23.57 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 08 Aug 2025 04:23:57 -0700 (PDT) From: James Clark Date: Fri, 08 Aug 2025 12:23:07 +0100 Subject: [PATCH v6 10/12] tools headers UAPI: Sync linux/perf_event.h with the kernel sources 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: <20250808-james-perf-feat_spe_eft-v6-10-6daf498578c8@linaro.org> References: <20250808-james-perf-feat_spe_eft-v6-0-6daf498578c8@linaro.org> In-Reply-To: <20250808-james-perf-feat_spe_eft-v6-0-6daf498578c8@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 , Anshuman Khandual 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 To pickup config4 changes. Tested-by: Leo Yan Reviewed-by: Ian Rogers Signed-off-by: James Clark --- tools/include/uapi/linux/perf_event.h | 2 ++ 1 file changed, 2 insertions(+) diff --git a/tools/include/uapi/linux/perf_event.h b/tools/include/uapi/lin= ux/perf_event.h index 78a362b80027..0d0ed85ad8cb 100644 --- a/tools/include/uapi/linux/perf_event.h +++ b/tools/include/uapi/linux/perf_event.h @@ -382,6 +382,7 @@ enum perf_event_read_format { #define PERF_ATTR_SIZE_VER6 120 /* Add: aux_sample_size */ #define PERF_ATTR_SIZE_VER7 128 /* Add: sig_data */ #define PERF_ATTR_SIZE_VER8 136 /* Add: config3 */ +#define PERF_ATTR_SIZE_VER9 144 /* add: config4 */ =20 /* * 'struct perf_event_attr' contains various attributes that define @@ -543,6 +544,7 @@ struct perf_event_attr { __u64 sig_data; =20 __u64 config3; /* extension of config2 */ + __u64 config4; /* extension of config3 */ }; =20 /* --=20 2.34.1 From nobody Tue Feb 10 09:45:02 2026 Received: from mail-wr1-f53.google.com (mail-wr1-f53.google.com [209.85.221.53]) (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 6FA7727781D for ; Fri, 8 Aug 2025 11:24:01 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.221.53 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1754652245; cv=none; b=JyPV4ZLo4obzKVf3P+8Gw+AKBjeFx9CrjfQXQDTQLbmKdsZ7Q0hxSPACK9SFe0VTJjGI+gr4aXAr0qoQ0d/MRNubW2cUDOEnboPB8AfWTOWdnkBuoCfeRZG/N0MsP3N9gwrNYnao9+X/xzNlUGl01z0wRSRm7Y9aiHiiL5ryCBo= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1754652245; c=relaxed/simple; bh=CNBe14pNLnXU+RaS/M5L+smgEMoBVwqw6DTZL4A5ZNc=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=VdK8w4zeyeuW3C85yWFanxioIEzZ0W3IMIlc+LEYXmccbTllqpT1gPZvSGhXQfNwO3FWUh8uqZGCe5YVXAAmZ55MZ3YHOeZpDprWRkcJbsnNsj5NklADHjt5YaEOsbDz51Aq9E1r64YPc3eqJxNOhLAJXlEEQ1LlxzzBYagEi4I= 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=q59ner4W; arc=none smtp.client-ip=209.85.221.53 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="q59ner4W" Received: by mail-wr1-f53.google.com with SMTP id ffacd0b85a97d-3b786421e36so1046993f8f.3 for ; Fri, 08 Aug 2025 04:24:01 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1754652240; x=1755257040; 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=7XfWTbVgLd+JOqYthg70wtq8ZILm6OycONzgKD9jOeg=; b=q59ner4WLsFIZJR8FBIanh5+OjOXnlt8JLAmm2SOhkY5dB3fqhDs1WWyPy0wzB/pQL 8r6mVF1ySjFwF1pgjziNUnldp3q/28gtlgT6g0aNQu1W9asbIbeO9pfGpBYGXgx8W8Ka 3/0jl/vn3L90A7qbhgfw48d7SIePaWHPBYqWkUtO5QtoR+/MGINrN8KQNf3xgIsQJRFS 1dWf1Ss8IpK5i4qbWfkvxJ2GnAWOIONPjFT/VXGJrufgOOrdhcULtLAnOXkHeItJtHGr d37bdGbnKAeE9SzT831m4+GM9wDLhyq1R/CUDRsM8kD2iFY3tx3mmihh6CR88p079Qxm GCiw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1754652240; x=1755257040; 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=7XfWTbVgLd+JOqYthg70wtq8ZILm6OycONzgKD9jOeg=; b=WZ/vTaveYQNy9K8kT2S3aW5aw925dZdTHD0e4yfLgiqEKrZp2+BLZQVUuLcEnMwzJP EKkmRh4KeeI9WiJgSdp/HJ7OA8I3VAlLMICGtIuqAB8o1BmwX8/kVNQW1iUv0YHTykP0 dQo82qGBJ2ESEWfONkscVKvmbTiGR0GHR2XBM2GfapDxprYio8I+M0S5E0i/5WvdNOHh 3JSS/GDpEB4lozhjd9pNZCFoH2gneZFgXY47Efb+TSFmVP3Y6g6XxVD4F0AK68gQo7+5 t9Rl79TsprsE/KMoIDPVVoCjYNgl1k99Hx9pqlJfGZmO4J+ID2tAgYGhVSceu3Sm89i1 zJEQ== X-Forwarded-Encrypted: i=1; AJvYcCWwhN7i3SDEIKM0TEH7CtZNVgsTGAXPXh4W8Ujdge+a00TYb3rHYzPQDRqR3z0fIouayMdvKl0dLxW82Xs=@vger.kernel.org X-Gm-Message-State: AOJu0YzjAbzzZU1+HhX55u/lHnIxbyQ5fjzvksa2quvhXytZtlqM1bz+ jATNeiJoHjhuI8I+59TRYQPtnUtGD0oe+BCDLv+AUkTcDRZnz9MnnEm8IOcH3hB5ibU= X-Gm-Gg: ASbGnctNyjCJJZYVgeqDi1TbgMUabmGbOlflnVWhGEKks+hrj8hsBpya+1VfUjsreBF WxMLyCQsbFkQFhomqLl6ieKKKJEg4pm+2h7IG3EFHXhla1nwQtxWgfJMwI6xWl9m72apsz3p5kB omYavcfJf/IEyBs3vtFi5n8GcALjFWswAvZiKDeq++kFCfQiQXGxB7OfYfeg7hceyKEy07PVUpf OspXJaMGABPt7X+nobM6Vc5mxdNXbihHtezEq6J08yzOMt7r8asgNERG1MG/WCTwGIQ3k+QJFyh pLVxbj0W7vwLfCdU/j/eQ8GW741ORK/J9PQa1U3mSMx1J7SJMsH6ORc9cQMEGzkSLmbVU5UPj8v jY+oXDtqU4JW+ByYsP1+aEqdDII2Octs= X-Google-Smtp-Source: AGHT+IGCueR4XsLqFJZvSYTsaohegfumGwRIqixWP89UFLd+1Fro5zFiBhtlyZeCuLb75QBbufFgyA== X-Received: by 2002:a05:6000:240b:b0:3b8:d360:336f with SMTP id ffacd0b85a97d-3b900b4d2d7mr2237756f8f.28.1754652239740; Fri, 08 Aug 2025 04:23:59 -0700 (PDT) Received: from ho-tower-lan.lan ([185.48.76.109]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-45923c34af8sm233482635e9.24.2025.08.08.04.23.58 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 08 Aug 2025 04:23:59 -0700 (PDT) From: James Clark Date: Fri, 08 Aug 2025 12:23:08 +0100 Subject: [PATCH v6 11/12] perf tools: Add support for perf_event_attr::config4 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: <20250808-james-perf-feat_spe_eft-v6-11-6daf498578c8@linaro.org> References: <20250808-james-perf-feat_spe_eft-v6-0-6daf498578c8@linaro.org> In-Reply-To: <20250808-james-perf-feat_spe_eft-v6-0-6daf498578c8@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 , Anshuman Khandual 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 perf_event_attr has gained a new field, config4, so add support for it extending the existing configN support. Reviewed-by: Leo Yan Reviewed-by: Ian Rogers Tested-by: Leo Yan Signed-off-by: James Clark --- tools/perf/tests/parse-events.c | 14 +++++++++++++- tools/perf/util/parse-events.c | 11 +++++++++++ tools/perf/util/parse-events.h | 1 + tools/perf/util/parse-events.l | 1 + tools/perf/util/pmu.c | 8 ++++++++ tools/perf/util/pmu.h | 1 + 6 files changed, 35 insertions(+), 1 deletion(-) diff --git a/tools/perf/tests/parse-events.c b/tools/perf/tests/parse-event= s.c index bb8004397650..342ed896b703 100644 --- a/tools/perf/tests/parse-events.c +++ b/tools/perf/tests/parse-events.c @@ -615,6 +615,8 @@ static int test__checkevent_pmu(struct evlist *evlist) TEST_ASSERT_VAL("wrong config1", 1 =3D=3D evsel->core.attr.config1); TEST_ASSERT_VAL("wrong config2", 3 =3D=3D evsel->core.attr.config2); TEST_ASSERT_VAL("wrong config3", 0 =3D=3D evsel->core.attr.config3); + TEST_ASSERT_VAL("wrong config4", 0 =3D=3D evsel->core.attr.config4); + /* * The period value gets configured within evlist__config, * while this test executes only parse events method. @@ -637,6 +639,7 @@ static int test__checkevent_list(struct evlist *evlist) TEST_ASSERT_VAL("wrong config1", 0 =3D=3D evsel->core.attr.config1); TEST_ASSERT_VAL("wrong config2", 0 =3D=3D evsel->core.attr.config2); TEST_ASSERT_VAL("wrong config3", 0 =3D=3D evsel->core.attr.config3); + TEST_ASSERT_VAL("wrong config4", 0 =3D=3D evsel->core.attr.config4); TEST_ASSERT_VAL("wrong exclude_user", !evsel->core.attr.exclude_user); TEST_ASSERT_VAL("wrong exclude_kernel", !evsel->core.attr.exclude_kernel= ); TEST_ASSERT_VAL("wrong exclude_hv", !evsel->core.attr.exclude_hv); @@ -813,6 +816,15 @@ static int test__checkterms_simple(struct parse_events= _terms *terms) TEST_ASSERT_VAL("wrong val", term->val.num =3D=3D 4); TEST_ASSERT_VAL("wrong config", !strcmp(term->config, "config3")); =20 + /* config4=3D5 */ + term =3D list_entry(term->list.next, struct parse_events_term, list); + TEST_ASSERT_VAL("wrong type term", + term->type_term =3D=3D PARSE_EVENTS__TERM_TYPE_CONFIG4); + TEST_ASSERT_VAL("wrong type val", + term->type_val =3D=3D PARSE_EVENTS__TERM_TYPE_NUM); + TEST_ASSERT_VAL("wrong val", term->val.num =3D=3D 5); + TEST_ASSERT_VAL("wrong config", !strcmp(term->config, "config4")); + /* umask=3D1*/ term =3D list_entry(term->list.next, struct parse_events_term, list); TEST_ASSERT_VAL("wrong type term", @@ -2451,7 +2463,7 @@ struct terms_test { =20 static const struct terms_test test__terms[] =3D { [0] =3D { - .str =3D "config=3D10,config1,config2=3D3,config3=3D4,umask=3D1,read,r= 0xead", + .str =3D "config=3D10,config1,config2=3D3,config3=3D4,config4=3D5,umas= k=3D1,read,r0xead", .check =3D test__checkterms_simple, }, }; diff --git a/tools/perf/util/parse-events.c b/tools/perf/util/parse-events.c index 8282ddf68b98..5f0b4a3c3dda 100644 --- a/tools/perf/util/parse-events.c +++ b/tools/perf/util/parse-events.c @@ -247,6 +247,8 @@ __add_event(struct list_head *list, int *idx, PERF_PMU_FORMAT_VALUE_CONFIG2, "config2"); perf_pmu__warn_invalid_config(pmu, attr->config3, name, PERF_PMU_FORMAT_VALUE_CONFIG3, "config3"); + perf_pmu__warn_invalid_config(pmu, attr->config4, name, + PERF_PMU_FORMAT_VALUE_CONFIG4, "config4"); } } /* @@ -811,6 +813,7 @@ const char *parse_events__term_type_str(enum parse_even= ts__term_type term_type) [PARSE_EVENTS__TERM_TYPE_CONFIG1] =3D "config1", [PARSE_EVENTS__TERM_TYPE_CONFIG2] =3D "config2", [PARSE_EVENTS__TERM_TYPE_CONFIG3] =3D "config3", + [PARSE_EVENTS__TERM_TYPE_CONFIG4] =3D "config4", [PARSE_EVENTS__TERM_TYPE_NAME] =3D "name", [PARSE_EVENTS__TERM_TYPE_SAMPLE_PERIOD] =3D "period", [PARSE_EVENTS__TERM_TYPE_SAMPLE_FREQ] =3D "freq", @@ -859,6 +862,7 @@ config_term_avail(enum parse_events__term_type term_typ= e, struct parse_events_er case PARSE_EVENTS__TERM_TYPE_CONFIG1: case PARSE_EVENTS__TERM_TYPE_CONFIG2: case PARSE_EVENTS__TERM_TYPE_CONFIG3: + case PARSE_EVENTS__TERM_TYPE_CONFIG4: case PARSE_EVENTS__TERM_TYPE_NAME: case PARSE_EVENTS__TERM_TYPE_METRIC_ID: case PARSE_EVENTS__TERM_TYPE_SAMPLE_PERIOD: @@ -928,6 +932,10 @@ do { \ CHECK_TYPE_VAL(NUM); attr->config3 =3D term->val.num; break; + case PARSE_EVENTS__TERM_TYPE_CONFIG4: + CHECK_TYPE_VAL(NUM); + attr->config4 =3D term->val.num; + break; case PARSE_EVENTS__TERM_TYPE_SAMPLE_PERIOD: CHECK_TYPE_VAL(NUM); break; @@ -1153,6 +1161,7 @@ static int config_term_tracepoint(struct perf_event_a= ttr *attr, case PARSE_EVENTS__TERM_TYPE_CONFIG1: case PARSE_EVENTS__TERM_TYPE_CONFIG2: case PARSE_EVENTS__TERM_TYPE_CONFIG3: + case PARSE_EVENTS__TERM_TYPE_CONFIG4: case PARSE_EVENTS__TERM_TYPE_NAME: case PARSE_EVENTS__TERM_TYPE_SAMPLE_PERIOD: case PARSE_EVENTS__TERM_TYPE_SAMPLE_FREQ: @@ -1294,6 +1303,7 @@ do { \ case PARSE_EVENTS__TERM_TYPE_CONFIG1: case PARSE_EVENTS__TERM_TYPE_CONFIG2: case PARSE_EVENTS__TERM_TYPE_CONFIG3: + case PARSE_EVENTS__TERM_TYPE_CONFIG4: case PARSE_EVENTS__TERM_TYPE_NAME: case PARSE_EVENTS__TERM_TYPE_METRIC_ID: case PARSE_EVENTS__TERM_TYPE_RAW: @@ -1332,6 +1342,7 @@ static int get_config_chgs(struct perf_pmu *pmu, stru= ct parse_events_terms *head case PARSE_EVENTS__TERM_TYPE_CONFIG1: case PARSE_EVENTS__TERM_TYPE_CONFIG2: case PARSE_EVENTS__TERM_TYPE_CONFIG3: + case PARSE_EVENTS__TERM_TYPE_CONFIG4: case PARSE_EVENTS__TERM_TYPE_NAME: case PARSE_EVENTS__TERM_TYPE_SAMPLE_PERIOD: case PARSE_EVENTS__TERM_TYPE_SAMPLE_FREQ: diff --git a/tools/perf/util/parse-events.h b/tools/perf/util/parse-events.h index 62dc7202e3ba..9e482cfdaaf9 100644 --- a/tools/perf/util/parse-events.h +++ b/tools/perf/util/parse-events.h @@ -60,6 +60,7 @@ enum parse_events__term_type { PARSE_EVENTS__TERM_TYPE_CONFIG1, PARSE_EVENTS__TERM_TYPE_CONFIG2, PARSE_EVENTS__TERM_TYPE_CONFIG3, + PARSE_EVENTS__TERM_TYPE_CONFIG4, PARSE_EVENTS__TERM_TYPE_NAME, PARSE_EVENTS__TERM_TYPE_SAMPLE_PERIOD, PARSE_EVENTS__TERM_TYPE_SAMPLE_FREQ, diff --git a/tools/perf/util/parse-events.l b/tools/perf/util/parse-events.l index 2034590eb789..300d84fd09ad 100644 --- a/tools/perf/util/parse-events.l +++ b/tools/perf/util/parse-events.l @@ -317,6 +317,7 @@ config { return term(yyscanner, PARSE_EVENTS__TERM_TY= PE_CONFIG); } config1 { return term(yyscanner, PARSE_EVENTS__TERM_TYPE_CONFIG1); } config2 { return term(yyscanner, PARSE_EVENTS__TERM_TYPE_CONFIG2); } config3 { return term(yyscanner, PARSE_EVENTS__TERM_TYPE_CONFIG3); } +config4 { return term(yyscanner, PARSE_EVENTS__TERM_TYPE_CONFIG4); } name { return term(yyscanner, PARSE_EVENTS__TERM_TYPE_NAME); } period { return term(yyscanner, PARSE_EVENTS__TERM_TYPE_SAMPLE_PERIOD); } freq { return term(yyscanner, PARSE_EVENTS__TERM_TYPE_SAMPLE_FREQ); } diff --git a/tools/perf/util/pmu.c b/tools/perf/util/pmu.c index 5a291f1380ed..5868d654872b 100644 --- a/tools/perf/util/pmu.c +++ b/tools/perf/util/pmu.c @@ -1539,6 +1539,10 @@ static int pmu_config_term(const struct perf_pmu *pm= u, assert(term->type_val =3D=3D PARSE_EVENTS__TERM_TYPE_NUM); pmu_format_value(bits, term->val.num, &attr->config3, zero); break; + case PARSE_EVENTS__TERM_TYPE_CONFIG4: + assert(term->type_val =3D=3D PARSE_EVENTS__TERM_TYPE_NUM); + pmu_format_value(bits, term->val.num, &attr->config4, zero); + break; case PARSE_EVENTS__TERM_TYPE_USER: /* Not hardcoded. */ return -EINVAL; case PARSE_EVENTS__TERM_TYPE_NAME ... PARSE_EVENTS__TERM_TYPE_CPU: @@ -1586,6 +1590,9 @@ static int pmu_config_term(const struct perf_pmu *pmu, case PERF_PMU_FORMAT_VALUE_CONFIG3: vp =3D &attr->config3; break; + case PERF_PMU_FORMAT_VALUE_CONFIG4: + vp =3D &attr->config4; + break; default: return -EINVAL; } @@ -1912,6 +1919,7 @@ int perf_pmu__for_each_format(struct perf_pmu *pmu, v= oid *state, pmu_format_call "config1=3D0..0xffffffffffffffff", "config2=3D0..0xffffffffffffffff", "config3=3D0..0xffffffffffffffff", + "config4=3D0..0xffffffffffffffff", "name=3Dstring", "period=3Dnumber", "freq=3Dnumber", diff --git a/tools/perf/util/pmu.h b/tools/perf/util/pmu.h index 1ebcf0242af8..67431f765266 100644 --- a/tools/perf/util/pmu.h +++ b/tools/perf/util/pmu.h @@ -23,6 +23,7 @@ enum { PERF_PMU_FORMAT_VALUE_CONFIG1, PERF_PMU_FORMAT_VALUE_CONFIG2, PERF_PMU_FORMAT_VALUE_CONFIG3, + PERF_PMU_FORMAT_VALUE_CONFIG4, PERF_PMU_FORMAT_VALUE_CONFIG_END, }; =20 --=20 2.34.1 From nobody Tue Feb 10 09:45:02 2026 Received: from mail-wm1-f54.google.com (mail-wm1-f54.google.com [209.85.128.54]) (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 E113127814C for ; Fri, 8 Aug 2025 11:24:02 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.54 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1754652245; cv=none; b=K4yMxQ70WtUqPC/9u1AAhpXKpVbpCZ/Chm0PItMIY8/Pb6zq7Emzgnr2sqnl0ElBQ4VFpq7EHSI93TVrTQwmFs2sl2HxMcorbfcv40+TPn5ErWnYyrt58NgGIFSskLLx6r+3Pb3f+C56c4SzlXz9W4zM/pD4zzKyQxLkcQlrB+s= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1754652245; c=relaxed/simple; bh=aRUWGynzXd2I0iPJ8E252lMe7rGfIx7dGynoHirUSWM=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=MQZyEc5gqgRTRHS5cpMRRPP6EZC09M/z4LvWws2gYSjSdT4fQmOhWGV4oLJmvaUoH0qgCIcmHomRqEFW2kbmE4nobQ3ZazWkdTN1EQB+yGyS7/58S4uP4umyl32ujs6d50lj+zPZfG7LLvYRNNfBEH6+oLOfjdH5WMSpZvR1HMc= 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=T9Qmx8oA; arc=none smtp.client-ip=209.85.128.54 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="T9Qmx8oA" Received: by mail-wm1-f54.google.com with SMTP id 5b1f17b1804b1-459e7ea3ebeso8023585e9.0 for ; Fri, 08 Aug 2025 04:24:02 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1754652241; x=1755257041; 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=aJMmlptoopG7uLnpNHx3BFeWdRFU3hEImM+p7yUrZvk=; b=T9Qmx8oA30OeY/AkrLd+4aJrgboV6NBUIKm1U/nCvGa8s6rKqEnplLWaxtiXuMD2Oh EmN77fIY+v4AlKh+dDxsEfSUPpDUq69xTLwjUpuaUAzn/KbHxnnMHjzrTx4cyEhAO5OV pGCA86SJghMUVcxwHP8F22KHe907F6F29RuJpnIR1syiKv9NSX2kTq4lEa3tJxhZP+zi oABntV0bxhGTSpQQSwTrydFIkKCgmQvUg4M0Pm1QEphP7TafBy1R227OLfW03BY8QhoW GBVXssor0AFKrPbbik2A+opzKdZSD+/+WkQWqNwfs6IFxZCaziRt0cUC44AnRpQpl4ph drkQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1754652241; x=1755257041; 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=aJMmlptoopG7uLnpNHx3BFeWdRFU3hEImM+p7yUrZvk=; b=buQpMF+Ulkp2oz/LPu0FdBEenNKFdF1Pidd4P1DMc0TNZdRDFIw/N6ADRzR+hh7Niv m7tSnhaYUzbPesDSYQ/Pb49TPG5HOo7obDbnDKNUGDOA/Ifl+M8P+hUgaay43dJwf21y n6B9/chWpfRBKpZd+UEnZDZzjjlidkUbfkg3gcoQ/xPnCCmnp9mKGRpY1rdV65KmYEGh akP0insXvU+hMI4wpBb3IUTeLdv0uNiYzwK9lvI4NC8owSN/s5hOrFllFh6Li6P8nypD WgiLZArmbkVQ3dp3wZZq/J2x/oXxRXxnCIwysmd7+JSCOXZwwg8fwTsMYVU8RMlC+mxv ySzw== X-Forwarded-Encrypted: i=1; AJvYcCVBH99jYfrWZ5grT/0QYXMZju8vt63qLvIxW9yIsZ2NA5Bsy2T272VPjSx+pmT9BaBc7X21hADxxkJlGek=@vger.kernel.org X-Gm-Message-State: AOJu0YykJ9/l1EURw0htjZe0DkgY0aE23KR0XbAR5XaBgvAXvfhYIROI vbiAnJriDh1HtW7Gu70Uk4ojF/A1Gjrpcpltm8KyCkQoAriR6s/yEuCwMkK5OHMvW4w= X-Gm-Gg: ASbGncsreKaf8iJy+dg8mCivCnqeyDYA+vZIjJi8k4YP7DJ49786LRxYWn/QhBZmFeK FEZ8XRs2EifPlpInnX315dgbgEsy8jWAxV8HJ8AjAgS1AqpZjfWOIFtN/mgoDxqRbQkxmuiddZM E/wwith9d6N9njHaklBHL9j0cqMIueBy3lcI4pIZsY2LrJ+YVFCVyVrJ3ONtozuYb0If6rKuKnz fF0+WXOx5p7iegocehsjDgsvjh90mw1xRxPg4nNH/YN1YNSDsRA2N8qAOQK9hgonex2F638U8WJ 9W4RajsscM6yQNsP1TfyPFr4MPyh0CtLPolGiXb1HJ/tqX2NchZwmAPZ0/3B4XsEDyiEzKh8plN CsgacSSSN6QTY1dFmqd1Fe+1ueTSS5+s= X-Google-Smtp-Source: AGHT+IHmVAPILAQt3jjnEVGZ95cvj/TwlhhBPdwWWqHVaKoukt+lAJlLJ0e2hot/FLFDTcAHZ+O1UQ== X-Received: by 2002:a05:600c:468d:b0:456:fdd:6030 with SMTP id 5b1f17b1804b1-459f4f98174mr23235225e9.19.1754652241155; Fri, 08 Aug 2025 04:24:01 -0700 (PDT) Received: from ho-tower-lan.lan ([185.48.76.109]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-45923c34af8sm233482635e9.24.2025.08.08.04.23.59 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 08 Aug 2025 04:24:00 -0700 (PDT) From: James Clark Date: Fri, 08 Aug 2025 12:23:09 +0100 Subject: [PATCH v6 12/12] perf docs: arm-spe: Document new SPE filtering features 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: <20250808-james-perf-feat_spe_eft-v6-12-6daf498578c8@linaro.org> References: <20250808-james-perf-feat_spe_eft-v6-0-6daf498578c8@linaro.org> In-Reply-To: <20250808-james-perf-feat_spe_eft-v6-0-6daf498578c8@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 , Anshuman Khandual 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 FEAT_SPE_EFT and FEAT_SPE_FDS etc have new user facing format attributes so document them. Also document existing 'event_filter' bits that were missing from the doc and the fact that latency values are stored in the weight field. Reviewed-by: Leo Yan Tested-by: Leo Yan Reviewed-by: Ian Rogers Signed-off-by: James Clark --- tools/perf/Documentation/perf-arm-spe.txt | 104 ++++++++++++++++++++++++++= +--- 1 file changed, 95 insertions(+), 9 deletions(-) diff --git a/tools/perf/Documentation/perf-arm-spe.txt b/tools/perf/Documen= tation/perf-arm-spe.txt index 37afade4f1b2..c7d1032ff219 100644 --- a/tools/perf/Documentation/perf-arm-spe.txt +++ b/tools/perf/Documentation/perf-arm-spe.txt @@ -141,27 +141,65 @@ Config parameters These are placed between the // in the event and comma separated. For exam= ple '-e arm_spe/load_filter=3D1,min_latency=3D10/' =20 - branch_filter=3D1 - collect branches only (PMSFCR.B) - event_filter=3D - filter on specific events (PMSEVFR) - see bitfie= ld description below + event_filter=3D - logical AND filter on specific events (PMSEVFR) = - see bitfield description below + inv_event_filter=3D - logical OR to filter out specific events (PM= SNEVFR, FEAT_SPEv1p2) - see bitfield description below jitter=3D1 - use jitter to avoid resonance when sampling (PMS= IRR.RND) - load_filter=3D1 - collect loads only (PMSFCR.LD) min_latency=3D - collect only samples with this latency or higher= * (PMSLATFR) pa_enable=3D1 - collect physical address (as well as VA) of load= s/stores (PMSCR.PA) - requires privilege pct_enable=3D1 - collect physical timestamp instead of virtual ti= mestamp (PMSCR.PCT) - requires privilege - store_filter=3D1 - collect stores only (PMSFCR.ST) ts_enable=3D1 - enable timestamping with value of generic timer = (PMSCR.TS) discard=3D1 - enable SPE PMU events but don't collect sample d= ata - see 'Discard mode' (PMBLIMITR.FM =3D DISCARD) + data_src_filter=3D - mask to filter from 0-63 possible data source= s (PMSDSFR, FEAT_SPE_FDS) - See 'Data source filtering' =20 +++*+++ Latency is the total latency from the point at which sampling star= ted on that instruction, rather than only the execution latency. =20 -Only some events can be filtered on; these include: - - bit 1 - instruction retired (i.e. omit speculative instructions) +Only some events can be filtered on using 'event_filter' bits. The overall +filter is the logical AND of these bits, for example if bits 3 and 5 are s= et +only samples that have both 'L1D cache refill' AND 'TLB walk' are recorded= . When +FEAT_SPEv1p2 is implemented 'inv_event_filter' can also be used to exclude +events that have any (OR) of the filter's bits set. For example setting bi= ts 3 +and 5 in 'inv_event_filter' will exclude any events that are either L1D ca= che +refill OR TLB walk. If the same bit is set in both filters it's UNPREDICTA= BLE +whether the sample is included or excluded. Filter bits for both event_fil= ter +and inv_event_filter are: + + bit 1 - Instruction retired (i.e. omit speculative instructions) + bit 2 - L1D access (FEAT_SPEv1p4) bit 3 - L1D refill + bit 4 - TLB access (FEAT_SPEv1p4) bit 5 - TLB refill - bit 7 - mispredict - bit 11 - misaligned access + bit 6 - Not taken event (FEAT_SPEv1p2) + bit 7 - Mispredict + bit 8 - Last level cache access (FEAT_SPEv1p4) + bit 9 - Last level cache miss (FEAT_SPEv1p4) + bit 10 - Remote access (FEAT_SPEv1p4) + bit 11 - Misaligned access (FEAT_SPEv1p1) + bit 12-15 - IMPLEMENTATION DEFINED events (when implemented) + bit 16 - Transaction (FEAT_TME) + bit 17 - Partial or empty SME or SVE predicate (FEAT_SPEv1p1) + bit 18 - Empty SME or SVE predicate (FEAT_SPEv1p1) + bit 19 - L2D access (FEAT_SPEv1p4) + bit 20 - L2D miss (FEAT_SPEv1p4) + bit 21 - Cache data modified (FEAT_SPEv1p4) + bit 22 - Recently fetched (FEAT_SPEv1p4) + bit 23 - Data snooped (FEAT_SPEv1p4) + bit 24 - Streaming SVE mode event (when FEAT_SPE_SME is implemented),= or + IMPLEMENTATION DEFINED event 24 (when implemented, only vers= ions + less than FEAT_SPEv1p4) + bit 25 - SMCU or external coprocessor operation event when FEAT_SPE_S= ME is + implemented, or IMPLEMENTATION DEFINED event 25 (when implem= ented, + only versions less than FEAT_SPEv1p4) + bit 26-31 - IMPLEMENTATION DEFINED events (only versions less than FEAT_= SPEv1p4) + bit 48-63 - IMPLEMENTATION DEFINED events (when implemented) + +For IMPLEMENTATION DEFINED bits, refer to the CPU TRM if these bits are +implemented. + +The driver will reject events if requested filter bits require unimplement= ed SPE +versions, but will not reject filter bits for unimplemented IMPDEF bits or= when +their related feature is not present (e.g. SME). For example, if FEAT_SPEv= 1p2 is +not implemented, filtering on "Not taken event" (bit 6) will be rejected. =20 So to sample just retired instructions: =20 @@ -171,6 +209,31 @@ or just mispredicted branches: =20 perf record -e arm_spe/event_filter=3D0x80/ -- ./mybench =20 +When set, the following filters can be used to select samples that match a= ny of +the operation types (OR filtering). If only one is set then only samples o= f that +type are collected: + + branch_filter=3D1 - Collect branches (PMSFCR.B) + load_filter=3D1 - Collect loads (PMSFCR.LD) + store_filter=3D1 - Collect stores (PMSFCR.ST) + +When extended filtering is supported (FEAT_SPE_EFT), SIMD and float +pointer operations can also be selected: + + simd_filter=3D1 - Collect SIMD loads, stores and operations (PMS= FCR.SIMD) + float_filter=3D1 - Collect floating point loads, stores and opera= tions (PMSFCR.FP) + +When extended filtering is supported (FEAT_SPE_EFT), operation type filter= s can +be changed to AND using _mask fields. For example samples could be selecte= d if +they are store AND SIMD by setting 'store_filter=3D1,simd_filter=3D1, +store_filter_mask=3D1,simd_filter_mask=3D1'. The new masks are as follows: + + branch_filter_mask=3D1 - Change branch filter behavior from OR to AND (= PMSFCR.Bm) + load_filter_mask=3D1 - Change load filter behavior from OR to AND (PM= SFCR.LDm) + store_filter_mask=3D1 - Change store filter behavior from OR to AND (P= MSFCR.STm) + simd_filter_mask=3D1 - Change SIMD filter behavior from OR to AND (PM= SFCR.SIMDm) + float_filter_mask=3D1 - Change floating point filter behavior from OR = to AND (PMSFCR.FPm) + Viewing the data ~~~~~~~~~~~~~~~~~ =20 @@ -204,6 +267,10 @@ Memory access details are also stored on the samples a= nd this can be viewed with =20 perf report --mem-mode =20 +The latency value from the SPE sample is stored in the 'weight' field of t= he +Perf samples and can be displayed in Perf script and report outputs by ena= bling +its display from the command line. + Common errors ~~~~~~~~~~~~~ =20 @@ -247,6 +314,25 @@ 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 =20 +Data source filtering +~~~~~~~~~~~~~~~~~~~~~ + +When FEAT_SPE_FDS is present, 'inv_data_src_filter' can be used as a mask = to +filter on a subset (0 - 63) of possible data source IDs. The full range of= data +sources is 0 - 65535 although these are unlikely to be used in practice. D= ata +sources are IMPDEF so refer to the TRM for the mappings. Each bit N of the +filter maps to data source N. The filter is an OR of all the bits, and the= value +provided inv_data_src_filter is inverted before writing to PMSDSFR_EL1 so = that +set bits exclude that data source and cleared bits include that data sourc= e. +Therefore the default value of 0 is equivalent to no filtering (all data s= ources +included). + +For example, to include only data sources 0 and 3, clear bits 0 and 3 +(0xFFFFFFFFFFFFFFF6) + +When 'inv_data_src_filter' is set to 0xFFFFFFFFFFFFFFFF, any samples with = any +data source set are excluded. + SEE ALSO -------- =20 --=20 2.34.1