From nobody Mon Oct 6 13:38:28 2025 Received: from mail-wr1-f50.google.com (mail-wr1-f50.google.com [209.85.221.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 0E8242D8771 for ; Mon, 21 Jul 2025 13:05:11 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.221.50 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1753103113; cv=none; b=AcAQFNeznwmxjXujNVHrkOtJY0NytU2bLg5pRLQixVpgRVKuRYCcU1rdsgG8BYBi5ZiDZ5ant6Fboq+GgMfo/hdgEdXJUHIABpIZQIIQzuFGg2BV0m+WV0zgZwlWKC5X1CF+R1rCOpEMNlSUhL0QVOd03tGqvSkxKquwKbSxKPg= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1753103113; c=relaxed/simple; bh=ajsH4sm5qIk98uVqstoVul55QamJ8yj95QFZdJtL4io=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=ZF99VDrk0bs8kwvW7HlsUEnJLunidN6bfIirR8L9sfsDNvDHmVI2HQETUVHxAjG/j5nXoIGvxAh9Gfpe3M6PcPDEAtoRwpdSaqA02IU3yqLTd/RSrMTyOYtJEUBDvXzkJcF3mDgCWRm1nj0BIVtVJQ6uY/pAnTCfipVKQfSU5UE= 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=Btk3rW9a; arc=none smtp.client-ip=209.85.221.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="Btk3rW9a" Received: by mail-wr1-f50.google.com with SMTP id ffacd0b85a97d-3a6e2d85705so2141336f8f.0 for ; Mon, 21 Jul 2025 06:05:11 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1753103110; x=1753707910; 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=fgBaXSS6eoL+tzDWl4vbvLMipClDtwiPdRYN3wg5eT8=; b=Btk3rW9aWAfCrwcaormqPLZRNf7IPkm8nNVxe7f/iDXNQkO3zjgd14W/Dn0KxScFBt T5Wc1drdZDdPTrk2pmiIM19klMSm3KQY44ZcJTVXiPyoYJ4JN6YshoBxgDy5AyhX7kp3 B+4ZkBl6n+K/Qwh2JaW5YAQUEn76Vvaa+9kXLcn2IZJX+YpU4VwuoRAEF7NvbwE//XOI TmYmbN3gTfSaFKk9fC1e08wExe8+9YN1bSBJpqIQ/aXO8AS676J7XTKYbjWi68bdg01a MXzJYkZZUIDOc1wXKpjW4QiDmZWhdA/OnY1zb+zyyyXq4K5FDN5iiCPTnqY5Bc64+s8t mLLA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1753103110; x=1753707910; 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=fgBaXSS6eoL+tzDWl4vbvLMipClDtwiPdRYN3wg5eT8=; b=OAZoZ5Pj7Jcam8U602iQ8LL+2tul+JUzI5wFMeMBrncI4FyWPmCIZEEp1IgMkDsTbH 3E2ocikUwsuwTZsrYJaTvi6/RkLQY6hmmV3W/l8GxOF8RKe1oT4wQVSf+8EZwL9dFIBJ qTbRCYv1nZuqTH52ttjqewUWO10np7s2acIYmLzASM2o7R4TEQiBZw0PIwd16sc1L7ms AEIYTRWfk1qt4TVRw71CgiS3SKnkFFd/7TexX6uH8nQR10ZeLW+0nGwBtD2EXg/JPerl 7iBwvjjIQ1WyG/oPFKzgmGZ5lSGQgeuOMTxCrzzeE2cik4lrdbuBByi2uRX8p6vBVM7C 1XjQ== X-Forwarded-Encrypted: i=1; AJvYcCUOWrfbvyiTtrxjVP8gDeTnjjsCFGfTxda7GJKDDE8WA1rD55DErxa5fusEx4L/hBuXsgcIePaS+hmu0AE=@vger.kernel.org X-Gm-Message-State: AOJu0Yyn9UBXmsPp9YnvgxUdnlKDz5oWQdzZlx9M+ArrJ8xHL1vWQDZy y8DQM6NSPhznfOurb5/p9fQSujJLDG+OzPrzIi0EvRIsTAvnQ5Oh7UjuakemzdsUDW4= X-Gm-Gg: ASbGncvwe0IoDI9qqYrkOstrk7S5Fsr8mHIard/EMy59AkgkLsvmMTtmgXxVdzc3BbH C8YO2IgetQ6VV7nExaHhiVSJiYexjoFaXlApwrudcQ4y77niXdriWQtxflXFjBUwsscIG+v7lxP YVSPiWFVRjkJfFoZn63ZX7Emvbl0M11Jpc/tAs3ZEdp6d/9H1tCcCxBftlQpoa/Ki+m1LkWK9/t PxjaUCxF/7QQIyKLdd7iNG2YrAa9NmDywBIIupjrJduxkDkBacEuLsxxuVgvtTsObY1dveyCyEi S9ewCb5RgXAZjx9B9JV6OlJYQNKl1RYPkGKO+UBe4hY1aU5/Jgc7B1q3aGnJlX+TqVelNQY1Non yKtjGf6pTSDugiOQ7en5Fa9PBvBkoN5s= X-Google-Smtp-Source: AGHT+IHW55CRAG6BTroVDQBsZVUrLOllfWSe7q6H/nJVZXgEqWqhx0CeR+WIH7uAuxzefIuhCImklQ== X-Received: by 2002:a05:6000:4704:b0:3a6:cfca:efee with SMTP id ffacd0b85a97d-3b60dd6aa5amr15956756f8f.17.1753103110115; Mon, 21 Jul 2025 06:05:10 -0700 (PDT) Received: from ho-tower-lan.lan ([185.48.76.109]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-3b61ca5c632sm10485077f8f.80.2025.07.21.06.05.08 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 21 Jul 2025 06:05:09 -0700 (PDT) From: James Clark Date: Mon, 21 Jul 2025 14:04:55 +0100 Subject: [PATCH v5 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: <20250721-james-perf-feat_spe_eft-v5-1-a7bc533485a1@linaro.org> References: <20250721-james-perf-feat_spe_eft-v5-0-a7bc533485a1@linaro.org> In-Reply-To: <20250721-james-perf-feat_spe_eft-v5-0-a7bc533485a1@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 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, Leo Yan , Anshuman Khandual , 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 8a8cf6874298..2e897d8a4040 100644 --- a/arch/arm64/tools/sysreg +++ b/arch/arm64/tools/sysreg @@ -2859,11 +2859,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 Mon Oct 6 13:38:28 2025 Received: from mail-wr1-f52.google.com (mail-wr1-f52.google.com [209.85.221.52]) (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 AE8942D8DAE for ; Mon, 21 Jul 2025 13:05:13 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.221.52 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1753103115; cv=none; b=UXm+bS9xkPXGGJmdI7ZwFMKqGlBRBCjX8CT0fQZ2MAndDED+gXSsygZwTRqQTd2S+QtFH5qRyNSlf+l15haAtrl1vGTgivmWs3WIBBTRhYxEx6U7OmmI4jQN0w/lMJQBa2VQybzNJhC+/OWkkxpah+lwJkNZSKhNsxwVXr7SG/I= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1753103115; c=relaxed/simple; bh=9AqTDlFlnYNqwgH8WgsUNUI/wAUjnT2DTHCTcxBObsc=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=dyGJ6ECyNKlEc5jeQRMTdb8sNzSMDIMLxhjNk6qIZMZxAmkEvuySfK776oWWTIcNnY+u40ybf9pwHUSYQAwlr3rahia9tvwg9FKyn0aNuA9SBX6fIcaUdvv4RXnEdyqdLdHnp2Nf5EaZ9q/qM/omyFf1W7lZP38g/xH6zbaqVW4= 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=GXgnmiK8; arc=none smtp.client-ip=209.85.221.52 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="GXgnmiK8" Received: by mail-wr1-f52.google.com with SMTP id ffacd0b85a97d-3a6e2d85705so2141364f8f.0 for ; Mon, 21 Jul 2025 06:05:13 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1753103112; x=1753707912; 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=qXkvCvtwQUgO1rzNPbi1g5SXwSvNrlBklFVwiaO7B+s=; b=GXgnmiK87pUGvIIqDHf0qAVHmMTH4+b6K+N+QNhLBjaNQ3zFTZKkwEsMPBqZRYgLyw N5migcPqrPqvTDeSYwkrniWbsepZjSdySv86JE/vOmWsbfOXLkmoQj0RM0mFj6J9Rb25 qxvOlJLepz9/9YcIYDjFaWD+GBqWJxFvu1a/dxwW6m4nEqKBmkdS1EWqzCW24NWoE99q gyVdrkY44VVBFB1n1Bjqy9IuVLhcNoS/BH6A+9aLg+DDyb6YBZ3f1W/QmqzRVA7hcdOx 7Ct89+vFjHbTnoV0Ng5u0vdeY1mBOQP7wZW0LrN52AhefyaXnQ1KTRF5FFodiMXyoLoB RRFQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1753103112; x=1753707912; 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=qXkvCvtwQUgO1rzNPbi1g5SXwSvNrlBklFVwiaO7B+s=; b=AvDF/jhTxUpzsy5h3dayhFt802jikWaxDasoUNDN7fTa2PNqbmRWK4AsEXkRuAVi0h w5ZpGHBHjvzpoFyLrTlOSOFtKDtpqdDOz4eIc0lFlL+bOlGg1I02SKFQBtGa9WcOdCxv osr0Z3qLEeFPoipHuGEM1NmLRqjTLIpeBzzzBFXPd2xSPcPyKb3/XCpi1gP3H7Hzxu1i Ro9YalAALw4LogcamTT+CYwxWjkM4vZWTfrEvIQ6KxyH647EBdYzK2xFmxRzGFu1e91+ WOUWRkgNT67StipErFpaiyKTBukvWXau9oVrRJzptY9yykeHrUEDdDvp/h8E4QvqzkR+ NRLQ== X-Forwarded-Encrypted: i=1; AJvYcCV7h/zJQ7Qzu0rEnbUNfTdFNiCdBt8EXnZTqvJ4+oa5QpxH1wfaYLFlwIsdIYubBpOFIT5PQoXjq4cpPu4=@vger.kernel.org X-Gm-Message-State: AOJu0Ywgs35QJ1AaUC63F2OXSOi03LyFfbjv46Fq4t7EKMi4h4YcRG8f 8ELL/9fG3MeE1VaYpXthohqFqQK1eTFP7lPEsKCbaqeygYkl2us8Cv6Zz1o5iy43XxQ= X-Gm-Gg: ASbGncsIRdHTH8x4Jw17BQ/xqhvA25aRRPCrpJ99jYaLkzm242iXct68c/ocOH7S5P5 eSl35fwF6qPKeAj1Lje6IFzYhSycjCs80cP6jFeVtaoaTrfria+/bBlvOdl9dip+K2i6rtCXa1B oUWaJgaQmimAtbPkxftmzCbuw2ZSj2ZK1AaxXsLl60xP8/QTEoUX9xtM2eyJ9byeO6arflbIkLx xunSBj4kzuu+CWPpXZyfR8dLDKn8H6zAlHC3Pp0DRuvaH6q7jaVqwsaAt5GjmKiEh7B1A9GNdf0 C3Cy6J2vZAFZ7u/bjlELTNpvmpRzb1f+JZBJI8nlu2nCAcd6vofp7EK3zqOtNx2T7SMqM8n5/s2 YUqvuXkhghJIoyVxTwa14rGUsqEnJY7sBfg8f3HnZlA== X-Google-Smtp-Source: AGHT+IEOKee5OpuGt7tH1bwQK4v8AaIvDjs15a7GCVyi12HJzHIaJCx8hnFkkTJ8CZZ7zhxcjRVi2w== X-Received: by 2002:a05:6000:2489:b0:3b5:e244:52f9 with SMTP id ffacd0b85a97d-3b60dd994d3mr15491057f8f.40.1753103111565; Mon, 21 Jul 2025 06:05:11 -0700 (PDT) Received: from ho-tower-lan.lan ([185.48.76.109]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-3b61ca5c632sm10485077f8f.80.2025.07.21.06.05.10 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 21 Jul 2025 06:05:11 -0700 (PDT) From: James Clark Date: Mon, 21 Jul 2025 14:04:56 +0100 Subject: [PATCH v5 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: <20250721-james-perf-feat_spe_eft-v5-2-a7bc533485a1@linaro.org> References: <20250721-james-perf-feat_spe_eft-v5-0-a7bc533485a1@linaro.org> In-Reply-To: <20250721-james-perf-feat_spe_eft-v5-0-a7bc533485a1@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 Cc: linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, linux-perf-users@vger.kernel.org, linux-doc@vger.kernel.org, kvmarm@lists.linux.dev, James Clark X-Mailer: b4 0.14.0 FEAT_SPEv1p4 (optional from Armv8.8) adds some new filter bits and also makes some previously available bits unavailable again e.g: E[30], bit [30] When FEAT_SPEv1p4 is _not_ implemented ... Continuing to hard code the valid filter bits for each version isn't scalable, and it also doesn't work for filter bits that aren't related to SPE version. For example most bits have a further condition: E[15], bit [15] When ... and filtering on event 15 is supported: Whether "filtering on event 15" is implemented or not is only discoverable from the TRM of that specific CPU or by probing PMSEVFR_EL1. Instead of hard coding them, write all 1s to the PMSEVFR_EL1 register and read it back to discover the RES0 bits. Unsupported bits are RAZ/WI so should read as 0s. For any hardware that doesn't strictly follow RAZ/WI for unsupported filters: Any bits that should have been supported in a specific SPE version but now incorrectly appear to be RES0 wouldn't have worked anyway, so it's better to fail to open events that request them rather than behaving unexpectedly. Bits that aren't implemented but also aren't RAZ/WI will be incorrectly reported as supported, but allowing them to be used is harmless. Testing on N1SDP shows the probed RES0 bits to be the same as the hard coded ones. The FVP with SPEv1p4 shows only additional new RES0 bits, i.e. no previously hard coded RES0 bits are missing. Signed-off-by: James Clark --- 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 f1bb0d10c39a..e80207572786 100644 --- a/arch/arm64/include/asm/sysreg.h +++ b/arch/arm64/include/asm/sysreg.h @@ -350,15 +350,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 3efed8839a4e..051ec885318d 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; @@ -693,20 +694,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) { @@ -722,10 +709,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) @@ -1103,6 +1090,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 Mon Oct 6 13:38:28 2025 Received: from mail-wr1-f41.google.com (mail-wr1-f41.google.com [209.85.221.41]) (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 0F2762D949C for ; Mon, 21 Jul 2025 13:05:14 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.221.41 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1753103117; cv=none; b=mMJeRD7HBfDtm11HHyB+T2SSTOjEND85/hCWNBbgFVrJTCdNuU1QYlo/qg3NgB7/x3gp/2V3hckFLSIScOqe9TYDGlRkX+qYOB5v7Qr+Ha5Oah7KmmPkSDZzLCVAHRhdUSM05gtShVrrea/O5eRACMigNmBGpIBdNyp0W5XeNU0= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1753103117; c=relaxed/simple; bh=ioJvhXZDfjEQt2ziDmXFW0nCeOZA32fi0+BXFuZXXMc=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=tp9IoU4K9I0Yo6xXgwFB9wWipoiMrMO+7MciX4zmOnU+gArz2WJfBDQQMql4K60OeM1qq98p0hPBYYKGUYz1YJb3iKgrmDWzKOBbAMr5uvLnF72NhucrOoMWisl1QokTY4Bp9jGieQ/y3kn6SF8aebhF7ex7yEwOvH+Ne/avRZc= 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=QVB3k91v; arc=none smtp.client-ip=209.85.221.41 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="QVB3k91v" Received: by mail-wr1-f41.google.com with SMTP id ffacd0b85a97d-3a536ecbf6fso2509654f8f.2 for ; Mon, 21 Jul 2025 06:05:14 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1753103113; x=1753707913; 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=55PgdiB+GN4B/bQE+c0k9cxCNgbWScuraMcZpMP7YeE=; b=QVB3k91vAt5X0x7iRt0ayPZUdtpHxi0kEISpq/TzDOoOAMe+qcBLAG6yGOdgvD9yfn wcpOik/5tVXd0S4lvue/vLRP5qqN/+NIhGZAGXjGKpat28krTj757muLMq/r4jSPcz59 Qr/KicDF7glSrvUMZCZqAg9ivxuQbX1CZ3sizCZ0VaKQ+dlQkzFIN+qG4XGQ6povyN6+ DTGAq2JJlMcOkeq9RCm9sHJK1a5SIIO7r3pbL/BqWNyYPaOR2TbWmlr9x1UObbtkPvH5 HO7d01/+uS6Sb81tf2fPduyA5SHlJAVuNcdgRkHrWCcqZzofYHpxz2GXHMpRJIRUm6DW qrhQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1753103113; x=1753707913; 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=55PgdiB+GN4B/bQE+c0k9cxCNgbWScuraMcZpMP7YeE=; b=biqvpT97OON38D2erQjft0jegS9VR07SVDhCrnevwhUBrIC/9FkC3EsAoajJyOeJdt fxWoTI9sQaLj78EseyUBqi0G2CHEyRjOeK48HUjr+GK6Hi3JE+Kua/oPt0mI/ouxQ6hz jCH3QPDXHL8wjJuD818s5MmhlP9SmsqV67g29peAPfM6Xd1NzjVR+gsNnG9ugBvQ90zk ERXbcOcsfSY9Cu7RiLcUYDREw+nypjfaRgLYvm2NbBdfksfseCGTY0RN5WVkHd19I8Dj 1XliC+dh4yaMUHgN0ofdj1qyoiyH8lSAH6twyfmoAJkDN89yz7jCMVIB5u/1zXPE6Mci QPkg== X-Forwarded-Encrypted: i=1; AJvYcCXK70KtooMpqOVF+0NBLCNVVGvPQUVy9TICOczNL9F9xZeIe91+9gorqWo+RwBpJNqD6s1MSFq0zTtiOY0=@vger.kernel.org X-Gm-Message-State: AOJu0YwAG56otaAS7jh3JXpjWRPpe9CiYS+mWcR4JtCy5lf5vUmNV6Nb Uwb5yfY5U7L+prWlHA0jdG72JMBCUHpqZID3fqSMuiGfDEYF4fjIHeUb+sKEFbTiPe8= X-Gm-Gg: ASbGncuJYW3D6QVPH65Efi56hO7pDbQYCdKap+5l6nYAjvF++mHQctxolu83LqDNK4O TJxehhV4suHOpVA4L4Z2BJSzB+fXo02KmnWhb2gQ6/n9mykM4kHXYKQUAqEZENzbwq9akfdpstj xYycv3bxP5KMgqLy8lgPsrYIZCOw6axNowuzIDrUIbGPrqcgSccyefc9DSikzPye+XciAgkVhqY UDr+/YdNsYsmFvCXOhCnMcywNqQG66aR9o6frA4owi63rHDKAhAGVQ6zFzq5KeY8bpoK3F/G7BS SP5/rKyg1k4JXy5UtOx35+MOKfRhv1Z0MzBGiXiJFSRCqywz+Pm8r9rYgB63c2ciIQzXW0B7wHb XbvTnR29gXi9uapLF5atAjnvMv+917Gs= X-Google-Smtp-Source: AGHT+IGWq4jzpIhEdv6123LGkJS3kcsTALE6uCDdvRzPU6u7cW14a0/tv2JQi8/2wxRmO1WYzyv6ew== X-Received: by 2002:a05:6000:430c:b0:3a4:d939:62f8 with SMTP id ffacd0b85a97d-3b613e984ccmr12134458f8f.32.1753103112960; Mon, 21 Jul 2025 06:05:12 -0700 (PDT) Received: from ho-tower-lan.lan ([185.48.76.109]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-3b61ca5c632sm10485077f8f.80.2025.07.21.06.05.11 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 21 Jul 2025 06:05:12 -0700 (PDT) From: James Clark Date: Mon, 21 Jul 2025 14:04:57 +0100 Subject: [PATCH v5 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: <20250721-james-perf-feat_spe_eft-v5-3-a7bc533485a1@linaro.org> References: <20250721-james-perf-feat_spe_eft-v5-0-a7bc533485a1@linaro.org> In-Reply-To: <20250721-james-perf-feat_spe_eft-v5-0-a7bc533485a1@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 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, Leo Yan , James Clark X-Mailer: b4 0.14.0 From: Leo Yan Expose an "event_filter" entry in the caps folder to inform user space about which events can be filtered. Change the return type of arm_spe_pmu_cap_get() from u32 to u64 to accommodate the added event filter entry. Signed-off-by: Leo Yan Signed-off-by: James Clark --- 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 051ec885318d..3e9221a22a61 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 Mon Oct 6 13:38:28 2025 Received: from mail-wm1-f43.google.com (mail-wm1-f43.google.com [209.85.128.43]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id A59902D97A4 for ; Mon, 21 Jul 2025 13:05:16 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.43 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1753103119; cv=none; b=WNC7HfevMHb142U3kPk2qt+Y9eNLWjPRHRTuxwYiYXKYAMvkEuBacvwgpF7ZChlgfykcu+S5ybNcl60zapqPrDo/lqqFH94UKA+GfyD8jTz76B+Keyr5NEAczusnzzV7YTZVaLawFC2ogX9LnX7MV8oQcUQS00sdEWuMZ9iZbrQ= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1753103119; c=relaxed/simple; bh=0lvW3KXNc6coCfrtsL0oIans0QG/77+hgVWwOlpuVDw=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=HLUMkLP0eJOd4PqqrozW7+M+avukm6xuTVjalIiYIp2+mjJ6fRzb5UDXNkVW8RTpYXk56Kpgrr+52Q+V7PqWmP5f5As9GKPSAs40RCNMl/V7XrYI3aydGnJEXPAc9lQ8JUx2QtyeuwJ8wTwWp4rmflGcGR5wgANV7CJancQGpik= 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=b5Vx5qEb; arc=none smtp.client-ip=209.85.128.43 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linaro.org Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="b5Vx5qEb" Received: by mail-wm1-f43.google.com with SMTP id 5b1f17b1804b1-455b00283a5so25668295e9.0 for ; Mon, 21 Jul 2025 06:05:16 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1753103115; x=1753707915; 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=PjhDYf9y6EuvwS1bzG74pgfv+zF3H7PqlliS5Dv+cFI=; b=b5Vx5qEbMUi+tMYhoTyOw+dbJjt+db2zgwXWguXZhPOknPEh8DdKyiuNVXFfxkyymy 7qOJGJVdB9SVCTHbAWa1zyq6JwFuNoly+mVqAT1rPW09nKG8a66TBzKrQ3Xin4F18tVu KB3VvVi+fGeoAvcNEWaz9gqv0uN2N2O//MfMdP3gleABw1qF0CTYWg+KZ7jd9Arji8HO kpZ5h2zwypwrPJQGqI69432jckGNboy/CTUEgREb6vmwsejqIoPsgxWYCV/WRXL638uw mlkOGB4QTxqU7TkxeVXmzeClvsSuB8Ix9DLc4EHsg1E8BcfYXvcdT9HnM5kbeEKrjhYI YzJw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1753103115; x=1753707915; 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=PjhDYf9y6EuvwS1bzG74pgfv+zF3H7PqlliS5Dv+cFI=; b=gS+yN8TErH02dTOmNN6BL30D0Pdb2e2Dv956hkJC7dpNTjjbPd+HXm18S9d25nBHT/ JsWEWBQ4WDjuZ1y/++LHbOBpztttWzK7fhEde4Kc9ynDWev5NpEKAAzwiH7HlidWfcBE natMlBCnDNjKaDgVsuVVUCo2pbKPloihTK+689oQGzqP6KXZ/1LmyALHuR7P3kyDDtSQ lNof9Jzghr6lMFQ8CbKzR17rLMhVRPVopXtd0CEbNzSO/6NzPNn7t4ZrEybDVHcF0px3 KF0c4pNEoM26VNpTM/x0cQoMaUVZjqdZRMEPCo/u6StG+vIcldfbHKssdzWctYQQnZzu /MCg== X-Forwarded-Encrypted: i=1; AJvYcCUfjvPYkzCjNH8wcPDgZ5Rqmwd845/0h1i75+WOt2N562zzRezrJ4C7VANVJ2bXBWzKS5gSk/6KEKG8Zy0=@vger.kernel.org X-Gm-Message-State: AOJu0Yy+ReiLSp1bYcSFrp5kMQGLZtegYZA2O8JIZo/19WS6va9nmikz 5zzK/WNUjUkZ529QhB5//kSkoHO+nbQSWyVPycD7qZKdhn3uMmSRHJunGjF4FXKhKmk= X-Gm-Gg: ASbGnctcnAF6PDUJm+14rgsDPaHDCWGZLYWfpN0BazOOgVNx2SKF+gBn2RzxLh8Hwng vwjnZUOzh441DysUfyPpwn3W22Paiu0JJ/5exXBsgtjyeCqi2hY4DcBdHGD0+z2nCB3SpNvuJ57 Z/ahXOfxjorhIOoWRJxOgNbH1wFrWMQT8/G1m5Jvsj9r9QdeTxUIM4Gk8yc028KJyPdhlMCQCSp CQnTzzrvKvu55Lu1wkAIff/k+94IQTfbMQhcwRKc+ghDtJgumub8eU55jZVz6i94s5/4O7rurN2 YxiHoinyvJasZamxzTgEj6V22stU+SvZv4wd8JedNaSjndloDM8kLBNJoh4EiWibc4w4askj24A dGhbgaYHa7IOQsFoOp4U7p1QaPhmM0co= X-Google-Smtp-Source: AGHT+IHGTPbKstjVxyAE57Edw9w+pDVFITpmCqgBsXIYOD4vtwabETOgcdaWuiTVMaVBQjjReqPiww== X-Received: by 2002:a05:6000:4910:b0:3a4:d274:1d9b with SMTP id ffacd0b85a97d-3b61b0f5cccmr10188146f8f.25.1753103114704; Mon, 21 Jul 2025 06:05:14 -0700 (PDT) Received: from ho-tower-lan.lan ([185.48.76.109]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-3b61ca5c632sm10485077f8f.80.2025.07.21.06.05.13 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 21 Jul 2025 06:05:13 -0700 (PDT) From: James Clark Date: Mon, 21 Jul 2025 14:04:58 +0100 Subject: [PATCH v5 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: <20250721-james-perf-feat_spe_eft-v5-4-a7bc533485a1@linaro.org> References: <20250721-james-perf-feat_spe_eft-v5-0-a7bc533485a1@linaro.org> In-Reply-To: <20250721-james-perf-feat_spe_eft-v5-0-a7bc533485a1@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 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, Leo Yan , 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 3e9221a22a61..e69a0d170702 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 @@ -360,8 +406,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; @@ -763,6 +816,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; @@ -1054,6 +1117,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 Mon Oct 6 13:38:28 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 2835F2D9EE7 for ; Mon, 21 Jul 2025 13:05:17 +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=1753103120; cv=none; b=XFQnVd614VZYZcZKup5Wq7nVNAuouJNUPu9Nk6la8WEStzQToYWOUQO6TpLnTS/6lMTIxYXfZQvsO1dZ3Xxcz26q+q6SADGpphhMxKX6ZUXITCEx9mkqLKPzNfFjKtivLcKX7TfB8m52C2fb49TA+U27F3UVR946BXTQQfM5vhU= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1753103120; c=relaxed/simple; bh=YxvmYpOV+737fyfcSQi4SIm2ZMFnBONYtUfp6vtMhrI=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=raPU0PR560qq8O2RYGF5+ztHnqgM8hwgvGY8FdGQYowypyO1gPTL5eQ6dE05/gidXhKF0noXTJJ+FLl65jNhp1TkziMH1H0aBvU2pBgP2t2p4SJqPlAmGccmdZEXNATwmgeQ5qHMKy72XStrlgGy4YWiTqmL2KsFUOm5Tx899xk= 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=A/IorPbN; 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="A/IorPbN" Received: by mail-wm1-f51.google.com with SMTP id 5b1f17b1804b1-451d41e1ad1so29873625e9.1 for ; Mon, 21 Jul 2025 06:05:17 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1753103116; x=1753707916; 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=jJFteMx4M8CuvuwGOOEAn5xVwGW4RJ+pfzFY5hwg8co=; b=A/IorPbNX8kTl1c4DpmsoK9rRYrmMSZ8EV2v3ewO+aNIeb9QBtDnmx6M6oxQKKqm5b QKK9RPLmPzO17CQaszDKXacWXEZr0O9L4eYNlBGvwRDEufcW4B8gUNAVh7c1d4bs2Gfg ekKtriJUB2B5jojUXDicYqG8kmJcAJtGZFmuNYcjAhl3rWqchIfmfwiVzlz0EKdL2GVP APrt5KlglYYC7ZNU3yM3UJakqqRaxfUZ4Hy71GzHmreZJ2ZSt8Mo69XwCXtRT1DY08WK CgWrmlpCUAVeYzKH2AnpS1aazJvdfN9/CsSBG82nb8Bih3mIL549ozBfpq+USHNWIB57 //Cw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1753103116; x=1753707916; 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=jJFteMx4M8CuvuwGOOEAn5xVwGW4RJ+pfzFY5hwg8co=; b=OEHNsgajSfSLMNhJcuLSpM+8I7af99U7qXAK4Ap9p8y9GFiT8d7o/sUv6NuAeg+yRG rVHsd8Pnsr0r35PYIKlBCQ7+/0t5JG0ynF17gSZPOrE7PHfxMR1TRqCwk8ffJSvz1Zp3 tqdQ1HQpFRkY0dOtCX+q35CBYDyWPDk1MmtL36A9/FWCq/faExG6hoXHsd579DI4Zd8G GjVj4b9ai/rif1Fe+e1jbDGkAhv6snw7reh2F2fmijfeFyNeahzeORpbapqW1+IbL+// 0a0D5tJ6Og4qLlMtcGQ/rA8hL3ilyBKhb57cTZ36HK8wWNgH/4ovmI5cJF/lQ849w02a jz8A== X-Forwarded-Encrypted: i=1; AJvYcCWhcGZpf0xininDRImesfN96GmPv7531OQ+TlQVR7rLWijc1EhxFzYNWD95ZxvdLmCEyGOs9tOIa2zXlSE=@vger.kernel.org X-Gm-Message-State: AOJu0Yy4OXr3dhqZAf7tz7JS9MuC3iHmghx0CeyERe5eJkZRh6X652nm tR++4L9tq9YGIocBx0cMBN7eaxEE1UQ2kGEJxn3gzCqDGzsetKns39m6D7yCw1QzTa4= X-Gm-Gg: ASbGnctpF8Nx5+KNzjCBJvcA5BrstgnE9TuBeACcHuw1OP9Yz64xxibtUDCLZeRjQ9H gitVWANMF52hzE6ojamLtDPpJY1vO7vvTdsIh8pqIHgPT7dHfftij1pS1l3XcVjrvBl/PISpbd3 aiUVAZpkoXe/yx3jPRx8hw5AC6Yt3Ed5mbV91Jh9DN8cECULg4CUQqTxkgQT/848h1RznXdH4tL 5BYG3GwYQboaxtSaWUNcAymgm8IoPlfWQ7G6Semcm/+iEG5+GyDZNE/wVDD3c0RZyUfDf1q4jE/ prZFbRNbCoVkeJboohpfFRrlh6Ljljb1f+sSFv1JKogjuV8zb1+UlO2ktjNHtAZkYZcYCkkHYrc u8rFLYvJEGGYeJpj1pLqrYMewevcfEQ8xLHRQowMQNA== X-Google-Smtp-Source: AGHT+IH/BaFdm6qjB9ghQzr4BZgdXtPtkOCmYQc/NNyMmIYlQPK76Vqi5YsqsCJo4ftIcTCJzUtW6A== X-Received: by 2002:a5d:64e8:0:b0:3a0:7d27:f076 with SMTP id ffacd0b85a97d-3b60dd651d2mr15563166f8f.2.1753103115987; Mon, 21 Jul 2025 06:05:15 -0700 (PDT) Received: from ho-tower-lan.lan ([185.48.76.109]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-3b61ca5c632sm10485077f8f.80.2025.07.21.06.05.14 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 21 Jul 2025 06:05:15 -0700 (PDT) From: James Clark Date: Mon, 21 Jul 2025 14:04:59 +0100 Subject: [PATCH v5 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: <20250721-james-perf-feat_spe_eft-v5-5-a7bc533485a1@linaro.org> References: <20250721-james-perf-feat_spe_eft-v5-0-a7bc533485a1@linaro.org> In-Reply-To: <20250721-james-perf-feat_spe_eft-v5-0-a7bc533485a1@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 Cc: linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, linux-perf-users@vger.kernel.org, linux-doc@vger.kernel.org, kvmarm@lists.linux.dev, James Clark X-Mailer: b4 0.14.0 We check the version of SPE twice, and we'll add one more check in the next commit so factor out a macro to do this. Change the #3 magic number to the actual SPE version define (V1p2) to make it more readable. No functional changes intended. Signed-off-by: James Clark --- 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 9f38340d24c2..2bb0d28952e4 100644 --- a/arch/arm64/include/asm/el2_setup.h +++ b/arch/arm64/include/asm/el2_setup.h @@ -103,8 +103,7 @@ csel x2, xzr, x0, eq // all PMU counters from EL1 =20 /* Statistical profiling */ - ubfx x0, x1, #ID_AA64DFR0_EL1_PMSVer_SHIFT, #4 - cbz x0, .Lskip_spe_\@ // Skip if SPE not present + __spe_vers_imp .Lskip_spe_\@, ID_AA64DFR0_EL1_PMSVer_IMP, x0 // Skip if S= PE not present =20 mrs_s x0, SYS_PMBIDR_EL1 // If SPE available at EL2, and x0, x0, #(1 << PMBIDR_EL1_P_SHIFT) @@ -189,6 +188,14 @@ .Lskip_set_cptr_\@: .endm =20 +/* Branch to skip_label if SPE version is less than given version */ +.macro __spe_vers_imp skip_label, version, tmp + mrs \tmp, id_aa64dfr0_el1 + ubfx \tmp, \tmp, #ID_AA64DFR0_EL1_PMSVer_SHIFT, #4 + cmp \tmp, \version + b.lt \skip_label +.endm + /* Disable any fine grained traps */ .macro __init_el2_fgt mrs x1, id_aa64mmfr0_el1 @@ -196,10 +203,8 @@ cbz x1, .Lskip_fgt_\@ =20 mov x0, 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, #(1 << 62) =20 --=20 2.34.1 From nobody Mon Oct 6 13:38:28 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 4F5EB2DA746 for ; Mon, 21 Jul 2025 13:05:19 +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=1753103121; cv=none; b=aVIrtbCg72gDSabcsgZV8N6O8v0s2ivQbd4C6lLeyxZNZyBI1u5tJj6XThrH4xsGp+K3Yj/S6tO/PAbBy5118t24YcGcOfZB8+HKX3qditpKvIfEGxbTzNFYMsUoJL39af6GciuU4ONTWY9jffecMzyZRYO6Psomtu8AmlOA3Lg= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1753103121; c=relaxed/simple; bh=nJUr8QBs1Bj7YhbHeTnMBeiABjZ7mfBR47rSyL99+v4=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=oNUnz03VLMh2GbbaFFSvTLTqkVRVRKvXsmGj2RYjZZTVKIDR5kmTSH+wbqqkiX4/GaUY7/pMIXGJEvTmyxx+sUtYHh8ZPKMcgUAC8KQsn0kkIAgbCXA75NqMfprzPth4OqtxMyeYgkSGh30i50B+BA231X/cS9DoGFC+HDshwyc= 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=VVbujU1W; 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="VVbujU1W" Received: by mail-wm1-f50.google.com with SMTP id 5b1f17b1804b1-45618ddd62fso44560905e9.3 for ; Mon, 21 Jul 2025 06:05:19 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1753103118; x=1753707918; 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=Tni0DswMrCD5TnIk9k/V3+/ZJa/XagFEwHSR8GX4s6s=; b=VVbujU1WJJxNMWptGL1MuqhqSglHGREDqloEnea94M8o/79Y0Elv5GUHRq9aV8hDMa nYEih5oypVNndAIKclJnj0nHkE3SQrFDVGPil4B2sG7ZRQmwUjumjRiU9Ee9YdNhUKTQ 0lNX8iDqawKj5C3CbFDTqcoxhnyOsI6cXRE1cPHUcikfXKg2EqctXYMl3ru4S+/y9ZLV xgGxlczM7TuaYO8bAYwkYTEquN/MnP5vCFr31wT1rj/pfX7d1hteZsCx0ItM7amh9KT8 Zn8huAyG5sfloZt2pRZI7z4LoaDM5w6RsZjE+4w5zmwghTJexjp4ZiVXb8xyAZHYwrbS NHPw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1753103118; x=1753707918; 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=Tni0DswMrCD5TnIk9k/V3+/ZJa/XagFEwHSR8GX4s6s=; b=hRIAPYCOfoUv9cySXNmfAXrQEeCzgCSPBtcVinrhI43Hop8bdoPj4SrQm/WECSqVEo tqUzllOr715v/2XroyfH8n7E7hIlf45Sjm7HOhwVdUDTQV8xd9GeX1DyXvRrdhWLdFD/ xElKB6o90V43YLdeqP2ZyZPGjqYrj4/2lAfJDtiyU0BwmfwMFJpDrbjbp58tbXhMtQbQ 3t2I4Ud2yfJEIvGxDgeN/dt5NBv87Rh+/8X5a3YV7KJPTSSpOVF0n2wNuO6egbdhqQ2B eYx/08BUXyZhxELQK3IFG/ux2Z/RZwEGpgNwYkIwWLRyVcCEKsAalN8p2ihARMDTquCz CzDw== X-Forwarded-Encrypted: i=1; AJvYcCVPfm/6YyYKXdSBpokqpfZPhrlKRpV8PT7W8zYZPFUPqXHabmcs+vsWzcEKwGApPLf5iHb/oqiPnjEqWs0=@vger.kernel.org X-Gm-Message-State: AOJu0Yz2nUnBKCSXTDaNBQFXKpuapD56cxqkJhB42JafBvCgnseB96An 6iYSQHkKogy2r4fOQagnHLUsjs9p8/DU7Mn+tO5dO1XhjC9TgV92pPBkFsj3PAYIDhE= X-Gm-Gg: ASbGncuOox7MvK5mcX44orABRtuecQO/Qjlrsc2eCOcfwU0qCD11aMcUACigdArc10N gd6EV8zcOhE+FdRrTtt34xAczAlRG03N/f8r7v9bImjApizkUX7JCpVNsRHFBU/HKR+pbddt7gL EH+KDmpjKGYYfWvOzs3oFs0XAqRgO3QNnJ1xqASsKqaFPEmrG9Fic5xj0IWdHim0SMS1BFcUIwu EUiM0xmr/qI4BVwdGiBLc5/9u14GUP+nUvBOIEnzE+T/PCGIFKsQa5FTjETil2tIfhClSbNBEhU xjDREF7Ch5Eve5A84NZp7QT0TMGyRG6YYLwa44WTiTgGeY2TWpsmYpVK4RU67BXvvZVcSJwBMKC LqRe4o+vOY6Ejnm5ahjBGR8pwZQiobFAo79BZtgTVZQ== X-Google-Smtp-Source: AGHT+IEbTWNhdSsCoye5ChJxrRKNCcL1bytD0ny/gbd0G1tPqNJCslwd6wNxX0L6BGInIzH8XxTY9A== X-Received: by 2002:a05:600c:5298:b0:456:15c7:ce90 with SMTP id 5b1f17b1804b1-4562e38a72fmr200645775e9.12.1753103117481; Mon, 21 Jul 2025 06:05:17 -0700 (PDT) Received: from ho-tower-lan.lan ([185.48.76.109]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-3b61ca5c632sm10485077f8f.80.2025.07.21.06.05.16 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 21 Jul 2025 06:05:17 -0700 (PDT) From: James Clark Date: Mon, 21 Jul 2025 14:05:00 +0100 Subject: [PATCH v5 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: <20250721-james-perf-feat_spe_eft-v5-6-a7bc533485a1@linaro.org> References: <20250721-james-perf-feat_spe_eft-v5-0-a7bc533485a1@linaro.org> In-Reply-To: <20250721-james-perf-feat_spe_eft-v5-0-a7bc533485a1@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 Cc: linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, linux-perf-users@vger.kernel.org, linux-doc@vger.kernel.org, kvmarm@lists.linux.dev, James Clark X-Mailer: b4 0.14.0 SPE data source filtering (optional from Armv8.8) requires that traps to the filter register PMSDSFR be disabled. Document the requirements and disable the traps if the feature is present. Signed-off-by: James Clark --- 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 ee9b790c0d72..b4f6d487a322 100644 --- a/Documentation/arch/arm64/booting.rst +++ b/Documentation/arch/arm64/booting.rst @@ -404,6 +404,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 2bb0d28952e4..7c89e0d6e739 100644 --- a/arch/arm64/include/asm/el2_setup.h +++ b/arch/arm64/include/asm/el2_setup.h @@ -284,6 +284,17 @@ orr x0, x0, #HDFGRTR2_EL2_nPMICFILTR_EL0 orr x0, x0, #HDFGRTR2_EL2_nPMUACR_EL1 .Lskip_pmuv3p9_\@: + /* If SPE is implemented, */ + __spe_vers_imp .Lskip_spefds_\@, ID_AA64DFR0_EL1_PMSVer_IMP, x1 + /* we can read PMSIDR and */ + mrs_s x1, SYS_PMSIDR_EL1 + and x1, x1, #PMSIDR_EL1_FDS + /* if FEAT_SPE_FDS is implemented, */ + cbz x1, .Lskip_spefds_\@ + /* disable traps to PMSDSFR. */ + orr x0, x0, #HDFGRTR2_EL2_nPMSDSFR_EL1 + +.Lskip_spefds_\@: msr_s SYS_HDFGRTR2_EL2, x0 msr_s SYS_HDFGWTR2_EL2, x0 msr_s SYS_HFGRTR2_EL2, xzr --=20 2.34.1 From nobody Mon Oct 6 13:38:28 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 B713E2DA77F for ; Mon, 21 Jul 2025 13:05:20 +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=1753103122; cv=none; b=FPGOomtn2wYdqxkkDP+UjM2AVrkF54n8WRfHVCNUBBzTcbPdCxR/3KwXC9X9y+9lN5i+XA//OqcN+oXc5ylK9+JIFBWbhlVwGnZss1WfTvtqNiysJWgp2BzUYS/6vc0vbxodu2Cx6M77AdtS0Xbpb0viwy/wAgPUJfyIRnimdhQ= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1753103122; c=relaxed/simple; bh=+SpNfvIdNfTZltOmSX39gMGmWG5o7oWGDEW8UKH3C24=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=Ll7AUhQllVWYgny50EZ7UVE+jKF6l365FC7mgYjwr0nwj4LNEvhecQE56D1VGIZ3qSkR4Ov7ibucPgqq0MMdRS3+qLZxxLLvPXTEm35vC+0C6OYmLCGaIhAs3kqPlSQFWkgTPy0rbSpC0wmfytELV32xw6aLXbNh2sfcCFxcIiM= 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=Edu2Cc9k; 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="Edu2Cc9k" Received: by mail-wm1-f45.google.com with SMTP id 5b1f17b1804b1-4561514c7f0so44641735e9.0 for ; Mon, 21 Jul 2025 06:05:20 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1753103119; x=1753707919; 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=aZ3PtlOR0m4xvI+xrlOA19tnjKSe6qe5HMQ0ewIzj6Q=; b=Edu2Cc9kv/9b5WwwT8A1LTpX0gEVjM9HPg2En43YpX8sfpMfkbkOSyAG8ogBH/U52/ h/DCsPdWqhbvIvowiy4LNqoatjmLiaeno0T4YoznL0vcnAM4Cl8vfCzpZP75gkYITcrN fM8rgSTQ57jfQnmOO0LL9J3a6QL3c/6p0a/ZoJTPFGUjBMCkV04RITMZtC/jM11YGUWe HyJIj37PruTxHUSCW+6QS6XLuJ5EF66HXCQv1a6Yf9WM4UujD7+4gc7v/LbL2RygHN0B 4vyaHACbm30C04Cl9qxYvLWTeYhZknOnrDgLYaUL+FOJ2/g/5f1+x7Xof090m5cvI4pp o1Ww== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1753103119; x=1753707919; 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=aZ3PtlOR0m4xvI+xrlOA19tnjKSe6qe5HMQ0ewIzj6Q=; b=cqB1io2Au3YvQIHdGAC2+3AbRzhLWtgXrYEHmw7KR0qnNERk571fRVcTGeH6SBqxXV pJgQn8E9cpeo+xftOZWzQBsDYNFeNduUA/crrysiDcC808j4urZBt1EuuekYMdPXS+k0 lNgcg6Do1N86w4K8SnXflnSUmJ+k/J5jumkadYCdpWv+QaHiNDaykaxqLcfO/XFNYPT3 Y2P5A+Z0xqh3l7XXEWK5RQ0QxpwmBj8GTvYuuVn0vk0P0cQd88boqBLoIt3d+LKKsoRl 85Frun6Bxmj1qnlcGEtYOKBmlkthtZ4vw67j+fMDquv2/lph3m+/m6CYy2I/F3yimdNn vFhA== X-Forwarded-Encrypted: i=1; AJvYcCXig+gZWph/vcKmEGQMI5nJE6Bg6cF2q4l4f0eddPXi79Ez3L8e/1Ki8jzJznepP8noz2NQ/8ermQwkok8=@vger.kernel.org X-Gm-Message-State: AOJu0YxuWQst7XFHqm7blrjd1yRryZ+wcGGlaafW4HIzS2tiWW+F+yiI nnzWiWj5buy4Eoig9TxLnB6S0PMUNKjt7GyUHhXZv7Qpk+MCKzSleF6MWHnHAzSsIfw= X-Gm-Gg: ASbGncvo/+ln8p+hLQeFzLwm6GI/NiFeK0EIiGnJXC+/596Tw5oKuvVbAM6rJz+Rzw1 h2kWb6IHh1oqMYB4AAeD7f+1xwQwKtnldPdM91ORjW3bhwGxSVaFdITPD2Q4AOz5AgOmM0reWYc 4PdICxl1abeP6qROKsAVdlPikTYi4jjHBPZn7bGu49dXyAOc6G0ECg0APJLtx/RPFGi2PUVjWsB 5lbC5mxTjPEz/eqQndsYe2ms045LdH/tcyfy/J+zXHQeHOG/jOBqo40m+JSn1weV/jVCLxMrqTH ed6voJht4TTVwMQaARIvvW3OZnzAnQgYdfRAJpnqzSwRQNL7VZHr9Avpm4oItT4WIe9gmuB6jMN nWMqxXq4DWAYcZpTvUipSWtHMzfxNCvc= X-Google-Smtp-Source: AGHT+IH9bw7cU8ns9QQ3mV/+eJ2qDxTwHmxGZEX7vgJMgWIg3L3lpoWH95LxFXy5NofnFtzmG3M36A== X-Received: by 2002:a05:600c:3589:b0:456:1d34:97a with SMTP id 5b1f17b1804b1-456357faf96mr152094745e9.9.1753103118896; Mon, 21 Jul 2025 06:05:18 -0700 (PDT) Received: from ho-tower-lan.lan ([185.48.76.109]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-3b61ca5c632sm10485077f8f.80.2025.07.21.06.05.17 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 21 Jul 2025 06:05:18 -0700 (PDT) From: James Clark Date: Mon, 21 Jul 2025 14:05:01 +0100 Subject: [PATCH v5 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: <20250721-james-perf-feat_spe_eft-v5-7-a7bc533485a1@linaro.org> References: <20250721-james-perf-feat_spe_eft-v5-0-a7bc533485a1@linaro.org> In-Reply-To: <20250721-james-perf-feat_spe_eft-v5-0-a7bc533485a1@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 Cc: linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, linux-perf-users@vger.kernel.org, linux-doc@vger.kernel.org, kvmarm@lists.linux.dev, James Clark X-Mailer: b4 0.14.0 SPE data source filtering (SPE_FEAT_FDS) adds a new register PMSDSFR_EL1, add the trap configs for it. PMSNEVFR_EL1 was also missing its VNCR offset so add it along with PMSDSFR_EL1. Signed-off-by: James Clark --- 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 6f556e993644..dba0e58a5fac 100644 --- a/arch/arm64/include/asm/vncr_mapping.h +++ b/arch/arm64/include/asm/vncr_mapping.h @@ -92,6 +92,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 3a384e9660b8..60bd8b7f0e5b 100644 --- a/arch/arm64/kvm/emulate-nested.c +++ b/arch/arm64/kvm/emulate-nested.c @@ -1174,6 +1174,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 c20bd6f21e60..82bddd631b47 100644 --- a/arch/arm64/kvm/sys_regs.c +++ b/arch/arm64/kvm/sys_regs.c @@ -3010,6 +3010,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 Mon Oct 6 13:38:28 2025 Received: from mail-wm1-f43.google.com (mail-wm1-f43.google.com [209.85.128.43]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 1A79F2DAFD3 for ; Mon, 21 Jul 2025 13:05:21 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.43 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1753103124; cv=none; b=twRmVYDzn2sMW6/yPkpCCh50U2EJjQj7RDLNHb1YvhKg2RzKPn3MoJsa76ZOwt5gLoaDTLJ8wYZUeZ8DFFWZ0Dqm+fHWwnGY+vBDmnmdoMG30HTMJIbj4KFRi0ROrxStPbEhSyFnhOW8CfvqT+8bbDGhu3I7kS4XD37oVWGE8G8= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1753103124; 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=m000w5Z7mAmXMggbE5jj4ny70B8i3oU1OY2ZsM57sLPRJSUxQcSxh1QoETZzjO/9DycyxsTp/h53icVMRVtmVrp/mhrvZDlZUWdpLkA/eCP3+4R3qLjzZgrjzwG1Xrp6kIvDXdhzwtWngwAGi7AcV5ba5M2keRwINX1lI0L6KyY= 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=o+8ZXiqL; arc=none smtp.client-ip=209.85.128.43 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linaro.org Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="o+8ZXiqL" Received: by mail-wm1-f43.google.com with SMTP id 5b1f17b1804b1-45600581226so45096795e9.1 for ; Mon, 21 Jul 2025 06:05:21 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1753103120; x=1753707920; 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=o+8ZXiqLRLXZX5M3emkvo3y3nwYFHiT+xAeP5lCWkA1tkX1lPvKNQXdoQDMx4UFoul U7kUGQoLkxAQnlrYz+9fPDuG5HQ0pC/z8GRfRSQEusmbwNPRyQO/AYGgdf8CyaBBlbzT 0XcUOziZNR7fY83Jf2YLxfM2+tzYoYGY6e2J8teDjEYNxxkfVtTGa3cWfOwAeJOJpLFs F1eyfK3jzIyBLVb716H8s2+rz4D2b7sKijqKJCbKy1ooYWThtdxUbDen6bhnJLSuEmip 1O+jekZKlJrehNe7G1RcsYpUR+IlOXHJyd/VorDjbdywo5BdzN4bdLmxaJxRSHDAUuYb zgBQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1753103120; x=1753707920; 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=dr2JsrrRP5GKHcc9ZBVgzK19x8xx3XGvFBsR1kD+V2bPEZdxV4M7kAX3AoVlrM0c39 5tfQNJbsD9650Ronl7SQI0mB+RBGRx18P48OWE0hmgBc5C8WReI95IaoMQdMvHJ003lB Dxtr6mM4Z3ht6odBQmhXlu3Q2ZrcbboFp/gdveQhm/mQcw3nRvaUKaADm0sWmErI+o+U eP57SpXKf/x7jrvyY2g9yI/iJ8LEsT1fpb4O3gsI3Xwk3RFqxJVJO5IVj8JwJQUPJlaQ zbgHUOqwdtz4w7HNQjW1+agHrJGfdiP90jjtv/j7JkM72otgtTf/T+Uac5EjnHzCFA0i amTw== X-Forwarded-Encrypted: i=1; AJvYcCX7ews7GRZaYYeFkE3z7TFt947JshboNQI0x/1+u/RWyHK570gUe02Y/h1FyzxV+t/+AKCXX1oCltFZQHw=@vger.kernel.org X-Gm-Message-State: AOJu0Yygj7NbAgu41Qncwyw+ghheQEp1Cfhh4N7Kd8nUxmRvzVX3izrq QwadHP78tpjr6pjpWCQwbOxehaJedBrfpwFppqhGbnq7JxI09TWpfesI8CXin434A94= X-Gm-Gg: ASbGncv+O/iOT2FpjIYnMQjVOPDnBuXNoIyUmtsOyU89qctsJO9MjgJKpvIVNdFFzj+ mzM1eokwFWczJiBiE5Y/d75+2S1WrnrDirJO5PMEk/wmFbhJ7OtsLg4aCbuPs3xiAo1vcHIM/qC Ls1w/N/0B/be8ZgsmPKU+gFTkyw+vnWG3pzyyics3UJ8gi+YSuHQj+ExFK0uSKxqLsek9eoNjmp uCtKtxf8h3sgJNUJkfjEJr19LZI3iRfX0jP7C2hgxeNkMh/LMhHEu6aUvCEh3Qq0+2zervW1Mji FwBmqJYGyo95WPx0C6bz+UxEm7W9YZIb8YzOjXfF+aHKudkPBuGC3PZ/3JAlGRHKu1UL/coOCe3 4GT/gmzJKKD2uBuK2qCFUcvbyguG+SPw= X-Google-Smtp-Source: AGHT+IHcC0WWzrKqr8+Igj35NnjWFuFj+8E1KaR+jWoua9xbcKUEBeLY4nnJZlnbhkk4+Th+Kwau9g== X-Received: by 2002:a05:6000:4022:b0:3a5:300d:5e17 with SMTP id ffacd0b85a97d-3b60dd731c4mr16367288f8f.29.1753103120265; Mon, 21 Jul 2025 06:05:20 -0700 (PDT) Received: from ho-tower-lan.lan ([185.48.76.109]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-3b61ca5c632sm10485077f8f.80.2025.07.21.06.05.19 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 21 Jul 2025 06:05:19 -0700 (PDT) From: James Clark Date: Mon, 21 Jul 2025 14:05:02 +0100 Subject: [PATCH v5 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: <20250721-james-perf-feat_spe_eft-v5-8-a7bc533485a1@linaro.org> References: <20250721-james-perf-feat_spe_eft-v5-0-a7bc533485a1@linaro.org> In-Reply-To: <20250721-james-perf-feat_spe_eft-v5-0-a7bc533485a1@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 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, Leo Yan , 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 Mon Oct 6 13:38:28 2025 Received: from mail-wr1-f48.google.com (mail-wr1-f48.google.com [209.85.221.48]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 8A8052D8DD6 for ; Mon, 21 Jul 2025 13:05:23 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.221.48 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1753103125; cv=none; b=cvGBn9Nr12lJMFgZeekdeQHESEMAuuibVlAUWD3vg1SV2n3nDC9+jPeYlyI28z81zGwIh+CkBmkA27X2AzgC8IOEkkd/fkSvhE+yJ/UgOA7AbDy1sBTjo5Tf7TSmHum03wYZmwmBoeBe3eZiZppc0ItxBlVyc+o4jN5XA3h+OpE= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1753103125; c=relaxed/simple; bh=Gadj83wy4unursiBjFtgA2eyEqAMFePNrTi88fqMsXQ=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=S/2zXR45RIAW6LMESgtzd6ZcAnPU7TL4hZLhvKSITxIBa2BJNYcM3s6LvJUUIUOwWI7Mz7NnEjNI3TYarAhlGoJ0JbYmW7icnJbynw9kRSMXljSfFNgQkHy56O1/2UOFMMt0v2gF8UDT8I54pVOU10GWPQfDBgRYZFfaJSOPY7I= 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=cBeYcOTK; arc=none smtp.client-ip=209.85.221.48 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linaro.org Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="cBeYcOTK" Received: by mail-wr1-f48.google.com with SMTP id ffacd0b85a97d-3a54700a463so2408567f8f.1 for ; Mon, 21 Jul 2025 06:05:23 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1753103122; x=1753707922; 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=lWHuVE1EgR5wLSuZVPObZK1oCh3b9sh0cLYRdc3oQUo=; b=cBeYcOTKr+41ENx9Lzn1gvGpZg+1eTi7/gzRywfHc5btAQAuO/sBHxcMRimvZ5YidX H9ZCEF+mRZRnAvzn54isK2ku48iF044JdQFStG+p1Zrajlqafk6kQBtUThYo5IpgVcOP QxIS7hYDzpyICp3bHoAwhXQ8RxYY0hUG9/r0+JUpVAVz+0G20xo9O05Gb6VOnI8eBKsK eUQrGlE4sfloAji0pyClhSRbHMGLCFOjFOqNE5Gg8D27jmO2i2OjeD+bLzyvej+ksexg TvHfdInDCanevtjUGS4QrZf+DU3ql8jVQ0EIatSKMnNYreTLnp/aM7g2s63pntq1WfPl W5nA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1753103122; x=1753707922; 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=lWHuVE1EgR5wLSuZVPObZK1oCh3b9sh0cLYRdc3oQUo=; b=esxvvP5/CeG69ZCOKJR8rkOM3NwpOSrcPkJ8WseUzDJ+piDDuGLVco8wQPqnI7ldar FKCsR7fVmhYGqgdsoJJnpYUE9PXeROdZaTZx2cbUd6t6hTYqruI/3yf6PJyVVlYONjYl zGHB67bS1AAyDrilWIClHZnPbMENZbVCqNy3jPRVrLAZZHeucW03ltGDi+uvsuX/nt7w SrdPoo9vpqUHiikadRabVD5kZpqjxv025+fJIEBb5saziImjIcRZrAV7+B2M2mAVdqoK duj82E2gEMmbXKINaa6eu6zKD79J7XwIDkUxzcoPkMJjpKceAKlfreeJJWZiwuPlX2DL NEAw== X-Forwarded-Encrypted: i=1; AJvYcCUpFf/2OWtOj2HbzbQvBW4nuy8+f+DdiPfutGb1nPIewKxbjWuIieghviMzermLjbR9XoWl/XNN99xFcVY=@vger.kernel.org X-Gm-Message-State: AOJu0YzyGqOJgcJ0E1XsGoavL0ca6JPo8rkPFsMp0bRsZNVkuuuCHqPB cQ//QEZ4sI3E2L5lyR+G4lvsb+9EMhs8Zw3aUK9QU+F4F3SIVw7TqdAI1RGNON52hh0= X-Gm-Gg: ASbGncv7s0/VLIO2ew4GX7XomYxfKJcIv8rtDFdc7I1t794kaays0Kihbf/lu33Vbd6 cKTkJc3d/VL6KEwRXUrORDLgetsjyTXinrEc0WkI4p0Zs2Ao0oOdq2u/DVE7xp+NJaB5jbc2Ofh U8ppm8hlOSfCQhDB4yp47plY36xBnzp283rV27jYzI8e5fgej3Gy0RyDQ0z3BqOerccDLz60fMG VF+IyJEkMrOEoAoHO4IKStMYx6RFhWhzv+Nzd83tQvCEMHPN71uZAhiz/77fI5k0fC4cfDaQ+C2 2+xGV/FAupiC+AgTEz5O5J494sGgtQYN6124YeQZLQLbKau8RBteFsQGeM4oRr2/AuKludKxmXn g/hxWyR7vTdurWDPTU9iJgywS+ADEBItlM/jDw996sg== X-Google-Smtp-Source: AGHT+IENuZ8sJTZYDX4FPNTpsJ3T0y3YydlBHbyO5i6H0FPLw38B5Bhq3yc1kar5ictPycy0p5ZNpw== X-Received: by 2002:a05:6000:438a:b0:3a3:7117:1bba with SMTP id ffacd0b85a97d-3b613ad5ec1mr14410276f8f.24.1753103121601; Mon, 21 Jul 2025 06:05:21 -0700 (PDT) Received: from ho-tower-lan.lan ([185.48.76.109]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-3b61ca5c632sm10485077f8f.80.2025.07.21.06.05.20 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 21 Jul 2025 06:05:21 -0700 (PDT) From: James Clark Date: Mon, 21 Jul 2025 14:05:03 +0100 Subject: [PATCH v5 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: <20250721-james-perf-feat_spe_eft-v5-9-a7bc533485a1@linaro.org> References: <20250721-james-perf-feat_spe_eft-v5-0-a7bc533485a1@linaro.org> In-Reply-To: <20250721-james-perf-feat_spe_eft-v5-0-a7bc533485a1@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 Cc: linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, linux-perf-users@vger.kernel.org, linux-doc@vger.kernel.org, kvmarm@lists.linux.dev, James Clark X-Mailer: b4 0.14.0 SPE_FEAT_FDS adds the ability to filter on the data source of packets. Like the other existing filters, enable filtering with PMSFCR_EL1.FDS when any of the filter bits are set. Each bit maps to data sources 0-63 described by bits[0:5] in the data source packet (although the full range of data source is 16 bits so higher value data sources can't be filtered on). The filter is an OR of all the bits, so for example clearing bits 0 and 3 only includes packets from data sources 0 OR 3. Invert the filter given by userspace so that the default value of 0 is equivalent to including all values (no filtering). This allows us to skip adding a new format bit to enable filtering and still support excluding all data sources which would have been a filter value of 0 if not for the inversion. Signed-off-by: James Clark --- 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 e69a0d170702..5729be9e5952 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 || @@ -425,6 +436,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 @@ -449,6 +463,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); @@ -786,6 +811,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 @@ -861,6 +890,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 @@ -1120,6 +1154,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 Mon Oct 6 13:38:28 2025 Received: from mail-wr1-f50.google.com (mail-wr1-f50.google.com [209.85.221.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 C51A72DCF4E for ; Mon, 21 Jul 2025 13:05:24 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.221.50 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1753103126; cv=none; b=JAMXyl4Vj3UZjm1kj+GlRCrJzyYNAZbD99kwr9FvEHvjaw3J09DkKXEW7iNvKvz2Ox/Bh32hjHCB12DbMNv8ANsWedoqI31t7qh16BtzvkiY2M7u9M4WO1MvrE/XPWNR5Vac5/s5YToPQX6UnU96BSpxFL7ZShMlDNx5TVL9A9c= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1753103126; c=relaxed/simple; bh=b/ttJae4xiEHONrSB61gWYPCVcnCnqIpQyNKL5V/Pqw=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=kbKow2esvs8DdvIFBBA4PjTMVYT0lWGA8KYZXI1EkiepERs5u7GJ2rPsk7hLZG36uDml/TgYLGymCnRkLoa5ledOwgsRTYIzF6zf2WKcTVQvLCurEh4Ki2JYzp6nWwN2RtbzFm+ZJfEImJ0Hqobve5WKTui8huJ3tqam1emvFu4= 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=qQlpmKsX; arc=none smtp.client-ip=209.85.221.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="qQlpmKsX" Received: by mail-wr1-f50.google.com with SMTP id ffacd0b85a97d-3a54700a463so2408604f8f.1 for ; Mon, 21 Jul 2025 06:05:24 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1753103123; x=1753707923; 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=qQlpmKsXEdRSk8zdwhOzInSekKeRUG4mdTqXX703NVvJQK+LBUT6sqlqeBWkABHvK4 100Pwf8M6jwhq9YXV/v0vMn5LZ/xPlhDCQExu/RXIe99YZLCZw4DqabDDyhUPEl3vbXl psNxeu9xi4S0+VShYCXUo2bBNsRjcdSX29y3zaamf/3Rf6zVfEarmBp65g2tpBwf8mVn lclNVBKJ8p9TZnkOtEzIMf4MUZl3iQDPb4ULTp0DrqgUWiOgW3s9K8NgIlx+5Toi7VG5 XWI0Dq18LMJTLmrF4zOMjoe6Iu3JI1lFtjouwFJ24DJ3Ys30ez+Y654XqVF4u3QJhyca 0rQA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1753103123; x=1753707923; 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=E7wZegOrovQqCbTMUhnl3z3fHM13bKa8n2IzZUAsTTFLFJ95f0qlgjGsH8KdqeyaBh XkvwPIVBFd9JpKInqcZvAlgiSAyr/7Eq5SE1Wql5emVCFClRjMYfBDzMHKZSZoBR5q7J tKg8fVooaJGI6KHVx0HDm5A4ze+d0GKP1Y5hui8Jr6MG5kZdfy2bFJg/z8GQCDNm+R91 gisuOWLwAEeXEajBtlmXfZQi13VZu0X5IXmQL/M6Fgta4q0Hg15+bzCR6HTdJa7W33R+ c04hjEcG3Gm+4ArZJCV86wAScRperRT9lTjOgupZWnJ9dJ9eNBCRYAZ8Vk+jvgTQYtwI cMQQ== X-Forwarded-Encrypted: i=1; AJvYcCXWAlpC4zKc7jflev0tT9pLow8w2gTCSp+iEHV9r4de1ZjYyCbDjlZZPYU56DHNW4fDoERB2NBawglnqeY=@vger.kernel.org X-Gm-Message-State: AOJu0Yyo2bPe1a0H+2K7L2Mp+I7vvUwgnBdQbOVzlRwH2qndi12CMkes KUlV9yX9K9aD5g5Xny40RsmBs0wxiAa/8FFOS3CC/rreQTU/DcG2QWDJPoBV4qHeZtI= X-Gm-Gg: ASbGncvKwpK0+i3dq8PksqAo3jmd7si4u20H9R3IfLvYdkcHaZda5LbQDpJ0nZVfuK/ aiG3NLd6DNDWyUP57ynjSHBLyd7/DFJcbq4iSlRzbpZjJBoez2Vr4pfwxSdDN6aQPvJvOvn0lpO cJG0BD8Ry69F0YMiPRbtElSSkNH7FClQmwtxsm+y3qbPBl7loYOo5HdfDioTvvZj6eXNDj/YEOa SKy/3BY0mf4Jiq1h0yzcsKf8cFHKRc42WPbA73NJ1tlc+qmb8LLKHdKK3JsJNcmHBNCMMY0nrkV 2rPZGPPePZJng1GG9o9YX0gR5Yedz9gy9kiYOS+ylpJEUe5CnkridKkSlNWeVbOOC98gSrDlfZC LV2SL/h3DM4MWMXQzYiO2VWEZn/6rrbU= X-Google-Smtp-Source: AGHT+IF6B+UvXtx0IYpruCvoBGXj7r+Qm/RbuQTzDQMBKY6Xx1qYG8QQ00o/M8y4LjQhDqQ1Ad7BQg== X-Received: by 2002:a05:6000:25c4:b0:3b5:f151:207f with SMTP id ffacd0b85a97d-3b613aa23a2mr14510920f8f.3.1753103123024; Mon, 21 Jul 2025 06:05:23 -0700 (PDT) Received: from ho-tower-lan.lan ([185.48.76.109]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-3b61ca5c632sm10485077f8f.80.2025.07.21.06.05.21 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 21 Jul 2025 06:05:22 -0700 (PDT) From: James Clark Date: Mon, 21 Jul 2025 14:05:04 +0100 Subject: [PATCH v5 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: <20250721-james-perf-feat_spe_eft-v5-10-a7bc533485a1@linaro.org> References: <20250721-james-perf-feat_spe_eft-v5-0-a7bc533485a1@linaro.org> In-Reply-To: <20250721-james-perf-feat_spe_eft-v5-0-a7bc533485a1@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 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, Leo Yan , 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 Mon Oct 6 13:38:28 2025 Received: from mail-wr1-f43.google.com (mail-wr1-f43.google.com [209.85.221.43]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 296E32DE1E5 for ; Mon, 21 Jul 2025 13:05:26 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.221.43 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1753103128; cv=none; b=q/FT/SoZa6uZ01TmlwApUOjJig/AU9ehwYwczR1odH0JyOjTHtjNqNNjgRwIVkihzblJubnhAND77Lof5xV52KEE18bTvH5vsxJ0My/CQoEWX6J4VwCMf4YgHhbkBDocHJNP16i2lK51p0LWadGpR1Qgs7tBHm0IDo57aGeeXUA= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1753103128; c=relaxed/simple; bh=zEhlu09ovEaZOKs03esXMkQBz9lJahTpuBkvyALKn4E=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=QnH38qm7Wg5aj2cGNas7Tg3vovYmD6JocjXYOW5fy178jUqtCq3zTGv16Y42aygiAKFkmc7LRcNp1t2I0iEKLUeEwiSba9YHsITNBehDgb6RtkNb3kqE8n+ijLXg6M8RFFQ3wuG+2b/w0JbOZzXyV4NuU704gro2A+WohY+vjfI= 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=nHfGWscB; arc=none smtp.client-ip=209.85.221.43 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linaro.org Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="nHfGWscB" Received: by mail-wr1-f43.google.com with SMTP id ffacd0b85a97d-3a531fcaa05so1909692f8f.3 for ; Mon, 21 Jul 2025 06:05:25 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1753103124; x=1753707924; 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=dAXIxI7OfKIjbF0vv8PgxXhY9PyJCfDAmY7uglgU/88=; b=nHfGWscB41QhyaB0sf68SkjQcXV2MlDjDoS4n7UpIHlu+IFZUv/LeMCK0M5zjrfU7H mL0JiVHdYafAzwY36jNL2dgLZxTWtpcS5hruG3NxQCJnUcILmvN9p779m4/Ll4l5z4zP iK9MOpVyIwCxHOn+U7KCJd2HLLJ/MPvwimh+JcaRSoWU9h/vTA+z9j3e9AENqyuCyr45 +uSSWS6JFJNRDGYI/a7RJ+uf8kDWNtCk3iWmXwwxsuYLV9ZPyT7ZPMqluFDr9C+UdaEF +WBHY7xaMPk1GGy+IOucVsa8exiXkgne+5QtsGchmbU75HoQdlnjNY7HCW3ELmADwnEm ozxg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1753103124; x=1753707924; 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=dAXIxI7OfKIjbF0vv8PgxXhY9PyJCfDAmY7uglgU/88=; b=O4eljZvwrpz9JlO1NILBw1fkuhfcibxIC4fTnH9UPxC6fwFJMPmK2PpABAf5L5QtIE HjxEEQ/P9nJgEVSH1P212UoADwg6tEKoxMyAEJ/PObtdTOCAF5xJa09phR5eDgVR007E Rmnex+MICoiPf0DaoSIpK5crYPLDkfe7icCsnZB9MZbQjQYiUf5OzCLBkGr1sHrVob8z xIkp1CtA85EacVtSrGGkfqm8vo3Op8HyoI5gO0GdSHumNvRXBnt3g5EMc46XR6Z/AS/y rW9wjS0o+5CgXS9JZJVLPagZjpTzG3xVg9d2V/yM5CowwC+Xs02dwDhF5ulxnZWqE7Da RjRw== X-Forwarded-Encrypted: i=1; AJvYcCUzgFTirrIfkPAEyW5BjwzecU47Id3BwfvDud5he5/ZCBvg+pKL6KsfHnsxHm0SwF3ZFFR1gpTRqDU8wE8=@vger.kernel.org X-Gm-Message-State: AOJu0YwYeLgEmROe4QJ1j2tDX+ZbztDeJ6MI5AOIaOBHmq6Dqb1Kp/IN 3AM2qnus/yvg/GT9uR7yG/ML4KrW6ADIYgN5K4iD2u+vwG1rSuHRCB2Fi4IrKz9MPXk= X-Gm-Gg: ASbGnct8lv75Qmygo22UukNc8wgT+P7HshbAVUKW7MAhMz2iMmKE6pDpcNNiuwV9qHU BrNxAi8muULnnMROFC9DURi6x+kiZrLT+1wy7+MjSIETJdbZCFH33ecUv1H7TKYeyghy9MLQyQz 7wp+2DidlqrJ5QukWazNsUHEl97DmsflpQijan32LZjaeBbG5Zp121/RIgleXCfTPPRN2WpOKDA RsevVUb7YFBYnauVf6c/ke2R3ol9LfdJDTvR3nhO4qCKAHEuZmX+tK2fZKcRHfj7NDW5xFNOfGR C/9LJ25jY3WrwfwZMSU3FiZ0VT8/tf3wdjvJEJY9qrR1PUocLD3iBz5bVLCNbaDmijS4VmpVJtD ul9l3LN36o/53+YwLdiDTfkYhHyCDJTwJub3VUTDBBg== X-Google-Smtp-Source: AGHT+IHSLKc1NvrbTSBAIr05h8vpMPbd8ZufmUFJ66bwSLRixnUu1C9KFjza66XJ2aN/SIFzmkRf3w== X-Received: by 2002:a05:6000:385:b0:3a6:eb59:f37f with SMTP id ffacd0b85a97d-3b60e4c5206mr17337606f8f.12.1753103124357; Mon, 21 Jul 2025 06:05:24 -0700 (PDT) Received: from ho-tower-lan.lan ([185.48.76.109]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-3b61ca5c632sm10485077f8f.80.2025.07.21.06.05.23 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 21 Jul 2025 06:05:23 -0700 (PDT) From: James Clark Date: Mon, 21 Jul 2025 14:05:05 +0100 Subject: [PATCH v5 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: <20250721-james-perf-feat_spe_eft-v5-11-a7bc533485a1@linaro.org> References: <20250721-james-perf-feat_spe_eft-v5-0-a7bc533485a1@linaro.org> In-Reply-To: <20250721-james-perf-feat_spe_eft-v5-0-a7bc533485a1@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 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, Leo Yan , 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 5ec2e5607987..5f624a63d550 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 2380de56a207..2fccdf5879c8 100644 --- a/tools/perf/util/parse-events.c +++ b/tools/perf/util/parse-events.c @@ -291,6 +291,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"); } } else { is_pmu_core =3D (attr->type =3D=3D PERF_TYPE_HARDWARE || @@ -848,6 +850,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", @@ -896,6 +899,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: @@ -965,6 +969,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; @@ -1173,6 +1181,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: @@ -1314,6 +1323,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: @@ -1352,6 +1362,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 ab242f671031..81af219cafb3 100644 --- a/tools/perf/util/parse-events.h +++ b/tools/perf/util/parse-events.h @@ -58,6 +58,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 4af7b9c1f44d..3f83aaf33a34 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 609828513f6c..c7782916f932 100644 --- a/tools/perf/util/pmu.c +++ b/tools/perf/util/pmu.c @@ -1508,6 +1508,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: @@ -1555,6 +1559,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; } @@ -1875,6 +1882,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 71b8636fd07d..49ac47e2b44f 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 Mon Oct 6 13:38:28 2025 Received: from mail-wr1-f52.google.com (mail-wr1-f52.google.com [209.85.221.52]) (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 11AC12DEA6A for ; Mon, 21 Jul 2025 13:05:27 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.221.52 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1753103130; cv=none; b=O7xC+IMadzB8rOTezNNoCCKygraoziXnqBmmvlb+pQ/5jLOpCyyEYJpuyiF6LXMoE3gTk/+TnRyUndRWqBZukKThmVSgfIrSTco21oRhGA5tCm5oFStwzpEk9iN5w/BubQEt9qcAmmGPIBYSzaNM980ZHG4dPS6oHQhrLeMRKVk= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1753103130; c=relaxed/simple; bh=aRUWGynzXd2I0iPJ8E252lMe7rGfIx7dGynoHirUSWM=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=UXh5ykXGv5sF2MENduWi7VU7UPybp3tpLPgu6LZzWzdi2efE8Pkvex+KWUiVaMwsFK4cE1Vp3gYQXN+U8Pk9XY45SDiy8uh4640Zd1bRQfuaWV5ESymsjyOwNG+PwC1SDjwvc6FWH5/jmdfIJBrbN+m/IzfMRNrNj5Pcm+Tt+Yo= 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=ZlXATXpj; arc=none smtp.client-ip=209.85.221.52 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="ZlXATXpj" Received: by mail-wr1-f52.google.com with SMTP id ffacd0b85a97d-3a54700a463so2408680f8f.1 for ; Mon, 21 Jul 2025 06:05:27 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1753103126; x=1753707926; 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=ZlXATXpj8cv2N2JOljaVFdsZZZX4/EsoydpSkAoJe8/1kVG0ahyVfrwaQnRxIyLU5S NIYhZqzgofY2hVSHcBDk2Na1EoC97wGyxFWEQG9GZ9XPjNyO1GUv8YhAHe/j2dWI1SCk jGCUYeLz7AxGLNiuW5tMtCi5f03iQJNu4ZAOTBE3ao4h+1VE7l/dSefne5S++ufftstA gJTyzZ5tzvKzdW9v154gC4ERfH4TJZXpqdPn0+I3gk1FdbC80krGePc/d60QYQQWVGkA fVU3JVR0101CJNVLuKbM3ExWcSYTOvIQf/+itJzAWBbfVBFnCuDcmDbVXjZajk26Pw1C ZjYg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1753103126; x=1753707926; 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=OdFY2kRA3yDw0N+hs0NXvBto2W3lRuMfsXzX2BizeFqcQd5zztpLY6MW+rAVCSfEIf iia0X2UXk5ThErqx4NEbN12oo1Q/7PioaDhVzvUpnWYKONhamgK9djbaQBA88D9snQv5 J5xxBJ3jX7yRBSsR6RT6DxEIU7Akrbda5sOe5YfjwNSA39AIEYu2fR6mk21w/99MQljS pTjzv3PcYvDvPht6yBkn5Xkj7xRxl2/F3tqMFc1dqDLLxx1A3gaxH+u6eA7G3grIp1tj xWwODUS1eN0qOtlTOPQ5LL9bviVOSrflH2OTWvYYr2t/A1EwIXYu49w8CfXgsxJa17x2 KPIA== X-Forwarded-Encrypted: i=1; AJvYcCWT8sHPEzv6WWONFr3UFxpcXLdwG127och4boE3uqYVVnEMF2KqzPuUoMNZzDiloP1tqN0Z3WUMw2Bm2cM=@vger.kernel.org X-Gm-Message-State: AOJu0YwHqJth3yuEv457XhpG4sDxRFgvsejLNKKxt3QC6SanWP3qwSzm UanKTN0oQznb5+jeFwqB5PEZDEuTQyUHDOhswgAS6nnbrGrgd2gCVMQV3ulGCY9/Am4= X-Gm-Gg: ASbGncswoLEzhCe1FEZsvYf5SVHi/jPCpDKXzaiEii6fY7gJV25W5BlSd26QT/zs/OZ TAtX/zER7WVMRVK+LD8kH/ErImeTlmk8o/E6IgaEvcFdESHuu2tQ92iEGY1sEpfwmDIGOElC/X8 D0Xj8W2cN/Xqj+rXw7e+mfJ+fpU13y/+bZM22EqwxOcYYvh647w1gCys1NkXcK2ZqTDjsm7eSVu Jgjk2VGjYKh7PVVTdmWefp6iSu7Libg5v0MyHip71KR0/0eTGYQtep50OntQ3wSSQ32nN1HAawD gmnUPPU2buqEOUilbEYmC0T4vUU0rd50xPGPnCo+5m9HbRnTVMWnfw7ZhvLA5ngpRldBV8NMWwm cpFZeRUpVhSPc3gylj7Sg2Mo5f58RiPE= X-Google-Smtp-Source: AGHT+IEQRxB7CE+HdieDcueXWljG81gay0nli7hyPKWhyc70neAo7UklcQhq3PGP9NmaS8BVDvp06g== X-Received: by 2002:a5d:64c4:0:b0:3a4:e231:8632 with SMTP id ffacd0b85a97d-3b613abe2c2mr14295215f8f.12.1753103126134; Mon, 21 Jul 2025 06:05:26 -0700 (PDT) Received: from ho-tower-lan.lan ([185.48.76.109]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-3b61ca5c632sm10485077f8f.80.2025.07.21.06.05.24 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 21 Jul 2025 06:05:25 -0700 (PDT) From: James Clark Date: Mon, 21 Jul 2025 14:05:06 +0100 Subject: [PATCH v5 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: <20250721-james-perf-feat_spe_eft-v5-12-a7bc533485a1@linaro.org> References: <20250721-james-perf-feat_spe_eft-v5-0-a7bc533485a1@linaro.org> In-Reply-To: <20250721-james-perf-feat_spe_eft-v5-0-a7bc533485a1@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 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, Leo Yan , 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