From nobody Sat Oct 4 17:34:18 2025 Received: from mail-wm1-f52.google.com (mail-wm1-f52.google.com [209.85.128.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 712792EA72A for ; Thu, 14 Aug 2025 09:26:00 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.52 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1755163562; cv=none; b=f7FxiSIxWmka1qDhIUFThnbQlpt9zBnqiLWzLoqGkh4nUldyF4TCxglOyi6GyFs32O5Z9tHplcy9+SDIHGLfJttZbw6mbgcgmLKbs1KcK4es19GKmxeL4X35vOqUFd9983D0RblTmG4qT8AaTxYEboAKoRFKHlJ4QpJqZPgNKDk= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1755163562; c=relaxed/simple; bh=51vdVVrDG2YLBYS3Pf8NCD6LBuxxPOs+8V116Ol8P34=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=FpQI3HiCfs6Jke35jisJ9dtAnJRJRca8/HLmsz54Ve7LjeaJAKIerEV3zVgC6niTPHft1i31vchMXhVN2ZyyQoFGjk8FMSlSm51d114Nz03huCqUaQhdLFNsi6vSVVfkutbPOndK9ymRR+boEHDrLW5KNcw1u7QEyVlnbx0cqog= 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=dVE1kZ4D; arc=none smtp.client-ip=209.85.128.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="dVE1kZ4D" Received: by mail-wm1-f52.google.com with SMTP id 5b1f17b1804b1-45a1b066b5eso3225235e9.1 for ; Thu, 14 Aug 2025 02:26:00 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1755163559; x=1755768359; darn=vger.kernel.org; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:from:to:cc:subject:date:message-id :reply-to; bh=CE9jiANI0cz/l/cDSr25IEHnZ3OQaeUcRCYLlwFZaDU=; b=dVE1kZ4DMWvjobvT1UbW3o+gMQ71xDrIorQujvcxwL+bteea2tnhFv2zL1jsuSw7dA d22C3relist1PqWR8OdDQ0B3PS8qL5fifNTbjsmNyiBNtbdSKdYUEygKwnwfXgTqQhog mgrHyRMq8L2J2xdlUeFIlZQOW760vJliGPNvNnwIP2J9+TtMRfot9vje0YufpRBO9ilb dsh8vDl0e6EQsGlMWyG7Kb5FdZBQ4u6UZQdVZNQCBTtrDVc0Dc6dO1cAnjzRvlG9tNLI s72tNplwzYN01Upc8pWpmZcLx9kDNMPA1CnQWYcAVVa7R7ekUkYTIEF38LyN09tLG27y z1bw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1755163559; x=1755768359; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=CE9jiANI0cz/l/cDSr25IEHnZ3OQaeUcRCYLlwFZaDU=; b=qHtgYP3/PJLV7MOIUwL1zG563WLAyzSB2JiSC8mNxegBKP1D8hgUf8LeQsESHvMEcM eVHVfGHT8wgxJpeME9rCF8//9u249apeZX1GHcTlEwu2+IFRTNGH6f3025NJz6GPUWpF AUc2BKfg0Iq8AQEqSEZ9/Ezds0tP7WHg3Z3Smnvw+8WwCJi9Si3EfQkPqYf3bldy4sqI H50YNhCkOPL/gBNTo1SeDb366TC9rW95YusyNOc8nDZTgYd3GQy/tVuizJeKWoS4eH9E 43pmazpsiNTOMcvAfPccgzZC8RP+Tw7UJF6jrydbIKBWf43HzS1yJKbrKZ7h1IMRF5qY lLnw== X-Forwarded-Encrypted: i=1; AJvYcCXBzwZVqFjNq8qZkTS3YUEI+/APNGRogBAokD5pL9oGf0vPFppnzeNu2UsyfDm3GiZ7BreSlWqoEOkq7Y0=@vger.kernel.org X-Gm-Message-State: AOJu0YwRo93BbRNUUdj2FOs65KHA446enuQ1CXzrkzh5wj3CCOnM7tWn bPokc3INbASoJvKDyaeMLj/V9w+nzkodHIbgzT/NRa5KDDhRdo+HnEbemFYbHWbuZ9Q= X-Gm-Gg: ASbGncvCW1/btr6oYvQJDYUbeIqeapodKHtUr7YWXkDSXyUG4Am2P+5llzP5zKcsKy6 1sPy+7Z9JgUCEMpyzKaOmQr57X9D+lW3xB2BBhOKdmkHADMozES3vqV8j28C+AwA31WtwWV8Y5y DutI2VoYJ08/Gm4iWNy/ksNzXNcCsRFcDWZUeKZ8Z1ONQzJLwE5CU3KYhxnNezLQczMWISHLVAl RSAnU+SwZj30qRyFb2wD+CTaSUJFCPFFp123YyFsqoNXaV21rzrAyfIOj4U654g4rJ8X9kJVrwq +lqa1XuFNlTfGcRnD6DK36D1wNkd699f0gjUbGnn+AcDqKReCTKaP0yIZu1R2GNFTpiBaF7p/lw geU9w+pRUbUGU3h6KSDZUr1EY6bhitY4= X-Google-Smtp-Source: AGHT+IH3aH4s+NYnAVYfqbXpSrP1ix9p1QHXe6mSxBCrVv3jDGybUKX6JctDT3xmTAkJSTP0/FwOIA== X-Received: by 2002:a05:600c:450e:b0:456:496:2100 with SMTP id 5b1f17b1804b1-45a1b6753a2mr19666565e9.31.1755163558609; Thu, 14 Aug 2025 02:25:58 -0700 (PDT) Received: from ho-tower-lan.lan ([185.48.76.109]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-45a1c76e9basm14536775e9.21.2025.08.14.02.25.57 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 14 Aug 2025 02:25:58 -0700 (PDT) From: James Clark Date: Thu, 14 Aug 2025 10:25:23 +0100 Subject: [PATCH v7 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: <20250814-james-perf-feat_spe_eft-v7-1-6a743f7fa259@linaro.org> References: <20250814-james-perf-feat_spe_eft-v7-0-6a743f7fa259@linaro.org> In-Reply-To: <20250814-james-perf-feat_spe_eft-v7-0-6a743f7fa259@linaro.org> To: Catalin Marinas , Will Deacon , Mark Rutland , Jonathan Corbet , Marc Zyngier , Oliver Upton , Joey Gouly , Suzuki K Poulose , Zenghui Yu , Peter Zijlstra , Ingo Molnar , Arnaldo Carvalho de Melo , Namhyung Kim , Alexander Shishkin , Jiri Olsa , Ian Rogers , Adrian Hunter , Leo Yan , Anshuman Khandual Cc: linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, linux-perf-users@vger.kernel.org, linux-doc@vger.kernel.org, kvmarm@lists.linux.dev, James Clark X-Mailer: b4 0.14.0 Add new fields and register that are introduced for the features FEAT_SPE_EFT (extended filtering) and FEAT_SPE_FDS (data source filtering). Tested-by: Leo Yan Reviewed-by: Anshuman Khandual Acked-by: Will Deacon Signed-off-by: James Clark --- arch/arm64/tools/sysreg | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/arch/arm64/tools/sysreg b/arch/arm64/tools/sysreg index 696ab1f32a67..b743fc8ffe5d 100644 --- a/arch/arm64/tools/sysreg +++ b/arch/arm64/tools/sysreg @@ -2994,11 +2994,20 @@ Field 0 RND EndSysreg =20 Sysreg PMSFCR_EL1 3 0 9 9 4 -Res0 63:19 +Res0 63:53 +Field 52 SIMDm +Field 51 FPm +Field 50 STm +Field 49 LDm +Field 48 Bm +Res0 47:21 +Field 20 SIMD +Field 19 FP Field 18 ST Field 17 LD Field 16 B -Res0 15:4 +Res0 15:5 +Field 4 FDS Field 3 FnE Field 2 FL Field 1 FT --=20 2.34.1 From nobody Sat Oct 4 17:34:18 2025 Received: from mail-wm1-f41.google.com (mail-wm1-f41.google.com [209.85.128.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 B6B442EACE7 for ; Thu, 14 Aug 2025 09:26:01 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.41 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1755163563; cv=none; b=fRTZEtRcDVy/lGcPPStGFto9QgIcvV5yQKXzydS6JvtVOa3wwIOujksLHJMzBiBy3g7CJajToG7FsBPUKv1ah3yZYxkeGcUYiF27uNcAjhq8vebCTqUoV+R9miabRMKf8jy3OnY5JP78Bszapw6WsL5LYwMRF1l6Y8uYkIFR0+Q= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1755163563; c=relaxed/simple; bh=MJ4HAF1ujEaX4WWG33h1bzdaHdgxbBRIaAA8EKMlhq0=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=IFz4GRCl6M9/APDrG/uhjHhyriWcePQWbEWmwgw6QBAiDSyEQlxNSIABETApVwp6lU6hrsaxiVdwDUq5vVKfP2KNsSf+YD+Qa9olhHIZL2lVNPWtkdT47bVf2HLosGB2SnvtEu37Y0gMMA9EsEbGH0CiILZgsUkLqHTfTpvrImk= 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=ZmVVqCkp; arc=none smtp.client-ip=209.85.128.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="ZmVVqCkp" Received: by mail-wm1-f41.google.com with SMTP id 5b1f17b1804b1-45a1b0bd237so5645395e9.2 for ; Thu, 14 Aug 2025 02:26:01 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1755163560; x=1755768360; 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=wBCwCeMPq8Yt3PwfMa3l8mtDD8QogBIfg4uFSkaUtvA=; b=ZmVVqCkpZ4ZBp/ZEIjGiloIvluCsx2czb0PZnaMeFg717bk5uz3mU2AXs2905RFrfv x1icYkn2/hGv/D+tThrXVnYN+z7qnCX2GjzeLs85jOD2exX5ApRIwN/kPf59VwP39sZu BhMtLDPaIXsNSw6OLLGurzQ4in6KlwFqByk5i+j3HF8F/T0hFLuqWckxLbt2zMdB2A+e xkvwR630NWPITEpgqZ1pWev6E/SEKzSnf9Nq2NpuH6godSkrKCF58DtGOE6cMmzY0JHJ EmWwMgK9dW9CBhIVg224BoXN3FThJZvNzsi2/nOnJ2rtkYzEKFNPrPJiQnAGjGDN59LX ov/Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1755163560; x=1755768360; 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=wBCwCeMPq8Yt3PwfMa3l8mtDD8QogBIfg4uFSkaUtvA=; b=mkw34cFjKaE2z/AiwypjaxFJ4Hvz0LC31/0iyZvLIrRzU3Q3eUIAu1fyXTjVFvaHL8 qeMY4mrtP7FAoPdd4q6xX4gSVxw2b4sd4CwiPpGxXBFetIif5ws6DcdLQKXVr4lc5lup gL32QpzCg8tM/Y0Ie0vHIMlkALDRzmD7ZeK3Zft0PxhlScjn8jsQzTXwKQGdUcayLc94 nGEmMfjACtd07nIZL9xGak0xsQ/V3RTiLK4EBiKuj2DK4xLuvxp8QVUgEQAloi1iJK03 emQElBdp2vkfOAIOnvlmlF51xvb1CUPOD3t5lMs6TQikUyc1oKmKUFG6OUvAfl+jBiD/ G40A== X-Forwarded-Encrypted: i=1; AJvYcCVL9jX+wW6vDg1FWLl15dDfCERg53+V7pEyhYN0X7vpgLwwNsLxHdhn3bjSYazps0Oe2+KlWVGRydvUdzw=@vger.kernel.org X-Gm-Message-State: AOJu0Ywr9+XolW3okd5r/qAQBWkaBSX/A34S6I9ZY71pnxvtDKA2CG8J 7VceQX/kLhvQ1LxNGSL+HxeRV70IZl3FUe62YyS6DmZ3yxgTnTkDEywn04KsDo2rboE= X-Gm-Gg: ASbGncu/tfL8lfrjN/xZKD44etpdc21uT3t0HzutQpjAGET9xSUCbLZQBjFdZ/dNIoz GE2ZbUvkEarBWZTpaTgCbCnbsXC9XIktIAeCdsdhxQ9h4Rti7HGwhinrp45LpkJpqstNlKVN3Jz JWRKNKPA8eND9FMaRnZuzOoAhphZOyNCzlf49wH95QAZpNnXAY7bvEqOLN3u3Tu4eU63A+KNa9/ VL1x+ANW8htFPHf/hE2VzQOeIPuygcN8DMgpE/h4smiJU6+qNR2Qf9RrrcnwKLywo01Jv54DeoV ngUCdnkemqnY8NN6fHi9o+AE2rty7iLX/NOCW/txBH8yAeY9xymHPTDbKRSOKD7m0VnwoWtYdm6 ZUBJmC9et212/0vfJjjXUILET/qkHWnw= X-Google-Smtp-Source: AGHT+IEY/vBBsMat/zDRtGVwETN+EInUSQGpLUXfrAhbT2usXhxgsQh4b8EMvcN2GhmxPcLHpgwORw== X-Received: by 2002:a05:600c:3b8e:b0:43c:fc04:6d35 with SMTP id 5b1f17b1804b1-45a1b605866mr20364335e9.4.1755163560021; Thu, 14 Aug 2025 02:26:00 -0700 (PDT) Received: from ho-tower-lan.lan ([185.48.76.109]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-45a1c76e9basm14536775e9.21.2025.08.14.02.25.58 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 14 Aug 2025 02:25:59 -0700 (PDT) From: James Clark Date: Thu, 14 Aug 2025 10:25:24 +0100 Subject: [PATCH v7 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: <20250814-james-perf-feat_spe_eft-v7-2-6a743f7fa259@linaro.org> References: <20250814-james-perf-feat_spe_eft-v7-0-6a743f7fa259@linaro.org> In-Reply-To: <20250814-james-perf-feat_spe_eft-v7-0-6a743f7fa259@linaro.org> To: Catalin Marinas , Will Deacon , Mark Rutland , Jonathan Corbet , Marc Zyngier , Oliver Upton , Joey Gouly , Suzuki K Poulose , Zenghui Yu , Peter Zijlstra , Ingo Molnar , Arnaldo Carvalho de Melo , Namhyung Kim , Alexander Shishkin , Jiri Olsa , Ian Rogers , Adrian Hunter , Leo Yan , Anshuman Khandual Cc: linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, linux-perf-users@vger.kernel.org, linux-doc@vger.kernel.org, kvmarm@lists.linux.dev, James Clark X-Mailer: b4 0.14.0 FEAT_SPEv1p4 (optional from Armv8.8) adds some new filter bits and also makes some previously available bits unavailable again e.g: E[30], bit [30] When FEAT_SPEv1p4 is _not_ implemented ... Continuing to hard code the valid filter bits for each version isn't scalable, and it also doesn't work for filter bits that aren't related to SPE version. For example most bits have a further condition: E[15], bit [15] When ... and filtering on event 15 is supported: Whether "filtering on event 15" is implemented or not is only discoverable from the TRM of that specific CPU or by probing PMSEVFR_EL1. Instead of hard coding them, write all 1s to the PMSEVFR_EL1 register and read it back to discover the RES0 bits. Unsupported bits are RAZ/WI so should read as 0s. For any hardware that doesn't strictly follow RAZ/WI for unsupported filters: Any bits that should have been supported in a specific SPE version but now incorrectly appear to be RES0 wouldn't have worked anyway, so it's better to fail to open events that request them rather than behaving unexpectedly. Bits that aren't implemented but also aren't RAZ/WI will be incorrectly reported as supported, but allowing them to be used is harmless. Testing on N1SDP shows the probed RES0 bits to be the same as the hard coded ones. The FVP with SPEv1p4 shows only additional new RES0 bits, i.e. no previously hard coded RES0 bits are missing. Tested-by: Leo Yan Signed-off-by: James Clark --- arch/arm64/include/asm/sysreg.h | 9 --------- drivers/perf/arm_spe_pmu.c | 23 +++++++---------------- 2 files changed, 7 insertions(+), 25 deletions(-) diff --git a/arch/arm64/include/asm/sysreg.h b/arch/arm64/include/asm/sysre= g.h index d5b5f2ae1afa..20cbd9860c8f 100644 --- a/arch/arm64/include/asm/sysreg.h +++ b/arch/arm64/include/asm/sysreg.h @@ -344,15 +344,6 @@ #define SYS_PAR_EL1_ATTR GENMASK_ULL(63, 56) #define SYS_PAR_EL1_F0_RES0 (GENMASK_ULL(6, 1) | GENMASK_ULL(55, 52)) =20 -/*** Statistical Profiling Extension ***/ -#define PMSEVFR_EL1_RES0_IMP \ - (GENMASK_ULL(47, 32) | GENMASK_ULL(23, 16) | GENMASK_ULL(11, 8) |\ - BIT_ULL(6) | BIT_ULL(4) | BIT_ULL(2) | BIT_ULL(0)) -#define PMSEVFR_EL1_RES0_V1P1 \ - (PMSEVFR_EL1_RES0_IMP & ~(BIT_ULL(18) | BIT_ULL(17) | BIT_ULL(11))) -#define PMSEVFR_EL1_RES0_V1P2 \ - (PMSEVFR_EL1_RES0_V1P1 & ~BIT_ULL(6)) - /* Buffer error reporting */ #define PMBSR_EL1_FAULT_FSC_SHIFT PMBSR_EL1_MSS_SHIFT #define PMBSR_EL1_FAULT_FSC_MASK PMBSR_EL1_MSS_MASK diff --git a/drivers/perf/arm_spe_pmu.c b/drivers/perf/arm_spe_pmu.c index 369e77ad5f13..86c9948ab5a0 100644 --- a/drivers/perf/arm_spe_pmu.c +++ b/drivers/perf/arm_spe_pmu.c @@ -89,6 +89,7 @@ struct arm_spe_pmu { #define SPE_PMU_FEAT_DEV_PROBED (1UL << 63) u64 features; =20 + u64 pmsevfr_res0; u16 max_record_sz; u16 align; struct perf_output_handle __percpu *handle; @@ -697,20 +698,6 @@ static irqreturn_t arm_spe_pmu_irq_handler(int irq, vo= id *dev) return IRQ_HANDLED; } =20 -static u64 arm_spe_pmsevfr_res0(u16 pmsver) -{ - switch (pmsver) { - case ID_AA64DFR0_EL1_PMSVer_IMP: - return PMSEVFR_EL1_RES0_IMP; - case ID_AA64DFR0_EL1_PMSVer_V1P1: - return PMSEVFR_EL1_RES0_V1P1; - case ID_AA64DFR0_EL1_PMSVer_V1P2: - /* Return the highest version we support in default */ - default: - return PMSEVFR_EL1_RES0_V1P2; - } -} - /* Perf callbacks */ static int arm_spe_pmu_event_init(struct perf_event *event) { @@ -726,10 +713,10 @@ static int arm_spe_pmu_event_init(struct perf_event *= event) !cpumask_test_cpu(event->cpu, &spe_pmu->supported_cpus)) return -ENOENT; =20 - if (arm_spe_event_to_pmsevfr(event) & arm_spe_pmsevfr_res0(spe_pmu->pmsve= r)) + if (arm_spe_event_to_pmsevfr(event) & spe_pmu->pmsevfr_res0) return -EOPNOTSUPP; =20 - if (arm_spe_event_to_pmsnevfr(event) & arm_spe_pmsevfr_res0(spe_pmu->pmsv= er)) + if (arm_spe_event_to_pmsnevfr(event) & spe_pmu->pmsevfr_res0) return -EOPNOTSUPP; =20 if (attr->exclude_idle) @@ -1107,6 +1094,10 @@ static void __arm_spe_pmu_dev_probe(void *info) spe_pmu->counter_sz =3D 16; } =20 + /* Write all 1s and then read back. Unsupported filter bits are RAZ/WI. */ + write_sysreg_s(U64_MAX, SYS_PMSEVFR_EL1); + spe_pmu->pmsevfr_res0 =3D ~read_sysreg_s(SYS_PMSEVFR_EL1); + dev_info(dev, "probed SPEv1.%d for CPUs %*pbl [max_record_sz %u, align %u, features 0= x%llx]\n", spe_pmu->pmsver - 1, cpumask_pr_args(&spe_pmu->supported_cpus), --=20 2.34.1 From nobody Sat Oct 4 17:34:18 2025 Received: from mail-wm1-f52.google.com (mail-wm1-f52.google.com [209.85.128.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 221212ECEAC for ; Thu, 14 Aug 2025 09:26:02 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.52 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1755163565; cv=none; b=M+PR8LvB6KMjfDI16loPTaCaENq5wuHMZhrLEZOux8KKr1zBGqCB2oGjvm5ZG/wwVSrfGgTeV/5+ChhHqC7biggjSOLcCpnLxnfPktnE1SkhqFrU3lKiycEIoUU5Cgny5BGqlazInvaNQTiSMneyVav5xLBtIL8RS1XdMFPypUE= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1755163565; c=relaxed/simple; bh=1dn2TsDH9c3qn851HU6KhoRjFDuyNupOzJtkpyRLaL0=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=U7LPzRxlcbkDXdDsJwnXv8AOpPzD3eN6gLcv8RlLyL/ZXoxRbaU2a4xdzfjEH2PuwiZAWyZNmWH2yW4L/IwQn1kyu136JRBYbDVEgJmeCww4Num0UrDESriaN9V8sRCa/+faQnNTiUlkvLwNhdY9CHwZmnrsgfhUNA/dJiHhPto= 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=rwh7yeme; arc=none smtp.client-ip=209.85.128.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="rwh7yeme" Received: by mail-wm1-f52.google.com with SMTP id 5b1f17b1804b1-45a1b005a3bso3357495e9.0 for ; Thu, 14 Aug 2025 02:26:02 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1755163561; x=1755768361; darn=vger.kernel.org; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:from:to:cc:subject:date:message-id :reply-to; bh=2rccDGxo7Zi/+ePrAmZStYRWWCBeSec1uJGq7oyHErE=; b=rwh7yemem+hPFddbg7RvodRLRYiNXJeyUlZS14YQGE8HSCOj3ZxdTHJTzplzD4ghJB F1pnjA9Ri0x+5+1J4KJRq00yf78V1lfmjQUxrDAQ52845Y/SrAD/TnGKIu5FWWYuK9ya iDEaW44r5Y032/ZOCS7x0GpnxZqmmZAeBs3KW8T6uqkHAex/70s7uWnyloiQnWdvNLXs h6pRRAyhmzreNVvCLUW+FGgerBs6zYoIxRtUu3NLOqDRIyUrotxzsY8uuWgxv8rjUI4w xxhZlSbHOhfD7CmopAv185PGli3V3oN/QbPzKwKa2eGnnQNDPUfNbJIcd/0PLyTR2k+p U47w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1755163561; x=1755768361; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=2rccDGxo7Zi/+ePrAmZStYRWWCBeSec1uJGq7oyHErE=; b=XusAlmTUolTSi5N+ONedJIhnNSw1oTG0tgVYP840sT6MmCedyMvoq78xEQ4eaEfpCj wAfa9Or++PtAdaT2wYsiU0f1spSMrwXL3E7Ue7O4sNwe7QFhhLLl8hlVoMhBwyssUw9O VvR0852w+EBdiZ6jmxd2Fjtq92H30tGfSWghY/0fW7Uk9ihRoZWclUGkkcZFLa9Uz0Oa Q0BTq0pDFeXHir7HD2Nsa5glfJo/l2wZ9Vbcvft0cNuz3W8Dkn1lBcaBgO/A6PX+2NCz Xe3LTGcDZx0t1m5ifyHj2WqNlRczkwt9faVYf8rsUlBGb2290qitdZhHhrPrI6n8JGRt aKYg== X-Forwarded-Encrypted: i=1; AJvYcCU9FNalQqau72C1jTazR6Crd75zh39h206Wa2IfumXBcQy/lPOOSa2wqfEFpuGsBgAjc1iUUHhfj24QjEI=@vger.kernel.org X-Gm-Message-State: AOJu0Yy1RlzcSmkgoQ3V+Qt7EnmdxuY2zRxPhRr0lOru0l6V4eonGxkr hXmAlFShrbOE7MArRqhULaXBJKnS5RzS+lzkNezoEOoa+5GfMSySPBIySVHWGJvlHq8= X-Gm-Gg: ASbGncsIqJHO5fSTwSm7in0NM5tVQ5kefRoMljdyJPhx8aMAVXRosjaUc2SJItKWJg6 24iCRqWGNd1ERQPSwf0TUTHLNgB17ui70gCPPdioIK3R5SK9L6tUWJWZ1oO7Y8xcgxgzbxT6PJ6 NUhgJKbqibGX8cl5CEEYOTp5244PYFnBHYxUlYqtnIj4b7Pp0ebCBxjh5l8Gc9OVLXllHFjwL7q bRE4iZYbSEIxHaQSebXA/qUCI+daT64U+LDBdtWN9qzoaBHRUCGujHh1+PTa+Lk2StRmuD0GL/T g3qL9daQ5NNwrrVRW02CEpT7gB8pSIo2PBe6IrbCKrFgDdxRkzS7HskQy5E/gkOAlq6ZcNjol6j s1NCJyrhkYVdKqw4OWZ4hDDglg2XO4x8= X-Google-Smtp-Source: AGHT+IF3mN9YM+z59LW2L2RCIJP1151F1ryrxu3DBo1bIpBosGzWHxhnT9S0+1q8xFvPjiRKK5C0xQ== X-Received: by 2002:a05:600c:4705:b0:458:bd31:2c27 with SMTP id 5b1f17b1804b1-45a1b6535bemr16452535e9.23.1755163561367; Thu, 14 Aug 2025 02:26:01 -0700 (PDT) Received: from ho-tower-lan.lan ([185.48.76.109]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-45a1c76e9basm14536775e9.21.2025.08.14.02.26.00 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 14 Aug 2025 02:26:01 -0700 (PDT) From: James Clark Date: Thu, 14 Aug 2025 10:25:25 +0100 Subject: [PATCH v7 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: <20250814-james-perf-feat_spe_eft-v7-3-6a743f7fa259@linaro.org> References: <20250814-james-perf-feat_spe_eft-v7-0-6a743f7fa259@linaro.org> In-Reply-To: <20250814-james-perf-feat_spe_eft-v7-0-6a743f7fa259@linaro.org> To: Catalin Marinas , Will Deacon , Mark Rutland , Jonathan Corbet , Marc Zyngier , Oliver Upton , Joey Gouly , Suzuki K Poulose , Zenghui Yu , Peter Zijlstra , Ingo Molnar , Arnaldo Carvalho de Melo , Namhyung Kim , Alexander Shishkin , Jiri Olsa , Ian Rogers , Adrian Hunter , Leo Yan , Anshuman Khandual Cc: linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, linux-perf-users@vger.kernel.org, linux-doc@vger.kernel.org, kvmarm@lists.linux.dev, James Clark X-Mailer: b4 0.14.0 From: Leo Yan Expose an "event_filter" entry in the caps folder to inform user space about which events can be filtered. Change the return type of arm_spe_pmu_cap_get() from u32 to u64 to accommodate the added event filter entry. Signed-off-by: Leo Yan Tested-by: Leo Yan Signed-off-by: James Clark --- drivers/perf/arm_spe_pmu.c | 22 ++++++++++++++++++++-- 1 file changed, 20 insertions(+), 2 deletions(-) diff --git a/drivers/perf/arm_spe_pmu.c b/drivers/perf/arm_spe_pmu.c index 86c9948ab5a0..ba55bc3db708 100644 --- a/drivers/perf/arm_spe_pmu.c +++ b/drivers/perf/arm_spe_pmu.c @@ -116,6 +116,7 @@ enum arm_spe_pmu_capabilities { SPE_PMU_CAP_FEAT_MAX, SPE_PMU_CAP_CNT_SZ =3D SPE_PMU_CAP_FEAT_MAX, SPE_PMU_CAP_MIN_IVAL, + SPE_PMU_CAP_EVENT_FILTER, }; =20 static int arm_spe_pmu_feat_caps[SPE_PMU_CAP_FEAT_MAX] =3D { @@ -123,7 +124,7 @@ static int arm_spe_pmu_feat_caps[SPE_PMU_CAP_FEAT_MAX] = =3D { [SPE_PMU_CAP_ERND] =3D SPE_PMU_FEAT_ERND, }; =20 -static u32 arm_spe_pmu_cap_get(struct arm_spe_pmu *spe_pmu, int cap) +static u64 arm_spe_pmu_cap_get(struct arm_spe_pmu *spe_pmu, int cap) { if (cap < SPE_PMU_CAP_FEAT_MAX) return !!(spe_pmu->features & arm_spe_pmu_feat_caps[cap]); @@ -133,6 +134,8 @@ static u32 arm_spe_pmu_cap_get(struct arm_spe_pmu *spe_= pmu, int cap) return spe_pmu->counter_sz; case SPE_PMU_CAP_MIN_IVAL: return spe_pmu->min_period; + case SPE_PMU_CAP_EVENT_FILTER: + return ~spe_pmu->pmsevfr_res0; default: WARN(1, "unknown cap %d\n", cap); } @@ -149,7 +152,19 @@ static ssize_t arm_spe_pmu_cap_show(struct device *dev, container_of(attr, struct dev_ext_attribute, attr); int cap =3D (long)ea->var; =20 - return sysfs_emit(buf, "%u\n", arm_spe_pmu_cap_get(spe_pmu, cap)); + return sysfs_emit(buf, "%llu\n", arm_spe_pmu_cap_get(spe_pmu, cap)); +} + +static ssize_t arm_spe_pmu_cap_show_hex(struct device *dev, + struct device_attribute *attr, + char *buf) +{ + struct arm_spe_pmu *spe_pmu =3D dev_get_drvdata(dev); + struct dev_ext_attribute *ea =3D + container_of(attr, struct dev_ext_attribute, attr); + int cap =3D (long)ea->var; + + return sysfs_emit(buf, "0x%llx\n", arm_spe_pmu_cap_get(spe_pmu, cap)); } =20 #define SPE_EXT_ATTR_ENTRY(_name, _func, _var) \ @@ -159,12 +174,15 @@ static ssize_t arm_spe_pmu_cap_show(struct device *de= v, =20 #define SPE_CAP_EXT_ATTR_ENTRY(_name, _var) \ SPE_EXT_ATTR_ENTRY(_name, arm_spe_pmu_cap_show, _var) +#define SPE_CAP_EXT_ATTR_ENTRY_HEX(_name, _var) \ + SPE_EXT_ATTR_ENTRY(_name, arm_spe_pmu_cap_show_hex, _var) =20 static struct attribute *arm_spe_pmu_cap_attr[] =3D { SPE_CAP_EXT_ATTR_ENTRY(arch_inst, SPE_PMU_CAP_ARCH_INST), SPE_CAP_EXT_ATTR_ENTRY(ernd, SPE_PMU_CAP_ERND), SPE_CAP_EXT_ATTR_ENTRY(count_size, SPE_PMU_CAP_CNT_SZ), SPE_CAP_EXT_ATTR_ENTRY(min_interval, SPE_PMU_CAP_MIN_IVAL), + SPE_CAP_EXT_ATTR_ENTRY_HEX(event_filter, SPE_PMU_CAP_EVENT_FILTER), NULL, }; =20 --=20 2.34.1 From nobody Sat Oct 4 17:34:18 2025 Received: from mail-wm1-f52.google.com (mail-wm1-f52.google.com [209.85.128.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 8D6452F0669 for ; Thu, 14 Aug 2025 09:26:04 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.52 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1755163567; cv=none; b=kQaDO2bRKJ6KqlmfH8AgX27kkv/28m9Qo1EufiCMfJGU4VsTK6gfOuruLpl5yBlMbi/SInv4WTjjECWwBxxtgfiPKHL6aup8DmVOB5tbygbuqhRKQqx5OJhqDTYqNLDt+4fD/iPU+TYPXaxm5nJ628gnsK2o9lbjCz2gOwP2aO8= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1755163567; c=relaxed/simple; bh=amxfcIwk9CPU6fVzRnT+1Y2WxFhNVG4dD8O25j9WGOo=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=NLAht/NzOj52Iz+CwaRIfnq8lajRuUo2mXgiHJdSlmDCuI4YBv+Dx/kvYOwibx0SHGbyED4T1GFkX5T2tnzDV+RBT+MvpJzlq5FWLuJsK1/3tYZxzuDEDZ0DkWwSTiKMaQQXecBgi5jH9Pf5ROas1Gg5tRjDKo6y+7HlQOajQaA= 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=Poz340d8; arc=none smtp.client-ip=209.85.128.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="Poz340d8" Received: by mail-wm1-f52.google.com with SMTP id 5b1f17b1804b1-45a1b066b5eso3225715e9.1 for ; Thu, 14 Aug 2025 02:26:04 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1755163563; x=1755768363; darn=vger.kernel.org; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:from:to:cc:subject:date:message-id :reply-to; bh=bqDXfRMF96Zx+Uai2DOOReiNYXmUoTa9f4yVdbBVPio=; b=Poz340d8igAgoynr1gHZ+06wOSc3lO/a/HMx4sPLAw4/C36NTgjX1HC3djeaW1lG6D SoRtMjD3Uy9tl2vSqthgwK0sjDoOquMmes3MENA5Hd+0QsoHRK6OCCwsK6xZUvrky47J /wVYOFjiGgHxgzVWFJBwcqxQmmm6ul31wgYGk+gnt+Cm6dXWApAs4HzKGZjkR5pO5bsr qMs3qqJO6lYN8FdrbBDL5nZZ1wVw9QqBLJ1GHVNBJpuK7UF8SXR+eyl1h1VxIee9uFBW 14lz9v3B/ru3OORRgwvXQVd+DijGttivPV8NLBOGv/f4FLEKaEHRC8kQZHvTMBAPTs9w 2hjA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1755163563; x=1755768363; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=bqDXfRMF96Zx+Uai2DOOReiNYXmUoTa9f4yVdbBVPio=; b=obV8iFGSFbA3QM3L5tEMSn5ZW5qlV+rWDhHfaz0cEaxRctZ5bd1zzXgkVYnbpePrDp AQ1ZVSki+QyapvhCW9FyzdjG7chGddDQokHKsSQqmSKBewR6JQwmAKforpaJ7gHDIe0I CM7v8KAHENmgdAAnVIvkj8urB8w+zwdWWmoPyOKFd2mHT+mWfBQnlJsJ4irnNmNYJ0/U +M/b1ftovHWLwEvGNzTHBOsUWS2rHYiGeM2Sm2xcmJNM7zZFFKYAg2MyRD1/9Fun0frR JqT90zJAQPzuROi20f5zNxlU0n/qEG1jo89Ad3uohb8c9mg0P4Kyw0ICIuv8I8/4IwZp pvxg== X-Forwarded-Encrypted: i=1; AJvYcCVY6L4f+88TKzidWP8uq3Dq9ilcIESN0lnP3hNFrXiKYeF+smomEptiwDPnTpSmYpBayP0LQ9onzhrIFVM=@vger.kernel.org X-Gm-Message-State: AOJu0YzAgT/S9y1daaIsrm1vWB8RXOFhujUTdYBrwM+8DYJA6ESqkCOg pkL1JJUiSXxqDqh+TTwnem+nsL87nmROKo+t7/AcEyqPxSwtHV/sGRHYyRoj7Jl9WoQ= X-Gm-Gg: ASbGncuVhhM7CmY5Lb730rnrrz3N3zlzAplIOKnAEEcFFsL3i6413Gr4wUqVoXpQneF xaZE0gALjpfBN2ojwCYX0Ua3wltdnjX5pHRaWE+CP2vlezyDhR6icWuJC/vSOJ++3J0a5Z94Se3 SjRyRlObE2UiE/mFkGVGAATE1PDdbiRq0gfwcnk9PRpXjzqOx/dtnOnOYo0DUvWIXFPIhAcXuge TPL5G6+Z8iLzWhU5LoXxjzWb69gBInMWiRDkjF70jwuE5nJviRWZUNf9g+CPuXcGMmwdbHrEreU Dlj59UMvdvrHo9nwAtSYDiMvKv25vg8fk+7XKwOG7uz3IY74e4/Gn8Kxu1wdmBP/BBeNNBWoxqr 35Ucs/HMisvB1giNo4h/hPbq1bqPYLIE= X-Google-Smtp-Source: AGHT+IGuE0LbKXM++BnD1YQTIa22DqsoAt1TyimBCD4rDHCTDj0GSCNcdwQ6xUKaa5XUnCPgyt3XOA== X-Received: by 2002:a05:600c:524b:b0:459:eeaf:d6c7 with SMTP id 5b1f17b1804b1-45a1b6692bemr15842395e9.26.1755163562696; Thu, 14 Aug 2025 02:26:02 -0700 (PDT) Received: from ho-tower-lan.lan ([185.48.76.109]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-45a1c76e9basm14536775e9.21.2025.08.14.02.26.01 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 14 Aug 2025 02:26:02 -0700 (PDT) From: James Clark Date: Thu, 14 Aug 2025 10:25:26 +0100 Subject: [PATCH v7 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: <20250814-james-perf-feat_spe_eft-v7-4-6a743f7fa259@linaro.org> References: <20250814-james-perf-feat_spe_eft-v7-0-6a743f7fa259@linaro.org> In-Reply-To: <20250814-james-perf-feat_spe_eft-v7-0-6a743f7fa259@linaro.org> To: Catalin Marinas , Will Deacon , Mark Rutland , Jonathan Corbet , Marc Zyngier , Oliver Upton , Joey Gouly , Suzuki K Poulose , Zenghui Yu , Peter Zijlstra , Ingo Molnar , Arnaldo Carvalho de Melo , Namhyung Kim , Alexander Shishkin , Jiri Olsa , Ian Rogers , Adrian Hunter , Leo Yan , Anshuman Khandual Cc: linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, linux-perf-users@vger.kernel.org, linux-doc@vger.kernel.org, kvmarm@lists.linux.dev, James Clark X-Mailer: b4 0.14.0 FEAT_SPE_EFT (optional from Armv9.4) adds mask bits for the existing load, store and branch filters. It also adds two new filter bits for SIMD and floating point with their own associated mask bits. The current filters only allow OR filtering on samples that are load OR store etc, and the new mask bits allow setting part of the filter to an AND, for example filtering samples that are store AND SIMD. With mask bits set to 0, the OR behavior is preserved, so the unless any masks are explicitly set old filters will behave the same. Add them all and make them behave the same way as existing format bits, hidden and return EOPNOTSUPP if set when the feature doesn't exist. Reviewed-by: Leo Yan Tested-by: Leo Yan Signed-off-by: James Clark --- drivers/perf/arm_spe_pmu.c | 66 ++++++++++++++++++++++++++++++++++++++++++= ++++ 1 file changed, 66 insertions(+) diff --git a/drivers/perf/arm_spe_pmu.c b/drivers/perf/arm_spe_pmu.c index ba55bc3db708..591f72fa0327 100644 --- a/drivers/perf/arm_spe_pmu.c +++ b/drivers/perf/arm_spe_pmu.c @@ -86,6 +86,7 @@ struct arm_spe_pmu { #define SPE_PMU_FEAT_ERND (1UL << 5) #define SPE_PMU_FEAT_INV_FILT_EVT (1UL << 6) #define SPE_PMU_FEAT_DISCARD (1UL << 7) +#define SPE_PMU_FEAT_EFT (1UL << 8) #define SPE_PMU_FEAT_DEV_PROBED (1UL << 63) u64 features; =20 @@ -216,6 +217,27 @@ static const struct attribute_group arm_spe_pmu_cap_gr= oup =3D { #define ATTR_CFG_FLD_discard_CFG config /* PMBLIMITR_EL1.FM =3D DISCARD */ #define ATTR_CFG_FLD_discard_LO 35 #define ATTR_CFG_FLD_discard_HI 35 +#define ATTR_CFG_FLD_branch_filter_mask_CFG config /* PMSFCR_EL1.Bm */ +#define ATTR_CFG_FLD_branch_filter_mask_LO 36 +#define ATTR_CFG_FLD_branch_filter_mask_HI 36 +#define ATTR_CFG_FLD_load_filter_mask_CFG config /* PMSFCR_EL1.LDm */ +#define ATTR_CFG_FLD_load_filter_mask_LO 37 +#define ATTR_CFG_FLD_load_filter_mask_HI 37 +#define ATTR_CFG_FLD_store_filter_mask_CFG config /* PMSFCR_EL1.STm */ +#define ATTR_CFG_FLD_store_filter_mask_LO 38 +#define ATTR_CFG_FLD_store_filter_mask_HI 38 +#define ATTR_CFG_FLD_simd_filter_CFG config /* PMSFCR_EL1.SIMD */ +#define ATTR_CFG_FLD_simd_filter_LO 39 +#define ATTR_CFG_FLD_simd_filter_HI 39 +#define ATTR_CFG_FLD_simd_filter_mask_CFG config /* PMSFCR_EL1.SIMDm */ +#define ATTR_CFG_FLD_simd_filter_mask_LO 40 +#define ATTR_CFG_FLD_simd_filter_mask_HI 40 +#define ATTR_CFG_FLD_float_filter_CFG config /* PMSFCR_EL1.FP */ +#define ATTR_CFG_FLD_float_filter_LO 41 +#define ATTR_CFG_FLD_float_filter_HI 41 +#define ATTR_CFG_FLD_float_filter_mask_CFG config /* PMSFCR_EL1.FPm */ +#define ATTR_CFG_FLD_float_filter_mask_LO 42 +#define ATTR_CFG_FLD_float_filter_mask_HI 42 =20 #define ATTR_CFG_FLD_event_filter_CFG config1 /* PMSEVFR_EL1 */ #define ATTR_CFG_FLD_event_filter_LO 0 @@ -234,8 +256,15 @@ GEN_PMU_FORMAT_ATTR(pa_enable); GEN_PMU_FORMAT_ATTR(pct_enable); GEN_PMU_FORMAT_ATTR(jitter); GEN_PMU_FORMAT_ATTR(branch_filter); +GEN_PMU_FORMAT_ATTR(branch_filter_mask); GEN_PMU_FORMAT_ATTR(load_filter); +GEN_PMU_FORMAT_ATTR(load_filter_mask); GEN_PMU_FORMAT_ATTR(store_filter); +GEN_PMU_FORMAT_ATTR(store_filter_mask); +GEN_PMU_FORMAT_ATTR(simd_filter); +GEN_PMU_FORMAT_ATTR(simd_filter_mask); +GEN_PMU_FORMAT_ATTR(float_filter); +GEN_PMU_FORMAT_ATTR(float_filter_mask); GEN_PMU_FORMAT_ATTR(event_filter); GEN_PMU_FORMAT_ATTR(inv_event_filter); GEN_PMU_FORMAT_ATTR(min_latency); @@ -247,8 +276,15 @@ static struct attribute *arm_spe_pmu_formats_attr[] = =3D { &format_attr_pct_enable.attr, &format_attr_jitter.attr, &format_attr_branch_filter.attr, + &format_attr_branch_filter_mask.attr, &format_attr_load_filter.attr, + &format_attr_load_filter_mask.attr, &format_attr_store_filter.attr, + &format_attr_store_filter_mask.attr, + &format_attr_simd_filter.attr, + &format_attr_simd_filter_mask.attr, + &format_attr_float_filter.attr, + &format_attr_float_filter_mask.attr, &format_attr_event_filter.attr, &format_attr_inv_event_filter.attr, &format_attr_min_latency.attr, @@ -269,6 +305,16 @@ static umode_t arm_spe_pmu_format_attr_is_visible(stru= ct kobject *kobj, if (attr =3D=3D &format_attr_inv_event_filter.attr && !(spe_pmu->features= & SPE_PMU_FEAT_INV_FILT_EVT)) return 0; =20 + if ((attr =3D=3D &format_attr_branch_filter_mask.attr || + attr =3D=3D &format_attr_load_filter_mask.attr || + attr =3D=3D &format_attr_store_filter_mask.attr || + attr =3D=3D &format_attr_simd_filter.attr || + attr =3D=3D &format_attr_simd_filter_mask.attr || + attr =3D=3D &format_attr_float_filter.attr || + attr =3D=3D &format_attr_float_filter_mask.attr) && + !(spe_pmu->features & SPE_PMU_FEAT_EFT)) + return 0; + return attr->mode; } =20 @@ -364,8 +410,15 @@ static u64 arm_spe_event_to_pmsfcr(struct perf_event *= event) u64 reg =3D 0; =20 reg |=3D FIELD_PREP(PMSFCR_EL1_LD, ATTR_CFG_GET_FLD(attr, load_filter)); + reg |=3D FIELD_PREP(PMSFCR_EL1_LDm, ATTR_CFG_GET_FLD(attr, load_filter_ma= sk)); reg |=3D FIELD_PREP(PMSFCR_EL1_ST, ATTR_CFG_GET_FLD(attr, store_filter)); + reg |=3D FIELD_PREP(PMSFCR_EL1_STm, ATTR_CFG_GET_FLD(attr, store_filter_m= ask)); reg |=3D FIELD_PREP(PMSFCR_EL1_B, ATTR_CFG_GET_FLD(attr, branch_filter)); + reg |=3D FIELD_PREP(PMSFCR_EL1_Bm, ATTR_CFG_GET_FLD(attr, branch_filter_m= ask)); + reg |=3D FIELD_PREP(PMSFCR_EL1_SIMD, ATTR_CFG_GET_FLD(attr, simd_filter)); + reg |=3D FIELD_PREP(PMSFCR_EL1_SIMDm, ATTR_CFG_GET_FLD(attr, simd_filter_= mask)); + reg |=3D FIELD_PREP(PMSFCR_EL1_FP, ATTR_CFG_GET_FLD(attr, float_filter)); + reg |=3D FIELD_PREP(PMSFCR_EL1_FPm, ATTR_CFG_GET_FLD(attr, float_filter_m= ask)); =20 if (reg) reg |=3D PMSFCR_EL1_FT; @@ -767,6 +820,16 @@ static int arm_spe_pmu_event_init(struct perf_event *e= vent) !(spe_pmu->features & SPE_PMU_FEAT_FILT_LAT)) return -EOPNOTSUPP; =20 + if ((FIELD_GET(PMSFCR_EL1_LDm, reg) || + FIELD_GET(PMSFCR_EL1_STm, reg) || + FIELD_GET(PMSFCR_EL1_Bm, reg) || + FIELD_GET(PMSFCR_EL1_SIMD, reg) || + FIELD_GET(PMSFCR_EL1_SIMDm, reg) || + FIELD_GET(PMSFCR_EL1_FP, reg) || + FIELD_GET(PMSFCR_EL1_FPm, reg)) && + !(spe_pmu->features & SPE_PMU_FEAT_EFT)) + return -EOPNOTSUPP; + if (ATTR_CFG_GET_FLD(&event->attr, discard) && !(spe_pmu->features & SPE_PMU_FEAT_DISCARD)) return -EOPNOTSUPP; @@ -1058,6 +1121,9 @@ static void __arm_spe_pmu_dev_probe(void *info) if (spe_pmu->pmsver >=3D ID_AA64DFR0_EL1_PMSVer_V1P2) spe_pmu->features |=3D SPE_PMU_FEAT_DISCARD; =20 + if (FIELD_GET(PMSIDR_EL1_EFT, reg)) + spe_pmu->features |=3D SPE_PMU_FEAT_EFT; + /* This field has a spaced out encoding, so just use a look-up */ fld =3D FIELD_GET(PMSIDR_EL1_INTERVAL, reg); switch (fld) { --=20 2.34.1 From nobody Sat Oct 4 17:34:18 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 016F92F49E0 for ; Thu, 14 Aug 2025 09:26:05 +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=1755163568; cv=none; b=ebxCIXRx1Sa/vfQqrxqRAZVP14c2YKzOtWTbLhVtFvmN+XivBxwMfhxUJGlK6dKfRobwF3rQWYHI60V63Bk0fWrGuVbu5gukGHygIXGMVsx4B6yGbX4w7/1s8wxvaynCvhOkKa9PBrDE4/AqvvQV0mLaNDjMu91pd5jSckt/nJA= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1755163568; c=relaxed/simple; bh=o5hoKk8PVrb3Jz138QI9+seK1sxidrzo/A/lviEOL3Y=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=Co4f5nLrLK+81ExF5q78NLR4dEvn2IXd1W9GjLt6zqFAkuZ/fsK8vLKPV4OrwSM25gqr2y59EmznhLIROY1/3LAldmmL9dj8gFhqqgLRXAijoNtgIfBuL/JVhU5lBwpKCaupBhUtZXwAiQM8zjX5K1MApkY1thhfgFFQTO7flJE= 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=M9S641uk; 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="M9S641uk" Received: by mail-wm1-f45.google.com with SMTP id 5b1f17b1804b1-45a1ac7c066so4655225e9.1 for ; Thu, 14 Aug 2025 02:26:05 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1755163564; x=1755768364; 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=CHd8HPOm/LFAxhlOS9e+lKUAamxvrPZUbEjnXUTZJIA=; b=M9S641uk7y40vGu/P0qaXAFNhSeXaEKdD9nwGsvVBxT+7rRafrhvvbfrx1e60/JogZ f7jYboych6Ts03qM+FHUL8Fb8cI9U/HIpUVqEmsKMVIndq+xL5Z27mvNwS9w3s8X1XLW t5C5z7/txeF/ZYa3WZcuu+JhEvlM7npiWhdHlg7ec5QXjDe49itGkiLMvl1ZmwTf0qit 1wqy4OPYbahJ6/ODUFv3L085TJjk7uXYQubX9lbhrRO8KN8T7SHDct9xRwaAzEmFSzEH fZTpXDxIuTEVaX0UzZJIw6pbzEBYzSQtGOH1H2Yhfgr2pCrGE/JPZstg3cFa+mt5/S6b ez8g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1755163564; x=1755768364; 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=CHd8HPOm/LFAxhlOS9e+lKUAamxvrPZUbEjnXUTZJIA=; b=qH+5TTEAiA72oX63+iQfzHsA7x5cbRXt9n7KRLx6fl7OvzneNdr50J+0ChvjwNl9UT VQMuN+yDWnlRocAuOs4xGVT3CXv7iKLnjb0Ol8KcsY9UbiGEJdyXTrrrzxqFxr6iGfTW 4RGYcFBmDIvNnVLNBssNvxRpan/6sJwiyEQSj7/bFrBQ17qt8TzrS4RjERD8XVkSqR1X HS+X2iZRk5xRFNp9b5FgAAMHwWPfApYIB7XCdiie9KdVuViqj61CEhgrlGop5vuqpWDA Av4CZIquyu6ZmIFyRNWEfSpyyuwh8kpsWPWJ5WiqqeDf4ymY7id93WsX1XWFJ+3H2wf0 ASRQ== X-Forwarded-Encrypted: i=1; AJvYcCVB3lyOSMamoe7OZw3IJfsppUttkKCPQgzQ6rYX+mnrYX+h5G+dR/xlOuP3mwUS+ulgaovwRsrtlVeP1W0=@vger.kernel.org X-Gm-Message-State: AOJu0YxhRaOdctAvKb0RoVYC2sYVwWd7FWx4vAzIoZVWyGgH/mik8EY+ A+iUGLLc7TS5s4OpFxLE97q43rbo0rra45rolB5qEPUR/4yqwghJVwcpSvqbLkO9dRc= X-Gm-Gg: ASbGncvyfAxLi9jY58/LOwlNDWXjAOp5W5YYZBmcAw434MtPaSKzYBTBfXKThbKMNZa uFbJ/t4P/FDxsKUXzM0hRfpCBXOoWOP9tqaDic8265JfyHqzopfakqJSH0tpK93KEPaxiQcVPqQ PxBD7zAnXKamQYaKt3GuIlY4d+8mWSoeJ12Gtq5BpRNnjlFzCEoGxb6XUBa1Uc+544lGhHI6dLX uKPL6ECygf2spH9FzflEOPGpL+8yNd9/wEOL6zwL5wlVqErSO55LZWYmC6+K9QTvJoBbFIFVgQL V2HMsCdEiDv+3r6hnnusw7vrXmFJCfllUpgD53m9jqxPsUq3+NdawePyWdk3/5SfI9jjz+NA9Kn s3kD8+/Wkfip7SG/uJlBmQDgMimXfj+g= X-Google-Smtp-Source: AGHT+IHVbFNevY/X+5Fk3dLFGyCp8s96euJO8o8AaVBD0HLHGypEL/usVLk1GhbMm0uoIXFS5XgajQ== X-Received: by 2002:a05:600c:458a:b0:459:e39e:e5a5 with SMTP id 5b1f17b1804b1-45a1b791232mr17035875e9.5.1755163564130; Thu, 14 Aug 2025 02:26:04 -0700 (PDT) Received: from ho-tower-lan.lan ([185.48.76.109]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-45a1c76e9basm14536775e9.21.2025.08.14.02.26.02 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 14 Aug 2025 02:26:03 -0700 (PDT) From: James Clark Date: Thu, 14 Aug 2025 10:25:27 +0100 Subject: [PATCH v7 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: <20250814-james-perf-feat_spe_eft-v7-5-6a743f7fa259@linaro.org> References: <20250814-james-perf-feat_spe_eft-v7-0-6a743f7fa259@linaro.org> In-Reply-To: <20250814-james-perf-feat_spe_eft-v7-0-6a743f7fa259@linaro.org> To: Catalin Marinas , Will Deacon , Mark Rutland , Jonathan Corbet , Marc Zyngier , Oliver Upton , Joey Gouly , Suzuki K Poulose , Zenghui Yu , Peter Zijlstra , Ingo Molnar , Arnaldo Carvalho de Melo , Namhyung Kim , Alexander Shishkin , Jiri Olsa , Ian Rogers , Adrian Hunter , Leo Yan , Anshuman Khandual Cc: linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, linux-perf-users@vger.kernel.org, linux-doc@vger.kernel.org, kvmarm@lists.linux.dev, James Clark X-Mailer: b4 0.14.0 We check the version of SPE twice, and we'll add one more check in the next commit so factor out a macro to do this. Change the #3 magic number to the actual SPE version define (V1p2) to make it more readable. No functional changes intended. Tested-by: Leo Yan Signed-off-by: James Clark Reviewed-by: Leo Yan --- arch/arm64/include/asm/el2_setup.h | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/arch/arm64/include/asm/el2_setup.h b/arch/arm64/include/asm/el= 2_setup.h index 46033027510c..3a4ca7f9acfb 100644 --- a/arch/arm64/include/asm/el2_setup.h +++ b/arch/arm64/include/asm/el2_setup.h @@ -103,8 +103,7 @@ csel x2, xzr, x0, eq // all PMU counters from EL1 =20 /* Statistical profiling */ - ubfx x0, x1, #ID_AA64DFR0_EL1_PMSVer_SHIFT, #4 - cbz x0, .Lskip_spe_\@ // Skip if SPE not present + __spe_vers_imp .Lskip_spe_\@, ID_AA64DFR0_EL1_PMSVer_IMP, x0 // Skip if S= PE not present =20 mrs_s x0, SYS_PMBIDR_EL1 // If SPE available at EL2, and x0, x0, #(1 << PMBIDR_EL1_P_SHIFT) @@ -255,6 +254,14 @@ .Lskip_brbe_\@: .endm =20 +/* Branch to skip_label if SPE version is less than given version */ +.macro __spe_vers_imp skip_label, version, tmp + mrs \tmp, id_aa64dfr0_el1 + ubfx \tmp, \tmp, #ID_AA64DFR0_EL1_PMSVer_SHIFT, #4 + cmp \tmp, \version + b.lt \skip_label +.endm + /* Disable any fine grained traps */ .macro __init_el2_fgt mrs x1, id_aa64mmfr0_el1 @@ -263,10 +270,8 @@ =20 mov x0, xzr mov x2, xzr - mrs x1, id_aa64dfr0_el1 - ubfx x1, x1, #ID_AA64DFR0_EL1_PMSVer_SHIFT, #4 - cmp x1, #3 - b.lt .Lskip_spe_fgt_\@ + /* If SPEv1p2 is implemented, */ + __spe_vers_imp .Lskip_spe_fgt_\@, #ID_AA64DFR0_EL1_PMSVer_V1P2, x1 /* Disable PMSNEVFR_EL1 read and write traps */ orr x0, x0, #HDFGRTR_EL2_nPMSNEVFR_EL1_MASK orr x2, x2, #HDFGWTR_EL2_nPMSNEVFR_EL1_MASK --=20 2.34.1 From nobody Sat Oct 4 17:34:18 2025 Received: from mail-wm1-f47.google.com (mail-wm1-f47.google.com [209.85.128.47]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 3ADA82F60A7 for ; Thu, 14 Aug 2025 09:26:07 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.47 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1755163570; cv=none; b=SM/LFgtub7BilstwIN4lOi2zuzetbTkj1AFL8Dcwcq6ptB74d75oUdKI06bVhnmjTszivwBxyTGGBqs6AGQhytJbTJcOmJQhVqOrb6GfilAn8n2tHyJHf/SBLU7Bzb1jmRbYXsJfD+VQ18cb8AGKTzLfZmJjpvnTRK/aXLF5f78= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1755163570; c=relaxed/simple; bh=GxOVOeFB86vYsIqEPOrJfP+toIpofQdbwv56n+DyiyM=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=jqhu5BtqEXD+FbnZgkDCIqJCAWVq6UAX80Hmmq43QdfqA/PgaXshJya2A4pBaBbJV15ftVA5AErNWsAf9Vv8vJSBx6mv8uqhC3IVyk4JgNWItXUob3CZn/hvtiQsd7aUj7/qqaT+Bt4c4HYprvgpUDDLC/cv05BFe2btiCe0Pwc= 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=Ezv7EonJ; arc=none smtp.client-ip=209.85.128.47 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linaro.org Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="Ezv7EonJ" Received: by mail-wm1-f47.google.com with SMTP id 5b1f17b1804b1-45a1b0d224dso3545255e9.3 for ; Thu, 14 Aug 2025 02:26:06 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1755163565; x=1755768365; 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=6ufcAb3VHeR+uwp3SrFDBKP9OtJsomlijITnASDdFZ4=; b=Ezv7EonJMyPf1NgVaElc4JTZT5urIHO9FIiaZQWcjU9vYDaY5yz+zOyZafgMOsKFEv Dq6lzJJ78wtXtxxI290zFatfTb2Ib/EkTAiz/A0tQn/fX2JZ0ZvP6HcgRY5pRb24ANGn bY37KrEfl3h/S0MjfSZsqVzqLLbVQpdYNuWEWyoMF9vfwz2kBLOJkyZjYRy5XqlGSyRo Ce9PD8SWOgbI92Ir8kvIX+X9mOthM6eo9hCWh5gB0pV5BWOEG43mCuNVFNLSRkxWJkF9 PxeScJmfHITDSv4Lb3PJixyDVrEwzxJiGPszx87WFLTJ0mfxe0TZ9WicIe6ra4l6pxXL Ka6w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1755163565; x=1755768365; 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=6ufcAb3VHeR+uwp3SrFDBKP9OtJsomlijITnASDdFZ4=; b=C04uMYx7YOmpdNllAN2RiYW0fTWSrMTbr8QSRtx+qfq8O4+UN4Z4H63yAoUais3TcR V+wFFCcsoK/ST1/KKya8pGtZmP0hENj1wC+PeSTJVhjoTPe/Df1SENaKQisJm52vBREh X6Q7PFZSq03Rv3zQazyYs6T4bFDAOF2SDfjZQ/dWSu4Uvbr8bAFD+QxBfKUyHzJBGQ6n axwxKjyy/85+KcZua/6luOU1fd0xAnBNwfy3fdmrolCHg3l0G8mHMlMKP3QyX7/CdLqe g01dXqEAGRMgcpG/oooCXF4cRlzmnNeLcmET8g1Og4GRSZihg7JKiA3KvbqZCjgJdYH8 mXtw== X-Forwarded-Encrypted: i=1; AJvYcCW3upDfwh7XzOXN9+ukQ4Tv8p1rjqDw29DDJiu6/DWmZ0youkcjMEqiOS5gwdx1FXlNTurdCuEd5Qcx/UQ=@vger.kernel.org X-Gm-Message-State: AOJu0YwSmcvtAmUowY7d36LtFpFb/SbrR6QAA/rxaayry9cPfrQIFAwe UniVp6WLCtwc1S7MQpUKCnKuHY/NW6IkMybRingZkEw0FRcpr9eM68bB3VbluH3Ezos= X-Gm-Gg: ASbGncvRcAVw30UODqoRWZ5rW0DCDuGPdLesLnc1OmKkxQP4fOeMnpKaZFuf9t+z1tQ 3i5tENa0WhfbZU7dd9rUpZ7evhOJAr7G14sRrZJWsY6WwJfNMA+ADEje99IQu+G2BTykHfmXd+y y6Ed4FRp/fp26WB+JSRYfxTpZfMkCJE0wR+JpKI0EYw3uWtNdCrOqUuEikoinD+EUY7LerAbnmb t7YpxXK8/SdzvPf+u9aKrLeCTXq/Xps+w5lIquB0stzyZlxSBV/bYC6MFHIfK4RLsXugxCe0GCq xkRm5Z6QpkLWivZck1wv9Z8D/cTZbRrNESw4g+gXyhIT22G+n3wAe5IMpwtRA0YqcbkEktdftak RH0aAwQMZ6XZYQ1ZI43hgU61wMtQnUSI= X-Google-Smtp-Source: AGHT+IHAe77kAGKOL9ac19qggXFCssFULmcjf7EqpMgCC95aWkBTN0oGZBZjWaCvCRy5GyrpGxVt+Q== X-Received: by 2002:a05:600c:450e:b0:456:496:2100 with SMTP id 5b1f17b1804b1-45a1b6753a2mr19670995e9.31.1755163565465; Thu, 14 Aug 2025 02:26:05 -0700 (PDT) Received: from ho-tower-lan.lan ([185.48.76.109]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-45a1c76e9basm14536775e9.21.2025.08.14.02.26.04 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 14 Aug 2025 02:26:05 -0700 (PDT) From: James Clark Date: Thu, 14 Aug 2025 10:25:28 +0100 Subject: [PATCH v7 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: <20250814-james-perf-feat_spe_eft-v7-6-6a743f7fa259@linaro.org> References: <20250814-james-perf-feat_spe_eft-v7-0-6a743f7fa259@linaro.org> In-Reply-To: <20250814-james-perf-feat_spe_eft-v7-0-6a743f7fa259@linaro.org> To: Catalin Marinas , Will Deacon , Mark Rutland , Jonathan Corbet , Marc Zyngier , Oliver Upton , Joey Gouly , Suzuki K Poulose , Zenghui Yu , Peter Zijlstra , Ingo Molnar , Arnaldo Carvalho de Melo , Namhyung Kim , Alexander Shishkin , Jiri Olsa , Ian Rogers , Adrian Hunter , Leo Yan , Anshuman Khandual Cc: linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, linux-perf-users@vger.kernel.org, linux-doc@vger.kernel.org, kvmarm@lists.linux.dev, James Clark X-Mailer: b4 0.14.0 SPE data source filtering (optional from Armv8.8) requires that traps to the filter register PMSDSFR be disabled. Document the requirements and disable the traps if the feature is present. Tested-by: Leo Yan Signed-off-by: James Clark Reviewed-by: Leo Yan --- Documentation/arch/arm64/booting.rst | 11 +++++++++++ arch/arm64/include/asm/el2_setup.h | 11 +++++++++++ 2 files changed, 22 insertions(+) diff --git a/Documentation/arch/arm64/booting.rst b/Documentation/arch/arm6= 4/booting.rst index 2f666a7c303c..e4f953839f71 100644 --- a/Documentation/arch/arm64/booting.rst +++ b/Documentation/arch/arm64/booting.rst @@ -466,6 +466,17 @@ Before jumping into the kernel, the following conditio= ns must be met: - HDFGWTR2_EL2.nPMICFILTR_EL0 (bit 3) must be initialised to 0b1. - HDFGWTR2_EL2.nPMUACR_EL1 (bit 4) must be initialised to 0b1. =20 + For CPUs with SPE data source filtering (FEAT_SPE_FDS): + + - If EL3 is present: + + - MDCR_EL3.EnPMS3 (bit 42) must be initialised to 0b1. + + - If the kernel is entered at EL1 and EL2 is present: + + - HDFGRTR2_EL2.nPMSDSFR_EL1 (bit 19) must be initialised to 0b1. + - HDFGWTR2_EL2.nPMSDSFR_EL1 (bit 19) must be initialised to 0b1. + For CPUs with Memory Copy and Memory Set instructions (FEAT_MOPS): =20 - If the kernel is entered at EL1 and EL2 is present: diff --git a/arch/arm64/include/asm/el2_setup.h b/arch/arm64/include/asm/el= 2_setup.h index 3a4ca7f9acfb..a0361ddcdca4 100644 --- a/arch/arm64/include/asm/el2_setup.h +++ b/arch/arm64/include/asm/el2_setup.h @@ -392,6 +392,17 @@ orr x0, x0, #HDFGRTR2_EL2_nPMICFILTR_EL0 orr x0, x0, #HDFGRTR2_EL2_nPMUACR_EL1 .Lskip_pmuv3p9_\@: + /* If SPE is implemented, */ + __spe_vers_imp .Lskip_spefds_\@, ID_AA64DFR0_EL1_PMSVer_IMP, x1 + /* we can read PMSIDR and */ + mrs_s x1, SYS_PMSIDR_EL1 + and x1, x1, #PMSIDR_EL1_FDS + /* if FEAT_SPE_FDS is implemented, */ + cbz x1, .Lskip_spefds_\@ + /* disable traps to PMSDSFR. */ + orr x0, x0, #HDFGRTR2_EL2_nPMSDSFR_EL1 + +.Lskip_spefds_\@: msr_s SYS_HDFGRTR2_EL2, x0 msr_s SYS_HDFGWTR2_EL2, x0 msr_s SYS_HFGRTR2_EL2, xzr --=20 2.34.1 From nobody Sat Oct 4 17:34:18 2025 Received: from mail-wm1-f54.google.com (mail-wm1-f54.google.com [209.85.128.54]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id C68202F60AE for ; Thu, 14 Aug 2025 09:26:08 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.54 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1755163570; cv=none; b=joLF/zyhhbckMykf8BuKhNrSGoSaqehFuJk4v6ppeWY/KUQOe1BbaY8XTXxV8WjKc1r1Ivld9Zgqh9fU14Tcnsh3IxY0lL1YVW0LgCntmpwuNVk/Gr3YABnkpB7WPNcbWZZkshWqGAfJnnfGI24DOTMqPbH+KLskvin33S5p9/s= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1755163570; c=relaxed/simple; bh=UsFp0sErRCl0MxQtdMcp7ORp6c6Qv9zuPqmFhcaNxF8=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=R46bvNT0OCuljOewC/r2ejW7ga/c4344NNbreYttosb7Yw1KXxXuZs4QemEjRGOJbTILlrHJ/Ag4P6V/yrkhPpt1QXZwz5+VD5VTSyYtwVHTwnTcC/nSHm6KliUfM626IjtCjd+10MKnIuR4wrxGSiXbB7ikd8wiNNBhIlpTFT8= 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=VSEkrnGN; arc=none smtp.client-ip=209.85.128.54 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linaro.org Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="VSEkrnGN" Received: by mail-wm1-f54.google.com with SMTP id 5b1f17b1804b1-45a1b098f43so4841355e9.2 for ; Thu, 14 Aug 2025 02:26:08 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1755163567; x=1755768367; 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=NGZcvUVCZS8QsvENr66yrxXLduHaz342cTv3n2jzGu0=; b=VSEkrnGN49aRP8cwWfmBNS2KfXVemu9PRYgYjG/BbtnK3Geaeb++Y6AL7yDZ6Rrfrg wbgQGVGE/PgRowlOjeRl8ONSBQUiDvsn5JeBCIhwN4aPAjgXhXsyWVw/TjY39ExoIsNg L35tyQN0DykOwpc9HyVB4bkeY9NS1mh/TeDreW5eLkXQsDmOyIxMcBTeeEs168DZ2y+q nza6o80s1iDLTvqZPr9d970rCl+5guEdvlh7P2Q9TWmi/Uj2tzcvGi2djaxICB2oDvz2 oD5fk1Dk6VT5F+68p9oin87JMxrBtT0e8G+1RelrZi5ms0EJT6dEQ/ECHCrab26B0l7o qPyA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1755163567; x=1755768367; 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=NGZcvUVCZS8QsvENr66yrxXLduHaz342cTv3n2jzGu0=; b=K7h2K2y6sOvQ1rnhhCN7T1WuEzkJxuZqJ/Hfloko/3lizcA7aJdSY/v0qkRyOBCTof URkfdfrbuqkcr7saijVrNHlMKV0C7Nw/pb082dtm2bF9ShJn/ug4p5ppu0gTdyudYdip PRy5ZMXqzYsWMbhaktB7cUDMq5WFKDgMhM0YXnrF8MenMpz2vw4nD/BiTQ92TPqDj7de 15ASuYNUAP58oHdjPxwmoelPMfJeDJGsY+p7q9y/CPXxPqcpHC81UYAhyIHcHQVv6rpx 2Ep048ZUIJPQ4JRRXpAHESaSa0zigxRPPttMu36CmWfsQKotqN+t7L1yHlMtFiuX2aLz MmAQ== X-Forwarded-Encrypted: i=1; AJvYcCUIf6+uLEHUXBsEdBKGZ/z1uY8XJp7zMq5FY8fDj7YNlunv/6PPzS+dnvsiU1oS5pA7Fy0OVyvJmWA9Ui0=@vger.kernel.org X-Gm-Message-State: AOJu0YwRdMHuh3y24T3BEIOLKjyBQ23s1Apw6jvvrjs8nGYjQp7Hu8/l wep/cKpccqwde84+HOTwy3QE6djOE+H8nTY8vZfQwVOXDTeCzEfF71cpzK3B/duZPYU= X-Gm-Gg: ASbGncuJUsvGjqruw8wzuuPujzYVcG8JXLlkSQUzOeP7JtljbC1v5EapF3DQ6OaUVVi xfUdU16GrNgZpBxGhYFV0XfuTk47CvUXrDHnXSe7iP92oIxWrgu+mSI23QimdhRodSu0zwR5CtQ Q0sM2VAtu5ipYLGme+YbAAxeu6n0izvyuo8+x6QPA7J1APiQpTHOavPtVsjI19zBI65sq9W8F7H FVB8wEuOgCAxea+2gITbXUcL9JyFtbYjbrsFzBIE4WuUMOCirStJhtOuE1PVY0IBVE6ImzTW7Nx n37o1vZG3tu58RWchV20aWvmNxKiZNyqEuPsVkKTLUGvoAim2ZBJG35HwvLtWqZDLifb/P1UTSr V9Y6J3IlBVHSbv6tD4QG1Q5mnwSdQgZQ= X-Google-Smtp-Source: AGHT+IEOkVLtv4LKb277h/Y6u80yjiTAO7bDjmFHcIn9yFqBWPJOT++6KQmTGEGyq1SqLmRRRDPzJA== X-Received: by 2002:a05:600c:470d:b0:456:214f:f78d with SMTP id 5b1f17b1804b1-45a1b65f96cmr14249085e9.22.1755163566832; Thu, 14 Aug 2025 02:26:06 -0700 (PDT) Received: from ho-tower-lan.lan ([185.48.76.109]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-45a1c76e9basm14536775e9.21.2025.08.14.02.26.05 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 14 Aug 2025 02:26:06 -0700 (PDT) From: James Clark Date: Thu, 14 Aug 2025 10:25:29 +0100 Subject: [PATCH v7 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: <20250814-james-perf-feat_spe_eft-v7-7-6a743f7fa259@linaro.org> References: <20250814-james-perf-feat_spe_eft-v7-0-6a743f7fa259@linaro.org> In-Reply-To: <20250814-james-perf-feat_spe_eft-v7-0-6a743f7fa259@linaro.org> To: Catalin Marinas , Will Deacon , Mark Rutland , Jonathan Corbet , Marc Zyngier , Oliver Upton , Joey Gouly , Suzuki K Poulose , Zenghui Yu , Peter Zijlstra , Ingo Molnar , Arnaldo Carvalho de Melo , Namhyung Kim , Alexander Shishkin , Jiri Olsa , Ian Rogers , Adrian Hunter , Leo Yan , Anshuman Khandual Cc: linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, linux-perf-users@vger.kernel.org, linux-doc@vger.kernel.org, kvmarm@lists.linux.dev, James Clark X-Mailer: b4 0.14.0 SPE data source filtering (SPE_FEAT_FDS) adds a new register PMSDSFR_EL1, add the trap configs for it. PMSNEVFR_EL1 was also missing its VNCR offset so add it along with PMSDSFR_EL1. Tested-by: Leo Yan Signed-off-by: James Clark --- arch/arm64/include/asm/vncr_mapping.h | 2 ++ arch/arm64/kvm/emulate-nested.c | 1 + arch/arm64/kvm/sys_regs.c | 1 + 3 files changed, 4 insertions(+) diff --git a/arch/arm64/include/asm/vncr_mapping.h b/arch/arm64/include/asm= /vncr_mapping.h index f6ec500ad3fa..c2485a862e69 100644 --- a/arch/arm64/include/asm/vncr_mapping.h +++ b/arch/arm64/include/asm/vncr_mapping.h @@ -94,6 +94,8 @@ #define VNCR_PMSICR_EL1 0x838 #define VNCR_PMSIRR_EL1 0x840 #define VNCR_PMSLATFR_EL1 0x848 +#define VNCR_PMSNEVFR_EL1 0x850 +#define VNCR_PMSDSFR_EL1 0x858 #define VNCR_TRFCR_EL1 0x880 #define VNCR_MPAM1_EL1 0x900 #define VNCR_MPAMHCR_EL2 0x930 diff --git a/arch/arm64/kvm/emulate-nested.c b/arch/arm64/kvm/emulate-neste= d.c index 90cb4b7ae0ff..aeaba7813275 100644 --- a/arch/arm64/kvm/emulate-nested.c +++ b/arch/arm64/kvm/emulate-nested.c @@ -1185,6 +1185,7 @@ static const struct encoding_to_trap_config encoding_= to_cgt[] __initconst =3D { SR_TRAP(SYS_PMSIRR_EL1, CGT_MDCR_TPMS), SR_TRAP(SYS_PMSLATFR_EL1, CGT_MDCR_TPMS), SR_TRAP(SYS_PMSNEVFR_EL1, CGT_MDCR_TPMS), + SR_TRAP(SYS_PMSDSFR_EL1, CGT_MDCR_TPMS), SR_TRAP(SYS_TRFCR_EL1, CGT_MDCR_TTRF), SR_TRAP(SYS_TRBBASER_EL1, CGT_MDCR_E2TB), SR_TRAP(SYS_TRBLIMITR_EL1, CGT_MDCR_E2TB), diff --git a/arch/arm64/kvm/sys_regs.c b/arch/arm64/kvm/sys_regs.c index 82ffb3b3b3cf..d1a55cf589b7 100644 --- a/arch/arm64/kvm/sys_regs.c +++ b/arch/arm64/kvm/sys_regs.c @@ -3083,6 +3083,7 @@ static const struct sys_reg_desc sys_reg_descs[] =3D { { SYS_DESC(SYS_PMBLIMITR_EL1), undef_access }, { SYS_DESC(SYS_PMBPTR_EL1), undef_access }, { SYS_DESC(SYS_PMBSR_EL1), undef_access }, + { SYS_DESC(SYS_PMSDSFR_EL1), undef_access }, /* PMBIDR_EL1 is not trapped */ =20 { PMU_SYS_REG(PMINTENSET_EL1), --=20 2.34.1 From nobody Sat Oct 4 17:34:18 2025 Received: from mail-wm1-f52.google.com (mail-wm1-f52.google.com [209.85.128.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 EE8CD2F60C8 for ; Thu, 14 Aug 2025 09:26:09 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.52 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1755163571; cv=none; b=Fy/6ggvKuza3avVff9EMR+VnZA5ALer/q+yY54lsOa7QcP6Sz/oyzC6ZEJWDEt1UbWiYhKawjLAjZ9ON4DZBVsRprprISs1DnABeAJH/RzddUIfw8w3+9/KTJRJ6GvBENrXekui737tXfPnRKBlME5vjgx23imJG2A+bMkX0x1k= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1755163571; 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=m92R5sQnz4nTF9RG9du83HjOnt8vzraDL9LOL1MvO21eJ0Gi5EX3v5B/8i/+ESxzllzW8D0l/BK3XzPEmb6TN3F4PJaNeOyWd/zPvtSzlBnbRwoXKPn3Y+pT9IOXN1ToHoCuPytnBnTIePZA3VgTblE/5DOHZm8aTIjKI0bNMfs= 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=vZx4yWid; arc=none smtp.client-ip=209.85.128.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="vZx4yWid" Received: by mail-wm1-f52.google.com with SMTP id 5b1f17b1804b1-45a1abf5466so4566035e9.0 for ; Thu, 14 Aug 2025 02:26:09 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1755163568; x=1755768368; 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=vZx4yWidLDoaeNiJDRNy5ZUp/YxpLKFArIBE+g7IRIuFFt4POqkE+zq67r8HdiaQyG u/89EthjxuD9iIs0D4fnKivkfLSThP7BMWSJerQG8+e6eR6f/Sv9jLttTSrwpC/rd4Bv o2P207ammyRTSn1Q5reoMGFZuJE8VuL4W9w2cCxPKbvdayE5lbT9f/nNMoK4pB5x2J2B d/WXWqHMzJ1s6rByHA2GxE9lsBD085p30QFLkvv5dpSHZNh3e7KKuopT/EJcOwAhhbjE rdy2zR7aAsROvf46NPrgqB+rbf91qOH3V8e5CHARzhvZ9Y3/KGmWH5/2sXiBSRaNShQ2 /bqQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1755163568; x=1755768368; 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=bic8GH8M1UmYwFVgOE1t9OzRqgOyIFXHpfm0TeZ0qhwOvONYk5IUjly11fxlXckH76 iU4kKryFAjG3EgUxvACkqoinQMRGliTDS6QCClbkNbtSIQ2Zld6PakdrueljP6eG9jWG psneIJYS+jG3iLhMfaUFcoPi3FgMDNdbpwuhF9EETtkPvfmexayjL6yfominbqtzIoro S+dnug38dvYMIr7Yaxx8ALNfoXkvhZOttSXPMNOrWYp3Rx7shEpG+jp2i4k84noU7XRY /22kWK30IreNCbP5CZiEqdIYEmLr4sS8rc127IJpIPmSv5qsLttGu6Rpf1sFFByoLDZ9 Zc5w== X-Forwarded-Encrypted: i=1; AJvYcCUKbiX84fP/MJa7PIfT/PrCPjuM39slJmI/PgxME6vwjcaM9f7wrbBdDSjHTIvx9pVFaaDJoSdzAU/2XqE=@vger.kernel.org X-Gm-Message-State: AOJu0YzX0Qv7+UNmBqYCcfdioiwWiFa4ve22/fW2gn3bXhDEPpSvXNWm 9pkbu4clw6vd+lhUht58IbEwjjeObsXswI3WhclATlvT0/QELtaawhihTfLd9Y+V6BY= X-Gm-Gg: ASbGncu3L4J7IFr2YRGS1yu75kEgMYi6yUhbFpTfYoymiibWOuZCEr7Ut7gqxWZmRL4 oHRnGI3iJxVCs3p3wQXNhlIGT2v3+gUIoEaVFipzu6NyI7Wli2iBlys/WUoCCZsZH2E+WI+OLZc APM4jlOsH6EDNkgsrbdXhnFpkyskmfIrccIJUOX1KC/mSdmjZx13hnA8ITbVaQ/PaYG+O3bbTyY l2nzNSxYJQZNFbHkb3du8xTMNHv2LzEXJQS2iX2rGsrr5vZ9PFOobKjG2In8MPNM6Zts7yvnP8L K/ycfLLUOBhQkMDi2oVbvloC6NOxaLzRapvjDw39rBa3S+pMbjcA+bS615ONSMXtpeR3Sf5NSpq H8PQtFwfPVmAnAT4p4NOU4X4bgsq+QNo= X-Google-Smtp-Source: AGHT+IEfiNAJpBqr1EBOXZKivbX12m1SjqEMe6qLmXAWuSO2UYgUUw0TISQjYJI+9nhScFZ8SMs3Cg== X-Received: by 2002:a05:600c:1d04:b0:458:b8b0:6338 with SMTP id 5b1f17b1804b1-45a1b79573cmr16522705e9.6.1755163568201; Thu, 14 Aug 2025 02:26:08 -0700 (PDT) Received: from ho-tower-lan.lan ([185.48.76.109]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-45a1c76e9basm14536775e9.21.2025.08.14.02.26.06 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 14 Aug 2025 02:26:07 -0700 (PDT) From: James Clark Date: Thu, 14 Aug 2025 10:25:30 +0100 Subject: [PATCH v7 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: <20250814-james-perf-feat_spe_eft-v7-8-6a743f7fa259@linaro.org> References: <20250814-james-perf-feat_spe_eft-v7-0-6a743f7fa259@linaro.org> In-Reply-To: <20250814-james-perf-feat_spe_eft-v7-0-6a743f7fa259@linaro.org> To: Catalin Marinas , Will Deacon , Mark Rutland , Jonathan Corbet , Marc Zyngier , Oliver Upton , Joey Gouly , Suzuki K Poulose , Zenghui Yu , Peter Zijlstra , Ingo Molnar , Arnaldo Carvalho de Melo , Namhyung Kim , Alexander Shishkin , Jiri Olsa , Ian Rogers , Adrian Hunter , Leo Yan , Anshuman Khandual Cc: linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, linux-perf-users@vger.kernel.org, linux-doc@vger.kernel.org, kvmarm@lists.linux.dev, James Clark X-Mailer: b4 0.14.0 Arm FEAT_SPE_FDS adds the ability to filter on the data source of a packet using another 64-bits of event filtering control. As the existing perf_event_attr::configN fields are all used up for SPE PMU, an additional field is needed. Add a new 'config4' field. Reviewed-by: Leo Yan Tested-by: Leo Yan Reviewed-by: Ian Rogers Signed-off-by: James Clark --- include/uapi/linux/perf_event.h | 2 ++ 1 file changed, 2 insertions(+) diff --git a/include/uapi/linux/perf_event.h b/include/uapi/linux/perf_even= t.h index 78a362b80027..0d0ed85ad8cb 100644 --- a/include/uapi/linux/perf_event.h +++ b/include/uapi/linux/perf_event.h @@ -382,6 +382,7 @@ enum perf_event_read_format { #define PERF_ATTR_SIZE_VER6 120 /* Add: aux_sample_size */ #define PERF_ATTR_SIZE_VER7 128 /* Add: sig_data */ #define PERF_ATTR_SIZE_VER8 136 /* Add: config3 */ +#define PERF_ATTR_SIZE_VER9 144 /* add: config4 */ =20 /* * 'struct perf_event_attr' contains various attributes that define @@ -543,6 +544,7 @@ struct perf_event_attr { __u64 sig_data; =20 __u64 config3; /* extension of config2 */ + __u64 config4; /* extension of config3 */ }; =20 /* --=20 2.34.1 From nobody Sat Oct 4 17:34:18 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 70B8F2F744D for ; Thu, 14 Aug 2025 09:26:11 +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=1755163573; cv=none; b=FW5Wl9Hzu8rOOmxgSsOK+k66GxQDsX9VI3BtMkGxCzflCnk8xJe3y/ZdYotvRzBlpEDTpntahibGHXbCRuUQGCPopmBAAHCWVxEM0bXIBBACby+t7/s/T1FKfmSOgt9gSVr9jhxnfayYdA3y9hQRrhaPGQv6z9luReS+mf4JmAg= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1755163573; c=relaxed/simple; bh=0Sysn8K7QxBSXhh4+yVi+5eX8XDZpR4uCpq/1GrIYWU=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=lTpBPrFgetRCets1nWPsPY3YoOKvebV1085eHfkjnyuucLMUR6pJQpw1m5Pf+asoO0mdlzg0EE+k7GcVSmLPmQPYbxEF+3WoLiosiI+aetxrPZuDWb3YXGGoJbll8QJR5DIfmNEqShPEr6OtTHBmvC7bQBSOqw9UUXXOheH36vc= 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=th+dKb1L; 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="th+dKb1L" Received: by mail-wm1-f51.google.com with SMTP id 5b1f17b1804b1-45a1b004a31so4887595e9.0 for ; Thu, 14 Aug 2025 02:26:11 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1755163570; x=1755768370; 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=kU3pVBhaBY5D1ADCXJFCOl8E+cDESMwoM3MT+w6qdBg=; b=th+dKb1LYfuiRkobEl0bCHNdq1UUL7Rnib76SiNLDgfoVxRwr+HFDZgy2iArOsyMeO F6GlEDhSlEQiGiUwiB4O+3a6uuchXt8hYXPq7yxFsKfZuViICgf/Ge44QOdeTAfr2w6S U7IxlnNYvbnveBTIAzoJYYr0UtvvW9N5pPoTCTMujW9RZUC85KXMVJW97fZpppAGcUS2 a2r0+PZVCwkOw/mI57lZp9lrV0c1+cpIsp6DVqrhtS5RqM8vQ+EG0s9Lio6UQuXgVd5/ mb4NQFd7EDFMJuGvWHzyoveC0T0luwqZFD+eYG1EErCTQ8Y0GYYdiGt2jgpJyScF/Hmk ckAg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1755163570; x=1755768370; 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=kU3pVBhaBY5D1ADCXJFCOl8E+cDESMwoM3MT+w6qdBg=; b=epnvTPwaC//yXn7mjCjXp+Mnk9BXK99o5ELvhi6zDDEwr5+qBNrdNUjsRwkKjE6PPg Zc1dvIDbIbQC5G7pxqgkA8O4X2UOZkz4QC7DYSDdmjt2L88x53PBBS6WkGclOmof28t/ 4Ctn7YlT2IuVxQdh7y34GcQUJjiRGPqdmcTPaqKcToyOqa6ZFGX9FxlmHqJsgWs9wL4v oxyEFwzaNGfj2NZ/3Vt+CBPYvzMzpAiDk+AgLtD2oh/h66j1CxtmKLn8E+qHSUMEzTSz eD2tlPRDHn+yI46cVHKlibyRR0I2YqXWtF5RT7NSc+OxiQeDFF6dkxELvkCRq7X1YE1r X78w== X-Forwarded-Encrypted: i=1; AJvYcCU074Ll6M7/l52IoJ+/yYUNY6AaY0HtSrOpAjVUq2n0tBwH+p75HPgWXoWoe5AsscGV/iui3kFXvbCn/bU=@vger.kernel.org X-Gm-Message-State: AOJu0Ywopcu5VLuWcFJFRZD0mXbvF7n5gT0FrgdMisIBqz7wQVl/1g5J rztCcmzx+kQnVMNXln4rpV9raBjYeOiQAmGHK0FXO+TEd4KfC5iEztI099KyFnomv/Y= X-Gm-Gg: ASbGnctKdMaycVr+XbtLPE7FJ8Gj5sqxezwX7U/XfTCvHAYmvx0D3uzfs1uhe1Qyw9Z NdZGyplQbqgdhZ2DYb2CUkTNNc9q+4XvD5GBoEjpAWxeUToNnShGUin6NSWVCL1LRQbXBito1hO GD74PP3pDf+qr0GWZ1GWIf4gpZ8S2S2s3bYkuCnhKOnRD1xZ4XzppMXILhqZq0BkyO/V9u9PlNv +7qvkBGSBeySBGRYs+aVZOeQ8BYUXY4qkWV6E+fGtaAlAMshawkisbs8HoqWU89MDz7YQ6o3vm3 ciGsOgo8d2IuIbrSvB/btcgxH5DhV4Xg3zH9R1/Y190v1V8T502qBEYjEgX+Qz31Ei8e30/m59L ZfwjEpMaErpwJY9HH0CeOgI3cxgoWDsA= X-Google-Smtp-Source: AGHT+IG7VtJU6yEctLHSbbPHQRJt83DmrEVIyD4UvM5HiNPb8kIWkjAaSB91zdHiKQMYUKW7kzxcGA== X-Received: by 2002:a05:600c:5486:b0:456:25aa:e9b0 with SMTP id 5b1f17b1804b1-45a1b646a96mr22322175e9.16.1755163569549; Thu, 14 Aug 2025 02:26:09 -0700 (PDT) Received: from ho-tower-lan.lan ([185.48.76.109]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-45a1c76e9basm14536775e9.21.2025.08.14.02.26.08 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 14 Aug 2025 02:26:09 -0700 (PDT) From: James Clark Date: Thu, 14 Aug 2025 10:25:31 +0100 Subject: [PATCH v7 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: <20250814-james-perf-feat_spe_eft-v7-9-6a743f7fa259@linaro.org> References: <20250814-james-perf-feat_spe_eft-v7-0-6a743f7fa259@linaro.org> In-Reply-To: <20250814-james-perf-feat_spe_eft-v7-0-6a743f7fa259@linaro.org> To: Catalin Marinas , Will Deacon , Mark Rutland , Jonathan Corbet , Marc Zyngier , Oliver Upton , Joey Gouly , Suzuki K Poulose , Zenghui Yu , Peter Zijlstra , Ingo Molnar , Arnaldo Carvalho de Melo , Namhyung Kim , Alexander Shishkin , Jiri Olsa , Ian Rogers , Adrian Hunter , Leo Yan , Anshuman Khandual Cc: linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, linux-perf-users@vger.kernel.org, linux-doc@vger.kernel.org, kvmarm@lists.linux.dev, James Clark X-Mailer: b4 0.14.0 SPE_FEAT_FDS adds the ability to filter on the data source of packets. Like the other existing filters, enable filtering with PMSFCR_EL1.FDS when any of the filter bits are set. Each bit maps to data sources 0-63 described by bits[0:5] in the data source packet (although the full range of data source is 16 bits so higher value data sources can't be filtered on). The filter is an OR of all the bits, so for example clearing bits 0 and 3 only includes packets from data sources 0 OR 3. Invert the filter given by userspace so that the default value of 0 is equivalent to including all values (no filtering). This allows us to skip adding a new format bit to enable filtering and still support excluding all data sources which would have been a filter value of 0 if not for the inversion. Tested-by: Leo Yan Signed-off-by: James Clark --- drivers/perf/arm_spe_pmu.c | 37 +++++++++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) diff --git a/drivers/perf/arm_spe_pmu.c b/drivers/perf/arm_spe_pmu.c index 591f72fa0327..e5b36ab90786 100644 --- a/drivers/perf/arm_spe_pmu.c +++ b/drivers/perf/arm_spe_pmu.c @@ -87,6 +87,7 @@ struct arm_spe_pmu { #define SPE_PMU_FEAT_INV_FILT_EVT (1UL << 6) #define SPE_PMU_FEAT_DISCARD (1UL << 7) #define SPE_PMU_FEAT_EFT (1UL << 8) +#define SPE_PMU_FEAT_FDS (1UL << 9) #define SPE_PMU_FEAT_DEV_PROBED (1UL << 63) u64 features; =20 @@ -251,6 +252,10 @@ static const struct attribute_group arm_spe_pmu_cap_gr= oup =3D { #define ATTR_CFG_FLD_inv_event_filter_LO 0 #define ATTR_CFG_FLD_inv_event_filter_HI 63 =20 +#define ATTR_CFG_FLD_inv_data_src_filter_CFG config4 /* inverse of PMSDSFR= _EL1 */ +#define ATTR_CFG_FLD_inv_data_src_filter_LO 0 +#define ATTR_CFG_FLD_inv_data_src_filter_HI 63 + GEN_PMU_FORMAT_ATTR(ts_enable); GEN_PMU_FORMAT_ATTR(pa_enable); GEN_PMU_FORMAT_ATTR(pct_enable); @@ -267,6 +272,7 @@ GEN_PMU_FORMAT_ATTR(float_filter); GEN_PMU_FORMAT_ATTR(float_filter_mask); GEN_PMU_FORMAT_ATTR(event_filter); GEN_PMU_FORMAT_ATTR(inv_event_filter); +GEN_PMU_FORMAT_ATTR(inv_data_src_filter); GEN_PMU_FORMAT_ATTR(min_latency); GEN_PMU_FORMAT_ATTR(discard); =20 @@ -287,6 +293,7 @@ static struct attribute *arm_spe_pmu_formats_attr[] =3D= { &format_attr_float_filter_mask.attr, &format_attr_event_filter.attr, &format_attr_inv_event_filter.attr, + &format_attr_inv_data_src_filter.attr, &format_attr_min_latency.attr, &format_attr_discard.attr, NULL, @@ -305,6 +312,10 @@ static umode_t arm_spe_pmu_format_attr_is_visible(stru= ct kobject *kobj, if (attr =3D=3D &format_attr_inv_event_filter.attr && !(spe_pmu->features= & SPE_PMU_FEAT_INV_FILT_EVT)) return 0; =20 + if (attr =3D=3D &format_attr_inv_data_src_filter.attr && + !(spe_pmu->features & SPE_PMU_FEAT_FDS)) + return 0; + if ((attr =3D=3D &format_attr_branch_filter_mask.attr || attr =3D=3D &format_attr_load_filter_mask.attr || attr =3D=3D &format_attr_store_filter_mask.attr || @@ -429,6 +440,9 @@ static u64 arm_spe_event_to_pmsfcr(struct perf_event *e= vent) if (ATTR_CFG_GET_FLD(attr, inv_event_filter)) reg |=3D PMSFCR_EL1_FnE; =20 + if (ATTR_CFG_GET_FLD(attr, inv_data_src_filter)) + reg |=3D PMSFCR_EL1_FDS; + if (ATTR_CFG_GET_FLD(attr, min_latency)) reg |=3D PMSFCR_EL1_FL; =20 @@ -453,6 +467,17 @@ static u64 arm_spe_event_to_pmslatfr(struct perf_event= *event) return FIELD_PREP(PMSLATFR_EL1_MINLAT, ATTR_CFG_GET_FLD(attr, min_latency= )); } =20 +static u64 arm_spe_event_to_pmsdsfr(struct perf_event *event) +{ + struct perf_event_attr *attr =3D &event->attr; + + /* + * Data src filter is inverted so that the default value of 0 is + * equivalent to no filtering. + */ + return ~ATTR_CFG_GET_FLD(attr, inv_data_src_filter); +} + static void arm_spe_pmu_pad_buf(struct perf_output_handle *handle, int len) { struct arm_spe_pmu_buf *buf =3D perf_get_aux(handle); @@ -790,6 +815,10 @@ static int arm_spe_pmu_event_init(struct perf_event *e= vent) if (arm_spe_event_to_pmsnevfr(event) & spe_pmu->pmsevfr_res0) return -EOPNOTSUPP; =20 + if (arm_spe_event_to_pmsdsfr(event) !=3D U64_MAX && + !(spe_pmu->features & SPE_PMU_FEAT_FDS)) + return -EOPNOTSUPP; + if (attr->exclude_idle) return -EOPNOTSUPP; =20 @@ -865,6 +894,11 @@ static void arm_spe_pmu_start(struct perf_event *event= , int flags) write_sysreg_s(reg, SYS_PMSNEVFR_EL1); } =20 + if (spe_pmu->features & SPE_PMU_FEAT_FDS) { + reg =3D arm_spe_event_to_pmsdsfr(event); + write_sysreg_s(reg, SYS_PMSDSFR_EL1); + } + reg =3D arm_spe_event_to_pmslatfr(event); write_sysreg_s(reg, SYS_PMSLATFR_EL1); =20 @@ -1124,6 +1158,9 @@ static void __arm_spe_pmu_dev_probe(void *info) if (FIELD_GET(PMSIDR_EL1_EFT, reg)) spe_pmu->features |=3D SPE_PMU_FEAT_EFT; =20 + if (FIELD_GET(PMSIDR_EL1_FDS, reg)) + spe_pmu->features |=3D SPE_PMU_FEAT_FDS; + /* This field has a spaced out encoding, so just use a look-up */ fld =3D FIELD_GET(PMSIDR_EL1_INTERVAL, reg); switch (fld) { --=20 2.34.1 From nobody Sat Oct 4 17:34:18 2025 Received: from mail-wm1-f47.google.com (mail-wm1-f47.google.com [209.85.128.47]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id D97012F83CD for ; Thu, 14 Aug 2025 09:26:12 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.47 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1755163575; cv=none; b=NfcogNbKojcChmz9Fw3RrvVaYAcUOZA/4JWRSxWedH9wuBHyn0q8eKC1+S1Utw2vCuctTqhEiJiWBwlhqDFno1LQJXln0u53A92/R2dpfZ9M21rhEtpMFgiTBXkd6Xlu57cfRl5+gbrCJA2pX4M/0v2jphVSBlZ+ZK6aK4z5Tzg= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1755163575; c=relaxed/simple; bh=b/ttJae4xiEHONrSB61gWYPCVcnCnqIpQyNKL5V/Pqw=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=UBvfS0vMeVxQ9ZY5ZLNILHrudlErfHkYMgQtmklnSSiFWwkWM6qhuUJ4pLrTQdgREwuUGrD8Gy6b8FpCY599kZvpN2oQXS39uT3FBxSQgcpbzVWzgdM5gyVRr9itb0DqBqQq3Dz45ct8f7AbxIuZIt9mhlTqa+N8c7DjpaQIW0k= 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=p/laRN4f; arc=none smtp.client-ip=209.85.128.47 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linaro.org Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="p/laRN4f" Received: by mail-wm1-f47.google.com with SMTP id 5b1f17b1804b1-45a1b00f23eso3760915e9.0 for ; Thu, 14 Aug 2025 02:26:12 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1755163571; x=1755768371; 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=p/laRN4flPe2/P1CowT86YgfTWKRwrcfXfn//tIJLMZ+YmZK+B0jRpyKDZw38m+wW8 ydCeeK2gkUgAjVHEM4cIUR2kL6W3Soi/dSBZPnpMT4aCAutvLbRZMG36u9APU4tqUG6/ 7fPmdPp58FQSpF9P3tPiLe8u1vZT1E+SDCCrl4iGvxBGl/r12Qfqi5DmpUSss7G8Mx30 vpIz1U+4+IjXJbmUBWGih5ISiVPxzUOXyUfAWtQHoi2E238TJYENgXByNSgMI7/XNrt1 NH3XUGOweofx1kC4mk3gjayod4rKeRf4/kUwumiJAPcv1xNijXF82noWUxdXz1ke2wkk hoBA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1755163571; x=1755768371; 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=rdXkwZQ42Yf/XLZIgi/mgpIMqYFDPziQfAIrAsyvO8NHYpB8bq78nMMQWqXWjOxk7J mM/0kdHLqWtQiQO6tTAeKr5SR5zzTm8wjXIh7Izap9xWF36jau7lGJSjV3lJ4PclGRIk 0n+JDCQ7qxF2jhvGA7vDy3f6xxOLpj1uVbrBVOvg0aAgy3iQ4jSlSSSYuUtGe3lhxbnP BSLS/b+mOxG3yumNr74vO/L31hDuiN/LYzhdipmMv1a3+1ul5r3G/1DElpDKHdfuA0tX D+LUefPcMWqyVhGBsEA1q9ZAgkuKvCqXnB96A9vsaycjXQUbWdA5N0OJ60zVSnotWbxS apOw== X-Forwarded-Encrypted: i=1; AJvYcCUDB/rRSs3X5z2xC5C4p4UsQOfnKZPgA0nqf3NxPTq8Rp3LKbPQpJX6IANdsA9cKp8KjwhU0V3rR3Dyvh4=@vger.kernel.org X-Gm-Message-State: AOJu0YyUfN10Wgo3Of+ZSmt61jGb5p4gOfoosKRmqjjvssLOsw4J6Mt/ DKy11+4cqvLm8RHgLvq/IizJbfJbs5AmeJAJEGfRauSfqz/8s8rwswZ9AVNUJ4nMWwI= X-Gm-Gg: ASbGncs0Ar4tyK9AHDtNEwvNSFc+wq41bc/nllPdkOkFVYCrMac/OFP669oObSveOp2 2MqZ9LHmx9iUCsx+Pss27hOj0siSVcU6R+SyYqw4wdN7G4aUt5plehcQ2S1afggd2UuxDBpq8aU DDcAQ6ZR1HnIO24+s7mUJ89817l7ouj8KlSKgLCsIZEHbZ/zNj2hyj78IXHeNyMgVyrwGd4mMCW r0+ErLYcccInhJ7VYE8//H0RTeslQRLftFYIi5aDguLsuRadNHzkUVnqslofnA/rEVoSsYgtWhQ RK7XbwCdEuTg8gGO9y4qAnRdJ83bDQj9UvEV15DF9213g3Chthax99mCXIQc56KaEsCcHcHavm/ 6IDDKjV93Z12TWCZDGjt9+tj5LxYuYQE= X-Google-Smtp-Source: AGHT+IHtct+umesyv5x7r2OiRVf/2g4YUX/d+UTbwfLkfG/5sEvYEqn1B72mWCeZftKk8wn55AxWng== X-Received: by 2002:a05:600c:3543:b0:456:1a69:94fa with SMTP id 5b1f17b1804b1-45a1b628566mr17809305e9.13.1755163570902; Thu, 14 Aug 2025 02:26:10 -0700 (PDT) Received: from ho-tower-lan.lan ([185.48.76.109]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-45a1c76e9basm14536775e9.21.2025.08.14.02.26.09 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 14 Aug 2025 02:26:10 -0700 (PDT) From: James Clark Date: Thu, 14 Aug 2025 10:25:32 +0100 Subject: [PATCH v7 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: <20250814-james-perf-feat_spe_eft-v7-10-6a743f7fa259@linaro.org> References: <20250814-james-perf-feat_spe_eft-v7-0-6a743f7fa259@linaro.org> In-Reply-To: <20250814-james-perf-feat_spe_eft-v7-0-6a743f7fa259@linaro.org> To: Catalin Marinas , Will Deacon , Mark Rutland , Jonathan Corbet , Marc Zyngier , Oliver Upton , Joey Gouly , Suzuki K Poulose , Zenghui Yu , Peter Zijlstra , Ingo Molnar , Arnaldo Carvalho de Melo , Namhyung Kim , Alexander Shishkin , Jiri Olsa , Ian Rogers , Adrian Hunter , Leo Yan , Anshuman Khandual Cc: linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, linux-perf-users@vger.kernel.org, linux-doc@vger.kernel.org, kvmarm@lists.linux.dev, James Clark X-Mailer: b4 0.14.0 To pickup config4 changes. Tested-by: Leo Yan Reviewed-by: Ian Rogers Signed-off-by: James Clark --- tools/include/uapi/linux/perf_event.h | 2 ++ 1 file changed, 2 insertions(+) diff --git a/tools/include/uapi/linux/perf_event.h b/tools/include/uapi/lin= ux/perf_event.h index 78a362b80027..0d0ed85ad8cb 100644 --- a/tools/include/uapi/linux/perf_event.h +++ b/tools/include/uapi/linux/perf_event.h @@ -382,6 +382,7 @@ enum perf_event_read_format { #define PERF_ATTR_SIZE_VER6 120 /* Add: aux_sample_size */ #define PERF_ATTR_SIZE_VER7 128 /* Add: sig_data */ #define PERF_ATTR_SIZE_VER8 136 /* Add: config3 */ +#define PERF_ATTR_SIZE_VER9 144 /* add: config4 */ =20 /* * 'struct perf_event_attr' contains various attributes that define @@ -543,6 +544,7 @@ struct perf_event_attr { __u64 sig_data; =20 __u64 config3; /* extension of config2 */ + __u64 config4; /* extension of config3 */ }; =20 /* --=20 2.34.1 From nobody Sat Oct 4 17:34:18 2025 Received: from mail-wm1-f52.google.com (mail-wm1-f52.google.com [209.85.128.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 5CA9F2F9994 for ; Thu, 14 Aug 2025 09:26:14 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.52 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1755163576; cv=none; b=Z06lLVxJgtd9CuJcfHnptAxSNHF65nd7yas6asQVjP4I318OFp3rZ/zA/VnehwnnmBeeC30NVZqs6+SFV5W4rAmL5/EHEWc1qOimbpAOeReZLwxd/NkI1nZhIwxWAhqWd5mSLNxu7k/ogaFNjRm8V+Z+a6OEajSrS7oceJTvxyw= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1755163576; c=relaxed/simple; bh=CNBe14pNLnXU+RaS/M5L+smgEMoBVwqw6DTZL4A5ZNc=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=pDur+hovO8+RPZDhpvLJI1hv0dFsEI9hkqWd5iOVMc+n7uX1lRVr7lavKhUO1Ouh/14jJAbgVLEDm1wWhQhKaHy95zatfXBHb7MjUSzSyMu0lcs493rE/YSemoPjleODzAfz3FOI4L42vvut/NOelbfHiGBMGtIg+/YH+IqhlDM= 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=SRzuRfZ7; arc=none smtp.client-ip=209.85.128.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="SRzuRfZ7" Received: by mail-wm1-f52.google.com with SMTP id 5b1f17b1804b1-45a1ac7c066so4656355e9.1 for ; Thu, 14 Aug 2025 02:26:14 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1755163572; x=1755768372; darn=vger.kernel.org; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:from:to:cc:subject:date:message-id :reply-to; bh=7XfWTbVgLd+JOqYthg70wtq8ZILm6OycONzgKD9jOeg=; b=SRzuRfZ7W5H9ct7QxTPoeinPasNtYuVHQ0xZ7urgnpYtvCzPxd4JX6P8Soy83D9itf MhutMPrTILtcSduqCSOvxNcRtqoXHabsxGFPKCAbkPn+4kyFotvKNzYekDsXD6eCUBne 1xEqDKeHSjSMzdLQdUUy5Ip3zwXf9GsmGrL5rMzRRMALUPmWe0bwulatydWhHtc1pLSJ ZbQzXqdtx5uxzCo25RI63BzFHOl7vX0xOKJ3PlVFTIE8zo1DEapSfRzsW8UysZCppaN1 8U/onlWXUFjmO6j8tHrEpuwh9MUzGTAaU8ZpdaYEVwY3ZTKrTN/U86dfD07aqBOYmSxd yVSA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1755163572; x=1755768372; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=7XfWTbVgLd+JOqYthg70wtq8ZILm6OycONzgKD9jOeg=; b=Hju9GAmSIQ8PEp2mDgvcyV0zuzcvPrE+3ugePOin3qleSOTQ61HE0bUleXUMEPDV6D gnKr/5gQF15oG8OyQEsvjjao3Wf/PcAaZ8ApPiGBJaUNP8/t6Jj1U0aZCbf0JKzDFsdO aoPS3MID6smOoaBeWo8XBCFNoW3oHaFK1brPolmGNTnLALbi3qCeFUMDJ4YIpFLpC6z2 2LNKMAVNeusASzEbbQZq/Dweilyor1PnoJuNrI4wde9ratFlgN+uSJIZQEQLhwV7UFCd AqbAnofGhItf8tvO466ENaC9ctzWkQC8t9z2oeqBT8kwQB3KmF/CK2OIhuEZRF7sDgbO oMTg== X-Forwarded-Encrypted: i=1; AJvYcCX39Bse09QxrNT6W3rP+BV/ZCKDcCQW2bHjFF8Fgo0f8JZPtcn1CDqMtMxYpUQ09GsTnL/62Ytsu3QWVGY=@vger.kernel.org X-Gm-Message-State: AOJu0YzmJDLA7WwEn2fW4rigwrzfc0Af6iERPlolb6hmMCtVskEqqpiz 7YeRsKhce+ryeadVJO1fVg0l9/acsGjEPH+jKOQ1QqpM3Vv2Rk7fqAIBJp5t5N7xYis= X-Gm-Gg: ASbGncuS3q7SOGgW/wrDqVCO4TBWPtNed64qg2ePM3Uwy2juO06xCANgS5TQ8xxoLS8 4x/415EEDKhhZvBoITRk9E4B7rf+t4RTYjxF7oF0+cuiVLPhHTrn2OfWKNb6TMdH6aXIxbmtiHZ lXtcPIDkyNP9ph6MWXzwfSsStco9uD9PLFOQf5f8UNyis3Z6qiF6GPdXYWH+C15T1iEEP+OiLep w6tGrdiZ2m3acJ3ZnMGTxnS4DdbaBWCeNctPOdyO/ozQ68cXGquJW2EDbLEoQcyQOJmh8rHcMMo iIdyJEJZI3kZG19sseW+xvWb/jjuemYBqPA8iVInPadfEPkOlVN4J4JTnH+ElRlKhwadNzr96WI IYiNwIj6k2EU3+bSHdg+t1rpwqzsP3Iys4WUmTWQXtw== X-Google-Smtp-Source: AGHT+IHgkhhSTJhTAotn5NYJjMj9xThkUbjFj6SmyZtDbwASU1U62gN3YjlKhJch73nBu/JUlmdJFg== X-Received: by 2002:a05:600c:4e89:b0:459:dfa8:b85e with SMTP id 5b1f17b1804b1-45a1bf9cc71mr13631165e9.0.1755163572258; Thu, 14 Aug 2025 02:26:12 -0700 (PDT) Received: from ho-tower-lan.lan ([185.48.76.109]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-45a1c76e9basm14536775e9.21.2025.08.14.02.26.11 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 14 Aug 2025 02:26:11 -0700 (PDT) From: James Clark Date: Thu, 14 Aug 2025 10:25:33 +0100 Subject: [PATCH v7 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: <20250814-james-perf-feat_spe_eft-v7-11-6a743f7fa259@linaro.org> References: <20250814-james-perf-feat_spe_eft-v7-0-6a743f7fa259@linaro.org> In-Reply-To: <20250814-james-perf-feat_spe_eft-v7-0-6a743f7fa259@linaro.org> To: Catalin Marinas , Will Deacon , Mark Rutland , Jonathan Corbet , Marc Zyngier , Oliver Upton , Joey Gouly , Suzuki K Poulose , Zenghui Yu , Peter Zijlstra , Ingo Molnar , Arnaldo Carvalho de Melo , Namhyung Kim , Alexander Shishkin , Jiri Olsa , Ian Rogers , Adrian Hunter , Leo Yan , Anshuman Khandual Cc: linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, linux-perf-users@vger.kernel.org, linux-doc@vger.kernel.org, kvmarm@lists.linux.dev, James Clark X-Mailer: b4 0.14.0 perf_event_attr has gained a new field, config4, so add support for it extending the existing configN support. Reviewed-by: Leo Yan Reviewed-by: Ian Rogers Tested-by: Leo Yan Signed-off-by: James Clark --- tools/perf/tests/parse-events.c | 14 +++++++++++++- tools/perf/util/parse-events.c | 11 +++++++++++ tools/perf/util/parse-events.h | 1 + tools/perf/util/parse-events.l | 1 + tools/perf/util/pmu.c | 8 ++++++++ tools/perf/util/pmu.h | 1 + 6 files changed, 35 insertions(+), 1 deletion(-) diff --git a/tools/perf/tests/parse-events.c b/tools/perf/tests/parse-event= s.c index bb8004397650..342ed896b703 100644 --- a/tools/perf/tests/parse-events.c +++ b/tools/perf/tests/parse-events.c @@ -615,6 +615,8 @@ static int test__checkevent_pmu(struct evlist *evlist) TEST_ASSERT_VAL("wrong config1", 1 =3D=3D evsel->core.attr.config1); TEST_ASSERT_VAL("wrong config2", 3 =3D=3D evsel->core.attr.config2); TEST_ASSERT_VAL("wrong config3", 0 =3D=3D evsel->core.attr.config3); + TEST_ASSERT_VAL("wrong config4", 0 =3D=3D evsel->core.attr.config4); + /* * The period value gets configured within evlist__config, * while this test executes only parse events method. @@ -637,6 +639,7 @@ static int test__checkevent_list(struct evlist *evlist) TEST_ASSERT_VAL("wrong config1", 0 =3D=3D evsel->core.attr.config1); TEST_ASSERT_VAL("wrong config2", 0 =3D=3D evsel->core.attr.config2); TEST_ASSERT_VAL("wrong config3", 0 =3D=3D evsel->core.attr.config3); + TEST_ASSERT_VAL("wrong config4", 0 =3D=3D evsel->core.attr.config4); TEST_ASSERT_VAL("wrong exclude_user", !evsel->core.attr.exclude_user); TEST_ASSERT_VAL("wrong exclude_kernel", !evsel->core.attr.exclude_kernel= ); TEST_ASSERT_VAL("wrong exclude_hv", !evsel->core.attr.exclude_hv); @@ -813,6 +816,15 @@ static int test__checkterms_simple(struct parse_events= _terms *terms) TEST_ASSERT_VAL("wrong val", term->val.num =3D=3D 4); TEST_ASSERT_VAL("wrong config", !strcmp(term->config, "config3")); =20 + /* config4=3D5 */ + term =3D list_entry(term->list.next, struct parse_events_term, list); + TEST_ASSERT_VAL("wrong type term", + term->type_term =3D=3D PARSE_EVENTS__TERM_TYPE_CONFIG4); + TEST_ASSERT_VAL("wrong type val", + term->type_val =3D=3D PARSE_EVENTS__TERM_TYPE_NUM); + TEST_ASSERT_VAL("wrong val", term->val.num =3D=3D 5); + TEST_ASSERT_VAL("wrong config", !strcmp(term->config, "config4")); + /* umask=3D1*/ term =3D list_entry(term->list.next, struct parse_events_term, list); TEST_ASSERT_VAL("wrong type term", @@ -2451,7 +2463,7 @@ struct terms_test { =20 static const struct terms_test test__terms[] =3D { [0] =3D { - .str =3D "config=3D10,config1,config2=3D3,config3=3D4,umask=3D1,read,r= 0xead", + .str =3D "config=3D10,config1,config2=3D3,config3=3D4,config4=3D5,umas= k=3D1,read,r0xead", .check =3D test__checkterms_simple, }, }; diff --git a/tools/perf/util/parse-events.c b/tools/perf/util/parse-events.c index 8282ddf68b98..5f0b4a3c3dda 100644 --- a/tools/perf/util/parse-events.c +++ b/tools/perf/util/parse-events.c @@ -247,6 +247,8 @@ __add_event(struct list_head *list, int *idx, PERF_PMU_FORMAT_VALUE_CONFIG2, "config2"); perf_pmu__warn_invalid_config(pmu, attr->config3, name, PERF_PMU_FORMAT_VALUE_CONFIG3, "config3"); + perf_pmu__warn_invalid_config(pmu, attr->config4, name, + PERF_PMU_FORMAT_VALUE_CONFIG4, "config4"); } } /* @@ -811,6 +813,7 @@ const char *parse_events__term_type_str(enum parse_even= ts__term_type term_type) [PARSE_EVENTS__TERM_TYPE_CONFIG1] =3D "config1", [PARSE_EVENTS__TERM_TYPE_CONFIG2] =3D "config2", [PARSE_EVENTS__TERM_TYPE_CONFIG3] =3D "config3", + [PARSE_EVENTS__TERM_TYPE_CONFIG4] =3D "config4", [PARSE_EVENTS__TERM_TYPE_NAME] =3D "name", [PARSE_EVENTS__TERM_TYPE_SAMPLE_PERIOD] =3D "period", [PARSE_EVENTS__TERM_TYPE_SAMPLE_FREQ] =3D "freq", @@ -859,6 +862,7 @@ config_term_avail(enum parse_events__term_type term_typ= e, struct parse_events_er case PARSE_EVENTS__TERM_TYPE_CONFIG1: case PARSE_EVENTS__TERM_TYPE_CONFIG2: case PARSE_EVENTS__TERM_TYPE_CONFIG3: + case PARSE_EVENTS__TERM_TYPE_CONFIG4: case PARSE_EVENTS__TERM_TYPE_NAME: case PARSE_EVENTS__TERM_TYPE_METRIC_ID: case PARSE_EVENTS__TERM_TYPE_SAMPLE_PERIOD: @@ -928,6 +932,10 @@ do { \ CHECK_TYPE_VAL(NUM); attr->config3 =3D term->val.num; break; + case PARSE_EVENTS__TERM_TYPE_CONFIG4: + CHECK_TYPE_VAL(NUM); + attr->config4 =3D term->val.num; + break; case PARSE_EVENTS__TERM_TYPE_SAMPLE_PERIOD: CHECK_TYPE_VAL(NUM); break; @@ -1153,6 +1161,7 @@ static int config_term_tracepoint(struct perf_event_a= ttr *attr, case PARSE_EVENTS__TERM_TYPE_CONFIG1: case PARSE_EVENTS__TERM_TYPE_CONFIG2: case PARSE_EVENTS__TERM_TYPE_CONFIG3: + case PARSE_EVENTS__TERM_TYPE_CONFIG4: case PARSE_EVENTS__TERM_TYPE_NAME: case PARSE_EVENTS__TERM_TYPE_SAMPLE_PERIOD: case PARSE_EVENTS__TERM_TYPE_SAMPLE_FREQ: @@ -1294,6 +1303,7 @@ do { \ case PARSE_EVENTS__TERM_TYPE_CONFIG1: case PARSE_EVENTS__TERM_TYPE_CONFIG2: case PARSE_EVENTS__TERM_TYPE_CONFIG3: + case PARSE_EVENTS__TERM_TYPE_CONFIG4: case PARSE_EVENTS__TERM_TYPE_NAME: case PARSE_EVENTS__TERM_TYPE_METRIC_ID: case PARSE_EVENTS__TERM_TYPE_RAW: @@ -1332,6 +1342,7 @@ static int get_config_chgs(struct perf_pmu *pmu, stru= ct parse_events_terms *head case PARSE_EVENTS__TERM_TYPE_CONFIG1: case PARSE_EVENTS__TERM_TYPE_CONFIG2: case PARSE_EVENTS__TERM_TYPE_CONFIG3: + case PARSE_EVENTS__TERM_TYPE_CONFIG4: case PARSE_EVENTS__TERM_TYPE_NAME: case PARSE_EVENTS__TERM_TYPE_SAMPLE_PERIOD: case PARSE_EVENTS__TERM_TYPE_SAMPLE_FREQ: diff --git a/tools/perf/util/parse-events.h b/tools/perf/util/parse-events.h index 62dc7202e3ba..9e482cfdaaf9 100644 --- a/tools/perf/util/parse-events.h +++ b/tools/perf/util/parse-events.h @@ -60,6 +60,7 @@ enum parse_events__term_type { PARSE_EVENTS__TERM_TYPE_CONFIG1, PARSE_EVENTS__TERM_TYPE_CONFIG2, PARSE_EVENTS__TERM_TYPE_CONFIG3, + PARSE_EVENTS__TERM_TYPE_CONFIG4, PARSE_EVENTS__TERM_TYPE_NAME, PARSE_EVENTS__TERM_TYPE_SAMPLE_PERIOD, PARSE_EVENTS__TERM_TYPE_SAMPLE_FREQ, diff --git a/tools/perf/util/parse-events.l b/tools/perf/util/parse-events.l index 2034590eb789..300d84fd09ad 100644 --- a/tools/perf/util/parse-events.l +++ b/tools/perf/util/parse-events.l @@ -317,6 +317,7 @@ config { return term(yyscanner, PARSE_EVENTS__TERM_TY= PE_CONFIG); } config1 { return term(yyscanner, PARSE_EVENTS__TERM_TYPE_CONFIG1); } config2 { return term(yyscanner, PARSE_EVENTS__TERM_TYPE_CONFIG2); } config3 { return term(yyscanner, PARSE_EVENTS__TERM_TYPE_CONFIG3); } +config4 { return term(yyscanner, PARSE_EVENTS__TERM_TYPE_CONFIG4); } name { return term(yyscanner, PARSE_EVENTS__TERM_TYPE_NAME); } period { return term(yyscanner, PARSE_EVENTS__TERM_TYPE_SAMPLE_PERIOD); } freq { return term(yyscanner, PARSE_EVENTS__TERM_TYPE_SAMPLE_FREQ); } diff --git a/tools/perf/util/pmu.c b/tools/perf/util/pmu.c index 5a291f1380ed..5868d654872b 100644 --- a/tools/perf/util/pmu.c +++ b/tools/perf/util/pmu.c @@ -1539,6 +1539,10 @@ static int pmu_config_term(const struct perf_pmu *pm= u, assert(term->type_val =3D=3D PARSE_EVENTS__TERM_TYPE_NUM); pmu_format_value(bits, term->val.num, &attr->config3, zero); break; + case PARSE_EVENTS__TERM_TYPE_CONFIG4: + assert(term->type_val =3D=3D PARSE_EVENTS__TERM_TYPE_NUM); + pmu_format_value(bits, term->val.num, &attr->config4, zero); + break; case PARSE_EVENTS__TERM_TYPE_USER: /* Not hardcoded. */ return -EINVAL; case PARSE_EVENTS__TERM_TYPE_NAME ... PARSE_EVENTS__TERM_TYPE_CPU: @@ -1586,6 +1590,9 @@ static int pmu_config_term(const struct perf_pmu *pmu, case PERF_PMU_FORMAT_VALUE_CONFIG3: vp =3D &attr->config3; break; + case PERF_PMU_FORMAT_VALUE_CONFIG4: + vp =3D &attr->config4; + break; default: return -EINVAL; } @@ -1912,6 +1919,7 @@ int perf_pmu__for_each_format(struct perf_pmu *pmu, v= oid *state, pmu_format_call "config1=3D0..0xffffffffffffffff", "config2=3D0..0xffffffffffffffff", "config3=3D0..0xffffffffffffffff", + "config4=3D0..0xffffffffffffffff", "name=3Dstring", "period=3Dnumber", "freq=3Dnumber", diff --git a/tools/perf/util/pmu.h b/tools/perf/util/pmu.h index 1ebcf0242af8..67431f765266 100644 --- a/tools/perf/util/pmu.h +++ b/tools/perf/util/pmu.h @@ -23,6 +23,7 @@ enum { PERF_PMU_FORMAT_VALUE_CONFIG1, PERF_PMU_FORMAT_VALUE_CONFIG2, PERF_PMU_FORMAT_VALUE_CONFIG3, + PERF_PMU_FORMAT_VALUE_CONFIG4, PERF_PMU_FORMAT_VALUE_CONFIG_END, }; =20 --=20 2.34.1 From nobody Sat Oct 4 17:34:18 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 6554C2FA0E2 for ; Thu, 14 Aug 2025 09:26:15 +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=1755163577; cv=none; b=n1AtbTZrRMp7TikNYNOUYS9tU9pbRXZAlhZB5kqudogCMrKUOLCWnZSxpeVCRQJI3FD5bqlMdwUbe24PNnCUxTs8Ybmy/q/O0H+9cB1TuxsFGtvz+Q3R7yoFSl/Sq/cXy7VNVhsRvhyxJBl8fa2Y6MlGpGi7V9eS79URPOk09+Q= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1755163577; c=relaxed/simple; bh=aRUWGynzXd2I0iPJ8E252lMe7rGfIx7dGynoHirUSWM=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=CiopCZru8b6CkL8P3CZnU51KNClL7Fve6nSBeLgfH0Jom2+IYsFFHz2lIxVKiipdRLj0jOJO/sXA6jJAoZ9EV9TYFsNmNAFGa8dldReDHVASz7PVA4gd8adgSTWIZdbTrg8307ZFMe2jCd/wHIwiEd3ASmGOxFGN4wdBtaj/98w= 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=j4LEOplN; 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="j4LEOplN" Received: by mail-wm1-f43.google.com with SMTP id 5b1f17b1804b1-45a1abf5466so4566795e9.0 for ; Thu, 14 Aug 2025 02:26:15 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1755163574; x=1755768374; 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=j4LEOplNcrW7X8kwb1CnXfaTbEajo03DB6g7x6QZwdzE/a38HKx97UupxLT/NUIIlG qxNIDWbLJSk90hnzTmUSHOulWTFuScvLFfNpAQdDCRstlDx1tmOAy/tuwRwuUCeu3NXd VlAE/QJ9CuCfU0oVVOq2eoTzz/G4i9Ll0AYTS9XUCEbGRLT8QegIvpKHUKuCzkQXrHna bH71/jCbgq4666O2BcycxEISrukrFtAaAjWbFRDfKAMjnvc2xLRabayGhD/X7XkJ1bzS uuY75busUZurog/HkA+rDz/Nx6GueHkdgtNVawU/aF8n6/Eizlo2ZqHplKNZb8vpbW/P uFDQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1755163574; x=1755768374; 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=ABUFMVU1j8FRxVuq8IMO6tnZaaJbpEPsM+iFDHib2XiGQMcWdikeHo26W4nOTYsviM P07hqT+pq8HwREVeydd6K5PlUiqB0slrCbQrfbapw4PKCt1OCn3eIPgmSG4iG+yYL3Dr LvKv+VYRvKIcW0Cbzsv0FHeuW8bXAdQuYlU0j7mqjlDVVKRFLgVXsfBd0rEiGIr2S1Xs pVYQFBOQ1LvBSkTT9bEcygi3u3z8zSZFwGbkdS9PjpBUOozAXFXPu1Ioc67PZUe87PXA ITMyUG+G32HI7cqG6Ik+3wDSLfiNa7HzlV9+0akUQUJCXaf46ThB5/laN8O7/c5/9o6I xhDg== X-Forwarded-Encrypted: i=1; AJvYcCXMZPPxWYtV4fL4RnCsgZwmF2t46HekKVkuXO+6/gocdhLXvPkZxXv9pUsTBxYc6wS1sKnnqn9YIMxr824=@vger.kernel.org X-Gm-Message-State: AOJu0Yw+HMDaEJXfA9suqZfOQIOFioBjB+c8zIpEfk+tXuDXPQ86LNMa uqTYhhpKseE70bIQxa3d3n5b2ddT6X/H1MLbPtBMviZAAWYue5zQ3OQODWEzYqo0+eY= X-Gm-Gg: ASbGnctaobGXSbK0x/kKJ0uMDFQXwjW4XSn9aP0TAJBQAaMdgEuI474GtW05JNrNW4d jW0/vVQFpnWMmKMiAd8cheCr/wHYjaZpgWFjXy34NRuvCVp8dA1Ir7Ie5lF/PTlk+uIW5ljalHz 3D+c0D2XaK6k4BYWg6IQFPpjzpMnKsTxrzLo+N2rG7FTSJxrHkQ8ZlKJA42X3ckg/YEOzgVJA6I w5jPbWdn1gqN41oJ6kn4qFtItNPPJ03hMLb4ZnV/CbSIct7YpsSQIFMgzR0d6D0fenMYQB39V54 XJnH9Mguo0Kb/2/bxPooLPA97BGrCvUgZ9tatyaHe+u6cEbJJs7XUM/2YpAZj6LHdZu8E8h+QAr eLT+3HHkgSc3EB7c6Ja8Pqcmzmp0tFq0= X-Google-Smtp-Source: AGHT+IGGwcoMzDXS1HdgNpJCFBXwesMKa6+WGWKlGGM+FBXwvfsNCs5rIY/Vzr6H0lhl8WHOxlwXhg== X-Received: by 2002:a05:600c:3006:b0:459:db88:c4ca with SMTP id 5b1f17b1804b1-45a1b65c7c9mr13077885e9.3.1755163573684; Thu, 14 Aug 2025 02:26:13 -0700 (PDT) Received: from ho-tower-lan.lan ([185.48.76.109]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-45a1c76e9basm14536775e9.21.2025.08.14.02.26.12 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 14 Aug 2025 02:26:13 -0700 (PDT) From: James Clark Date: Thu, 14 Aug 2025 10:25:34 +0100 Subject: [PATCH v7 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: <20250814-james-perf-feat_spe_eft-v7-12-6a743f7fa259@linaro.org> References: <20250814-james-perf-feat_spe_eft-v7-0-6a743f7fa259@linaro.org> In-Reply-To: <20250814-james-perf-feat_spe_eft-v7-0-6a743f7fa259@linaro.org> To: Catalin Marinas , Will Deacon , Mark Rutland , Jonathan Corbet , Marc Zyngier , Oliver Upton , Joey Gouly , Suzuki K Poulose , Zenghui Yu , Peter Zijlstra , Ingo Molnar , Arnaldo Carvalho de Melo , Namhyung Kim , Alexander Shishkin , Jiri Olsa , Ian Rogers , Adrian Hunter , Leo Yan , Anshuman Khandual Cc: linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, linux-perf-users@vger.kernel.org, linux-doc@vger.kernel.org, kvmarm@lists.linux.dev, James Clark X-Mailer: b4 0.14.0 FEAT_SPE_EFT and FEAT_SPE_FDS etc have new user facing format attributes so document them. Also document existing 'event_filter' bits that were missing from the doc and the fact that latency values are stored in the weight field. Reviewed-by: Leo Yan Tested-by: Leo Yan Reviewed-by: Ian Rogers Signed-off-by: James Clark --- tools/perf/Documentation/perf-arm-spe.txt | 104 ++++++++++++++++++++++++++= +--- 1 file changed, 95 insertions(+), 9 deletions(-) diff --git a/tools/perf/Documentation/perf-arm-spe.txt b/tools/perf/Documen= tation/perf-arm-spe.txt index 37afade4f1b2..c7d1032ff219 100644 --- a/tools/perf/Documentation/perf-arm-spe.txt +++ b/tools/perf/Documentation/perf-arm-spe.txt @@ -141,27 +141,65 @@ Config parameters These are placed between the // in the event and comma separated. For exam= ple '-e arm_spe/load_filter=3D1,min_latency=3D10/' =20 - branch_filter=3D1 - collect branches only (PMSFCR.B) - event_filter=3D - filter on specific events (PMSEVFR) - see bitfie= ld description below + event_filter=3D - logical AND filter on specific events (PMSEVFR) = - see bitfield description below + inv_event_filter=3D - logical OR to filter out specific events (PM= SNEVFR, FEAT_SPEv1p2) - see bitfield description below jitter=3D1 - use jitter to avoid resonance when sampling (PMS= IRR.RND) - load_filter=3D1 - collect loads only (PMSFCR.LD) min_latency=3D - collect only samples with this latency or higher= * (PMSLATFR) pa_enable=3D1 - collect physical address (as well as VA) of load= s/stores (PMSCR.PA) - requires privilege pct_enable=3D1 - collect physical timestamp instead of virtual ti= mestamp (PMSCR.PCT) - requires privilege - store_filter=3D1 - collect stores only (PMSFCR.ST) ts_enable=3D1 - enable timestamping with value of generic timer = (PMSCR.TS) discard=3D1 - enable SPE PMU events but don't collect sample d= ata - see 'Discard mode' (PMBLIMITR.FM =3D DISCARD) + data_src_filter=3D - mask to filter from 0-63 possible data source= s (PMSDSFR, FEAT_SPE_FDS) - See 'Data source filtering' =20 +++*+++ Latency is the total latency from the point at which sampling star= ted on that instruction, rather than only the execution latency. =20 -Only some events can be filtered on; these include: - - bit 1 - instruction retired (i.e. omit speculative instructions) +Only some events can be filtered on using 'event_filter' bits. The overall +filter is the logical AND of these bits, for example if bits 3 and 5 are s= et +only samples that have both 'L1D cache refill' AND 'TLB walk' are recorded= . When +FEAT_SPEv1p2 is implemented 'inv_event_filter' can also be used to exclude +events that have any (OR) of the filter's bits set. For example setting bi= ts 3 +and 5 in 'inv_event_filter' will exclude any events that are either L1D ca= che +refill OR TLB walk. If the same bit is set in both filters it's UNPREDICTA= BLE +whether the sample is included or excluded. Filter bits for both event_fil= ter +and inv_event_filter are: + + bit 1 - Instruction retired (i.e. omit speculative instructions) + bit 2 - L1D access (FEAT_SPEv1p4) bit 3 - L1D refill + bit 4 - TLB access (FEAT_SPEv1p4) bit 5 - TLB refill - bit 7 - mispredict - bit 11 - misaligned access + bit 6 - Not taken event (FEAT_SPEv1p2) + bit 7 - Mispredict + bit 8 - Last level cache access (FEAT_SPEv1p4) + bit 9 - Last level cache miss (FEAT_SPEv1p4) + bit 10 - Remote access (FEAT_SPEv1p4) + bit 11 - Misaligned access (FEAT_SPEv1p1) + bit 12-15 - IMPLEMENTATION DEFINED events (when implemented) + bit 16 - Transaction (FEAT_TME) + bit 17 - Partial or empty SME or SVE predicate (FEAT_SPEv1p1) + bit 18 - Empty SME or SVE predicate (FEAT_SPEv1p1) + bit 19 - L2D access (FEAT_SPEv1p4) + bit 20 - L2D miss (FEAT_SPEv1p4) + bit 21 - Cache data modified (FEAT_SPEv1p4) + bit 22 - Recently fetched (FEAT_SPEv1p4) + bit 23 - Data snooped (FEAT_SPEv1p4) + bit 24 - Streaming SVE mode event (when FEAT_SPE_SME is implemented),= or + IMPLEMENTATION DEFINED event 24 (when implemented, only vers= ions + less than FEAT_SPEv1p4) + bit 25 - SMCU or external coprocessor operation event when FEAT_SPE_S= ME is + implemented, or IMPLEMENTATION DEFINED event 25 (when implem= ented, + only versions less than FEAT_SPEv1p4) + bit 26-31 - IMPLEMENTATION DEFINED events (only versions less than FEAT_= SPEv1p4) + bit 48-63 - IMPLEMENTATION DEFINED events (when implemented) + +For IMPLEMENTATION DEFINED bits, refer to the CPU TRM if these bits are +implemented. + +The driver will reject events if requested filter bits require unimplement= ed SPE +versions, but will not reject filter bits for unimplemented IMPDEF bits or= when +their related feature is not present (e.g. SME). For example, if FEAT_SPEv= 1p2 is +not implemented, filtering on "Not taken event" (bit 6) will be rejected. =20 So to sample just retired instructions: =20 @@ -171,6 +209,31 @@ or just mispredicted branches: =20 perf record -e arm_spe/event_filter=3D0x80/ -- ./mybench =20 +When set, the following filters can be used to select samples that match a= ny of +the operation types (OR filtering). If only one is set then only samples o= f that +type are collected: + + branch_filter=3D1 - Collect branches (PMSFCR.B) + load_filter=3D1 - Collect loads (PMSFCR.LD) + store_filter=3D1 - Collect stores (PMSFCR.ST) + +When extended filtering is supported (FEAT_SPE_EFT), SIMD and float +pointer operations can also be selected: + + simd_filter=3D1 - Collect SIMD loads, stores and operations (PMS= FCR.SIMD) + float_filter=3D1 - Collect floating point loads, stores and opera= tions (PMSFCR.FP) + +When extended filtering is supported (FEAT_SPE_EFT), operation type filter= s can +be changed to AND using _mask fields. For example samples could be selecte= d if +they are store AND SIMD by setting 'store_filter=3D1,simd_filter=3D1, +store_filter_mask=3D1,simd_filter_mask=3D1'. The new masks are as follows: + + branch_filter_mask=3D1 - Change branch filter behavior from OR to AND (= PMSFCR.Bm) + load_filter_mask=3D1 - Change load filter behavior from OR to AND (PM= SFCR.LDm) + store_filter_mask=3D1 - Change store filter behavior from OR to AND (P= MSFCR.STm) + simd_filter_mask=3D1 - Change SIMD filter behavior from OR to AND (PM= SFCR.SIMDm) + float_filter_mask=3D1 - Change floating point filter behavior from OR = to AND (PMSFCR.FPm) + Viewing the data ~~~~~~~~~~~~~~~~~ =20 @@ -204,6 +267,10 @@ Memory access details are also stored on the samples a= nd this can be viewed with =20 perf report --mem-mode =20 +The latency value from the SPE sample is stored in the 'weight' field of t= he +Perf samples and can be displayed in Perf script and report outputs by ena= bling +its display from the command line. + Common errors ~~~~~~~~~~~~~ =20 @@ -247,6 +314,25 @@ to minimize output. Then run perf stat: perf record -e arm_spe/discard/ -a -N -B --no-bpf-event -o - > /dev/null= & perf stat -e SAMPLE_FEED_LD =20 +Data source filtering +~~~~~~~~~~~~~~~~~~~~~ + +When FEAT_SPE_FDS is present, 'inv_data_src_filter' can be used as a mask = to +filter on a subset (0 - 63) of possible data source IDs. The full range of= data +sources is 0 - 65535 although these are unlikely to be used in practice. D= ata +sources are IMPDEF so refer to the TRM for the mappings. Each bit N of the +filter maps to data source N. The filter is an OR of all the bits, and the= value +provided inv_data_src_filter is inverted before writing to PMSDSFR_EL1 so = that +set bits exclude that data source and cleared bits include that data sourc= e. +Therefore the default value of 0 is equivalent to no filtering (all data s= ources +included). + +For example, to include only data sources 0 and 3, clear bits 0 and 3 +(0xFFFFFFFFFFFFFFF6) + +When 'inv_data_src_filter' is set to 0xFFFFFFFFFFFFFFFF, any samples with = any +data source set are excluded. + SEE ALSO -------- =20 --=20 2.34.1