From nobody Sat Oct 4 17:34:15 2025 Received: from mail-wm1-f50.google.com (mail-wm1-f50.google.com [209.85.128.50]) (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 D0859212FB9 for ; Mon, 1 Sep 2025 12:41:51 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.50 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1756730514; cv=none; b=DJAPdsAEIjYP3HpD+TkpqXtkoNufbwPAi1EnmTQG+vYb/3WPLlrtt6+j34qF6n7wjX4YxyRjTqC35NmyQpGvDqx7IqLBvxta7I7z/7WYXKdHJ1UOtDiERvs9mEfbA7XIZG9TqWKaBkkNJVAxX6LWHw6dS+eUP8/jXDxIqM1Ib0M= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1756730514; c=relaxed/simple; bh=51vdVVrDG2YLBYS3Pf8NCD6LBuxxPOs+8V116Ol8P34=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=N2uV5UrtcerXJpA6E+bW2mBZMlYgDltBZZs3K0JdEw2Oq99d0krRuYrCdj9dqf/UbcnrSA5q/ezUCdbYgBhuwkVP7zcb2S5uUmJBJysoL/uJD1WpNPCZ7F6ZzXDxMkQVO9agrL1AyXNzYtwNYWr2LLo2U99WNXL0jfunWbVy4HM= 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=KSLJ8OHF; arc=none smtp.client-ip=209.85.128.50 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="KSLJ8OHF" Received: by mail-wm1-f50.google.com with SMTP id 5b1f17b1804b1-45b8b7ac427so6204815e9.2 for ; Mon, 01 Sep 2025 05:41:51 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1756730510; x=1757335310; 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=KSLJ8OHFtKsK31Tw0zIpqb4zGK/GIZkebUUsXm04g/yN7z9rANcdK++IHl2GGgvR10 VbKsEwO8pHlpyPDc/onLGlRyKyOKpO2Gz6gH+T7kITDRZnkXHl1E/HvHFOA3zd15KS02 3DEE82X6JnAEVkaRLhdCDPBagc/MaeBwykBJzs3Be6WfQheQwQ7Y4Bqn8yWzPFzDJ+Sk WxTtZhIotGOdpb014s37v+pWQlBBEjSMnJO5tMbShwijUZNNkiYStI644IBez0UUY3Hp inSCquu5VgIn990JofdVJiG1vCOQ41AlylV47uLclxeQal0tNCIj+nxv9BUWVfsDtSUH Q8RQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1756730510; x=1757335310; 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=Ix0NLrRWz+KgfF3ljNb/ImcgPA6Gt2b1DbO6clEcAp1LGG3PTCzLjyDeDyWH+itii0 hzeah9lXjCowYYH46vA5UmJ6OpEX4bVLoNtu7PzQNhBpgsAouhZoehSe7PAK8avm49Ko azUGwIYv2rb96PvpJ216rVfgVZOtZK9K+MG2b+cwTH3EnGriAE47pNnFRFxXN4MltAZl TJhc+ywjHhWJlbRCkyqzi3KfB3gGh6tpwHmRjPRSLJo6oqdT2s7624XYB518VKKQOkgu ruzLtBubt8D+ksz5PdSiCFfYQ8yuTUh9YU/MTMfg68klMb4tyUwvcIQfx5PG+y8lv+zx tm2Q== X-Forwarded-Encrypted: i=1; AJvYcCV+P6J+BZnffZ0NZOKZxVUgZBPQ9KM23+UGF6obN6/nrToZY307DulmMjQAujxHt9Boy32OPAXio5UstjY=@vger.kernel.org X-Gm-Message-State: AOJu0Yxyv009ifcIKDgJ9rrbu0eCputuz3cako+8uCmpSbjt96qcj8tx kfaJgRjYO4dAmMsZtbjyNv25dAk8YeljTawcZRDV1nfAmonmTvhteLy3tZ0xjyBd5pE= X-Gm-Gg: ASbGncsU4+hgYqbiu3zVGx0ue7y8RSpxyTroDnA5WRUDtPYgx4CtHlEXn9JWGU/n8dA ToDRfuykNxFmR8nvEUkA5G60pnU79neCTc4WkSbNZStwuF9mbGpAlNPjUcgnKSBYyePuk+/J5lG bnzgV53Hd/TL8B8bzZJYvIuHi3CJWOXnbRoe7rEuytzV7HnXMEY+Mr3xT1IcO+Yg5OXwuaWzG9e FeVg2duqWiFnKDsBqzJ5xk23jVcRMO4glT0+WOAF8M8ntnsZJiqilA2NH19AI2IdMQtwbmTrcPC r0w9Mow+V1UkbbvE6a+J8CMff3BGpEpBooIDjbEhN937358AzJabHE1oDYbwBrDIBcho0UbSHqs 0ViR62gNIH8Jwnfqqn4yRR/xW4SYUzE6dMZZ7JMPemQ== X-Google-Smtp-Source: AGHT+IEpKxBP9k/vYtw8Ht1MbnsTYjDO7wEj/uW0QbGaAjhmSNIBbT3ZI/wMtrWxLNIo5Z9MYwmVUA== X-Received: by 2002:a05:600c:1e89:b0:45b:88c6:70a2 with SMTP id 5b1f17b1804b1-45b88c67360mr50627485e9.1.1756730509844; Mon, 01 Sep 2025 05:41:49 -0700 (PDT) Received: from ho-tower-lan.lan ([185.48.76.109]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-45b7e898b99sm154946315e9.19.2025.09.01.05.41.48 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 01 Sep 2025 05:41:49 -0700 (PDT) From: James Clark Date: Mon, 01 Sep 2025 13:40:30 +0100 Subject: [PATCH v8 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: <20250901-james-perf-feat_spe_eft-v8-1-2e2738f24559@linaro.org> References: <20250901-james-perf-feat_spe_eft-v8-0-2e2738f24559@linaro.org> In-Reply-To: <20250901-james-perf-feat_spe_eft-v8-0-2e2738f24559@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 Sat Oct 4 17:34:15 2025 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 1C9BF3115B1 for ; Mon, 1 Sep 2025 12:41:52 +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=1756730515; cv=none; b=AM8ZsPvILtygrQ8uMb9KK0TB2mFjcKU7Azeaj/blTVXj2/kkaVh6c+fUv4vPKooEQtKCHQBb3uDOA47ryg02Uza3bOuO0WVhp9hjqj67dVgVg2az3t+ynYucaMXeourPit75dmiuvXsDl5TuoB7+Uh9tMiQ47HlN6AFP6Xsf65A= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1756730515; c=relaxed/simple; bh=u8t6+Ai5818q2OqeuPRlI3lTIu6X9MGrpK8W6uKLv4M=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=aaw9H8I3YyOw7Tqi1Vk3JH9mltmov5XVgiUCIHQ2pZ/AYUjVp2TQfU35pIa0aoKpaa426uYxCKFAsLG7zFxWiQ9MCML0e4K1DSpMyHP1i5iRzResQGAyja6U1cZnp6N8Pc6Ta0nNWlpc8+zCnwZzmJx7nm3T45cKcFbhssmQls0= 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=PNkdOFH4; 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="PNkdOFH4" Received: by mail-wm1-f45.google.com with SMTP id 5b1f17b1804b1-45b77f59bd8so24638205e9.0 for ; Mon, 01 Sep 2025 05:41:52 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1756730511; x=1757335311; 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=GZZgvWpkzzBr+nwBCDJ3J4f7oxmGZr0r5wi9QRbWfI8=; b=PNkdOFH40+IdgAKYGHJtZUlnFy1OCPmSSma/lmg0O6FLu38A99DbTskppWZ+SnpfNN L2mWuoEDqHl/rOSGiJcxY/QisBAcLY06PmsQNTo3miVfAEC8AeXGQdu3o56QyBSMDMO+ CA+KUktaPPFF1ioRRC4PqzQS/LXdKd6j5/lwpKmH78ylkmKxn9uL3m6iPDRF2vmS8ozS IQT3Or8iPEs0ydrCrgPaON+P2/OOp0Eq8xMcDveXplB+RYabh5f+l6VaqNo9HSkDF7gX Daj2oaDAjyhT/clUoBfmg6r1gqQ6NcLQhqOQR8nnGEmU9qOlcuW8lq0EXO5CNfglxkqd 92Cg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1756730511; x=1757335311; 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=GZZgvWpkzzBr+nwBCDJ3J4f7oxmGZr0r5wi9QRbWfI8=; b=FBypG8Nxm/kh34fbd1OhhUwXYUSS+nFZn5i+Sa1N1taig+vF6YQ9+FZ8notDVpBfIz lrBkbxV0LhNuRPgmj/8Tb+IVT7oiQs1fMJmhc9EhvLK1L5LjGalxgcNrKPNeDVpahbLm Yo5DFeyO5NJ39QEx1EuANri1ZazCVAM+b9+rmk2+07e2X6S1bjljcDUpQHhYZn0Ue1VR hIgKYbr7ovpT7D5+ztIA87K0La2JvI/dKURTNNERLwqulWItHqqnsE1flqcxCjA5DcCm VXgc3LyafyevrJ3XAQFGQWr7jlV2HWOd0ALQ9kKYpzcDdAO+teKaEhRb+xGqBR/Q4Rra +9FQ== X-Forwarded-Encrypted: i=1; AJvYcCXs6NzmcTxRWKWjByp7OjKakWhHzYAdqmgVgSfW2YZfAe1U0g2mQ3gzy4HCtYSe+6LgWIIQOOa0duqSmCk=@vger.kernel.org X-Gm-Message-State: AOJu0YylpM/Pu9BTKIuwSLgOyF8zXDCpEM2uahvaopxRwgrtDrR7mzIn 0XssAqCl0ZSdRLP1RqcW0h6WKvXVidpIjxW38PkL7Dck3lP8Qj9EsbA7C7+NvoCha1w= X-Gm-Gg: ASbGncsplx2IL4s+1RqMDmauIDSXbZI0DRfw+7EeefktRF5HnRbM3lcVawVWgtoWVvq cXFGhvqlZ4YqxhsP6DV6kYqX6EOlXCWKoaEZwaIZSgxDCd0d4Qb4621h8YaBuUZ6tgHjp88MKPs RSYa+XWYLbCLnvkeUDSK9rBklCUJ8HcrJyT1z6b08pv0O5hbj5baM0H08NcbRqXxMvF9/hsisQu RfJ04znXolrkmDv4/wZvP2DPpns4Sc6NKzz+46p6sVmNFk2MzFk0yMAipea7c1FHTKjhFRdI6TR s75RiBi3beEsPQMX/G+UhEtYxrjLuicSxDTe5KHvK3sKMLLk95vt7bMr0DAp4ERkuYYiqyxwitJ uic5t/glgRKTbWLHS/mfs3+0MHuW0aA0= X-Google-Smtp-Source: AGHT+IHOmsUvkIOzZdpZGUdJ8+tog1LZQ1DvZke4oaEKX68EXOiUCozD6kPp0FykYmEdPI7ixAJleQ== X-Received: by 2002:a5d:5d0d:0:b0:3ce:5696:39f1 with SMTP id ffacd0b85a97d-3d1b1af1fc2mr5785396f8f.22.1756730511229; Mon, 01 Sep 2025 05:41:51 -0700 (PDT) Received: from ho-tower-lan.lan ([185.48.76.109]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-45b7e898b99sm154946315e9.19.2025.09.01.05.41.49 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 01 Sep 2025 05:41:50 -0700 (PDT) From: James Clark Date: Mon, 01 Sep 2025 13:40:31 +0100 Subject: [PATCH v8 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: <20250901-james-perf-feat_spe_eft-v8-2-2e2738f24559@linaro.org> References: <20250901-james-perf-feat_spe_eft-v8-0-2e2738f24559@linaro.org> In-Reply-To: <20250901-james-perf-feat_spe_eft-v8-0-2e2738f24559@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. Tested-by: Leo Yan Signed-off-by: James Clark --- 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 6604fd6f33f4..2cf7f30b0d4f 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 Sat Oct 4 17:34:15 2025 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 9BD103101AB for ; Mon, 1 Sep 2025 12:41:54 +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=1756730516; cv=none; b=GwUq0DtiukjyeHleFdhH1sRc+IcGQ6djLoCJkyrPnQYjNkK/ICFtyTBxG5EHZrwhd5wjZSJQTvlNWsyuEIr2+ltzMi0m8HPTFzyjYcFt3wDoLruVk4vU8+pPM2GKZzPpD32zyyW+TdMtFRVzSbSItnzC7swzglv6BuEX8aKYv2M= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1756730516; c=relaxed/simple; bh=1dn2TsDH9c3qn851HU6KhoRjFDuyNupOzJtkpyRLaL0=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=gLU/hYBGJWFjIAupBMbJaR8IkZNiGoF0u2LO+uI0lADUv5Ip1QgitIc7yFOcaNESRsx3Ad5aOJubUoW3cvBgWm/k9S6rYws2JIbqKU/5EPZ0zWZ0Yfh5SjrfxrewizjpBXH2dptydO/Ik9BinzzeDHr84DqcVc/12oFSG7p80N8= 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=s9FZoOfx; 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="s9FZoOfx" Received: by mail-wm1-f53.google.com with SMTP id 5b1f17b1804b1-45b883aa3c9so9442635e9.2 for ; Mon, 01 Sep 2025 05:41:54 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1756730513; x=1757335313; 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=2rccDGxo7Zi/+ePrAmZStYRWWCBeSec1uJGq7oyHErE=; b=s9FZoOfxxCzWkIyetl9yZTurTTiqZnIDBztZWxtN3g1VERZXI/I8fgyqkXb1X4prB6 VrxPGcEPoDVHYxOFk9ZZ+7nWwsB95fs9vl48ziCAsweYytdZFZRfTd0pYyLwaTsoNgBJ gFpbtgGwQVNlLrSTjPpx1MWKuTiiwMzDCV9JK+jAzt3DwlOtxJ4h7o4Z2tVPAz3Vk5QJ WB7jEqlCdZ2Y4oiVIRgc0VXi6Ri8YmbidLzw9ejs05bevqwkQt7pwC3wzwU7Zlc+5Dri LoVv4+yuHdlh1DL2Dybmu9m5nYoqIcENLYYxk0b3OniejBljVibF1zpiT0EazFtBD2mU p+Zw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1756730513; x=1757335313; 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=2rccDGxo7Zi/+ePrAmZStYRWWCBeSec1uJGq7oyHErE=; b=Fsp5tQC1APRsnE1V1C5odlQe3grnp0awzC7ynuAWMiNYhxDgJ7W8EsRjHFO7vPQhkF o033b210CVQaq+OayDQvumKor1SL8lKWMO10t+xVo+Ws3SlVwSK8GfCvt8WBcSLsfEkJ PXOcZ7UtiiKIKWFBWwlxGvtHg73b583GOTGWdT/iNcjA7j8Kqw0gahU15LTU1QdxP/s0 W399AgKhylQPFSwnHSTyjzOfZLZvT5VRBP45uQP7cihhiUlFcs+gOLB+tTcpePAF0EfL eRpgV2m4FHt7KZ6qeT7zU1JYWn/nOGHzjSbKyuKd6MaMTnQlokYPRbddHva4ohqwvon3 cPQg== X-Forwarded-Encrypted: i=1; AJvYcCXicd/OYoo3ClPB+PckDFF9nA//11x/JUr82nEhrPs2wKBXwJpo5zvJ4+O4YVPLJGXgAYNgTwrncddl2sg=@vger.kernel.org X-Gm-Message-State: AOJu0YyGweLfrtbFUJujSt/hfnzIXMhNfYtlQ4kQBzsltnONHNdEGivN +P9YvAnBL5SuHIQoOaymHYU6c87dpaA1f+W6/lRBhr70m2BNmgMOglIP9ns0CzleK8w= X-Gm-Gg: ASbGncu5iZKnl7vq/VQB2cXXeismYNvV24kHpI4pjXQVrQJU1zgThfVYc+S1oo1IQH+ e8lcPkmZsEdGieVv5xZchUPzoO4oSnjLTcBGbF8ZFkTCTU0XoCguRUlDA4uOTMQbQrmnsGMheP1 bJJxZ/38CFFw7/uQNIIF2scT/9VXh/vVvKwoQ3yw2Sv32tEfXUba+DnagJ/zC3jxDi2u89h08y4 Z/tfCqvXs0SS89LUR9q/TRQl0CvyZ3fKE2F+jpspHgm0/xTWA5VPTKSjqCRqPo8W0XkIBK/1TUf maDP406X7IF7avzWwlcq0yAxlUwOX9CvpUjAUx31oQ7iUJRY3otA90zpR+tqiiyjthANHZ4eErq ZCcfGWZequcBysEkJOsjbE3Cjzv7xBrs= X-Google-Smtp-Source: AGHT+IEiJacQeJIhAlVFIVb4gBUFN/ZD4+BtNn08VuvIydbSJk4ZmQ+RW5QdnGmgopAeFlemw8drNw== X-Received: by 2002:a05:600c:4fcd:b0:459:db71:74d7 with SMTP id 5b1f17b1804b1-45b8557c8d1mr55430795e9.27.1756730512680; Mon, 01 Sep 2025 05:41:52 -0700 (PDT) Received: from ho-tower-lan.lan ([185.48.76.109]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-45b7e898b99sm154946315e9.19.2025.09.01.05.41.51 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 01 Sep 2025 05:41:52 -0700 (PDT) From: James Clark Date: Mon, 01 Sep 2025 13:40:32 +0100 Subject: [PATCH v8 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: <20250901-james-perf-feat_spe_eft-v8-3-2e2738f24559@linaro.org> References: <20250901-james-perf-feat_spe_eft-v8-0-2e2738f24559@linaro.org> In-Reply-To: <20250901-james-perf-feat_spe_eft-v8-0-2e2738f24559@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 Tested-by: Leo Yan Signed-off-by: James Clark --- 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 Sat Oct 4 17:34:15 2025 Received: from mail-wm1-f46.google.com (mail-wm1-f46.google.com [209.85.128.46]) (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 F1649326D7A for ; Mon, 1 Sep 2025 12:41:55 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.46 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1756730520; cv=none; b=QbP883k3vO59OZh0pfdpgIhgYZrv6mdpLrHk6tj38asy46yqv60q9ESyvJe4avLRpCSRnbEDg0xRT/GUfaC1RKHFq9m/KlUM9rxP1zxd3zzu5AvGFov5H7KFUutYL7gxPfUF8tYewWCNsz2Bva7EBTfojU2OpM4QuOGFACrGA2k= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1756730520; c=relaxed/simple; bh=amxfcIwk9CPU6fVzRnT+1Y2WxFhNVG4dD8O25j9WGOo=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=XfKsg47ck3b9gZ2dS5z7+dJK4hurP3e4yqXjKWU0DQi6X8OAsKoamnBGgseSv9X212T4vKB+Yg9OqNcXlb0QKaDHs87hAPGK29tFJfe/QHsRL1QrVn7gKhGK2mF62jPbo/kPld+jZpWgfiMGVionBSRg4ksthM286n4xCSkzosg= 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=hfEkn2HD; arc=none smtp.client-ip=209.85.128.46 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="hfEkn2HD" Received: by mail-wm1-f46.google.com with SMTP id 5b1f17b1804b1-45b8b8d45b3so10190035e9.1 for ; Mon, 01 Sep 2025 05:41:55 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1756730514; x=1757335314; 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=hfEkn2HDeRlCNO9QuWCzvgPilgKqk4aP6w8kWSPoGgNe+kd0VSSrIWcDDxKkt8j8lb ieLgRAKZqaOye/4CkSO8pUSDxfHLq5Sgjtm0Jg6dNBnw7C08VglKfcXr4xBYZGsa43nO XxNjKi0b0qleTZNXoeOuykBc+4SS/vdbdU2R+YRzm4jD06wzj6J0xCvHBrtiSmbgP6yD o0Rv4sGLCc63/V3y2sLw3ma5PcNxdBwH2AzTmuCZP5sHTEcXRfrOF8DIKZgnAIMWYtbj EKuOUgy04H1FXoCThfZudgt5Om6ZmC/HSDJcXYljeQ/6M1fgYZnEhNEIq4if9GSIEF+I aJXw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1756730514; x=1757335314; 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=GOOZsjmQ3rovDxijQ81kAUSGVXaJ9d2EQ187W3vrkr0oIQPUFp87+s4BtJtxLn0yWO GAs8tce0eVGXckNVdm7ahnYRliYjeXs2NNLYYC3eahtihh//3Pnmm5lWlKYD6X48BEkR VEt/8ixwEH3zLuQLn1anPfMWHqNoV8G2EYZ5671g0rjgWw48J/fUW1QsZv/CMRbV6CAe VostH7SH+e6XXCp1VVTV8+H3+Ivaorpz0BoMAGD12ZjyR+GbjhxxSj2cDkCs/jnW6JbU uGN3Hz4EhlR3uJXn/iKkNvUyUrCPyrMtJguskGwVRlWDK8daJdr/pU/mXq0FRFCqGRgs T+uA== X-Forwarded-Encrypted: i=1; AJvYcCVrK2XnafxQwgLD3V27hYXdLilLXgTAVhpTW+p/rVN1hUwHsy3N+QjgsMcSBoDFE+vhy+9Y2xvaGT4CTqQ=@vger.kernel.org X-Gm-Message-State: AOJu0YzVdCYp+KWrNYNCVoc68E4f3tNoAf/tzZ8qZGrVyj1sz53N1gCU orMg6tCcYCIxQ+EfXebXSPGur+UppCeMh5Jnsr5J9rYGwBAyPwh52HwFCQ87OfKXPoI= X-Gm-Gg: ASbGncuod81zQsYn+Rs9lLg1UZf2sO9P6LD7L/FwUr918uXpcZStKlBsZXc4NgYiGRO ylJrIHfsDLijBEZF4bSADolYELHNcK+6GSuy0tRemQyhG7vPN4lmFk692WLNRyk18HzPjzxWAQD ng0eva6G08m2wXyEAzQQjANoYsbAhM3CPu84XTg8tD8Ow1yceyNefz7a9GcRA/hKBZbt6nq2PD8 rjfiQPtZohlxqsWlzPNSV+rX06XPidF7N1bwt/ID8vAUsiyT1Kk93x1zQKnnKGyuPaf18NS7MlR dkXndEzKmo7n1ZXnL78TUzPRqO92lt3O5VQsgk4Qxa0Kmlq24V5UkB9VPzOaG3hwIxYyNFlw9P6 JzXhqoo3ikw2j3T6YhjzHfaUVaIu28mMttENfzcpyww== X-Google-Smtp-Source: AGHT+IHk68F1RBOrqLALR+tzK9Nwo83FiPd6ugd+/+WAEVGrF5K5fNRJag0/z1sLqK4GKgsw4UDhFw== X-Received: by 2002:a5d:64cd:0:b0:3d1:9979:dd48 with SMTP id ffacd0b85a97d-3d1de897d76mr6865637f8f.39.1756730514072; Mon, 01 Sep 2025 05:41:54 -0700 (PDT) Received: from ho-tower-lan.lan ([185.48.76.109]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-45b7e898b99sm154946315e9.19.2025.09.01.05.41.52 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 01 Sep 2025 05:41:53 -0700 (PDT) From: James Clark Date: Mon, 01 Sep 2025 13:40:33 +0100 Subject: [PATCH v8 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: <20250901-james-perf-feat_spe_eft-v8-4-2e2738f24559@linaro.org> References: <20250901-james-perf-feat_spe_eft-v8-0-2e2738f24559@linaro.org> In-Reply-To: <20250901-james-perf-feat_spe_eft-v8-0-2e2738f24559@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 Sat Oct 4 17:34:15 2025 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 A2E8132C30C for ; Mon, 1 Sep 2025 12:41:57 +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=1756730520; cv=none; b=hNY5i3r9VULDHuZj8BDsp31HjSOkAi597xivgS7l4KvZ/Hk0ETni2SA16NXQgYQk7ZtXbz1qKze7bHAmyRTSZD7dbuVLA3cdktzLtRVStci342IW2xh+1fYp5mV1VwBrf7FMxSVaerqo8OJ9waSfCA18SpG09gdtvjAR9itRPJI= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1756730520; c=relaxed/simple; bh=oruhsQ/XnkBWLsHo0pDjGsCJg2Naa/yFYEoihUsJuQY=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=RwQ5++fDuKt/uHM1cP/Buyk6qOFlAmS31ePafXmZrQOFi7EuB8cvajkD+DkkmwRYgIc6EyWWvf/2J/NOwdrGEYwvHFt+HAFXOFTLv4Nw+XQcev/bZ4HCC26OPqhiUfTkIjdT/3xFwxfpQGYVa3OF6zcu+KQORXU9YiJapnswwo0= 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=ePXwn0MV; 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="ePXwn0MV" Received: by mail-wm1-f48.google.com with SMTP id 5b1f17b1804b1-45b4d89217aso25802755e9.2 for ; Mon, 01 Sep 2025 05:41:57 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1756730516; x=1757335316; 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=IH4IhsI7u0PxrBs1+bnHSTEJenEfrd4F7dzjVPqlBZM=; b=ePXwn0MVt5XH9a0y83Mm4/qPuBH6c1iqF+heiqdhm6mdcVaTNl09RjCndaUPFMYIXe 2f6QEOMDKVXkhjXhsxWUjuz0EFd56W81UXcWGtoIQQ1EWR7FkWwVZHeMCaRl/F00dWJ8 wOTViPmFHbxSh5K/O43+ROhAHCbjiEtfroH3r0XBi/CK/0RU5ZiD5aABEeVdIaLuFcCT Mz7YqdI6eutp4FM+Gy286/s77SleRaKz0JUoUfj0JGurRhWx23RPXsQjMmSyA1xZzmNd sJ1pvBXpvymqZm5DPJtdtty9K9ntvCJRAEawBzb1o1diPUvfKtXQrD2aQ6t9zAP1duRj QBLg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1756730516; x=1757335316; 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=IH4IhsI7u0PxrBs1+bnHSTEJenEfrd4F7dzjVPqlBZM=; b=RM1U/d/Xf0XzICnBDYlXVqafMC6Hb6u9sgfaU9/MhmYMpiK7Uvu94YXgiURUUNlb1X mOkrNEW9Dy0a1jpR8HGAUP1311+92mTHp49h+LLwmw29GrDy/sDkmXrQRf9qfIXNGd3O lPvtVYHzpBggwEqz5r5uqSR3agct90cBsiyqHntpPzLDj3/dCOT6b2O86lNIC6F9O3/H H4ua9ZamtGEA4gTxU9NXCtUu30m2sFnXjCF4c9UHwKT6mcb5yYLL0DPT6APjzAQ1DE6q RUtmhDtcvk8x0RGgSYFkRUAwa0EzOezJIFCJ2nA0DXorSADD7C0oRT8tiEftd2AnVT0U 0ACg== X-Forwarded-Encrypted: i=1; AJvYcCX9X9TEcHbu5/XSksOgUvjvDKkomWobxWCMfj0iPfjKS9Me18uRcj4lqI6srB69xM4FW8ivKS9IKRLF9b4=@vger.kernel.org X-Gm-Message-State: AOJu0Yznunh+utYa5JaEVEPs2dgG1lgVm1dOHYUzXLBbaSxsalHeRFsL xYv6ObTx/nAaBYZqkes4Z0ua95VDUduvf8dpNasg1Vcre6e8Yfn1q08+azJ4N9Xbvnw9Of7HyTh pHyu4KWs= X-Gm-Gg: ASbGncthld8K/MU4k2bDas3B9xmh4JWdNyebzOby24YxVrS/lmtJZs6wEKV3MBjqW58 L9fLSeVDXcp3qBoPBcVN3cxi2jo2cyn143JpuxVEUBxFkuy/pH/AnmMszZiH7vA3qC267jOh/do ph/WIRqKZUhaTGsm/PLcfKSN+5VyEpMLsEtiHLRZxdPg7a1ioViHs7gaLlTmJRZcFrW8DMs+XUb FZ0Lswrq6qOJeYzD/Dm3OIH/+TNteZI/ZmYjKBuXo8q1uaqM7XyRwxklStvJtAfmGqcUK5lEPp/ 3LobdLVhCiG9GlngDnB0hrlE32EzDn5m210Aj6VZ5cska1gbq6UrF6c0PKb2Ezb/CVzn04liBvp pzwT8dIuJFpxX+3+VBNMz4qXZHwv80IdusS4ziR1Y4Q== X-Google-Smtp-Source: AGHT+IHhau7EY0MQDlSyqPT+GtgoSvzp5Mp3oC9O8x1gCNdLj74/uD4J58UjK1u3FTzG5sPU+DMpPg== X-Received: by 2002:a05:600c:3b10:b0:45b:8f38:8d36 with SMTP id 5b1f17b1804b1-45b8f388f6bmr19047285e9.30.1756730515555; Mon, 01 Sep 2025 05:41:55 -0700 (PDT) Received: from ho-tower-lan.lan ([185.48.76.109]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-45b7e898b99sm154946315e9.19.2025.09.01.05.41.54 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 01 Sep 2025 05:41:55 -0700 (PDT) From: James Clark Date: Mon, 01 Sep 2025 13:40:34 +0100 Subject: [PATCH v8 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: <20250901-james-perf-feat_spe_eft-v8-5-2e2738f24559@linaro.org> References: <20250901-james-perf-feat_spe_eft-v8-0-2e2738f24559@linaro.org> In-Reply-To: <20250901-james-perf-feat_spe_eft-v8-0-2e2738f24559@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. Tested-by: Leo Yan Reviewed-by: Leo Yan Signed-off-by: James Clark --- 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..a305386eb2e3 100644 --- a/arch/arm64/include/asm/el2_setup.h +++ b/arch/arm64/include/asm/el2_setup.h @@ -91,6 +91,14 @@ msr cntvoff_el2, xzr // Clear virtual offset .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 + .macro __init_el2_debug mrs x1, id_aa64dfr0_el1 ubfx x0, x1, #ID_AA64DFR0_EL1_PMUVer_SHIFT, #4 @@ -103,8 +111,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) @@ -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 Sat Oct 4 17:34:15 2025 Received: from mail-wm1-f49.google.com (mail-wm1-f49.google.com [209.85.128.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 E71213314CC for ; Mon, 1 Sep 2025 12:41:58 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.49 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1756730521; cv=none; b=EAxf+pvWsG0K3eVdR3PI/shRfeXzvl9eo7C2u8Cs0191z9tWYcjK95FxFA9GHUxb+Vfu3zqDt0JKV2/pbdIsVH9w6Y0ycMtS8ArMr5dCmXhxkahANKbDK9O5W38Bmipe9RGKoFGcUVOWXZ7E8NFbdi50FBK2lsgk71YhblxU/uc= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1756730521; c=relaxed/simple; bh=hHJpIJlIFEz6CSYyOaizP0+u4TVXaro/PALZLQfLUyE=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=LL+Eg8UpW6N+0yNym49dDYuYn2E4OpGCex3HRM1e8qH7APcgRETjc9dGFrIEL4JS+pXJ8A7NJjcIz2c5+x5FtLlhA8U/Mnxfkn+41xkYsbhgc9IW59iF0RXoxJMs9jCyVwu0ytIVUwxwP8O77Mt3bSQwNZsVr61NV8bUuNMQNBs= 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=tGzKKMuN; arc=none smtp.client-ip=209.85.128.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="tGzKKMuN" Received: by mail-wm1-f49.google.com with SMTP id 5b1f17b1804b1-45b7d87b90fso27015075e9.0 for ; Mon, 01 Sep 2025 05:41:58 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1756730517; x=1757335317; 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=OSNn3QEar0+QuKyDmtURSQ4BVOB8JOPxQiblvR548LM=; b=tGzKKMuN73bqybJ2SbOIMdNZ5i0hurffWI2ph4yCsvcjkKuUgQRkQnAYCoLXqrtJrW jPKjr8djh9GiXy1bDxU4raXSsIyDhfsAKIOLvkukL62QTMLJ/x6MAl3HzZ8TJhl4m2Tm sqYjF0CToRzrFZkWAUfsLnPtgiG9+UZJ6btzX8f9pjbU/v6JtIjnbRtfUf1eMk5QYQZA pfd2ZiBb2/+gghHp0YRrxu1t6WnSxo7aBY4pVjzd0J8Cof+15AKB1HTrvIhFXJP4ZmI5 DryN9SHDlS1f0Eq9GjiaygkqxHSK2GTyGgRFZfMaesSGgovF+OptRgA3EsARfZ/SPHyG aAgg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1756730517; x=1757335317; 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=OSNn3QEar0+QuKyDmtURSQ4BVOB8JOPxQiblvR548LM=; b=eFNrVPL4EYcbtJNdRDeIwT5rlYMgCsvgiTJZ+scY9SQgmMuK9WSbyJ8itd5sMM/lII 09dFdikTP7s6F/a2RA2HaHubDPIbhuiaXKggmcZxygaeGnzJZCpDD3blvzfPCP7A4/2A cUcRyTHMS31XuUSYH4eGdLuxUejnriIuU5R6ltV907DSQp39HQhIPW/Usj+810StPs7G 4Xmga6+RmSO/MQ1ibzT+bDfiA/EGNr9p7pKzBWRTC5WeDaw2zvtDOfIKYrDdokqTNWAX UUKXlSvlZzY8C2lhL0EZ3SzoyWRjMXv3WoWoxW/J25DHQFzj4RyisAkTy81PPm8urgHQ FKXg== X-Forwarded-Encrypted: i=1; AJvYcCXS65hsk0ZiUwYN+IoC/f55F6bdAXg1CZMhhOE2Uxb/RScPEHXPHz0D+9IhHPwqfYNZIut3AVgt+SwFaOQ=@vger.kernel.org X-Gm-Message-State: AOJu0YzNbqxSPUOkZljJ9r3ls267NLbHQZDm91s++HNnpIE1/bjKQCYe bmlYl4NYtZPsxIaxPV10Ge/0hmjuHbfvINGgmRCqCtzRr/e5DPr+yE97JiNWZgQQ5wE= X-Gm-Gg: ASbGncv6gTtTSwE+D1WLY3LfKDcO6QH7oUNYftkF0AuhGooYdCqiisQxNBHfQ2RxiFm qyQOC2g4HFq+gHSqqxgmJFldSaDMEYYhyedwvBy6i7RDkz8eu7X51OekmAP6sVlzKzuFp46nsDI +zhOeiPIYZaJvFFIth+hd5BZvu/F0ryCuaa62m9bjT6yhgpTcaiGa10Gk0LO3KnhsOKHihGNFRV YgE+R6d2FwBfKqQveL99t75QBwJbZe2tJnzM3D15HRRyau3iCAyCMlK5W9/WrNiETUMnUok7kXX TnabyoBuDSP7uQZOwcEEoIKACjqRewjO44Tk2mnug2yiE5b6S5vSOk7U7rZMEh9a3trvq0nbcnF i4wQ1rwO9vyKajTv4OK7A6y6HDL8sPqCn6jKLgAYNDEFgvB+RDPUB X-Google-Smtp-Source: AGHT+IFhQWkNlLbN+/KIksY266G8T+wNBjSFtPM3Dq8DGWiTprcVcLD3OEdLOpKY4eMNn6tRYHKpVg== X-Received: by 2002:a05:600c:810c:b0:45b:92a6:63e3 with SMTP id 5b1f17b1804b1-45b92a665f4mr3191135e9.9.1756730517057; Mon, 01 Sep 2025 05:41:57 -0700 (PDT) Received: from ho-tower-lan.lan ([185.48.76.109]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-45b7e898b99sm154946315e9.19.2025.09.01.05.41.55 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 01 Sep 2025 05:41:56 -0700 (PDT) From: James Clark Date: Mon, 01 Sep 2025 13:40:35 +0100 Subject: [PATCH v8 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: <20250901-james-perf-feat_spe_eft-v8-6-2e2738f24559@linaro.org> References: <20250901-james-perf-feat_spe_eft-v8-0-2e2738f24559@linaro.org> In-Reply-To: <20250901-james-perf-feat_spe_eft-v8-0-2e2738f24559@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. Tested-by: Leo Yan Reviewed-by: Leo Yan Signed-off-by: James Clark --- 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 a305386eb2e3..b37da3ee8529 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 of PMSDSFR to EL2. */ + 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 Sat Oct 4 17:34:15 2025 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 2BE3733438B for ; Mon, 1 Sep 2025 12:42:00 +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=1756730522; cv=none; b=Ohlptp1C7WfV3nNOMybqzZmo0q7KiQPIVreE2bpI1o85cEtOSATwg7PJjw6SxTPCxnEX7CV1ZCEeOQc+tQJHwlrFpIVvw8rAZjs7Rg9q6Ede7NLenHFIBYkX4dbDdoYcwQeXD8gS7kfkNszqAV9oW0cSQwXpPuXZCkLh4so9/50= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1756730522; c=relaxed/simple; bh=CrtUTDi45Qns4EGcNkps9RWbCufp7alE0/jGYmVMHDE=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=rlFzCzBtRn+egyq+MSYa5xTrgQpSDduWaeWLKIl+jW1vaTM7pLeh7gb3Nc/dksUcop8dRBjh2bMrn01gED5RdBx5vauv34LhqSLd2GC04uQSqKzN/MunV82oVr20a9idkSlcBp2MuJaDABJ7qNxdcFJGVuOY2TLu4fVENrqImwY= 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=VVa7P+mX; 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="VVa7P+mX" Received: by mail-wm1-f54.google.com with SMTP id 5b1f17b1804b1-45b873a2092so15261455e9.1 for ; Mon, 01 Sep 2025 05:41:59 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1756730518; x=1757335318; 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=roHZTPEwCGJoEFzevhfwMCKmJqGfJWiT+6yPYuF1kKY=; b=VVa7P+mXvPA6KblTmWgTBWqU2VFhG1epBpozYO4eQE9Vnk7myZaDUKSslTH9K1L56s v/n4GiTpsmnWU2omHc0WG5PwpxnY3kfQQMH/2neOZx4j+un0KA1G8dYPnIckkWRw4Epq ko29dLX9437Fm96pf1DJQp9CgHwPnnZ5Ptl6EQLY9VhDc4+sQ+CNDTI5Vdz3wfPwvuYY cnxYl+Z3VJ3CuhCWMFuK0pyXnZ4v96PqeFDo/n0nQ0Xe5MzpMzzPqSZx5lwC/E9pns50 6rQWd9BXuJFLV1tT6U8eO9YJj0ekktZQYAdD3i/f/RSztWajY89/E/iRMC/IojPqdrZ6 INFA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1756730518; x=1757335318; 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=roHZTPEwCGJoEFzevhfwMCKmJqGfJWiT+6yPYuF1kKY=; b=bRsdUFUEO92rDX7jFuRWL7DJSmX8C/BgTwW+OkO6qwuuUoRt97EwGserkKGol5efiV pFkNQLIvB39zEu7jo3vRiJBbtgrv7zaNh7ulQUy9UBfYiIv6WfIoYek1YBIpUY5jOJ4J vmPn4RV1125Wh6b8Lr67v/AYi4psAa4AZRDy3/I0ivKpBIm6uHygHr9q8Y3rr17u2XMG qMp8yg2y4WXk1OSiDxNdBlDRRzP/BYgNnVHna0O7F+uoyrrbozumNElati0d6npSNij6 0/xTHQDAzTlw4gDXqF5Tq9icEL6yltMhFwLUY0b1sDLtH5hhhEriD2iYL+62z8CcpI5B 5+mQ== X-Forwarded-Encrypted: i=1; AJvYcCXHU/FVLaG4ae8bm1MyqTQhYMURohL99iva01P8cZjIwQGVGMIfScAXK++aN58glhTqxMSLObhdwNJxz4A=@vger.kernel.org X-Gm-Message-State: AOJu0YxsHU3yjdiE4W5xLRcfXrOw28eY9bxp40nayWjCsKTsy4qe6u3/ 5euOVO8/rWGZ3r6V21x0ed4TLFKT+U+zKbgEdO/HOLi7GRR6htoTO5ImWgukmJ5wMt0= X-Gm-Gg: ASbGncvzktNnwGHypHlBHQpB4S83qlLsnTJaP3JQyA6JF5rkjccZhy3rthl+uD1MEw/ wDtylc1/F638bqEnnsFlJ4ColLk7/f82MqdH+j2bUgRaLwb54FPFO4KnrRvBK4u59y6dcNS4emH CN6GYs5KLjr4wbsiBQIZ2mJCYxnrCiBB7cRGntWdExrN0fn/cYnhZfehUlZXdKrd6UtZ+SP3cba RWLS2oPa2rWRp83eaCZqTp0jcBJwKuKmsWjOAfY8turuSD5Wr3b+zU79POsWeieT9OuLMsQqCIc Y4bX7Z5kHUrSLh/FcwParlfY1vKVcpYHTA0O4WIhbvS0h6uQuMQoeBcS5O3Io6zTEuafQF1SnBw D4Hzd3uM1qf9qKSR/BQgo9UIHWL3ka+DSvW6triU2qg== X-Google-Smtp-Source: AGHT+IEYsYRoLgxLqyTVy0NzxTp86n2JBRtVW7sZ408sdKUcLSuGVXIbslWs4Mhg9uhS8qt4f2Cbrg== X-Received: by 2002:a05:600c:19ca:b0:45b:8aad:d604 with SMTP id 5b1f17b1804b1-45b8aadd867mr37637205e9.33.1756730518458; Mon, 01 Sep 2025 05:41:58 -0700 (PDT) Received: from ho-tower-lan.lan ([185.48.76.109]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-45b7e898b99sm154946315e9.19.2025.09.01.05.41.57 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 01 Sep 2025 05:41:58 -0700 (PDT) From: James Clark Date: Mon, 01 Sep 2025 13:40:36 +0100 Subject: [PATCH v8 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: <20250901-james-perf-feat_spe_eft-v8-7-2e2738f24559@linaro.org> References: <20250901-james-perf-feat_spe_eft-v8-0-2e2738f24559@linaro.org> In-Reply-To: <20250901-james-perf-feat_spe_eft-v8-0-2e2738f24559@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. Tested-by: Leo Yan Signed-off-by: James Clark --- 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 af69c897c2c3..834f13fb1fb7 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 b29f72478a50..4732ee1ad7fd 100644 --- a/arch/arm64/kvm/sys_regs.c +++ b/arch/arm64/kvm/sys_regs.c @@ -3238,6 +3238,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 Sat Oct 4 17:34:15 2025 Received: from mail-wm1-f51.google.com (mail-wm1-f51.google.com [209.85.128.51]) (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 C7D1D334739 for ; Mon, 1 Sep 2025 12:42:01 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.51 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1756730524; cv=none; b=CznqHABc8ma7S85gAl8p2qa2A5OCdQ85aV8lljMARMNvWUXWq1BzY2K2HRz6p1zJ7P6SWwMsWRIq27oySInkz+3wqB05h05uiuR7m2krRf+t+iaaTyc9Q5vPrhHvHZrW62XtL4KQLZBQ+6PztHPRyojCoCjGwCw18fof0t477KQ= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1756730524; 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=UtQNf9O3vbIKlnDQCqmR03qhl7ZQITLCgET1KIBSIx/cDMLwi0WxN/ZpFD75XrvMFB2HRIjKePYRzoFTrMR8TMxX/DIhp7cuRRQ1qrZkKIV/3aqYhAVwkiaQnEvjnhxWDYDC2FwZJpH9z/1M8eJBMkNX70B+OPJ9ljS8KPwaA1Q= 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=hohsdAT8; arc=none smtp.client-ip=209.85.128.51 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="hohsdAT8" Received: by mail-wm1-f51.google.com with SMTP id 5b1f17b1804b1-45b8b02dd14so6794155e9.1 for ; Mon, 01 Sep 2025 05:42:01 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1756730520; x=1757335320; 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=hohsdAT88bofCDMmitFNT/Kz+f8rgI/d/lT7I1OUgzfb20Z4ilH2/dj/AODXjxVX68 k/S7JrtFSM0oYX2FBn7sGq+IKPfv8XhG6H7OCr8OXhojKf6Iv2phk+pTZ3JxPSpqakMm bxzV/sg0m+IqLTjFGGd3PD4QBlZykfd5fgv+uJl0QFb0Fxwe8xH5rshyPeZLVhVUWZqd AO/L+6LIivmq5syeDBuvcoRH3o5z0v2XEVi0OxccMPB1Jjsh/5H2b6wZrZ3kvAw0PQ51 dfIsKo7i/pOlCLesRukCpZwBCtA11DqlKNqWNAhTvvYjpE1mWMBsiBMixi/7X8TyX6qP TZlw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1756730520; x=1757335320; 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=vQkb1nCsfgxQ87oMWycbFZo7iFRh2CH6umX8TH4Q+GbDFnhOKONFmsWjLbFQUK0TWY DDg8WcnroxdB7S/5Y51AvXl1jE4Tz18CfnVA9TxytlzwpT+tX+mPOPm3FdUWuLmaZBlF smIkFR//giHFCWa15jbcVJ7yMkhOBOV8Lm/9SR8GY5rt0fW/gd21RzBHdbhZ9aLkl7rl 4L4LGBzl0vz4Hna6Kxvb96mzIp2WXQMurBPe4RPlLoCtG3Vmm5rvThxu5/9hDzMLMXVP /pItent6W2XWNvr7VNNe6SWGpfb7xVIlerScRAsczJ8BQQ/jbsmemXrhinqz87lMZiGE QWWg== X-Forwarded-Encrypted: i=1; AJvYcCV0xmdH+ETwnsBwbGnl5/dOfmjLDH6TxMJ1o6BKMe5S4BGF/xcLVxoNCDwfGhGlZ+sFU5+LHjzClIMXydY=@vger.kernel.org X-Gm-Message-State: AOJu0YyvWi6Z/p1Ga3vpnmaAO4jhcALw+lAR7Ypam0OQvOyMaASFYEEn 7AcXSTYwBtx9bgqox8W5s3ZTAnbQO7ZHDPtRQCCTNmDfalig4aAR6ipiTvWOUJeHgUk= X-Gm-Gg: ASbGncvNT7JOib+nfOFI5DC2Ng3qH7EQIFEXICCaK6HcRsuyV213jl9oExMNkMxHrTR seg1pCrUWmdmkMOc2gxVudBEts2BepnFEe2VlnpTlbvQPVg3MTVLjsMGnBBuHpPWRAO05hmQb3e FfFY1YyRawmBAz4iw1/a9GalHbgO6VGbfThdTFMC9Wr0oWgm558tbx86zbjfnYt4NinDnt8iCAy MdiKge9vKmOhEB2BcV/iR4JLo6enzV+ZGR1mRPLxyonl6Km+3YfRCOKRvq4XsKE+H0CdaRcf5yk nLJj+h1A2g9OrMyXqFSGSzFwpBHdNcfb7vn+J2sVyrSHsmt/A80xJXyJLIMY8O0k/92DXBCP6h9 cejpjC4DFcZjCn5OEb/uDf4+Cizg9JrYqPc+DVWAkRw== X-Google-Smtp-Source: AGHT+IFPTd5JV8rlNw+el2iMeq4VwQ39O/JeQnoM1FnI5OWoImn9QUGVjCoJJX8IN0HGzcTQOolA/Q== X-Received: by 2002:a05:600c:4f89:b0:45b:8d2a:cce7 with SMTP id 5b1f17b1804b1-45b8e2ee782mr21104445e9.15.1756730519938; Mon, 01 Sep 2025 05:41:59 -0700 (PDT) Received: from ho-tower-lan.lan ([185.48.76.109]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-45b7e898b99sm154946315e9.19.2025.09.01.05.41.58 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 01 Sep 2025 05:41:59 -0700 (PDT) From: James Clark Date: Mon, 01 Sep 2025 13:40:37 +0100 Subject: [PATCH v8 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: <20250901-james-perf-feat_spe_eft-v8-8-2e2738f24559@linaro.org> References: <20250901-james-perf-feat_spe_eft-v8-0-2e2738f24559@linaro.org> In-Reply-To: <20250901-james-perf-feat_spe_eft-v8-0-2e2738f24559@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 Sat Oct 4 17:34:15 2025 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 4422E3375BE for ; Mon, 1 Sep 2025 12:42:03 +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=1756730525; cv=none; b=JsSscDyhH3EuQCagoPtXmDpVxkAGgJSQ360Ela0vp6nF3tz192pRbrAdJwuUJAIGoWkv8scEHSkQ5ao9h8VWTlTSizVhrVWeQbPQF5e+RJEqRCjE1Lv5OTc28mk95XECmgehITqv/XF5TjwgS5hKKvHfjALrbIJjksMj9t6B5e4= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1756730525; c=relaxed/simple; bh=RVZayCp5OixCPVRZdJVQFNOqw4c7KtixASsd5Xntv6I=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=IBqJHWmjHHenh4r4rru/1we+NR5Ppv1gEvZ2xEtoGsnVk1Yz/pW01Ukb7S2Pk9Neew1X0HRXsUx9BLr0LLH+bqXJ01ybR5EHkw7ku2VHNgsEG6tRFh5LR0dKDAvn+6CEXFsVDjiFJYDCO7e8R3GW+xqRx1RZLfICKD9VpFPjsnY= 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=JGg6Dgzr; 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="JGg6Dgzr" Received: by mail-wm1-f54.google.com with SMTP id 5b1f17b1804b1-45b89147cfbso12304015e9.3 for ; Mon, 01 Sep 2025 05:42:02 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1756730521; x=1757335321; 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=0gYBkgwI12gbrT5fDRBP0jl2MaqA4H2/njWa7gROlbw=; b=JGg6Dgzr8QenlZQaXSCa3yYHRp2AaPCAzXqBuifGfnEnjcwuxnzCH2wtdJnGwRxMbT Jy/i0Qwc3wGpMuGnWpBIRbOblBHLie4crYsxwEotQEvryGXDMWmhzF/jJtUD+2k2d/RH tESdSYU6XNs5TJTMnmsVKT8pvQAiqXrXHqfnmrNAj8AlEzovL3/k1oS0tTuEJfJnMv4l cdB0FkV9XQcT+ngfFE93TWbyQcU1Srgcu7u0Cqgq5qnUzVLQkotc9EHrhmKiQW6Ea0k4 n7rvAbzM1oDqDZvE1j5UomXp8/hl/xULe53bRlLy07rePqAvhJZLbS2yvTUob3ackGlC CEPQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1756730521; x=1757335321; 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=0gYBkgwI12gbrT5fDRBP0jl2MaqA4H2/njWa7gROlbw=; b=Cxdkcf09C12FRRew+wcR97fsw61jSCiEmlxJhXuZehQ+KakC+OobH4Lwu7ouZBDoXR cwFSpMM1WBpP+h02xg013OV4UwejUYWGLY0Ua7VnXj4tVpVZwPGZs8rY++iD2oUe6j8C LgToQhz9+N1s3GUhSbwN7GtbWe3P8YsiswW18OszmfBJ17IXset10yv76j7MnkxQYwhM 5i0D7MkhhBkCiGKIKZa1f01YBhm+Txrny+uM7BMURxMakQJEopANKxj3PpNmt/dKCESO RcP7BeMeff/7TjhWGuDFWT5vwiujPL4oGnraL5jB3Obyh55liKiVkrgi+f9d8fhk5tVs a+tA== X-Forwarded-Encrypted: i=1; AJvYcCUwPVj0SDXco2BeTXQu/5KEKkQQheG61dpuI9a4KHAK/oILYBD45h+bSYJD31tD4mx6pN1vyUZBLNfy514=@vger.kernel.org X-Gm-Message-State: AOJu0YzbJrtHu6S8RyySk8Kb8IWELTI6pU/ZYOCjsLxyjBKsR/eZpZe0 dpPG6AtnQ6wT/uETBZuH84S/UOJ48ehZMufjVb/rZ9YQocD2CYj7btnsB9+19aiKrzc= X-Gm-Gg: ASbGncslRhmEMk7XoGi7I9gkR9bKvY1a9Mr68nPFDzUt1cs9nwU0fw2tmvfsKpJsukc TFR9p1TkQGQwMHAzVxnswPZ641xCPxeYXz3+x/Ni4ViusTYQdnhlXLQDeFFjZPgAw+KwKrGMIUC dwam0mKcBr5evpFvcJYeCoSABOBCE/E2zz/aHyr9if379yUJg25SuNDHa/oPzOZrelf0Zc5EGs8 Xf6BcEHZLoPjkrMwPHgdNI5MShNhtdRrLtiAVFtfrm+Jj6xJXeswKCBrdPMNjCZTvcmm+YMMB4A a0kr8wgzEBW2DyU5f4TBaaB3iBuLHLQH5l46zbpXmHyTGsEj03IAh9HVBqYQT+A3L1O9zP9KkDw HJ6+BUQ7NBw0GY3qKFbFZhTw8N9XTBGl3+KSCAk4fIA== X-Google-Smtp-Source: AGHT+IGtybtA43LzaX+nZGwbXW5Im33x1sTdapVn9uZpGYduxlJ52+DycNYLVsJKQ1mPUhW2aRJdHA== X-Received: by 2002:a05:600c:1d24:b0:45b:581c:ad0d with SMTP id 5b1f17b1804b1-45b85550679mr68872005e9.8.1756730521322; Mon, 01 Sep 2025 05:42:01 -0700 (PDT) Received: from ho-tower-lan.lan ([185.48.76.109]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-45b7e898b99sm154946315e9.19.2025.09.01.05.42.00 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 01 Sep 2025 05:42:00 -0700 (PDT) From: James Clark Date: Mon, 01 Sep 2025 13:40:38 +0100 Subject: [PATCH v8 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: <20250901-james-perf-feat_spe_eft-v8-9-2e2738f24559@linaro.org> References: <20250901-james-perf-feat_spe_eft-v8-0-2e2738f24559@linaro.org> In-Reply-To: <20250901-james-perf-feat_spe_eft-v8-0-2e2738f24559@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. Tested-by: Leo Yan Reviewed-by: Leo Yan Signed-off-by: James Clark --- 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 Sat Oct 4 17:34:15 2025 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 81FBA31DDAE for ; Mon, 1 Sep 2025 12:42:04 +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=1756730526; cv=none; b=lvzDEAoL8BvvoMZSaiQTkjU7qQ6rsnkbBSv+XYZb5XG3x1B2QKH7q200Ji0Lg0Y/qBvSY4JYIm0ab0L6k6N6hQLNf9y80tVRcTTuuB5bbcHcPjwzg0HPUhHf2nsz5GhiGZKHHFedmoL331miO43g6+p6DAQ0NIue5cmK644/Sik= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1756730526; c=relaxed/simple; bh=b/ttJae4xiEHONrSB61gWYPCVcnCnqIpQyNKL5V/Pqw=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=p0lPrXVj5bmo9bfTwcj4d8oFTqoPqPjvRb0nNY0VMaovs3zEHhLsb/wYyTsoJa5x/aYtntcDXSttDGl0WFYAuHsqcXn9S7uruOYsHaIvRY6sCEt6SD1sizu4tT3utWRJDV7Smak2D/rtVymtr3pteAZVbUUOGsT7NGWNgakN1VU= 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=qQqmXfcM; 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="qQqmXfcM" Received: by mail-wm1-f48.google.com with SMTP id 5b1f17b1804b1-45b83ae1734so15460645e9.0 for ; Mon, 01 Sep 2025 05:42:04 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1756730523; x=1757335323; 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=qQqmXfcMxUNaX1Otr4NfZ1ITH3q8jsS0Z1PkbYY2wroS/Nc7HlmT67nrUX9O3uBqls ikmXz+QZUtibNm7YTeAu9m6qMpUcXEfN2vFCl/StynxK3nSWETLElHDHoS7gOldtkysn E81Ta2DoCPUfd05HC8JgJFt74/PYnHFePiE8FzWaW12g66LofHX6n01ZOqe+x7aUGXwT Q4LZ9L7olhyQPOnrs5lPoVA4DxuPjBP0uEOKEqWj+BV8z1JwjufJKPcE6qGMJs5dmocQ boRN/BJvbfIbK0NU0W5aUE9uFilbkAuCNQKly9MRJ/jIg6wxDsE9OqSEZLkRCpzJWK97 vs4w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1756730523; x=1757335323; 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=mdIN8Wn0HJyqTTTPWf2/jd6eJCV1RcnbDC4Dr15I2TXH+mfXq68SMK0MMz6cC6YeDs 14dfQFTv1qEFBMK+iDNUSJn+aZVvu2hEVQRyzOhAJ7EACY3oTYKMIleNFAR730aQfkXd 1744u9StFc6CYvHCQWLVPinSMACLBB6Ir6r4/RGh/NhSDr8/b61bqA1FhlKmO+x5g0NN nLZNeaMxDC3FX/l9WSAOeO9yy2eB1tf18KyXK/UarfmOmlmHNqlewkQO/QArWmGp42rD 3YjLK+R2J7ayofBVPf0bit0f2MOnLBFT5V4gfk/i6KozcYf1SDKAQq7N/UpAVMiIhp+l P+Og== X-Forwarded-Encrypted: i=1; AJvYcCUb65zpL8dPtyHR2oiq/FFaH4XI2z/6dBzynAzAt0fLCoHB+JGE2A+bv7mgIHu0aDEijAm2Xq/5sRvc2VQ=@vger.kernel.org X-Gm-Message-State: AOJu0YxhPTu/icWBTl01OBCQ+HVO+VSRHyWYwELMK7y0kZRBuNG/bdSt rjyNGCxIgpaWqDmpzdG/vIq3WPQK8smC7ju5ADtVw7mXMs+Ptqx0OEZMP1946RsSATM= X-Gm-Gg: ASbGncu5v9dAyylVDZZopyHQ5PylzjJcRdH/cfOGeYZYLQ17/k9JrmCnjno3vEuhryB 4M9xu5LbnBahLEIWKt7dBSLfsLPxR+HJSqFabtDsPuMX31y4vgtKprZ/CDDxOWee94mnTOQMQju ZEONfejRi1sdkzI1IQiC+X5hGpqjQP259d2htITOciB2g/QfbSshsarC1P0aX/9YeXG49zBy+r5 tbk8L3eRtNjbxEOkluTs2vfN5wr9DWIg7mv+K0QlfyYT23VRbyPh+276ZpYPcWbY6Cbigq9DdLo mG54TU/QnoBdTrMMQ33XManv+6gd0hJ/YUOQSHAlpvWPItNcmcNmT82+gBu27E0Z2Y+Q93LmuB7 1CqO8XbBVj2S9S+ZyHE9fON2zrUWuhlQ= X-Google-Smtp-Source: AGHT+IEQj3GrkfSjpxyNOrXOZvvlmQ+TSw4g8/XmWwPgGUWH337/Zp0pT39A7m8T0jFPe3YqQi07Lg== X-Received: by 2002:a05:600c:46c6:b0:45b:84b1:b409 with SMTP id 5b1f17b1804b1-45b855ad0b0mr80544675e9.30.1756730522690; Mon, 01 Sep 2025 05:42:02 -0700 (PDT) Received: from ho-tower-lan.lan ([185.48.76.109]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-45b7e898b99sm154946315e9.19.2025.09.01.05.42.01 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 01 Sep 2025 05:42:02 -0700 (PDT) From: James Clark Date: Mon, 01 Sep 2025 13:40:39 +0100 Subject: [PATCH v8 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: <20250901-james-perf-feat_spe_eft-v8-10-2e2738f24559@linaro.org> References: <20250901-james-perf-feat_spe_eft-v8-0-2e2738f24559@linaro.org> In-Reply-To: <20250901-james-perf-feat_spe_eft-v8-0-2e2738f24559@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 Sat Oct 4 17:34:15 2025 Received: from mail-wm1-f42.google.com (mail-wm1-f42.google.com [209.85.128.42]) (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 2F2EE24DCF9 for ; Mon, 1 Sep 2025 12:42:06 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.42 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1756730528; cv=none; b=rQpW2JA5XVCExfxIW9mwFu9wlPMggcPmFamWhnuzUgCbZpyo9w6ryLYV7HWJYX7v4/btZiGSLziEYFrVnsC8Pb9++E+SuGtqO5RZeGEWAmMKRZ6HcO7OY8WL2Nnv32iUsDyxJ3ldowRpXEiZlX2LCiG74WQPCkC2p5EkOMlGFGQ= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1756730528; 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=kzSXI+d9YPFDvhfk1hJNUMjBKDXaNiluluoukYp5JTMKUxlWJceaR6rlS43tGgjEDJ3FIRCKeNbIjbU22V5NepNE97gVvdiQCs5zT9ZtSImIJQnpDKHyvaEAzXovsESHsl4ZvtINEkt5zAET8rguVrsbUMWWCDlwpXSN3l/kuMw= 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=CGfTSURF; arc=none smtp.client-ip=209.85.128.42 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="CGfTSURF" Received: by mail-wm1-f42.google.com with SMTP id 5b1f17b1804b1-45b8b1a104cso10703565e9.2 for ; Mon, 01 Sep 2025 05:42:05 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1756730524; x=1757335324; 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=CGfTSURFDatYaImKOnPdEfQZkGFxeTxQzM5p5r8wlaBySirnfq/CZ+Fa5AhmuJtDM1 ecMQP6CNH5tf0ScCMEZwD53gFa2EpOdgxFhpQfRKzjcfrbgC/vtADp1zOo5qFkXdNbaa UlY4+Mgs3OFPpT0xCqMaNOb9NOTIblYfFBmuexcynuIwkSdr9mHJ5p++iXBaau4eg7tU Chgc1RdrUs8h/us4yerv94k2FuohK0N2IkC5E2TfaEBxNALXK5i2eowIhLK5BmA1WgAK 8y/+qoNuLpxnnMdUAEOCN2EVDjyKmX/3WzUek8NMhbxrMAKKYkGC6EdOwRFRI8VuNmnf 5h2Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1756730524; x=1757335324; 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=AlPfWZPJsjVgWzGUSvKhpZzKOqNz/nrD/chV19wbIJgwmXdp66AMZYhfSYfqMh6emP dFcTH5x8be3XKjqhyHlyKfuix3CjuU0HKJqKD7UbJAn18RbXtEc61TzPerM5gw59v842 zej3MhJGtPnsbsi7CzRBfwGNYFYZ+P3LT43ooaFbzN36QnhPCGL5eJpCUARqZTM5gtbu yihSbG7ll9rUje+fV480vj1cquTN9liJJQ/6ae6F0dIMVP6jOVw0ZBOoSP3QBRX0HKBT uuPjVLDdlgALItb3EbgkfxzIVoSBRZesqGe8Gfy4agkfKRw9W2mgXJnewVRYie8Cl08x fUvw== X-Forwarded-Encrypted: i=1; AJvYcCVjsWfc0sbx7WKXpc6Phis9BdJ8NdfQ+40fyj8k9b01sw4eEAv1NU9MBJz5wBWwLtMPP2irJFFtqvUt43E=@vger.kernel.org X-Gm-Message-State: AOJu0YzpIuvS5Kpd+nBcWKGB5mhabGh1lo9K8uQ+eEhSXhe1+WqhgZ56 eyw7yNpLeXQkI4enE2nB/0/5Bgo9pKRmj0I0i8sqIyCUFjjFmL9Z2SIJsiJqs9P1IFs= X-Gm-Gg: ASbGnctvjQemOWpn4AXApnFCJSTzHiOT1YanAU097QotQxR3grFwdauzS0tNrRCQilq PE/oGbR//pgFyPL1dKigIvIML4xYJG/GzTypjsQZMT06RxlLkCm5TyerQi0m6PWGwN+6ayhdx7w u67JJF45hYs/0Y8rC3YAQAXl+q7pu20wKL67Sun6VDFLWcegX6k1Piv6eugrA6rBPvRlip8wij8 950dKaRhM1OsjO2IHnUcZTnhbsGLQOEAbaYnYK6NBYX+1eUFl1JJ1JcXRP1CZY4oponytgFWRoO yW1PVRNs48LodZmjuZxQQ1Z+qW9/0hNhW1XpKSCotOM/aoY+Rx3S7vCmNU16ZMF5OxsqqNRvY43 O4i+Ge5OiFswYLT4r0SERF+SmE5N5JSEoTFnFe6mQCBpZiSqfNxOI X-Google-Smtp-Source: AGHT+IE3klXttsPiEipLDxL5zv9yhkpRFlRjpdtkt2+C+vyGhe17anthlDt1sMdCiW1RqMpy+xqD7Q== X-Received: by 2002:a05:600c:c162:b0:45b:8352:4475 with SMTP id 5b1f17b1804b1-45b85598a56mr60040715e9.36.1756730524122; Mon, 01 Sep 2025 05:42:04 -0700 (PDT) Received: from ho-tower-lan.lan ([185.48.76.109]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-45b7e898b99sm154946315e9.19.2025.09.01.05.42.02 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 01 Sep 2025 05:42:03 -0700 (PDT) From: James Clark Date: Mon, 01 Sep 2025 13:40:40 +0100 Subject: [PATCH v8 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: <20250901-james-perf-feat_spe_eft-v8-11-2e2738f24559@linaro.org> References: <20250901-james-perf-feat_spe_eft-v8-0-2e2738f24559@linaro.org> In-Reply-To: <20250901-james-perf-feat_spe_eft-v8-0-2e2738f24559@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 Sat Oct 4 17:34:15 2025 Received: from mail-wr1-f46.google.com (mail-wr1-f46.google.com [209.85.221.46]) (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 9111C33A012 for ; Mon, 1 Sep 2025 12:42:07 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.221.46 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1756730530; cv=none; b=oA1V5siQGsmuEmZ8NKgF6hp+9O5WNHqsa3ISRQ0KBnZzJJgWumnWB3Ilq8T5rsWQRrJv3UwcXPUmcnp0cFHuapZFauYsYMej6TEFozxZTmLhIVV+hzlYYbWrc2fDpajro+jfhkkM0dB3lUrQvqQpkMLb/9g9yHuD2swxrBwZS8c= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1756730530; c=relaxed/simple; bh=aRUWGynzXd2I0iPJ8E252lMe7rGfIx7dGynoHirUSWM=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=FdsM/ChxSu5GgHvTilLH5JF5TDZ0e+Pi91zbU/punsn8BcH7ffJ2qNDZPuy+gEdn3JC7VtooT9ghhpXr0+F240rxorxYMtWNZ478WOqc9L6PHVq+iE8Qs6Gtof0jnw1xec65QnebwjkT53I/v3NB250u0s7+n4Qe+ZMELM5sVcw= 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=awmpQBDt; arc=none smtp.client-ip=209.85.221.46 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="awmpQBDt" Received: by mail-wr1-f46.google.com with SMTP id ffacd0b85a97d-3c6abcfd142so2015113f8f.2 for ; Mon, 01 Sep 2025 05:42:07 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1756730526; x=1757335326; 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=awmpQBDt0Gs+Si2vA8Yv362kYmUVDU/Traq2QzQZk2YM/pCVUxWJetJZ7+oBM3CygJ BathBKqud1ge2EFs+aBIh5fVqTa/HRDAVcca2pwYRmn+O32GmTQZb9oOp6APIP26PHwh g8rCf+4pkta3pz1LbbflTl4eOZrl8KAhtdjv3q4DXS/zFz33Readvr7qZqk8EqEJkAOj BUWcUMPbL0VXIYtueqyZtfg21dQ1upJ5P5u8NvZubbB32+DRSkys0o3//ipiClaUCChk HJgdAMo1ZMwUWF0ulagI13u/uBS47/xqDhiFAjZtW0kdqbUKO6erBBb8nEbdQo722wEY kyng== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1756730526; x=1757335326; 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=w2o6dU3Wp7csewVOZJ1I4w/6OMWtHMKmbFDlEJ3kGvLhHq15OHXemlvlBAjiwTB0r3 D2bc6urSVvPhVW0ymjjI1k82Buv1AWC9egKS2o3fuDkCYGgvV9OZpeDsLdZ5cm3BKglS /4BMfOdZd5Fo6Yszpho+bEyf0NEpjApR/yQjiZZfN4UKojGCGkl5CR4r61zUU1NRUiwm miJm+5J/Ed9MNZOtmEYSGdtBr/ko+xpZdK7V5pVwKWHiB/Z4aTgmfcZgrqRXTGbOWDw1 q9Ev/N/hBjurMeMoUA1EkdeJxQYt5sX4SRQvIXBpzvBS0kYsFFldM6xt1tmc7XYchB9Z S6uA== X-Forwarded-Encrypted: i=1; AJvYcCUZssJZxJowpBzsyIRir/XZDVfsTsvuhquZQtJOajREQSkxIe3Im+nBAy6WpaEIJ7XqzKdfjtQpBcz/p/c=@vger.kernel.org X-Gm-Message-State: AOJu0YyoCvllgxKea9CtzqrC6X9aDtkbWZxtaERhq4g8R9u5fh17Dapc BCQ7r4MDl+u124S5Sx5bTRlREJaTFVSyI8NiHqG/5+826d/4FPjnk8HINUrWoeEqGL4= X-Gm-Gg: ASbGnctO0GGUnKjWJaZ3nKX3Mt48N6oX4V283oPv4YkkZFzrosPE+4pDs8De8brvxG+ bdN6bILbvdGSa3clcWCNDhCvXn0BIpclbJzQDXyphA3s+7yb2LH+HANjsIFMbcyBgkc20WNZXv7 9zuxJrsI5gSpMitk+rQtGzOy/AavhjiaiitvLHORuNV7p+XKbXOSLIPPSgKdQf+cKMytvJToLoV FNyGSwTpReObOfvZMDRzxkzklquvnoLLdyeLbWHFofeVXnnWseMQMbJ4+QdDw3G5bRNdl8ZxsW3 zKdiNsi70Xc6Wjm4ORRqwWvO/x1bgQxOtCs3a3+mEqktOAbe4iccCQ77PExQcLrTB7zd/C/K9Kt ZdcwKb7Z4+dG/nddp+ff/SBSnGom2MMnoiuKDPvHjsw== X-Google-Smtp-Source: AGHT+IECaoZy5pvnRAO4teiBa7+xyZAA7FXy5rt2kJAtspzIXhcD7cZ0rCYXN2FiZnTJdu387593uw== X-Received: by 2002:a05:6000:2886:b0:3d7:7def:8424 with SMTP id ffacd0b85a97d-3d77def8cb3mr2256194f8f.24.1756730525586; Mon, 01 Sep 2025 05:42:05 -0700 (PDT) Received: from ho-tower-lan.lan ([185.48.76.109]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-45b7e898b99sm154946315e9.19.2025.09.01.05.42.04 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 01 Sep 2025 05:42:05 -0700 (PDT) From: James Clark Date: Mon, 01 Sep 2025 13:40:41 +0100 Subject: [PATCH v8 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: <20250901-james-perf-feat_spe_eft-v8-12-2e2738f24559@linaro.org> References: <20250901-james-perf-feat_spe_eft-v8-0-2e2738f24559@linaro.org> In-Reply-To: <20250901-james-perf-feat_spe_eft-v8-0-2e2738f24559@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