From nobody Sun Dec 14 02:00:56 2025 Received: from NAM10-MW2-obe.outbound.protection.outlook.com (mail-mw2nam10on2075.outbound.protection.outlook.com [40.107.94.75]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id F3DB128CF5B; Thu, 15 May 2025 22:52:37 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.94.75 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1747349559; cv=fail; b=scbr4fbDoD2M8GC1IwsgMgADbFLZfHjfqpedrEbBkBSVG84GaMqCaIp/1vHn7oXcC0mTB1D1Uh7YYlkmJrJhUfiFvOClKKQSaVwVrp5rdtGYABaqEGPLnDVWIcoiimJbSJ6ngbIeD2NLR7VKM2VTvCDFNZwPzS4FOfbd4wwjzO8= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1747349559; c=relaxed/simple; bh=g1vG1TVFWJ83nexjkUzg6XRo07BFjZ82aZ+Prv+QKFk=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=VuUDhrtsq6mdQytn0fVbGdv8ZKGIei9xmkikcsdB1K30+uBbygyJONCtUD9P8E1LXn6L7MhPD4qvVRbPOY7Zd/NlXYdsJYEN1OJD68GYFHzB0kwKmRaDtaarlWSMvbHmE6ng076ecc9+goZKD/VJ7Z6hN8kp+tcsk4emocmvFxo= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=amd.com; spf=fail smtp.mailfrom=amd.com; dkim=pass (1024-bit key) header.d=amd.com header.i=@amd.com header.b=wrSaL29f; arc=fail smtp.client-ip=40.107.94.75 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=amd.com Authentication-Results: smtp.subspace.kernel.org; spf=fail smtp.mailfrom=amd.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=amd.com header.i=@amd.com header.b="wrSaL29f" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=dko0YhzZcRWGYyyHnY95/0TzJn/bJ30JW0KSx5kH3K8e2m40qvzpbtpva6iCYyuYfXMJhvdY/kFoiVUC4GVNa2Hli7mKF1x+o7fRTwBgM1HtFk35nMIz9a3YPWB/p1yPC1aXgySK1p9oCa0/LknNouPWHppkF2fqvzpJKS1vMiFcKr6HMu7sp1EM9mQgwW2Vm6hIrhOUVppphcnt/0xvQ4NQtaov3/PUIeLEc+yn5zMoGH/wEmN6cPnmdgjcCSwAMd684AOA1oNuYFwF6SIVAifW5BAeWYN795diQNLPNLfLq3yzTzMK/dmE3XUu7tM1qMmP84CnsNYPYrTKq3/yWQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=Po7O7xeWZu12ShzY87rp997Tlag5EYSyzVHIz/yf6Qo=; b=VhEBb18ZS4eDGDsabUBdO0DqKa/XAocLJ87JLrMvNi+KLKYqygQAF8RbM4HUyoRd47si3CZquaVhryCdpp7fB8tdqSPR5jFyOtlM7pSZG75F2KxCpIAGO8iY/vd+BL2qvw8HrExkwX1OkxKPrEkpVjExF1H4BPG1Jr7fWIQiLFonok1vwANr2kKALmnQ9hSSooM9/Ws+yv/+F5G4FayPmXaf+YHllx2sh1GmA1ThHjZ1AjdkuZFEXSEZoI6D8jwW3hGg6zWvP2tP5a1grT5jKU3cwR/o6XmOb29c6A4P2nTzNgNZhNv2wmLmVvYVReriVlw1kR98j9H2Ohqc0zcGzA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=lwn.net smtp.mailfrom=amd.com; dmarc=pass (p=quarantine sp=quarantine pct=100) action=none header.from=amd.com; dkim=none (message not signed); arc=none (0) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amd.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=Po7O7xeWZu12ShzY87rp997Tlag5EYSyzVHIz/yf6Qo=; b=wrSaL29f/bA6Z6qynFYufbmzJqujXv+02qlX+4BJGvvtHuPuOHMIUXFOlcq7jgxi98727AZDpDBLK1O6r0ebNyxp3PBZqoN7flRAQNaIZrUF2ZdijUETLAsY0rkQD8j0CRITj94szUR9YxCu6yPWY7ij38GeAEhQlFqaGqaw4DE= Received: from LV3P220CA0010.NAMP220.PROD.OUTLOOK.COM (2603:10b6:408:234::30) by SN7PR12MB7809.namprd12.prod.outlook.com (2603:10b6:806:34e::21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8722.29; Thu, 15 May 2025 22:52:33 +0000 Received: from BN1PEPF00004683.namprd03.prod.outlook.com (2603:10b6:408:234:cafe::ad) by LV3P220CA0010.outlook.office365.com (2603:10b6:408:234::30) with Microsoft SMTP Server (version=TLS1_3, cipher=TLS_AES_256_GCM_SHA384) id 15.20.8746.18 via Frontend Transport; Thu, 15 May 2025 22:52:33 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 165.204.84.17) smtp.mailfrom=amd.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=amd.com; Received-SPF: Pass (protection.outlook.com: domain of amd.com designates 165.204.84.17 as permitted sender) receiver=protection.outlook.com; client-ip=165.204.84.17; helo=SATLEXMB04.amd.com; pr=C Received: from SATLEXMB04.amd.com (165.204.84.17) by BN1PEPF00004683.mail.protection.outlook.com (10.167.243.89) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.8722.18 via Frontend Transport; Thu, 15 May 2025 22:52:31 +0000 Received: from bmoger-ubuntu.amd.com (10.180.168.240) by SATLEXMB04.amd.com (10.181.40.145) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.39; Thu, 15 May 2025 17:52:28 -0500 From: Babu Moger To: , , , , , , CC: , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , Subject: [PATCH v13 01/27] x86/cpufeatures: Add support for Assignable Bandwidth Monitoring Counters (ABMC) Date: Thu, 15 May 2025 17:51:46 -0500 Message-ID: X-Mailer: git-send-email 2.34.1 In-Reply-To: References: Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-ClientProxiedBy: SATLEXMB04.amd.com (10.181.40.145) To SATLEXMB04.amd.com (10.181.40.145) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: BN1PEPF00004683:EE_|SN7PR12MB7809:EE_ X-MS-Office365-Filtering-Correlation-Id: 2fee09c0-ea93-4955-5274-08dd94032cc8 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|1800799024|36860700013|7416014|376014|82310400026|13003099007; X-Microsoft-Antispam-Message-Info: =?us-ascii?Q?vt6XY9fhwrdr8mTpn469nVAFJ44IvTG1Movec3MZJTWQ3byPoTROpy5aXA+x?= =?us-ascii?Q?s13chsTC/CgG8G+Aleno1+9aEadO6ssWVYeMhKKmUCI8t5ebLtz/zKi/Iv3Z?= =?us-ascii?Q?eUu05Cu7qAKzIYcF3QgWYakaNxWwSLnoUvqjqbOHulvJZA4TCSXezqhTvPTI?= =?us-ascii?Q?yJZdkPtZdiRTTZUbaSbFQs5z0gfM/RMcO/6GP0klJoNZnIK+8aiH17XTAeA7?= =?us-ascii?Q?rev45xStniHm+yuvAoWANloXiKXScdzNlEAKaFvdA6Fuv9mLBr9GLkj8csg3?= =?us-ascii?Q?7uUQisdF/takwEDK6StO/SkFMgtqZu6nXnDAH6Zr6/EDwc94iH/wOCe99/RC?= =?us-ascii?Q?8+E6tPE13aNz87mGbm/FXt4DS8mXLiY2tfywdsqC6kcjWNCIv57+e9Mr0ZFl?= =?us-ascii?Q?bvxWCoHr1oLh5tXXxAqO7Q7sv3Jjf4k0qsR4U8emz/fk+aBBNYCW4GWu1Itp?= =?us-ascii?Q?3BEWRZ3mbiphdQujUa2ESMKI4iONLvbiYm40EixLAQ9Gj7f09/pL3W8w2Heb?= =?us-ascii?Q?VEEe8GFEdSSBluf4gkztztNhk7/SjCgwDBrn/aHcmKkajHwS3EyW2ud0a7WA?= =?us-ascii?Q?CqG7RuP16hQ6MHtxZNLw3cI/vcOJEkoJZgUvXSH7tJmnlRJ2NwEvIb09l99N?= =?us-ascii?Q?UVVk42PmcoYv47QOH7b9lRoQW/GIrirbdCAFljnD/9ju7BhuJMdmWtYG5VaZ?= =?us-ascii?Q?zNoYmayQnn1rTEPeJLyQ/zD7GnGdtxynjAluTaC8HO4bg0U6/xYG7KJr1TMG?= =?us-ascii?Q?VRh8sWOl51MWIRkOPGesIrF+rb9uZ/nd34TlQofkv3ITlizNzaxcXxvIdYq0?= =?us-ascii?Q?VLr9d6kC44I4AKTeOAurdImOUR6SCp3aKAbjIaF3d27LnCLPJUgBgij67ayw?= =?us-ascii?Q?/SSv2sMef0K1oRNyn2+fFSEpKLiTp9EwdFyy1Wxxi3eQ0wQm9Mk3Ib/YTrdi?= =?us-ascii?Q?bLTej/k6gzkzBxho81G3X4D0SZrrhvYvTVpzarRJW2D57CrBxqcofqiI1lzt?= =?us-ascii?Q?lfvnlxqFOvIVLCjxUf+N+MOGymABiWzqpnM7bPg06agcgMzmqAtmJeS19Rr1?= =?us-ascii?Q?Uq8Ux8KPPQSfqOYd8A6mcEyACpIQRwAVuH75CquTNwu4sUush2NikJwhkMg9?= =?us-ascii?Q?8Zq8hSP54WwEVJYbskmwRT7x/EAOVsSeN+E7Z5H+O+4cEbTT65XwwDoJAsNy?= =?us-ascii?Q?FlCL4UxD3YYDXT3Q6fDuVNYKFqAhDydzShm4U8TkPaTvogiCNdQ8vqhkPi1H?= =?us-ascii?Q?BcXBFo1xQlMV5RPR+CiyLtWxH0dV4Oi62echpNClee70ZsYUfvuJ2/oWcGCM?= =?us-ascii?Q?AQOIVHb9RSzwFCD2BYd/baIVEQUcp/KJx//+hxAp204rGhrr8ChpzfOU9UZa?= =?us-ascii?Q?We2YutI6zcMtb3WqlmnI6F8HQLpZEbPTZh4tyEf8WDpV+iRANikyWz8tjQTB?= =?us-ascii?Q?12v11C+BgFuOyuTD8F1o15kXcZBhnVpc5pbrUVeHfyFn+NE3297SlC15d6cT?= =?us-ascii?Q?nV3qu8wLuNJ6X9c927s6AmoUnv0WDHkQ/FSZP7/Rm5J5Otp9pghXXIsM7Q?= =?us-ascii?Q?=3D=3D?= X-Forefront-Antispam-Report: CIP:165.204.84.17;CTRY:US;LANG:en;SCL:1;SRV:;IPV:CAL;SFV:NSPM;H:SATLEXMB04.amd.com;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(13230040)(1800799024)(36860700013)(7416014)(376014)(82310400026)(13003099007);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 15 May 2025 22:52:31.3151 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 2fee09c0-ea93-4955-5274-08dd94032cc8 X-MS-Exchange-CrossTenant-Id: 3dd8961f-e488-4e60-8e11-a82d994e183d X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=3dd8961f-e488-4e60-8e11-a82d994e183d;Ip=[165.204.84.17];Helo=[SATLEXMB04.amd.com] X-MS-Exchange-CrossTenant-AuthSource: BN1PEPF00004683.namprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: SN7PR12MB7809 Content-Type: text/plain; charset="utf-8" Users can create as many monitor groups as RMIDs supported by the hardware. However, bandwidth monitoring feature on AMD system only guarantees that RMIDs currently assigned to a processor will be tracked by hardware. The counters of any other RMIDs which are no longer being tracked will be reset to zero. The MBM event counters return "Unavailable" for the RMIDs that are not tracked by hardware. So, there can be only limited number of groups that can give guaranteed monitoring numbers. With ever changing configurations there is no way to definitely know which of these groups are being tracked for certain point of time. Users do not have the option to monitor a group or set of groups for certain period of time without worrying about RMID being reset in between. The ABMC feature provides an option to the user to assign a hardware counter to an RMID, event pair and monitor the bandwidth as long as it is assigned. The assigned RMID will be tracked by the hardware until the user unassigns it manually. There is no need to worry about counters being reset during this period. Additionally, the user can specify a bitmask identifying the specific bandwidth types from the given source to track with the counter. Without ABMC enabled, monitoring will work in current mode without assignment option. The Linux resctrl subsystem provides an interface that allows monitoring of up to two memory bandwidth events per group, selected from a combination of available total and local events. When ABMC is enabled, two events will be assigned to each group by default, in line with the current interface design. Users will also have the option to configure which types of memory transactions are counted by these events. Due to the limited number of available counters (32), users may quickly exhaust the available counters. If the system runs out of assignable ABMC counters, the kernel will report an error. In such cases, users will nee dto unassign one or more active counters to free up countes for new assignments. The interface will provide options to assign or unassign events through the group-specific interface file. The feature can be detected via CPUID_Fn80000020_EBX_x00 bit 5. Bits Description 5 ABMC (Assignable Bandwidth Monitoring Counters) The feature details are documented in APM listed below [1]. [1] AMD64 Architecture Programmer's Manual Volume 2: System Programming Publication # 24593 Revision 3.41 section 19.3.3.3 Assignable Bandwidth Monitoring (ABMC). Link: https://bugzilla.kernel.org/show_bug.cgi?id=3D206537 Signed-off-by: Babu Moger --- Note: Checkpatch checks/warnings are ignored to maintain coding style. v13: Updated the commit log with Linux interface details. v12: Removed the dependancy on X86_FEATURE_BMEC. Removed the Reviewed-by tag as patch has changed. v11: No changes. v10: No changes. v9: Took care of couple of minor merge conflicts. No other changes. v8: No changes. v7: Removed "" from feature flags. Not required anymore. https://lore.kernel.org/lkml/20240817145058.GCZsC40neU4wkPXeVR@fat_crat= e.local/ v6: Added Reinette's Reviewed-by. Moved the Checkpatch note below ---. v5: Minor rebase change and subject line update. v4: Changes because of rebase. Feature word 21 has few more additions now. Changed the text to "tracked by hardware" instead of active. v3: Change because of rebase. Actual patch did not change. v2: Added dependency on X86_FEATURE_BMEC. --- arch/x86/include/asm/cpufeatures.h | 1 + arch/x86/kernel/cpu/cpuid-deps.c | 2 ++ arch/x86/kernel/cpu/scattered.c | 1 + 3 files changed, 4 insertions(+) diff --git a/arch/x86/include/asm/cpufeatures.h b/arch/x86/include/asm/cpuf= eatures.h index 6c2c152d8a67..d5c14dc678df 100644 --- a/arch/x86/include/asm/cpufeatures.h +++ b/arch/x86/include/asm/cpufeatures.h @@ -481,6 +481,7 @@ #define X86_FEATURE_AMD_HETEROGENEOUS_CORES (21*32 + 6) /* Heterogeneous C= ore Topology */ #define X86_FEATURE_AMD_WORKLOAD_CLASS (21*32 + 7) /* Workload Classificat= ion */ #define X86_FEATURE_PREFER_YMM (21*32 + 8) /* Avoid ZMM registers due to = downclocking */ +#define X86_FEATURE_ABMC (21*32 + 9) /* Assignable Bandwidth Monitoring C= ounters */ =20 /* * BUG word(s) diff --git a/arch/x86/kernel/cpu/cpuid-deps.c b/arch/x86/kernel/cpu/cpuid-d= eps.c index a2fbea0be535..2f54831e04e5 100644 --- a/arch/x86/kernel/cpu/cpuid-deps.c +++ b/arch/x86/kernel/cpu/cpuid-deps.c @@ -71,6 +71,8 @@ static const struct cpuid_dep cpuid_deps[] =3D { { X86_FEATURE_CQM_MBM_LOCAL, X86_FEATURE_CQM_LLC }, { X86_FEATURE_BMEC, X86_FEATURE_CQM_MBM_TOTAL }, { X86_FEATURE_BMEC, X86_FEATURE_CQM_MBM_LOCAL }, + { X86_FEATURE_ABMC, X86_FEATURE_CQM_MBM_TOTAL }, + { X86_FEATURE_ABMC, X86_FEATURE_CQM_MBM_LOCAL }, { X86_FEATURE_AVX512_BF16, X86_FEATURE_AVX512VL }, { X86_FEATURE_AVX512_FP16, X86_FEATURE_AVX512BW }, { X86_FEATURE_ENQCMD, X86_FEATURE_XSAVES }, diff --git a/arch/x86/kernel/cpu/scattered.c b/arch/x86/kernel/cpu/scattere= d.c index 16f3ca30626a..3b72b72270f1 100644 --- a/arch/x86/kernel/cpu/scattered.c +++ b/arch/x86/kernel/cpu/scattered.c @@ -49,6 +49,7 @@ static const struct cpuid_bit cpuid_bits[] =3D { { X86_FEATURE_MBA, CPUID_EBX, 6, 0x80000008, 0 }, { X86_FEATURE_SMBA, CPUID_EBX, 2, 0x80000020, 0 }, { X86_FEATURE_BMEC, CPUID_EBX, 3, 0x80000020, 0 }, + { X86_FEATURE_ABMC, CPUID_EBX, 5, 0x80000020, 0 }, { X86_FEATURE_AMD_WORKLOAD_CLASS, CPUID_EAX, 22, 0x80000021, 0 }, { X86_FEATURE_PERFMON_V2, CPUID_EAX, 0, 0x80000022, 0 }, { X86_FEATURE_AMD_LBR_V2, CPUID_EAX, 1, 0x80000022, 0 }, --=20 2.34.1 From nobody Sun Dec 14 02:00:56 2025 Received: from NAM12-MW2-obe.outbound.protection.outlook.com (mail-mw2nam12on2052.outbound.protection.outlook.com [40.107.244.52]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 16AC428CF5B; Thu, 15 May 2025 22:52:44 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.244.52 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1747349566; cv=fail; b=Rx4Ehb0oK6pqKZ4LD27xdfoVm7bKJGKihB9S0IshlK9FiMNj3aHqK9o4PfO0b1j/fbeXpnSVVZi04ka/SCnQbRVZlNzLsLoHEqBUREqu4qTZfCwCV0pGhzqJl81ZohJEJ37gTAlWgsTEWIeHXZUO5elptJwTT7v564yEzt7d3B0= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1747349566; c=relaxed/simple; bh=0/iDnoAeqpM+vJ9H5LPo6A1avDG8P61CkYy/phjGLOU=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=EAYVysgcz8M5vVglWuou/S5454bM9IsLczf9JjK8NbvmmDuNthvc21xMA9hT4p8i3rIpZv67PM5ln3u9qcrbEi8OwTSzS7mT247z8D0pJDwjElL13ZjJ83M+B/n8RuFqQC9wCgsBOUReGHtBTzPimo5hkH0OxQOcSIUHC59ZSVE= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=amd.com; spf=fail smtp.mailfrom=amd.com; dkim=pass (1024-bit key) header.d=amd.com header.i=@amd.com header.b=V8MyZMfn; arc=fail smtp.client-ip=40.107.244.52 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=amd.com Authentication-Results: smtp.subspace.kernel.org; spf=fail smtp.mailfrom=amd.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=amd.com header.i=@amd.com header.b="V8MyZMfn" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=wtlj3/Gw9CwgTgI/hnlYvpNtoR3ZGgixeGF/RtE1hEvO5XO53KdV0hgG89XIEOU15wvvowwMNb4wB0RDJ/StvJ19vqxrvV63Rb61ElCBpFTIMevEXPjuhU2vEQ23XcGCdaqOWF8Qyrv4yvBaTmLkcoRmPv20RkJ0ILgEm8Qu+vM20W9R4eoyhuHY4xkFn6q7ctbn5gNwozQ2l/wMfHWYuK01a4FdLUyqYG/9jhgDQ9UxJE9+/ArgkiKzgLzCTHq+f+6VQ1fjUWRHj3os5Y/q0koEqzWVA/vLalx7gPwU/zja/u9aldd4ffAHcKuip3qxlkwndHI1qgEDCr8yOOWF1A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=1cyQCtr8wFokSYAvV/dk7NVVNUo65eWk53+zUQGPfMM=; b=qVhyrSY1Ek+ZIj/hWTgkvTmaAi8rAJZxvPxg41FB40udZWwStwLz21udUmW2nBlVef/K/LakJFCFyWgSnoLU3V/Ly+k9KU9XYeuvgonguRN6EizoEEhEWjtsC3VPBsONO08TZ2P3cxDzoog7r7l1jYaBCx0DOTerdHajnoIC6IW+JBR90ZYmXBqAQ7QbIhGyA9eftK3X44DLVv2V/E6Pzx8g4HgUajnmTa0tW2W7rZtjcZaI8ok6j0WJPY7KwHRW1yUpM8yBw2e17Fq/1wp2jY5/BYP7zsf2MX9qaGs4F0HmhWfichLEmQ3TkHq1uNzMD5LU6PdhzfI8dyX8573LnQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=lwn.net smtp.mailfrom=amd.com; dmarc=pass (p=quarantine sp=quarantine pct=100) action=none header.from=amd.com; dkim=none (message not signed); arc=none (0) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amd.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=1cyQCtr8wFokSYAvV/dk7NVVNUo65eWk53+zUQGPfMM=; b=V8MyZMfnQiVq1fwTOKS6p6lFRMys1N1z4ItJdWUMzr+j5HdHy3xCFapc8acDHSGQflW3Ghdhm1eRnnUIpmQF2KafMXGyc86Lv8EOefd2MczAqMWBvvUeO6gTCKskTDuAOun8iS3qDjG6cGiLE9u1OQ8QnmmJd9g3ha7neeNrLPM= Received: from BN9PR03CA0358.namprd03.prod.outlook.com (2603:10b6:408:f6::33) by PH7PR12MB8154.namprd12.prod.outlook.com (2603:10b6:510:2b9::14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8722.33; Thu, 15 May 2025 22:52:41 +0000 Received: from BN1PEPF00004686.namprd03.prod.outlook.com (2603:10b6:408:f6:cafe::ed) by BN9PR03CA0358.outlook.office365.com (2603:10b6:408:f6::33) with Microsoft SMTP Server (version=TLS1_3, cipher=TLS_AES_256_GCM_SHA384) id 15.20.8699.29 via Frontend Transport; Thu, 15 May 2025 22:52:40 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 165.204.84.17) smtp.mailfrom=amd.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=amd.com; Received-SPF: Pass (protection.outlook.com: domain of amd.com designates 165.204.84.17 as permitted sender) receiver=protection.outlook.com; client-ip=165.204.84.17; helo=SATLEXMB04.amd.com; pr=C Received: from SATLEXMB04.amd.com (165.204.84.17) by BN1PEPF00004686.mail.protection.outlook.com (10.167.243.91) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.8722.18 via Frontend Transport; Thu, 15 May 2025 22:52:40 +0000 Received: from bmoger-ubuntu.amd.com (10.180.168.240) by SATLEXMB04.amd.com (10.181.40.145) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.39; Thu, 15 May 2025 17:52:37 -0500 From: Babu Moger To: , , , , , , CC: , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , Subject: [PATCH v13 02/27] x86/resctrl: Add ABMC feature in the command line options Date: Thu, 15 May 2025 17:51:47 -0500 Message-ID: X-Mailer: git-send-email 2.34.1 In-Reply-To: References: Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-ClientProxiedBy: SATLEXMB04.amd.com (10.181.40.145) To SATLEXMB04.amd.com (10.181.40.145) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: BN1PEPF00004686:EE_|PH7PR12MB8154:EE_ X-MS-Office365-Filtering-Correlation-Id: 8937266b-fff9-476d-40fa-08dd94033273 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|1800799024|7416014|82310400026|376014|36860700013; X-Microsoft-Antispam-Message-Info: =?us-ascii?Q?GXXwuns4yVkZINtHeikLBORvFX3yEYpU5UYA/NOugon0N9eyaAIfC+MPnCuB?= =?us-ascii?Q?RbmCJUTWiJZV+1HiJ17D6HsAvIZFEWznjOk0viRuwx13sRxf5ZARtIvx4FNy?= =?us-ascii?Q?tFqOYDSEIetXXfnp0CgeHPGZtMYBkFTtd5YT2Wt+ehtvChFPbKRzH1SeElvP?= =?us-ascii?Q?lpejjamnOy3UaSNaQiNoiJt8j6892y6t5kd58zeYg9oGnIHZWIXKHChWoe3B?= =?us-ascii?Q?hdGrOQ4usOOq7UqC4hZCfGwaH8VdVSyaYL/J9fWaksH0Cz9zsMW3Ncozaryq?= =?us-ascii?Q?RO961xVzB0nLf0FBknQKaJ04QAedHRoqD8uURQYnnsEzbWzbJq9emiYS0dfl?= =?us-ascii?Q?HfUGKD/Cxchq9b0AU5CJ+FhVPsQAovIIziSQqs883BV9Rtev/igQ/xLSS8d9?= =?us-ascii?Q?DnPeiQ8Gt7E9rGXafhANkDVDZnted1qwnjpKfKdKraBAtJ8N8hK8V/wvS4AK?= =?us-ascii?Q?zqGXp+8MzJ0oEGpoTIJgZriS1GBQDv/R5MwcXxuTE/ZgbtPMv7B4SGW8Mmn+?= =?us-ascii?Q?jIsSJYcFUuoPiSTOLFaaH++syAfxGXw0WgBLpUKwGE61mGh/127YQitN3LYY?= =?us-ascii?Q?QPw8Ijs6VtQWZVFLAedrV2E4kq2Y68lxJkgX1OfSVosF01vszvwg/IliKF/N?= =?us-ascii?Q?XGUCknAjWhxR0/Np7V93gyEj54vlvkBbf1/TSDC/gq5qOiG1s3rWoi8zpWIO?= =?us-ascii?Q?zS80mRKFlTR9b1oHxq2oiBO6F0t8UOT5OTxo6z5eIIEXJnOyGnKKk1DkZ3pz?= =?us-ascii?Q?ZFHecfn3dfpxNat9YOB8zXAQJ+7nxLxRQvTkDtav8kWCxArY1+LpgnuB5RF9?= =?us-ascii?Q?PX4ZbGCOERmI3KJnJAmd5jX+m3OHWvh3O57IPImTmYhjyMBxYMLtqbImG7Md?= =?us-ascii?Q?kVpgiwXIvRZ90Gt7ElNGXlpcxwcQrJiKrVvE8/WrB+nte4MgccqNNA3So0q/?= =?us-ascii?Q?zhpz4LhEo1b9PIf5VMex24rzch0xk44eGTqOT2eZ9TibgNfhIi2BKt/2RDXm?= =?us-ascii?Q?LNQ07QHW3cDYQwQg4Fl67hl/kBUUr7niwCoFNdAUKSPDHAjq2mRxHz4Ee4G9?= =?us-ascii?Q?V0oc2RZd9wPuXoHKvA9LMVfjsDT19TlMoZwIpWuhfrPdCqTaAUeUA0lhu1lO?= =?us-ascii?Q?gLOUVXdE5/+xQqUc2VlnsPtIHJUIrNyUTDmtusm22z1IEs0YqvVgg9j5WtbS?= =?us-ascii?Q?cfDW10ZoBccPtk9R8u/5Mp0hveN16HtCbHrxsSSNRHV2knmTnMoHVIkpV4nH?= =?us-ascii?Q?caIozI/XkXjJ5Y1Zeu1rja6nDeXko6c5CuN77GQ3Y1oloGkYVAV70QwxztUZ?= =?us-ascii?Q?oZu6LaTQzW4ktkZ3YSxW2aCWcSNTXl7TW6DxNU6hEejUDgoqVXRc5PCNHvuX?= =?us-ascii?Q?H0sJGsfWsIErT/qXlEsdgg0GWklb6hr1jMpa4Q27xMaZ777OENc2xftAhF6X?= =?us-ascii?Q?/c66SWJpqKY3Q1bjZJiKJt/ynqC37wdWt5ka5nfPKSm6MZHMjI/op9AUPQ0J?= =?us-ascii?Q?u6NOepYbkScWazSB1CHDG6Kg0ysgfyTcoVy2?= X-Forefront-Antispam-Report: CIP:165.204.84.17;CTRY:US;LANG:en;SCL:1;SRV:;IPV:CAL;SFV:NSPM;H:SATLEXMB04.amd.com;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(13230040)(1800799024)(7416014)(82310400026)(376014)(36860700013);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 15 May 2025 22:52:40.8285 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 8937266b-fff9-476d-40fa-08dd94033273 X-MS-Exchange-CrossTenant-Id: 3dd8961f-e488-4e60-8e11-a82d994e183d X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=3dd8961f-e488-4e60-8e11-a82d994e183d;Ip=[165.204.84.17];Helo=[SATLEXMB04.amd.com] X-MS-Exchange-CrossTenant-AuthSource: BN1PEPF00004686.namprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH7PR12MB8154 Content-Type: text/plain; charset="utf-8" Add the command line option to enable or disable exposing the ABMC (Assignable Bandwidth Monitoring Counters) hardware feature to resctrl. Signed-off-by: Babu Moger --- v13: Removed the Reviewed-by as the file resctrl.rst is moved to Documentation/filesystems/resctrl.rst. In that sense patch has changed. v12: No changes. v11: No changes. v10: No changes. v9: No code changes. Added Reviewed-by. v8: Commit message update. v7: No changes v6: No changes v5: No changes v4: No changes v3: No changes v2: No changes --- Documentation/admin-guide/kernel-parameters.txt | 2 +- Documentation/filesystems/resctrl.rst | 1 + arch/x86/kernel/cpu/resctrl/core.c | 2 ++ 3 files changed, 4 insertions(+), 1 deletion(-) diff --git a/Documentation/admin-guide/kernel-parameters.txt b/Documentatio= n/admin-guide/kernel-parameters.txt index d9fd26b95b34..ed9761bb2e4a 100644 --- a/Documentation/admin-guide/kernel-parameters.txt +++ b/Documentation/admin-guide/kernel-parameters.txt @@ -5988,7 +5988,7 @@ rdt=3D [HW,X86,RDT] Turn on/off individual RDT features. List is: cmt, mbmtotal, mbmlocal, l3cat, l3cdp, l2cat, l2cdp, - mba, smba, bmec. + mba, smba, bmec, abmc. E.g. to turn on cmt and turn off mba use: rdt=3Dcmt,!mba =20 diff --git a/Documentation/filesystems/resctrl.rst b/Documentation/filesyst= ems/resctrl.rst index c7949dd44f2f..c97fd77a107d 100644 --- a/Documentation/filesystems/resctrl.rst +++ b/Documentation/filesystems/resctrl.rst @@ -26,6 +26,7 @@ MBM (Memory Bandwidth Monitoring) "cqm_mbm_total", "cqm_= mbm_local" MBA (Memory Bandwidth Allocation) "mba" SMBA (Slow Memory Bandwidth Allocation) "" BMEC (Bandwidth Monitoring Event Configuration) "" +ABMC (Assignable Bandwidth Monitoring Counters) "" =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D =3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D =20 Historically, new features were made visible by default in /proc/cpuinfo. = This diff --git a/arch/x86/kernel/cpu/resctrl/core.c b/arch/x86/kernel/cpu/resct= rl/core.c index 224bed28f341..15a1dfa92923 100644 --- a/arch/x86/kernel/cpu/resctrl/core.c +++ b/arch/x86/kernel/cpu/resctrl/core.c @@ -704,6 +704,7 @@ enum { RDT_FLAG_MBA, RDT_FLAG_SMBA, RDT_FLAG_BMEC, + RDT_FLAG_ABMC, }; =20 #define RDT_OPT(idx, n, f) \ @@ -729,6 +730,7 @@ static struct rdt_options rdt_options[] __ro_after_ini= t =3D { RDT_OPT(RDT_FLAG_MBA, "mba", X86_FEATURE_MBA), RDT_OPT(RDT_FLAG_SMBA, "smba", X86_FEATURE_SMBA), RDT_OPT(RDT_FLAG_BMEC, "bmec", X86_FEATURE_BMEC), + RDT_OPT(RDT_FLAG_ABMC, "abmc", X86_FEATURE_ABMC), }; #define NUM_RDT_OPTIONS ARRAY_SIZE(rdt_options) =20 --=20 2.34.1 From nobody Sun Dec 14 02:00:56 2025 Received: from NAM04-BN8-obe.outbound.protection.outlook.com (mail-bn8nam04on2063.outbound.protection.outlook.com [40.107.100.63]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id F1C8728E572; Thu, 15 May 2025 22:52:55 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.100.63 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1747349577; cv=fail; b=CWhPJ06W322R9rpus0e8W2d2OU1NszJ6XKZ07iY5bjsNNQfeCy4eu+Wj/8Fvvzx6LUCISTgujhSmD1oharpg+plQdUMsiRrcsWB3u+4wUluz24G9qN0valiMJ7W7K/yNcW1bhijnKQ3m5+W6hlQWVZA1H2bcLcbNjHoKIOxgh3k= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1747349577; c=relaxed/simple; bh=gHF0Im8W8X8FVD+zrt4MperDctIIW34ctUc4l/OxMqo=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=mo81f03PjFNey9JTLkCKg6TsXlO4dChrNvpDdRLIh/nhXpXh3PIkatquOO/pQcgezn+v83uhwq6hZ6nNq+3HXeJM/wo+r3Xd86KFUG6jyjJRyB3uk4sXC/ngmVC3vnhsfy2enBreBC5N8vR9NFaGMNMiJY2gbWj4Dsg51t/XYXU= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=amd.com; spf=fail smtp.mailfrom=amd.com; dkim=pass (1024-bit key) header.d=amd.com header.i=@amd.com header.b=r3oQWbvy; arc=fail smtp.client-ip=40.107.100.63 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=amd.com Authentication-Results: smtp.subspace.kernel.org; spf=fail smtp.mailfrom=amd.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=amd.com header.i=@amd.com header.b="r3oQWbvy" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=vJVXbGJJxJLS3aSdIu+AJcUp6tt/Yfw/dThGPgy4YttXEmdpxO8P6WUGMxVC7mIh6J2wJbiLrPJyIbvozsFGDpXw+QNBMglqzSFmKvxtHl+LC5Vx+L0mPK40U5GwmtIJHgiAa1h1BuGGieY5YXIoIQv/lNBaeWhnbf15kao81egne735DrdwvfCt9JR6S4WK3FI2ApTzoKSot8A1XPI+DIS9iYdEJ0kXEeuCzyWUQIGSp3U5eBOX6u0LpNQRCAS1OIFoOdiNP6gOVCLySrbP4r7A7HCzjVi/kmcONxw7N82RhEdyqYvantkxum8k1/5iIZOXZz4TWUa4d8+ltBz7UA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=SBrMXdYLyUpyFC47x8ImWYyRw7PNtAd5L2PoyYtCWRw=; b=NjuQGfUrUrDB/dozB30opSZVFY7UtpndTnR6Pb7UrHALzXRIeVa3LYRmEsdXUayshKSeHDmzj27A6R/EBEGMFaqUDdiOJ9CCth28TTARFQgPf5O+QTj5vOjLQSturapa6r4gco7iiFpmfC0b+6BoyTywkcb29XmEs0BfpICosNOrJat4I864EE+UxsvKPVvAKaXye88HSD3bsRgRMe89j6wbXEEP0sO1qTNQ+dYue1KZgXiv+xYWkKzFEoWbJK8B4Nj3Wl60GMQ3w8XGny6uv8TGxgXgFVw0p8pjSH8D04ztE7qkQ9R6pUFHK8Cgm0b9AQ9IQ1hMvyYlyiCzSnwbkA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=lwn.net smtp.mailfrom=amd.com; dmarc=pass (p=quarantine sp=quarantine pct=100) action=none header.from=amd.com; dkim=none (message not signed); arc=none (0) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amd.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=SBrMXdYLyUpyFC47x8ImWYyRw7PNtAd5L2PoyYtCWRw=; b=r3oQWbvy5pGOF7Cs36nCDtWwPmuuUtF0lxB4o7ZbIFKgg48eweHZZe0NzjStxe6N+jMKh2idtCcX0yVYiIKn+KrC7dWA/JPyS6dQZMmDLjGWGK4l5iXBaAHovxRPN7uHC1xOs4b4cqO2Tx3fWtUacegYXmPKuaaKLO+nSx0AOyE= Received: from BN9PR03CA0350.namprd03.prod.outlook.com (2603:10b6:408:f6::25) by IA1PR12MB7544.namprd12.prod.outlook.com (2603:10b6:208:42c::7) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8722.28; Thu, 15 May 2025 22:52:50 +0000 Received: from BN1PEPF00004686.namprd03.prod.outlook.com (2603:10b6:408:f6:cafe::f0) by BN9PR03CA0350.outlook.office365.com (2603:10b6:408:f6::25) with Microsoft SMTP Server (version=TLS1_3, cipher=TLS_AES_256_GCM_SHA384) id 15.20.8699.40 via Frontend Transport; Thu, 15 May 2025 22:52:50 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 165.204.84.17) smtp.mailfrom=amd.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=amd.com; Received-SPF: Pass (protection.outlook.com: domain of amd.com designates 165.204.84.17 as permitted sender) receiver=protection.outlook.com; client-ip=165.204.84.17; helo=SATLEXMB04.amd.com; pr=C Received: from SATLEXMB04.amd.com (165.204.84.17) by BN1PEPF00004686.mail.protection.outlook.com (10.167.243.91) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.8722.18 via Frontend Transport; Thu, 15 May 2025 22:52:50 +0000 Received: from bmoger-ubuntu.amd.com (10.180.168.240) by SATLEXMB04.amd.com (10.181.40.145) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.39; Thu, 15 May 2025 17:52:47 -0500 From: Babu Moger To: , , , , , , CC: , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , Subject: [PATCH v13 03/27] x86/resctrl: Consolidate monitoring related data from rdt_resource Date: Thu, 15 May 2025 17:51:48 -0500 Message-ID: X-Mailer: git-send-email 2.34.1 In-Reply-To: References: Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-ClientProxiedBy: SATLEXMB04.amd.com (10.181.40.145) To SATLEXMB04.amd.com (10.181.40.145) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: BN1PEPF00004686:EE_|IA1PR12MB7544:EE_ X-MS-Office365-Filtering-Correlation-Id: 83a703a0-efa5-4958-3f90-08dd94033827 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|36860700013|1800799024|82310400026|7416014|376014; X-Microsoft-Antispam-Message-Info: =?us-ascii?Q?WurnsAgqXitgfDWKe8cyLnDx0cGACuXn9EXkQHi2D6kMjnGDuE9voHL0jpvf?= =?us-ascii?Q?Dt3tQztbKVnzJEwoQ3lH/JHCRJ+LQjuoNITc8DMl9LS/3/+CITNaEno8A/6Q?= =?us-ascii?Q?7qWdTFjzDsfbqYAlPJZyTSh/UVorYUcEcVM0yGNm6wZ3PvPn08A3SJMg/tmv?= =?us-ascii?Q?6bhsS0tAtL5VXWlZY6zQGX8/Cki9ZoFbQyz0IfqfWAfjmAFqIVmCN/jYD0O7?= =?us-ascii?Q?R8iWBuP4DDlAX8vwgPS/LcVA8DVTFD/2wTxKNl2NmZ1t5nnV+zO0wutb6hMq?= =?us-ascii?Q?4XrQVmFd9fqc2hadsbHQM/bW48lB14xVWtypfFzgf64leO0pEP2lt1cNmPYt?= =?us-ascii?Q?dGxzBsqcLSff0xAsbjOgZa05bDIKxIVEiPwYjd6J7+fyItuwM4GYMchlG2xv?= =?us-ascii?Q?Ww6pc2D8Sci8HHd7YgG+UAZ1AF17zRivfxfGkN8JUGp+SHPON4r9DGeAxYow?= =?us-ascii?Q?qb03o2IRZz50UEPjW3YHKR69lSYhcMBZ5dt2xEuYtPhu3s/k+P1TTg40iCcy?= =?us-ascii?Q?xTScvjMKKvG4L50s/lCqFLaHFKMVKKuSmnyIdj7fTL8N4x0I0PiRkvuJWZ4m?= =?us-ascii?Q?YbiyspyO7RWLnl+/dLcaOiP3KGWw9naZXNEI+vZYVKrw7xjZjz5Pt6odkGVn?= =?us-ascii?Q?EjZzkvJNB5kz7iDidvlE5cDfuTOzbvSit4L9emgW22Blub7ORiS+P84VZHPj?= =?us-ascii?Q?jFMIPK6SqV1ObV9b9CEkWHr2zpML9PQI0RpAmBGrX3PYQs48yFvB2gIMgQHN?= =?us-ascii?Q?1zDwIcasKXPKydMMK5egM0+JAG+8Q5PWduVh+DyuefL/Ow3TrcwX0egeGrsk?= =?us-ascii?Q?LVumKHrGShgo8EY6g9xCCcpIb1H9pAqv7TOzYqelIwB31EAyky+1qaeJq9vK?= =?us-ascii?Q?bXZHlwJ55wHA5JUKTByqVHaoIJdHg3Gcjc1A+8NVtH069QdZBLQjcUFsklfa?= =?us-ascii?Q?mR4/qEOuaKic+l8J/7K/ABGAh9AaCY85klkAJ4ygE2uLmaz/885qghMtQ7Eq?= =?us-ascii?Q?Kfx7HOHqkBg3k0TEZOB3o5karikmCyclWMk9NOxaFmZFpbYt2EQCTkIw8Vxn?= =?us-ascii?Q?Dfsv8+eoethuN22KPeLQh9j6+ZqDvIKCWSUrQiU2E0g4IpStj9nI+T3Z2eHe?= =?us-ascii?Q?EjIWzvt6RnRcOhScMCX1ZXWSitBcGndBM4hcTsqOPbWzrm8W9C69SMmUx0MY?= =?us-ascii?Q?4n5sJ5ncJCNV6zvYhFSGRlgu3P9HcS6pLUkC8NXn3SsJIYjxnPlKFSYLBNRj?= =?us-ascii?Q?b7yIy+n4SvrE0i71ispAzKu+EkFZpeVFPizMi6siXPfq/MUHaQjdcXo/ii6N?= =?us-ascii?Q?WZBd1XTLEKMZlrprIIxZ7NHCAe4/AZE0+Lco0svtnF/dANLTUeAyb/vOKLJy?= =?us-ascii?Q?fR3NI2L+Vh0QBP4tLI8iwqmksdoNCURVtLZ9sS6mOq9euXsogHbGbmH0Gkcm?= =?us-ascii?Q?tVSlsW7xFFS9mu+x1Y5L3rlbhNqrZ4iUVcqrQ0Ob8/xtZgDda+qZwow82+YI?= =?us-ascii?Q?loGvzhCbelhS7p80y59bnXQqQ1RClK5j5glC?= X-Forefront-Antispam-Report: CIP:165.204.84.17;CTRY:US;LANG:en;SCL:1;SRV:;IPV:CAL;SFV:NSPM;H:SATLEXMB04.amd.com;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(13230040)(36860700013)(1800799024)(82310400026)(7416014)(376014);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 15 May 2025 22:52:50.3960 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 83a703a0-efa5-4958-3f90-08dd94033827 X-MS-Exchange-CrossTenant-Id: 3dd8961f-e488-4e60-8e11-a82d994e183d X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=3dd8961f-e488-4e60-8e11-a82d994e183d;Ip=[165.204.84.17];Helo=[SATLEXMB04.amd.com] X-MS-Exchange-CrossTenant-AuthSource: BN1PEPF00004686.namprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: IA1PR12MB7544 Content-Type: text/plain; charset="utf-8" The cache allocation and memory bandwidth allocation feature properties are consolidated into struct resctrl_cache and struct resctrl_membw respectively. In preparation for more monitoring properties that will clobber the existing resource struct more, re-organize the monitoring specific properties to also be in a separate structure. Suggested-by: Reinette Chatre Signed-off-by: Babu Moger --- v13: Changes due to FS/ARCH restructure. v12: Fixed the conflicts due to recent changes in rdt_resource data structu= re. Added new mbm_cfg_mask field to resctrl_mon. Removed Reviewed-by tag as patch has changed. v11: No changes. v10: No changes. v9: No changes. v8: Added Reviewed-by from Reinette. No other changes. v7: Added kernel doc for data structure. Minor text update. v6: Update commit message and update kernel doc for rdt_resource. v5: Commit message update. Also changes related to data structure updates does to SNC support. v4: New patch. --- arch/x86/kernel/cpu/resctrl/core.c | 4 ++-- arch/x86/kernel/cpu/resctrl/monitor.c | 12 ++++++------ fs/resctrl/monitor.c | 8 ++++---- fs/resctrl/rdtgroup.c | 12 ++++++------ include/linux/resctrl.h | 22 +++++++++++++++------- 5 files changed, 33 insertions(+), 25 deletions(-) diff --git a/arch/x86/kernel/cpu/resctrl/core.c b/arch/x86/kernel/cpu/resct= rl/core.c index 15a1dfa92923..6859566398d6 100644 --- a/arch/x86/kernel/cpu/resctrl/core.c +++ b/arch/x86/kernel/cpu/resctrl/core.c @@ -106,7 +106,7 @@ u32 resctrl_arch_system_num_rmid_idx(void) struct rdt_resource *r =3D &rdt_resources_all[RDT_RESOURCE_L3].r_resctrl; =20 /* RMID are independent numbers for x86. num_rmid_idx =3D=3D num_rmid */ - return r->num_rmid; + return r->mon.num_rmid; } =20 struct rdt_resource *resctrl_arch_get_resource(enum resctrl_res_level l) @@ -534,7 +534,7 @@ static void domain_add_cpu_mon(int cpu, struct rdt_reso= urce *r) =20 arch_mon_domain_online(r, d); =20 - if (arch_domain_mbm_alloc(r->num_rmid, hw_dom)) { + if (arch_domain_mbm_alloc(r->mon.num_rmid, hw_dom)) { mon_domain_free(hw_dom); return; } diff --git a/arch/x86/kernel/cpu/resctrl/monitor.c b/arch/x86/kernel/cpu/re= sctrl/monitor.c index 3fc4d9f56f0d..aeb2a9283069 100644 --- a/arch/x86/kernel/cpu/resctrl/monitor.c +++ b/arch/x86/kernel/cpu/resctrl/monitor.c @@ -134,7 +134,7 @@ static int logical_rmid_to_physical_rmid(int cpu, int l= rmid) if (snc_nodes_per_l3_cache =3D=3D 1) return lrmid; =20 - return lrmid + (cpu_to_node(cpu) % snc_nodes_per_l3_cache) * r->num_rmid; + return lrmid + (cpu_to_node(cpu) % snc_nodes_per_l3_cache) * r->mon.num_r= mid; } =20 static int __rmid_read_phys(u32 prmid, enum resctrl_event_id eventid, u64 = *val) @@ -208,11 +208,11 @@ void resctrl_arch_reset_rmid_all(struct rdt_resource = *r, struct rdt_mon_domain * =20 if (resctrl_arch_is_mbm_total_enabled()) memset(hw_dom->arch_mbm_total, 0, - sizeof(*hw_dom->arch_mbm_total) * r->num_rmid); + sizeof(*hw_dom->arch_mbm_total) * r->mon.num_rmid); =20 if (resctrl_arch_is_mbm_local_enabled()) memset(hw_dom->arch_mbm_local, 0, - sizeof(*hw_dom->arch_mbm_local) * r->num_rmid); + sizeof(*hw_dom->arch_mbm_local) * r->mon.num_rmid); } =20 static u64 mbm_overflow_count(u64 prev_msr, u64 cur_msr, unsigned int widt= h) @@ -350,7 +350,7 @@ int __init rdt_get_mon_l3_config(struct rdt_resource *r) =20 resctrl_rmid_realloc_limit =3D boot_cpu_data.x86_cache_size * 1024; hw_res->mon_scale =3D boot_cpu_data.x86_cache_occ_scale / snc_nodes_per_l= 3_cache; - r->num_rmid =3D (boot_cpu_data.x86_cache_max_rmid + 1) / snc_nodes_per_l3= _cache; + r->mon.num_rmid =3D (boot_cpu_data.x86_cache_max_rmid + 1) / snc_nodes_pe= r_l3_cache; hw_res->mbm_width =3D MBM_CNTR_WIDTH_BASE; =20 if (mbm_offset > 0 && mbm_offset <=3D MBM_CNTR_WIDTH_OFFSET_MAX) @@ -365,7 +365,7 @@ int __init rdt_get_mon_l3_config(struct rdt_resource *r) * * For a 35MB LLC and 56 RMIDs, this is ~1.8% of the LLC. */ - threshold =3D resctrl_rmid_realloc_limit / r->num_rmid; + threshold =3D resctrl_rmid_realloc_limit / r->mon.num_rmid; =20 /* * Because num_rmid may not be a power of two, round the value @@ -379,7 +379,7 @@ int __init rdt_get_mon_l3_config(struct rdt_resource *r) =20 /* Detect list of bandwidth sources that can be tracked */ cpuid_count(0x80000020, 3, &eax, &ebx, &ecx, &edx); - r->mbm_cfg_mask =3D ecx & MAX_EVT_CONFIG_BITS; + r->mon.mbm_cfg_mask =3D ecx & MAX_EVT_CONFIG_BITS; } =20 r->mon_capable =3D true; diff --git a/fs/resctrl/monitor.c b/fs/resctrl/monitor.c index bde2801289d3..6ffa9d14a8b4 100644 --- a/fs/resctrl/monitor.c +++ b/fs/resctrl/monitor.c @@ -866,14 +866,14 @@ static struct mon_evt mbm_local_event =3D { */ static void l3_mon_evt_init(struct rdt_resource *r) { - INIT_LIST_HEAD(&r->evt_list); + INIT_LIST_HEAD(&r->mon.evt_list); =20 if (resctrl_arch_is_llc_occupancy_enabled()) - list_add_tail(&llc_occupancy_event.list, &r->evt_list); + list_add_tail(&llc_occupancy_event.list, &r->mon.evt_list); if (resctrl_arch_is_mbm_total_enabled()) - list_add_tail(&mbm_total_event.list, &r->evt_list); + list_add_tail(&mbm_total_event.list, &r->mon.evt_list); if (resctrl_arch_is_mbm_local_enabled()) - list_add_tail(&mbm_local_event.list, &r->evt_list); + list_add_tail(&mbm_local_event.list, &r->mon.evt_list); } =20 /** diff --git a/fs/resctrl/rdtgroup.c b/fs/resctrl/rdtgroup.c index ec28228f6a8d..9412c7b64523 100644 --- a/fs/resctrl/rdtgroup.c +++ b/fs/resctrl/rdtgroup.c @@ -1139,7 +1139,7 @@ static int rdt_num_rmids_show(struct kernfs_open_file= *of, { struct rdt_resource *r =3D rdt_kn_parent_priv(of->kn); =20 - seq_printf(seq, "%d\n", r->num_rmid); + seq_printf(seq, "%d\n", r->mon.num_rmid); =20 return 0; } @@ -1150,7 +1150,7 @@ static int rdt_mon_features_show(struct kernfs_open_f= ile *of, struct rdt_resource *r =3D rdt_kn_parent_priv(of->kn); struct mon_evt *mevt; =20 - list_for_each_entry(mevt, &r->evt_list, list) { + list_for_each_entry(mevt, &r->mon.evt_list, list) { seq_printf(seq, "%s\n", mevt->name); if (mevt->configurable) seq_printf(seq, "%s_config\n", mevt->name); @@ -1733,9 +1733,9 @@ static int mon_config_write(struct rdt_resource *r, c= har *tok, u32 evtid) } =20 /* Value from user cannot be more than the supported set of events */ - if ((val & r->mbm_cfg_mask) !=3D val) { + if ((val & r->mon.mbm_cfg_mask) !=3D val) { rdt_last_cmd_printf("Invalid event configuration: max valid mask is 0x%0= 2x\n", - r->mbm_cfg_mask); + r->mon.mbm_cfg_mask); return -EINVAL; } =20 @@ -3055,10 +3055,10 @@ static int mon_add_all_files(struct kernfs_node *kn= , struct rdt_mon_domain *d, struct mon_evt *mevt; int ret, domid; =20 - if (WARN_ON(list_empty(&r->evt_list))) + if (WARN_ON(list_empty(&r->mon.evt_list))) return -EPERM; =20 - list_for_each_entry(mevt, &r->evt_list, list) { + list_for_each_entry(mevt, &r->mon.evt_list, list) { domid =3D do_sum ? d->ci->id : d->hdr.id; priv =3D mon_get_kn_priv(r->rid, domid, mevt, do_sum); if (WARN_ON_ONCE(!priv)) diff --git a/include/linux/resctrl.h b/include/linux/resctrl.h index 9ba771f2ddea..2a8fa454d3e6 100644 --- a/include/linux/resctrl.h +++ b/include/linux/resctrl.h @@ -255,40 +255,48 @@ enum resctrl_schema_fmt { RESCTRL_SCHEMA_RANGE, }; =20 +/** + * struct resctrl_mon - Monitoring related data of a resctrl resource + * @num_rmid: Number of RMIDs available + * @mbm_cfg_mask: Bandwidth sources that can be tracked when bandwidth + * monitoring events can be configured. + * @evt_list: List of monitoring events + */ +struct resctrl_mon { + int num_rmid; + unsigned int mbm_cfg_mask; + struct list_head evt_list; +}; + /** * struct rdt_resource - attributes of a resctrl resource * @rid: The index of the resource * @alloc_capable: Is allocation available on this machine * @mon_capable: Is monitor feature available on this machine - * @num_rmid: Number of RMIDs available * @ctrl_scope: Scope of this resource for control functions * @mon_scope: Scope of this resource for monitor functions * @cache: Cache allocation related data * @membw: If the component has bandwidth controls, their properties. + * @mon: Monitoring related data. * @ctrl_domains: RCU list of all control domains for this resource * @mon_domains: RCU list of all monitor domains for this resource * @name: Name to use in "schemata" file. * @schema_fmt: Which format string and parser is used for this schema. - * @evt_list: List of monitoring events - * @mbm_cfg_mask: Bandwidth sources that can be tracked when bandwidth - * monitoring events can be configured. * @cdp_capable: Is the CDP feature available on this resource */ struct rdt_resource { int rid; bool alloc_capable; bool mon_capable; - int num_rmid; enum resctrl_scope ctrl_scope; enum resctrl_scope mon_scope; struct resctrl_cache cache; struct resctrl_membw membw; + struct resctrl_mon mon; struct list_head ctrl_domains; struct list_head mon_domains; char *name; enum resctrl_schema_fmt schema_fmt; - struct list_head evt_list; - unsigned int mbm_cfg_mask; bool cdp_capable; }; =20 --=20 2.34.1 From nobody Sun Dec 14 02:00:56 2025 Received: from NAM10-MW2-obe.outbound.protection.outlook.com (mail-mw2nam10on2075.outbound.protection.outlook.com [40.107.94.75]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 7255428E5E3; Thu, 15 May 2025 22:53:05 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.94.75 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1747349587; cv=fail; b=piieC79lCVd5OMsoGNf3uErNyOPK227/sI83XxXsNQDVpjjaFEV9R7YwAfcCxC6DZY0flIj/acZ/2vLPBr7+x2FsULMlIyJI+2HBbJoKssaEiHfCx4pXRs22A55blVllMAqP5oUKWSRdi7YoaC6Y9u0AwZA848jffAtfXGrw9b0= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1747349587; c=relaxed/simple; bh=2RH+SkoZXqohLg/zSDlrqEWMmiVWQ4gamf4smxLYl8Q=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=Sfx2Eos2PB/wa1fuUoTo/TJaP57qej/bh31SjRHQqmZtYpRVTUw7ETuHmOYpRa5adcSRY/UGNr8kzrJ0wkeItVLMgKSXf95dw8nYP6EbpIQ+b+w1ioy9812KmeF5snHB5pcIZIlGmRBevnJJtwwCNYspV/on8V4DaB82cWORXRQ= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=amd.com; spf=fail smtp.mailfrom=amd.com; dkim=pass (1024-bit key) header.d=amd.com header.i=@amd.com header.b=5gWm+m7s; arc=fail smtp.client-ip=40.107.94.75 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=amd.com Authentication-Results: smtp.subspace.kernel.org; spf=fail smtp.mailfrom=amd.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=amd.com header.i=@amd.com header.b="5gWm+m7s" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=wtjLm40RKymZAkljDkZNCIryb4dO76d0+a0RyzbXXYTzm6A+/M9TxIStN5HuI3zKCsXlJkQgBK2bnuA1Ql2OoCZn8Ci4WAu1WrOLpmZjg/v+Ym7NBPoh8pZqWXeYGVCua72zUOwKV2ZXc3dxc7jsc0vmnHeB+0SqxWNk1vySzGfqLYsyJkvKs2g48ue8KYh3gYt/uKlrEiHwfFLcUBK0UYGHn9ptYmdJg7LgbHUdIf9FgSHxc1CRyutmXU5HWDsLZczJcRNFKmPpyg9fAVZEKfYkv0eJV3YP2BdZpMmXtwz3c2qgbqZfg/I2cKy2sZG/wwRRMyR/UbVxgmFD5arHpQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=u+E4W8NtiFTTSqcn4AqDvt5+bB56hyjI1wYqqU2Vij0=; b=aPm7aO6vBsmXUaYRWF7tcCCFjhO6iKsd2qn6jKUfSXT8koPPrvMt3yL8ef75LOr06Vkxsg64HRir7RnNSLR9ACoLGDwDOuudfZXHhEP3CoaTZQOLM+BPOeLrcJTb1xW2bWqY1S0DoVlLolAVltOuVqYh/BhHWMayypJb1JX/qtM2cBweLUYPBOe5/Cnj6MJSWwVIm6PHpv6RbNlQa3jfhu83e8wXlfJzJDh9qJ+bXgtsvMJG+PSR0L+BTNuoBK6+Ln+7hE2AMIEfaxr1wYWg1uyrwXR5HNPW7IKHrZCvMLdEAOcVswjUMztEYHn8XsFQPZ1Z2ow4QyCS2Yz4K+WvsQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=lwn.net smtp.mailfrom=amd.com; dmarc=pass (p=quarantine sp=quarantine pct=100) action=none header.from=amd.com; dkim=none (message not signed); arc=none (0) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amd.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=u+E4W8NtiFTTSqcn4AqDvt5+bB56hyjI1wYqqU2Vij0=; b=5gWm+m7sry2zI1Hw/pMb1nXwV6amgp3qckXyGy87ewbRXhS3tYXkULI23t2SPl5Lq24qauvE20dh4JU9vaUgs9/a1N73oGSljdYZ+jlG2D77I6grgcij5znsVrrU4soBbbpstigu4D89gZqLMyEOnGON6Ll9n3cjYlr4yJhY5kU= Received: from MN0P222CA0009.NAMP222.PROD.OUTLOOK.COM (2603:10b6:208:531::10) by IA1PR12MB6305.namprd12.prod.outlook.com (2603:10b6:208:3e7::16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8722.33; Thu, 15 May 2025 22:53:00 +0000 Received: from BN1PEPF00004684.namprd03.prod.outlook.com (2603:10b6:208:531:cafe::2) by MN0P222CA0009.outlook.office365.com (2603:10b6:208:531::10) with Microsoft SMTP Server (version=TLS1_3, cipher=TLS_AES_256_GCM_SHA384) id 15.20.8746.20 via Frontend Transport; Thu, 15 May 2025 22:53:00 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 165.204.84.17) smtp.mailfrom=amd.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=amd.com; Received-SPF: Pass (protection.outlook.com: domain of amd.com designates 165.204.84.17 as permitted sender) receiver=protection.outlook.com; client-ip=165.204.84.17; helo=SATLEXMB04.amd.com; pr=C Received: from SATLEXMB04.amd.com (165.204.84.17) by BN1PEPF00004684.mail.protection.outlook.com (10.167.243.90) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.8722.18 via Frontend Transport; Thu, 15 May 2025 22:53:00 +0000 Received: from bmoger-ubuntu.amd.com (10.180.168.240) by SATLEXMB04.amd.com (10.181.40.145) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.39; Thu, 15 May 2025 17:52:57 -0500 From: Babu Moger To: , , , , , , CC: , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , Subject: [PATCH v13 04/27] x86/resctrl: Detect Assignable Bandwidth Monitoring feature details Date: Thu, 15 May 2025 17:51:49 -0500 Message-ID: X-Mailer: git-send-email 2.34.1 In-Reply-To: References: Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-ClientProxiedBy: SATLEXMB04.amd.com (10.181.40.145) To SATLEXMB04.amd.com (10.181.40.145) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: BN1PEPF00004684:EE_|IA1PR12MB6305:EE_ X-MS-Office365-Filtering-Correlation-Id: d74bfda9-9734-4866-1010-08dd94033de6 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|36860700013|1800799024|82310400026|376014|7416014|13003099007; X-Microsoft-Antispam-Message-Info: =?us-ascii?Q?DwI43Aiusi2F8vzfT+jS+ke5nT+R91HGcUv9Y0tVZloAZeLwDXrXeIkUYlMJ?= =?us-ascii?Q?k/iES00jTisYsSiU+t0X+nhSroZQXvrbDlYeX5NZBPLfMmzddPHN9p/RA9ln?= =?us-ascii?Q?Arh6IXpzb3pAXVz6m4LHxFvdTbiU4RrfXiUQe5pH3BHNJIW2pi+IPLTvuYdF?= =?us-ascii?Q?+GhONJfyk52n/i/ATtjAywJQMEKHUpLrCOuIRTMYtbhsxcW+R/1KmqXxt8bN?= =?us-ascii?Q?G7x+oLSkH41n7b+C9ef1bFmMpnlGkfuvZkL6rb9U47R46LVU1WG/MbdCubT4?= =?us-ascii?Q?4CJrihkIMLi0MhkFQVmL2nPvcOF8hjJISUX1+0zkLqKD9OiInPuANeX+aQkQ?= =?us-ascii?Q?NQoWddd2pbwdS8x0w42k1qylIDn5TC3nYd1JAngNc2N4Yv4PAgQqkOfmyB+Y?= =?us-ascii?Q?A1sor/tAQG4CbVSA2gbAsKGmIBDIMKzonw/YffVM9cLU0fYUDbcfgkAky7gp?= =?us-ascii?Q?YEDZqd9hyYlJiuGPhcyUjVi1dyd080gPi4BvSy8iX2adUh5imdAmRp2EdCNy?= =?us-ascii?Q?vKG1womdismTLYOinHDLAUnYNzwhOVgZ6qZbNVAVdqkTQMcF3rq3MZ75LttO?= =?us-ascii?Q?X6x0ExglRX0OMHNEIVN6ZZR4V0ZKc83FqUsnlKz1VfJLt1AuSKfqtNbmb/QK?= =?us-ascii?Q?CAITUQah1G9tyARc4cxbqh2inuE7JqunRmA0PNlyuL9jeKKjRZUxpz56pUtA?= =?us-ascii?Q?1EIEYDeVbdhAHzNB2PVLQgVJOTFCyGWWOGMM8j1Iz7+C5RIr39sHr1WO/3LW?= =?us-ascii?Q?V7+a21VCDy+ifB7dr37pMWl3cwczbRjQVquOG/FKMvTnGp2WsiHtZtdku4rc?= =?us-ascii?Q?kNfVqpnkLmoxW0eA1csY5ZThfs2Ue753bBD87V/Ef/ifJtXr5crVQCuhYsLp?= =?us-ascii?Q?SGQtmF2py/ygumSmFxCX1mZPfgHpJrTs+4UXdnN9ZCoX0hpuZnfRchZbitaJ?= =?us-ascii?Q?yzzN8YHknsbs5QOZWVKnakpE1oY1BeL+rNQzE9K0m6pvtVp2pzfB+8oeSrhQ?= =?us-ascii?Q?tVD8WduCi95WiIq7UtExbrhMEXwsP6Qddf/rZdhJqEonETS8lMEOZcngtw7I?= =?us-ascii?Q?rfjvwzuxpZ2N5VsA8by6CzJQjPWvKxaj/KA9a32l5sMp+jLLAd2eIZnLUupp?= =?us-ascii?Q?9NO4uk49dfbY+mCBB5S8uTXSPO3PgitCE6TTgpSOSx+Mt6LEdxuVqwi8hYY3?= =?us-ascii?Q?+5h/MBvRvPhf1yiLgqa/TBnowOq//JHhUrOmXYbgMG4X2j+35sJhd61raroI?= =?us-ascii?Q?YuG/bGmrSeZFb5mz7/rAVJWv0c3a5FsvCqmSc/el1vvrIVGCB/zfGx1Nr/vw?= =?us-ascii?Q?rwOHD6Kyk+0qtuqiBbHeeZOFAEx9sjPISF57oX+qIRtNnvEwTHEOhnnR33Bh?= =?us-ascii?Q?S1AoXJwKGrSJiJLHFKwallChX8RJsrED8b1kObhgMTKClnMkWW90Br2Qt1dx?= =?us-ascii?Q?pJL6jpbbUKvx7OwDgybMfCW5jwYmhspmE8SxUVQt3gjuI8thKx5OuQ4UJhnI?= =?us-ascii?Q?GPlGuMTZc/0EU7pNMtMDFCkH6ebFfl5L6I1oP4KokO2xIZVjwy6S4Z/hgA?= =?us-ascii?Q?=3D=3D?= X-Forefront-Antispam-Report: CIP:165.204.84.17;CTRY:US;LANG:en;SCL:1;SRV:;IPV:CAL;SFV:NSPM;H:SATLEXMB04.amd.com;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(13230040)(36860700013)(1800799024)(82310400026)(376014)(7416014)(13003099007);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 15 May 2025 22:53:00.0340 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: d74bfda9-9734-4866-1010-08dd94033de6 X-MS-Exchange-CrossTenant-Id: 3dd8961f-e488-4e60-8e11-a82d994e183d X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=3dd8961f-e488-4e60-8e11-a82d994e183d;Ip=[165.204.84.17];Helo=[SATLEXMB04.amd.com] X-MS-Exchange-CrossTenant-AuthSource: BN1PEPF00004684.namprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: IA1PR12MB6305 Content-Type: text/plain; charset="utf-8" ABMC feature details are reported via CPUID Fn8000_0020_EBX_x5. Bits Description 15:0 MAX_ABMC Maximum Supported Assignable Bandwidth Monitoring Counter ID + 1 The feature details are documented in APM listed below [1]. [1] AMD64 Architecture Programmer's Manual Volume 2: System Programming Publication # 24593 Revision 3.41 section 19.3.3.3 Assignable Bandwidth Monitoring (ABMC). Detect the feature and number of assignable monitoring counters supported. Link: https://bugzilla.kernel.org/show_bug.cgi?id=3D206537 Signed-off-by: Babu Moger --- v13: No changes. v12: Resolved conflicts because of latest merge. Removed Reviewed-by as the patch has changed. v11: No changes. v10: No changes. v9: Added Reviewed-by tag. No code changes v8: Used GENMASK for the mask. v7: Removed WARN_ON for num_mbm_cntrs. Decided to dynamically allocate the bitmap. WARN_ON is not required anymore. Removed redundant comments. v6: Commit message update. Renamed abmc_capable to mbm_cntr_assignable. v5: Name change num_cntrs to num_mbm_cntrs. Moved abmc_capable to resctrl_mon. v4: Removed resctrl_arch_has_abmc(). Added all the code inline. We dont need to separate this as arch code. v3: Removed changes related to mon_features. Moved rdt_cpu_has to core.c and added new function resctrl_arch_has_abm= c. Also moved the fields mbm_assign_capable and mbm_assign_cntrs to rdt_resource. (James) v2: Changed the field name to mbm_assign_capable from abmc_capable. --- arch/x86/kernel/cpu/resctrl/monitor.c | 9 +++++++-- include/linux/resctrl.h | 4 ++++ 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/arch/x86/kernel/cpu/resctrl/monitor.c b/arch/x86/kernel/cpu/re= sctrl/monitor.c index aeb2a9283069..fd2761d9f3f7 100644 --- a/arch/x86/kernel/cpu/resctrl/monitor.c +++ b/arch/x86/kernel/cpu/resctrl/monitor.c @@ -345,6 +345,7 @@ int __init rdt_get_mon_l3_config(struct rdt_resource *r) unsigned int mbm_offset =3D boot_cpu_data.x86_cache_mbm_width_offset; struct rdt_hw_resource *hw_res =3D resctrl_to_arch_res(r); unsigned int threshold; + u32 eax, ebx, ecx, edx; =20 snc_nodes_per_l3_cache =3D snc_get_config(); =20 @@ -375,13 +376,17 @@ int __init rdt_get_mon_l3_config(struct rdt_resource = *r) resctrl_rmid_realloc_threshold =3D resctrl_arch_round_mon_val(threshold); =20 if (rdt_cpu_has(X86_FEATURE_BMEC)) { - u32 eax, ebx, ecx, edx; - /* Detect list of bandwidth sources that can be tracked */ cpuid_count(0x80000020, 3, &eax, &ebx, &ecx, &edx); r->mon.mbm_cfg_mask =3D ecx & MAX_EVT_CONFIG_BITS; } =20 + if (rdt_cpu_has(X86_FEATURE_ABMC)) { + r->mon.mbm_cntr_assignable =3D true; + cpuid_count(0x80000020, 5, &eax, &ebx, &ecx, &edx); + r->mon.num_mbm_cntrs =3D (ebx & GENMASK(15, 0)) + 1; + } + r->mon_capable =3D true; =20 return 0; diff --git a/include/linux/resctrl.h b/include/linux/resctrl.h index 2a8fa454d3e6..065fb6e38933 100644 --- a/include/linux/resctrl.h +++ b/include/linux/resctrl.h @@ -260,11 +260,15 @@ enum resctrl_schema_fmt { * @num_rmid: Number of RMIDs available * @mbm_cfg_mask: Bandwidth sources that can be tracked when bandwidth * monitoring events can be configured. + * @num_mbm_cntrs: Number of assignable monitoring counters + * @mbm_cntr_assignable:Is system capable of supporting monitor assignment? * @evt_list: List of monitoring events */ struct resctrl_mon { int num_rmid; unsigned int mbm_cfg_mask; + int num_mbm_cntrs; + bool mbm_cntr_assignable; struct list_head evt_list; }; =20 --=20 2.34.1 From nobody Sun Dec 14 02:00:56 2025 Received: from NAM10-BN7-obe.outbound.protection.outlook.com (mail-bn7nam10on2082.outbound.protection.outlook.com [40.107.92.82]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 472FD29293D; Thu, 15 May 2025 22:53:14 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.92.82 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1747349597; cv=fail; b=jm6Jy1Ai6z03OxG/yDfRch9MVL9JE4FaXIjLVZwkjWhkdpJI9Hica3JhctAN6PIzg5X3L2gUT2y8aQZgZcuZEJIJjoqcBgsvqKMnqHgt+Py6Bv85xxZ5CHADxG87l/o38vvCWJGDxIZ+n/1hLjlDKXPNeUCsoQTy8M4hungXtRc= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1747349597; c=relaxed/simple; bh=3uvAMjzSVYWVLvOzoZ6SbjTzyQDlJhrmgG7AoF4SqkM=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=jB6CJ6iHDfffHNc/O5ZL0FzCyFxgbq8QgrcmVe2HB1K5wm5Sjs95cnxFYfqhIx2BwHPMzoh0gVtwIMT9Fn+9Ox1Ra6PtMKTL4xr++/n3WdvUfYuc8o9xeTiu0b6tJgxzQYt9T1NZMxPqfl7kJ/uogu/jFAVxm5SUXs5K+oERlB8= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=amd.com; spf=fail smtp.mailfrom=amd.com; dkim=pass (1024-bit key) header.d=amd.com header.i=@amd.com header.b=5hEYhbYK; arc=fail smtp.client-ip=40.107.92.82 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=amd.com Authentication-Results: smtp.subspace.kernel.org; spf=fail smtp.mailfrom=amd.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=amd.com header.i=@amd.com header.b="5hEYhbYK" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=L4MYZSn5uaGRw+eWDOMZhApYN/jh8+PqpcnhWAal8rUfsA+7jrSjq5tJ/DfVSO7kW8JJHbWzOFO45jIQWE5l3mnHBbhkaStNMyywLJWVHFsrLwCkPC54OFqkXhFWfYp7b2HIQIPyr6EY7PX1pDxqE6vEQ8R4R5GALgoHkJ/Uy9i5KZ4PFqwkwbwqC1zg0dhxFXAhEJeOsyS419qv/P4OE8sQynKR+hVnZMrZg2ZnCtSSQ2t32kbdPD6KpCTD1vkXeyb1lLBiQtFZKQhuOih/uBO1WKJbc0iABqmHfu/gerQ5NcYenkaDw9GHXz5QWN99dCduBRJssRTRbyyizncL+Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=4c9RIkKhuBbh5GQnSPdBAPekWZ1MQWSNSDIewdp760A=; b=QryDjwmqcEwAX0TlYf8HQe/zZeWB9qtwvFPe749fUSP80prGviEAMcdxa+Cfbecdiozx/52ftjiEHP5lDstEJsiQV2JBA4hdDAkb0qAA9LnmSq5aQvAff3sP6+DSvvTku9uvQ+VAzqesg0s9kR1VqWsdcLjmeWcTvjOiEu1/2Mvjochn7eTnaQGzpQUjAL+UM+L+fiAg7UVKO1vPVJAImrEBVWGQqoPmSB/H3VBM+49GH9nEidAilmMunwbzn0v3od/3v2Or2o2gGdu3mnTcEA9NP9Kp496oyc2lqFyESqfQoQYcpRZ/WI7oi2OUgYHM6EMDxB0xZeiN+kKb5kCdTA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=lwn.net smtp.mailfrom=amd.com; dmarc=pass (p=quarantine sp=quarantine pct=100) action=none header.from=amd.com; dkim=none (message not signed); arc=none (0) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amd.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=4c9RIkKhuBbh5GQnSPdBAPekWZ1MQWSNSDIewdp760A=; b=5hEYhbYKCxDGXyCeovtg34/cgPX/loKWHPMZOh54MjslxqZv2JZS2J6mt7HPJ3btS6831SkgYBYaCjR4XYDOAiNwaTMcos/fVmtDzWd0x0MgUJonSIZNFMtntGdf3Ri3N5MleNLSAm4iE/4rMDR3px2aJ5pBV0IwNKSiIvHzypA= Received: from BN9PR03CA0370.namprd03.prod.outlook.com (2603:10b6:408:f7::15) by MN0PR12MB5809.namprd12.prod.outlook.com (2603:10b6:208:375::7) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8722.30; Thu, 15 May 2025 22:53:09 +0000 Received: from BN1PEPF00004681.namprd03.prod.outlook.com (2603:10b6:408:f7:cafe::3d) by BN9PR03CA0370.outlook.office365.com (2603:10b6:408:f7::15) with Microsoft SMTP Server (version=TLS1_3, cipher=TLS_AES_256_GCM_SHA384) id 15.20.8722.25 via Frontend Transport; Thu, 15 May 2025 22:53:09 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 165.204.84.17) smtp.mailfrom=amd.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=amd.com; Received-SPF: Pass (protection.outlook.com: domain of amd.com designates 165.204.84.17 as permitted sender) receiver=protection.outlook.com; client-ip=165.204.84.17; helo=SATLEXMB04.amd.com; pr=C Received: from SATLEXMB04.amd.com (165.204.84.17) by BN1PEPF00004681.mail.protection.outlook.com (10.167.243.87) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.8722.18 via Frontend Transport; Thu, 15 May 2025 22:53:09 +0000 Received: from bmoger-ubuntu.amd.com (10.180.168.240) by SATLEXMB04.amd.com (10.181.40.145) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.39; Thu, 15 May 2025 17:53:06 -0500 From: Babu Moger To: , , , , , , CC: , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , Subject: [PATCH v13 05/27] x86/resctrl: Add support to enable/disable AMD ABMC feature Date: Thu, 15 May 2025 17:51:50 -0500 Message-ID: X-Mailer: git-send-email 2.34.1 In-Reply-To: References: Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-ClientProxiedBy: SATLEXMB04.amd.com (10.181.40.145) To SATLEXMB04.amd.com (10.181.40.145) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: BN1PEPF00004681:EE_|MN0PR12MB5809:EE_ X-MS-Office365-Filtering-Correlation-Id: 3106a6fa-ff56-47ef-24ca-08dd94034385 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|82310400026|36860700013|376014|1800799024|7416014; X-Microsoft-Antispam-Message-Info: =?us-ascii?Q?l6keoFlyznH8ie+YqOKHYhJV1fewqoMcW+0WxU/Ido4bbfu4V1b54pC8dQDL?= =?us-ascii?Q?AApgHwwDxvUGBisMoqrVX8hrcyT+YxbGEXnvtjaVm7BjoxfZu8+s0TnNLULn?= =?us-ascii?Q?fpTFQDh/yPfQ4se2G/eRnAWjaUYLirreJnTxbuJnlHDqzJtqgzHmiaPe6QnT?= =?us-ascii?Q?aO6lQOBwUw+6a7DPZFmscMEPf2aoA6F9oRiowFMQ8fYsRvWJ9DT20Tg/0nuy?= =?us-ascii?Q?ZLx+qLxRcdA7ulwaiGzY34b6WgqddklGQwYPV7F1B921UgNHRzsGq6r3DgBm?= =?us-ascii?Q?wLNThaeWvH60IS+Fz5Fi2JNlljUUac22cO1J7XLTar2O2XKgX1ymlJjPYEmx?= =?us-ascii?Q?ITARZtedw5z3zwEq7+TS/Eux1EeN06bjahr6RY2bpHziiVaVryTcjFf9I+Qs?= =?us-ascii?Q?UCx61RmkAhgj6o4FD2cdAyZiCv1/AiEbVofKvBRW8Xo0EzIr/WxxJMXzOYHq?= =?us-ascii?Q?ybS5jZHR29U4sZfX8bAiQCH9iLtBpRP0ZrU3ggJC0OKromaWUwS17EPmlFqN?= =?us-ascii?Q?p9PKJPx76XWdA370d4GoYzZrGgx/CdaiHsbVVCfAPgj8//R1brvidmFtYNH0?= =?us-ascii?Q?eJgceXeJQuqkh6sRNav5xv8PfMD5Tko09LU7JFFSquyj0r8swyJhm8ySLPaF?= =?us-ascii?Q?odq6VPlVTTrxVnyOzsQOkM2/EmZNo7u20wYxAzkoU5ShLLhHLS4gvNHHZybr?= =?us-ascii?Q?Gkis+FPT2yUKWiGFq8XyJWzZMaE9bW0J/RkwxhhqQywytNcqR2TeBIxoeI9K?= =?us-ascii?Q?gGTUMHRK7B9LSlVupnDcj6wvYkFwjlmR9akSJBhb9+zK8dYDBzIHZD/1fQfr?= =?us-ascii?Q?Pa/CiWY9BEeYoXmfz0DSrCTNSEla9DOd+Bgokt+oug+PnqUYer+n/x+nf6f/?= =?us-ascii?Q?2pPic8jMA1TdljAAxn7Bbrt+IuKViQDhs3g8LzZE9pRX9HU7VDs5sgmJA1gr?= =?us-ascii?Q?b92kbOMCAaRVSc17HAQ+YlKIml40MMg4JLEv+zs0+2F/zV/7nt2/B7u33dCF?= =?us-ascii?Q?dpJ8lRrvGXBc/J5pU6uKwnVWtBSn5Ab+GJcTRhCiPHy0n9k8pjhJ/4yfAsGc?= =?us-ascii?Q?0WDc+bXvB51uYXX85zy+7+MoWngfGLVtKlfNWKrsnuWqJ4/DTzbdlfT7YZy+?= =?us-ascii?Q?TZ86JgAWfKGSUlw0aDjhwjfGnRonKJrz8xJaSl9lCNFRay+3L+3iTBAfwUXL?= =?us-ascii?Q?ubTq3/Ss3zGCyxBnkLO7P25BDYafOyI56E3tJsPq7G/XZxKILrmRwsYXpCbF?= =?us-ascii?Q?JxqOOBCQKTqOWokhX73zQvieCe0KDSLz+cnOWCGhXEyS+DxCigM30q2YYSue?= =?us-ascii?Q?WoXtPluYThKQaoueDfCpVBlOPcv5pUrQxY5R4j/PdG9CWZ29g/Vr0M1boMXQ?= =?us-ascii?Q?Cu9dTr1yqy7xpKw1+6XtsAJ2yJdUDboRtnzRBQ27EZq9XDCIuwH9+XDxcGGp?= =?us-ascii?Q?I4miXde4GVzmmPLBHeijxouXYWXWhyRO6gLXrMGq6hQe/QZVldkM88iYHBTr?= =?us-ascii?Q?YEbDD9d1/l1gZH98QehZ1waDFGo7n8hybuKbRccyipApQb4hwwnx7SLfhA?= =?us-ascii?Q?=3D=3D?= X-Forefront-Antispam-Report: CIP:165.204.84.17;CTRY:US;LANG:en;SCL:1;SRV:;IPV:CAL;SFV:NSPM;H:SATLEXMB04.amd.com;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(13230040)(82310400026)(36860700013)(376014)(1800799024)(7416014);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 15 May 2025 22:53:09.4684 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 3106a6fa-ff56-47ef-24ca-08dd94034385 X-MS-Exchange-CrossTenant-Id: 3dd8961f-e488-4e60-8e11-a82d994e183d X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=3dd8961f-e488-4e60-8e11-a82d994e183d;Ip=[165.204.84.17];Helo=[SATLEXMB04.amd.com] X-MS-Exchange-CrossTenant-AuthSource: BN1PEPF00004681.namprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: MN0PR12MB5809 Content-Type: text/plain; charset="utf-8" Add the functionality to enable/disable AMD ABMC feature. AMD ABMC feature is enabled by setting enabled bit(0) in MSR L3_QOS_EXT_CFG. When the state of ABMC is changed, the MSR needs to be updated on all the logical processors in the QOS Domain. Hardware counters will reset when ABMC state is changed. The ABMC feature details are documented in APM listed below [1]. [1] AMD64 Architecture Programmer's Manual Volume 2: System Programming Publication # 24593 Revision 3.41 section 19.3.3.3 Assignable Bandwidth Monitoring (ABMC). Link: https://bugzilla.kernel.org/show_bug.cgi?id=3D206537 Signed-off-by: Babu Moger --- v13: Resolved minor conflicts with recent FS/ARCH restructure. v12: Clarified the comment on _resctrl_abmc_enable(). Added the code to reset arch state in _resctrl_abmc_enable(). Resolved the conflicts with latest merge. v11: Moved the monitoring related calls to monitor.c file. Moved the changes from include/linux/resctrl.h to arch/x86/kernel/cpu/resctrl/internal.h. Removed the Reviewed-by tag as patch changed. Actual code did not change. v10: No changes. v9: Re-ordered the MSR and added Reviewed-by tag. v8: Commit message update and moved around the comments about L3_QOS_EXT_CFG to _resctrl_abmc_enable. v7: Renamed the function resctrl_arch_get_abmc_enabled() to resctrl_arch_mbm_cntr_assign_enabled= (). Merged resctrl_arch_mbm_cntr_assign_disable, resctrl_arch_mbm_cntr_assi= gn_disable and renamed to resctrl_arch_mbm_cntr_assign_set(). Moved the function definition to linux/resctrl.h. Passed the struct rdt_resource to these functions. Removed resctrl_arch_reset_rmid_all() from arch code. This will be done from the caller. v6: Renamed abmc_enabled to mbm_cntr_assign_enabled. Used msr_set_bit and msr_clear_bit for msr updates. Renamed resctrl_arch_abmc_enable() to resctrl_arch_mbm_cntr_assign_enab= le(). Renamed resctrl_arch_abmc_disable() to resctrl_arch_mbm_cntr_assign_dis= able(). Made _resctrl_abmc_enable to return void. v5: Renamed resctrl_abmc_enable to resctrl_arch_abmc_enable. Renamed resctrl_abmc_disable to resctrl_arch_abmc_disable. Introduced resctrl_arch_get_abmc_enabled to get abmc state from non-arch code. Renamed resctrl_abmc_set_all to _resctrl_abmc_enable(). Modified commit log to make it clear about AMD ABMC feature. v3: No changes. v2: Few text changes in commit message. --- arch/x86/include/asm/msr-index.h | 1 + arch/x86/kernel/cpu/resctrl/internal.h | 5 +++ arch/x86/kernel/cpu/resctrl/monitor.c | 43 ++++++++++++++++++++++++++ include/linux/resctrl.h | 3 ++ 4 files changed, 52 insertions(+) diff --git a/arch/x86/include/asm/msr-index.h b/arch/x86/include/asm/msr-in= dex.h index e6134ef2263d..3970e0b16e47 100644 --- a/arch/x86/include/asm/msr-index.h +++ b/arch/x86/include/asm/msr-index.h @@ -1203,6 +1203,7 @@ /* - AMD: */ #define MSR_IA32_MBA_BW_BASE 0xc0000200 #define MSR_IA32_SMBA_BW_BASE 0xc0000280 +#define MSR_IA32_L3_QOS_EXT_CFG 0xc00003ff #define MSR_IA32_EVT_CFG_BASE 0xc0000400 =20 /* AMD-V MSRs */ diff --git a/arch/x86/kernel/cpu/resctrl/internal.h b/arch/x86/kernel/cpu/r= esctrl/internal.h index 5e3c41b36437..fcc9d23686a1 100644 --- a/arch/x86/kernel/cpu/resctrl/internal.h +++ b/arch/x86/kernel/cpu/resctrl/internal.h @@ -37,6 +37,9 @@ struct arch_mbm_state { u64 prev_msr; }; =20 +/* Setting bit 0 in L3_QOS_EXT_CFG enables the ABMC feature. */ +#define ABMC_ENABLE_BIT 0 + /** * struct rdt_hw_ctrl_domain - Arch private attributes of a set of CPUs th= at share * a resource for a control function @@ -102,6 +105,7 @@ struct msr_param { * @mon_scale: cqm counter * mon_scale =3D occupancy in bytes * @mbm_width: Monitor width, to detect and correct for overflow. * @cdp_enabled: CDP state of this resource + * @mbm_cntr_assign_enabled: ABMC feature is enabled * * Members of this structure are either private to the architecture * e.g. mbm_width, or accessed via helpers that provide abstraction. e.g. @@ -115,6 +119,7 @@ struct rdt_hw_resource { unsigned int mon_scale; unsigned int mbm_width; bool cdp_enabled; + bool mbm_cntr_assign_enabled; }; =20 static inline struct rdt_hw_resource *resctrl_to_arch_res(struct rdt_resou= rce *r) diff --git a/arch/x86/kernel/cpu/resctrl/monitor.c b/arch/x86/kernel/cpu/re= sctrl/monitor.c index fd2761d9f3f7..ff4b2abfa044 100644 --- a/arch/x86/kernel/cpu/resctrl/monitor.c +++ b/arch/x86/kernel/cpu/resctrl/monitor.c @@ -405,3 +405,46 @@ void __init intel_rdt_mbm_apply_quirk(void) mbm_cf_rmidthreshold =3D mbm_cf_table[cf_index].rmidthreshold; mbm_cf =3D mbm_cf_table[cf_index].cf; } + +static void resctrl_abmc_set_one_amd(void *arg) +{ + bool *enable =3D arg; + + if (*enable) + msr_set_bit(MSR_IA32_L3_QOS_EXT_CFG, ABMC_ENABLE_BIT); + else + msr_clear_bit(MSR_IA32_L3_QOS_EXT_CFG, ABMC_ENABLE_BIT); +} + +/* + * ABMC enable/disable requires update of L3_QOS_EXT_CFG MSR on all the CP= Us + * associated with all monitor domains. + */ +static void _resctrl_abmc_enable(struct rdt_resource *r, bool enable) +{ + struct rdt_mon_domain *d; + + list_for_each_entry(d, &r->mon_domains, hdr.list) { + on_each_cpu_mask(&d->hdr.cpu_mask, + resctrl_abmc_set_one_amd, &enable, 1); + resctrl_arch_reset_rmid_all(r, d); + } +} + +int resctrl_arch_mbm_cntr_assign_set(struct rdt_resource *r, bool enable) +{ + struct rdt_hw_resource *hw_res =3D resctrl_to_arch_res(r); + + if (r->mon.mbm_cntr_assignable && + hw_res->mbm_cntr_assign_enabled !=3D enable) { + _resctrl_abmc_enable(r, enable); + hw_res->mbm_cntr_assign_enabled =3D enable; + } + + return 0; +} + +inline bool resctrl_arch_mbm_cntr_assign_enabled(struct rdt_resource *r) +{ + return resctrl_to_arch_res(r)->mbm_cntr_assign_enabled; +} diff --git a/include/linux/resctrl.h b/include/linux/resctrl.h index 065fb6e38933..bdb264875ef6 100644 --- a/include/linux/resctrl.h +++ b/include/linux/resctrl.h @@ -428,6 +428,9 @@ static inline u32 resctrl_get_config_index(u32 closid, bool resctrl_arch_get_cdp_enabled(enum resctrl_res_level l); int resctrl_arch_set_cdp_enabled(enum resctrl_res_level l, bool enable); =20 +bool resctrl_arch_mbm_cntr_assign_enabled(struct rdt_resource *r); +int resctrl_arch_mbm_cntr_assign_set(struct rdt_resource *r, bool enable); + /* * Update the ctrl_val and apply this config right now. * Must be called on one of the domain's CPUs. --=20 2.34.1 From nobody Sun Dec 14 02:00:56 2025 Received: from NAM02-SN1-obe.outbound.protection.outlook.com (mail-sn1nam02on2064.outbound.protection.outlook.com [40.107.96.64]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id D4CB728CF5B; Thu, 15 May 2025 22:53:24 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.96.64 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1747349606; cv=fail; b=HZiPXlHZLEJHcxSOnfIToyzBP03F/uZ14tALwrlY/q8GRzqqrMF/m2vIdRsaUZhv9dtmkbGHqKtYg4VUpMhFNYvEyDc6wlzhr5ULoz0AxJnLVTsrJJFfHuymsNLmePQR4K7LEI1Gs6uzZGI5w33gFNgV9kCcxD/yh2n3b2eeTSo= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1747349606; c=relaxed/simple; bh=htzSgeknkCpYJUc/0ANZJltLEXDoKv98RRKMOshc8rw=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=XPMds1dGpHT0TWYfBWF84fB1w1vBNbSgejPnwres7T5KGwiRl6y2gJlLvV8xurNskn2EgJPWzGkyTNPfI1WJwf2/Org5YkNBL5dmkretAgYwitCkY0tHzY5Cf6bV8cVwdX+vVHKSvy2fVjqqYfYR4DZqDrCeZCGNf6znp+NfGgw= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=amd.com; spf=fail smtp.mailfrom=amd.com; dkim=pass (1024-bit key) header.d=amd.com header.i=@amd.com header.b=J6b/OpSk; arc=fail smtp.client-ip=40.107.96.64 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=amd.com Authentication-Results: smtp.subspace.kernel.org; spf=fail smtp.mailfrom=amd.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=amd.com header.i=@amd.com header.b="J6b/OpSk" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=Ru4f6f/o9sQCUsyejszs0IyCdrWF4WvyvB54vyVf61hfUJK2HcmzlUn2U4vQcIl99aj7fXmMxEoCzm9aXrztc3daPoZEVDJ4bxg9KCC+FbgtnAytcJptLHU9ussF1hKJBfNjR9wGCSHXGGvmTw8Ri9B+Zp9hZokCqv1F5eyG0QCfjlYTlRke6wb6PBiDWqgklqw1rbHjutQsPrkz0WSJD344mdhTW3VTWbhU+YnUkED1Nokzdb7TSmdPsaxt1pRrteo7rxUYAGossbPb/wREaBB1bZJh4x3fEAlbKqbXaZ8LtQ/9eFYV2lRDNCyKJPk1eIPcqlfPjExKwrtaFU+NLw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=BJ7fGrav3EyP7zM321zk7ZJ+Z8zmz+mFr7b6e3QjNCQ=; b=eKoFGcokpcTEOQezh9rdzzd60zRkuJhJYn2qLfm5AlvIWzcE/Hwi9VcstqdThtVrQnsQ86xMd9WS9PsvzWhaSVTJ53YeUrS4ZJg6W5l/CdKa2l62vDP0GrRzHkjURVDc/Oh8ZORNvtHviTLfT8oZ1srD4zqBqsY7IsjwRpmRYS2ZRY9tNqHwWdHzsn5rI6gVmz7McaSqzuVcLeYnOfc2qHM9VR1F7kOA7ZjucMq1XawNagaY4hHnOf6/CwlpIekx7a8w8d674OYInlWFcbi80CWPNojXUBUmtJz0lEEARzbcdU2ZFSuR6K3190kYwZglm8tLUlpq8VTCZoBpcVC4qg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=lwn.net smtp.mailfrom=amd.com; dmarc=pass (p=quarantine sp=quarantine pct=100) action=none header.from=amd.com; dkim=none (message not signed); arc=none (0) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amd.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=BJ7fGrav3EyP7zM321zk7ZJ+Z8zmz+mFr7b6e3QjNCQ=; b=J6b/OpSkwLT1/Fjb9hdXz4lQlXIl8kjLnckhFVroyUmzvssiMU2IjATfI26tkS+R4Yu+W7LcrclLyxyhXTAcuqeE5dsxEAjt+k0F3f/tJy7A/s1XqRVHPMZX4nrg3RNSNitclPaoGU2VN1DPf7ZbJ06eE+G3gDUkeme1AIZwnRI= Received: from BN0PR08CA0003.namprd08.prod.outlook.com (2603:10b6:408:142::19) by SN7PR12MB8603.namprd12.prod.outlook.com (2603:10b6:806:260::15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8722.29; Thu, 15 May 2025 22:53:19 +0000 Received: from BN1PEPF0000467F.namprd03.prod.outlook.com (2603:10b6:408:142:cafe::80) by BN0PR08CA0003.outlook.office365.com (2603:10b6:408:142::19) with Microsoft SMTP Server (version=TLS1_3, cipher=TLS_AES_256_GCM_SHA384) id 15.20.8746.20 via Frontend Transport; Thu, 15 May 2025 22:53:19 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 165.204.84.17) smtp.mailfrom=amd.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=amd.com; Received-SPF: Pass (protection.outlook.com: domain of amd.com designates 165.204.84.17 as permitted sender) receiver=protection.outlook.com; client-ip=165.204.84.17; helo=SATLEXMB04.amd.com; pr=C Received: from SATLEXMB04.amd.com (165.204.84.17) by BN1PEPF0000467F.mail.protection.outlook.com (10.167.243.84) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.8722.18 via Frontend Transport; Thu, 15 May 2025 22:53:18 +0000 Received: from bmoger-ubuntu.amd.com (10.180.168.240) by SATLEXMB04.amd.com (10.181.40.145) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.39; Thu, 15 May 2025 17:53:16 -0500 From: Babu Moger To: , , , , , , CC: , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , Subject: [PATCH v13 06/27] x86/resctrl: Introduce the interface to display monitor mode Date: Thu, 15 May 2025 17:51:51 -0500 Message-ID: X-Mailer: git-send-email 2.34.1 In-Reply-To: References: Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-ClientProxiedBy: SATLEXMB04.amd.com (10.181.40.145) To SATLEXMB04.amd.com (10.181.40.145) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: BN1PEPF0000467F:EE_|SN7PR12MB8603:EE_ X-MS-Office365-Filtering-Correlation-Id: f4e2d4e4-e84d-4789-ccff-08dd94034932 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|376014|1800799024|7416014|82310400026|36860700013; X-Microsoft-Antispam-Message-Info: =?us-ascii?Q?RJYvXlIsHPBptee6C9+0yOSkY3Hj6Zx4JS3x4yXzKjIRmDbMGxOjINMH7L3J?= =?us-ascii?Q?GorEmayEu4rRXLxPbjnmDWg/yv8Di8kiuI1Bz+nMWjgrizn+/0fWYqmsAYKz?= =?us-ascii?Q?imtReyvM6tOh2ZXGIjBUdDQ808yMnFcGgqIhE+NtwhNYX+6RWjJSePFQn5GE?= =?us-ascii?Q?LkHaAfp6UYGNHjX27+mAmHa5gfd1NGEt3nCN0pcCUETXP2rQw77FUhD4HhoX?= =?us-ascii?Q?SPFoMN7ip+aiOjzXRL2BzcPGOxDNddiXNyEmFr2H49dNmJ55JndcGb61gc6r?= =?us-ascii?Q?XO2U/phQRBKAYvokPbDYShDoi+4Y4avlDM7zoy+Wu2Y2kd3EvECSlG9sFbfI?= =?us-ascii?Q?NRHQf/hiaqeQU1anxhZ1FKoSgq1XaldlSXc9PK3EeN4dXUyWtydbWIfAPP1h?= =?us-ascii?Q?pFMKRbPQoJ0sspwoDbfCN/wPWferAb8bM65hHu9aQdtfypyExkK1smE2bpgG?= =?us-ascii?Q?USNIli1A916yo4ykSEVM5dyQQbcbPil3vH/s6ErZdUc35OEp/CmDxDlrFZYd?= =?us-ascii?Q?YNLuWfr14C5tRi5p4B7IulbUwhME8C4M9DK6eUhxEB1rplwjbbjECbxAZ7lu?= =?us-ascii?Q?TsKZRb2dmf2bhl9RTRUMnPP3Hn15WPZ3+eBIxZFTdfEj0A8Tqf5N/2FGXhu2?= =?us-ascii?Q?qh989oUbPyVu2gMzbXvlIVDeR2jeurwVxCK78Kr1Gkm/hpuBYkll7j6NA1ep?= =?us-ascii?Q?28/1MZWg2srtQcNLoSUP9mULMy/uGYNF7RJGo5AbJzqvWLlKexF1kOWdo8fD?= =?us-ascii?Q?7wlGyVeQkTgXJUONeoSM/xHawNDNPjwQPzobg6jiUEC5FIsWx9uDZLR7JzBg?= =?us-ascii?Q?kv9XlyleloaCaTuCc1Vd20BwyB5w086aCFvcEtuX2YSVyzYuWgCQgX2z+Amw?= =?us-ascii?Q?12PZDHmPQE2PXeR3Q0c5mN3oDJme024iiFEOv9dm48NFnq1i/Nvg6KrRVh9j?= =?us-ascii?Q?+Bx56l2/ynXYKf8STQfw1iWbpLC/PdVyJVDQuP1mxE48km09vRdf74C9xves?= =?us-ascii?Q?sJHoxkK3PshbXNsZeSNZe0DF5E8BSrAFnj/I24Dwq3yx9vdjG+gsBoKCl0Pm?= =?us-ascii?Q?zXtcIOdwRIT441P+Idzhlpoc68c/Hw5CeL6B0UuVobq8iI8sRWO57kBR6ljQ?= =?us-ascii?Q?ZQn+yKsAe1SgU3Foebl26rR6m8q0JRPJufvHRvRRBUgQSVT7G0bDZfdY4REn?= =?us-ascii?Q?EVSwvxTZdRvcireULauV5YgbEKXYDgQOwhulqslR+5T5bPUx3vndGOArqpTU?= =?us-ascii?Q?jLPkGbAnmW6Cnco8qBwTgACXhoFT67l+jfNjITAnRtcjjlH2who3QLAxrb09?= =?us-ascii?Q?RfoexDXCpeF0FQwkwDMwR/xKFBZ+rGKm0Xlu54aKyGElroDp1AMi6o4vde/P?= =?us-ascii?Q?wj5wcF29EPu4zhP5Pw+14n7apT6njwlmnWhF6ls4/WaCh0gGE/wdbh0zBVwA?= =?us-ascii?Q?ealsSCFY+6fQ6c09WT3nnK6sDDW1aT8Tpx8GosqXQ6UmuvP4rN3bw18VbRzK?= =?us-ascii?Q?8etUi/zhSirqHzcT0T2koRqG1oFlvMtlJky8?= X-Forefront-Antispam-Report: CIP:165.204.84.17;CTRY:US;LANG:en;SCL:1;SRV:;IPV:CAL;SFV:NSPM;H:SATLEXMB04.amd.com;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(13230040)(376014)(1800799024)(7416014)(82310400026)(36860700013);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 15 May 2025 22:53:18.9938 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: f4e2d4e4-e84d-4789-ccff-08dd94034932 X-MS-Exchange-CrossTenant-Id: 3dd8961f-e488-4e60-8e11-a82d994e183d X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=3dd8961f-e488-4e60-8e11-a82d994e183d;Ip=[165.204.84.17];Helo=[SATLEXMB04.amd.com] X-MS-Exchange-CrossTenant-AuthSource: BN1PEPF0000467F.namprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: SN7PR12MB8603 Content-Type: text/plain; charset="utf-8" Introduce the resctrl file "mbm_assign_mode" to list monitor modes supported. The "mbm_cntr_assign" mode provides the option to assign a counter to an RMID, event pair and monitor the bandwidth as long as it is assigned. On AMD systems "mbm_cntr_assign" mode is backed by the ABMC (Assignable Bandwidth Monitoring Counters) hardware feature and is enabled by default. The "default" mode is the existing monitoring mode that works without the explicit counter assignment, instead relying on dynamic counter assignment by hardware that may result in hardware not dedicating a counter resulting in monitoring data reads returning "Unavailable". Provide an interface to display the monitor mode on the system. $ cat /sys/fs/resctrl/info/L3_MON/mbm_assign_mode [mbm_cntr_assign] default Add IS_ENABLED(CONFIG_RESCTRL_ASSIGN_FIXED) check to support Arm64. On x86, CONFIG_RESCTRL_ASSIGN_FIXED is not defined. On Arm64, it will be defined when the "mbm_cntr_assign" mode is supported. Add IS_ENABLED(CONFIG_RESCTRL_ASSIGN_FIXED) check early to ensure the user interface remains compatible with upcoming Arm64 support. IS_ENABLED() safely evaluates to 0 when the configuration is not defined. As a result, for MPAM, the display would be either: [default] or [mbm_cntr_assign] Signed-off-by: Babu Moger --- v13: Updated the commit log with motivation for adding CONFIG_RESCTRL_ASSIG= N_FIXED. Added fflag RFTYPE_RES_CACHE for mbm_assign_mode file. Updated user doc. Removed the references to "mbm_assign_control". Resolved the conflicts with latest FS/ARCH code restructure. v12: Minor text update in change log and user documentation. Added the check CONFIG_RESCTRL_ASSIGN_FIXED to take care of arm platfo= rms. This will be defined only in arm and not in x86. v11: Renamed rdtgroup_mbm_assign_mode_show() to resctrl_mbm_assign_mode_sho= w(). Removed few texts in resctrl.rst about AMD specific information. Updated few texts. v10: Added few more text to user documentation clarify on the default mode. v9: Updated user documentation based on comments. v8: Commit message update. v7: Updated the descriptions/commit log in resctrl.rst to generic text. Thanks to James and Reinette. Rename mbm_mode to mbm_assign_mode. Introduced mutex lock in rdtgroup_mbm_mode_show(). v6: Added documentation for mbm_cntr_assign and legacy mode. Moved mbm_mode fflags initialization to static initialization. v5: Changed interface name to mbm_mode. It will be always available even if ABMC feature is not supported. Added description in resctrl.rst about ABMC mode. Fixed display abmc and legacy consistantly. v4: Fixed the checks for legacy and abmc mode. Default it ABMC. v3: New patch to display ABMC capability. --- Documentation/filesystems/resctrl.rst | 27 +++++++++++++++++++ fs/resctrl/rdtgroup.c | 37 +++++++++++++++++++++++++++ 2 files changed, 64 insertions(+) diff --git a/Documentation/filesystems/resctrl.rst b/Documentation/filesyst= ems/resctrl.rst index c97fd77a107d..8013418b6ca2 100644 --- a/Documentation/filesystems/resctrl.rst +++ b/Documentation/filesystems/resctrl.rst @@ -257,6 +257,33 @@ with the following files: # cat /sys/fs/resctrl/info/L3_MON/mbm_local_bytes_config 0=3D0x30;1=3D0x30;3=3D0x15;4=3D0x15 =20 +"mbm_assign_mode": + Reports the list of monitoring modes supported. The enclosed brackets + indicate which mode is enabled. + :: + + # cat /sys/fs/resctrl/info/L3_MON/mbm_assign_mode + [mbm_cntr_assign] + default + + "mbm_cntr_assign": + + In mbm_cntr_assign mode, a monitoring event can only accumulate data + while it is backed by a hardware counter. Use "mbm_L3_assignments" found + in each CTRL_MON and MON group to specify which of the events should have + a counter assigned. The number of counters available is described in the + "num_mbm_cntrs" file. Changing the mode may cause all counters on the + resource to reset. + + "default": + + In default mode, resctrl assumes there is a hardware counter for each + event within every CTRL_MON and MON group. On AMD platforms, it is + recommended to use the mbm_cntr_assign mode, if supported, to prevent + reset of MBM events between reads resulting from hardware re-allocating + counters. This can result in misleading values or display "Unavailable" + if no counter is assigned to the event. + "max_threshold_occupancy": Read/write file provides the largest value (in bytes) at which a previously used LLC_occupancy diff --git a/fs/resctrl/rdtgroup.c b/fs/resctrl/rdtgroup.c index 9412c7b64523..a9e1055df75f 100644 --- a/fs/resctrl/rdtgroup.c +++ b/fs/resctrl/rdtgroup.c @@ -1801,6 +1801,36 @@ static ssize_t mbm_local_bytes_config_write(struct k= ernfs_open_file *of, return ret ?: nbytes; } =20 +static int resctrl_mbm_assign_mode_show(struct kernfs_open_file *of, + struct seq_file *s, void *v) +{ + struct rdt_resource *r =3D rdt_kn_parent_priv(of->kn); + bool enabled; + + mutex_lock(&rdtgroup_mutex); + enabled =3D resctrl_arch_mbm_cntr_assign_enabled(r); + + if (r->mon.mbm_cntr_assignable) { + if (enabled) + seq_puts(s, "[mbm_cntr_assign]\n"); + else + seq_puts(s, "[default]\n"); + + if (!IS_ENABLED(CONFIG_RESCTRL_ASSIGN_FIXED)) { + if (enabled) + seq_puts(s, "default\n"); + else + seq_puts(s, "mbm_cntr_assign\n"); + } + } else { + seq_puts(s, "[default]\n"); + } + + mutex_unlock(&rdtgroup_mutex); + + return 0; +} + /* rdtgroup information files for one cache resource. */ static struct rftype res_common_files[] =3D { { @@ -1913,6 +1943,13 @@ static struct rftype res_common_files[] =3D { .seq_show =3D mbm_local_bytes_config_show, .write =3D mbm_local_bytes_config_write, }, + { + .name =3D "mbm_assign_mode", + .mode =3D 0444, + .kf_ops =3D &rdtgroup_kf_single_ops, + .seq_show =3D resctrl_mbm_assign_mode_show, + .fflags =3D RFTYPE_MON_INFO | RFTYPE_RES_CACHE, + }, { .name =3D "cpus", .mode =3D 0644, --=20 2.34.1 From nobody Sun Dec 14 02:00:56 2025 Received: from NAM02-DM3-obe.outbound.protection.outlook.com (mail-dm3nam02on2078.outbound.protection.outlook.com [40.107.95.78]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 891E428C2C2; Thu, 15 May 2025 22:53:35 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.95.78 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1747349617; cv=fail; b=A7AV1lDwuth41eNmojk7RExSnMK7uXGjixGH53y0D7hd9zUe2GfdfgK5JaJBrd/6d3TtgOjR3LYgu5zScGVl5VsSNbTUTt1eXDoa3ktooog+ppaR49AH8r2TDDYQRBQb9nfrVZk2l0bQYHyYEjcpG5JeWASy/1XyZW+Lp5wG/v4= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1747349617; c=relaxed/simple; bh=sZwmpPXRz8GEiz3dAKWnHvNdlzlKdAY+x6M7cyfXVIk=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=pbMgM+YcbJ6IenMf9yoaM4EOIFFqOmtPb4gWMM48vmOWzL3Rye0kDzGwSHt2Td6YCZaiGXQUNOh6wTBLEgnzlQAP2blojEisTHUDG44HqzdeXsyV2zs2b7bXQJbgG22APhl5+G3Jw8YmWIcf7p8b1lY+UvHHXiBvhEXlHVdyB70= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=amd.com; spf=fail smtp.mailfrom=amd.com; dkim=pass (1024-bit key) header.d=amd.com header.i=@amd.com header.b=AdUziLfu; arc=fail smtp.client-ip=40.107.95.78 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=amd.com Authentication-Results: smtp.subspace.kernel.org; spf=fail smtp.mailfrom=amd.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=amd.com header.i=@amd.com header.b="AdUziLfu" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=ARGxABbiyki8i8iZp8yPqlY0kSlu1bpCWaqP1Kyhjt4SfyKEjdk6J4fK64R/G3YI5yv3HO54iwRooFVGzdxYCpTDi1AJDrSsFRNXvnTVn/8LI3xIMDJC3TKoWKkhVYGQL62MBzrmwFame+jEBnzgVW5FYpqFP96jk6jTAx+ZyKgtSVSkuIFJtTrBitOfVhRGmgfNr/wchGv2vZmWZ8MzGJlW3LJOr7krd2qrOm+ZwlKY0R5vCnYc4modHy91Og+pJABZggTKWGaAKB80mQvy2Z4MES7ov4yP54VOTTAdoEwJaKYzdIUJtH/JEU6+9NN8lVbmvUrUCvI8yzsQcbKdOA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=uwxYVwemHOzvAyud1yZbWakkt3bTCFU9s7J0l/NjzcI=; b=jrQ6JRZCrLOLIU4NDHakKT3ZgRRMEsiNE50ZgpEpYG5twIm34CL59xEklXGQA3VhXPPoNBp1TDSzp6NuM4GOjmpE4s9PXlf81S05NpSrMUOTcFBIO9gyYRe0xgRbjaGWfd0SgK7Cgt6ihMABzjTj6rHzIG1g1Npf1Q/Z+vqAx7a5GbY87t/f50HWiwXGecQxuPLihdMun7D6xc9bLLIupYWsZH+m6OX+Hz1Zq/h59RLz41UMCSrLfy6fhKGhCN4nmMcqjW8y5hkAkhnUhxj6ZBvKEZnbOZ6dDHwSNxstUUcfALMdb3tEmeLqv3u1g27HFi2VKLzp17PboLb5nHLy9g== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=lwn.net smtp.mailfrom=amd.com; dmarc=pass (p=quarantine sp=quarantine pct=100) action=none header.from=amd.com; dkim=none (message not signed); arc=none (0) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amd.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=uwxYVwemHOzvAyud1yZbWakkt3bTCFU9s7J0l/NjzcI=; b=AdUziLfutlINCw+d5KoOTwChNe1UjfArqU/CZAi9EBLtGxnnI2NEl/sJhZ+qlCraFVUGj+NBMe1ru7cp26p4uRxl4ZoSc8RIvFyEzuZzRSeP3CssCIJ2gTxXY1zR0wbzWg0ncljfbseV2FTIemjLr6jKUjI22ctIvIlKv6zZQCU= Received: from BN0PR08CA0019.namprd08.prod.outlook.com (2603:10b6:408:142::12) by CY5PR12MB6479.namprd12.prod.outlook.com (2603:10b6:930:34::17) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8722.29; Thu, 15 May 2025 22:53:29 +0000 Received: from BN1PEPF0000467F.namprd03.prod.outlook.com (2603:10b6:408:142:cafe::8a) by BN0PR08CA0019.outlook.office365.com (2603:10b6:408:142::12) with Microsoft SMTP Server (version=TLS1_3, cipher=TLS_AES_256_GCM_SHA384) id 15.20.8722.28 via Frontend Transport; Thu, 15 May 2025 22:53:28 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 165.204.84.17) smtp.mailfrom=amd.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=amd.com; Received-SPF: Pass (protection.outlook.com: domain of amd.com designates 165.204.84.17 as permitted sender) receiver=protection.outlook.com; client-ip=165.204.84.17; helo=SATLEXMB04.amd.com; pr=C Received: from SATLEXMB04.amd.com (165.204.84.17) by BN1PEPF0000467F.mail.protection.outlook.com (10.167.243.84) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.8722.18 via Frontend Transport; Thu, 15 May 2025 22:53:28 +0000 Received: from bmoger-ubuntu.amd.com (10.180.168.240) by SATLEXMB04.amd.com (10.181.40.145) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.39; Thu, 15 May 2025 17:53:25 -0500 From: Babu Moger To: , , , , , , CC: , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , Subject: [PATCH v13 07/27] x86/resctrl: Introduce interface to display number of monitoring counters Date: Thu, 15 May 2025 17:51:52 -0500 Message-ID: X-Mailer: git-send-email 2.34.1 In-Reply-To: References: Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-ClientProxiedBy: SATLEXMB04.amd.com (10.181.40.145) To SATLEXMB04.amd.com (10.181.40.145) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: BN1PEPF0000467F:EE_|CY5PR12MB6479:EE_ X-MS-Office365-Filtering-Correlation-Id: 6daf80c9-ff18-48f5-61c7-08dd94034ee3 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|7416014|376014|1800799024|82310400026|36860700013; X-Microsoft-Antispam-Message-Info: =?us-ascii?Q?9BqlSUFIBLbX3RB2Pc1tEj8aG5N6nSYzmIf54dBLNQkgYvc2Tbbp0kbePTr9?= =?us-ascii?Q?iXmo8C2ur2js0Ada7trYHxvs2D8cXFDfVmD2HzRiGXZmCC26uCs8iZEeeRZB?= =?us-ascii?Q?5EzvNOJ74mfOGr4687ncVcYgq+Ygl6h3mCKpMTrKqaev4gE88oommE3YWoWk?= =?us-ascii?Q?GPtRyYk1+SnN9/ua7x0SuKmK07U/n54mM0QEGmM7h5FxyOmV54MdZyUI8TQR?= =?us-ascii?Q?JRR9nbHlCZb5NU1IFxlmxz80SY0g3MDuXF4jhblxfh4+NubqS0Mc0EG/kqFS?= =?us-ascii?Q?SJVrhWnXVdb4YPxshYC9ZI4foEZ4q/0KbxDjffHUkcTxdvxYnItEwxgYPjmC?= =?us-ascii?Q?BukUi6mdVaVTUiTcRjQ689wiwLJJAWd6Ec5McAiO5jpum9x/jy1qXw6LQfQb?= =?us-ascii?Q?OstWzu034O7zTakYnSUVDEnVZzOy75TCGjt8eONvywZuWi8pCbEzqbcK9csQ?= =?us-ascii?Q?ErT4ofQKj4m+qkqJ3EL65R7h/idRTOFnJEUEweQK47XAdMVPs9EhscwGRQCe?= =?us-ascii?Q?lHRs0wa98+IpzWGqFiYA5ADJ/1/j7rkvRG5bDHL0OEylYLyzuVfgY/ZNW5LX?= =?us-ascii?Q?IGj6g6lSojRz6x9hSk8EUd00/rKFXewNgp3yo3QN2M+YxbZKZpY5DemT253u?= =?us-ascii?Q?yw+hyklbGJU/p4H0b8xQPCNvdvFcW72JPGl6Ng9FssDskAvjegcxKz3BSpAU?= =?us-ascii?Q?E251mYnLVa8kAlBQiwYaf3/5HtTqWnPTLCNT39FNq+NzeUltZgzqbBKixUzq?= =?us-ascii?Q?jvata6nWIp6Tb5qHWTxbxJ04lkc87OCDdc3vYJeMT0J6MWkB6pFkXAFft6Fc?= =?us-ascii?Q?Mz8m91rIy9Kp2dBkiBkozdCnPeXyKlVXOE44KjoDhAdGDi48RexwfsCsHurF?= =?us-ascii?Q?5pNQZA//i6c9YO8xfkPI0U0VleiZgce2+b/B0YlZ/XsWEdZ77Ml7h6OdhdQC?= =?us-ascii?Q?+UTGcGE8Bv4Du/0sAASH790P7ZEOOHA6gngrYCn6T2wUzPydk7xwdIbaPwFm?= =?us-ascii?Q?g07gFfIGFJauMHr3aFCGigJAll0n5ExOALI3eEPpmFbZfMIEbKrWLH6XYYqC?= =?us-ascii?Q?U/2onJY3FaPAluwg8Xp+VBd5xqh7piyQGsYIEWTqjWTBY4yut8xHTLsgzcQa?= =?us-ascii?Q?GVcMwAYCg1QtobgpkTWf1SGOnaDO5xgJeQV0+V8fD16hU16RrAHvbtj4irx1?= =?us-ascii?Q?lO2pFf21BNdSneMcFFhd0D+XK6rG3FPntOZpa3toeIPMuY6+LcZETuZNU9fx?= =?us-ascii?Q?GpzREQtSGgKfauXsT1SWLiLtf/5NqxowKxsDeGGGGiB85vhuYl6kNlP94yYA?= =?us-ascii?Q?jythfqEOw2ljdExqmkRC7j7oWGNS0PDnxpO0wefTriQdit+NbIrVnzXfvDnB?= =?us-ascii?Q?HsNh7mar/+2YvhK1BdYkFE/fIHcWZekereGp7BK22/3/iNhzaKq3SLqk9pRD?= =?us-ascii?Q?6lWhc+gHa8orw4Xh0WtCBinVKIrGiQ9qlIwJn4gRpABeBlP/1OTMaMLJMI21?= =?us-ascii?Q?eCnGqcGvKI/r9MVN1cN1HVEH8i6I2z8V7G9J?= X-Forefront-Antispam-Report: CIP:165.204.84.17;CTRY:US;LANG:en;SCL:1;SRV:;IPV:CAL;SFV:NSPM;H:SATLEXMB04.amd.com;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(13230040)(7416014)(376014)(1800799024)(82310400026)(36860700013);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 15 May 2025 22:53:28.5397 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 6daf80c9-ff18-48f5-61c7-08dd94034ee3 X-MS-Exchange-CrossTenant-Id: 3dd8961f-e488-4e60-8e11-a82d994e183d X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=3dd8961f-e488-4e60-8e11-a82d994e183d;Ip=[165.204.84.17];Helo=[SATLEXMB04.amd.com] X-MS-Exchange-CrossTenant-AuthSource: BN1PEPF0000467F.namprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: CY5PR12MB6479 Content-Type: text/plain; charset="utf-8" The mbm_cntr_assign mode provides an option to the user to assign a counter to an RMID, event pair and monitor the bandwidth as long as the counter is assigned. Number of assignments depend on number of monitoring counters available. Create 'num_mbm_cntrs' resctrl file that displays the number of monitoring counters supported in each domain. 'num_mbm_cntrs' is only visible to user space when the system supports mbm_cntr_assign mode. Signed-off-by: Babu Moger --- v13: Updated the changelog. Added fflags RFTYPE_RES_CACHE to the file num_mbm_cntrs. Replaced seq_puts from seq_putc where applicable. Resolved conflicts caused by the recent FS/ARCH code restructure. The files monitor.c/rdtgroup.c have been split between FS and ARCH dir= ectories. v12: Changed the code to display the max supported monitoring counters in each domain. Also updated the documentation. Resolved the conflict with the latest code. v11: Renamed rdtgroup_num_mbm_cntrs_show() to resctrl_num_mbm_cntrs_show(). Few monor text updates. v10: No changes. v9: Updated user document based on the comments. Will add a new file available_mbm_cntrs later in the series. v8: Commit message update and documentation update. v7: Minor commit log text changes. v6: No changes. v5: Changed the display name from num_cntrs to num_mbm_cntrs. Updated the commit message. Moved the patch after mbm_mode is introduced. v4: Changed the counter name to num_cntrs. And few text changes. v3: Changed the field name to mbm_assign_cntrs. v2: Changed the field name to mbm_assignable_counters from abmc_counter. --- Documentation/filesystems/resctrl.rst | 11 ++++++++++ fs/resctrl/monitor.c | 4 ++++ fs/resctrl/rdtgroup.c | 30 +++++++++++++++++++++++++++ 3 files changed, 45 insertions(+) diff --git a/Documentation/filesystems/resctrl.rst b/Documentation/filesyst= ems/resctrl.rst index 8013418b6ca2..abbbbdf61062 100644 --- a/Documentation/filesystems/resctrl.rst +++ b/Documentation/filesystems/resctrl.rst @@ -284,6 +284,17 @@ with the following files: counters. This can result in misleading values or display "Unavailable" if no counter is assigned to the event. =20 +"num_mbm_cntrs": + The maximum number of monitoring counters (total of available and assigned + counters) in each domain when the system supports mbm_cntr_assign mode. + + For example, on a system with maximum of 32 memory bandwidth monitoring + counters in each of its L3 domains: + :: + + # cat /sys/fs/resctrl/info/L3_MON/num_mbm_cntrs + 0=3D32;1=3D32 + "max_threshold_occupancy": Read/write file provides the largest value (in bytes) at which a previously used LLC_occupancy diff --git a/fs/resctrl/monitor.c b/fs/resctrl/monitor.c index 6ffa9d14a8b4..039516cf410d 100644 --- a/fs/resctrl/monitor.c +++ b/fs/resctrl/monitor.c @@ -918,6 +918,10 @@ int resctrl_mon_resource_init(void) else if (resctrl_arch_is_mbm_total_enabled()) mba_mbps_default_event =3D QOS_L3_MBM_TOTAL_EVENT_ID; =20 + if (r->mon.mbm_cntr_assignable) + resctrl_file_fflags_init("num_mbm_cntrs", + RFTYPE_MON_INFO | RFTYPE_RES_CACHE); + return 0; } =20 diff --git a/fs/resctrl/rdtgroup.c b/fs/resctrl/rdtgroup.c index a9e1055df75f..51f8f8d3ccbc 100644 --- a/fs/resctrl/rdtgroup.c +++ b/fs/resctrl/rdtgroup.c @@ -1831,6 +1831,30 @@ static int resctrl_mbm_assign_mode_show(struct kernf= s_open_file *of, return 0; } =20 +static int resctrl_num_mbm_cntrs_show(struct kernfs_open_file *of, + struct seq_file *s, void *v) +{ + struct rdt_resource *r =3D rdt_kn_parent_priv(of->kn); + struct rdt_mon_domain *dom; + bool sep =3D false; + + cpus_read_lock(); + mutex_lock(&rdtgroup_mutex); + + list_for_each_entry(dom, &r->mon_domains, hdr.list) { + if (sep) + seq_putc(s, ';'); + + seq_printf(s, "%d=3D%d", dom->hdr.id, r->mon.num_mbm_cntrs); + sep =3D true; + } + seq_putc(s, '\n'); + + mutex_unlock(&rdtgroup_mutex); + cpus_read_unlock(); + return 0; +} + /* rdtgroup information files for one cache resource. */ static struct rftype res_common_files[] =3D { { @@ -1868,6 +1892,12 @@ static struct rftype res_common_files[] =3D { .seq_show =3D rdt_default_ctrl_show, .fflags =3D RFTYPE_CTRL_INFO | RFTYPE_RES_CACHE, }, + { + .name =3D "num_mbm_cntrs", + .mode =3D 0444, + .kf_ops =3D &rdtgroup_kf_single_ops, + .seq_show =3D resctrl_num_mbm_cntrs_show, + }, { .name =3D "min_cbm_bits", .mode =3D 0444, --=20 2.34.1 From nobody Sun Dec 14 02:00:56 2025 Received: from NAM04-DM6-obe.outbound.protection.outlook.com (mail-dm6nam04on2083.outbound.protection.outlook.com [40.107.102.83]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id AD6DB297120; Thu, 15 May 2025 22:53:43 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.102.83 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1747349625; cv=fail; b=BsQpVTL7d4IsMwvEThhUXAqKI60qFooPpCt06B57L9/AvJc4p7/YtDtWdCqrSskim+kkFoMBqHYP2r4XAzIfeVcw6SMTjK4L7MYgcZr5mtcKaHWMGFZzVj1n1em14w6T98Vsr+R+N6MdfCBZ6Lwl5VSdXdvJhCwioRV5E7Hia7Y= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1747349625; c=relaxed/simple; bh=lCpWmcOSIMoylaUrG861vxvoCWyW3ckFa8a3nC9FAys=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=BFYU87v77MeiMvMvtK24FLNFzJSH3Qn8xH4a2t3RftonMzHfEtVS6U69/aBkASv5E9m8AqeflJrby2pwEqSfQ9gvxQqJtgGdIbp2giXevXA3cuSGROMh+oN1TMN3WM6kiUCLkv0NZVNUh9AXlVtsw2JIXUg24xHieyl5jknIAjk= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=amd.com; spf=fail smtp.mailfrom=amd.com; dkim=pass (1024-bit key) header.d=amd.com header.i=@amd.com header.b=TEzWCAZg; arc=fail smtp.client-ip=40.107.102.83 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=amd.com Authentication-Results: smtp.subspace.kernel.org; spf=fail smtp.mailfrom=amd.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=amd.com header.i=@amd.com header.b="TEzWCAZg" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=d/Rv4prdejDhdNSp8ODJEC2xGa39nGcnYurV6f4ODIHChKxOirXqmSgpvLsVfbRFYSLGBJ4XUpG3P2sj0CfFdVbVywD6ZWaTUfBylnRtdoTEyBRMCgxOc4hTVCEr9PZGZvwgIPbhXhs1n21zqpq+Ps7m9TL5988swxJV66A2atVh4K4MTCX8D4M0f572FXr23/IAo3oRYQXW4FOgJwqXDg8nh7D8O56ccMj6yZJJMtWLz+UlbwvptOgqwdWL2DMmXVYXb+duKLQCmlOiY+ntaG2lMBt5M6GXgxxOcAhbV9uZkU/0TrH2hlggdGU6n79NfAIzR6IHrWz7dUw9fEj6lA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=+nnDyUw5rhvujopGdCGQd5mtcqP159MB3DfCoHUXBYc=; b=OeNtqIN//w09owWjd214zxF2UUq91AklWNOk2v+OMoQBz7fAOB1tKIbDsLO2zSK2/AhJ/1VaJqW3BXj9k0kUa1efrTLU7GtnjajHQj+nYemBSDQho1HtYVyy/Y3/UiHpsOTX41xPWCSjRWYFDtxt1AnpdGLYE1ZBLNaM5kwBjqt1NpX2wVgQE/ZoMRO/eUXuOTSs26pXkAWcr60If3FWK98WmvsWW5vrNkwBk9fherwf2Tv8yzMrt+7+xPJ4x+u4Xk56PtymTSZPsEnCeIIHgDYmfZEb9/3xQVTMqR6CnHiSQAPFlBbLkjOJnVYWltnXE/MwjkicG5Ew25jbRtK5eg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=lwn.net smtp.mailfrom=amd.com; dmarc=pass (p=quarantine sp=quarantine pct=100) action=none header.from=amd.com; dkim=none (message not signed); arc=none (0) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amd.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=+nnDyUw5rhvujopGdCGQd5mtcqP159MB3DfCoHUXBYc=; b=TEzWCAZgtqLp+T9+3DdyjpFvLmAzdkiQ8d+yjlFrW7kOBBgtomvcUK1bM4jLzukzDyP4M9dU3OPYhtB6zMz4bTbY4MfxpYeh6SU75VTSJxxLJl1g8SjcylBAgMTOk3pXps4MwFCPFHgfxpTmMHC58TL6cejZDrLUrp4mCsKs2Lw= Received: from BLAP220CA0009.NAMP220.PROD.OUTLOOK.COM (2603:10b6:208:32c::14) by MN0PR12MB6175.namprd12.prod.outlook.com (2603:10b6:208:3c4::19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8722.30; Thu, 15 May 2025 22:53:39 +0000 Received: from BN2PEPF0000449E.namprd02.prod.outlook.com (2603:10b6:208:32c:cafe::8f) by BLAP220CA0009.outlook.office365.com (2603:10b6:208:32c::14) with Microsoft SMTP Server (version=TLS1_3, cipher=TLS_AES_256_GCM_SHA384) id 15.20.8722.30 via Frontend Transport; Thu, 15 May 2025 22:53:39 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 165.204.84.17) smtp.mailfrom=amd.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=amd.com; Received-SPF: Pass (protection.outlook.com: domain of amd.com designates 165.204.84.17 as permitted sender) receiver=protection.outlook.com; client-ip=165.204.84.17; helo=SATLEXMB04.amd.com; pr=C Received: from SATLEXMB04.amd.com (165.204.84.17) by BN2PEPF0000449E.mail.protection.outlook.com (10.167.243.149) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.8722.18 via Frontend Transport; Thu, 15 May 2025 22:53:38 +0000 Received: from bmoger-ubuntu.amd.com (10.180.168.240) by SATLEXMB04.amd.com (10.181.40.145) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.39; Thu, 15 May 2025 17:53:35 -0500 From: Babu Moger To: , , , , , , CC: , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , Subject: [PATCH v13 08/27] x86/resctrl: Introduce mbm_cntr_cfg to track assignable counters at domain Date: Thu, 15 May 2025 17:51:53 -0500 Message-ID: <79efa13654a6f1a308622bd13e0d2bc21ffb4367.1747349530.git.babu.moger@amd.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: References: Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-ClientProxiedBy: SATLEXMB04.amd.com (10.181.40.145) To SATLEXMB04.amd.com (10.181.40.145) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: BN2PEPF0000449E:EE_|MN0PR12MB6175:EE_ X-MS-Office365-Filtering-Correlation-Id: 3d4c0216-8177-41a5-be05-08dd940354ed X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|82310400026|376014|36860700013|1800799024|7416014; X-Microsoft-Antispam-Message-Info: =?us-ascii?Q?bb+ObrrZlNO6dGNiG3q1CQVkYK6YKUmzMUT5TlVNwhlKp09ET1xPppO8SZCM?= =?us-ascii?Q?CLAQYD6ZjJOgT5TnK+9++7WRCg92vokml5R6R9lw6DlJrASJoTOQhjH/gRhR?= =?us-ascii?Q?n2CLlU0wiIA8scRX3Z7a58tWNxi0oIguLYtluHCGVsnQdi/Rx7RbqLRpk22s?= =?us-ascii?Q?xo57D5FKRFdSoJwEwglowP8/Gxo3eTI1lNYKBA1rUOcnfebatDtRPVEr4Ykn?= =?us-ascii?Q?hnRAEwXWbpB8c9n78gnjpx6C8A6aB7z/kesaXZMh91fXOWgS4hnxws3KfEy5?= =?us-ascii?Q?pTDHauuB4VgekW74i9YSqEdtQj9m1guJjJFnL18Gx0MuiQf6Dx0eNaVdR1DV?= =?us-ascii?Q?b4kgNRQ6V4BAEFej+8bNSknk/DcuQ7GA7yy+Rag7yOiTcNXmLi+2v2GicKdd?= =?us-ascii?Q?aqV8PgrxPisWEpXE52aCCSLI0+lK9Y8lIieMEvXrUz2Jp/kjNcn3Wyz7pfD3?= =?us-ascii?Q?0DBpQN4OY9Ry1mxsERvnO2OuBNkQSZ7PVsCty2KXRz/pH82N8R1lGmtE9CmM?= =?us-ascii?Q?ZzxFm4cB2Z8uFNaei3E8Ynud1eMuD1oaRMJ2q24p1XT81rcuqrbVKf45zqv8?= =?us-ascii?Q?umCkeMhqU3vrfz7dqHNU0xrPre9gXEXLSolIpSQO3Qq2iXOPICes8nXXHEUl?= =?us-ascii?Q?w3X1i8nnP6OVyG/9d19/qr6XOvtYzDJbp6OtKbQuVkETsC82v5PEHeNZdYIS?= =?us-ascii?Q?IRE6BYvFE2L6FWLHoFT5suoOHDISlH/fX+jXa9czG1I+SdKfU6rx8lcglMGJ?= =?us-ascii?Q?U6OG2jvUduar5GOVgoEQnHqP+A1SmjgVIX8gg2Glcd50XKG+lRP8GBu3fzQ1?= =?us-ascii?Q?NPNPbLcQulG1SaBjhIE39Rd0HU51dyP7nFjnjJwuX2UD9UGf5hZGoC2kZX/p?= =?us-ascii?Q?f8gCZFJnEsK8N26UxHJT+CEVkVMdEKrrrqUIHm1iEOTgjfggndver5DvyORV?= =?us-ascii?Q?goi9COJOFQz4QSwii2s3hCGJnOvn0D83yKx9zJ7aYKVTVwf3+b5L11uXZ3q/?= =?us-ascii?Q?Z12frahhKpULldqLVqsyzf1KyXn5PdWyPMMnSGZVjoN43cA5hFW5RsuhboUq?= =?us-ascii?Q?5Tyh3Zh2PGaI+0gupTme2WhTC4TVt8p3yGOeCVLOUQzN+s8cj9edKH6UAugA?= =?us-ascii?Q?PiZ8WYDHTimTaKF0Qo5bj/9nfBFrFOaGRHQxSQAIR7VM/zVH1NI/EK3K2oMq?= =?us-ascii?Q?ghAjohyf8Nha31Tw4EUScaIm1tAuLTa2rw1hwKBUPF4X8kR1wvxf9jy8UdKz?= =?us-ascii?Q?wYbEnbMS62XzydrH6X146wx9WTzv0Su7++KqxgSXFVDNeseW8Nto+JxEMYXh?= =?us-ascii?Q?2QroHRq6izLK2ixPmji6TlXiQyI1sGrKbP7BNbvh61zKE/0XrqK5ewW3AXTG?= =?us-ascii?Q?ZLRmx5NOKit0Bc1fhtwV+Siey+SDJwM63zkbtvNjYVN11qMsUR6ZW2LShZQU?= =?us-ascii?Q?wBs/Ld+Cn+Ie5eBN1fHdgFFg3cnOMEhi0GgssYgegZFy/98E3qkHpc77FXYc?= =?us-ascii?Q?yNPZjR7AZrdfhBXM7OA0ScoOZxOaRMw6cmnUCWPy4JLZ2xzz8eb061ojRA?= =?us-ascii?Q?=3D=3D?= X-Forefront-Antispam-Report: CIP:165.204.84.17;CTRY:US;LANG:en;SCL:1;SRV:;IPV:CAL;SFV:NSPM;H:SATLEXMB04.amd.com;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(13230040)(82310400026)(376014)(36860700013)(1800799024)(7416014);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 15 May 2025 22:53:38.6739 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 3d4c0216-8177-41a5-be05-08dd940354ed X-MS-Exchange-CrossTenant-Id: 3dd8961f-e488-4e60-8e11-a82d994e183d X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=3dd8961f-e488-4e60-8e11-a82d994e183d;Ip=[165.204.84.17];Helo=[SATLEXMB04.amd.com] X-MS-Exchange-CrossTenant-AuthSource: BN2PEPF0000449E.namprd02.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: MN0PR12MB6175 Content-Type: text/plain; charset="utf-8" In mbm_cntr_assign mode hardware counters are assigned/unassigned to an MBM event of a monitor group. Hardware counters are assigned/unassigned at monitoring domain level. Manage a monitoring domain's hardware counters using a per monitoring domain array of struct mbm_cntr_cfg that is indexed by the hardware counter ID. A hardware counter's configuration contains the MBM event ID and points to the monitoring group that it is assigned to, with a NULL pointer meaning that the hardware counter is available for assignment. There is no direct way to determine which hardware counters are assigned to a particular monitoring group. Check every entry of every hardware counter configuration array in every monitoring domain to query which MBM events of a monitoring group is tracked by hardware. Such queries are acceptable because of a very small number of assignable counters (32 to 64). Suggested-by: Peter Newman Signed-off-by: Babu Moger --- v13: Resolved conflicts caused by the recent FS/ARCH code restructure. The files monitor.c/rdtgroup.c have been split between FS and ARCH dir= ectories. v12: Fixed the struct mbm_cntr_cfg code documentation. Removed few strange charactors in changelog. Added the counter range for better understanding. Moved the struct mbm_cntr_cfg definition to resctrl/internal.h as suggested by James. v11: Refined the change log based on Reinette's feedback. Fixed few style issues. v10: Patch changed completely to handle the counters at domain level. https://lore.kernel.org/lkml/CALPaoCj+zWq1vkHVbXYP0znJbe6Ke3PXPWjtri5A= FgD9cQDCUg@mail.gmail.com/ Removed Reviewed-by tag. Did not see the need to add cntr_id in mbm_state structure. Not used i= n the code. v9: Added Reviewed-by tag. No other changes. v8: Minor commit message changes. v7: Added check mbm_cntr_assignable for allocating bitmap mbm_cntr_map v6: New patch to add domain level assignment. --- fs/resctrl/rdtgroup.c | 11 +++++++++++ include/linux/resctrl.h | 16 ++++++++++++++++ 2 files changed, 27 insertions(+) diff --git a/fs/resctrl/rdtgroup.c b/fs/resctrl/rdtgroup.c index 51f8f8d3ccbc..e2005fc9acd9 100644 --- a/fs/resctrl/rdtgroup.c +++ b/fs/resctrl/rdtgroup.c @@ -4085,6 +4085,7 @@ static void rdtgroup_setup_default(void) =20 static void domain_destroy_mon_state(struct rdt_mon_domain *d) { + kfree(d->cntr_cfg); bitmap_free(d->rmid_busy_llc); kfree(d->mbm_total); kfree(d->mbm_local); @@ -4171,6 +4172,16 @@ static int domain_setup_mon_state(struct rdt_resourc= e *r, struct rdt_mon_domain return -ENOMEM; } } + if (resctrl_is_mbm_enabled() && r->mon.mbm_cntr_assignable) { + tsize =3D sizeof(*d->cntr_cfg); + d->cntr_cfg =3D kcalloc(r->mon.num_mbm_cntrs, tsize, GFP_KERNEL); + if (!d->cntr_cfg) { + bitmap_free(d->rmid_busy_llc); + kfree(d->mbm_total); + kfree(d->mbm_local); + return -ENOMEM; + } + } =20 return 0; } diff --git a/include/linux/resctrl.h b/include/linux/resctrl.h index bdb264875ef6..d77981d1fcb9 100644 --- a/include/linux/resctrl.h +++ b/include/linux/resctrl.h @@ -156,6 +156,20 @@ struct rdt_ctrl_domain { u32 *mbps_val; }; =20 +/** + * struct mbm_cntr_cfg - Assignable counter configuration + * @evtid: MBM event to which the counter is assigned. Only valid + * if @rdtgroup is not NULL. + * @evt_cfg: Event configuration value. + * @rdtgrp: resctrl group assigned to the counter. NULL if the + * counter is free. + */ +struct mbm_cntr_cfg { + enum resctrl_event_id evtid; + u32 evt_cfg; + struct rdtgroup *rdtgrp; +}; + /** * struct rdt_mon_domain - group of CPUs sharing a resctrl monitor resource * @hdr: common header for different domain types @@ -167,6 +181,7 @@ struct rdt_ctrl_domain { * @cqm_limbo: worker to periodically read CQM h/w counters * @mbm_work_cpu: worker CPU for MBM h/w counters * @cqm_work_cpu: worker CPU for CQM h/w counters + * @cntr_cfg: assignable counters configuration */ struct rdt_mon_domain { struct rdt_domain_hdr hdr; @@ -178,6 +193,7 @@ struct rdt_mon_domain { struct delayed_work cqm_limbo; int mbm_work_cpu; int cqm_work_cpu; + struct mbm_cntr_cfg *cntr_cfg; }; =20 /** --=20 2.34.1 From nobody Sun Dec 14 02:00:56 2025 Received: from NAM12-DM6-obe.outbound.protection.outlook.com (mail-dm6nam12on2045.outbound.protection.outlook.com [40.107.243.45]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 62AFC293725; Thu, 15 May 2025 22:53:53 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.243.45 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1747349636; cv=fail; b=ERCeK/Qz8OFj9cIrMt5StWxoGleyK6O+ucCRFhwidDcplP0zdUzryJ2/6XVqszA3mYTT7Xhvo61Mplvtw7NQ+1HQaiz1aD/v9auUwYL1Lvls3vzRuN2WDQKIbSYmkI1rbQd3J6u48N0bgwRb32SJnBpM490kpi4PUK3NnsnMsc8= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1747349636; c=relaxed/simple; bh=tF/J9L8tzhpjpQZZqDo7R+/Z78ikF2AeLRRdMpLKZNU=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=YRTmRI0lmQk6jvPBHLVC1QelUOyPT8GEg8rNDgyk44jWYvHAicn1KwBg3jb4lsGSsvZldi/zIZa6lthkgXNphf1VRuj4UiUQB6aLBB5mYVuocqdUcijmYuqkfmzPpTd7aJN2dxt+6L9Ldz2NUsfrYRaPJxyU/1Oq3ETgAtx7HaU= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=amd.com; spf=fail smtp.mailfrom=amd.com; dkim=pass (1024-bit key) header.d=amd.com header.i=@amd.com header.b=qaiwAeb2; arc=fail smtp.client-ip=40.107.243.45 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=amd.com Authentication-Results: smtp.subspace.kernel.org; spf=fail smtp.mailfrom=amd.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=amd.com header.i=@amd.com header.b="qaiwAeb2" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=O7YKuuh2EkkhMjrTc9Etc0/D6FGohch7MsOwSpznpJcStiwSfZXjrBMy7zopEpJ3KE7WuMw1pv7zWNAHdMGdnfKWJT2zc4mjV3uQHH4eqI3Km92v790YFtyd7SHCcaEpSNAtE3OJLN18ZIeTYCe27QgYCyNGIxWHqpym8pfVjc6mYHOu48dUXgK5r3O6Vnp7p00l+XbciSyyJJGhS+JTtORHK8KckMx0xsrolI4HNarWHF7ppG72Fpgc/jVht4emcUWO99JKyFhxJGf0Sw/4q5RYHE5CYGwPoOFvGrpqDzwSo4MCva5EbIVYZEMD3Ym6yaCfRFU50KAvmGXF+j1iJA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=211ip/OWPS/dFpl9CAynwjK1FupVsst57iYzL5gRdTo=; b=VZW7/qVQ0wIoxEjtVCOHKdLWIs6PXTQjNwzpKHI5RFduqDJ4TPW164ebyV9PfQBT1Z3bXdjbiNTzxnXP+EkQ2QDshXQHDHxcEjoHAQyjJWNeCYmp5KNsxLa5BAYb5/3sO9QcsruaW1HaOrB6/zzGG5e9usfMXmRd3us3Qqqyn0iwAXcUkEwX6rjs8rFTlQcSgyuf9JRss+RKGCN0R0cNi0rvPhxC7thZDbSZ0lHcpcE7BIl7AzYpq+6Z5eD/w+GoMiXOh5c6291k+g5DRjAXjk+4V9AXOF7ao9Sywfv77OKHMIFFAwI5JvIo4lFxQD3DCT2Wmy8fHBnyUUSkP8jIWg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=lwn.net smtp.mailfrom=amd.com; dmarc=pass (p=quarantine sp=quarantine pct=100) action=none header.from=amd.com; dkim=none (message not signed); arc=none (0) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amd.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=211ip/OWPS/dFpl9CAynwjK1FupVsst57iYzL5gRdTo=; b=qaiwAeb2XsWCZ/Iz8+hE9YYpFw8bLe86XTWYjMhTbQ7Z1z56lnqhohAlg6Vjk2+rYEcYPY9ONVPSLmHfiA2QNNO4L7pLjOapBDAgLbxaFBBSdtYlOcRkJiKYOp8e6FZzmpEj02iLPEBWSGUCri6KHfiLgCFpFrNiM6tXz4m36Ws= Received: from BN8PR12CA0019.namprd12.prod.outlook.com (2603:10b6:408:60::32) by SJ0PR12MB8140.namprd12.prod.outlook.com (2603:10b6:a03:4e3::7) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8722.29; Thu, 15 May 2025 22:53:49 +0000 Received: from BN2PEPF000044A3.namprd02.prod.outlook.com (2603:10b6:408:60:cafe::70) by BN8PR12CA0019.outlook.office365.com (2603:10b6:408:60::32) with Microsoft SMTP Server (version=TLS1_3, cipher=TLS_AES_256_GCM_SHA384) id 15.20.8699.33 via Frontend Transport; Thu, 15 May 2025 22:53:49 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 165.204.84.17) smtp.mailfrom=amd.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=amd.com; Received-SPF: Pass (protection.outlook.com: domain of amd.com designates 165.204.84.17 as permitted sender) receiver=protection.outlook.com; client-ip=165.204.84.17; helo=SATLEXMB04.amd.com; pr=C Received: from SATLEXMB04.amd.com (165.204.84.17) by BN2PEPF000044A3.mail.protection.outlook.com (10.167.243.154) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.8722.18 via Frontend Transport; Thu, 15 May 2025 22:53:48 +0000 Received: from bmoger-ubuntu.amd.com (10.180.168.240) by SATLEXMB04.amd.com (10.181.40.145) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.39; Thu, 15 May 2025 17:53:44 -0500 From: Babu Moger To: , , , , , , CC: , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , Subject: [PATCH v13 09/27] x86/resctrl: Introduce interface to display number of free MBM counters Date: Thu, 15 May 2025 17:51:54 -0500 Message-ID: X-Mailer: git-send-email 2.34.1 In-Reply-To: References: Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-ClientProxiedBy: SATLEXMB04.amd.com (10.181.40.145) To SATLEXMB04.amd.com (10.181.40.145) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: BN2PEPF000044A3:EE_|SJ0PR12MB8140:EE_ X-MS-Office365-Filtering-Correlation-Id: dc8afa50-37ea-4b38-ae01-08dd94035ad1 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|82310400026|36860700013|1800799024|376014|7416014; X-Microsoft-Antispam-Message-Info: =?us-ascii?Q?IlEvQnHCSMnptKuO/+9xQVgpk0DJRF98d0qTroz+Tl4yKWnTfiBrF1rQq0Gu?= =?us-ascii?Q?SWDLZ08qTeZnHzm70gFID6KA7zgS2jukIqaUXoChSx/hKs6KnPDgGTp5AHVS?= =?us-ascii?Q?tPjqxlgp2VP8HXJLBozn0Q8A6Tck5tUvtqdLfcpJZiMGoFUnlChoy0u6quEA?= =?us-ascii?Q?lN9cE1vE0CVm78pndji3/aQkYoH/KFmd80VYVhppcTP60ZrYYu+dg58zs3fk?= =?us-ascii?Q?B/FMeBZbzLgk4I3rcnQ0ppNfsgB0aCah0VPt7YvjCpZNyKWTxGOm9ku7+OdD?= =?us-ascii?Q?BzTtsu1tXiM1HkjuzVfo/nAmkGk1NS2+0T9MUFJHv8+dbIx/6GcmE+PyG4ui?= =?us-ascii?Q?vfS1FsuSRgnGA0YDsaMqGzDA/C1/SDYMK9QgzYAt5OIgmP9WX4BTBDG9YlzO?= =?us-ascii?Q?2mqMNKBgeGJGgbVOroC6GeTmJZbltvnZMEkUCWNGaJxkVDR9Y4x8fVaBP9cP?= =?us-ascii?Q?oUZS0JiYktonD3KlxFx2BygyWhpWvyaRRemdodLscCuWE3Y2I12tyNzmPjxI?= =?us-ascii?Q?RAI8eARvUphKgF9QSPsnxXA77dEamF8LW6Wk3CK5h1tri84JJ4ATvhKrDX4A?= =?us-ascii?Q?3fZ2DWqIWtBzdoy6PsDMA70QFASrdAG5UPHBXgUZQ1K0Khkinftd9x1edfoX?= =?us-ascii?Q?naGNKbnqVVH7COW53QaPtK1aKfx0PD00iRTScDeJ7Vpaf1lTjljn4lP1Xwze?= =?us-ascii?Q?HAadkaNds3oIe+MSmKQx7kE9siALruLFFYCmEdiGXJQwSPLmuqdpgwC05DgP?= =?us-ascii?Q?vBx/NL/tYWcYBaq3gnRRuG96grPhpSzFU1k25KwmHt8mg1MPu1XnXu8vPUQK?= =?us-ascii?Q?3ZzgSufXWc5WKhSOE+GJqs4DLgcuNKbL+FEYi+SZ4Y7QDKNX/joNoMJU21+r?= =?us-ascii?Q?x9ryjlc4tc2fOwKVV0UfzrpONEeinOgL/TCzCB02Kb39VYfVLHkED1iIGUPh?= =?us-ascii?Q?+/1Myd8oPcRHyueWG/GtAB81qdd+EhAe+agrzzcfskizh9+lfh+RasUe9wXl?= =?us-ascii?Q?mLBCApq/1lt4xQ2NTb6Gy5bfZiH1Ga77fT8QvoP5fWWUMB0m8HC4GKWq5zQI?= =?us-ascii?Q?gLGLHwm9xbIuM1DZlGHnAZg2f1nBYgzcWRxxQvA3LJvhSqj03+amUnewHMW6?= =?us-ascii?Q?vFzmdpBO9k6GK086Fw9D4NVaDLv3nYbW27H1bfrlZPe4iXXl4WVnqghkbSvj?= =?us-ascii?Q?zSSHjpLPQMv8nLmA6o7BgLmKWEgMYbN/TUKf3gB+izlPPTwvnY4tDpZhg/3r?= =?us-ascii?Q?SQx3HVxFFncwgC7u3D43PxZnlu3eBA1Cze/qggDoCzLKPG2r1w+yJGzQDgss?= =?us-ascii?Q?PdAVagpR4Q5wiY2dFqm9UzZ+KjxPxv/CjjUTIw+e4Xy+eYALyPwmvxhflNZ9?= =?us-ascii?Q?QnLfxXWlGAMA2QwRag9nxhtEUtnCns3qavd3Vn+BfjbTwCMHIZAlXuRNTDdR?= =?us-ascii?Q?CLsx8laPcfSt/On/ld8RXRAsTXMnX/smdLN2tIOruzqDcvcIfaDKTf80cb+s?= =?us-ascii?Q?+19NSZZApatYdZUBTLnIfGLHSSdEz2WSyYoTJztLiPCVuEy8C1lh0fJgHQ?= =?us-ascii?Q?=3D=3D?= X-Forefront-Antispam-Report: CIP:165.204.84.17;CTRY:US;LANG:en;SCL:1;SRV:;IPV:CAL;SFV:NSPM;H:SATLEXMB04.amd.com;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(13230040)(82310400026)(36860700013)(1800799024)(376014)(7416014);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 15 May 2025 22:53:48.5552 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: dc8afa50-37ea-4b38-ae01-08dd94035ad1 X-MS-Exchange-CrossTenant-Id: 3dd8961f-e488-4e60-8e11-a82d994e183d X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=3dd8961f-e488-4e60-8e11-a82d994e183d;Ip=[165.204.84.17];Helo=[SATLEXMB04.amd.com] X-MS-Exchange-CrossTenant-AuthSource: BN2PEPF000044A3.namprd02.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: SJ0PR12MB8140 Content-Type: text/plain; charset="utf-8" Provide the interface to display the number of monitoring counters available for assignment in each domain when mbm_cntr_assign mode is enabled. Signed-off-by: Babu Moger --- v13: Resolved conflicts caused by the recent FS/ARCH code restructure. The files monitor.c and rdtgroup.c file has now been split between the FS and ARCH directories. v12: Minor change to change log. Updated the documentation text with an example. Replaced seq_puts(s, ";") with seq_putc(s, ';'); Added missing rdt_last_cmd_clear() in resctrl_available_mbm_cntrs_show= (). v11: Rename rdtgroup_available_mbm_cntrs_show() to resctrl_available_mbm_cn= trs_show(). Few minor text changes. v10: Patch changed to handle the counters at domain level. https://lore.kernel.org/lkml/CALPaoCj+zWq1vkHVbXYP0znJbe6Ke3PXPWjtri5A= FgD9cQDCUg@mail.gmail.com/ So, display logic also changed now. v9: New patch --- Documentation/filesystems/resctrl.rst | 11 ++++++ fs/resctrl/monitor.c | 5 ++- fs/resctrl/rdtgroup.c | 48 +++++++++++++++++++++++++++ 3 files changed, 63 insertions(+), 1 deletion(-) diff --git a/Documentation/filesystems/resctrl.rst b/Documentation/filesyst= ems/resctrl.rst index abbbbdf61062..2bfad43aac9c 100644 --- a/Documentation/filesystems/resctrl.rst +++ b/Documentation/filesystems/resctrl.rst @@ -295,6 +295,17 @@ with the following files: # cat /sys/fs/resctrl/info/L3_MON/num_mbm_cntrs 0=3D32;1=3D32 =20 +"available_mbm_cntrs": + The number of monitoring counters available for assignment in each + domain when mbm_cntr_assign mode is enabled on the system. + + For example, on a system with 30 available [hardware] monitoring counters + in each of its L3 domains: + :: + + # cat /sys/fs/resctrl/info/L3_MON/available_mbm_cntrs + 0=3D30;1=3D30 + "max_threshold_occupancy": Read/write file provides the largest value (in bytes) at which a previously used LLC_occupancy diff --git a/fs/resctrl/monitor.c b/fs/resctrl/monitor.c index 039516cf410d..2548aee0151c 100644 --- a/fs/resctrl/monitor.c +++ b/fs/resctrl/monitor.c @@ -918,9 +918,12 @@ int resctrl_mon_resource_init(void) else if (resctrl_arch_is_mbm_total_enabled()) mba_mbps_default_event =3D QOS_L3_MBM_TOTAL_EVENT_ID; =20 - if (r->mon.mbm_cntr_assignable) + if (r->mon.mbm_cntr_assignable) { resctrl_file_fflags_init("num_mbm_cntrs", RFTYPE_MON_INFO | RFTYPE_RES_CACHE); + resctrl_file_fflags_init("available_mbm_cntrs", + RFTYPE_MON_INFO | RFTYPE_RES_CACHE); + } =20 return 0; } diff --git a/fs/resctrl/rdtgroup.c b/fs/resctrl/rdtgroup.c index e2005fc9acd9..752750e3e443 100644 --- a/fs/resctrl/rdtgroup.c +++ b/fs/resctrl/rdtgroup.c @@ -1855,6 +1855,48 @@ static int resctrl_num_mbm_cntrs_show(struct kernfs_= open_file *of, return 0; } =20 +static int resctrl_available_mbm_cntrs_show(struct kernfs_open_file *of, + struct seq_file *s, void *v) +{ + struct rdt_resource *r =3D rdt_kn_parent_priv(of->kn); + struct rdt_mon_domain *dom; + bool sep =3D false; + u32 cntrs, i; + int ret =3D 0; + + cpus_read_lock(); + mutex_lock(&rdtgroup_mutex); + + rdt_last_cmd_clear(); + + if (!resctrl_arch_mbm_cntr_assign_enabled(r)) { + rdt_last_cmd_puts("mbm_cntr_assign mode is not enabled\n"); + ret =3D -EINVAL; + goto unlock_cntrs_show; + } + + list_for_each_entry(dom, &r->mon_domains, hdr.list) { + if (sep) + seq_putc(s, ';'); + + cntrs =3D 0; + for (i =3D 0; i < r->mon.num_mbm_cntrs; i++) { + if (!dom->cntr_cfg[i].rdtgrp) + cntrs++; + } + + seq_printf(s, "%d=3D%u", dom->hdr.id, cntrs); + sep =3D true; + } + seq_putc(s, '\n'); + +unlock_cntrs_show: + mutex_unlock(&rdtgroup_mutex); + cpus_read_unlock(); + + return ret; +} + /* rdtgroup information files for one cache resource. */ static struct rftype res_common_files[] =3D { { @@ -1878,6 +1920,12 @@ static struct rftype res_common_files[] =3D { .seq_show =3D rdt_mon_features_show, .fflags =3D RFTYPE_MON_INFO, }, + { + .name =3D "available_mbm_cntrs", + .mode =3D 0444, + .kf_ops =3D &rdtgroup_kf_single_ops, + .seq_show =3D resctrl_available_mbm_cntrs_show, + }, { .name =3D "num_rmids", .mode =3D 0444, --=20 2.34.1 From nobody Sun Dec 14 02:00:56 2025 Received: from NAM11-BN8-obe.outbound.protection.outlook.com (mail-bn8nam11on2047.outbound.protection.outlook.com [40.107.236.47]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 08603293725; Thu, 15 May 2025 22:54:01 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.236.47 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1747349643; cv=fail; b=OMEkDaKS4OKJiD1d1IT+oNSZEkibcu8PfTDp1K9ppSVChPSvxy+o5qwpwZDWBPko9x6rl9tm3yVzkCymQFCWOY5/A8aA0V87U+smzETSvsvU/tpzCS+fS3iKk6Vn6NF7LcCnsRmbEOQ74qA0LnYX56ZS+xIoU7J88xSU0PEnT54= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1747349643; c=relaxed/simple; bh=yUuDtlL2sYe+G/uLccQckjUWWZPgK/Z5VhfCOz85ejE=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=Ps27wcdzrFr4bLVp58vYrwdE8sdb8FcaY4GYnrIoaDVW+d3qj/mspjJhzhdf4yglZTXVTeipsOSb3KXvhLtxRozMF0kXMPd3JEpbDSbyhWOwXa2N9FCX+YHxp5GVZmR+dhubNz9G3gXmwRlRuXzgafhB/1pTK6hnhP3/zKVYTBM= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=amd.com; spf=fail smtp.mailfrom=amd.com; dkim=pass (1024-bit key) header.d=amd.com header.i=@amd.com header.b=Lgnmh1iP; arc=fail smtp.client-ip=40.107.236.47 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=amd.com Authentication-Results: smtp.subspace.kernel.org; spf=fail smtp.mailfrom=amd.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=amd.com header.i=@amd.com header.b="Lgnmh1iP" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=ntKT+wAyE31TW7K5Sqg1xcx+Dlc5ovIMQ6pl4JofkKiIbmTHtNgV6wG/V8X1ayp6jVsC15OInViO4Sgee0KLEOFx36zLxgDrS0kIAaPIJEPJ3ZOiadb54VaQUoEQhLLMTOruf0G3hAESWI0nIA2xBE6AHyJrOXsbGd1uSFq5HK+pd69AkW8BilqdpgCwGY3wLfW9JPMScZPj55MEMHMr/d4g9rnyKK8oHGX0XHIUVT6Y0z9+oObqffH+VTmASDmJt8/3/GrFx2HMPmokG7/d48e8zltb2T4WWK+ooE+J/R/l6tIKe9awVV6aoP00wO/u/xzsqf97i4IdY+UCpRirng== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=+HLqapW7lVpWHpZJhR0jaO7dcTA/iR2q3oyNbdM9U/E=; b=zVD8zY6EogN2Myv0rvfpPmZbvB41WRx8xoBkg1UKNfmTUtWeuqFA4jWxeH1MQK+iSEkWxIeR30eM67wokp4F3suRPfd7NsD+YBT7qeyIq2Ol5z6mdRpK0jkpeH4+9GMSLA3UyTvUTwqkGme0WcvLqTfvmSHlXtr1Eu0QwsXo8FOAntbg1nabhih8twTgEWIwFq+3Dg+cac8rci+2OLCxPE+ui3gagqEdFdZEa5i2AOZdOtn8rXOO0wJRCbmfMbgqbtkRrqv2BXojBhzA6Ku1X6iI8MBVZRXGbsgU5afGfEydcjI8wO0y24pSd7uK5XoRuv/zFsuOEBmjFFTkRBuLPQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=lwn.net smtp.mailfrom=amd.com; dmarc=pass (p=quarantine sp=quarantine pct=100) action=none header.from=amd.com; dkim=none (message not signed); arc=none (0) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amd.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=+HLqapW7lVpWHpZJhR0jaO7dcTA/iR2q3oyNbdM9U/E=; b=Lgnmh1iPM9158e2hocuNkcxPiMrhUcU8avibQCQ/vtCqbycpij7ifQTc8qU27IcF0AsuglfeQf4hIJP3rjMGso+mFGZTKuudOt4EhZUPrtvQQlXQS6TEvtH3wtaWW8WA/Avl+8DYhuGE+pkX2ikqadN19KeziSLlfj97At+6M88= Received: from BLAP220CA0001.NAMP220.PROD.OUTLOOK.COM (2603:10b6:208:32c::6) by SN7PR12MB7933.namprd12.prod.outlook.com (2603:10b6:806:342::13) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8722.30; Thu, 15 May 2025 22:53:57 +0000 Received: from BN2PEPF0000449E.namprd02.prod.outlook.com (2603:10b6:208:32c:cafe::95) by BLAP220CA0001.outlook.office365.com (2603:10b6:208:32c::6) with Microsoft SMTP Server (version=TLS1_3, cipher=TLS_AES_256_GCM_SHA384) id 15.20.8746.16 via Frontend Transport; Thu, 15 May 2025 22:53:57 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 165.204.84.17) smtp.mailfrom=amd.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=amd.com; Received-SPF: Pass (protection.outlook.com: domain of amd.com designates 165.204.84.17 as permitted sender) receiver=protection.outlook.com; client-ip=165.204.84.17; helo=SATLEXMB04.amd.com; pr=C Received: from SATLEXMB04.amd.com (165.204.84.17) by BN2PEPF0000449E.mail.protection.outlook.com (10.167.243.149) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.8722.18 via Frontend Transport; Thu, 15 May 2025 22:53:57 +0000 Received: from bmoger-ubuntu.amd.com (10.180.168.240) by SATLEXMB04.amd.com (10.181.40.145) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.39; Thu, 15 May 2025 17:53:54 -0500 From: Babu Moger To: , , , , , , CC: , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , Subject: [PATCH v13 10/27] x86/resctrl: Add data structures and definitions for ABMC assignment Date: Thu, 15 May 2025 17:51:55 -0500 Message-ID: <5fa043432aa1a697b11b0bd5fbd25a778014fb43.1747349530.git.babu.moger@amd.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: References: 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 X-ClientProxiedBy: SATLEXMB04.amd.com (10.181.40.145) To SATLEXMB04.amd.com (10.181.40.145) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: BN2PEPF0000449E:EE_|SN7PR12MB7933:EE_ X-MS-Office365-Filtering-Correlation-Id: 204e2e42-85ef-47fb-74bf-08dd94035ff6 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|36860700013|82310400026|1800799024|376014|7416014; X-Microsoft-Antispam-Message-Info: =?utf-8?B?Rko1QWhsbEo4VW9EcFVuckh6aUNUc1ZMc2V6cVJtSi9ldzFJVUN4NkNjOTlU?= =?utf-8?B?c1I3ZS9wc0h2T1o4cnpXbnJ2eUxpellBc3h0SEs0UkdNdW9BYXB2VFl0U3c2?= =?utf-8?B?L3ZaOGhZVVFLUWgrNGpxNmc2ZWZvdWRoQkdVSmdseGFvUzk0R0N3TFQ1aG5R?= =?utf-8?B?bFRCdW1NamtwTlN3SS80cHlBdFM4T05pRFdsbzF1Q09ZU3BpZklrUHAxeENh?= =?utf-8?B?WWJ1N25SWnJFUU0wTUN2L3NxOEVJVXEyQ2V5U1pBRmNQQ1B1clBlWDVKRmZC?= =?utf-8?B?d0ZUai9FSnlyMW9hT2VoWkR6NDBJT2RoVXZJRTI4RXl4Ny9KWkdHTjdVTW5n?= =?utf-8?B?bldmRlBOSHFjZkNkV2Iya0ZOZ0xISXhPZnd5T1ZsZjZsTndWNGF1Wmx0V0hB?= =?utf-8?B?b0R2cjFUSDUvYjVaYk1US1dpNW1Ga1NNeE5sWXpuKzBsYTJJUlBHbFRYbE1C?= =?utf-8?B?RDU0bVdVbzNHd3VHWTRQV1RJWXhRSEpjRzJRZEVvOFg1ZE1XajloNVA4Q3Y1?= =?utf-8?B?RlkyQU5HaFNUYmQwSnNBSkxpTjR1L0hVeW9xNGs1VVlIazJiME1pMG5XaGJr?= =?utf-8?B?cVNXaVY1dVc4STNHcUxzMjI4NStxUUhFS3RpM2dTY0lmVHQwN0lZSXFQV0Ey?= =?utf-8?B?aUZTTnl0UkM2VTh1emxCVHpqRElta3lncWcyTVlKTHBjeEFERGR5SFNSZU14?= =?utf-8?B?SnF6SkdLWDVHaHE4ZVh2bEswbUlKYWkwZGVoZDZkaHEwcTdhKzE4TlFhaVhr?= =?utf-8?B?cHdKN2ZYZUF0eDBtaWhiNE1ObUN3aDVuWFhjZjI5SXRmMzZUWXdiVHd5c0l2?= =?utf-8?B?Y3VBZ21nNlBScEsvK1RGQm43Mm9QWFk2bktyZXlXVWgza3F1UkR0QVFvL0xx?= =?utf-8?B?NTRpS1NqRW1rWWVsNjAzLytvQkFxeUhQdXZuTVBoWWF5ckJYM1BmNGNSTWNt?= =?utf-8?B?QjhNUWw0anpiRGQ2cWt6dFEyQ1hiTlQwb1BMR2pFZTYwaWtkcU1RbEZwZkYw?= =?utf-8?B?dWdjdDcvbkRYczYxaUR1TmpoVml6TVNLNzVsZWJsMUJwZmVGZHVESDhjeEJu?= =?utf-8?B?WGwwSmwyNUk0ZkN3UXRYNFU2RDRDNkpDUEZZb1hNRmQrQWt3bHpURjFTMXpX?= =?utf-8?B?R3IzU2M1MTEraDRUemtMN1V1MHQ4ekl4MDZHZEIwTTVEN2dpVVR5c2ZHanZl?= =?utf-8?B?NmJvL2V6T3VGdStjcVlHRVBReUFkNTVXNnpBdXFBNUNtRnhVaWo5WjJvd3lm?= =?utf-8?B?NmoyME1jdW40am8yY2pGQTlhS21IOFdJbWZXUUsrcnR3UTYwaU0yTzBWSUg3?= =?utf-8?B?a0pmSUExclJWU3ROTEZadW5xK3NDcTFKRnVBRUJVMkxLcG5MVE9OUHVRcWtT?= =?utf-8?B?UjFva0U0Ymk5NldQbkd1UVpkdG1jYUtUMHpvdXVuYkZLQTdUZzhBK091bjMr?= =?utf-8?B?M0pBQWtuZnlhalBjeHN5cFNDWHZnWXVQZnVRWG9CcWtRRlpua0lZTnJiMDNk?= =?utf-8?B?TFR5Uld4a1ZnYStyRUZ1bXFXZVc2MWVHUVMvd0FXV0ZXdWh3MmpSWTdTVGh0?= =?utf-8?B?bkJpcXA5WEphYm1ZK1hUWFFwUGV1RVc3TDhabHpJUnREZW5yVU8xTzJQREh0?= =?utf-8?B?SGczM3p3SytiSDZWaDN3YUJIUlBSWmtKYnV1TGtlOEw4cWlsVm13bDZiaWg1?= =?utf-8?B?by85RGdqOFlaV3JRNGhHOVgzZ1dMd0x3QUFyYkZVNDRUdGM1YWRRZDdFOGJN?= =?utf-8?B?U3pGQWp5SWJuNHlpWG9kNVpJaTAxMmtPZXlYWW9KNTdDVnRoWlRacTlRSWtt?= =?utf-8?B?REFqRVpGNUZSQk5DNVdWTHRFL3VKOFVEc21FY2NDSUluQU5DeThjb09JOGY0?= =?utf-8?B?Mmd0eVVhZHQrL1MrRm5WTTNNMWhWZ3hDRmViSUkyMnUydXZ1WEVnYXAyVk14?= =?utf-8?B?N1pSYnZmMXlpZnlDalZzWWRpVndiQThnRmpXZUNkbG1pT3NlWXpiT3lIREpy?= =?utf-8?B?K0pySjhrZDJGZUczZnowWnVBMUpCRTcrTzUwdGprQUNZTzRXVDY4RzBxT1Rq?= =?utf-8?B?OGF0cHVVZUNPNkVyV290eGJCdGRuZ3Y5ZVRiQT09?= X-Forefront-Antispam-Report: CIP:165.204.84.17;CTRY:US;LANG:en;SCL:1;SRV:;IPV:CAL;SFV:NSPM;H:SATLEXMB04.amd.com;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(13230040)(36860700013)(82310400026)(1800799024)(376014)(7416014);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 15 May 2025 22:53:57.1839 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 204e2e42-85ef-47fb-74bf-08dd94035ff6 X-MS-Exchange-CrossTenant-Id: 3dd8961f-e488-4e60-8e11-a82d994e183d X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=3dd8961f-e488-4e60-8e11-a82d994e183d;Ip=[165.204.84.17];Helo=[SATLEXMB04.amd.com] X-MS-Exchange-CrossTenant-AuthSource: BN2PEPF0000449E.namprd02.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: SN7PR12MB7933 The ABMC feature provides an option to the user to assign a hardware counter to an RMID, event pair and monitor the bandwidth as long as the counter is assigned. The bandwidth events will be tracked by the hardware until the user changes the configuration. Each resctrl group can configure maximum two counters, one for total event and one for local event. The ABMC feature implements an MSR L3_QOS_ABMC_CFG (C000_03FDh). ABMC counter assignment is done by setting the counter id, bandwidth source (RMID) and bandwidth configuration. Users will have the option to change the bandwidth configuration using resctrl interface which will be introduced later in the series. Attempts to read or write the MSR when ABMC is not enabled will result in a #GP(0) exception. Introduce the data structures and definitions for MSR L3_QOS_ABMC_CFG (0xC000_03FDh): =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D Bits Mnemonic Description Access Reset Type Value =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D 63 CfgEn Configuration Enable R/W 0 62 CtrEn Enable/disable counting R/W 0 61:53 =E2=80=93 Reserved MBZ 0 52:48 CtrID Counter Identifier R/W 0 47 IsCOS BwSrc field is a CLOSID R/W 0 (not an RMID) 46:44 =E2=80=93 Reserved MBZ 0 43:32 BwSrc Bandwidth Source R/W 0 (RMID or CLOSID) 31:0 BwType Bandwidth configuration R/W 0 to track for this counter =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D The feature details are documented in the APM listed below [1]. [1] AMD64 Architecture Programmer's Manual Volume 2: System Programming Publication # 24593 Revision 3.41 section 19.3.3.3 Assignable Bandwidth Monitoring (ABMC). Link: https://bugzilla.kernel.org/show_bug.cgi?id=3D206537 Signed-off-by: Babu Moger --- v13: Removed the Reviewed-by tag as there is commit log change to remove BMEC reference. v12: No changes. v11: No changes. v10: No changes. v9: Removed the references of L3_QOS_ABMC_DSC. Text changes about configuration in kernel doc. v8: Update the configuration notes in kernel_doc. Few commit message update. v7: Removed the reference of L3_QOS_ABMC_DSC as it is not used anymore. Moved the configuration notes to kernel_doc. Adjusted the tabs for l3_qos_abmc_cfg and checkpatch seems happy. v6: Removed all the fs related changes. Added note on CfgEn,CtrEn. Removed the definitions which are not used. Removed cntr_id initialization. v5: Moved assignment flags here (path 10/19 of v4). Added MON_CNTR_UNSET definition to initialize cntr_id's. More details in commit log. Renamed few fields in l3_qos_abmc_cfg for readability. v4: Added more descriptions. Changed the name abmc_ctr_id to ctr_id. Added L3_QOS_ABMC_DSC. Used for reading the configuration. v3: No changes. v2: No changes. --- arch/x86/include/asm/msr-index.h | 1 + arch/x86/kernel/cpu/resctrl/internal.h | 35 ++++++++++++++++++++++++++ 2 files changed, 36 insertions(+) diff --git a/arch/x86/include/asm/msr-index.h b/arch/x86/include/asm/msr-in= dex.h index 3970e0b16e47..b5b5ebead24f 100644 --- a/arch/x86/include/asm/msr-index.h +++ b/arch/x86/include/asm/msr-index.h @@ -1203,6 +1203,7 @@ /* - AMD: */ #define MSR_IA32_MBA_BW_BASE 0xc0000200 #define MSR_IA32_SMBA_BW_BASE 0xc0000280 +#define MSR_IA32_L3_QOS_ABMC_CFG 0xc00003fd #define MSR_IA32_L3_QOS_EXT_CFG 0xc00003ff #define MSR_IA32_EVT_CFG_BASE 0xc0000400 =20 diff --git a/arch/x86/kernel/cpu/resctrl/internal.h b/arch/x86/kernel/cpu/r= esctrl/internal.h index fcc9d23686a1..db6b0c28ee6b 100644 --- a/arch/x86/kernel/cpu/resctrl/internal.h +++ b/arch/x86/kernel/cpu/resctrl/internal.h @@ -164,6 +164,41 @@ union cpuid_0x10_x_edx { unsigned int full; }; =20 +/* + * ABMC counters are configured by writing to L3_QOS_ABMC_CFG. + * @bw_type : Bandwidth configuration (supported by BMEC) + * tracked by the @cntr_id. + * @bw_src : Bandwidth source (RMID or CLOSID). + * @reserved1 : Reserved. + * @is_clos : @bw_src field is a CLOSID (not an RMID). + * @cntr_id : Counter identifier. + * @reserved : Reserved. + * @cntr_en : Counting enable bit. + * @cfg_en : Configuration enable bit. + * + * Configuration and counting: + * Counter can be configured across multiple writes to MSR. Configuration + * is applied only when @cfg_en =3D 1. Counter @cntr_id is reset when the + * configuration is applied. + * @cfg_en =3D 1, @cntr_en =3D 0 : Apply @cntr_id configuration but do not + * count events. + * @cfg_en =3D 1, @cntr_en =3D 1 : Apply @cntr_id configuration and start + * counting events. + */ +union l3_qos_abmc_cfg { + struct { + unsigned long bw_type :32, + bw_src :12, + reserved1: 3, + is_clos : 1, + cntr_id : 5, + reserved : 9, + cntr_en : 1, + cfg_en : 1; + } split; + unsigned long full; +}; + void rdt_ctrl_update(void *arg); =20 int rdt_get_mon_l3_config(struct rdt_resource *r); --=20 2.34.1 From nobody Sun Dec 14 02:00:56 2025 Received: from NAM12-BN8-obe.outbound.protection.outlook.com (mail-bn8nam12on2060.outbound.protection.outlook.com [40.107.237.60]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id E1B9228E5E1; Thu, 15 May 2025 22:54:11 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.237.60 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1747349653; cv=fail; b=D8kW6u81KczTw2eSTq/ZRztSQIFNsNI0eureLRepjQzRbPoqktr1V4M/cQ4OCdYWVwf/C4SMg2tQWxBc0dJZwUY3viFzq5AZ5VtD6IwKNSZv+d//Dzr4EkoeUrmgR4EVY7JL5Eo8bvCYV1+zeasiA+Vskj7mabq6QOJJdmAv480= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1747349653; c=relaxed/simple; bh=UD4gpt93Z5WHPIiKUVOf7lZQ89yMwsn2QAGUmA9GAZI=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=Pv/lhJTdDBXEMKM4PZIC279le+M7C3AtEM+8RgVLXB7EkKBFBwwP/6DZ8kdSbMa0ynRcZfreAoWIUaY72SLy/lOZ/KYORNOf2tsDFscCbhdRp3dA/CmMrGFXZoHX3NPffo46FgGf3CEvAQWYptBudZJhIKSiGSXlHx1khuzKrdg= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=amd.com; spf=fail smtp.mailfrom=amd.com; dkim=pass (1024-bit key) header.d=amd.com header.i=@amd.com header.b=oxRX6yar; arc=fail smtp.client-ip=40.107.237.60 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=amd.com Authentication-Results: smtp.subspace.kernel.org; spf=fail smtp.mailfrom=amd.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=amd.com header.i=@amd.com header.b="oxRX6yar" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=YokU7rM4PJKfKroJXaPICe4hhm5uQrwo7807erbFdBlBRgqTELEuKKDChhyKmCNG0Jfdov+o4B8oPAuPl5+yl42uszQB1HhOfs9/Fvyvkp8UovzFRjdjJSNDxBPlTrDkMdNnKy6zm6uB6JZVaZ5Lgo8OPKUDBALd0yi6LlRoqIaAMKr/IjCrkJNpXVz2+FBX4NZF2X9m3w8CXXLH+LAUWm5JNr7TmRMYwzDgNOdB+c6x6Y6e9fqMZjaq/on9uLGIVD6PqQZHELO6DjTMZyUFCeY72EdsJHdZYv63J4jQ7uB3fBybUs5R6yb6GDjABj8GhMGNm0qrICml3AnPu/Mcxg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=32B82KLGJbHcD7IM4Th74wTr5F0rgWq002Y91Zj10CQ=; b=MCCW/hgqBExkae9jA08RLfaoEEdjdFnZo73J63Wos1mCgC0qPXTyecO7Qi1J2Nh4bhaOhGkpUo44LoKUOu2lbngk6F/E9GoXCPJ0xHojjjAY5/rReosqUfaZjeq3CXoYM3tTNpcWjbnQMnhQlj8yGiaeSVeGmvPXOD7c/95SmJct3nS3N7xsBEAXDlKEe557JOuHWklPHgS8mUqv/JaCgG1NL9GjdVs7VQTgrZeKgMNrWvOzKgAoivNB+HF+KctOWKjuplrEK6soUim9R3qaI4v6BhzyKh5ChAXc2xHgieOwrao2zKBjl1sqI8JQ1+ALRRsTdyHphB4roZtILk2hQg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=lwn.net smtp.mailfrom=amd.com; dmarc=pass (p=quarantine sp=quarantine pct=100) action=none header.from=amd.com; dkim=none (message not signed); arc=none (0) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amd.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=32B82KLGJbHcD7IM4Th74wTr5F0rgWq002Y91Zj10CQ=; b=oxRX6yarSzvWlUXmE/ve1MuJeGPcfdQy5gPal3j3obpTt5GZYm6vhD09/AxOI4+z+O8GaazVuBQlJUj6doy3P4x74O4fWWpv47U97XXOdEpFFd+5brxsBAV7ZB1Ay4JmYLxAFa8DPNBbnJjLrhby+N/FqIGd3KPmvLT35D6Pp4Q= Received: from BN0PR04CA0210.namprd04.prod.outlook.com (2603:10b6:408:e9::35) by DS7PR12MB6264.namprd12.prod.outlook.com (2603:10b6:8:94::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8722.33; Thu, 15 May 2025 22:54:07 +0000 Received: from BN2PEPF000044A2.namprd02.prod.outlook.com (2603:10b6:408:e9:cafe::ca) by BN0PR04CA0210.outlook.office365.com (2603:10b6:408:e9::35) with Microsoft SMTP Server (version=TLS1_3, cipher=TLS_AES_256_GCM_SHA384) id 15.20.8746.16 via Frontend Transport; Thu, 15 May 2025 22:54:07 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 165.204.84.17) smtp.mailfrom=amd.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=amd.com; Received-SPF: Pass (protection.outlook.com: domain of amd.com designates 165.204.84.17 as permitted sender) receiver=protection.outlook.com; client-ip=165.204.84.17; helo=SATLEXMB04.amd.com; pr=C Received: from SATLEXMB04.amd.com (165.204.84.17) by BN2PEPF000044A2.mail.protection.outlook.com (10.167.243.153) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.8722.18 via Frontend Transport; Thu, 15 May 2025 22:54:07 +0000 Received: from bmoger-ubuntu.amd.com (10.180.168.240) by SATLEXMB04.amd.com (10.181.40.145) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.39; Thu, 15 May 2025 17:54:03 -0500 From: Babu Moger To: , , , , , , CC: , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , Subject: [PATCH v13 11/27] x86/resctrl: Implement resctrl_arch_config_cntr() to assign a counter with ABMC Date: Thu, 15 May 2025 17:51:56 -0500 Message-ID: X-Mailer: git-send-email 2.34.1 In-Reply-To: References: Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-ClientProxiedBy: SATLEXMB04.amd.com (10.181.40.145) To SATLEXMB04.amd.com (10.181.40.145) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: BN2PEPF000044A2:EE_|DS7PR12MB6264:EE_ X-MS-Office365-Filtering-Correlation-Id: c85adc86-201a-4933-6e3f-08dd94036608 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|376014|36860700013|1800799024|7416014|82310400026|13003099007; X-Microsoft-Antispam-Message-Info: =?us-ascii?Q?T7zjgu8pn2YTRWL99OoDfvVvgikLVBSCkUbR5UY72U0nQnDOovuKEp3FYlsb?= =?us-ascii?Q?mgJGsyu+duFKeadu5KI4Y2HCJBcS7X+ls3n5cBCxhaP+PLC+JS7lpy4LZRPm?= =?us-ascii?Q?3B1Lp9XBXVJ23q37ybHQZbHXyzw7v7oDf2cuuQoGMNtQNfONrIP7Kp9AMYmG?= =?us-ascii?Q?v1vygSrAXN3buSYEWrWFw8Ijl3SgOsqB6c4hpd3VS2jkV83PiQEiYp/5rKNH?= =?us-ascii?Q?Rxnly9vV7XytrJFf+PDbraPu0ziiW2HL6gKdd8Jw+jla9B2R4qdm1GN8Nvve?= =?us-ascii?Q?JapqqwctlNi7UFyk9nSyIci2+XSkfZ0ILVXBQ/vz+6uEtpIaBz0j4Fv+ZZmZ?= =?us-ascii?Q?JtZ3lFy3btmVQYTvmAdMEQXU0ZveaFj44wmULYy2dfKCxHhZoq6PTnpb2O7B?= =?us-ascii?Q?B92uWh4jQSDuLnF/2x1ICixsoL8KCXL9PLm954SBeuFEMAEQ2afKvo3dP003?= =?us-ascii?Q?gJfuOrWTMhma+C7jo5OBbufVnJ3ifZr9ZlsfVAsfQSRi5ERfd7UeZPpZbDVI?= =?us-ascii?Q?XP2H07PpKO6IcycCX8AJK6DYCf9e8SDAnNbFeqR84HT4u9r3/lr5GFHDQjA7?= =?us-ascii?Q?1pXd2vPBsn2fIXTwHkmPpv6noJPF2DLGiEB+5pnCtIfO7CF83uGQDB5jlKxO?= =?us-ascii?Q?K4osXWuESdx4roHX0EkjVPKO7Zx6OHaa09n9iFyZZxrus1iBAIw0NQXTBV8T?= =?us-ascii?Q?+cjT5C7UzO3bdlYVWN1QdUTXrPvKCLCNQGq6dyknnE2gsQ+Zme/fr0Mz5Fb3?= =?us-ascii?Q?nel0x6nDMD49MkD7XUogdkFuTWFJBZJ2U+96GM5J6p9nfrOujU87eXqULCnb?= =?us-ascii?Q?D+OXfLPocbAwtKAt7CRxl2MMkkTrmpGgHVMwRBCKMl9u4+TjOa3Fkgtamqr5?= =?us-ascii?Q?LmfgOHNIoeFF5J904lTty77jyOSw7eVzSPSunuV1t7g6NWRhD8LlsxCEqFcB?= =?us-ascii?Q?fxdjYwCrKCR9O6srR95dm563WBrarkMyciBTbTRdMPhV5TrxjBf2Dmt5HnGU?= =?us-ascii?Q?atQ+9So5vD3IF4+9Hw6bEjiyg933b83odC6pyEPBfJ8hnjZxdf0hoZsAqjEA?= =?us-ascii?Q?iGbDPdyPnNObCrngiB83MCmvZ1aKB/EF+5sBwDOSaq+YOy6LG+IfiXw6jVtX?= =?us-ascii?Q?4R0PXYjI85Ase+N45u06ZTR1uAdvWPBt1ni8ylNbBJ9w5Ubl2gU+OFrz5+CI?= =?us-ascii?Q?LBBgxsqKyYznlemTu2b8jkAV9WyufpcR08kOvJSW3segsGi5uKIksMtkUYsI?= =?us-ascii?Q?sLKStue0VHtXpITpnjwa74sHtAPIrnGIJdh4lZZX2NDIjQu+1J25JWbpExkB?= =?us-ascii?Q?a46XWbxWwp9ubJzvrNrZDnkMCkE6Rc6agxxWhClXDb7NnvhZRFwzUmbHc2te?= =?us-ascii?Q?xJX9lgJtJohAEl3L0/kVa/BTiEd7J3ojXhkz3mMZVJU1hI24NmRAgtHgT7nm?= =?us-ascii?Q?7VAvxeGlRmcfLBIsivTicW58lPLiqgNoizIKGnyT7oFcC8/L99dcr6N7Uh9+?= =?us-ascii?Q?BRraWJay6NaZKZCC6bV/ufYj8l8pG3sF8SHMBVgqFvFEQFWFU31nW0H0EQ?= =?us-ascii?Q?=3D=3D?= X-Forefront-Antispam-Report: CIP:165.204.84.17;CTRY:US;LANG:en;SCL:1;SRV:;IPV:CAL;SFV:NSPM;H:SATLEXMB04.amd.com;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(13230040)(376014)(36860700013)(1800799024)(7416014)(82310400026)(13003099007);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 15 May 2025 22:54:07.3697 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: c85adc86-201a-4933-6e3f-08dd94036608 X-MS-Exchange-CrossTenant-Id: 3dd8961f-e488-4e60-8e11-a82d994e183d X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=3dd8961f-e488-4e60-8e11-a82d994e183d;Ip=[165.204.84.17];Helo=[SATLEXMB04.amd.com] X-MS-Exchange-CrossTenant-AuthSource: BN2PEPF000044A2.namprd02.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DS7PR12MB6264 Content-Type: text/plain; charset="utf-8" The ABMC feature provides an option to the user to assign a hardware counter to an RMID, event pair and monitor the bandwidth as long as it is assigned. The assigned RMID will be tracked by the hardware until the user unassigns it manually. Implement an architecture-specific handler to assign and unassign the counter. Configure counters by writing to the L3_QOS_ABMC_CFG MSR, specifying the counter ID, bandwidth source (RMID), and event configuration. The feature details are documented in the APM listed below [1]. [1] AMD64 Architecture Programmer's Manual Volume 2: System Programming Publication # 24593 Revision 3.41 section 19.3.3.3 Assignable Bandwidth Monitoring (ABMC). Link: https://bugzilla.kernel.org/show_bug.cgi?id=3D206537 Signed-off-by: Babu Moger --- v13: Moved resctrl_arch_config_cntr() prototype to include/linux/resctrl.h. Changed resctrl_arch_config_cntr() to retun void from int. Updated the kernal doc for the prototype. Updated the code comment. 12: Added the check to reset the architecture-specific state only when assign is requested. Added evt_cfg as the parameter as the user will be passing the event configuration from /info/L3_MON/event_configs/. v11: Moved resctrl_arch_assign_cntr() and resctrl_abmc_config_one_amd() to monitor.c. Added the code to reset the arch state in resctrl_arch_assign_cntr(). Also removed resctrl_arch_reset_rmid() inside IPI as the counters are reset from the callers. Re-wrote commit message. v10: Added call resctrl_arch_reset_rmid() to reset the RMID in the domain inside IPI call. SMP and non-SMP call support is not required in resctrl_arch_config_cn= tr with new domain specific assign approach/data structure. Commit message update. v9: Removed the code to reset the architectural state. It will done in another patch. v8: Rename resctrl_arch_assign_cntr to resctrl_arch_config_cntr. v7: Separated arch and fs functions. This patch only has arch implementatio= n. Added struct rdt_resource to the interface resctrl_arch_assign_cntr. Rename rdtgroup_abmc_cfg() to resctrl_abmc_config_one_amd(). v6: Removed mbm_cntr_alloc() from this patch to keep fs and arch code separate. Added code to update the counter assignment at domain level. v5: Few name changes to match cntr_id. Changed the function names to rdtgroup_assign_cntr resctr_arch_assign_cntr More comments on commit log. Added function summary. v4: Commit message update. User bitmap APIs where applicable. Changed the interfaces considering MPAM(arm). Added domain specific assignment. v3: Removed the static from the prototype of rdtgroup_assign_abmc. The function is not called directly from user anymore. These --- arch/x86/kernel/cpu/resctrl/monitor.c | 37 +++++++++++++++++++++++++++ include/linux/resctrl.h | 17 ++++++++++++ 2 files changed, 54 insertions(+) diff --git a/arch/x86/kernel/cpu/resctrl/monitor.c b/arch/x86/kernel/cpu/re= sctrl/monitor.c index ff4b2abfa044..e31084f7babd 100644 --- a/arch/x86/kernel/cpu/resctrl/monitor.c +++ b/arch/x86/kernel/cpu/resctrl/monitor.c @@ -448,3 +448,40 @@ inline bool resctrl_arch_mbm_cntr_assign_enabled(struc= t rdt_resource *r) { return resctrl_to_arch_res(r)->mbm_cntr_assign_enabled; } + +static void resctrl_abmc_config_one_amd(void *info) +{ + union l3_qos_abmc_cfg *abmc_cfg =3D info; + + wrmsrl(MSR_IA32_L3_QOS_ABMC_CFG, abmc_cfg->full); +} + +/* + * Send an IPI to the domain to assign the counter to RMID, event pair. + */ +void resctrl_arch_config_cntr(struct rdt_resource *r, struct rdt_mon_domai= n *d, + enum resctrl_event_id evtid, u32 rmid, u32 closid, + u32 cntr_id, u32 evt_cfg, bool assign) +{ + struct rdt_hw_mon_domain *hw_dom =3D resctrl_to_arch_mon_dom(d); + union l3_qos_abmc_cfg abmc_cfg =3D { 0 }; + struct arch_mbm_state *am; + + abmc_cfg.split.cfg_en =3D 1; + abmc_cfg.split.cntr_en =3D assign ? 1 : 0; + abmc_cfg.split.cntr_id =3D cntr_id; + abmc_cfg.split.bw_src =3D rmid; + abmc_cfg.split.bw_type =3D evt_cfg; + + smp_call_function_any(&d->hdr.cpu_mask, resctrl_abmc_config_one_amd, &abm= c_cfg, 1); + + /* + * The hardware counter is reset (because cfg_en =3D=3D 1) so there is no + * need to record initial non-zero counts. + */ + if (assign) { + am =3D get_arch_mbm_state(hw_dom, rmid, evtid); + if (am) + memset(am, 0, sizeof(*am)); + } +} diff --git a/include/linux/resctrl.h b/include/linux/resctrl.h index d77981d1fcb9..59a4fe60ab46 100644 --- a/include/linux/resctrl.h +++ b/include/linux/resctrl.h @@ -559,6 +559,23 @@ void resctrl_arch_reset_rmid_all(struct rdt_resource *= r, struct rdt_mon_domain * */ void resctrl_arch_reset_all_ctrls(struct rdt_resource *r); =20 +/** + * resctrl_arch_config_cntr() - Configure the counter id to RMID, event + * pair on the domain. + * @r: Resource structure. + * @d: Domain that the counter id to be configured. + * @evtid: Event type to configure. + * @rmid: RMID to configure. + * @closid: CLOSID to configure. + * @cntr_id: Counter ID to configure. + * @evt_cfg: MBM event configuration value representing reads, + * writes etc. + * @assign: Assign or unassign. + */ +void resctrl_arch_config_cntr(struct rdt_resource *r, struct rdt_mon_domai= n *d, + enum resctrl_event_id evtid, u32 rmid, u32 closid, + u32 cntr_id, u32 evt_cfg, bool assign); + extern unsigned int resctrl_rmid_realloc_threshold; extern unsigned int resctrl_rmid_realloc_limit; =20 --=20 2.34.1 From nobody Sun Dec 14 02:00:56 2025 Received: from NAM04-MW2-obe.outbound.protection.outlook.com (mail-mw2nam04on2068.outbound.protection.outlook.com [40.107.101.68]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 3222028D8C4; Thu, 15 May 2025 22:54:23 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.101.68 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1747349665; cv=fail; b=AyoTfUYfu1mBEB4AeyXlx6uGSDl4GWZR7HZJzDSbHrLvedqk9p851VexlUCoOX2c5S5nBC8Fu3miWEdW3SQgqKTXhRi180ry/L8ygM2PytWHbXLidNPWXaNnZwqTFg1wgBAfMpG8QsaZvm635avwvc47YvdxLR/t8XV+YBn3t3M= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1747349665; c=relaxed/simple; bh=jaBOlCyKeTznfflRMV6AZ3ppi0uBmXWFVZZGdpKcxM4=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=rJAcoDtzn3vjJQ9hsnJ4a2sT7JExlTW8pw69G6h4P/kaJNPx7w0eXcx+WF46G60r2Yj7hJYNvr9zwaxpIgWoqMwf1BYSe8ShviFzE6aRfHAN90WI5SHs3FA96UA90kjy6yA5AOOS8vm32xlUsqz7Pe0A7CZbbe047uSjE8+VO78= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=amd.com; spf=fail smtp.mailfrom=amd.com; dkim=pass (1024-bit key) header.d=amd.com header.i=@amd.com header.b=OX3i9otm; arc=fail smtp.client-ip=40.107.101.68 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=amd.com Authentication-Results: smtp.subspace.kernel.org; spf=fail smtp.mailfrom=amd.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=amd.com header.i=@amd.com header.b="OX3i9otm" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=uMFoungazQ7mpKvj8oX0zpx81tn1zdjKHwtyAn6A2JA0/i5Nhzn+6a11k95jt2eHVz7nGDQnivVHmOOAZdh+gpq0Hj+AVXqYAIDnJPacOpTEdwFCKzNYFzvHXjj7REIPb9jLmh2ABNoqBg9fmw3KOaTbW3KbTiEYh7+pqenSWGKPThDGFngxRLOpHCMOVAiPaDnVJJ0jXU1TUPVazu66pHz5FPVBuWBIdkaEyQhath4VbsDTO551OtWJtVjhGvIt3jyejTyx880X9XDKUGxKicl5mtFsFIyKW7kaprbfvqR+5WExbkSsB2Dolf/lx7G6zNwb8LDGtIhTsJCyj0vrEw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=Jy/TxVySw4h94wuTcseqUiMgpPwH9Cfk1iwTMOvzr4g=; b=vByKlk8dVUgFhIEEGoJ+uLTB3gpBuFwxQDOvRxEsPmhEtQbREcq88JJaKx8cJHtgzSf4fVV46pjnW++/kc7QKc/vXBfYQZnm+yZnHa3bGkHMr9B12YRtNL8ErLTzbjbk/WWO5Bd+THXHf8IZeVn2/0/1i4PpxocP8Rt2I7eVSe4ILVoaXsA0yMYkitKcGTEqj3LcI8GXefS4iL4+9NEMsWc0pT7zk8n7dMdLnIPGjogILzhETP7FR8jfU5u5bxWDCmbiDAVKahGS33dAHkukWlvcUCHDcDKcvsdAodWQ8jzMcP9NjfUtD3r1vuTgvyZq7zMbsO/DJaXgvNrAl9Y8PA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=lwn.net smtp.mailfrom=amd.com; dmarc=pass (p=quarantine sp=quarantine pct=100) action=none header.from=amd.com; dkim=none (message not signed); arc=none (0) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amd.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=Jy/TxVySw4h94wuTcseqUiMgpPwH9Cfk1iwTMOvzr4g=; b=OX3i9otm7RBdAZxAuL3OsdWiMbtk+0KYDqhihLJhSkCrSdKmHY6AvPmb9DcH3n4hfWC9r77Dw9IoyDSe+RsA4jAmeGZMRWN7eWh7mICRO6hjz/GRYhsJ9ZHMxY8XnNjaUbzOkf15wBJJg5PigLoG+wiVuWgkJL+/syW5AiIf6Ik= Received: from BN0PR04CA0193.namprd04.prod.outlook.com (2603:10b6:408:e9::18) by DS0PR12MB6437.namprd12.prod.outlook.com (2603:10b6:8:cb::21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8722.29; Thu, 15 May 2025 22:54:20 +0000 Received: from BN2PEPF000044A2.namprd02.prod.outlook.com (2603:10b6:408:e9:cafe::b2) by BN0PR04CA0193.outlook.office365.com (2603:10b6:408:e9::18) with Microsoft SMTP Server (version=TLS1_3, cipher=TLS_AES_256_GCM_SHA384) id 15.20.8699.33 via Frontend Transport; Thu, 15 May 2025 22:54:19 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 165.204.84.17) smtp.mailfrom=amd.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=amd.com; Received-SPF: Pass (protection.outlook.com: domain of amd.com designates 165.204.84.17 as permitted sender) receiver=protection.outlook.com; client-ip=165.204.84.17; helo=SATLEXMB04.amd.com; pr=C Received: from SATLEXMB04.amd.com (165.204.84.17) by BN2PEPF000044A2.mail.protection.outlook.com (10.167.243.153) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.8722.18 via Frontend Transport; Thu, 15 May 2025 22:54:19 +0000 Received: from bmoger-ubuntu.amd.com (10.180.168.240) by SATLEXMB04.amd.com (10.181.40.145) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.39; Thu, 15 May 2025 17:54:13 -0500 From: Babu Moger To: , , , , , , CC: , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , Subject: [PATCH v13 12/27] x86/resctrl: Introduce event configuration modes Date: Thu, 15 May 2025 17:51:57 -0500 Message-ID: <95b7f4e9d72773e8fda327fc80b429646efc3a8a.1747349530.git.babu.moger@amd.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: References: Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-ClientProxiedBy: SATLEXMB04.amd.com (10.181.40.145) To SATLEXMB04.amd.com (10.181.40.145) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: BN2PEPF000044A2:EE_|DS0PR12MB6437:EE_ X-MS-Office365-Filtering-Correlation-Id: 180ad92c-0035-4db1-d6b4-08dd94036d6d X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|82310400026|36860700013|1800799024|376014|7416014; X-Microsoft-Antispam-Message-Info: =?us-ascii?Q?VyF/QwYc8FW0UCgrLygGaO9LrP4zt1KKN+SJRWAk95r68bcnQXXdhlqOY8Uu?= =?us-ascii?Q?5u+6AaVenv4vKBiKybSCFij/Jql6E0hD3mgInqapaA0Ay7kFa5PitT+uHnlh?= =?us-ascii?Q?T8XUzs84dKbQAuwbtXjgIEsLS4by2AEzDbuNlNGjIfaZUYCWLI1Rp7sKFI8N?= =?us-ascii?Q?93EqpUiXi17/hKT2+6HgdXHq3HWlSOO5k0JoBz2tSylxUPQDPmOQp7ekbFZA?= =?us-ascii?Q?ewiDaHM/M5XQdlcqSUJ8cHIVBa+YkYVJmWsxYoluV+Q+7+Gcz0FTOf1W22me?= =?us-ascii?Q?jdPSFXZnLUpZ2svUB7WjCrH97R1MZDWInUnzqtxl+9cUTQVMfaqP+RazH43M?= =?us-ascii?Q?U2K2yCSfBCWDoOZSW5LjEAWtppmPk6T1CNUxq3kGdcT4DKWhdgT6byJyI4b3?= =?us-ascii?Q?KoLqKGWmpaWyztguWwYak3TJSVg+dVDnfHMNtGnpb9H+K26LgxjseXM7VmFW?= =?us-ascii?Q?Jhhndt9WtkbGD61Y64yVhnIh5E4WfJXAYG6U1CRYM2QzQiiAW+8AmeP7RSjS?= =?us-ascii?Q?uBEYe2BK3yGJkN9Yw4M/ERY3Ky0BBnXaMmBUB/8R407ERY2AH303eBhNl9JH?= =?us-ascii?Q?etkAPd+1dcsAYNNjC59bJjwmGEn7lruluBt37J5HDRYvoCTaJJBDZWv9HV1i?= =?us-ascii?Q?vPeuYXIlb8zwbnGM8uwwwdWfGsdA1CbX681mPfmJ5pGy94AsuSi8Y1AFbVa2?= =?us-ascii?Q?rkrgCyzLfAwDFd63uFgaT/eKkqYpbt9UKrR07J12ppjSzzOQYZjp5wwE0VxG?= =?us-ascii?Q?O82Z1WTAeD6VseRPehzYEKnbBkhNdlRAbnpMaveYhs1KZaTLkD/arXD1ukHZ?= =?us-ascii?Q?qzDOO9oSsN8iAp3FJKfxXeKGSos/tUmv0c7N8S6Bnf6fJk6Ucxr7WPc12NLs?= =?us-ascii?Q?08wMh9gFP/U+jK7z4SB5a07AltnNo3rOT+oCQEbyGYTFaiuFtOFK2H4xs+NY?= =?us-ascii?Q?WUwY8fKLWBAJXf1hDhfk+XGCuB+u6V8GuEEm5mIV6C9XSSgdn9lXPvd01XWh?= =?us-ascii?Q?nVdbp3MbxCRjOojxPMdcuk/6hYXoedBacXnJ9oIS4vStHYdVyX/ySzGM23GR?= =?us-ascii?Q?kvqTPc1CC9kxd+ftrKMTsr9n1QZBbKTitLEC9bVJLkH8feoLYQ96a9t99Oqk?= =?us-ascii?Q?/PeaCbqaEUwxQjKCwJiMhP9nNx6hfM/JPlAaCFdKi+n6EYVElsY/QSdsWyPM?= =?us-ascii?Q?UzYBUFnomOHeankA5P/4XMCIyT4/hVZkyI1jHD9MHdMFQEyz71GZBT2n64tG?= =?us-ascii?Q?mTgzZtmn/lwWQq7lOpHn02tSJwHj1HGg7VlG9VoDQ619IVLB4wr6lLcs+fHB?= =?us-ascii?Q?GUyhgp3dM1ZPCFDTrUTbJNrhlhNZAVB+w6SKvFxsjWcNft3SIldPwLW+hWFm?= =?us-ascii?Q?UnWmpfbbL7NrLUhoyACDwbrpSpOGwY/Y0h2WnzuKiafRwwvhILJT2ZfueBq3?= =?us-ascii?Q?yvqD/6IwPjW7D8+jqpbJJ7C6tx02oV3mx+LY3OeKoSyN0QXQ4IIM5qmeVSCy?= =?us-ascii?Q?i75izPlPwM5XaZQPeXtx4dLvTZkgsYogTzYu?= X-Forefront-Antispam-Report: CIP:165.204.84.17;CTRY:US;LANG:en;SCL:1;SRV:;IPV:CAL;SFV:NSPM;H:SATLEXMB04.amd.com;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(13230040)(82310400026)(36860700013)(1800799024)(376014)(7416014);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 15 May 2025 22:54:19.7782 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 180ad92c-0035-4db1-d6b4-08dd94036d6d X-MS-Exchange-CrossTenant-Id: 3dd8961f-e488-4e60-8e11-a82d994e183d X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=3dd8961f-e488-4e60-8e11-a82d994e183d;Ip=[165.204.84.17];Helo=[SATLEXMB04.amd.com] X-MS-Exchange-CrossTenant-AuthSource: BN2PEPF000044A2.namprd02.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DS0PR12MB6437 Content-Type: text/plain; charset="utf-8" MBM events can be configured using either BMEC (Bandwidth Monitoring Event Configuration) or the mbm_cntr_assign mode. Introduce a data structure to represent the various event configuration modes and their corresponding values. Suggested-by: Reinette Chatre Signed-off-by: Babu Moger --- v13: New patch to handle different event configuration types with mbm_cntr_assign mode. --- fs/resctrl/internal.h | 6 ++++-- fs/resctrl/monitor.c | 4 ++-- fs/resctrl/rdtgroup.c | 2 +- include/linux/resctrl_types.h | 11 +++++++++++ 4 files changed, 18 insertions(+), 5 deletions(-) diff --git a/fs/resctrl/internal.h b/fs/resctrl/internal.h index 9a8cf6f11151..0fae374559ba 100644 --- a/fs/resctrl/internal.h +++ b/fs/resctrl/internal.h @@ -55,13 +55,15 @@ static inline struct rdt_fs_context *rdt_fc2context(str= uct fs_context *fc) * struct mon_evt - Entry in the event list of a resource * @evtid: event id * @name: name of the event - * @configurable: true if the event is configurable + * @mbm_mode: monitoring mode (BMEC or mbm_cntr_assign) + * @evt_cfg: event configuration value decoding reads, writes. * @list: entry in &rdt_resource->evt_list */ struct mon_evt { enum resctrl_event_id evtid; char *name; - bool configurable; + enum resctrl_mbm_mode mbm_mode; + u32 evt_cfg; struct list_head list; }; =20 diff --git a/fs/resctrl/monitor.c b/fs/resctrl/monitor.c index 2548aee0151c..8e403587a02f 100644 --- a/fs/resctrl/monitor.c +++ b/fs/resctrl/monitor.c @@ -903,12 +903,12 @@ int resctrl_mon_resource_init(void) l3_mon_evt_init(r); =20 if (resctrl_arch_is_evt_configurable(QOS_L3_MBM_TOTAL_EVENT_ID)) { - mbm_total_event.configurable =3D true; + mbm_total_event.mbm_mode =3D MBM_MODE_BMEC; resctrl_file_fflags_init("mbm_total_bytes_config", RFTYPE_MON_INFO | RFTYPE_RES_CACHE); } if (resctrl_arch_is_evt_configurable(QOS_L3_MBM_LOCAL_EVENT_ID)) { - mbm_local_event.configurable =3D true; + mbm_local_event.mbm_mode =3D MBM_MODE_BMEC; resctrl_file_fflags_init("mbm_local_bytes_config", RFTYPE_MON_INFO | RFTYPE_RES_CACHE); } diff --git a/fs/resctrl/rdtgroup.c b/fs/resctrl/rdtgroup.c index 752750e3e443..f192b2736a77 100644 --- a/fs/resctrl/rdtgroup.c +++ b/fs/resctrl/rdtgroup.c @@ -1152,7 +1152,7 @@ static int rdt_mon_features_show(struct kernfs_open_f= ile *of, =20 list_for_each_entry(mevt, &r->mon.evt_list, list) { seq_printf(seq, "%s\n", mevt->name); - if (mevt->configurable) + if (mevt->mbm_mode =3D=3D MBM_MODE_BMEC) seq_printf(seq, "%s_config\n", mevt->name); } =20 diff --git a/include/linux/resctrl_types.h b/include/linux/resctrl_types.h index a25fb9c4070d..26cd1fec72db 100644 --- a/include/linux/resctrl_types.h +++ b/include/linux/resctrl_types.h @@ -47,4 +47,15 @@ enum resctrl_event_id { QOS_NUM_EVENTS, }; =20 +/* + * Event configuration mode. + * Events can be configured either in BMEC (Bandwidth Monitoring Event + * Configuration) mode or mbm_cntr_assign mode. + */ +enum resctrl_mbm_mode { + MBM_MODE_NONE, + MBM_MODE_BMEC, + MBM_MODE_ASSIGN, +}; + #endif /* __LINUX_RESCTRL_TYPES_H */ --=20 2.34.1 From nobody Sun Dec 14 02:00:56 2025 Received: from NAM04-BN8-obe.outbound.protection.outlook.com (mail-bn8nam04on2078.outbound.protection.outlook.com [40.107.100.78]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 2FC2C28D8C4; Thu, 15 May 2025 22:54:29 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.100.78 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1747349672; cv=fail; b=KNQVTaMmn/59Nj5hjKx89mZAMG/Ju9IYTvEqUO1MXYV60WbH4JbmI+C7Wf29b9ru5mvsNg+sSXkBbAS1IIOxmxiPKGP6C2cNtNztT6l1K1c2f3DLZEMh6IYC8txbZ5jEHSFxk+RMHTJc6JNd5/MllGXc716lLjs5RVzO8NhYOGE= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1747349672; c=relaxed/simple; bh=LwKbrldtM7FqjX3/6asK14EyFucCEVcrhm4yJL2SNbg=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=YD2cjVI3ACZLaNT8eILI4NokLuMLmo/KeiTqji6mEnSeBnl3IQNzdTBU7Pdg6sx+I3hFupIuuw2nvuiMZRqybPmBKEylN6UaeF50sknUbmAgneZeq3VY/w6FHeY3jQn2B6rXD03JR8vGVZig/yDjkddoYoHRoqJ4Gr97nN3PgYc= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=amd.com; spf=fail smtp.mailfrom=amd.com; dkim=pass (1024-bit key) header.d=amd.com header.i=@amd.com header.b=DnIU5LBV; arc=fail smtp.client-ip=40.107.100.78 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=amd.com Authentication-Results: smtp.subspace.kernel.org; spf=fail smtp.mailfrom=amd.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=amd.com header.i=@amd.com header.b="DnIU5LBV" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=wHvcadQemcWLGEQCMkfOTHXqIU31l2M7zhVShY937AE3F98HiDXOkKnk/OPV2ypC8FtTsaRMuXyTTyVPuI6Mwf8z5Gj27kftymqMG3/EN576SXOor2bahCsI47UZ4G5CW3g31EmKLkeU5FfGGxcvpOlJGqoxM5hNKRUnRtSAwW5SzF6qSmDRa8BmEwjmXLjuSTLbevuwwoILvOU2Ds6RskC2+eIzUfu9lFLwp/ex0CHYB2pGJq6oaBTqupCAQnBSU3cgOZ3z0hWYUx/EJFYADQ+fHT0LtQcATIJbhiC+Ht6lq1g2MAHPAeIa+dhPfOMEYPqi4gy/5iSHmYejKejeOw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=4iDSzoeHUENvrtYhRToqnXWHc+MyM9WHjIfABKWl9KA=; b=vSxlwmCRgADf9s93CLh3b7GvpMANz1YnMdVRGMPMSSwyl8Wc8AZcC56P2wN5giXoja1v8jEiR+ZxBvOICrrfZ2yTaNdpREUhf97kr5RrCqiUFxecziD+NUk7sUP7zM5mj6XKuRaHA1qNLaEpAS0xypu7BQKBPRXgnnR9k9RCavZ7WZVmzK1C39pF7KraAqiN9qnheTnLvue3N/hgDYa9g2SCO4ubciebS6ZJ5g5zOq+5EClnDJoDnFUUZEyUKJm8lR/jh+sEGVjr84VdXQAwhBuj3MAaaZA2sUF0yQKvk63OaUEAbbh98xLv9Px7e5xvw6XGB9oTVOINE1UJWUkJAw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=lwn.net smtp.mailfrom=amd.com; dmarc=pass (p=quarantine sp=quarantine pct=100) action=none header.from=amd.com; dkim=none (message not signed); arc=none (0) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amd.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=4iDSzoeHUENvrtYhRToqnXWHc+MyM9WHjIfABKWl9KA=; b=DnIU5LBVrx+/gLgoJvAzL7vdS8TQp9gbwynGTC5xRnUBCjvo6zqfMu4WNsCbO/8354ocSpKmt3/BW8DZHmYk5IdCvXrw3BExvspgKPe6Vd3NmKzjl5/WtS+xiGM+zBlvwtflwA/d+tol+Dl9KsyLADr0cg5+WjkI5TmbC2Ph0Ak= Received: from BLAPR03CA0009.namprd03.prod.outlook.com (2603:10b6:208:32b::14) by SJ2PR12MB7920.namprd12.prod.outlook.com (2603:10b6:a03:4c6::9) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8722.32; Thu, 15 May 2025 22:54:26 +0000 Received: from BN2PEPF0000449E.namprd02.prod.outlook.com (2603:10b6:208:32b:cafe::8c) by BLAPR03CA0009.outlook.office365.com (2603:10b6:208:32b::14) with Microsoft SMTP Server (version=TLS1_3, cipher=TLS_AES_256_GCM_SHA384) id 15.20.8699.31 via Frontend Transport; Thu, 15 May 2025 22:54:26 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 165.204.84.17) smtp.mailfrom=amd.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=amd.com; Received-SPF: Pass (protection.outlook.com: domain of amd.com designates 165.204.84.17 as permitted sender) receiver=protection.outlook.com; client-ip=165.204.84.17; helo=SATLEXMB04.amd.com; pr=C Received: from SATLEXMB04.amd.com (165.204.84.17) by BN2PEPF0000449E.mail.protection.outlook.com (10.167.243.149) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.8722.18 via Frontend Transport; Thu, 15 May 2025 22:54:26 +0000 Received: from bmoger-ubuntu.amd.com (10.180.168.240) by SATLEXMB04.amd.com (10.181.40.145) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.39; Thu, 15 May 2025 17:54:22 -0500 From: Babu Moger To: , , , , , , CC: , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , Subject: [PATCH v13 13/27] x86/resctrl: Add the functionality to assign MBM events Date: Thu, 15 May 2025 17:51:58 -0500 Message-ID: <690c1af39c9f7d4d9d5a1f2f84e89717bb756f23.1747349530.git.babu.moger@amd.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: References: Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-ClientProxiedBy: SATLEXMB04.amd.com (10.181.40.145) To SATLEXMB04.amd.com (10.181.40.145) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: BN2PEPF0000449E:EE_|SJ2PR12MB7920:EE_ X-MS-Office365-Filtering-Correlation-Id: ccf78a81-b023-4c67-9f6b-08dd94037141 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|1800799024|82310400026|7416014|376014|36860700013; X-Microsoft-Antispam-Message-Info: =?us-ascii?Q?Q2DflaLCzIz8UznFHh4gUWuyoBJ1k67yhwOeaR0HkRFjEuLKFsACyxMLbMdY?= =?us-ascii?Q?tCrHa6IQVHDV9vSL8dxZ6XulMUhIZE/0dmuL2jAJ2+iMethyFHZxUzg17Ipp?= =?us-ascii?Q?KqKJMAW8I7SBYgCUdxZJQ+d6bWDAMrxRYCLwxf1MJuMeBq8zjGMeMXgn8eG2?= =?us-ascii?Q?jIjQuko8UBQwAPRNa7dG8vDSXvvWEoqpnk13mGfnr4A5udsp9/s3R3Aq6IZU?= =?us-ascii?Q?ou6i11n7c7HE+TYNyYr4xyNJOw8zjmZ3gOc8RxMdLRYpUoOvcbM9HeiU4mHL?= =?us-ascii?Q?nSAgzbBReX0TppGGzHH71PPlkXyOxkEfFUFu3uAAbsKnrNlq+VQ8jm0Rktxe?= =?us-ascii?Q?dJzEhYxDR+WHufFF/DMnLUfNh9ip+3mlXudZLgLAxueri3Uxglj+Ln+0lt68?= =?us-ascii?Q?V9WORamCz24s+6A5AawIMBD3Xw78eQREMfJSWsIB2bKeUMZqNRRr+CZSG8Ps?= =?us-ascii?Q?m1Kkiwq9cs/sL8dZrksakj9ImJkZ2vBRqzhsWHjRaOlGwJTQr9adxPScpWZ4?= =?us-ascii?Q?pXbV1jlX0jcqWHZMwEli4pJPqkeUEqaSk8UQ0lRPCinqEDD/7mCbH2w7hO7e?= =?us-ascii?Q?T1G7qXBq/0OXuDanJ0dvFcFbQxGxCicSNy1QT+kiGDUjBR5+qNyO0e37kuNO?= =?us-ascii?Q?d6Sb5bPZI8wlFluA1msVXh0w14VV3LD/y/48uqd8meQEF+KhWdIQFU4TILn3?= =?us-ascii?Q?Yn+UA/NQLm0yVzOxQXh0V7iJnRMTtTy+68wDTrJS3dVFM9v4beS2ICpSwsdB?= =?us-ascii?Q?qU46LtyRxW2LHRa87CMiECjVIDmDqfmBuIu6tCxSJWbEE4ULi6ojRRuAPcRc?= =?us-ascii?Q?ibKP4iFHgo4MxEt33plOZu8wY+bRL6pK7Yioefb6V8gtSp0ZbM9/rnhhboWw?= =?us-ascii?Q?nzVviG4UPScgvp2xJyb5l3yOzOCmCVffbog/bnQSZP5sccKzlVOGRgsY1KLW?= =?us-ascii?Q?gRYunpvLsz6xYKstnlmgNC7Dx/moOYlofaqRqTlPUZCu0bdKW1VFZgSBN28G?= =?us-ascii?Q?Kbu8T6atfsTuSztpW3yXqn7SIYMYyJQ1S1a0s8muB4VY//hl+qV+y6a8Zqql?= =?us-ascii?Q?AEA9sUHUPaJyGpGvYvORrzMlpLmX0v6Eg83Pl8eooiGBgzajFS3jHWlm90ro?= =?us-ascii?Q?CeTibE+HwwWHK3kbs/sHa3IR1R6unNJOWY1aqrJriIyCcvkxKsITpZtMKZIp?= =?us-ascii?Q?rndJ0L4BRKSPWuyIKDqzsidwdUH/Ox4hX0kpF24WCRDvxCgvDZaYHy3a7yxc?= =?us-ascii?Q?sFv89kV/MThLldhZH4QGWq7g2z28ZpMUc/aDC61XSz+DRPiqI+zMLje6xDzk?= =?us-ascii?Q?+WZmq6Z+N/Jfsbm5aCKr2nuS7Gt9SZz7FEt9Lg1PSwD4YMOQ55pu/8Zorm5D?= =?us-ascii?Q?ZSi/hFdMgzSAV1IHQspG2kDqKl2npeQItKSnbVLZapMoOmRkGUAxQxq2owMt?= =?us-ascii?Q?W08lMC2o+3R/wOb9fDh2BUEU1c/YlsMtl4KyThRz3qqvd2IqCI3Ov64mwYMt?= =?us-ascii?Q?idjixayi8zW1EeHcOR7AWxWJ9QwBfFErT8pxXD+JhN0K04cDeVuj+FE5wA?= =?us-ascii?Q?=3D=3D?= X-Forefront-Antispam-Report: CIP:165.204.84.17;CTRY:US;LANG:en;SCL:1;SRV:;IPV:CAL;SFV:NSPM;H:SATLEXMB04.amd.com;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(13230040)(1800799024)(82310400026)(7416014)(376014)(36860700013);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 15 May 2025 22:54:26.1985 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: ccf78a81-b023-4c67-9f6b-08dd94037141 X-MS-Exchange-CrossTenant-Id: 3dd8961f-e488-4e60-8e11-a82d994e183d X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=3dd8961f-e488-4e60-8e11-a82d994e183d;Ip=[165.204.84.17];Helo=[SATLEXMB04.amd.com] X-MS-Exchange-CrossTenant-AuthSource: BN2PEPF0000449E.namprd02.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: SJ2PR12MB7920 Content-Type: text/plain; charset="utf-8" The mbm_cntr_assign mode offers "num_mbm_cntrs" number of counters that can be assigned to RMID, event pair and monitor the bandwidth as long as it is assigned. Add the functionality to allocate and assign a counter to am RMID, event pair in the domain. If all the counters are in use, kernel will log the error message "Unable to allocate counter in domain" in /sys/fs/resctrl/info/last_cmd_status when a new assignment is requested. Exit on the first failure when assigning counters across all the domains. Signed-off-by: Babu Moger --- v13: Updated changelog. Changed resctrl_arch_config_cntr() to return void instead of int. Just passing evtid is to resctrl_alloc_config_cntr() and resctrl_assign_cntr_event(). Event configuration value can be easily obtained from mon_evt list. Introduced new function mbm_get_mon_event() to get event configuration= value. Added prototype descriptions to mbm_cntr_get() and mbm_cntr_alloc(). Resolved conflicts caused by the recent FS/ARCH code restructure. The files monitor.c/rdtgroup.c have been split between FS and ARCH dir= ectories. v12: Fixed typo in the subjest line. Replaced several counters with "num_mbm_cntrs" counters. Changed the check in resctrl_alloc_config_cntr() to reduce the indenta= tion. Fixed the handling error on first failure. Added domain id and event id on failure. Fixed the return error override. Added new parameter event configuration (evt_cfg) to get the event con= figuration from user space. v11: Patch changed again quite a bit. Moved the functions to monitor.c. Renamed rdtgroup_assign_cntr_event() to resctrl_assign_cntr_event(). Refactored the resctrl_assign_cntr_event(). Added functionality to exit on the first error during assignment. Simplified mbm_cntr_free(). Removed the function mbm_cntr_assigned(). Will be using mbm_cntr_get()= to figure out if the counter is assigned or not. Updated commit message and code comments. v10: Patch changed completely. Counters are managed at the domain based on the discussion. https://lore.kernel.org/lkml/CALPaoCj+zWq1vkHVbXYP0znJbe6Ke3PXPWjtri5A= FgD9cQDCUg@mail.gmail.com/ Reset non-architectural MBM state. Commit message update. v9: Introduced new function resctrl_config_cntr to assign the counter, upda= te the bitmap and reset the architectural state. Taken care of error handling(freeing the counter) when assignment fails. Moved mbm_cntr_assigned_to_domain here as it used in this patch. Minor text changes. v8: Renamed rdtgroup_assign_cntr() to rdtgroup_assign_cntr_event(). Added the code to return the error if rdtgroup_assign_cntr_event fails. Moved definition of MBM_EVENT_ARRAY_INDEX to resctrl/internal.h. Updated typo in the comments. v7: New patch. Moved all the FS code here. Merged rdtgroup_assign_cntr and rdtgroup_alloc_cntr. Adde new #define MBM_EVENT_ARRAY_INDEX. --- fs/resctrl/internal.h | 3 + fs/resctrl/monitor.c | 134 ++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 137 insertions(+) diff --git a/fs/resctrl/internal.h b/fs/resctrl/internal.h index 0fae374559ba..ce4fcac91937 100644 --- a/fs/resctrl/internal.h +++ b/fs/resctrl/internal.h @@ -377,6 +377,9 @@ bool closid_allocated(unsigned int closid); =20 int resctrl_find_cleanest_closid(void); =20 +int resctrl_assign_cntr_event(struct rdt_resource *r, struct rdt_mon_domai= n *d, + struct rdtgroup *rdtgrp, enum resctrl_event_id evtid); + #ifdef CONFIG_RESCTRL_FS_PSEUDO_LOCK int rdtgroup_locksetup_enter(struct rdtgroup *rdtgrp); =20 diff --git a/fs/resctrl/monitor.c b/fs/resctrl/monitor.c index 8e403587a02f..d76fd0840946 100644 --- a/fs/resctrl/monitor.c +++ b/fs/resctrl/monitor.c @@ -934,3 +934,137 @@ void resctrl_mon_resource_exit(void) =20 dom_data_exit(r); } + +/* + * Configure the counter for the event, RMID pair for the domain. Reset the + * non-architectural state to clear all the event counters. + */ +static void resctrl_config_cntr(struct rdt_resource *r, struct rdt_mon_dom= ain *d, + enum resctrl_event_id evtid, u32 rmid, u32 closid, + u32 cntr_id, u32 evt_cfg, bool assign) +{ + struct mbm_state *m; + + resctrl_arch_config_cntr(r, d, evtid, rmid, closid, cntr_id, evt_cfg, ass= ign); + + m =3D get_mbm_state(d, closid, rmid, evtid); + if (m) + memset(m, 0, sizeof(struct mbm_state)); +} + +/* + * mbm_cntr_get() - Return the cntr_id for the matching evtid and rdtgrp in + * cntr_cfg array. + */ +static int mbm_cntr_get(struct rdt_resource *r, struct rdt_mon_domain *d, + struct rdtgroup *rdtgrp, enum resctrl_event_id evtid) +{ + int cntr_id; + + for (cntr_id =3D 0; cntr_id < r->mon.num_mbm_cntrs; cntr_id++) { + if (d->cntr_cfg[cntr_id].rdtgrp =3D=3D rdtgrp && + d->cntr_cfg[cntr_id].evtid =3D=3D evtid) + return cntr_id; + } + + return -ENOENT; +} + +/* + * mbm_cntr_alloc() - Return the first free entry in cntr_cfg array. + */ +static int mbm_cntr_alloc(struct rdt_resource *r, struct rdt_mon_domain *d, + struct rdtgroup *rdtgrp, enum resctrl_event_id evtid) +{ + int cntr_id; + + for (cntr_id =3D 0; cntr_id < r->mon.num_mbm_cntrs; cntr_id++) { + if (!d->cntr_cfg[cntr_id].rdtgrp) { + d->cntr_cfg[cntr_id].rdtgrp =3D rdtgrp; + d->cntr_cfg[cntr_id].evtid =3D evtid; + return cntr_id; + } + } + + return -ENOSPC; +} + +/* + * mbm_get_mon_event() - Return the mon_evt entry for the matching evtid. + */ +static struct mon_evt *mbm_get_mon_event(struct rdt_resource *r, + enum resctrl_event_id evtid) +{ + struct mon_evt *mevt; + + list_for_each_entry(mevt, &r->mon.evt_list, list) { + if (mevt->evtid =3D=3D evtid) + return mevt; + } + + return NULL; +} + +/* + * Allocate a fresh counter and configure the event if not assigned alread= y. + */ +static int resctrl_alloc_config_cntr(struct rdt_resource *r, struct rdt_mo= n_domain *d, + struct rdtgroup *rdtgrp, enum resctrl_event_id evtid) +{ + struct mon_evt *mevt; + int cntr_id; + + /* No need to allocate a new counter if it is already assigned */ + cntr_id =3D mbm_cntr_get(r, d, rdtgrp, evtid); + if (cntr_id >=3D 0) + goto cntr_configure; + + cntr_id =3D mbm_cntr_alloc(r, d, rdtgrp, evtid); + if (cntr_id < 0) { + rdt_last_cmd_printf("Unable to allocate counter in domain %d\n", + d->hdr.id); + return cntr_id; + } + +cntr_configure: + mevt =3D mbm_get_mon_event(r, evtid); + if (!mevt) { + rdt_last_cmd_printf("Invalid event id %d\n", evtid); + return -EINVAL; + } + + /* + * Skip reconfiguration if the event setup is current; otherwise, + * update and apply the new configuration to the domain. + */ + if (mevt->evt_cfg !=3D d->cntr_cfg[cntr_id].evt_cfg) { + d->cntr_cfg[cntr_id].evt_cfg =3D mevt->evt_cfg; + resctrl_config_cntr(r, d, evtid, rdtgrp->mon.rmid, rdtgrp->closid, + cntr_id, mevt->evt_cfg, true); + } + + return 0; +} + +/* + * Assign a hardware counter to event @evtid of group @rdtgrp. + * Assign counters to all domains if @d is NULL; otherwise, assign the + * counter to the specified domain @d. + */ +int resctrl_assign_cntr_event(struct rdt_resource *r, struct rdt_mon_domai= n *d, + struct rdtgroup *rdtgrp, enum resctrl_event_id evtid) +{ + int ret =3D 0; + + if (!d) { + list_for_each_entry(d, &r->mon_domains, hdr.list) { + ret =3D resctrl_alloc_config_cntr(r, d, rdtgrp, evtid); + if (ret) + return ret; + } + } else { + ret =3D resctrl_alloc_config_cntr(r, d, rdtgrp, evtid); + } + + return ret; +} --=20 2.34.1 From nobody Sun Dec 14 02:00:56 2025 Received: from NAM12-DM6-obe.outbound.protection.outlook.com (mail-dm6nam12on2087.outbound.protection.outlook.com [40.107.243.87]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 79514292924; Thu, 15 May 2025 22:54:43 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.243.87 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1747349686; cv=fail; b=SRmow+i4uXsLh3WKlpCTUn6tMHV9+7+V/uohz59MKEQjFBFtVND0ii65u5lWWY9KLGjoD4r4W8VBeMJ8zup0odwo/N9UMKMOa6BqY8oyOjtF+DvJzcg2SAoNd0Pkk5ojySOOHVQ+5KscsSy07XsowWjl7O7jiUE/AD4nF+bwUwg= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1747349686; c=relaxed/simple; bh=LQMzVGFunxKFXL0LNVcTMM5QxN3gnOnv+wXNK8fQSdA=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=krHAcfXYEIgbqyi9NAU50gRgGp6e/8OxUfxR3iQtuBpVvc1qXNzs7380vKTpE4XTPtFcvR0NfIEd3UbftRc3aSR0xoQuIOuxMf0CO48gnoIFNC+IjAO0V1HqgoLn42OHM2GNHDbh5+mWH76O4YSrz5HyNwbVlsXPNwmeErIuMGI= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=amd.com; spf=fail smtp.mailfrom=amd.com; dkim=pass (1024-bit key) header.d=amd.com header.i=@amd.com header.b=kUXpl2do; arc=fail smtp.client-ip=40.107.243.87 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=amd.com Authentication-Results: smtp.subspace.kernel.org; spf=fail smtp.mailfrom=amd.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=amd.com header.i=@amd.com header.b="kUXpl2do" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=M4wBHOA1RI2KZ4Y6dWqUzBDlMBtTJQUFxhUsu2QpngcEGMLYtd37Bgcg6VP2amBkdHvop3g8jCC3D8v3JZc/1LVqcycHPB2ANm5C6jYgNn9f2GFj9TIONZM0jgqPIVTvm0Nbp1NqRg/0BVS4DYG9N+TAyJRwgzTVdTCjg+u/BFIwelNfKnHmI/4zVAECqitJoz/mDp2MxdIsZGSMkREPc+Lqj+xgj5zVpsYCSQtucoBElGB0EnPYs5oLTwH3iGGfanzi6uqXLI2MekchZIVsMDYhARDmkFD2sZTuf1TgyPPvvvMgYkDs+6Ww39O1gQ96/zDsbEzhadKOC42gM0zCog== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=+9uZGkK0mRw7dMtI4hYXpICzwbjAcBBnQ1fqswQhats=; b=uEHQ5mMam2nM8Nz2YNLz9nmk+suHGNzYuMRwblglvwzA/T0RIlQ6sCNdzyrY8pG1hZmS4Mg6h4IOz9PqzgJypf9WrCl0XbZMc8jR44Ixx0GsYCftW8K53hC7C4ZWLlShqqJl1r8GHRU8AlQ6kjnijgALBZ/wKwo6vsy+pww9PEsH2QcRukYC7Xv5nZQQhf9aZWUXZXdxpEMojViLNJeDTULJczUu+yn62L41ooktKwfAvrSATGvhAFFwBzStI0Tb3YIDrnTpji/jn+P+VzgcdN7d1d37TxeMiGb0t+0DqHNdF5GA5s5xLCFD0UkRSqHim+ravyT3wE+4+lGvm6Uw5g== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=lwn.net smtp.mailfrom=amd.com; dmarc=pass (p=quarantine sp=quarantine pct=100) action=none header.from=amd.com; dkim=none (message not signed); arc=none (0) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amd.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=+9uZGkK0mRw7dMtI4hYXpICzwbjAcBBnQ1fqswQhats=; b=kUXpl2dobFFu7SP32yjJUDXlMSe6ynW/75hvatxnETsEUupPusxi1i+v5JhJcHxnMSsDT6Gx2MfHILf1J5WAii6EaUbyX1Hw9xEt450RuM6ZtXVy0yvWcQSnN4GPiPvi1+RDdhUEa4BlzUA6UrKTko0wwMF7O1hw2zJ8op8p7ug= Received: from BN9PR03CA0051.namprd03.prod.outlook.com (2603:10b6:408:fb::26) by SJ0PR12MB8615.namprd12.prod.outlook.com (2603:10b6:a03:484::12) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8722.30; Thu, 15 May 2025 22:54:38 +0000 Received: from BN2PEPF0000449F.namprd02.prod.outlook.com (2603:10b6:408:fb:cafe::16) by BN9PR03CA0051.outlook.office365.com (2603:10b6:408:fb::26) with Microsoft SMTP Server (version=TLS1_3, cipher=TLS_AES_256_GCM_SHA384) id 15.20.8722.20 via Frontend Transport; Thu, 15 May 2025 22:54:37 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 165.204.84.17) smtp.mailfrom=amd.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=amd.com; Received-SPF: Pass (protection.outlook.com: domain of amd.com designates 165.204.84.17 as permitted sender) receiver=protection.outlook.com; client-ip=165.204.84.17; helo=SATLEXMB04.amd.com; pr=C Received: from SATLEXMB04.amd.com (165.204.84.17) by BN2PEPF0000449F.mail.protection.outlook.com (10.167.243.150) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.8722.18 via Frontend Transport; Thu, 15 May 2025 22:54:37 +0000 Received: from bmoger-ubuntu.amd.com (10.180.168.240) by SATLEXMB04.amd.com (10.181.40.145) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.39; Thu, 15 May 2025 17:54:32 -0500 From: Babu Moger To: , , , , , , CC: , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , Subject: [PATCH v13 14/27] x86/resctrl: Add the functionality to unassign MBM events Date: Thu, 15 May 2025 17:51:59 -0500 Message-ID: <1ba0091cad7d1e5ab32136d4742580294a2ce5e3.1747349530.git.babu.moger@amd.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: References: Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-ClientProxiedBy: SATLEXMB04.amd.com (10.181.40.145) To SATLEXMB04.amd.com (10.181.40.145) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: BN2PEPF0000449F:EE_|SJ0PR12MB8615:EE_ X-MS-Office365-Filtering-Correlation-Id: 9f8e04e4-cb96-45f0-41ca-08dd940377cc X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|82310400026|36860700013|1800799024|376014|7416014; X-Microsoft-Antispam-Message-Info: =?us-ascii?Q?qng8Ut7DFhy3qgd8nZQSQOgoWTQ9ay3oP8H3FfMjHDLXPAtA361GhRfLlsJV?= =?us-ascii?Q?VIbsf+o00Z79iV0UGHvU/uHga6p2q5+FQJrjh8hAVAcScZfY4ZbN3eXyIIPV?= =?us-ascii?Q?7JjCxWevosG2DFpS4jnmlOhoOm5HdHT7ikyKZCg5D//uywGl1/SlrzrKmDDH?= =?us-ascii?Q?z9w3zB7fMwLaPul03ZPPuMMKM/SLTHALrEtwATayN3KCfInjiTvb8vw4x4Fr?= =?us-ascii?Q?dfvYaX/jXo5RPLiNMwh3pESDIaRAdmhG8CjDDugha3r8qgVk3PFlgfzP6nex?= =?us-ascii?Q?98DC8pstvARzSFPjjUhCWM9J0LR7/qLa0YBg+AtLjqHeSD/fcrKh40u7jniA?= =?us-ascii?Q?elvh+yBaW/y8wamDI/hOJuq83mSR2cn/4XrP/nsl0p4Da0AT176wqCOBBxhW?= =?us-ascii?Q?hpQNfKehVpqxw+ZWSEZHdU3phnz3iN2uDuBWYPISHhb2gDSfWtxL7PM916lY?= =?us-ascii?Q?h2sPTwIXo2waCuI+tHAVzsNK3XG3LU8shmYoGZzHfDDW8lGbqX1JN5R9LmNz?= =?us-ascii?Q?GsVVvx5tTPKlQwxT8NDe+zf2gqD8bhZn4N0/b/XNUaDqDN1Y8rDx8LTlHYjf?= =?us-ascii?Q?KzyUhu8QGk5mD6NveYHic90APaRY6OvSPJg5ODIVNVTq8TRWKaGu6mM9EIZ5?= =?us-ascii?Q?dXfXcUVasvJA6OxFfCKfpGT6Q64pbLb5E+Bvh6kzQRz7eSoV9OxW0xah3Frk?= =?us-ascii?Q?g/9Ab/MwUvEpwntx3xdcICZLs2WzGtjCM2XJ97tALJC46KbE5m8rXsLbmeQF?= =?us-ascii?Q?RM6R4XqUu/w6HYQ+xUcBCZHiYgfsCEo+rScHd/tU3f0FTMC1RCYyjJ7pwl7V?= =?us-ascii?Q?L1PxucuP3kHimSGJaZ8fUya4gKZYV4yFW9CJ2VSDp8YmbF6+O1fkcwjUiAVe?= =?us-ascii?Q?ApkwogjMmrdVp6u+DKI+8I2eQ8m4u5mpjGmAV2X9Sf1jVVinYg4gz6oIstc8?= =?us-ascii?Q?/+Hgy0WU6HYzySB/A0ZCzUKh/KIITWeM3YJTWawMe/wwkKhkw/CYJn1FaTOn?= =?us-ascii?Q?5B21qA0uW5MfdsZyx6EX/hf5ea12zas79MqcEJZKqeWVnAKQdd1hi7SyOvf9?= =?us-ascii?Q?/Bz/kP+Nzv/bwFqIPXgMToSGJIcemk47DZ9Dh0GnPzSobo/ed5b3Rbmt+a1a?= =?us-ascii?Q?8qggv4/YHtUWVxJC4Z8NNOjUrVEDdggmqb6Dke89iE9wKCZ72gZ3ZIUPUvTI?= =?us-ascii?Q?x2atGYvIaiCtNE7BU7E00tjP7g2pFxLbv/frqLf08agkpNiEa4m5tSr9gjTJ?= =?us-ascii?Q?oEXYbp24P+o4LnRiGWKOENz2NKUQpr1jlsrQ8l6YYwV7gOtJ5w/KpcDR5LDa?= =?us-ascii?Q?gLxdLxYn4qPh1TZOCLUnUfCfW7+NG16f4v/Qs/KPckD6IJddw+3qmsV6U2u5?= =?us-ascii?Q?vdY278KfnzawuRrIl9v+UfeV8Z+WKmClRlnLIzvqoZe/ZST5pRBVDtFkWjIK?= =?us-ascii?Q?RfJ5Rh2hgcuHWb1PSGTULUjfNYMIfQ9OkLJcJHWVLRRSbtkaXRhdYTT1Lnkx?= =?us-ascii?Q?o3iuZtF+tQv0dXI1EbYWlnSpKdo3Pv5n54GBDxNpFSBDTNN7AG4F7ymM1Q?= =?us-ascii?Q?=3D=3D?= X-Forefront-Antispam-Report: CIP:165.204.84.17;CTRY:US;LANG:en;SCL:1;SRV:;IPV:CAL;SFV:NSPM;H:SATLEXMB04.amd.com;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(13230040)(82310400026)(36860700013)(1800799024)(376014)(7416014);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 15 May 2025 22:54:37.1750 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 9f8e04e4-cb96-45f0-41ca-08dd940377cc X-MS-Exchange-CrossTenant-Id: 3dd8961f-e488-4e60-8e11-a82d994e183d X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=3dd8961f-e488-4e60-8e11-a82d994e183d;Ip=[165.204.84.17];Helo=[SATLEXMB04.amd.com] X-MS-Exchange-CrossTenant-AuthSource: BN2PEPF0000449F.namprd02.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: SJ0PR12MB8615 Content-Type: text/plain; charset="utf-8" The mbm_cntr_assign mode offers "num_mbm_cntrs" number of counters that can be assigned to an RMID, event pair and monitor the bandwidth as long as it is assigned. If all the counters are in use, the kernel will log the error message "Unable to allocate counter in domain" in /sys/fs/resctrl/info/last_cmd_status when a new assignment is requested. To make space for a new assignment, users must unassign an already assigned counter and retry the assignment again. Add the functionality to unassign and free the counters in the domain. Signed-off-by: Babu Moger --- v13: Moved mbm_cntr_free() to this patch as it is used in here first. Not required to pass evt_cfg to resctrl_unassign_cntr_event(). It is available via mbm_get_mon_event(). Resolved conflicts caused by the recent FS/ARCH code restructure. The monitor.c file has now been split between the FS and ARCH director= ies. v12: Updated the commit text to make bit more clear. Replaced several counters with "num_mbm_cntrs" counters. Fixed typo in the subjest line. Fixed the handling error on first failure. Added domain id and event id on failure. Added new parameter event configuration (evt_cfg) to provide the event= from user space. v11: Moved the functions to monitor.c. Renamed rdtgroup_unassign_cntr_event() to resctrl_unassign_cntr_event(= ). Refactored the resctrl_unassign_cntr_event(). Updated commit message and code comments. v10: Patch changed again. Counters are managed at the domain based on the discussion. https://lore.kernel.org/lkml/CALPaoCj+zWq1vkHVbXYP0znJbe6Ke3PXPWjtri5A= FgD9cQDCUg@mail.gmail.com/ commit message update. v9: Changes related to addition of new function resctrl_config_cntr(). The removed rdtgroup_mbm_cntr_is_assigned() as it was introduced already. Text changes to take care comments. v8: Renamed rdtgroup_mbm_cntr_is_assigned to mbm_cntr_assigned_to_domain Added return error handling in resctrl_arch_config_cntr(). v7: Merged rdtgroup_unassign_cntr and rdtgroup_free_cntr functions. Renamed rdtgroup_mbm_cntr_test() to rdtgroup_mbm_cntr_is_assigned(). Reworded the commit log little bit. v6: Removed mbm_cntr_free from this patch. Added counter test in all the domains and free if it is not assigned to any domains. v5: Few name changes to match cntr_id. Changed the function names to rdtgroup_unassign_cntr More comments on commit log. v4: Added domain specific unassign feature. Few name changes. v3: Removed the static from the prototype of rdtgroup_unassign_abmc. The function is not called directly from user anymore. These changes are related to global assignment interface. v2: No changes. --- fs/resctrl/internal.h | 2 ++ fs/resctrl/monitor.c | 60 +++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 62 insertions(+) diff --git a/fs/resctrl/internal.h b/fs/resctrl/internal.h index ce4fcac91937..64ddc107fcab 100644 --- a/fs/resctrl/internal.h +++ b/fs/resctrl/internal.h @@ -379,6 +379,8 @@ int resctrl_find_cleanest_closid(void); =20 int resctrl_assign_cntr_event(struct rdt_resource *r, struct rdt_mon_domai= n *d, struct rdtgroup *rdtgrp, enum resctrl_event_id evtid); +int resctrl_unassign_cntr_event(struct rdt_resource *r, struct rdt_mon_dom= ain *d, + struct rdtgroup *rdtgrp, enum resctrl_event_id evtid); =20 #ifdef CONFIG_RESCTRL_FS_PSEUDO_LOCK int rdtgroup_locksetup_enter(struct rdtgroup *rdtgrp); diff --git a/fs/resctrl/monitor.c b/fs/resctrl/monitor.c index d76fd0840946..fbc938bd3b23 100644 --- a/fs/resctrl/monitor.c +++ b/fs/resctrl/monitor.c @@ -989,6 +989,14 @@ static int mbm_cntr_alloc(struct rdt_resource *r, stru= ct rdt_mon_domain *d, return -ENOSPC; } =20 +/* + * mbm_cntr_free() - Reset cntr_id to zero. + */ +static void mbm_cntr_free(struct rdt_mon_domain *d, int cntr_id) +{ + memset(&d->cntr_cfg[cntr_id], 0, sizeof(struct mbm_cntr_cfg)); +} + /* * mbm_get_mon_event() - Return the mon_evt entry for the matching evtid. */ @@ -1068,3 +1076,55 @@ int resctrl_assign_cntr_event(struct rdt_resource *r= , struct rdt_mon_domain *d, =20 return ret; } + +/* + * Unassign and free the counter if assigned. + */ +static int resctrl_free_config_cntr(struct rdt_resource *r, struct rdt_mon= _domain *d, + struct rdtgroup *rdtgrp, enum resctrl_event_id evtid) +{ + struct mon_evt *mevt; + int cntr_id; + + cntr_id =3D mbm_cntr_get(r, d, rdtgrp, evtid); + + /* If there is no cntr_id assigned, nothing to do */ + if (cntr_id < 0) + return 0; + + mevt =3D mbm_get_mon_event(r, evtid); + if (!mevt) { + rdt_last_cmd_printf("Invalid event id %d\n", evtid); + return -EINVAL; + } + + resctrl_config_cntr(r, d, evtid, rdtgrp->mon.rmid, rdtgrp->closid, + cntr_id, mevt->evt_cfg, false); + + mbm_cntr_free(d, cntr_id); + + return 0; +} + +/* + * Unassign a hardware counter associated with @evtid from the domain and + * the group. Unassign the counters from all the domains if @d is NULL else + * unassign from @d. + */ +int resctrl_unassign_cntr_event(struct rdt_resource *r, struct rdt_mon_do= main *d, + struct rdtgroup *rdtgrp, enum resctrl_event_id evtid) +{ + int ret; + + if (!d) { + list_for_each_entry(d, &r->mon_domains, hdr.list) { + ret =3D resctrl_free_config_cntr(r, d, rdtgrp, evtid); + if (ret) + return ret; + } + } else { + ret =3D resctrl_free_config_cntr(r, d, rdtgrp, evtid); + } + + return ret; +} --=20 2.34.1 From nobody Sun Dec 14 02:00:56 2025 Received: from NAM11-CO1-obe.outbound.protection.outlook.com (mail-co1nam11on2061.outbound.protection.outlook.com [40.107.220.61]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 3BED3298996; Thu, 15 May 2025 22:54:49 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.220.61 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1747349692; cv=fail; b=FgMjvzIDBncxVa7Uj+LGbKuljKuaeQo9nGJky3A1ojcQYqbQ9nAcWoW9j6ktHsRmLaWsYOBQWVFkQym+o0SHjePnPi+LDGIstCx9XF4uN3q7sUiFfqiJY5R+oyWpRZ9gLSNjiPvHxbfSgxgZLfAppdaQ8W1Es67Hjc+bvIqAHqE= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1747349692; c=relaxed/simple; bh=lWL9ozXIEU4adkYROpVZ/JouhefYUAEJa59x+2x5pSc=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=okmdK0LiTkrH0oHwrx1+FbJyVDGHuuA5X4FdUBMjldWIqjOYzI6OYyeGYZjPPGmAlrj30gxCaQayHwwJkGpab6yr1RS+ikznvU6Z5c9IpZEXkfWGGv0qUXOmiyPsYq0d1Dy42xTST1rWNZxXQzD0fJ85ADAIOZ2my+/nVueaERg= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=amd.com; spf=fail smtp.mailfrom=amd.com; dkim=pass (1024-bit key) header.d=amd.com header.i=@amd.com header.b=YQEzfIrV; arc=fail smtp.client-ip=40.107.220.61 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=amd.com Authentication-Results: smtp.subspace.kernel.org; spf=fail smtp.mailfrom=amd.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=amd.com header.i=@amd.com header.b="YQEzfIrV" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=yCC5oYeSNN+8NaAB+trvB/esI9X/TxU7bzkeRXzGhGgh5T1yCcGInSeR2K38pH2W0yU9783G1/nvg3pnCQGnhLPTnhSsVvg5g0RLg82/P3tQAYd80tEw75Q164Ft5rEmC536pXa0hWH9xmwSS9HqndQRCdRRs8s+bUUS+NUmbLivchRhh1+X+XWmeDqA9Ev5zmlxFsPP6Ke+bc6ZMSBPquugaHgIW9iDnf7AfKetCE39+IY4swZfqPyQn526be4uG0grKGTUKrkySePqFi/IcfKGqNcLgph0LCW5MFbe6vMrSknTwWVQAKCqWkXkqcNnklU6udMbmn1eon3hl0RFUg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=BhEUDIMo2Fu8S0Huk+Ti2RqKqojAuDl/+x5tIa9M4jY=; b=Ppoblr9WVWacsFwLJq0WWFizb96MXAxnaJY7eOfroFTQ14ClM2x0RDWHmltMlSUy5S37PwNcbNkIg+ZYegAIaGL6PmIPb+A4v20yboZixH5opvu/zozWnGyYQveZBlT6T/WhLZTS/MKqh3Ln2fak2kibszYM1iYpQfzrmhAa+wec2np4MaatfYdzNh3Cx9Dmy3TKkfQ7NlpmoLu773DKM5ecCa05FKioRHEBudva1rBaoZvsGuJ5cGvpAwWXbuHvEnGNvC6YYINjADQwjXNnzBGrBY329BEvsc5sT+GWSaAA8k8mJXDa0/iB+P3ghyx/5Bsvt3m9CROSj2q5Goxc/g== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=lwn.net smtp.mailfrom=amd.com; dmarc=pass (p=quarantine sp=quarantine pct=100) action=none header.from=amd.com; dkim=none (message not signed); arc=none (0) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amd.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=BhEUDIMo2Fu8S0Huk+Ti2RqKqojAuDl/+x5tIa9M4jY=; b=YQEzfIrV5svE3R3Gipd3vdMnU6vy2rUd6CUKLbV7ihiuh/zgcAUs3noFW9NUE1xJbg5bkA1Tlu0VMuvsO3u8Gg9g8UNDZW7iS4YfNjkefLeSEGmeQo/8WpAADeY7zrExkxdt1FfX6VlXK8BxGVZCGgO40uNxUQ28UkD2UVz7JYs= Received: from BN9PR03CA0060.namprd03.prod.outlook.com (2603:10b6:408:fb::35) by LV8PR12MB9081.namprd12.prod.outlook.com (2603:10b6:408:188::12) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8722.31; Thu, 15 May 2025 22:54:45 +0000 Received: from BN2PEPF0000449F.namprd02.prod.outlook.com (2603:10b6:408:fb:cafe::c9) by BN9PR03CA0060.outlook.office365.com (2603:10b6:408:fb::35) with Microsoft SMTP Server (version=TLS1_3, cipher=TLS_AES_256_GCM_SHA384) id 15.20.8722.30 via Frontend Transport; Thu, 15 May 2025 22:54:45 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 165.204.84.17) smtp.mailfrom=amd.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=amd.com; Received-SPF: Pass (protection.outlook.com: domain of amd.com designates 165.204.84.17 as permitted sender) receiver=protection.outlook.com; client-ip=165.204.84.17; helo=SATLEXMB04.amd.com; pr=C Received: from SATLEXMB04.amd.com (165.204.84.17) by BN2PEPF0000449F.mail.protection.outlook.com (10.167.243.150) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.8722.18 via Frontend Transport; Thu, 15 May 2025 22:54:45 +0000 Received: from bmoger-ubuntu.amd.com (10.180.168.240) by SATLEXMB04.amd.com (10.181.40.145) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.39; Thu, 15 May 2025 17:54:42 -0500 From: Babu Moger To: , , , , , , CC: , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , Subject: [PATCH v13 15/27] x86/resctrl: Report 'Unassigned' for MBM events in mbm_cntr_assign mode Date: Thu, 15 May 2025 17:52:00 -0500 Message-ID: X-Mailer: git-send-email 2.34.1 In-Reply-To: References: Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-ClientProxiedBy: SATLEXMB04.amd.com (10.181.40.145) To SATLEXMB04.amd.com (10.181.40.145) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: BN2PEPF0000449F:EE_|LV8PR12MB9081:EE_ X-MS-Office365-Filtering-Correlation-Id: 5ada5381-b3a2-4a24-2e82-08dd94037ce0 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|82310400026|7416014|376014|1800799024|36860700013; X-Microsoft-Antispam-Message-Info: =?us-ascii?Q?cldwbeTSwMya7VVX3R5mpZDiUSLC2CXsMgBxN634Sd1hOv18KweNdqxl8wyE?= =?us-ascii?Q?cNsx0Rwcv6DDZPSQssDz8m6Y7SvF54QPzCiKZNJk9WHRTFi/keGuu95m2UoN?= =?us-ascii?Q?TQXgACcU9iTwosrV4/F+UdKLKpQtd8x5BYhy4oxVqj6vmSexMQTAES7IHq4K?= =?us-ascii?Q?iNVi2rwjAUm1MUjdONaDtWcWdc8G55D+RjlAXeJEya4mb1PjnQh/nqoBNbjZ?= =?us-ascii?Q?1mUPgIv67/XRXSWm1w3XgZuTXUXOFS1tbzUu2qibBuZuXL99rz2mGVBViPeJ?= =?us-ascii?Q?YMaRcQGOX4poTiu7PlsZcQ79uRAsE+RJn4g/ZqulqJsImdIGY7+9lDo/51wJ?= =?us-ascii?Q?WLrY7xRZG7KqUmQbnf9MjWnyYPAP8YAy2XZ6Qr6Ews27MdkZrCceco95w+u6?= =?us-ascii?Q?yocQRJCJFcXp3vg39b3yXps+8UE6oY2F/azn+bt+0IXjXrmNJHVr92MOjVCz?= =?us-ascii?Q?lgLVVdVv3hUCbNaLSEMMRw++RKSbGQN1DjFOtRKrl7jOEsRJCuR3zzk7TCwb?= =?us-ascii?Q?OZJzXgCkJ/YxyCIXJ+YvAnTn/ULgDzZNDg231aagLIEQzn/DN+tM4XTCch8U?= =?us-ascii?Q?w2yTrd0Ct5F4X+kSvZ+JvcDdNI6X+BUVi2Isb4+JE6S6E+FQcLPaJxYwtTfi?= =?us-ascii?Q?KRVAidGiNCocUQznxln47el4Tbs1F61nhgdSOdtSe6vMCYVzt/3Ev8M3Z4EO?= =?us-ascii?Q?v9zOSZOMJmAmI02MEsEScyy+E+6weSpVpxlbJz7z6punXEuq9kvQ/RcWE1TM?= =?us-ascii?Q?4elvfaLk4tEwWAbiuUdf5QxNIFdpTkMWacEdTZ38GX+TfsvQR1s4wNHtU5sN?= =?us-ascii?Q?LTDj4M/nGLUqFgx2DIjlJ8HzdFtAp2KpnkxXt+55+NUJcfLu9Qy4ofo3RcDT?= =?us-ascii?Q?2P9Mn2T6mMeVOwozNUxXwx+2KnWP1MC4V6yyUY2uLy/clt16VGXgNlie42gB?= =?us-ascii?Q?rHcHgTM/1jblsPCy0a30LztGU0Ibe/oUECeNJZLDJVHKFKiOlXeQus9iGt4S?= =?us-ascii?Q?8pWPhdDenz1t8EAJbTufEVrSkClE5UAqhynVw8fRREWZGcA5+B2zsSmllDEZ?= =?us-ascii?Q?/HwR3hXUcQVP08Grua2ogBfYhfAc6f+gAyFIO0qXcS/3cWTSu049xADYDD0p?= =?us-ascii?Q?EU2kCbqq+Z2DDDBUgtlh0CTaeH6Jncj4Sxx0oomdP5pXopID62ZOjJrbRkXp?= =?us-ascii?Q?nM7f1+eIJiEvPKfLcIkQ34FxbbWqMLKWTYgchTscntHArXUq/5nqH6Um6s9a?= =?us-ascii?Q?mvEDHnVDT2r4Bipz1sdLY7Pi1ivgeLHgwASl4AA38EOh73XOWxHNt3NhCD8Q?= =?us-ascii?Q?sq1XbbYuyFrCw1Wf+tSG+d1u5oztoLdSwQkJxn7DJVZulpBpqH+cTl2qJvXp?= =?us-ascii?Q?82p9+O0033HE5F99PcU+ftQD1EgXTlKovEhxvQ5bQBAIii11kzfkV5gyZjcc?= =?us-ascii?Q?ePOxZOkGPmpEfSRITHbSZbnVV710bxeLOI9b/nP3aLJHFKc+LZxqIP23qVpy?= =?us-ascii?Q?v7hRqNXzCZdVkyLbOPmrCG7EwGSmwURGs7za?= X-Forefront-Antispam-Report: CIP:165.204.84.17;CTRY:US;LANG:en;SCL:1;SRV:;IPV:CAL;SFV:NSPM;H:SATLEXMB04.amd.com;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(13230040)(82310400026)(7416014)(376014)(1800799024)(36860700013);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 15 May 2025 22:54:45.6929 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 5ada5381-b3a2-4a24-2e82-08dd94037ce0 X-MS-Exchange-CrossTenant-Id: 3dd8961f-e488-4e60-8e11-a82d994e183d X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=3dd8961f-e488-4e60-8e11-a82d994e183d;Ip=[165.204.84.17];Helo=[SATLEXMB04.amd.com] X-MS-Exchange-CrossTenant-AuthSource: BN2PEPF0000449F.namprd02.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: LV8PR12MB9081 Content-Type: text/plain; charset="utf-8" In mbm_cntr_assign mode, the hardware counter should be assigned to read the MBM events. Report 'Unassigned' in case the user attempts to read the event without assigning a hardware counter. Export resctrl_is_mbm_event() and mbm_cntr_get() to allow usage from other functions within fs/resctrl. Signed-off-by: Babu Moger --- v13: Minor commitlog and user doc update. Resolved conflicts caused by the recent FS/ARCH code restructure. The monitor.c/rdtgroup.c files have been split between the FS and ARCH= directories. v12: Updated the documentation for more clarity. v11: Domain can be NULL with SNC support so moved the unassign check in rdtgroup_mondata_show(). v10: Moved the code to check the assign state inside mon_event_read(). Fixed few text comments. v9: Used is_mbm_event() to check the event type. Minor user documentation update. v8: Used MBM_EVENT_ARRAY_INDEX to get the index for the MBM event. Documentation update to make the text generic. v7: Moved the documentation under "mon_data". Updated the text little bit. v6: Added more explaination in the resctrl.rst Added checks to detect "Unassigned" before reading RMID. v5: New patch. --- Documentation/filesystems/resctrl.rst | 8 ++++++++ fs/resctrl/ctrlmondata.c | 14 ++++++++++++++ fs/resctrl/internal.h | 2 ++ fs/resctrl/monitor.c | 4 ++-- fs/resctrl/rdtgroup.c | 2 +- include/linux/resctrl.h | 1 + 6 files changed, 28 insertions(+), 3 deletions(-) diff --git a/Documentation/filesystems/resctrl.rst b/Documentation/filesyst= ems/resctrl.rst index 2bfad43aac9c..5cf2d742f04c 100644 --- a/Documentation/filesystems/resctrl.rst +++ b/Documentation/filesystems/resctrl.rst @@ -430,6 +430,14 @@ When monitoring is enabled all MON groups will also co= ntain: for the L3 cache they occupy). These are named "mon_sub_L3_YY" where "YY" is the node number. =20 + The mbm_cntr_assign mode offers "num_mbm_cntrs" number of counters + and allows users to assign a counter to mon_hw_id, event pair enabling + bandwidth monitoring for as long as the counter remains assigned. + The hardware will continue tracking the assigned mon_hw_id until + the user manually unassigns it, ensuring that counters are not reset + during this period. An MBM event returns 'Unassigned' when the event + does not have a hardware counter assigned. + "mon_hw_id": Available only with debug option. The identifier used by hardware for the monitor group. On x86 this is the RMID. diff --git a/fs/resctrl/ctrlmondata.c b/fs/resctrl/ctrlmondata.c index 6ed2dfd4dbbd..f6b8ad24b0b5 100644 --- a/fs/resctrl/ctrlmondata.c +++ b/fs/resctrl/ctrlmondata.c @@ -643,6 +643,18 @@ int rdtgroup_mondata_show(struct seq_file *m, void *ar= g) goto out; } d =3D container_of(hdr, struct rdt_mon_domain, hdr); + + /* + * Report 'Unassigned' if mbm_cntr_assign mode is enabled and + * counter is unassigned. + */ + if (resctrl_arch_mbm_cntr_assign_enabled(r) && + resctrl_is_mbm_event(evtid) && + (mbm_cntr_get(r, d, rdtgrp, evtid) < 0)) { + rr.err =3D -ENOENT; + goto checkresult; + } + mon_event_read(&rr, r, d, rdtgrp, &d->hdr.cpu_mask, evtid, false); } =20 @@ -652,6 +664,8 @@ int rdtgroup_mondata_show(struct seq_file *m, void *arg) seq_puts(m, "Error\n"); else if (rr.err =3D=3D -EINVAL) seq_puts(m, "Unavailable\n"); + else if (rr.err =3D=3D -ENOENT) + seq_puts(m, "Unassigned\n"); else seq_printf(m, "%llu\n", rr.val); =20 diff --git a/fs/resctrl/internal.h b/fs/resctrl/internal.h index 64ddc107fcab..0dfd2efe68fc 100644 --- a/fs/resctrl/internal.h +++ b/fs/resctrl/internal.h @@ -381,6 +381,8 @@ int resctrl_assign_cntr_event(struct rdt_resource *r, s= truct rdt_mon_domain *d, struct rdtgroup *rdtgrp, enum resctrl_event_id evtid); int resctrl_unassign_cntr_event(struct rdt_resource *r, struct rdt_mon_dom= ain *d, struct rdtgroup *rdtgrp, enum resctrl_event_id evtid); +int mbm_cntr_get(struct rdt_resource *r, struct rdt_mon_domain *d, + struct rdtgroup *rdtgrp, enum resctrl_event_id evtid); =20 #ifdef CONFIG_RESCTRL_FS_PSEUDO_LOCK int rdtgroup_locksetup_enter(struct rdtgroup *rdtgrp); diff --git a/fs/resctrl/monitor.c b/fs/resctrl/monitor.c index fbc938bd3b23..c98a61bde179 100644 --- a/fs/resctrl/monitor.c +++ b/fs/resctrl/monitor.c @@ -956,8 +956,8 @@ static void resctrl_config_cntr(struct rdt_resource *r,= struct rdt_mon_domain *d * mbm_cntr_get() - Return the cntr_id for the matching evtid and rdtgrp in * cntr_cfg array. */ -static int mbm_cntr_get(struct rdt_resource *r, struct rdt_mon_domain *d, - struct rdtgroup *rdtgrp, enum resctrl_event_id evtid) +int mbm_cntr_get(struct rdt_resource *r, struct rdt_mon_domain *d, + struct rdtgroup *rdtgrp, enum resctrl_event_id evtid) { int cntr_id; =20 diff --git a/fs/resctrl/rdtgroup.c b/fs/resctrl/rdtgroup.c index f192b2736a77..72317a5adee2 100644 --- a/fs/resctrl/rdtgroup.c +++ b/fs/resctrl/rdtgroup.c @@ -127,7 +127,7 @@ static bool resctrl_is_mbm_enabled(void) resctrl_arch_is_mbm_local_enabled()); } =20 -static bool resctrl_is_mbm_event(int e) +bool resctrl_is_mbm_event(int e) { return (e >=3D QOS_L3_MBM_TOTAL_EVENT_ID && e <=3D QOS_L3_MBM_LOCAL_EVENT_ID); diff --git a/include/linux/resctrl.h b/include/linux/resctrl.h index 59a4fe60ab46..f78b6064230c 100644 --- a/include/linux/resctrl.h +++ b/include/linux/resctrl.h @@ -441,6 +441,7 @@ static inline u32 resctrl_get_config_index(u32 closid, } } =20 +bool resctrl_is_mbm_event(int e); bool resctrl_arch_get_cdp_enabled(enum resctrl_res_level l); int resctrl_arch_set_cdp_enabled(enum resctrl_res_level l, bool enable); =20 --=20 2.34.1 From nobody Sun Dec 14 02:00:56 2025 Received: from NAM11-BN8-obe.outbound.protection.outlook.com (mail-bn8nam11on2075.outbound.protection.outlook.com [40.107.236.75]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id C081C28DEEF; Thu, 15 May 2025 22:55:00 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.236.75 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1747349702; cv=fail; b=Gfk4mHk9Qxx5q6AkEpjz8qZ1ZiN0TetyMI/vtDpFEHpKJHgWtBxhap1yEV4Ych6JrB40pw0mKx9A/To7i8R9v3f/1hi7kYYue5BvRkMuxKShfimAyrV+5KAdXCED5VDZKqeRK+okqc6j9pv07NQBASfdcRaplrSm7NPSxnCu+dc= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1747349702; c=relaxed/simple; bh=lBqb0Xa8L2yzM9ozcYRGjljFWkx/PwcR+IwWA65uhNw=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=HBVrzRYjQNXZzr8rn5UEskBtlUQDl9AaLvC4pFhsl++8EmoYs0CAB3L40Kl5ROOdoFKNYF/BMcX9onjsxpbv0z+EgYl3PBthyShwtYv1lFokNyT8Y7KNJOxhVCyiocyYPjTyFARHDna+SwkSYoeqn0+GsY+We1MEBtRrpgz2TeE= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=amd.com; spf=fail smtp.mailfrom=amd.com; dkim=pass (1024-bit key) header.d=amd.com header.i=@amd.com header.b=T5dMFJiS; arc=fail smtp.client-ip=40.107.236.75 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=amd.com Authentication-Results: smtp.subspace.kernel.org; spf=fail smtp.mailfrom=amd.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=amd.com header.i=@amd.com header.b="T5dMFJiS" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=KNYU+wi4/xpCMBr5Q7/kRg3OsCsQmHEDxI7zEMJIv22iuZd6kah6TnoYo2gcF2icq4kZY8Ku9QoAGobjg2db7NutXHQWLTDGaivVOJoDAAN9iv+PP6JYcpV7Gu5c7yQKxRmWdmhr6BAQkc47j5NvgYN++XF/xUG/ne8MZs+6+3ohbpsguBip8Tjj028U9VTnsRMhbD2zjBLbyMxuwtUgPmIp9YnWTl1C0xqH7QWUcPGJZkCLYP+27ThXUQgFVtpPFLl71ZQWsFF9+QpUbnbK4fpORTnb7yNq+ZiuUW9/PtswBvHFuorCfNDbC3T2JW8u4Xu8BiAezAzNKwpYtwQcuA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=DBSmw/7fN55eUCQShymQRXbY48bKvu4eLQuT2aajrwQ=; b=XY1U/cgxWHlQuQy1+e9j32pQOJdjEN7qsYmeRbTHEryUMKB4dyDDoO0LxCkQ30sDk53N8aZsf6/zP5qfAIxtT34DuHR3aq9oZJWbGoLXcNun7lq0fZ7aHrD2vCMfeI0+iveY5jvJceAtm48AMuCZIZlfE5yOa3bH1d+BYttSU9730FuDOcuc8zTzxVYeVyjEqQC108NXApeJu5o3KuflTMwKR4BtJMmZ1nSLcS02X90Kg7fT+JpqGJxZtvRv0Epn+2vWVm7m0blUfrAW1Z2Hl90qbC/JHZaq7mdwSa3g1S2UHPYo0eGs84i0rvKrdBHyVcuQNk0wayPDGIDEHYbmjg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=lwn.net smtp.mailfrom=amd.com; dmarc=pass (p=quarantine sp=quarantine pct=100) action=none header.from=amd.com; dkim=none (message not signed); arc=none (0) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amd.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=DBSmw/7fN55eUCQShymQRXbY48bKvu4eLQuT2aajrwQ=; b=T5dMFJiSRKIIJTAlq1tHpdeLjJ29fZyrejO427FYFwImR0yMiKmBPX07ZfQru79+T0bsGPTadEJMDAYbr+1rsRTnk3g0WtQZIAIVJSRnuJaRdAayF7/Y2hN1MGZ2D5+mLknA04nkWkCbMVx2nWMmkemyLe36R513h+I8YPc+/uM= Received: from BLAPR03CA0008.namprd03.prod.outlook.com (2603:10b6:208:32b::13) by SA1PR12MB8917.namprd12.prod.outlook.com (2603:10b6:806:386::20) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8722.29; Thu, 15 May 2025 22:54:56 +0000 Received: from BN2PEPF0000449E.namprd02.prod.outlook.com (2603:10b6:208:32b:cafe::95) by BLAPR03CA0008.outlook.office365.com (2603:10b6:208:32b::13) with Microsoft SMTP Server (version=TLS1_3, cipher=TLS_AES_256_GCM_SHA384) id 15.20.8699.32 via Frontend Transport; Thu, 15 May 2025 22:54:55 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 165.204.84.17) smtp.mailfrom=amd.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=amd.com; Received-SPF: Pass (protection.outlook.com: domain of amd.com designates 165.204.84.17 as permitted sender) receiver=protection.outlook.com; client-ip=165.204.84.17; helo=SATLEXMB04.amd.com; pr=C Received: from SATLEXMB04.amd.com (165.204.84.17) by BN2PEPF0000449E.mail.protection.outlook.com (10.167.243.149) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.8722.18 via Frontend Transport; Thu, 15 May 2025 22:54:55 +0000 Received: from bmoger-ubuntu.amd.com (10.180.168.240) by SATLEXMB04.amd.com (10.181.40.145) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.39; Thu, 15 May 2025 17:54:52 -0500 From: Babu Moger To: , , , , , , CC: , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , Subject: [PATCH v13 16/27] x86/resctrl: Pass entire struct rdtgroup rather than passing individual members Date: Thu, 15 May 2025 17:52:01 -0500 Message-ID: <619c9cbb6b1525a2d4a46a042384e6771800d61c.1747349530.git.babu.moger@amd.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: References: Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-ClientProxiedBy: SATLEXMB04.amd.com (10.181.40.145) To SATLEXMB04.amd.com (10.181.40.145) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: BN2PEPF0000449E:EE_|SA1PR12MB8917:EE_ X-MS-Office365-Filtering-Correlation-Id: 0fcbc504-ceb7-4ec9-dadc-08dd940382f8 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|1800799024|82310400026|36860700013|376014|7416014; X-Microsoft-Antispam-Message-Info: =?us-ascii?Q?kaqqYBW674tgMutXOcWq7vSW0LVBenMgWegEr/xPS/NfxkrbyomRq6DIVDkb?= =?us-ascii?Q?qQse6w1CzeeYeQOxJIvo+XyEkeTaomlOGhdX2LME1lnAPyGf9aYToqI2iVVq?= =?us-ascii?Q?EnbAUpGZ5J7IIZ/DYtoljoXAUJOjj+0e7jdyinjMsoDcyanhPeyRqyHHUQiv?= =?us-ascii?Q?jq9fKNI+4Ao9W7tyF+m/Xb/Drd0F1fZ/buPSNOOz5nghBf/Qbd7uYUnYKCPK?= =?us-ascii?Q?5gJpE+KavC52VhLgJhiiXvSbFY3zUr9QPDTnO/RoOQ6OqtIf6na4rNvOhssv?= =?us-ascii?Q?hqn/OmeXv6n6rt4mWc1S51KSMKoboKi0XUvx1SKK79cn7gs1CLznR5azObFF?= =?us-ascii?Q?EaDY3km7MAh7F241MouuFidCWEpr2QY7OixOC79f08j69nhjob5DUddkoD5b?= =?us-ascii?Q?DPbaKodA5SRkD9xtiODV0nnKjgTQOouQoyI/EziigdgYvh5G4y/u7yhY5VdS?= =?us-ascii?Q?FQ817/aZHZRo9FI4pMrm8AzXoaQ1Dsb0tIVo5BbbZifzlQYd0KXlUF5d4eqS?= =?us-ascii?Q?ijjy8/wkw3xvDwl9Eeaq2+VVZE1gcx5mRMHSrF+q0alVLvlfnKf550+Id/8Y?= =?us-ascii?Q?ECFQ11vB5asirtV2IEMdR579qKoeBGUqZzzzfcvmTXKzk1RWuJSq/5Ga7bcy?= =?us-ascii?Q?Md7womUS0XI2z2CfwJd07h/ZLlc94P+4arFrQOUpmGP0+0Av6Uc4MpaOsFNN?= =?us-ascii?Q?FcNEpu03ha00jEq3oDPvHo84/FW1zSET7Rl4CJnXug4p/Rl1/wUqabu2EmSf?= =?us-ascii?Q?AtLTDtIDlpnBepGDYsGoHLh+Q8FYXn6SNQlFg0vJLPDf4Y7KpcDqed40ygAn?= =?us-ascii?Q?unowZzWLrg7q5HFl0ZmXyGjNegnfUfOkYNk8aKElLr6f7mon+qK38466OCvD?= =?us-ascii?Q?5SFTUhhk3lAiC+7GJVSTqb8p5FzZp8bKDkPSNODen69WU1qm1rYJiSqo56wh?= =?us-ascii?Q?wsx2XtVBCkg4HHneJ99Mzz4K4tP669NLk6XeNXnn/fvRNY7R+Pi0XAq5oA0I?= =?us-ascii?Q?HxzU22AEluwBrL4vL2kQ5PxQb2QBeYBWz+n6MqkpAEIlOkEhfiSLKwzO6elj?= =?us-ascii?Q?njRwyvhlSmcjrT7pHudrbACu6ITDOhVq7krii0xZGIB0oV9LdRIuoUMwxTcr?= =?us-ascii?Q?ys7hTup5oWavamQDggaEvtL0W06rohacAb4DHK2b8i61RZESj4HSrpcgAtLN?= =?us-ascii?Q?gDgxz8LNo5gxsvb3Aefs/bfSKqJvei7gjNSHUSVKvhmoHZeyppYQXqp63rrL?= =?us-ascii?Q?iaucEA3mtpAuf+7uDfdGRR5gWXp2TxjtDPXz8/5IRtM4cHkowtRBLHWGUuSh?= =?us-ascii?Q?1sEdeuj5zdovTVzgq0+Szpoxb9AhmyWSiYVh3jATKAebpY9H/o9xGuuqK9vm?= =?us-ascii?Q?3t9uJWd1N6hI70g1D1JA086ZqEP2plOSkrHP2NJSZCIigaqAF/S/k/HUMcUi?= =?us-ascii?Q?pABho+VEf1bv8vhhTQ/sg0/SNQ9ju6W48qP7fp2xnDP24UseV3FgSe54fuWw?= =?us-ascii?Q?oIaKEKxHhYzujbrvMNPsnW/2f0iMmeI/4zBc?= X-Forefront-Antispam-Report: CIP:165.204.84.17;CTRY:US;LANG:en;SCL:1;SRV:;IPV:CAL;SFV:NSPM;H:SATLEXMB04.amd.com;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(13230040)(1800799024)(82310400026)(36860700013)(376014)(7416014);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 15 May 2025 22:54:55.9215 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 0fcbc504-ceb7-4ec9-dadc-08dd940382f8 X-MS-Exchange-CrossTenant-Id: 3dd8961f-e488-4e60-8e11-a82d994e183d X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=3dd8961f-e488-4e60-8e11-a82d994e183d;Ip=[165.204.84.17];Helo=[SATLEXMB04.amd.com] X-MS-Exchange-CrossTenant-AuthSource: BN2PEPF0000449E.namprd02.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: SA1PR12MB8917 Content-Type: text/plain; charset="utf-8" The mbm_cntr_assign mode requires a cntr_id to read event data. The cntr_id is retrieved via mbm_cntr_get, which takes a struct rdtgroup as a parameter. Passing the full rdtgroup also provides access to closid and rmid, both of which are necessary to read monitoring events. Refactor the code to pass the entire struct rdtgroup instead of individual members in preparation for this requirement. Suggested-by: Reinette Chatre Signed-off-by: Babu Moger --- v13: New patch to pass the entire struct rdtgroup to __mon_event_count(), mbm_update(), and related functions. --- fs/resctrl/monitor.c | 29 ++++++++++++++++------------- 1 file changed, 16 insertions(+), 13 deletions(-) diff --git a/fs/resctrl/monitor.c b/fs/resctrl/monitor.c index c98a61bde179..a477be9cdb66 100644 --- a/fs/resctrl/monitor.c +++ b/fs/resctrl/monitor.c @@ -357,9 +357,11 @@ static struct mbm_state *get_mbm_state(struct rdt_mon_= domain *d, u32 closid, } } =20 -static int __mon_event_count(u32 closid, u32 rmid, struct rmid_read *rr) +static int __mon_event_count(struct rdtgroup *rdtgrp, struct rmid_read *rr) { int cpu =3D smp_processor_id(); + u32 closid =3D rdtgrp->closid; + u32 rmid =3D rdtgrp->mon.rmid; struct rdt_mon_domain *d; struct mbm_state *m; int err, ret; @@ -428,9 +430,11 @@ static int __mon_event_count(u32 closid, u32 rmid, str= uct rmid_read *rr) * __mon_event_count() is compared with the chunks value from the previous * invocation. This must be called once per second to maintain values in M= Bps. */ -static void mbm_bw_count(u32 closid, u32 rmid, struct rmid_read *rr) +static void mbm_bw_count(struct rdtgroup *rdtgrp, struct rmid_read *rr) { u64 cur_bw, bytes, cur_bytes; + u32 closid =3D rdtgrp->closid; + u32 rmid =3D rdtgrp->mon.rmid; struct mbm_state *m; =20 m =3D get_mbm_state(rr->d, closid, rmid, rr->evtid); @@ -459,7 +463,7 @@ void mon_event_count(void *info) =20 rdtgrp =3D rr->rgrp; =20 - ret =3D __mon_event_count(rdtgrp->closid, rdtgrp->mon.rmid, rr); + ret =3D __mon_event_count(rdtgrp, rr); =20 /* * For Ctrl groups read data from child monitor groups and @@ -470,8 +474,7 @@ void mon_event_count(void *info) =20 if (rdtgrp->type =3D=3D RDTCTRL_GROUP) { list_for_each_entry(entry, head, mon.crdtgrp_list) { - if (__mon_event_count(entry->closid, entry->mon.rmid, - rr) =3D=3D 0) + if (__mon_event_count(entry, rr) =3D=3D 0) ret =3D 0; } } @@ -602,7 +605,7 @@ static void update_mba_bw(struct rdtgroup *rgrp, struct= rdt_mon_domain *dom_mbm) } =20 static void mbm_update_one_event(struct rdt_resource *r, struct rdt_mon_do= main *d, - u32 closid, u32 rmid, enum resctrl_event_id evtid) + struct rdtgroup *rdtgrp, enum resctrl_event_id evtid) { struct rmid_read rr =3D {0}; =20 @@ -616,30 +619,30 @@ static void mbm_update_one_event(struct rdt_resource = *r, struct rdt_mon_domain * return; } =20 - __mon_event_count(closid, rmid, &rr); + __mon_event_count(rdtgrp, &rr); =20 /* * If the software controller is enabled, compute the * bandwidth for this event id. */ if (is_mba_sc(NULL)) - mbm_bw_count(closid, rmid, &rr); + mbm_bw_count(rdtgrp, &rr); =20 resctrl_arch_mon_ctx_free(rr.r, rr.evtid, rr.arch_mon_ctx); } =20 static void mbm_update(struct rdt_resource *r, struct rdt_mon_domain *d, - u32 closid, u32 rmid) + struct rdtgroup *rdtgrp) { /* * This is protected from concurrent reads from user as both * the user and overflow handler hold the global mutex. */ if (resctrl_arch_is_mbm_total_enabled()) - mbm_update_one_event(r, d, closid, rmid, QOS_L3_MBM_TOTAL_EVENT_ID); + mbm_update_one_event(r, d, rdtgrp, QOS_L3_MBM_TOTAL_EVENT_ID); =20 if (resctrl_arch_is_mbm_local_enabled()) - mbm_update_one_event(r, d, closid, rmid, QOS_L3_MBM_LOCAL_EVENT_ID); + mbm_update_one_event(r, d, rdtgrp, QOS_L3_MBM_LOCAL_EVENT_ID); } =20 /* @@ -712,11 +715,11 @@ void mbm_handle_overflow(struct work_struct *work) d =3D container_of(work, struct rdt_mon_domain, mbm_over.work); =20 list_for_each_entry(prgrp, &rdt_all_groups, rdtgroup_list) { - mbm_update(r, d, prgrp->closid, prgrp->mon.rmid); + mbm_update(r, d, prgrp); =20 head =3D &prgrp->mon.crdtgrp_list; list_for_each_entry(crgrp, head, mon.crdtgrp_list) - mbm_update(r, d, crgrp->closid, crgrp->mon.rmid); + mbm_update(r, d, crgrp); =20 if (is_mba_sc(NULL)) update_mba_bw(prgrp, d); --=20 2.34.1 From nobody Sun Dec 14 02:00:56 2025 Received: from NAM10-MW2-obe.outbound.protection.outlook.com (mail-mw2nam10on2089.outbound.protection.outlook.com [40.107.94.89]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 9347F296725; Thu, 15 May 2025 22:55:09 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.94.89 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1747349711; cv=fail; b=a8Cdl0f363OxfKMK+npCysawTHSJbuXRi11w33D65MjIUYOW7UMoF3ZG1esM4ZhAOIgF7u/HL7kY2IzoxLflL92LHCaTb9rz74PfqWho14BHUHZhaqhyOPK0b1EZ7mvSdbYKFkP5YXoTOxtm8si6IpRSPL0JjQWFCJufsz21laA= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1747349711; c=relaxed/simple; bh=UbdiY+fv281cxoeZJR19V7nQH+qA8xhEIGjutl1PaBo=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=Soss+WE4fJNTRa6MaZX4Uy2uqqYeN5ecvcguUiYQc2QUz5sn/qj94vSE6SqoW5GQDfbG3zlciTh4hOsuypMJjQeIdt09PF61crYelNCv3/rCoGgQmDP3B8TN1AnhdiivipCOtWNzFg6LP2GcL+nyzNqv6N//YLB67c4UtfMLdJs= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=amd.com; spf=fail smtp.mailfrom=amd.com; dkim=pass (1024-bit key) header.d=amd.com header.i=@amd.com header.b=NmnG7pKz; arc=fail smtp.client-ip=40.107.94.89 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=amd.com Authentication-Results: smtp.subspace.kernel.org; spf=fail smtp.mailfrom=amd.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=amd.com header.i=@amd.com header.b="NmnG7pKz" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=ZWS4Vd2T04g0IRUGaGG9Ift2sNEHsuTogaoarA3XttiRPFtBOdyo4iGVwP9tFXwa1XQBG6YHzf5B7LFX0q9mV+pqlZGyVa/4rTYG+oU+Gl9avmHOD29tYaUaZVTAY9qlKSFk9AHk+diSLQQKOEFAeIsI3clUeEjVbVB9fDkHGbOdau2YlQkoKbsPrmeuoTIMGwDrPQuPM5AFNiW1/9NEvYUbDXJeGXEKK5sA8FsXP/4Ygo9nwAUMpUgckh1COlY0emoA1KYswIIXDP5afvyVQfesJe/AI0AWgZ0hsi7ZHrYldeevbj9sE2qNUs4l4rFWxp9j7/S7Hr4s7qPaX4AOAA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=X8LqMviSKTRna9kUIil50cEMvvVwkhend4qpslXnXJA=; b=r+6i330b/71/vlBNIujGEjaAXfPhWeHrBWoHsV0imqMOEG7Y+LJ/wbMKH+Jtrujck1feQy1I8PxywEkXLQ3R64AMNkMiBnX8AhWxUqCljDBj7RGUDRwUsUpIyFjKtuc6C9z6PrEFMDZ+p9XATJ/VmJ7Zp69wZjkyK8Z1jvuppIUrem2tX3taJqVTBQD785+KJX61f0bIJXBEk8ahpC3EqsBOmWfiXU0lN6g6lb09b2tDVkmEONby2Pj8GR9RTaSYi2OQWECxlIBuOu2o4PjOvm/GpKw5unUhKRdLec9CEiJEVTqa+kjrLVyo21VSoD/VZJhYHpGQ64BkjgdtnqLJ5A== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=lwn.net smtp.mailfrom=amd.com; dmarc=pass (p=quarantine sp=quarantine pct=100) action=none header.from=amd.com; dkim=none (message not signed); arc=none (0) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amd.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=X8LqMviSKTRna9kUIil50cEMvvVwkhend4qpslXnXJA=; b=NmnG7pKzj+nlAghmRevDqb9uwOwmDUS4GXSSjYiwhteARibu5MSTNhvzYGt23KEGWHuXd+2zUY3pp13kiBdnlxL483QJB+uDKive8+f3mIHVl/HbuhrB0NN/6Yz5n5Z2f1IhInSDbEEVOKXAlHg1459/ju8LnbSdy7uGUmyfrQI= Received: from BN9PR03CA0042.namprd03.prod.outlook.com (2603:10b6:408:fb::17) by MN6PR12MB8469.namprd12.prod.outlook.com (2603:10b6:208:46e::19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8722.32; Thu, 15 May 2025 22:55:04 +0000 Received: from BN2PEPF0000449F.namprd02.prod.outlook.com (2603:10b6:408:fb:cafe::f1) by BN9PR03CA0042.outlook.office365.com (2603:10b6:408:fb::17) with Microsoft SMTP Server (version=TLS1_3, cipher=TLS_AES_256_GCM_SHA384) id 15.20.8722.25 via Frontend Transport; Thu, 15 May 2025 22:55:04 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 165.204.84.17) smtp.mailfrom=amd.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=amd.com; Received-SPF: Pass (protection.outlook.com: domain of amd.com designates 165.204.84.17 as permitted sender) receiver=protection.outlook.com; client-ip=165.204.84.17; helo=SATLEXMB04.amd.com; pr=C Received: from SATLEXMB04.amd.com (165.204.84.17) by BN2PEPF0000449F.mail.protection.outlook.com (10.167.243.150) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.8722.18 via Frontend Transport; Thu, 15 May 2025 22:55:04 +0000 Received: from bmoger-ubuntu.amd.com (10.180.168.240) by SATLEXMB04.amd.com (10.181.40.145) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.39; Thu, 15 May 2025 17:55:01 -0500 From: Babu Moger To: , , , , , , CC: , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , Subject: [PATCH v13 17/27] x86/resctrl: Add the support for reading ABMC counters Date: Thu, 15 May 2025 17:52:02 -0500 Message-ID: X-Mailer: git-send-email 2.34.1 In-Reply-To: References: Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-ClientProxiedBy: SATLEXMB04.amd.com (10.181.40.145) To SATLEXMB04.amd.com (10.181.40.145) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: BN2PEPF0000449F:EE_|MN6PR12MB8469:EE_ X-MS-Office365-Filtering-Correlation-Id: 93ae2216-c6f6-4781-84ca-08dd9403884e X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|82310400026|1800799024|7416014|376014|36860700013|13003099007; X-Microsoft-Antispam-Message-Info: =?us-ascii?Q?NpRvaJJ8PEBW2VT4MDfz2SyRlhNjUS5RY4lfXutGJPS+TiSrdcjSczWZEKAS?= =?us-ascii?Q?3+nTOE1UWc2ReoZICsL7njV61AaFwNkiqK2AsBoNDh+g3FSwpJR9ZZMSOyYO?= =?us-ascii?Q?g2TzL/ljRSdBvIbNEUcWNWrf3Zsyjo3vYeo33aIwIkJMYWZL2KwYVEk5mU21?= =?us-ascii?Q?BO08N4xOw7YOIAx1c5KiuUezIcihKaJF5aC9h6yCj4CfiJfKxZ9x3VT+m1ED?= =?us-ascii?Q?w+xyiYRMsPXewxllBa9Y7at1EGhgXrDLZ6rwNK/5YSXIi731t25R+qQ7LFDV?= =?us-ascii?Q?ybBuTwwCQmBEOfCJXCcfhC3xWCTQSSVOBqwLjY04+hfiRbhWiwdhDf+zHOiX?= =?us-ascii?Q?gW7wzCoT9zHgYLbOF7W4gzazQCbkFpbMlUGSfiHGx+FUtCwmJlOkeQjTG5Xs?= =?us-ascii?Q?mr9Bg1up3QQN29jWsTOrGC3SNMjp0B6QVZWel3gmSfN31VTWj83qx/Aq08ii?= =?us-ascii?Q?GIS4VGSeZJDyIXr6Mq/uAk2t81QV50xklBdeTUoA+jBIjezfZLRNd+XYMHDQ?= =?us-ascii?Q?i+Ji3PElyhAIIClK/+AoDPzVOUFORjeymcnaboXjx9SrS1XSKmdVKDRXfn2E?= =?us-ascii?Q?Mq6i4Yvsvp5jKTXkePSe5GIoT1x4QaCtKZA4+6vMym3byb10OLw/bs8SuoD5?= =?us-ascii?Q?Zrj/rTqFXBfiebPxkNMFBZotkIiji9j8X6vKFErK3ic/MNB/m1a1+eJpi59P?= =?us-ascii?Q?O4OQ2MJfvVy/rUwF1ZY/QdHfmAbmz+UEA+Juu+sl7ZSfvsgSwT507oAIsKaz?= =?us-ascii?Q?xdMGAg3j8dmmwxhneHWBjn9CtBY7LD+0xbsWd79fFFMOL0J3zsPemznFy0zw?= =?us-ascii?Q?Ei6/Z+tSg1R3mVLy09c3ArHX06cYACxzQS9BtY4aPDwFrjTiVsXkA3r/pJtk?= =?us-ascii?Q?JzSCuTjWOwX3F1m8VeZwF7h2W6wKYxRg+FyC7mbYsCA5Kyxt0l9rrYg8VnhM?= =?us-ascii?Q?iSjLMteVpRpMY4CPx2HJ98c8pI6OXPxolV+RFqMNgeZmi5UObj4nMcJ7xffQ?= =?us-ascii?Q?b0P4T1cMkXs04zIdNV7LMMfQO+H6SJVd61zsELeAiQV4eddAX79mSM+kQrJd?= =?us-ascii?Q?1ZwUzY79vRrHenRp7AeDMKu47+DRG745xRGiAU/PEzOkn4zyfxZfKU+jCP43?= =?us-ascii?Q?wW2TCBv8JpZPtqEYlx5ygfCzpRqJEIJkYmRmQNgWn1xHsN6N1HI5c0oWpbJ9?= =?us-ascii?Q?LQ8LMjf8QTCQ+elhzQ6rdZtGun1jjiwl+i8+QtZGP+xsylLHUE0mnXRGklBl?= =?us-ascii?Q?39gcgApoSS0k3kBo/hPorIuRG98GT6A/F35/7fWSUzZiFk+Cg7RE9cnWPQlV?= =?us-ascii?Q?mJM7iSDRhJ3cy8uLVvlAK+320Kb4XgFEWBHA9AJ1ydJy+qN2cH+uZwZ69FGU?= =?us-ascii?Q?ebk2Z7q+vmGi8nYsC2fCZX87/N1iPaOWRJYvn3BMwynG52pNUrMzrpOP+9xD?= =?us-ascii?Q?DQnzsgIEH5O45EtY2TIVAWV9wwS7zEWBevmOIo6VYfH2azMmFmfswb4gJUAP?= =?us-ascii?Q?pEEzLsImocwqtB4ehVs/kxBl98YipoXNIM4TXUrjU7gEK/UsAIW14Tp+rA?= =?us-ascii?Q?=3D=3D?= X-Forefront-Antispam-Report: CIP:165.204.84.17;CTRY:US;LANG:en;SCL:1;SRV:;IPV:CAL;SFV:NSPM;H:SATLEXMB04.amd.com;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(13230040)(82310400026)(1800799024)(7416014)(376014)(36860700013)(13003099007);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 15 May 2025 22:55:04.8717 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 93ae2216-c6f6-4781-84ca-08dd9403884e X-MS-Exchange-CrossTenant-Id: 3dd8961f-e488-4e60-8e11-a82d994e183d X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=3dd8961f-e488-4e60-8e11-a82d994e183d;Ip=[165.204.84.17];Helo=[SATLEXMB04.amd.com] X-MS-Exchange-CrossTenant-AuthSource: BN2PEPF0000449F.namprd02.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: MN6PR12MB8469 Content-Type: text/plain; charset="utf-8" Software can read the assignable counters using the QM_EVTSEL and QM_CTR register pair. QM_EVTSEL Register definition: =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D Bits Mnemonic Description =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D 63:44 -- Reserved 43:32 RMID Resource Monitoring Identifier 31 ExtEvtID Extended Event Identifier 30:8 -- Reserved 7:0 EvtID Event Identifier =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D The contents of a specific counter can be read by setting the following fields in QM_EVTSEL.ExtendedEvtID =3D 1, QM_EVTSEL.EvtID =3D L3CacheABMC (= =3D1) and setting [RMID] to the desired counter ID. Reading QM_CTR will then return the contents of the specified counter. The E bit will be set if the counter configuration was invalid, or if an invalid counter ID was set in the QM_EVTSEL[RMID] field. Introduce __cntr_id_read_phys() to read the counter ID event data. Link: https://www.amd.com/content/dam/amd/en/documents/processor-tech-docs/= programmer-references/40332.pdf Signed-off-by: Babu Moger --- v13: Split the patch into 2. First one to handle the passing of rdtgroup st= ructure to few functions( __mon_event_count and mbm_update(). Second one to handle AB= MC counter reading. Added new function __cntr_id_read_phys() to handle ABMC event reading. Updated kernel doc for resctrl_arch_reset_rmid() and resctrl_arch_rmid= _read(). Resolved conflicts caused by the recent FS/ARCH code restructure. The monitor.c file has now been split between the FS and ARCH director= ies. v12: New patch to support extended event mode when ABMC is enabled. --- arch/x86/kernel/cpu/resctrl/internal.h | 6 +++ arch/x86/kernel/cpu/resctrl/monitor.c | 66 ++++++++++++++++++++++---- fs/resctrl/monitor.c | 14 ++++-- include/linux/resctrl.h | 9 ++-- 4 files changed, 80 insertions(+), 15 deletions(-) diff --git a/arch/x86/kernel/cpu/resctrl/internal.h b/arch/x86/kernel/cpu/r= esctrl/internal.h index db6b0c28ee6b..3b0cdb5520c7 100644 --- a/arch/x86/kernel/cpu/resctrl/internal.h +++ b/arch/x86/kernel/cpu/resctrl/internal.h @@ -40,6 +40,12 @@ struct arch_mbm_state { /* Setting bit 0 in L3_QOS_EXT_CFG enables the ABMC feature. */ #define ABMC_ENABLE_BIT 0 =20 +/* + * ABMC Qos Event Identifiers. + */ +#define ABMC_EXTENDED_EVT_ID BIT(31) +#define ABMC_EVT_ID 1 + /** * struct rdt_hw_ctrl_domain - Arch private attributes of a set of CPUs th= at share * a resource for a control function diff --git a/arch/x86/kernel/cpu/resctrl/monitor.c b/arch/x86/kernel/cpu/re= sctrl/monitor.c index e31084f7babd..36a03dae6d8e 100644 --- a/arch/x86/kernel/cpu/resctrl/monitor.c +++ b/arch/x86/kernel/cpu/resctrl/monitor.c @@ -161,6 +161,41 @@ static int __rmid_read_phys(u32 prmid, enum resctrl_ev= ent_id eventid, u64 *val) return 0; } =20 +static int __cntr_id_read_phys(u32 cntr_id, u64 *val) +{ + u64 msr_val; + + /* + * QM_EVTSEL Register definition: + * =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D + * Bits Mnemonic Description + * =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D + * 63:44 -- Reserved + * 43:32 RMID Resource Monitoring Identifier + * 31 ExtEvtID Extended Event Identifier + * 30:8 -- Reserved + * 7:0 EvtID Event Identifier + * =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D + * The contents of a specific counter can be read by setting the + * following fields in QM_EVTSEL.ExtendedEvtID(=3D1) and + * QM_EVTSEL.EvtID =3D L3CacheABMC (=3D1) and setting [RMID] to the + * desired counter ID. Reading QM_CTR will then return the + * contents of the specified counter. The E bit will be set if the + * counter configuration was invalid, or if an invalid counter ID + * was set in the QM_EVTSEL[RMID] field. + */ + wrmsr(MSR_IA32_QM_EVTSEL, ABMC_EXTENDED_EVT_ID | ABMC_EVT_ID, cntr_id); + rdmsrl(MSR_IA32_QM_CTR, msr_val); + + if (msr_val & RMID_VAL_ERROR) + return -EIO; + if (msr_val & RMID_VAL_UNAVAIL) + return -EINVAL; + + *val =3D msr_val; + return 0; +} + static struct arch_mbm_state *get_arch_mbm_state(struct rdt_hw_mon_domain = *hw_dom, u32 rmid, enum resctrl_event_id eventid) @@ -180,7 +215,7 @@ static struct arch_mbm_state *get_arch_mbm_state(struct= rdt_hw_mon_domain *hw_do } =20 void resctrl_arch_reset_rmid(struct rdt_resource *r, struct rdt_mon_domain= *d, - u32 unused, u32 rmid, + u32 unused, u32 rmid, int cntr_id, enum resctrl_event_id eventid) { struct rdt_hw_mon_domain *hw_dom =3D resctrl_to_arch_mon_dom(d); @@ -192,9 +227,16 @@ void resctrl_arch_reset_rmid(struct rdt_resource *r, s= truct rdt_mon_domain *d, if (am) { memset(am, 0, sizeof(*am)); =20 - prmid =3D logical_rmid_to_physical_rmid(cpu, rmid); - /* Record any initial, non-zero count value. */ - __rmid_read_phys(prmid, eventid, &am->prev_msr); + if (resctrl_arch_mbm_cntr_assign_enabled(r) && + resctrl_is_mbm_event(eventid)) { + if (cntr_id < 0) + return; + __cntr_id_read_phys(cntr_id, &am->prev_msr); + } else { + prmid =3D logical_rmid_to_physical_rmid(cpu, rmid); + /* Record any initial, non-zero count value. */ + __rmid_read_phys(prmid, eventid, &am->prev_msr); + } } } =20 @@ -224,8 +266,8 @@ static u64 mbm_overflow_count(u64 prev_msr, u64 cur_msr= , unsigned int width) } =20 int resctrl_arch_rmid_read(struct rdt_resource *r, struct rdt_mon_domain *= d, - u32 unused, u32 rmid, enum resctrl_event_id eventid, - u64 *val, void *ignored) + u32 unused, u32 rmid, int cntr_id, + enum resctrl_event_id eventid, u64 *val, void *ignored) { struct rdt_hw_mon_domain *hw_dom =3D resctrl_to_arch_mon_dom(d); struct rdt_hw_resource *hw_res =3D resctrl_to_arch_res(r); @@ -237,8 +279,16 @@ int resctrl_arch_rmid_read(struct rdt_resource *r, str= uct rdt_mon_domain *d, =20 resctrl_arch_rmid_read_context_check(); =20 - prmid =3D logical_rmid_to_physical_rmid(cpu, rmid); - ret =3D __rmid_read_phys(prmid, eventid, &msr_val); + if (resctrl_arch_mbm_cntr_assign_enabled(r) && + resctrl_is_mbm_event(eventid)) { + if (cntr_id < 0) + return cntr_id; + ret =3D __cntr_id_read_phys(cntr_id, &msr_val); + } else { + prmid =3D logical_rmid_to_physical_rmid(cpu, rmid); + ret =3D __rmid_read_phys(prmid, eventid, &msr_val); + } + if (ret) return ret; =20 diff --git a/fs/resctrl/monitor.c b/fs/resctrl/monitor.c index a477be9cdb66..72f3dfb5b903 100644 --- a/fs/resctrl/monitor.c +++ b/fs/resctrl/monitor.c @@ -159,7 +159,11 @@ void __check_limbo(struct rdt_mon_domain *d, bool forc= e_free) break; =20 entry =3D __rmid_entry(idx); - if (resctrl_arch_rmid_read(r, d, entry->closid, entry->rmid, + /* + * cntr_id is not relevant for QOS_L3_OCCUP_EVENT_ID. + * Pass dummy value -1. + */ + if (resctrl_arch_rmid_read(r, d, entry->closid, entry->rmid, -1, QOS_L3_OCCUP_EVENT_ID, &val, arch_mon_ctx)) { rmid_dirty =3D true; @@ -359,6 +363,7 @@ static struct mbm_state *get_mbm_state(struct rdt_mon_d= omain *d, u32 closid, =20 static int __mon_event_count(struct rdtgroup *rdtgrp, struct rmid_read *rr) { + int cntr_id =3D mbm_cntr_get(rr->r, rr->d, rdtgrp, rr->evtid); int cpu =3D smp_processor_id(); u32 closid =3D rdtgrp->closid; u32 rmid =3D rdtgrp->mon.rmid; @@ -368,7 +373,7 @@ static int __mon_event_count(struct rdtgroup *rdtgrp, s= truct rmid_read *rr) u64 tval =3D 0; =20 if (rr->first) { - resctrl_arch_reset_rmid(rr->r, rr->d, closid, rmid, rr->evtid); + resctrl_arch_reset_rmid(rr->r, rr->d, closid, rmid, cntr_id, rr->evtid); m =3D get_mbm_state(rr->d, closid, rmid, rr->evtid); if (m) memset(m, 0, sizeof(struct mbm_state)); @@ -379,7 +384,7 @@ static int __mon_event_count(struct rdtgroup *rdtgrp, s= truct rmid_read *rr) /* Reading a single domain, must be on a CPU in that domain. */ if (!cpumask_test_cpu(cpu, &rr->d->hdr.cpu_mask)) return -EINVAL; - rr->err =3D resctrl_arch_rmid_read(rr->r, rr->d, closid, rmid, + rr->err =3D resctrl_arch_rmid_read(rr->r, rr->d, closid, rmid, cntr_id, rr->evtid, &tval, rr->arch_mon_ctx); if (rr->err) return rr->err; @@ -404,7 +409,8 @@ static int __mon_event_count(struct rdtgroup *rdtgrp, s= truct rmid_read *rr) list_for_each_entry(d, &rr->r->mon_domains, hdr.list) { if (d->ci->id !=3D rr->ci->id) continue; - err =3D resctrl_arch_rmid_read(rr->r, d, closid, rmid, + cntr_id =3D mbm_cntr_get(rr->r, d, rdtgrp, rr->evtid); + err =3D resctrl_arch_rmid_read(rr->r, d, closid, rmid, cntr_id, rr->evtid, &tval, rr->arch_mon_ctx); if (!err) { rr->val +=3D tval; diff --git a/include/linux/resctrl.h b/include/linux/resctrl.h index f78b6064230c..cd24d1577e0a 100644 --- a/include/linux/resctrl.h +++ b/include/linux/resctrl.h @@ -473,6 +473,7 @@ void resctrl_offline_cpu(unsigned int cpu); * counter may match traffic of both @closid and @rmid, or @rmid * only. * @rmid: rmid of the counter to read. + * @cntr_id: cntr_id to read MBM events with mbm_cntr_assign mode. * @eventid: eventid to read, e.g. L3 occupancy. * @val: result of the counter read in bytes. * @arch_mon_ctx: An architecture specific value from @@ -490,8 +491,9 @@ void resctrl_offline_cpu(unsigned int cpu); * 0 on success, or -EIO, -EINVAL etc on error. */ int resctrl_arch_rmid_read(struct rdt_resource *r, struct rdt_mon_domain *= d, - u32 closid, u32 rmid, enum resctrl_event_id eventid, - u64 *val, void *arch_mon_ctx); + u32 closid, u32 rmid, int cntr_id, + enum resctrl_event_id eventid, u64 *val, + void *arch_mon_ctx); =20 /** * resctrl_arch_rmid_read_context_check() - warn about invalid contexts @@ -532,12 +534,13 @@ struct rdt_domain_hdr *resctrl_find_domain(struct lis= t_head *h, int id, * @closid: closid that matches the rmid. Depending on the architecture, t= he * counter may match traffic of both @closid and @rmid, or @rmid only. * @rmid: The rmid whose counter values should be reset. + * @cntr_id: The cntr_id to read MBM events with mbm_cntr_assign mode. * @eventid: The eventid whose counter values should be reset. * * This can be called from any CPU. */ void resctrl_arch_reset_rmid(struct rdt_resource *r, struct rdt_mon_domain= *d, - u32 closid, u32 rmid, + u32 closid, u32 rmid, int cntr_id, enum resctrl_event_id eventid); =20 /** --=20 2.34.1 From nobody Sun Dec 14 02:00:56 2025 Received: from NAM04-MW2-obe.outbound.protection.outlook.com (mail-mw2nam04on2063.outbound.protection.outlook.com [40.107.101.63]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id AA4F928CF7E; Thu, 15 May 2025 22:55:16 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.101.63 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1747349719; cv=fail; b=V9q3//bSr3LID5vwzj6R0rhroZoL9GqxC+uzX4q4GlWO747ScKBIXhMfcKT2eygTq56m3IMMiUtideTnhi0cUeruW6cbvgbARmbiDZTxTCJn0247PTQZBIdAuhZP0JYnKWt7+k5pnkYdjafVYvY0ueNi0Ib7SbD188Wc+Jxk7PE= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1747349719; c=relaxed/simple; bh=17VPuDKWOmGfCle6MiAqUDMK8zO8S27U0plqOFmOau8=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=CqY7WWTh+kqumLEQxJ8oz7Fw+CeeV+By8Oodxgw8vuXpjupu/m/cRw9lJ/rGju2gChiR1qzs/SmO26GG5p39nn8R9nhkp9naxM1mZ68o+tDYt22kKGlSNRNPkgKM9fpbQwNEhSVWZERGxMiKqLT5cWou4uTXGFtf57mWpKw4/zE= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=amd.com; spf=fail smtp.mailfrom=amd.com; dkim=pass (1024-bit key) header.d=amd.com header.i=@amd.com header.b=LRY+Yhc/; arc=fail smtp.client-ip=40.107.101.63 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=amd.com Authentication-Results: smtp.subspace.kernel.org; spf=fail smtp.mailfrom=amd.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=amd.com header.i=@amd.com header.b="LRY+Yhc/" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=psHwJygHShOjNz6SN8ZMSc2XYKbhn1Bo10KBOWdh2qHat0LckdYWA4JFMMYEBPt80ZKWow09tqTBm49BFtSGCV+ZFEnShT1xR+vp0lUuMU1o1KxepZhnziVxetrovzltRMlL0v3PjG9QjvQhzPGkk0+fmZfTh3NUJgqWeE8F+xeVwtq8E8Ahd2dlLZCA2dKt2J3vX29F4MufIpukRu4od4jHSdZjGeM9NpMAY7hQGPlnIZKVV8tuLVJsASNScjMvYOvL6JtLun8qr1FhE5rKKjKdxc4rJ4sKsuFyegKK8o5FrAB8XAoRMhLc7j0IND+Y4dhbmjxavJXeHATb/FTXvw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=80cyqy5wgwzi6+JWcbAFUq8N6Pr4PDBXGGue+0x4X9Q=; b=L7Fn9cn5hnhVlkgR6E3Fi8S4aZzmXVtAwHfaLAhQND8h1dk1tmCHw/oN9sOwBcuZE2vw9nmZaR0KQYuzg6EbPWR12Nf03/o5Ii4UmNKCa8KXYiU8bM5CDUl24TFWP3wRdHneph/PdnQOA7mKY6xg3dCfwtbCKgAwV3evJP0fSVyZ7mFgGMo7YxhhxkTgGX32dQS5ZLZMAxoRnivdL08kKfCKECtmSeUoGwT1Cki28w1aX1zx54L3hkA6iR3BNi+MAfCJDP/NdiezRNSBYmnngrB7LZEU3vDkkFyogWKwKId4dgvTHRNUVy93E/ZqCxbbcX2RzUQtb7NlYEPLsqevYg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=lwn.net smtp.mailfrom=amd.com; dmarc=pass (p=quarantine sp=quarantine pct=100) action=none header.from=amd.com; dkim=none (message not signed); arc=none (0) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amd.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=80cyqy5wgwzi6+JWcbAFUq8N6Pr4PDBXGGue+0x4X9Q=; b=LRY+Yhc/Eu6dvZCHwNiQK9epKTmz2ddv9AvEyOFIqAy7P4g8v24425PHouxETWaT75S0xzeJLeew2Y/Ks211o92TDcSoQJz+d2CtToiwEb0U/SFjwXVaLvNfzyFNemy3CpyxC5LO4tT5SbO1IWthjJxPBS+3idgmF55GujwyEMk= Received: from BN7PR06CA0064.namprd06.prod.outlook.com (2603:10b6:408:34::41) by MN2PR12MB4270.namprd12.prod.outlook.com (2603:10b6:208:1d9::21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8722.29; Thu, 15 May 2025 22:55:14 +0000 Received: from BN2PEPF000044A4.namprd02.prod.outlook.com (2603:10b6:408:34:cafe::e8) by BN7PR06CA0064.outlook.office365.com (2603:10b6:408:34::41) with Microsoft SMTP Server (version=TLS1_3, cipher=TLS_AES_256_GCM_SHA384) id 15.20.8722.28 via Frontend Transport; Thu, 15 May 2025 22:55:14 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 165.204.84.17) smtp.mailfrom=amd.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=amd.com; Received-SPF: Pass (protection.outlook.com: domain of amd.com designates 165.204.84.17 as permitted sender) receiver=protection.outlook.com; client-ip=165.204.84.17; helo=SATLEXMB04.amd.com; pr=C Received: from SATLEXMB04.amd.com (165.204.84.17) by BN2PEPF000044A4.mail.protection.outlook.com (10.167.243.155) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.8722.18 via Frontend Transport; Thu, 15 May 2025 22:55:14 +0000 Received: from bmoger-ubuntu.amd.com (10.180.168.240) by SATLEXMB04.amd.com (10.181.40.145) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.39; Thu, 15 May 2025 17:55:11 -0500 From: Babu Moger To: , , , , , , CC: , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , Subject: [PATCH v13 18/27] x86/resctrl: Add definitions for MBM event configuration Date: Thu, 15 May 2025 17:52:03 -0500 Message-ID: <8e9f18e1bba578d74fc3e3cb887c5101eb73e1d7.1747349530.git.babu.moger@amd.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: References: Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-ClientProxiedBy: SATLEXMB04.amd.com (10.181.40.145) To SATLEXMB04.amd.com (10.181.40.145) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: BN2PEPF000044A4:EE_|MN2PR12MB4270:EE_ X-MS-Office365-Filtering-Correlation-Id: 2c754d9f-7785-4261-8ef4-08dd94038dfa X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|36860700013|1800799024|376014|82310400026|7416014; X-Microsoft-Antispam-Message-Info: =?us-ascii?Q?iz+VkV08Frl8yLYyQobeA5cxxD9LJRZKt5fhLmuVV9CCZa6rirJbGWGE2U4E?= =?us-ascii?Q?dHnUowwxx+b0PNlzV4vHJkW8TOIkYtSBLVqjO4nFOvQILnmc5nsXLXEfFsk1?= =?us-ascii?Q?jnrlOe+RCg6tel3KYc4L2f/lH+ZRz0pfmWn3HLzLMNwMxqLMGnjLOvc1viVB?= =?us-ascii?Q?KK1tRt0zrD3yrBTA2xWGMeVv9fFR5oqslylqHL82bnKtALi51/pU8Kauxg7v?= =?us-ascii?Q?d1hpUcq3oeKUseUL3V1PtVaflTCmR2VowfL2yx2vsB8tLiDFZwj215qd2+OO?= =?us-ascii?Q?V8XnJIVZWEz2qODNX8W3zBHC/lur+5AJy/ZI/pIQdnU4+UcYw6UfyjJo9f3b?= =?us-ascii?Q?Wq7hi56A2UUThE1VcvwQTS1/aTTkT9Mov5RuaxRKKIOI5S0Yn3w7Dc5EjbCw?= =?us-ascii?Q?joyGcH8N80S8eb7doqqGfx3np/pdDppu7/g3YCqjMoqByyzdTg5znLzvVXSM?= =?us-ascii?Q?n/GpQNJEbrthSXW6UXksM7p7UB74UaGxvW7aebOy2qnDmkNgyDr7ZUFGMikO?= =?us-ascii?Q?r5kYFIYRjBQDmzdrlbVCyTtx4F+72SnZgS5mQN237RmuxCE2HWaHjfg4uxXl?= =?us-ascii?Q?ojKV33q7XYqZJih3AL0Klxf7lPQq71fCsCFn8K8aKVgAuVCr4GlM7DcZ6g9L?= =?us-ascii?Q?u8kcsLzWTvufIoV/v61tT3w7oTsbCdwZFM38TLKXL2K8zYzo2rltEUhF+BRw?= =?us-ascii?Q?LRxyfLJtiQtTqQBynvj2DwFQjnf2zBetBrIvX2Mv2HLOuksMBRvnJAsiErfR?= =?us-ascii?Q?RmoChkWf4y1g7Oy8QhqAiMebWqmJDxSZ7OtwYzNIXqqRJjz9c1qAgBnpOE9P?= =?us-ascii?Q?Ow39k5RfoX1JgheVMVWrB66e95W9ejABpHlVCiaHDUxCDaC6PucBAN7NZzmb?= =?us-ascii?Q?UyGy33K5PbAtFScIYWeSVJUfp9MiHgxo9TEj5PrDo/NUDMZwGpQiPoHdSWX+?= =?us-ascii?Q?AQ03m8ScLyZUqJkzaTXWN/h4wc37YMSRvfAuhchz/F2TSuXDMMuFY++xCwUl?= =?us-ascii?Q?/mxI9jQ5V4mzlZAXtu82vI3tJSTTeNZfWiIjrW8QfRa8kOSrmQ3FeCXgmxM/?= =?us-ascii?Q?5feMgiY99krHm7hcKdK1P8hPZp9o3X3dtmybFfxR4i9yFFsfJiJUiCMV5iN7?= =?us-ascii?Q?P4XFDb/zzIGyyon5Php/AFM1MBcuhQKCfSXYAoyrvQbTS2asocO9tgW8w8uE?= =?us-ascii?Q?OPkGv099F9yg1xOmfsBnoSU7ABTh9Jz0IDKseaAz2bCmC6mD/cvbeGRGC8JA?= =?us-ascii?Q?Yr/wN9ZZlhx+5iHIIn15UvMnHua5eGVTDEs3KD3KJQ59yaLc8GMrmkmRAxVZ?= =?us-ascii?Q?5cVYOTupFRa7p5bdzWhhPS2rmUbiyGkX8hCFN3R6o2DrZ/WeqYhfaVz0dlEH?= =?us-ascii?Q?SzQwUJoY/Cs7iQkcrDwQJ30B+k8Pe3NlQ/kvLWU/XL+cRviYhFwhOCorES6R?= =?us-ascii?Q?IMRfHrTeq2n8Y8pdgp4YmXAFO2zgQe0KSqwCHVw5wGdMz+M8FdMj9uhpwpTD?= =?us-ascii?Q?di+VJy9XqC3YA+ZOWDOAjSc5qi6YthVsaTvY?= X-Forefront-Antispam-Report: CIP:165.204.84.17;CTRY:US;LANG:en;SCL:1;SRV:;IPV:CAL;SFV:NSPM;H:SATLEXMB04.amd.com;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(13230040)(36860700013)(1800799024)(376014)(82310400026)(7416014);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 15 May 2025 22:55:14.3889 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 2c754d9f-7785-4261-8ef4-08dd94038dfa X-MS-Exchange-CrossTenant-Id: 3dd8961f-e488-4e60-8e11-a82d994e183d X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=3dd8961f-e488-4e60-8e11-a82d994e183d;Ip=[165.204.84.17];Helo=[SATLEXMB04.amd.com] X-MS-Exchange-CrossTenant-AuthSource: BN2PEPF000044A4.namprd02.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: MN2PR12MB4270 Content-Type: text/plain; charset="utf-8" The "mbm_cntr_assign" mode allows users to manually assign a hardware counter to a specific RMID and event pair. The events available for assignment are configurable. By default, each resctrl group supports two MBM events: mbm_total_bytes and mbm_local_bytes. Each event corresponds to an MBM configuration that specifies the bandwidth sources tracked by the event. Add definitions of supported bandwidth sources. Signed-off-by: Babu Moger --- v13: Updated the changelog. Removed the definitions from resctrl_types.h and moved to internal.h. Removed mbm_assign_config definition. Configurations will be part of mon_evt list. Resolved conflicts caused by the recent FS/ARCH code restructure. The rdtgroup.c file has now been split between the FS and ARCH directo= ries. v12: New patch to support event configurations via new counter_configs method. --- fs/resctrl/internal.h | 10 ++++++++++ fs/resctrl/rdtgroup.c | 14 ++++++++++++++ 2 files changed, 24 insertions(+) diff --git a/fs/resctrl/internal.h b/fs/resctrl/internal.h index 0dfd2efe68fc..019d00bf5adf 100644 --- a/fs/resctrl/internal.h +++ b/fs/resctrl/internal.h @@ -203,6 +203,16 @@ struct rdtgroup { struct pseudo_lock_region *plr; }; =20 +/** + * struct mbm_evt_value - Specific type of memory events. + * @evt_name: Name of memory transaction type (read, write etc). + * @evt_val: Value representing the memory transaction. + */ +struct mbm_evt_value { + char evt_name[32]; + u32 evt_val; +}; + /* rdtgroup.flags */ #define RDT_DELETED 1 =20 diff --git a/fs/resctrl/rdtgroup.c b/fs/resctrl/rdtgroup.c index 72317a5adee2..b109e91096b0 100644 --- a/fs/resctrl/rdtgroup.c +++ b/fs/resctrl/rdtgroup.c @@ -75,6 +75,20 @@ static void rdtgroup_destroy_root(void); =20 struct dentry *debugfs_resctrl; =20 +/* Number of memory transaction types that can be monitored */ +#define NUM_MBM_EVT_VALUES 7 + +/* Decoded values for each type of memory events */ +struct mbm_evt_value mbm_evt_values[NUM_MBM_EVT_VALUES] =3D { + {"local_reads", READS_TO_LOCAL_MEM}, + {"remote_reads", READS_TO_REMOTE_MEM}, + {"local_non_temporal_writes", NON_TEMP_WRITE_TO_LOCAL_MEM}, + {"remote_non_temporal_writes", NON_TEMP_WRITE_TO_REMOTE_MEM}, + {"local_reads_slow_memory", READS_TO_LOCAL_S_MEM}, + {"remote_reads_slow_memory", READS_TO_REMOTE_S_MEM}, + {"dirty_victim_writes_all", DIRTY_VICTIMS_TO_ALL_MEM}, +}; + /* * Memory bandwidth monitoring event to use for the default CTRL_MON group * and each new CTRL_MON group created by the user. Only relevant when --=20 2.34.1 From nobody Sun Dec 14 02:00:56 2025 Received: from NAM11-CO1-obe.outbound.protection.outlook.com (mail-co1nam11on2088.outbound.protection.outlook.com [40.107.220.88]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 4D5E328CF7E; Thu, 15 May 2025 22:55:27 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.220.88 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1747349730; cv=fail; b=t1Lm7ZAeaQ73SyTLoOwejlPviwo+T4IqHTycC5kflrUf+vzLZT3/ZmKKhHEJP5fp4Lf2X8juX8+tlaaezOrHyzx2WP51trCcSDUVy/HRT4PhLXgKC7scNrzB5RgzAC8h2LXTZY+zdvLBQznF4gOwGFGxzDycXD8PbxcB6nsygWk= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1747349730; c=relaxed/simple; bh=EBwau4Xsn0DYiXJ33qCq4cPdsrn6ZBvWFmnzClGX9bU=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=PDbxuvwy1P01uFD6y/piWEwrQgGwXq9WxXrvTVMcUKV/FTsG7M488lHY8SH3xoApwe5jjScLFZl5E7waURiLK4cMMFYpJOxa6uYQFAwJHawvgqyJEQ88pKWQSFljOEoOL+ShftlfqrBRckpwk4VzVr/beqZlIivlvYRzuDN/A4M= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=amd.com; spf=fail smtp.mailfrom=amd.com; dkim=pass (1024-bit key) header.d=amd.com header.i=@amd.com header.b=vZ20gUjO; arc=fail smtp.client-ip=40.107.220.88 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=amd.com Authentication-Results: smtp.subspace.kernel.org; spf=fail smtp.mailfrom=amd.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=amd.com header.i=@amd.com header.b="vZ20gUjO" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=zKJAkqvJkOaGM3pwXAAiVDO44PCXoLFpaM/xDuL3oq60Xs9Vkay83vpyFWI3/yF5TAszxLR2as/te25wHiyR9wjCaMHmK0KyqNEpfYAcf48tcEGBqGxoVzjabC2QOnjX8hkcR0Uf6oNsWw7GHIRJTHgytlPs8LeyxP80J9QQQpHpZBjTteYGjcYUA+bshsEe/W6+013RB2aNwt9q2SH6bFrSIFk8OrdjAz9l7mRI1ved6TjB1FyO1r6C+oVxvZcVhPgVB0nr1adZMCFJlM8vxHuI+0uRyrDhSTs8wVdX1vq5caW3hJWIbXAcAocMDAAt6LAcXn9CT14CuUZ/utHapQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=NT/BiTKjuIs3kjLdUA8qcAh1yyZRCDE2nsB5XZ+65cs=; b=Qpe7L2hRVtSjlHIRBc+IK07aQdO3EN2EJawdxNFJufqO3Gl4D6NETTQ5z6axJpMtX9maIYNkPT3qZUhubIXCa9tP4JPQ7pFfZ/6z6DXzAQ4REkarcO2uXjLNhcwZvLAszZlxNoBpBv4OcBnAg2ixXwF3FsKTO97hl68I+r2+PKt5I4U1s2WZElcoS6zPH69ZZsJlU2xQrdkukNdGjdOaNVA4TPPLR1uaPhapVDRY7OLlOCEi8md0j83BztEFagYCwFrv5yShoyLPe+DNpdFBB9gjFzBZQrNcF1xCsMt8eotoVBhVmI2aMhMpk/w3hnyr0e04FJdtjWwAwC13LKwWiQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=lwn.net smtp.mailfrom=amd.com; dmarc=pass (p=quarantine sp=quarantine pct=100) action=none header.from=amd.com; dkim=none (message not signed); arc=none (0) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amd.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=NT/BiTKjuIs3kjLdUA8qcAh1yyZRCDE2nsB5XZ+65cs=; b=vZ20gUjOSZZ2pbMwYQX4tuirz4pHtEZuu7QgKi1x0OiSLgX7WBMtKuib2ODUL/Jw9oIYRZ1i+jN5Eg6gJPvc8uTUWsof+MULGiRciC79OUo8K+l3H5Fd0L44RMc8vV4mcJiPJ9/5kfLdqMVVXFawwyrOIWD8rvzohHG1L6EK5+o= Received: from BN7PR06CA0071.namprd06.prod.outlook.com (2603:10b6:408:34::48) by DS7PR12MB9475.namprd12.prod.outlook.com (2603:10b6:8:251::6) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8722.32; Thu, 15 May 2025 22:55:24 +0000 Received: from BN2PEPF000044A4.namprd02.prod.outlook.com (2603:10b6:408:34:cafe::f3) by BN7PR06CA0071.outlook.office365.com (2603:10b6:408:34::48) with Microsoft SMTP Server (version=TLS1_3, cipher=TLS_AES_256_GCM_SHA384) id 15.20.8722.20 via Frontend Transport; Thu, 15 May 2025 22:55:23 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 165.204.84.17) smtp.mailfrom=amd.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=amd.com; Received-SPF: Pass (protection.outlook.com: domain of amd.com designates 165.204.84.17 as permitted sender) receiver=protection.outlook.com; client-ip=165.204.84.17; helo=SATLEXMB04.amd.com; pr=C Received: from SATLEXMB04.amd.com (165.204.84.17) by BN2PEPF000044A4.mail.protection.outlook.com (10.167.243.155) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.8722.18 via Frontend Transport; Thu, 15 May 2025 22:55:23 +0000 Received: from bmoger-ubuntu.amd.com (10.180.168.240) by SATLEXMB04.amd.com (10.181.40.145) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.39; Thu, 15 May 2025 17:55:21 -0500 From: Babu Moger To: , , , , , , CC: , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , Subject: [PATCH v13 19/27] x86/resctrl: Add event configuration directory under info/L3_MON/ Date: Thu, 15 May 2025 17:52:04 -0500 Message-ID: <3e7ae289622f9ff019604f2e7b78de33924c2a65.1747349530.git.babu.moger@amd.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: References: Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-ClientProxiedBy: SATLEXMB04.amd.com (10.181.40.145) To SATLEXMB04.amd.com (10.181.40.145) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: BN2PEPF000044A4:EE_|DS7PR12MB9475:EE_ X-MS-Office365-Filtering-Correlation-Id: 616578e7-901f-4607-d46f-08dd940393ad X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|82310400026|36860700013|1800799024|376014|7416014; X-Microsoft-Antispam-Message-Info: =?us-ascii?Q?zzsYDLLQJ7Yi5IxKQk+PcwvMU1UTTIXJtt6h0jn8LSSGMzqFTSURwM8lsK2c?= =?us-ascii?Q?qYUOBFkwmRuUIsVNYjFRQ3y8iOk9HZ45kwlfyBax/EEgv+rnnSL7taRfvLag?= =?us-ascii?Q?KPLbWEvI7X+5xaH2nz6Q/uLLqAO2y/1mC81gEvZQNDHkVPpakBR38hdL5HXA?= =?us-ascii?Q?HrvPpIClwMRwTZfBPOx3F4WOG9OPpkYvYD73EUSeO5ilprCJpUo/UrOIi19c?= =?us-ascii?Q?JfAqz0W6XNT5C697rOTv7Qdz9x2D29yeK8cBD/BNVHRvx96SdE5EtALn5/82?= =?us-ascii?Q?pFdBnQWdu5FVHGKJ2vPHnQqtcgvkqmPRqzf1k5TbRLWnVND+8RVQGS4J0fGB?= =?us-ascii?Q?9d1n6guWClgjyqrQWxne8j7wR/n7B2oAl8Q8PdL0K28qFsMGVeml1Y1si/zd?= =?us-ascii?Q?/0FqIp6Ge3sK7oMM6A39iQimgsfbVvs6REiDEKOrzpiwo74mqJSTiysSjX2e?= =?us-ascii?Q?EYf2Hltg1gQyH2/4kFsYAUGuuE1QWs0T589Ec6OkXi3zghz8bXB87OhG8B0V?= =?us-ascii?Q?P4VWOplM2cR434t1Z/BroLtZR5fbI28hDKeUCP51Sy3vAnpHPckVu8vPwiJL?= =?us-ascii?Q?c347xB7HmJEkWjnWpYKx2X1vsMwbNp3ccQkUoYJmNMUUDFl8Hq/q31dkMQ5A?= =?us-ascii?Q?ophBzjmp7TMOTe9hyQHfB5Vl0eoumpqoALgZmNY9h76GVzlAwv9SRzkZDmNv?= =?us-ascii?Q?WPfqH2cO9GNI7Xy+tFDBg5c8YgVe3ML8bYM56PNYTdjmyrGhw/JWAizo3VcA?= =?us-ascii?Q?L5N4isjt7M5YETlSPcv+lOsBLLxkLDO9wsuJ4PHfKD0o6GsZmAy4H+uWXrtD?= =?us-ascii?Q?yXr1wjBD0wPFIiKq4uJq1hHiRn4LS3PWszS4Yz68Ymzre3YU92acdr0WtYi9?= =?us-ascii?Q?SgG2opc/JmClrhu66DyOqr4foUINfQuIjvTB7lhl4D1z2EIvAHVyhlDDCdOW?= =?us-ascii?Q?Rwh4sLG0Ff05z5Z6g0q3dOYjrpNhcwkmE4hSedaEzFcN3Mr51Gn4LZvoEbXc?= =?us-ascii?Q?UqeVrSpjkjKUTJ5db7I/gbkja0nlmH55bi0Jw3cm5SFuaTGw6AGXl0EQ8tMB?= =?us-ascii?Q?DDU+NM944pM4V1TsJHP7rnVmdAZgzw4OyJXH9ITxbUurN5hoHFChAnU20FWt?= =?us-ascii?Q?MKATquTdI6cLwCfrstIJuTSg8jELWRGZdhFrde9sghULi1vQDBmsdAdJ5Oe1?= =?us-ascii?Q?2LohngHaif78U9kl6O4MTqpqskt4V7V0P0NY5FxErphsqSmcDBX0ZXS482sJ?= =?us-ascii?Q?xyAUAsx7SrM9P5BZUbup/nIRt3Sx+efVhI07XZvAuqL7UKWa3Lp0qiQOZaW0?= =?us-ascii?Q?0MghBN2W96cKVVtK0XrQEEo2+lhok0dIrFbil+5bd84DMKB3sU86eatsuZu7?= =?us-ascii?Q?X+spIFOweTvMsf29d4ZICctekzQ6zGF0+c4U9rdBb4BD6uXSLmFmAY9BguYq?= =?us-ascii?Q?aw+DsRnZA8nKbpQr1J1uXaF1a1O0Z0cbyyNvyQs5piSkhNILjiOBheQrHCGV?= =?us-ascii?Q?9p8ywVLXYx5EzfGFZWerk6q6a/aWSgbLUFC7?= X-Forefront-Antispam-Report: CIP:165.204.84.17;CTRY:US;LANG:en;SCL:1;SRV:;IPV:CAL;SFV:NSPM;H:SATLEXMB04.amd.com;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(13230040)(82310400026)(36860700013)(1800799024)(376014)(7416014);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 15 May 2025 22:55:23.9508 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 616578e7-901f-4607-d46f-08dd940393ad X-MS-Exchange-CrossTenant-Id: 3dd8961f-e488-4e60-8e11-a82d994e183d X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=3dd8961f-e488-4e60-8e11-a82d994e183d;Ip=[165.204.84.17];Helo=[SATLEXMB04.amd.com] X-MS-Exchange-CrossTenant-AuthSource: BN2PEPF000044A4.namprd02.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DS7PR12MB9475 Content-Type: text/plain; charset="utf-8" Create the configuration directory and files for mbm_cntr_assign mode. These configurations will be used to assign MBM events in mbm_cntr_assign mode, with two default configurations created upon mounting. Example: $ cd /sys/fs/resctrl/ $ cat info/L3_MON/counter_configs/mbm_total_bytes/event_filter local_reads, remote_reads, local_non_temporal_writes, remote_non_temporal_writes, local_reads_slow_memory, remote_reads_slow_memory, dirty_victim_writes_all $ cat info/L3_MON/counter_configs/mbm_local_bytes/event_filter local_reads, local_non_temporal_writes, local_reads_slow_memory Signed-off-by: Babu Moger --- v13: Updated user doc (resctrl.rst). Changed the name of the function resctrl_mkdir_info_configs to resctrl_mkdir_counter_configs(). Replaced seq_puts() with seq_putc() where applicable. Removed RFTYPE_MON_CONFIG definition. Not required. Changed the name of the flag RFTYPE_CONFIG to RFTYPE_ASSIGN_CONFIG. Reinette suggested RFTYPE_MBM_EVENT_CONFIG but RFTYPE_ASSIGN_CONFIG seemed shorter and pricise. The configuration is created using evt_list. Resolved conflicts caused by the recent FS/ARCH code restructure. The monitor.c/rdtgroup.c files have been split between the FS and ARCH= directories. v12: New patch to hold the MBM event configurations for mbm_cntr_assign mod= e. --- Documentation/filesystems/resctrl.rst | 30 ++++++++++ fs/resctrl/internal.h | 2 + fs/resctrl/monitor.c | 1 + fs/resctrl/rdtgroup.c | 80 +++++++++++++++++++++++++++ 4 files changed, 113 insertions(+) diff --git a/Documentation/filesystems/resctrl.rst b/Documentation/filesyst= ems/resctrl.rst index 5cf2d742f04c..4eb9f007ba3d 100644 --- a/Documentation/filesystems/resctrl.rst +++ b/Documentation/filesystems/resctrl.rst @@ -306,6 +306,36 @@ with the following files: # cat /sys/fs/resctrl/info/L3_MON/available_mbm_cntrs 0=3D30;1=3D30 =20 +"counter_configs": + When the "mbm_cntr_assign" mode is supported, a dedicated directory is cr= eated + under the "L3_MON" directory to store configuration files. + + These files contain the list of configurable events. There are two default + configurations: mbm_local_bytes and mbm_total_bytes. + + Following types of events are supported: + + =3D=3D=3D=3D =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D + Bits Name Description + =3D=3D=3D=3D =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D + 6 dirty_victim_writes_all Dirty Victims from the QOS domain to all= types of memory + 5 remote_reads_slow_memory Reads to slow memory in the non-local NU= MA domain + 4 local_reads_slow_memory Reads to slow memory in the local NUMA d= omain + 3 remote_non_temporal_writes Non-temporal writes to non-local NUMA do= main + 2 local_non_temporal_writes Non-temporal writes to local NUMA domain + 1 remote_reads Reads to memory in the non-local NUMA do= main + 0 local_reads Reads to memory in the local NUMA domain + =3D=3D=3D=3D =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D + + For example:: + + # cat /sys/fs/resctrl/info/L3_MON/counter_configs/mbm_total_bytes/event= _filter + local_reads, remote_reads, local_non_temporal_writes, remote_non_tempor= al_writes, + local_reads_slow_memory, remote_reads_slow_memory, dirty_victim_writes_= all + + # cat /sys/fs/resctrl/info/L3_MON/counter_configs/mbm_local_bytes/event= _filter + local_reads, local_non_temporal_writes, local_reads_slow_memory + "max_threshold_occupancy": Read/write file provides the largest value (in bytes) at which a previously used LLC_occupancy diff --git a/fs/resctrl/internal.h b/fs/resctrl/internal.h index 019d00bf5adf..446cc9cc61df 100644 --- a/fs/resctrl/internal.h +++ b/fs/resctrl/internal.h @@ -238,6 +238,8 @@ struct mbm_evt_value { =20 #define RFTYPE_DEBUG BIT(10) =20 +#define RFTYPE_ASSIGN_CONFIG BIT(11) + #define RFTYPE_CTRL_INFO (RFTYPE_INFO | RFTYPE_CTRL) =20 #define RFTYPE_MON_INFO (RFTYPE_INFO | RFTYPE_MON) diff --git a/fs/resctrl/monitor.c b/fs/resctrl/monitor.c index 72f3dfb5b903..1f72249a5c93 100644 --- a/fs/resctrl/monitor.c +++ b/fs/resctrl/monitor.c @@ -932,6 +932,7 @@ int resctrl_mon_resource_init(void) RFTYPE_MON_INFO | RFTYPE_RES_CACHE); resctrl_file_fflags_init("available_mbm_cntrs", RFTYPE_MON_INFO | RFTYPE_RES_CACHE); + resctrl_file_fflags_init("event_filter", RFTYPE_ASSIGN_CONFIG); } =20 return 0; diff --git a/fs/resctrl/rdtgroup.c b/fs/resctrl/rdtgroup.c index b109e91096b0..cf84e3a382ac 100644 --- a/fs/resctrl/rdtgroup.c +++ b/fs/resctrl/rdtgroup.c @@ -1911,6 +1911,25 @@ static int resctrl_available_mbm_cntrs_show(struct k= ernfs_open_file *of, return ret; } =20 +static int event_filter_show(struct kernfs_open_file *of, struct seq_file = *seq, void *v) +{ + struct mon_evt *mevt =3D rdt_kn_parent_priv(of->kn); + bool sep =3D false; + int i; + + for (i =3D 0; i < NUM_MBM_EVT_VALUES; i++) { + if (mevt->evt_cfg & mbm_evt_values[i].evt_val) { + if (sep) + seq_putc(seq, ','); + seq_printf(seq, "%s", mbm_evt_values[i].evt_name); + sep =3D true; + } + } + seq_putc(seq, '\n'); + + return 0; +} + /* rdtgroup information files for one cache resource. */ static struct rftype res_common_files[] =3D { { @@ -2035,6 +2054,12 @@ static struct rftype res_common_files[] =3D { .seq_show =3D mbm_local_bytes_config_show, .write =3D mbm_local_bytes_config_write, }, + { + .name =3D "event_filter", + .mode =3D 0444, + .kf_ops =3D &rdtgroup_kf_single_ops, + .seq_show =3D event_filter_show, + }, { .name =3D "mbm_assign_mode", .mode =3D 0444, @@ -2317,6 +2342,55 @@ static int rdtgroup_mkdir_info_resdir(void *priv, ch= ar *name, return ret; } =20 +static int resctrl_mkdir_counter_configs(struct rdt_resource *r, char *nam= e) +{ + struct kernfs_node *l3_mon_kn, *kn_subdir, *kn_subdir2; + struct mon_evt *mevt; + int ret; + + l3_mon_kn =3D kernfs_find_and_get(kn_info, name); + if (!l3_mon_kn) + return -ENOENT; + + kn_subdir =3D kernfs_create_dir(l3_mon_kn, "counter_configs", l3_mon_kn->= mode, NULL); + if (IS_ERR(kn_subdir)) { + kernfs_put(l3_mon_kn); + return PTR_ERR(kn_subdir); + } + + ret =3D rdtgroup_kn_set_ugid(kn_subdir); + if (ret) { + kernfs_put(l3_mon_kn); + return ret; + } + + list_for_each_entry(mevt, &r->mon.evt_list, list) { + if (mevt->mbm_mode =3D=3D MBM_MODE_ASSIGN) { + kn_subdir2 =3D kernfs_create_dir(kn_subdir, mevt->name, + kn_subdir->mode, mevt); + if (IS_ERR(kn_subdir2)) { + ret =3D PTR_ERR(kn_subdir2); + goto config_out; + } + + ret =3D rdtgroup_kn_set_ugid(kn_subdir2); + if (ret) + goto config_out; + + ret =3D rdtgroup_add_files(kn_subdir2, RFTYPE_ASSIGN_CONFIG); + if (!ret) + kernfs_activate(kn_subdir); + } + } + +config_out: + kernfs_put(l3_mon_kn); + if (ret) + kernfs_remove(kn_subdir); + + return ret; +} + static unsigned long fflags_from_resource(struct rdt_resource *r) { switch (r->rid) { @@ -2363,6 +2437,12 @@ static int rdtgroup_create_info_dir(struct kernfs_no= de *parent_kn) ret =3D rdtgroup_mkdir_info_resdir(r, name, fflags); if (ret) goto out_destroy; + + if (r->mon.mbm_cntr_assignable) { + ret =3D resctrl_mkdir_counter_configs(r, name); + if (ret) + goto out_destroy; + } } =20 ret =3D rdtgroup_kn_set_ugid(kn_info); --=20 2.34.1 From nobody Sun Dec 14 02:00:56 2025 Received: from NAM11-BN8-obe.outbound.protection.outlook.com (mail-bn8nam11on2053.outbound.protection.outlook.com [40.107.236.53]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 89C8128D845; Thu, 15 May 2025 22:55:40 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.236.53 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1747349742; cv=fail; b=RS/4ZHeeT9na/S5Ntr2P6zijByVbkSqco9vce9+f6Dy/EU3I7lL9OqAJcGjO7kPE/gDmDNOPgDH4KxM6WXI/LznpjJQwzzcFAEN9VLQHH7ig9ckt649ObRtPS5RHt8A/hIlLX6YbBGSgi8qKHVPNSIcbs/x1iXKTqwK1HJqH0po= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1747349742; c=relaxed/simple; bh=Lp6AGtOw98nD8QYDa1VCqKIv+U6P1I8u2kCNTqvOdpQ=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=EIiWa0+2TaXZySB3Ptwa6i/M6sElu8JqHCM2W+pibkM9I1GebIbiOD8/UnM0GanohwTtbYZkscT8jyeusCnd4jWVgQIRdv0gxcGWCha3Rb0TkzU7egv87TsYz4cwa+xZDgsZgIyg53i1Fnyxhkx4T5QgQXOo8xeao6GPdiOVm/8= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=amd.com; spf=fail smtp.mailfrom=amd.com; dkim=pass (1024-bit key) header.d=amd.com header.i=@amd.com header.b=ra3pTcXg; arc=fail smtp.client-ip=40.107.236.53 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=amd.com Authentication-Results: smtp.subspace.kernel.org; spf=fail smtp.mailfrom=amd.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=amd.com header.i=@amd.com header.b="ra3pTcXg" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=FYV8Ta4weVFj6Jf36z+J4T6aH3s523tqrUys405wyBWLNwqUevyhiBO+fJSspq2TxsJimOkVrWZFoO5YFcrCHkHd5WvDECveIkSmbsFhNTqSK+Fe5BDUHBU6+z2soNFVb+AfQlMMHgXSFCEwJFWgob4UuFFlW7gJ8+nz5PtKaX3SlRinACHPYKDg5TCX+TSMycO43NDV3kAOknUr34xjaBZ54f7Z6ay8eq2OvJLk6qP2BD92pgJKuAq4ahqOyVl2JPlqMwCOq6l1mnsdLzKTmWQcaHsSvw7Pocr0v05L3I2o+D3WhjauxASdygVWc65sYbDgSRjpa789VwHrFc37Yw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=3iT7VVHnXPPmOehuElpTjJppRIQB4BXJzbNSTs80Xu4=; b=rusn5texCKXwsO7NbaA21BB7KwpZBTQux3rTZtSV1M1lp3HJqKK0Yb4qY7EmFnhGvoa+dVmxu/ZAHCDTEeI/T3XjJ8iodEYRioK0pzLKsUNZty4ZVBb5Ns7He6x5I2qCVAGp+3d72GcU6/GXK5cBYRxeBVboVQ2E5/yw4vAPH41+H6JUgPuvaPzVzy90okxkQuislz0W6JqPOvl1CEe8/v+CNcG0hwtSyhqrq+vMX5gaNEfI2qaiVYjtuTUt/OmklZ2OX0Xp8qC7EnoWdU3TBg3rHqc8nBAkRHGY4xGcid7KTk/sU9SVMHjsSvhwL/82lrZciqaIRe5kcA/tkdBXOw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=lwn.net smtp.mailfrom=amd.com; dmarc=pass (p=quarantine sp=quarantine pct=100) action=none header.from=amd.com; dkim=none (message not signed); arc=none (0) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amd.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=3iT7VVHnXPPmOehuElpTjJppRIQB4BXJzbNSTs80Xu4=; b=ra3pTcXgKeVUDyILO5DYOuvAcNjJh7i5U88Bk2hcAWGz9b1FAWJi1pxY6zAHrOLeVp53haiALYYLkKF5enzQd6tPzJmbQCwtxAW7VM0zdaJU2RuoC2qGmGJV2Zgq9hsP+jwRtABmhWQcURsbciWQ4XOTLPi56U5R59/bxT8Lf6Q= Received: from BN9PR03CA0097.namprd03.prod.outlook.com (2603:10b6:408:fd::12) by DS4PR12MB9609.namprd12.prod.outlook.com (2603:10b6:8:278::16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8722.32; Thu, 15 May 2025 22:55:33 +0000 Received: from BN2PEPF0000449D.namprd02.prod.outlook.com (2603:10b6:408:fd:cafe::22) by BN9PR03CA0097.outlook.office365.com (2603:10b6:408:fd::12) with Microsoft SMTP Server (version=TLS1_3, cipher=TLS_AES_256_GCM_SHA384) id 15.20.8746.18 via Frontend Transport; Thu, 15 May 2025 22:55:33 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 165.204.84.17) smtp.mailfrom=amd.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=amd.com; Received-SPF: Pass (protection.outlook.com: domain of amd.com designates 165.204.84.17 as permitted sender) receiver=protection.outlook.com; client-ip=165.204.84.17; helo=SATLEXMB04.amd.com; pr=C Received: from SATLEXMB04.amd.com (165.204.84.17) by BN2PEPF0000449D.mail.protection.outlook.com (10.167.243.148) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.8722.18 via Frontend Transport; Thu, 15 May 2025 22:55:33 +0000 Received: from bmoger-ubuntu.amd.com (10.180.168.240) by SATLEXMB04.amd.com (10.181.40.145) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.39; Thu, 15 May 2025 17:55:30 -0500 From: Babu Moger To: , , , , , , CC: , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , Subject: [PATCH v13 20/27] x86/resctrl: Provide interface to update the event configurations Date: Thu, 15 May 2025 17:52:05 -0500 Message-ID: X-Mailer: git-send-email 2.34.1 In-Reply-To: References: Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-ClientProxiedBy: SATLEXMB04.amd.com (10.181.40.145) To SATLEXMB04.amd.com (10.181.40.145) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: BN2PEPF0000449D:EE_|DS4PR12MB9609:EE_ X-MS-Office365-Filtering-Correlation-Id: a270ddbd-216d-4527-7204-08dd94039959 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|376014|1800799024|7416014|82310400026|36860700013; X-Microsoft-Antispam-Message-Info: =?us-ascii?Q?/1coTU3/uaiIczc5qndyETNI+sLCzH76EkGjWMC+jb4N0829m+kZWu+BRXdO?= =?us-ascii?Q?h9OZbjpBVUoQ7/Aqie3XPmdeXFIxLNeM9B1GFKKGPij4DI76N/ZRfLl5+NuV?= =?us-ascii?Q?5X8cHy7UPsuNZDgnun7pmuxib7670eWKCtLS0HGbpWD513X5tIzUJO5kYHSo?= =?us-ascii?Q?5rwya664No1cNfcAW3lZcfeaYf09PS4QMNYeUlEd6TYW4NQih5JwMXbFgR5+?= =?us-ascii?Q?Pt1TFkbp2kEch5gEaIeektHh/IONaQQ7yiEZuWTsFTpRPFftvQTDgNhQGoOp?= =?us-ascii?Q?Bug/aDx3O+SKI+TcLFmWzqnO7uSUpgnPpeIisjbH06A+IS2/Jn+anUA80Bnq?= =?us-ascii?Q?nzcpcSV5aWes9s3PVKVtmdyVhtEPNJmjtvIQ9Jird60m7oV+oikuC8gRmLBc?= =?us-ascii?Q?1Z33SWr4ocZysE3GZDyScMkVnf4k7Hjq1IJyPc7wkPHQwycIIbVcyV8uQNEQ?= =?us-ascii?Q?sbI26TfWD6mjN6VnpaWJ5Lgn1c5Xej7QdZQB51GFC4S/emEidba8xsJOzloi?= =?us-ascii?Q?IHcD7aItgMGp+Par9X/y7pO25+sKqFplXyu3NtXQmo9e63gvE/fCY3w5ORC3?= =?us-ascii?Q?M13T3ZvK3zZU8ohISigfZYP30SJATxKfEn/P6JxuBmMu0l/8PTbxf7GLoxS/?= =?us-ascii?Q?bMFvnf2R5E+3KPx0oBklxiLVWHdmMRgNL9nXE0SCEJV75C8Bi1bWtd4zvcC3?= =?us-ascii?Q?0DNQQlhdXm04xVpFc70N0Wiq5KQW2+Ikr+kuaxEpSHwjGEnkcgs9uvFpCI/G?= =?us-ascii?Q?AF8cb9fySh2bmUgeZ8lsR2Ro9DVaLdJfAHOx6v5l539agTVObZrW5ye5Xwme?= =?us-ascii?Q?X5pmQFxwDLY+fZ83W6VPx0YikiwDInfNTsRTIHfYRtXVC49eX8WbQkAUwrSv?= =?us-ascii?Q?BXhSmzTrrEE+R31pTtRCcT+O9lzboNm0SxGXYTHDM0XxBVxZqbS0fCbrSvbw?= =?us-ascii?Q?l7aSq5xcv6PXPtd9zzU1uz9Tw/rAnGdPmhlGo4VIsssuf7jeaqpCpuu3/+yn?= =?us-ascii?Q?lfL3TYFl6KaZJsbmQUbW5ufmbqExz+YW6PFqtvh9ko4mLYsSZNGxM7BpesiG?= =?us-ascii?Q?ShJcFVza/a08Nr7iAjPO+uAW5Y9s1EOA9O8oHajy2/lSGgAGBBmWNsoi4ze6?= =?us-ascii?Q?tAVsztkF1VoHl+dP9xtY4DpXwUldSS8WOpSz3bV+DPOsvPBlNNE/Fep1+xGo?= =?us-ascii?Q?M56Hg1jSnwfxFbIIhSDq8MFq5AyAThyrnbo2eI+93TnsmT0r1LIMwSHL/Q0w?= =?us-ascii?Q?8aJhsfmZfl2nbyVAT8IVbQy6fPK3Re429TF2cYzv0JwEed4aOMKlkGQzluNY?= =?us-ascii?Q?khZenxEvjThqkdDQIARukcyNeMsC4YJCaR3JP7c9d6DCKFfEjwUCCTnOaXl6?= =?us-ascii?Q?DH/7pPGn8zXrj8qVVxPaWsP737mq3XMHS5G1snJKBB9aAU6B3HJOvWXNQIX4?= =?us-ascii?Q?HpppPld9FO3ggUSJtf+yH8dGexBqPSXycL+m0bS8wgjm6oJGtQGjecJgWn1K?= =?us-ascii?Q?6YESIJCR6SduwroQ7fHcia8mZqqqY/OY9d0K?= X-Forefront-Antispam-Report: CIP:165.204.84.17;CTRY:US;LANG:en;SCL:1;SRV:;IPV:CAL;SFV:NSPM;H:SATLEXMB04.amd.com;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(13230040)(376014)(1800799024)(7416014)(82310400026)(36860700013);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 15 May 2025 22:55:33.4641 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: a270ddbd-216d-4527-7204-08dd94039959 X-MS-Exchange-CrossTenant-Id: 3dd8961f-e488-4e60-8e11-a82d994e183d X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=3dd8961f-e488-4e60-8e11-a82d994e183d;Ip=[165.204.84.17];Helo=[SATLEXMB04.amd.com] X-MS-Exchange-CrossTenant-AuthSource: BN2PEPF0000449D.namprd02.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DS4PR12MB9609 Content-Type: text/plain; charset="utf-8" Users can modify the event configuration by writing to the event_filter interface file. The event configurations for mbm_cntr_assign mode are located in /sys/fs/resctrl/info/event_configs/. Update the assignments of all groups when the event configuration is modified. Example: $ cd /sys/fs/resctrl/ $ cat info/L3_MON/counter_configs/mbm_local_bytes/event_filter local_reads,local_non_temporal_writes,local_reads_slow_memory $ echo "local_reads,local_non_temporal_writes" > info/L3_MON/counter_configs/mbm_total_bytes/event_filter $ cat info/L3_MON/counter_configs/mbm_total_bytes/event_filter local_reads,local_non_temporal_writes Signed-off-by: Babu Moger --- v13: Updated changelog for imperative mode. Added function description in the prototype. Updated the user doc resctrl.rst to address few feedback. Resolved conflicts caused by the recent FS/ARCH code restructure. The rdtgroup.c/monitor.c file has now been split between the FS and AR= CH directories. v12: New patch to modify event configurations. --- Documentation/filesystems/resctrl.rst | 12 +++ fs/resctrl/rdtgroup.c | 120 +++++++++++++++++++++++++- 2 files changed, 131 insertions(+), 1 deletion(-) diff --git a/Documentation/filesystems/resctrl.rst b/Documentation/filesyst= ems/resctrl.rst index 4eb9f007ba3d..9923276826db 100644 --- a/Documentation/filesystems/resctrl.rst +++ b/Documentation/filesystems/resctrl.rst @@ -336,6 +336,18 @@ with the following files: # cat /sys/fs/resctrl/info/L3_MON/counter_configs/mbm_local_bytes/event= _filter local_reads, local_non_temporal_writes, local_reads_slow_memory =20 + Modify the event configuration by writing to the "event_filter" file with= in the + configuration directory. The read/write event_filter file contains the co= nfiguration + of the event that reflects which memory transactions are counted by it. + + For example:: + + # echo "local_reads, local_non_temporal_writes" > + /sys/fs/resctrl/info/L3_MON/counter_configs/mbm_total_bytes/event_fil= ter + + # cat /sys/fs/resctrl/info/L3_MON/counter_configs/mbm_total_bytes/event= _filter + local_reads, local_non_temporal_writes + "max_threshold_occupancy": Read/write file provides the largest value (in bytes) at which a previously used LLC_occupancy diff --git a/fs/resctrl/rdtgroup.c b/fs/resctrl/rdtgroup.c index cf84e3a382ac..8c498b41be5d 100644 --- a/fs/resctrl/rdtgroup.c +++ b/fs/resctrl/rdtgroup.c @@ -1930,6 +1930,123 @@ static int event_filter_show(struct kernfs_open_fil= e *of, struct seq_file *seq, return 0; } =20 +/** + * resctrl_group_assign - Update the counter assignments for the event in + * a group. + * @r: Resource to which update needs to be done. + * @rdtgrp: Resctrl group. + * @evtid: Event ID. + * @evt_cfg: Event configuration value. + */ +static int resctrl_group_assign(struct rdt_resource *r, struct rdtgroup *r= dtgrp, + enum resctrl_event_id evtid, u32 evt_cfg) +{ + struct rdt_mon_domain *d; + int cntr_id; + + list_for_each_entry(d, &r->mon_domains, hdr.list) { + cntr_id =3D mbm_cntr_get(r, d, rdtgrp, evtid); + if (cntr_id >=3D 0 && d->cntr_cfg[cntr_id].evt_cfg !=3D evt_cfg) { + d->cntr_cfg[cntr_id].evt_cfg =3D evt_cfg; + resctrl_arch_config_cntr(r, d, evtid, rdtgrp->mon.rmid, + rdtgrp->closid, cntr_id, evt_cfg, true); + } + } + + return 0; +} + +/** + * resctrl_update_assign - Update the counter assignments for the event fo= r all + * the groups. + * @r: Resource to which update needs to be done. + * @evtid: Event ID. + * @evt_cfg: Event configuration value. + */ +static int resctrl_update_assign(struct rdt_resource *r, enum resctrl_even= t_id evtid, + u32 evt_cfg) +{ + struct rdtgroup *prgrp, *crgrp; + + /* Check if the cntr_id is associated to the event type updated */ + list_for_each_entry(prgrp, &rdt_all_groups, rdtgroup_list) { + resctrl_group_assign(r, prgrp, evtid, evt_cfg); + + list_for_each_entry(crgrp, &prgrp->mon.crdtgrp_list, mon.crdtgrp_list) { + resctrl_group_assign(r, crgrp, evtid, evt_cfg); + } + } + + return 0; +} + +static int resctrl_process_configs(char *tok, u32 *val) +{ + char *evt_str; + bool found; + int i; + +next_config: + if (!tok || tok[0] =3D=3D '\0') + return 0; + + /* Start processing the strings for each event type */ + evt_str =3D strim(strsep(&tok, ",")); + found =3D false; + for (i =3D 0; i < NUM_MBM_EVT_VALUES; i++) { + if (!strcmp(mbm_evt_values[i].evt_name, evt_str)) { + *val |=3D mbm_evt_values[i].evt_val; + found =3D true; + break; + } + } + + if (!found) { + rdt_last_cmd_printf("Invalid event type %s\n", evt_str); + return -EINVAL; + } + + goto next_config; +} + +static ssize_t event_filter_write(struct kernfs_open_file *of, char *buf, + size_t nbytes, loff_t off) +{ + struct rdt_resource *r =3D resctrl_arch_get_resource(RDT_RESOURCE_L3); + struct mon_evt *mevt =3D rdt_kn_parent_priv(of->kn); + u32 evt_cfg =3D 0; + int ret =3D 0; + + /* Valid input requires a trailing newline */ + if (nbytes =3D=3D 0 || buf[nbytes - 1] !=3D '\n') + return -EINVAL; + + buf[nbytes - 1] =3D '\0'; + + cpus_read_lock(); + mutex_lock(&rdtgroup_mutex); + + rdt_last_cmd_clear(); + + if (!resctrl_arch_mbm_cntr_assign_enabled(r)) { + rdt_last_cmd_puts("mbm_cntr_assign mode is not enabled\n"); + ret =3D -EINVAL; + goto unlock_out; + } + + ret =3D resctrl_process_configs(buf, &evt_cfg); + if (!ret && mevt->evt_val !=3D evt_cfg) { + mevt->evt_val =3D evt_cfg; + resctrl_update_assign(r, mevt->evtid, evt_cfg); + } + +unlock_out: + mutex_unlock(&rdtgroup_mutex); + cpus_read_unlock(); + + return ret ?: nbytes; +} + /* rdtgroup information files for one cache resource. */ static struct rftype res_common_files[] =3D { { @@ -2056,9 +2173,10 @@ static struct rftype res_common_files[] =3D { }, { .name =3D "event_filter", - .mode =3D 0444, + .mode =3D 0644, .kf_ops =3D &rdtgroup_kf_single_ops, .seq_show =3D event_filter_show, + .write =3D event_filter_write, }, { .name =3D "mbm_assign_mode", --=20 2.34.1 From nobody Sun Dec 14 02:00:56 2025 Received: from NAM12-MW2-obe.outbound.protection.outlook.com (mail-mw2nam12on2049.outbound.protection.outlook.com [40.107.244.49]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 821B928D845; Thu, 15 May 2025 22:55:47 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.244.49 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1747349749; cv=fail; b=GrlmxqYE0y2rrecLO+8ggcyM/eb1lGyvJ36RrXkqin5wVz6LKeLlJdShLM7y2kSxN31K/mWhkqKiZk+IoFrSbSE6XZ3VgNJIGt4K2d+jjCBqtW00FforXrTs+ly217q3VhV4iUbbz1R9jzlOak9VFXrOzHInL/KJZzKNViyIkyc= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1747349749; c=relaxed/simple; bh=u3Mq6F3+q0KbJzGbo6+aFa1c4uAay3aVYHq/yx7p2V4=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=IslnkSRIxiumLuuD2+4Q4hi6FMHCiOlkJJRx5SgT5ZjN8aj24JgBPOn5MkXrYurYAuNAP0uVPn1hcoFFQCtf5RM0qPLBq3cNbb/hMQDFuClBwbmax16x7BFwS4EvVHkBuzergzHpSwMUxYtlMdnHP2Jbd+Uyu34Bz6aiFYJc6oY= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=amd.com; spf=fail smtp.mailfrom=amd.com; dkim=pass (1024-bit key) header.d=amd.com header.i=@amd.com header.b=pOcZjWIm; arc=fail smtp.client-ip=40.107.244.49 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=amd.com Authentication-Results: smtp.subspace.kernel.org; spf=fail smtp.mailfrom=amd.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=amd.com header.i=@amd.com header.b="pOcZjWIm" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=gfjHwNmItByj1zx8UcuenEJU/gXLQ4GILBVzLm76XHGtYHj6Yn4gN4sYOW7B0snWS4LS0508j2/SyvndHHTzfhuRYe1kN9IZ+tUNdyGiqnIFMeSmT/5Bvlf4BgOwwGvhtcb7DnKlNXuEQz8dh3kXAJW8l4bBITqHm4wzpOB3nOZ8Gs1YO7dGHx/+C8xnAPxKzeNvU1m487I2LQNlTJvLbTXQ0599Jm3NEjz0sIIotHQFbOYeKZ/UsLYaVIOOWTstF2K5XTxmQoXiqRViQvPYudvUo1C8DW4BFv6m22F+5fBRKEZXVrIgKRDXuOI5tkijjzpOqABel6kJ7D+e3xWuew== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=xfD3lLeta8Ng3P+KvCVlxOsYWLD+rSQbCdzWwxDrGTQ=; b=dG57gMzSP/Feef5R3G6U2tP4yUdJBrQ+CvMyDtb0wTaPQ+tD6vt3H++2QjBectbS28XL21tjJ7+k4laV5fXMOgbOhatdgwXeLFdr/Rt656BPFZg57h1+3uPZy5G6bHYeUWg3VFbb3V4Iqjez+C7jjDkBCh+5Y8pnjEDN42eujKgbk/o5UByTo8YqtXMdoUIJzpgpzaU/bSnCMecB69PxTMA6RLVgi6OJHkGvhLDa1z6e/9HK658Lo9ehHjbanFt5arSUKvs7sncZ3ybHqOp5lHNLn4u4qcHNWL2+bNzG1tD5NXRmHAu6xGB/ilFqZ24ZCeZCPOJdgs7r1OKiWOuBoQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=lwn.net smtp.mailfrom=amd.com; dmarc=pass (p=quarantine sp=quarantine pct=100) action=none header.from=amd.com; dkim=none (message not signed); arc=none (0) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amd.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=xfD3lLeta8Ng3P+KvCVlxOsYWLD+rSQbCdzWwxDrGTQ=; b=pOcZjWImchlp+EklUUqpsMbxXpHDJMXE2alptjfJDFfRjWurnU7x52v9Vr0HtddctsX2I43vOEAZYtVRNM8SA4D+dqJh79GggUO7uk42epwB68scsTB7F33G5MeK/nfgPn90DVqUmi4KrWaiJwIxWwl1qj3eHt2hn9C1c/fCdeQ= Received: from BN9PR03CA0173.namprd03.prod.outlook.com (2603:10b6:408:f4::28) by CH3PR12MB8658.namprd12.prod.outlook.com (2603:10b6:610:175::8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8722.32; Thu, 15 May 2025 22:55:43 +0000 Received: from BN2PEPF000044A1.namprd02.prod.outlook.com (2603:10b6:408:f4:cafe::70) by BN9PR03CA0173.outlook.office365.com (2603:10b6:408:f4::28) with Microsoft SMTP Server (version=TLS1_3, cipher=TLS_AES_256_GCM_SHA384) id 15.20.8722.25 via Frontend Transport; Thu, 15 May 2025 22:55:43 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 165.204.84.17) smtp.mailfrom=amd.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=amd.com; Received-SPF: Pass (protection.outlook.com: domain of amd.com designates 165.204.84.17 as permitted sender) receiver=protection.outlook.com; client-ip=165.204.84.17; helo=SATLEXMB04.amd.com; pr=C Received: from SATLEXMB04.amd.com (165.204.84.17) by BN2PEPF000044A1.mail.protection.outlook.com (10.167.243.152) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.8722.18 via Frontend Transport; Thu, 15 May 2025 22:55:42 +0000 Received: from bmoger-ubuntu.amd.com (10.180.168.240) by SATLEXMB04.amd.com (10.181.40.145) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.39; Thu, 15 May 2025 17:55:40 -0500 From: Babu Moger To: , , , , , , CC: , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , Subject: [PATCH v13 21/27] x86/resctrl: Introduce mbm_assign_on_mkdir to configure assignments Date: Thu, 15 May 2025 17:52:06 -0500 Message-ID: X-Mailer: git-send-email 2.34.1 In-Reply-To: References: Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-ClientProxiedBy: SATLEXMB04.amd.com (10.181.40.145) To SATLEXMB04.amd.com (10.181.40.145) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: BN2PEPF000044A1:EE_|CH3PR12MB8658:EE_ X-MS-Office365-Filtering-Correlation-Id: a9349f4b-7038-4c0c-53fe-08dd94039f06 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|376014|7416014|1800799024|82310400026|36860700013|13003099007; X-Microsoft-Antispam-Message-Info: =?us-ascii?Q?KKj2zz/PhgMKIJ2JKNWV1oOPSR0p7/rpOT/HwFI/ix3DuaGyxc/7epGgYpW7?= =?us-ascii?Q?kGhAhfNUHOC+lBdDj0ntAFAe+EaLh8Gk/uRj4up8RomZZ6KrwDOSp6jB3EkZ?= =?us-ascii?Q?RqT5WxkuqWnRJy9OKddegsxmBUnMfZAd8kQxkObRuBvwerTpWwpn3P2yBEm+?= =?us-ascii?Q?lAadIBkobm3METYBfU5t6BhW2YjGa1syPg6I/0sSHc59Pk+eLpNNb10Wsi7A?= =?us-ascii?Q?rEgozHzVof0uarn/DvCvnsGULDiuTFS+6jIZdC25SP6zZKLF6zRgwIbu9CND?= =?us-ascii?Q?MHRQaq7nObmBg7/IHPc+HqMdOX5A2ou8WGbrkfQ1eqqmCKSXc8eLhEXnt0/G?= =?us-ascii?Q?f+XGSDXetEAniqVjXMtg9bkzMti9PzHPB6W3DvcoqBbQow3tv2O0SknFuEar?= =?us-ascii?Q?dkjikApezgPrBk8wugPR6BGx8QSE8kQMwehXwa0O3bc2lIyJVG7y4DjakcAP?= =?us-ascii?Q?vAO+bxetPkL+jygYTg4hHet/q5Le9oCbkwXNZXXK+pTIY4ZNTvZgPiXGclbT?= =?us-ascii?Q?cip48KvQ1FiTvyECWfIFpuzDE44xgDcgbTuMbBCuOy4dmuTSraim3k1w1rs/?= =?us-ascii?Q?PWvVFdEu0SaY6TAiKrb27lykJTF6CpHx1zQjoaNUOZDaKP50lAlpE5ciClU9?= =?us-ascii?Q?0Z8qt9OpSCkZu5+tr8AwH/82IUIJGBToaw0zUbUTc5ax2bi7zQp3xLz+Q14g?= =?us-ascii?Q?rnpPapT6s/aoMmUxZxRbOwY59Z20IUcttKzZ/AIYrM7J4xLl5X89Fk4yF/cw?= =?us-ascii?Q?aDRiERIFM4YHwk8qDZFxcbEzGOJOxxz613e4r24Lom6/AdihXKXGmeQpIKcA?= =?us-ascii?Q?z/KSEjv0hKuAVU66RiuisPGLlKua6TsxI/mqHiXyhzQZWhOA0eUZHazx4C3i?= =?us-ascii?Q?+DWz+w42a9ep9jHXhan5/p7vQSyWmX0wT5ovoux1vSseeuOt19sqYtI0Fe25?= =?us-ascii?Q?TXghO45F9noj2pz/a1Ar+JOzSBg/8oRk0Xyu+a5ZUgnap6GhCxcQ1Z5IA0O7?= =?us-ascii?Q?eUq6fwpfY6F21MD16ynPnoeN4qUh2ZpCfQSbnrZQC6W293gTmNqeP/krdZML?= =?us-ascii?Q?hzJVY45nssLHw4+md/P43b3Dtrr6lG80D6uibU06fJiw3tVMxbnR1kOwQvaB?= =?us-ascii?Q?UUqZAwqv3Fg3VuKdSUYJ57pmsWxNvCH//MHrtTNeYerRguIsvzChdqvDWrcj?= =?us-ascii?Q?iiddWKpY/0cmtC7xZ600KH2jMsK9YHEuT4zjWp3PJonymQk3XQkXLJFac7kC?= =?us-ascii?Q?b7Jo6FM3O+NEE4BQwaJpDYa4sV2/4RKe/c4clZvfSZ59YgX+TX5IdNt4GQPS?= =?us-ascii?Q?gQMW0NyMdCDo8t5JmTilEROQpkn401brMbhwSmNfsyegKrss/WHzVl1BcuVb?= =?us-ascii?Q?AWAga3J+ejAek6OQkicdLCCCbwGCTY9T6wwBDEcgoPnzARdvCUnIbv0Oujl5?= =?us-ascii?Q?p8Y92zDIfB+VVOULYb8sZJ9QLBiAy8G7iSzAaJ1T3fJQQBxWSg1DcNNdHP9W?= =?us-ascii?Q?NNUIPn+uJzuhF/PzU+RBQff3Ymv7CvMRmo9x20NxRRsqbvtKhAQlKfBn2Q?= =?us-ascii?Q?=3D=3D?= X-Forefront-Antispam-Report: CIP:165.204.84.17;CTRY:US;LANG:en;SCL:1;SRV:;IPV:CAL;SFV:NSPM;H:SATLEXMB04.amd.com;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(13230040)(376014)(7416014)(1800799024)(82310400026)(36860700013)(13003099007);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 15 May 2025 22:55:42.9852 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: a9349f4b-7038-4c0c-53fe-08dd94039f06 X-MS-Exchange-CrossTenant-Id: 3dd8961f-e488-4e60-8e11-a82d994e183d X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=3dd8961f-e488-4e60-8e11-a82d994e183d;Ip=[165.204.84.17];Helo=[SATLEXMB04.amd.com] X-MS-Exchange-CrossTenant-AuthSource: BN2PEPF000044A1.namprd02.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: CH3PR12MB8658 Content-Type: text/plain; charset="utf-8" The mbm_cntr_assign mode provides an option to the user to assign a counter to an RMID, event pair and monitor the bandwidth as long as the counter is assigned. Introduce a configuration option to automatically assign counter IDs when a resctrl group is created, provided the counters are available. By default, this option is enabled at boot. Suggested-by: Peter Newman Signed-off-by: Babu Moger --- v13: Added Suggested-by tag. Resolved conflicts caused by the recent FS/ARCH code restructure. The rdtgroup.c/monitor.c file has now been split between the FS and AR= CH directories. v12: New patch. Added after the discussion on the list. https://lore.kernel.org/lkml/CALPaoCh8siZKjL_3yvOYGL4cF_n_38KpUFgHVGbQ= 86nD+Q2_SA@mail.gmail.com/ --- Documentation/filesystems/resctrl.rst | 10 ++++++ fs/resctrl/monitor.c | 2 ++ fs/resctrl/rdtgroup.c | 44 +++++++++++++++++++++++++-- include/linux/resctrl.h | 2 ++ 4 files changed, 56 insertions(+), 2 deletions(-) diff --git a/Documentation/filesystems/resctrl.rst b/Documentation/filesyst= ems/resctrl.rst index 9923276826db..356f1f918a86 100644 --- a/Documentation/filesystems/resctrl.rst +++ b/Documentation/filesystems/resctrl.rst @@ -348,6 +348,16 @@ with the following files: # cat /sys/fs/resctrl/info/L3_MON/counter_configs/mbm_total_bytes/event= _filter local_reads, local_non_temporal_writes =20 +"mbm_assign_on_mkdir": + Automatically assign the monitoring counters on resctrl group creation + if the counters are available. It is enabled by default on boot and users + can disable by writing to the interface. + :: + + # echo 0 > /sys/fs/resctrl/info/L3_MON/mbm_assign_on_mkdir + # cat /sys/fs/resctrl/info/L3_MON/mbm_assign_on_mkdir + 0 + "max_threshold_occupancy": Read/write file provides the largest value (in bytes) at which a previously used LLC_occupancy diff --git a/fs/resctrl/monitor.c b/fs/resctrl/monitor.c index 1f72249a5c93..5f6c4b662f3b 100644 --- a/fs/resctrl/monitor.c +++ b/fs/resctrl/monitor.c @@ -933,6 +933,8 @@ int resctrl_mon_resource_init(void) resctrl_file_fflags_init("available_mbm_cntrs", RFTYPE_MON_INFO | RFTYPE_RES_CACHE); resctrl_file_fflags_init("event_filter", RFTYPE_ASSIGN_CONFIG); + resctrl_file_fflags_init("mbm_assign_on_mkdir", RFTYPE_MON_INFO | + RFTYPE_RES_CACHE); } =20 return 0; diff --git a/fs/resctrl/rdtgroup.c b/fs/resctrl/rdtgroup.c index 8c498b41be5d..0093b323d858 100644 --- a/fs/resctrl/rdtgroup.c +++ b/fs/resctrl/rdtgroup.c @@ -2035,8 +2035,8 @@ static ssize_t event_filter_write(struct kernfs_open_= file *of, char *buf, } =20 ret =3D resctrl_process_configs(buf, &evt_cfg); - if (!ret && mevt->evt_val !=3D evt_cfg) { - mevt->evt_val =3D evt_cfg; + if (!ret && mevt->evt_cfg !=3D evt_cfg) { + mevt->evt_cfg =3D evt_cfg; resctrl_update_assign(r, mevt->evtid, evt_cfg); } =20 @@ -2047,6 +2047,39 @@ static ssize_t event_filter_write(struct kernfs_open= _file *of, char *buf, return ret ?: nbytes; } =20 +static int resctrl_mbm_assign_on_mkdir_show(struct kernfs_open_file *of, + struct seq_file *s, void *v) +{ + struct rdt_resource *r =3D rdt_kn_parent_priv(of->kn); + + seq_printf(s, "%u\n", r->mon.mbm_assign_on_mkdir); + + return 0; +} + +static ssize_t resctrl_mbm_assign_on_mkdir_write(struct kernfs_open_file *= of, + char *buf, size_t nbytes, loff_t off) +{ + struct rdt_resource *r =3D rdt_kn_parent_priv(of->kn); + bool value; + int ret; + + ret =3D kstrtobool(buf, &value); + if (ret) + return ret; + + cpus_read_lock(); + mutex_lock(&rdtgroup_mutex); + rdt_last_cmd_clear(); + + r->mon.mbm_assign_on_mkdir =3D value; + + mutex_unlock(&rdtgroup_mutex); + cpus_read_unlock(); + + return ret ?: nbytes; +} + /* rdtgroup information files for one cache resource. */ static struct rftype res_common_files[] =3D { { @@ -2056,6 +2089,13 @@ static struct rftype res_common_files[] =3D { .seq_show =3D rdt_last_cmd_status_show, .fflags =3D RFTYPE_TOP_INFO, }, + { + .name =3D "mbm_assign_on_mkdir", + .mode =3D 0644, + .kf_ops =3D &rdtgroup_kf_single_ops, + .seq_show =3D resctrl_mbm_assign_on_mkdir_show, + .write =3D resctrl_mbm_assign_on_mkdir_write, + }, { .name =3D "num_closids", .mode =3D 0444, diff --git a/include/linux/resctrl.h b/include/linux/resctrl.h index cd24d1577e0a..d6435abdde7b 100644 --- a/include/linux/resctrl.h +++ b/include/linux/resctrl.h @@ -278,6 +278,7 @@ enum resctrl_schema_fmt { * monitoring events can be configured. * @num_mbm_cntrs: Number of assignable monitoring counters * @mbm_cntr_assignable:Is system capable of supporting monitor assignment? + * @mbm_assign_on_mkdir:Auto enable monitor assignment on mkdir? * @evt_list: List of monitoring events */ struct resctrl_mon { @@ -285,6 +286,7 @@ struct resctrl_mon { unsigned int mbm_cfg_mask; int num_mbm_cntrs; bool mbm_cntr_assignable; + bool mbm_assign_on_mkdir; struct list_head evt_list; }; =20 --=20 2.34.1 From nobody Sun Dec 14 02:00:56 2025 Received: from NAM10-MW2-obe.outbound.protection.outlook.com (mail-mw2nam10on2067.outbound.protection.outlook.com [40.107.94.67]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 4F6CF28D8C4; Thu, 15 May 2025 22:55:58 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.94.67 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1747349761; cv=fail; b=XJW3ekieGDPt8EKOoAQ/mKoPl4A76Yed2/Ctup89s/XjUtYo3ocusD4xrfwbyBRsYWdSoPFuJlqLhN6E1lNLwJwa7U38MoJD2YH5IUmzYEfYMPXWE4/cdFTBu7zGr9Lp6p79dFXrqYMJRb8h4iCbtB1eWME3DUlb4COMrN9Lt+4= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1747349761; c=relaxed/simple; bh=qo5zX5zCDxE1xAZPsHZrOmvCRwQ3JG+K8dflhu/MbCM=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=DLLscoeV0UAOHqcSwi28TGnMQuqBIKTKyL8d+nACYen5pZEh80UFXKVrmvsfq4OUZnj+5XsZqh1lsFdET2mI6Qm9PH1MzEf5BQhw6SoPCwyiPFytGeUswqJQpdfkk2qtKAdCb+oJ+wPGsTUiIXV4SOyeeDD63TDULZ544jsoaqk= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=amd.com; spf=fail smtp.mailfrom=amd.com; dkim=pass (1024-bit key) header.d=amd.com header.i=@amd.com header.b=RhHQDIZ2; arc=fail smtp.client-ip=40.107.94.67 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=amd.com Authentication-Results: smtp.subspace.kernel.org; spf=fail smtp.mailfrom=amd.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=amd.com header.i=@amd.com header.b="RhHQDIZ2" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=Yods4le+Y1G/ryU+3p1ak248UigIBglgZpOh263LbE55/z4ZYpOIUBdkWRGaTHNd1Vgosrw8Pvt7nH+D0xRH/zjzBfqrzXPWxoOuVzRn4/hnhTAA4RiP8VO/GREno/26YJlhX9C2gpVS0ZLY8lirWBdPMjxXL1PlV5FgtVA7q6kVkp4uE+nAaJU8rMo/5fukQLrNI2Bnvf1G4MnEnzmSNMlkXyVGZrcTjUKqm2kE6uBNIkrVWlUcbw7/U5i3L0Ypiq7lWLR6CjoFZ3l6ivsC0uoaC8MPqO5PfK95MH7Dtp4PuT83fXJDHKuiKSNrbl51I/OrU7iLrBvdHmb2DO4Muw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=R72LMR3xfreYKkcME3/0odm0LGY05apoI8kKaaoHwlg=; b=oP1RykY58tog9CWrcOL/HPbNF4VaSJ29P8+0ivciuisifJVill3EzSVpFZEHz9a7+p3o0UTah6vwbVUbJKCZlf/Q4t5TJPSlOFbbSlJcAKKuK0LP9npbtwj/p/8S7Imdih9pGXH7PYqwL3L5+O1m9vFY1RWvosb6FosKaQqeiyVy660HtIVRNQ+PVea5S4zgf6DdHJXZ9gm1Lid/tR/gW3oIZP9BSSQ94U6XPjPtEXN+Cg5Zvi0dpRinAjO4BK5xncrvY9aMhQGkESON3pLjkFLxDGkYDfNYGgE3H1E1079D8wEkUyrqnU4EDAOiBZnC6U+OOE3xb9tomdpietNmcA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=lwn.net smtp.mailfrom=amd.com; dmarc=pass (p=quarantine sp=quarantine pct=100) action=none header.from=amd.com; dkim=none (message not signed); arc=none (0) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amd.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=R72LMR3xfreYKkcME3/0odm0LGY05apoI8kKaaoHwlg=; b=RhHQDIZ2tBnC+Os4RWm2aMXuq3LQ6Z8QMFY0+FYFKxXsBzMsbGel/gFbj1W7+cN3jmhuMza1A1TjNi7IG67CfK0C+U2gUZHdZ64ppFenGy/Dk2jANsNpeJ185fcegwpkxKqK+JTg2TB6pUHqKclvIZr5qRFuMgpdwQttmHuGjbQ= Received: from BN0PR02CA0030.namprd02.prod.outlook.com (2603:10b6:408:e4::35) by CH2PR12MB4102.namprd12.prod.outlook.com (2603:10b6:610:a9::7) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8722.33; Thu, 15 May 2025 22:55:54 +0000 Received: from BN2PEPF000044A0.namprd02.prod.outlook.com (2603:10b6:408:e4:cafe::10) by BN0PR02CA0030.outlook.office365.com (2603:10b6:408:e4::35) with Microsoft SMTP Server (version=TLS1_3, cipher=TLS_AES_256_GCM_SHA384) id 15.20.8722.20 via Frontend Transport; Thu, 15 May 2025 22:55:53 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 165.204.84.17) smtp.mailfrom=amd.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=amd.com; Received-SPF: Pass (protection.outlook.com: domain of amd.com designates 165.204.84.17 as permitted sender) receiver=protection.outlook.com; client-ip=165.204.84.17; helo=SATLEXMB04.amd.com; pr=C Received: from SATLEXMB04.amd.com (165.204.84.17) by BN2PEPF000044A0.mail.protection.outlook.com (10.167.243.151) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.8722.18 via Frontend Transport; Thu, 15 May 2025 22:55:52 +0000 Received: from bmoger-ubuntu.amd.com (10.180.168.240) by SATLEXMB04.amd.com (10.181.40.145) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.39; Thu, 15 May 2025 17:55:49 -0500 From: Babu Moger To: , , , , , , CC: , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , Subject: [PATCH v13 22/27] x86/resctrl: Auto assign/unassign counters when mbm_cntr_assign is enabled Date: Thu, 15 May 2025 17:52:07 -0500 Message-ID: <8ae6b97ada1737a87d3c6aebb524081c95ff623f.1747349530.git.babu.moger@amd.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: References: Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-ClientProxiedBy: SATLEXMB04.amd.com (10.181.40.145) To SATLEXMB04.amd.com (10.181.40.145) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: BN2PEPF000044A0:EE_|CH2PR12MB4102:EE_ X-MS-Office365-Filtering-Correlation-Id: 40dce6be-e77a-4d29-c7e9-08dd9403a4c6 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|82310400026|1800799024|7416014|376014|36860700013; X-Microsoft-Antispam-Message-Info: =?us-ascii?Q?2K0rRNPWNVZbUITo+y0tpm1EkHagU61H9swMu8Ew/lxJZasQCKXavvZfBJpW?= =?us-ascii?Q?SAub8wI9o8/+hpdiP6/uHEAzjVs2iuiWHoNBdK4z+JF2nPrl+ye13mcLvvUz?= =?us-ascii?Q?TrvuP76WK/GRSHh6lhFdJm2pYF0ff717/p9mB1uqPOwOiX/wpIPAfCQIcpxz?= =?us-ascii?Q?puIvp4GDLUmRL+NjwijdVJfnUuBLbVRkOVk+z+4PhwUZ+1hHHWt3+4GpaTah?= =?us-ascii?Q?gQ/1GC9QQWCuQoGhRX7HRyRx1dUxQMS8eFycycQXB8Orsdi1ioEm9fLYoaTD?= =?us-ascii?Q?f8lob9HSRpnnfmYv7g/vHLg2lCNz/Yds9k1P3I+ucT36QSF+Ff+BOwiylJxw?= =?us-ascii?Q?3r+9Gbuq5uQ+qHi7F/Dr1+H9G/pLbGpUqp9MxCKPoBOwZ1S/51mTeZp67MBK?= =?us-ascii?Q?Twj6luzztlXoiSvCQzDp1kfhOtgfwF93Pt164bYWNnc2GjMlREshiVw1670A?= =?us-ascii?Q?xu0QmkLgMmI2tD6YOSv7IaTXocPKzWqxcWaSdbJ5vHEDpVFDldAmviwSsOdB?= =?us-ascii?Q?LV4Z9kAzHW4POL2P5/eWEuKHs0tyyZnZLKgcAU99LDZSiRs6/1/rWoGl4bA1?= =?us-ascii?Q?PWLpIAp8ThqF2i//8HeG1nXWpngjKFfXNt9ycxgHNc3rwR79dQbQmtc7F4NG?= =?us-ascii?Q?3ljqxrP1FNuyUab8JshX0/nCG4TOa+b3TvU/lQE/Ye7CD0+nBQEedesrn/3s?= =?us-ascii?Q?EZfYAv5gBa1va4NARGurd5g2vBZP9994InuEKw4kuLQ8pXgK9Y9QMKCVKHYN?= =?us-ascii?Q?31Uis4zhi9IfFwkT3UMyKQbwwm431s6lLiLw2ZE0fr6l29iPFIY2dRJ9w2hY?= =?us-ascii?Q?6NGNQG30Yf7WbJtzaADqprji8PmH+XxmTi/QfUaS/74rwgwDZ2dg8Zf0R8Nf?= =?us-ascii?Q?1eKOmKXjmGOufibOMqpHa5PWPQLi5lLsCUxwvzbbseo/UBlKEfMRMwS7U7lV?= =?us-ascii?Q?YD+q6wSJrtUFwTSuCI7u3us6Qo2efp06mm/AJvsqioj7XJAnfJt7qrZ1CqmK?= =?us-ascii?Q?71CFMGuxf05qf5NJqV1S0uFBY6R8YlGVYonT4h9LEv3xT7UzvDfwl+dexarJ?= =?us-ascii?Q?YGwrvJsFtyPNT0C7ZDNaKi5pXmIymtSRUwYPYWyh26SHJ8ZyjvMd725goJcT?= =?us-ascii?Q?6nHx2AgyUF1FwNP2QwuIz1LLGBgeumHYn+ZkjGbf8yn7nKVg5Fj5cpzpTWTK?= =?us-ascii?Q?vcvDLcWc9E6A7fq7tIHfZJ8AHL2pR0YDe8R+tWJLU3W14afNg9oXXkawu03e?= =?us-ascii?Q?Y9TBKkrfejU+RqutJ6ckN2oyG7mN9luxBTX540EXoNnPROn4+EPzOLJxhPq4?= =?us-ascii?Q?54tWpEAnCJKaQbgLuJ9vFvH7wY0LUbcYGXIChtwQcPaZ6PgARm4TOFzlcT+I?= =?us-ascii?Q?MXO3daNCppvoSTWeZnejhK2P+bFrejre4IfCIoYLTH7Yl7NWkEEeZbo7bH9L?= =?us-ascii?Q?TlKGv0B5V/aMsuGrBNgjt6yJmzTSFeoZwBUBLo+hENixbX3bxLUja6DblWMS?= =?us-ascii?Q?f6OO+cXAlI2hkKtnSIjLYD+pxFttoz0zAejV?= X-Forefront-Antispam-Report: CIP:165.204.84.17;CTRY:US;LANG:en;SCL:1;SRV:;IPV:CAL;SFV:NSPM;H:SATLEXMB04.amd.com;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(13230040)(82310400026)(1800799024)(7416014)(376014)(36860700013);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 15 May 2025 22:55:52.6352 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 40dce6be-e77a-4d29-c7e9-08dd9403a4c6 X-MS-Exchange-CrossTenant-Id: 3dd8961f-e488-4e60-8e11-a82d994e183d X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=3dd8961f-e488-4e60-8e11-a82d994e183d;Ip=[165.204.84.17];Helo=[SATLEXMB04.amd.com] X-MS-Exchange-CrossTenant-AuthSource: BN2PEPF000044A0.namprd02.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: CH2PR12MB4102 Content-Type: text/plain; charset="utf-8" Automatically assign or unassign counters when a resctrl group is created or deleted. By default, each group requires two counters: one for the MBM total event and one for the MBM local event. The mbm_cntr_assign mode offers "num_mbm_cntrs" number of counters that can be assigned to an RMID, event pair and monitor the bandwidth as long as it is assigned. If these counters are exhausted, the kernel will log the error message "Unable to allocate counter in domain" in /sys/fs/resctrl/info/last_cmd_status when a new group is created. However, the creation of a group should not fail due to assignment failures. Users have the flexibility to modify the assignments at a later time. Signed-off-by: Babu Moger --- v13: Changes due to calling of resctrl_assign_cntr_event() and resctrl_unas= sign_cntr_event(). It only takes evtid. evt_cfg is not required anymore. Resolved conflicts caused by the recent FS/ARCH code restructure. The monitor.c/rdtgroup.c files have been split between the FS and ARCH= directories. v12: Removed mbm_cntr_reset() as it is not required while removing the grou= p. Update the commit text. Added r->mon_capable check in rdtgroup_assign_cntrs() and rdtgroup_un= assign_cntrs. v11: Moved mbm_cntr_reset() to monitor.c. Added code reset non-architectural state in mbm_cntr_reset(). Added missing rdtgroup_unassign_cntrs() calls on failure path. v10: Assigned the counter before exposing the event files. Moved the call rdtgroup_assign_cntrs() inside mkdir_rdt_prepare_rmid_al= loc(). This is called both CNTR_MON and MON group creation. Call mbm_cntr_reset() when unmounted to clear all the assignments. Taken care of few other feedback comments. v9: Changed rdtgroup_assign_cntrs() and rdtgroup_unassign_cntrs() to return= void. Updated couple of rdtgroup_unassign_cntrs() calls properly. Updated function comments. v8: Renamed rdtgroup_assign_grp to rdtgroup_assign_cntrs. Renamed rdtgroup_unassign_grp to rdtgroup_unassign_cntrs. Fixed the problem with unassigning the child MON groups of CTRL_MON gro= up. v7: Reworded the commit message. Removed the reference of ABMC with mbm_cntr_assign. Renamed the function rdtgroup_assign_cntrs to rdtgroup_assign_grp. v6: Removed the redundant comments on all the calls of rdtgroup_assign_cntrs. Updated the commit message. Dropped printing error message on every call of rdtgroup_assign_cntrs. v5: Removed the code to enable/disable ABMC during the mount. That will be another patch. Added arch callers to get the arch specific data. Renamed fuctions to match the other abmc function. Added code comments for assignment failures. v4: Few name changes based on the upstream discussion. Commit message update. v3: This is a new patch. Patch addresses the upstream comment to enable ABMC feature by default if the feature is available. --- arch/x86/kernel/cpu/resctrl/monitor.c | 1 + fs/resctrl/rdtgroup.c | 65 ++++++++++++++++++++++++++- 2 files changed, 64 insertions(+), 2 deletions(-) diff --git a/arch/x86/kernel/cpu/resctrl/monitor.c b/arch/x86/kernel/cpu/re= sctrl/monitor.c index 36a03dae6d8e..c3e15f4de0b4 100644 --- a/arch/x86/kernel/cpu/resctrl/monitor.c +++ b/arch/x86/kernel/cpu/resctrl/monitor.c @@ -435,6 +435,7 @@ int __init rdt_get_mon_l3_config(struct rdt_resource *r) r->mon.mbm_cntr_assignable =3D true; cpuid_count(0x80000020, 5, &eax, &ebx, &ecx, &edx); r->mon.num_mbm_cntrs =3D (ebx & GENMASK(15, 0)) + 1; + r->mon.mbm_assign_on_mkdir =3D true; } =20 r->mon_capable =3D true; diff --git a/fs/resctrl/rdtgroup.c b/fs/resctrl/rdtgroup.c index 0093b323d858..931ea355f159 100644 --- a/fs/resctrl/rdtgroup.c +++ b/fs/resctrl/rdtgroup.c @@ -2946,6 +2946,49 @@ static void schemata_list_destroy(void) } } =20 +/* + * Called when a new group is created. If "mbm_cntr_assign" mode is enable= d, + * counters are automatically assigned. Each group can accommodate two cou= nters: + * one for the total event and one for the local event. Assignments may fa= il + * due to the limited number of counters. However, it is not necessary to = fail + * the group creation and thus no failure is returned. Users have the opti= on + * to modify the counter assignments after the group has been created. + */ +static void rdtgroup_assign_cntrs(struct rdtgroup *rdtgrp) +{ + struct rdt_resource *r =3D resctrl_arch_get_resource(RDT_RESOURCE_L3); + + if (!r->mon_capable) + return; + + if (resctrl_arch_mbm_cntr_assign_enabled(r) && !r->mon.mbm_assign_on_mkdi= r) + return; + + if (resctrl_arch_is_mbm_total_enabled()) + resctrl_assign_cntr_event(r, NULL, rdtgrp, QOS_L3_MBM_TOTAL_EVENT_ID); + + if (resctrl_arch_is_mbm_local_enabled()) + resctrl_assign_cntr_event(r, NULL, rdtgrp, QOS_L3_MBM_LOCAL_EVENT_ID); +} + +/* + * Called when a group is deleted. Counters are unassigned if it was in + * assigned state. + */ +static void rdtgroup_unassign_cntrs(struct rdtgroup *rdtgrp) +{ + struct rdt_resource *r =3D resctrl_arch_get_resource(RDT_RESOURCE_L3); + + if (!r->mon_capable || !resctrl_arch_mbm_cntr_assign_enabled(r)) + return; + + if (resctrl_arch_is_mbm_total_enabled()) + resctrl_unassign_cntr_event(r, NULL, rdtgrp, QOS_L3_MBM_TOTAL_EVENT_ID); + + if (resctrl_arch_is_mbm_local_enabled()) + resctrl_unassign_cntr_event(r, NULL, rdtgrp, QOS_L3_MBM_LOCAL_EVENT_ID); +} + static int rdt_get_tree(struct fs_context *fc) { struct rdt_fs_context *ctx =3D rdt_fc2context(fc); @@ -3002,6 +3045,8 @@ static int rdt_get_tree(struct fs_context *fc) if (ret < 0) goto out_info; =20 + rdtgroup_assign_cntrs(&rdtgroup_default); + ret =3D mkdir_mondata_all(rdtgroup_default.kn, &rdtgroup_default, &kn_mondata); if (ret < 0) @@ -3040,8 +3085,10 @@ static int rdt_get_tree(struct fs_context *fc) if (resctrl_arch_mon_capable()) kernfs_remove(kn_mondata); out_mongrp: - if (resctrl_arch_mon_capable()) + if (resctrl_arch_mon_capable()) { + rdtgroup_unassign_cntrs(&rdtgroup_default); kernfs_remove(kn_mongrp); + } out_info: kernfs_remove(kn_info); out_closid_exit: @@ -3187,6 +3234,7 @@ static void free_all_child_rdtgrp(struct rdtgroup *rd= tgrp) =20 head =3D &rdtgrp->mon.crdtgrp_list; list_for_each_entry_safe(sentry, stmp, head, mon.crdtgrp_list) { + rdtgroup_unassign_cntrs(sentry); free_rmid(sentry->closid, sentry->mon.rmid); list_del(&sentry->mon.crdtgrp_list); =20 @@ -3227,6 +3275,8 @@ static void rmdir_all_sub(void) cpumask_or(&rdtgroup_default.cpu_mask, &rdtgroup_default.cpu_mask, &rdtgrp->cpu_mask); =20 + rdtgroup_unassign_cntrs(rdtgrp); + free_rmid(rdtgrp->closid, rdtgrp->mon.rmid); =20 kernfs_remove(rdtgrp->kn); @@ -3311,6 +3361,7 @@ static void resctrl_fs_teardown(void) return; =20 rmdir_all_sub(); + rdtgroup_unassign_cntrs(&rdtgroup_default); mon_put_kn_priv(); rdt_pseudo_lock_release(); rdtgroup_default.mode =3D RDT_MODE_SHAREABLE; @@ -3792,9 +3843,12 @@ static int mkdir_rdt_prepare_rmid_alloc(struct rdtgr= oup *rdtgrp) } rdtgrp->mon.rmid =3D ret; =20 + rdtgroup_assign_cntrs(rdtgrp); + ret =3D mkdir_mondata_all(rdtgrp->kn, rdtgrp, &rdtgrp->mon.mon_data_kn); if (ret) { rdt_last_cmd_puts("kernfs subdir error\n"); + rdtgroup_unassign_cntrs(rdtgrp); free_rmid(rdtgrp->closid, rdtgrp->mon.rmid); return ret; } @@ -3804,8 +3858,10 @@ static int mkdir_rdt_prepare_rmid_alloc(struct rdtgr= oup *rdtgrp) =20 static void mkdir_rdt_prepare_rmid_free(struct rdtgroup *rgrp) { - if (resctrl_arch_mon_capable()) + if (resctrl_arch_mon_capable()) { + rdtgroup_unassign_cntrs(rgrp); free_rmid(rgrp->closid, rgrp->mon.rmid); + } } =20 /* @@ -4079,6 +4135,9 @@ static int rdtgroup_rmdir_mon(struct rdtgroup *rdtgrp= , cpumask_var_t tmpmask) update_closid_rmid(tmpmask, NULL); =20 rdtgrp->flags =3D RDT_DELETED; + + rdtgroup_unassign_cntrs(rdtgrp); + free_rmid(rdtgrp->closid, rdtgrp->mon.rmid); =20 /* @@ -4126,6 +4185,8 @@ static int rdtgroup_rmdir_ctrl(struct rdtgroup *rdtgr= p, cpumask_var_t tmpmask) cpumask_or(tmpmask, tmpmask, &rdtgrp->cpu_mask); update_closid_rmid(tmpmask, NULL); =20 + rdtgroup_unassign_cntrs(rdtgrp); + free_rmid(rdtgrp->closid, rdtgrp->mon.rmid); closid_free(rdtgrp->closid); =20 --=20 2.34.1 From nobody Sun Dec 14 02:00:56 2025 Received: from NAM10-MW2-obe.outbound.protection.outlook.com (mail-mw2nam10on2041.outbound.protection.outlook.com [40.107.94.41]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 2B7FF29713E; Thu, 15 May 2025 22:56:05 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.94.41 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1747349769; cv=fail; b=HL40Od/88eHidZ98Z3Fh4ixLLvGE4dfmIlNR9PhrIO2xfbLllWEl4T0fKam7zoRWvk1l/Ty1XwMp60MlCQA/49oNkRfRRovHVbg/DnZ/d4tdnarD+OLSqh06g1zXZq8MM7At7jIPoNGEKKnl2ZjSEVD6Ebc3Cwa/oxYdk441AOA= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1747349769; c=relaxed/simple; bh=NTCk/ZX/PVy0XQ+B8hP4/E/F2QM+0itpl3534IHwmlk=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=qCwL0r2mxEZZvXTA4R62Lsz/4Mpu8wnGPVK3AfjGcyJZucMOzrKlbNlH38G0n8YzameBOUazGYCJ9QOxXuXrhceKVDN8PzU9TI7GH0XHQnHEM3HKlzLDxnWl4/eYxO1Fp5snJyoHQzis1e7OWb7BOFRiO/TAjij/r/Bb4w7pZbY= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=amd.com; spf=fail smtp.mailfrom=amd.com; dkim=pass (1024-bit key) header.d=amd.com header.i=@amd.com header.b=xf/s2mpq; arc=fail smtp.client-ip=40.107.94.41 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=amd.com Authentication-Results: smtp.subspace.kernel.org; spf=fail smtp.mailfrom=amd.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=amd.com header.i=@amd.com header.b="xf/s2mpq" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=FzstsIt6kw6k71f0NUtho4RN3NtL/mUCMIVqv90EpGIhELk6Y0PutmB2YwUxAPVyf7lSU+hWwEbxQiA6g3yPaFYKBDcD0b0IgYzclPOC6vEOETqZgcsaysg5ZvWwYcGgc9n/7crPfr3qh/cGTJJ/OO4wx1ZCzAc9RD6lbAURdCiL1L4UvV7AV1xV4ovGEi+zP/wdabaf7iHP5MuYgQJd7zIangfGb/MgUWlZDrEgdLFuAMRkbOXBGup35cg00tshxA+SD2+7l986oVBG0BedhXihgpSWaGM4kFAP+QaKG/zqVU56OJCU9qWWzmor1DBg1hlEFSuqGIlkdJBSTxz71w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=91zfi6scmr2sYG7Qh0rO829+LHKmLcoGpQix9O5mqQc=; b=LFkjfQSYEh9HnJiF7pcsky9iccg47KXCJX0jha9yZO5NsPhEUpIhrqJ/4FtgWLuEjn+XiNzh5Vmjdx9tdI0hk1XAUxWdRd2U6751ir6b2bzD+yXyRvCCQEd8omHkKxmrB1aysHbbLFLD9mgUONfAndx/JZb6tsJzbYDvYy+IskR4ppLF6AjtIzlzVuw7C9VYHMaOJ8deC/OtFWO1m6BExXs/qaETsZwf9qUj/uy+huF4/FYu4+Mpimt0W6rknGOBBp2t9LR3Sy6I6mfwgkK5au3OmzoESLX4RNOg+s++b7N603H96bfSkT1+fFcdqApPQPy6af1TQJwLV8/uPbkyFA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=lwn.net smtp.mailfrom=amd.com; dmarc=pass (p=quarantine sp=quarantine pct=100) action=none header.from=amd.com; dkim=none (message not signed); arc=none (0) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amd.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=91zfi6scmr2sYG7Qh0rO829+LHKmLcoGpQix9O5mqQc=; b=xf/s2mpqwpqYN5cMZhg3s15vIKYeqkOJM56N8Zx8pqFTYpShxgJQz4BsCT4mJ0ZIOM80fHWq7USp+u9rnFltSlmlsQkd3UFOI6xNB0RluRP8H3M6M/Ek/ZPK6LMqk1ehPAHBArS/hvfqXSdUqFFfxzOLqVwFFwszJPLiQQny1KU= Received: from BN9PR03CA0266.namprd03.prod.outlook.com (2603:10b6:408:ff::31) by CY8PR12MB8196.namprd12.prod.outlook.com (2603:10b6:930:78::17) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8722.30; Thu, 15 May 2025 22:56:02 +0000 Received: from BN2PEPF0000449F.namprd02.prod.outlook.com (2603:10b6:408:ff:cafe::2e) by BN9PR03CA0266.outlook.office365.com (2603:10b6:408:ff::31) with Microsoft SMTP Server (version=TLS1_3, cipher=TLS_AES_256_GCM_SHA384) id 15.20.8699.33 via Frontend Transport; Thu, 15 May 2025 22:56:02 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 165.204.84.17) smtp.mailfrom=amd.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=amd.com; Received-SPF: Pass (protection.outlook.com: domain of amd.com designates 165.204.84.17 as permitted sender) receiver=protection.outlook.com; client-ip=165.204.84.17; helo=SATLEXMB04.amd.com; pr=C Received: from SATLEXMB04.amd.com (165.204.84.17) by BN2PEPF0000449F.mail.protection.outlook.com (10.167.243.150) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.8722.18 via Frontend Transport; Thu, 15 May 2025 22:56:02 +0000 Received: from bmoger-ubuntu.amd.com (10.180.168.240) by SATLEXMB04.amd.com (10.181.40.145) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.39; Thu, 15 May 2025 17:55:59 -0500 From: Babu Moger To: , , , , , , CC: , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , Subject: [PATCH v13 23/27] x86/resctrl: Introduce mbm_L3_assignments to list assignments in a group Date: Thu, 15 May 2025 17:52:08 -0500 Message-ID: X-Mailer: git-send-email 2.34.1 In-Reply-To: References: Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-ClientProxiedBy: SATLEXMB04.amd.com (10.181.40.145) To SATLEXMB04.amd.com (10.181.40.145) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: BN2PEPF0000449F:EE_|CY8PR12MB8196:EE_ X-MS-Office365-Filtering-Correlation-Id: 420514d5-1e9e-48ed-f856-08dd9403aa6a X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|82310400026|36860700013|1800799024|7416014|376014|13003099007; X-Microsoft-Antispam-Message-Info: =?us-ascii?Q?VoFCDcTU1advnQ7Fk2B7DTYvmI4qb2fj/tC+rzzZObdT2zSxNl9JNl6KTMH7?= =?us-ascii?Q?zjGX7ycpIDUxqpAaBjzGPTeoWiGX0TO1dtpWDbhBZU1oVYrF5x9lZk2UQJGo?= =?us-ascii?Q?XaiBgpt1TWyE8Dc+tIi5Fvcdsx5EqN6CBxBrBB6s7HeDQ/FpgRLVSb2KpKI0?= =?us-ascii?Q?LL3knkI0wtfdhPTuw8Wjb7puEz8VQwdVhaCC/8iOZHPyregJO9HFSrpN3YyD?= =?us-ascii?Q?uvmJmcNroBMirxORr9FzxY/0DHOII8RZpi9/MUy28l1arQtXd6vzLJlwbP6S?= =?us-ascii?Q?HQe4PIAtdA3wPCON+As0voLdEGevGri3F4s9fwAqDyDlxdkXeKXThsENDR7D?= =?us-ascii?Q?ed2iOcGewfTH2FiNq7JimelO1YXHC3hh+XmLi960KqlRy6/zN+Iy+0GWHb+L?= =?us-ascii?Q?F/KIls++sVbI8rLtg174Vq4OfzBgwlVtCKbFFDOxi4WG9YxESO/ZnfYDktdL?= =?us-ascii?Q?pByHz2WArxlzlkNT78RyuMFyVoVBshNfqiznyi2QSZGOBenbSVGxDftMiQ6F?= =?us-ascii?Q?9vYa6QtJseIRIaeYE0d7QOGLN4iq4BbKQWQ6zJYbrth6pWzO2cqP6MZ9kmyU?= =?us-ascii?Q?qHyy6zlORK3IGTxv4tmjP8ywhh7lNIXES+bkF6fKH9TRoMiSSeavEYPj9u4G?= =?us-ascii?Q?WnOkcsnr1eSeTklumyHVLdepnDZAQDOCt3NXF3EcthfLgtAF0qgzjS/mmmZA?= =?us-ascii?Q?DpNH0Aa6BZR+s/DlX43gT9dLCF5deIt86URHiKKWt0T9IXpjvfMJGN9otF70?= =?us-ascii?Q?fur9wQImzwfk/R23VGMX8OBo9aZzRmQbY+yd2QFShuG31vyV7YoT3PkwgL2L?= =?us-ascii?Q?YKkBFuBYaMM3HCT6/B2sZrEYDoruHtAFYB9OLx2EwJJqKY4EeJgf8Wqc0Rtg?= =?us-ascii?Q?zo0N/P8rf5HRTkH1egKhG4DbxquFdu0wlSSy7aGyW5pg8l+JR1TI6isNMyaO?= =?us-ascii?Q?D92vIhwjYatgCZEosMnJondK3hJGPsiKOBxraj6fBx9T70oc1HAi8uELlc/M?= =?us-ascii?Q?SqUCKhGuBQf6rMPiICfYER7D6dQioDs+Cuda3dhmn17ZuO7YdAoSGxo5UzDe?= =?us-ascii?Q?E0cu1QAKAa0UZ1ffIBp+Vkm3HwNww08UuO98uKDkCSlgPenMhxgKG2wD1bxd?= =?us-ascii?Q?1yrKTonWMsFGvjxqYgW7+jDfqvO/TibnvTRDs6djXJ/iauXBjc1v60kGfbo+?= =?us-ascii?Q?XIGjfk5/82ITErBZAVcF2UnCl1vc/X3wPuuVh3W2JiP+5lZizVg+PtAR/nEn?= =?us-ascii?Q?WCb+CdMlpKDegZSilCL7xjcYY+55S4jsQWR05G36dAe9j49fOjH4DaZpaeUQ?= =?us-ascii?Q?2q/gAbjl6oKgYyeiPxugMTANzuBPm0l1hBDi64r6RxMN/SKKkiGoU/oOrWix?= =?us-ascii?Q?2DA2YF/CEgQXImpr+Qsy07vhPH7cv/BiVIQAOmGjgc392NR/wtixfnHGdDyd?= =?us-ascii?Q?N5IiGSoqT4IQce6sifM6I3XUEcKUf0M4MG6+OtxvFZcZhtOz0bdGqA=3D=3D?= X-Forefront-Antispam-Report: CIP:165.204.84.17;CTRY:US;LANG:en;SCL:1;SRV:;IPV:CAL;SFV:NSPM;H:SATLEXMB04.amd.com;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(13230040)(82310400026)(36860700013)(1800799024)(7416014)(376014)(13003099007);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 15 May 2025 22:56:02.1000 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 420514d5-1e9e-48ed-f856-08dd9403aa6a X-MS-Exchange-CrossTenant-Id: 3dd8961f-e488-4e60-8e11-a82d994e183d X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=3dd8961f-e488-4e60-8e11-a82d994e183d;Ip=[165.204.84.17];Helo=[SATLEXMB04.amd.com] X-MS-Exchange-CrossTenant-AuthSource: BN2PEPF0000449F.namprd02.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: CY8PR12MB8196 Content-Type: text/plain; charset="utf-8" Introduce the interface to display the assignment states for each group when mbm_cntr_assign mode is enabled. The list is displayed in the following format: :=3D Event configuration: A valid event configuration listed in the /sys/fs/resctrl/info/L3_MON/counter_configs directory. Domain ID: A valid domain ID number. The assignment type can be one of the following: _ : No event configuration assigned e : Event configuration assigned in exclusive mode Example: $cd /sys/fs/resctrl $cat mbm_L3_assignments mbm_total_bytes:0=3De;1=3De mbm_local_bytes:0=3De;1=3De Signed-off-by: Babu Moger --- v13: Changelog update. Few changes in mbm_L3_assignments_show() after moving the event config= to evt_list. Resolved conflicts caused by the recent FS/ARCH code restructure. The rdtgroup.c/monitor.c files have been split between the FS and ARCH= directories. v12: New patch: Assignment interface moved inside the group based the discussion https://lore.kernel.org/lkml/CALPaoCiii0vXOF06mfV=3DkVLBzhfNo0SFqt4kQG= wGSGVUqvr2Dg@mail.gmail.com/#t --- Documentation/filesystems/resctrl.rst | 28 +++++++++++++++ fs/resctrl/monitor.c | 1 + fs/resctrl/rdtgroup.c | 52 +++++++++++++++++++++++++++ 3 files changed, 81 insertions(+) diff --git a/Documentation/filesystems/resctrl.rst b/Documentation/filesyst= ems/resctrl.rst index 356f1f918a86..2350c1f21f4e 100644 --- a/Documentation/filesystems/resctrl.rst +++ b/Documentation/filesystems/resctrl.rst @@ -504,6 +504,34 @@ When the "mba_MBps" mount option is used all CTRL_MON = groups will also contain: /sys/fs/resctrl/info/L3_MON/mon_features changes the input event. =20 +"mbm_L3_assignments": + This interface file is created when the mbm_cntr_assign mode is supported + and shows the assignment status for each group. + + The assignment list is displayed in the following format: + + :=3D + + Event configuration: A valid event configuration listed in the + /sys/fs/resctrl/info/L3_MON/counter_configs directory. + + Domain ID: A valid domain ID number. + + Assignment types: + + _ : No event configuration assigned + + e : Event configuration assigned in exclusive mode + + Example: + To list the assignment states for the default group. + :: + + # cd /sys/fs/resctrl + # cat mbm_L3_assignments + mbm_total_bytes:0=3De;1=3De + mbm_local_bytes:0=3De;1=3De + Resource allocation rules ------------------------- =20 diff --git a/fs/resctrl/monitor.c b/fs/resctrl/monitor.c index 5f6c4b662f3b..b982540ce4e3 100644 --- a/fs/resctrl/monitor.c +++ b/fs/resctrl/monitor.c @@ -935,6 +935,7 @@ int resctrl_mon_resource_init(void) resctrl_file_fflags_init("event_filter", RFTYPE_ASSIGN_CONFIG); resctrl_file_fflags_init("mbm_assign_on_mkdir", RFTYPE_MON_INFO | RFTYPE_RES_CACHE); + resctrl_file_fflags_init("mbm_L3_assignments", RFTYPE_MON_BASE); } =20 return 0; diff --git a/fs/resctrl/rdtgroup.c b/fs/resctrl/rdtgroup.c index 931ea355f159..8d970b99bbbd 100644 --- a/fs/resctrl/rdtgroup.c +++ b/fs/resctrl/rdtgroup.c @@ -2080,6 +2080,52 @@ static ssize_t resctrl_mbm_assign_on_mkdir_write(str= uct kernfs_open_file *of, return ret ?: nbytes; } =20 +static int mbm_L3_assignments_show(struct kernfs_open_file *of, struct seq= _file *s, void *v) +{ + struct rdt_resource *r =3D resctrl_arch_get_resource(RDT_RESOURCE_L3); + struct rdt_mon_domain *d; + struct rdtgroup *rdtgrp; + struct mon_evt *mevt; + int ret =3D 0; + bool sep; + + rdtgrp =3D rdtgroup_kn_lock_live(of->kn); + if (!rdtgrp) + return -ENOENT; + + rdt_last_cmd_clear(); + if (!resctrl_arch_mbm_cntr_assign_enabled(r)) { + rdt_last_cmd_puts("mbm_cntr_assign mode not enabled\n"); + ret =3D -ENOENT; + goto assign_out; + } + + list_for_each_entry(mevt, &r->mon.evt_list, list) { + if (mevt->mbm_mode !=3D MBM_MODE_ASSIGN) + continue; + + sep =3D false; + seq_printf(s, "%s:", mevt->name); + list_for_each_entry(d, &r->mon_domains, hdr.list) { + if (sep) + seq_putc(s, ';'); + + if (mbm_cntr_get(r, d, rdtgrp, mevt->evtid) >=3D 0) + seq_printf(s, "%d=3De", d->hdr.id); + else + seq_printf(s, "%d=3D_", d->hdr.id); + + sep =3D true; + } + seq_putc(s, '\n'); + } + +assign_out: + rdtgroup_kn_unlock(of->kn); + + return ret; +} + /* rdtgroup information files for one cache resource. */ static struct rftype res_common_files[] =3D { { @@ -2218,6 +2264,12 @@ static struct rftype res_common_files[] =3D { .seq_show =3D event_filter_show, .write =3D event_filter_write, }, + { + .name =3D "mbm_L3_assignments", + .mode =3D 0444, + .kf_ops =3D &rdtgroup_kf_single_ops, + .seq_show =3D mbm_L3_assignments_show, + }, { .name =3D "mbm_assign_mode", .mode =3D 0444, --=20 2.34.1 From nobody Sun Dec 14 02:00:56 2025 Received: from NAM04-BN8-obe.outbound.protection.outlook.com (mail-bn8nam04on2054.outbound.protection.outlook.com [40.107.100.54]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id DF593295519; Thu, 15 May 2025 22:56:19 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.100.54 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1747349781; cv=fail; b=M7+pXJr1rBYmCbD4xlWLtGmhUEWk519DOwteRQPFrzb1/miTWjwG8Z0kliGuZZpqRTnJ6GKQq9T23GxL/AMwXkyaIsGCGADXUFK2zSoV9uXYFe6dNG6D6Mr/7KdFPqeDSDQLTehwjgI4Y5rXA4iz46/sS5e1J21uDyNTiNVAZb8= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1747349781; c=relaxed/simple; bh=lQyjcmoj21lBZzdastJ94nMUCki0qUcdZHQbvtz5iDA=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=TbvQwP0/q+HLnFNZbDHIsr6PYig8w1PuvoEDtMDzCzbz0BlT4FZv1PDrfkIVhKMG8E1m0EfIxXfiVPzvr4q6icPyBbQnfXDVqoQSuX6EIIR4KkwuaOLookaHhgoKb0dME4F0OO+21eL0sfhd3fJUbSG615pYP+/tFgPTS53Pfhw= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=amd.com; spf=fail smtp.mailfrom=amd.com; dkim=pass (1024-bit key) header.d=amd.com header.i=@amd.com header.b=kgS1Teff; arc=fail smtp.client-ip=40.107.100.54 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=amd.com Authentication-Results: smtp.subspace.kernel.org; spf=fail smtp.mailfrom=amd.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=amd.com header.i=@amd.com header.b="kgS1Teff" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=PMJgXgZMPjlQ/Saq3oR2/fpIs8Hl/YYUgbkNtmgFxFH7BwUwW82wtqMLsCGDVW0eCj9mwSeBCBqJzkr0zshlgGYRxZYGP08ZGLOs6O7R8sJHv1aTEMWCkt6b0vHA9VCQHJGNOIf5EAAXx0GZggL1cM5HxgSe/GRNn4BKri8axHZiUjK0lbu7GyBsBtNuO9UXvRc4p5DkDPeU7xPy+qCboMor28Afaz1ldXQyz/jIy4ab2OT6XFR4TGBYtltKqggoGLg7CGYT2ZF2dv5RF+siuDOU9RdT5GaOn21p3m82PzN+LEjHFA8iGAjXOWTJK4HJWmNLNODwg2fxbNHtb57XEA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=9MmI2b7kpFbxaTZNizGaoCZ88FSLLVf2EzwL0yH7JRY=; b=PHeOiKn1rK5ELl+l66HnV1oszRAypONNvPe0kp2miInM+BirQ/FJsM1/czebw24ZtfYJIeA4holsgIWRXSYa0pviiqq+UMJnCuQuf9+3iQziyc+l/gQygqz6RR80KJu4tbtf6uE6vyRPp9TWOPmFJ4GTOiGKl875Oz0jzrkm58by4bUrodZFATtCZucQOLRxzHpklnOOLBflLFQe9ZnwMDV/+9CLLR75MH87bAIp5zf6NzFicEPEqM1TWSqJXjB4Et07k5QNqz0+tG0WW4R9zSYOsoICAXTlEloukNGFgL17q49xODyjSti1gm8unK6kg3bzRZUSXmuNQtN5rIV3DA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=lwn.net smtp.mailfrom=amd.com; dmarc=pass (p=quarantine sp=quarantine pct=100) action=none header.from=amd.com; dkim=none (message not signed); arc=none (0) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amd.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=9MmI2b7kpFbxaTZNizGaoCZ88FSLLVf2EzwL0yH7JRY=; b=kgS1TeffOsYh46KXfaxKmuWCCH7hF3QuOwYuSFSFVVeT1gIHe7enrWuG3iwumCnwxhm/p4285WAG00dfpki/zNr+TiUcH02xEenHR/GToeGTsRGV+btwwcK5Xnz7g81s9gGPClUzv1ifD/EUPTSJR2PXfm7S+utZt/9q5qruxk4= Received: from BN7PR06CA0071.namprd06.prod.outlook.com (2603:10b6:408:34::48) by IA1PR12MB9531.namprd12.prod.outlook.com (2603:10b6:208:596::8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8722.24; Thu, 15 May 2025 22:56:12 +0000 Received: from BN2PEPF000044A4.namprd02.prod.outlook.com (2603:10b6:408:34:cafe::c3) by BN7PR06CA0071.outlook.office365.com (2603:10b6:408:34::48) with Microsoft SMTP Server (version=TLS1_3, cipher=TLS_AES_256_GCM_SHA384) id 15.20.8722.20 via Frontend Transport; Thu, 15 May 2025 22:56:12 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 165.204.84.17) smtp.mailfrom=amd.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=amd.com; Received-SPF: Pass (protection.outlook.com: domain of amd.com designates 165.204.84.17 as permitted sender) receiver=protection.outlook.com; client-ip=165.204.84.17; helo=SATLEXMB04.amd.com; pr=C Received: from SATLEXMB04.amd.com (165.204.84.17) by BN2PEPF000044A4.mail.protection.outlook.com (10.167.243.155) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.8722.18 via Frontend Transport; Thu, 15 May 2025 22:56:12 +0000 Received: from bmoger-ubuntu.amd.com (10.180.168.240) by SATLEXMB04.amd.com (10.181.40.145) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.39; Thu, 15 May 2025 17:56:08 -0500 From: Babu Moger To: , , , , , , CC: , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , Subject: [PATCH v13 24/27] x86/resctrl: Introduce the interface to modify assignments in a group Date: Thu, 15 May 2025 17:52:09 -0500 Message-ID: <6a2cdedc0b2bf7e3da82d453b0104b46a2e85529.1747349530.git.babu.moger@amd.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: References: 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 X-ClientProxiedBy: SATLEXMB04.amd.com (10.181.40.145) To SATLEXMB04.amd.com (10.181.40.145) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: BN2PEPF000044A4:EE_|IA1PR12MB9531:EE_ X-MS-Office365-Filtering-Correlation-Id: 03867ef2-9e2a-441d-6bec-08dd9403b06e X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|82310400026|36860700013|7416014|376014|1800799024|13003099007; X-Microsoft-Antispam-Message-Info: =?utf-8?B?cnVweUZiem9mdjVhRXBjSVlaNGpMMnpmS1h1eUNvc2Z5aDlXS1dBZDRMQ3lJ?= =?utf-8?B?UVhhdDh6Y1JKcGw5aVBzWHNCUkQrK2JmKzc2SFV4OEgwRXAxYzlibzdJNTBj?= =?utf-8?B?N2FOTVhpeWR1S3ZwbUFNT2M0UEhsZStrWWtYT1ZucTZxeTA4Y2NwOFc4NHZN?= =?utf-8?B?RzcxTzhlb0IrTUcvOWZuS0hGUkJBb1NRRThHK3BJczVJM1YydkJ1YURTTFYv?= =?utf-8?B?QnBaRk5tUnMrMFdIeWhaMFI2N0t0SDk1dDVhakJNQks3eU9kTktpckFvUG9q?= =?utf-8?B?cWR0dTRFRGZaS1lVQnNjWlh4UjZJdHdLSzlNTUR2YVh2L2lYU3JsU3VlMG9F?= =?utf-8?B?ZkpDNVAzV0hpTVpkQ2JVZDgrTmo5ajNGbk5ldk9NQTlyRU11YTJOSmtySkp0?= =?utf-8?B?Nk9FenU4bzJJQTRMdnEwckttTDZ3ZnlUb0NraEIxNHVPZ1JFN1AvbE9CUjZG?= =?utf-8?B?RjlYaHMwZU5GNlBlazdlelRpU1hxajJHdjh4UGdpdWlYbURJTUM0QS9OMnA0?= =?utf-8?B?SEN5dnJjYis2THB2RmplQkh6SjZlS3VnY1Z5ZGlMWTVZQ1VXd2NOQU9hdVdx?= =?utf-8?B?U2NtVDl6S1YxTE1tK3BHUWVpbWMyVEZjVVZ2dzl5WW8xNnFjT0FiOS9BRjF4?= =?utf-8?B?RFhYTDhoZUJFUzU3dXhidmJkaDVCdlg0aHVZeHd1bGZGUmpiek9BOEx6ZGp6?= =?utf-8?B?NVpGWHRtcmxWNmEydWxGVFA5enI1TWtvSTVCdlRTb1pEaUdmbTRkN0hJN25s?= =?utf-8?B?ZGZYRTlUSDJsaWpxeU8yRDNySkRrMFBMV3ozMFpiS2dGRU1yZzN5VmpoL0lw?= =?utf-8?B?ZStvR0xmWFR6UnZLRFVQZTFiUmR3cklpWHRENE5NK3pyUWlnejhvdzZwYlJO?= =?utf-8?B?YWk3RmY0TzAxSXdDdW45TUVndW4wVWgwMDJ1Z29hVmxySlIxNkh4aHlDcXAx?= =?utf-8?B?T0YyVkRsR1B2bEtQckpQSzk0cFA4SVdlVHZNRHlmaVY4UW0xNnZwdEQyaU84?= =?utf-8?B?YnVmSkdzYTRMZ0VZY3plL1hxcmxFMXA0VVVPQkZzNXpzdEpPMzRMMGRwSU15?= =?utf-8?B?RjE4UkNvbUdWVlYxYjBOdDhFUWxWa2ZWdmdHT1ZTMUxPUlV6VGF3bXNRdmFm?= =?utf-8?B?b3MrK3lhanBySW8xN3E3Nzd0WU9UOG5vSVMxZWxBYzAzeXZ4ZHlxdS91dVo4?= =?utf-8?B?azBTa05obkNUZEJNb0NKSlI4TEpvVmtHbVlWejJMbFJORngyamtSY2FUVkEz?= =?utf-8?B?cFM3aXF1dnJlR1A2Z1BqdXdZVXpocDRLTUNTWWNDNVFuVUxzMWQrclVFT1F4?= =?utf-8?B?UUNyNHBOUWIwMlRXWHBXRlc0WkZiekdFaXBPZld4SHppNVE1WWxWaGRRMGIv?= =?utf-8?B?UHJFSHVWVXdPeGpVNEFkeGZMREEwa21vT0Z3blh0VjFiVzhRRnYwcjVHTmQx?= =?utf-8?B?bCs1eTNybi9TWU9SMnhjZFF3Y3RBNGNPY1VvazFXVU1kZ2RLOUg0WmI2YW40?= =?utf-8?B?dGtiTEIxYlJyb1VzRWIxa3lXeTdzVTNSdWpPczRzajZwQ3oxRkJDNzY3RWU5?= =?utf-8?B?cVJyQnlnQWljeVNXL21WRmJmbFBJSnpjV1VLdXlrSHQ2MXpMdHVKVnhMelNT?= =?utf-8?B?UEozbHd6YUR6bTRzUkExZkI0aEtyQ0FGMkNGeE53OFRtbjMramRYZmdRek5F?= =?utf-8?B?elhJYXE4QWZMeXMydTI2WWhYYUFWZ0JOODMzUDJ3ZzhEZ1B0UjdFc3V1N0p6?= =?utf-8?B?YVkzSnF0YzRCTG1nYXRrRHp6Tmg4cUhrWkQvTmtrRWFUUnRMTjA3Uis0cnFZ?= =?utf-8?B?TGNoNlFoYlRIT1c3a003MGdRNVBzQVlJSVpHakFObUFQWHZ1cVVTbG5rdDhG?= =?utf-8?B?R0pDM0Y4bXR4eFp4bjJDd0llOXo5L0hERkszSjZrVGVQUW1PRElzdjUvZzJ3?= =?utf-8?B?aE52ZWc0YUtVemwyNHFWZzllM1d0UkM1NTV0MW52ZVN0TnhmZEsvZnc1Y2Rh?= =?utf-8?B?bVdMcUZaMUlnPT0=?= X-Forefront-Antispam-Report: CIP:165.204.84.17;CTRY:US;LANG:en;SCL:1;SRV:;IPV:CAL;SFV:NSPM;H:SATLEXMB04.amd.com;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(13230040)(82310400026)(36860700013)(7416014)(376014)(1800799024)(13003099007);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 15 May 2025 22:56:12.1884 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 03867ef2-9e2a-441d-6bec-08dd9403b06e X-MS-Exchange-CrossTenant-Id: 3dd8961f-e488-4e60-8e11-a82d994e183d X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=3dd8961f-e488-4e60-8e11-a82d994e183d;Ip=[165.204.84.17];Helo=[SATLEXMB04.amd.com] X-MS-Exchange-CrossTenant-AuthSource: BN2PEPF000044A4.namprd02.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: IA1PR12MB9531 Introduce an interface to modify assignments within a group. Modifications follow this format: :=3D The assignment type can be one of the following: _ : No event configuration assigned e : Event configuration assigned in exclusive mode Domain id can be any valid domain ID number or '*' to update all the domains. Example: $cd /sys/fs/resctrl $cat mbm_L3_assignments mbm_total_bytes:0=3De;1=3De mbm_local_bytes:0=3De;1=3De To unassign the configuration of mbm_total_bytes on domain 0: $echo "mbm_total_bytes:0=3D_" > mbm_L3_assignments $cat mbm_L3_assignments mbm_total_bytes:0=3D_;1=3De mbm_local_bytes:0=3De;1=3De To unassign the mbm_total_bytes configuration on all domains: $echo "mbm_total_bytes:*=3D_" > mbm_L3_assignments $cat mbm_L3_assignments mbm_total_bytes:0=3D_;1=3D_ mbm_local_bytes:0=3De;1=3De Signed-off-by: Babu Moger --- v13: Few changes in mbm_L3_assignments_write() after moving the event confi= g to evt_list. Resolved conflicts caused by the recent FS/ARCH code restructure. v12: New patch: Assignment interface moved inside the group based the discussion https://lore.kernel.org/lkml/CALPaoCiii0vXOF06mfV=3DkVLBzhfNo0SFqt4kQG= wGSGVUqvr2Dg@mail.gmail.com/#t --- Documentation/filesystems/resctrl.rst | 29 ++++- fs/resctrl/internal.h | 9 ++ fs/resctrl/rdtgroup.c | 165 +++++++++++++++++++++++++- 3 files changed, 201 insertions(+), 2 deletions(-) diff --git a/Documentation/filesystems/resctrl.rst b/Documentation/filesyst= ems/resctrl.rst index 2350c1f21f4e..d779554a2f91 100644 --- a/Documentation/filesystems/resctrl.rst +++ b/Documentation/filesystems/resctrl.rst @@ -515,7 +515,7 @@ When the "mba_MBps" mount option is used all CTRL_MON g= roups will also contain: Event configuration: A valid event configuration listed in the /sys/fs/resctrl/info/L3_MON/counter_configs directory. =20 - Domain ID: A valid domain ID number. + Domain ID: A valid domain ID number or '*' to update all the domains. =20 Assignment types: =20 @@ -532,6 +532,33 @@ When the "mba_MBps" mount option is used all CTRL_MON = groups will also contain: mbm_total_bytes:0=3De;1=3De mbm_local_bytes:0=3De;1=3De =20 + Modify the assignment states by writing to the interface file. + + Example: + To unassign the configuration of mbm_total_bytes on domain 0: + :: + + # echo "mbm_total_bytes:0=3D_" > mbm_L3_assignments + # cat mbm_L3_assignments + mbm_total_bytes:0=3D_;1=3De + mbm_local_bytes:0=3De;1=3De + + To unassign the mbm_total_bytes configuration on all domains: + :: + + # echo "mbm_total_bytes:*=3D_" > mbm_L3_assignments + # cat mbm_L3_assignments + mbm_total_bytes:0=3D_;1=3D_ + mbm_local_bytes:0=3De;1=3De + + To assign the mbm_total_bytes configuration on all domains in exclusive m= ode: + :: + + # echo "mbm_total_bytes:*=3De" > mbm_L3_assignments + # cat mbm_L3_assignments + mbm_total_bytes:0=3De;1=3De + mbm_local_bytes:0=3De;1=3De + Resource allocation rules ------------------------- =20 diff --git a/fs/resctrl/internal.h b/fs/resctrl/internal.h index 446cc9cc61df..a6069a5dfd49 100644 --- a/fs/resctrl/internal.h +++ b/fs/resctrl/internal.h @@ -51,6 +51,15 @@ static inline struct rdt_fs_context *rdt_fc2context(stru= ct fs_context *fc) return container_of(kfc, struct rdt_fs_context, kfc); } =20 +/* + * Assignment types for mbm_cntr_assign mode + */ +enum { + ASSIGN_NONE =3D 0, + ASSIGN_EXCLUSIVE, + ASSIGN_INVALID, +}; + /** * struct mon_evt - Entry in the event list of a resource * @evtid: event id diff --git a/fs/resctrl/rdtgroup.c b/fs/resctrl/rdtgroup.c index 8d970b99bbbd..ea1782723f81 100644 --- a/fs/resctrl/rdtgroup.c +++ b/fs/resctrl/rdtgroup.c @@ -2126,6 +2126,168 @@ static int mbm_L3_assignments_show(struct kernfs_op= en_file *of, struct seq_file return ret; } =20 +/* + * mbm_get_mon_event_by_name() - Return the mon_evt entry for the matching + * event name. + */ +static struct mon_evt *mbm_get_mon_event_by_name(struct rdt_resource *r, + char *name) +{ + struct mon_evt *mevt; + + list_for_each_entry(mevt, &r->mon.evt_list, list) { + if (!strcmp(mevt->name, name)) + return mevt; + } + + return NULL; +} + +static unsigned int resctrl_get_assing_type(char *assign) +{ + unsigned int mon_state =3D ASSIGN_NONE; + int len =3D strlen(assign); + + if (!len || len > 1) + return ASSIGN_INVALID; + + switch (*assign) { + case 'e': + mon_state =3D ASSIGN_EXCLUSIVE; + break; + case '_': + mon_state =3D ASSIGN_NONE; + break; + default: + mon_state =3D ASSIGN_INVALID; + break; + } + + return mon_state; +} + +static int resctrl_process_assign(struct rdt_resource *r, struct rdtgroup = *rdtgrp, + char *config, char *tok) +{ + struct rdt_mon_domain *d; + char *dom_str, *id_str; + unsigned long dom_id =3D 0; + struct mon_evt *mevt; + int assign_type; + char domain[10]; + bool found; + int ret; + + mevt =3D mbm_get_mon_event_by_name(r, config); + if (!mevt) { + rdt_last_cmd_printf("Invalid assign configuration %s\n", config); + return -ENOENT; + } + +next: + if (!tok || tok[0] =3D=3D '\0') + return 0; + + /* Start processing the strings for each domain */ + dom_str =3D strim(strsep(&tok, ";")); + + id_str =3D strsep(&dom_str, "=3D"); + + /* Check for domain id '*' which means all domains */ + if (id_str && *id_str =3D=3D '*') { + d =3D NULL; + goto check_state; + } else if (!id_str || kstrtoul(id_str, 10, &dom_id)) { + rdt_last_cmd_puts("Missing domain id\n"); + return -EINVAL; + } + + /* Verify if the dom_id is valid */ + found =3D false; + list_for_each_entry(d, &r->mon_domains, hdr.list) { + if (d->hdr.id =3D=3D dom_id) { + found =3D true; + break; + } + } + + if (!found) { + rdt_last_cmd_printf("Invalid domain id %ld\n", dom_id); + return -EINVAL; + } + +check_state: + assign_type =3D resctrl_get_assing_type(dom_str); + + switch (assign_type) { + case ASSIGN_NONE: + ret =3D resctrl_unassign_cntr_event(r, d, rdtgrp, mevt->evtid); + break; + case ASSIGN_EXCLUSIVE: + ret =3D resctrl_assign_cntr_event(r, d, rdtgrp, mevt->evtid); + break; + case ASSIGN_INVALID: + ret =3D -EINVAL; + } + + if (ret) + goto out_fail; + + goto next; + +out_fail: + sprintf(domain, d ? "%ld" : "*", dom_id); + + rdt_last_cmd_printf("Assign operation '%s:%s=3D%s' failed\n", config, dom= ain, dom_str); + + return ret; +} + +static ssize_t mbm_L3_assignments_write(struct kernfs_open_file *of, char = *buf, + size_t nbytes, loff_t off) +{ + struct rdt_resource *r =3D resctrl_arch_get_resource(RDT_RESOURCE_L3); + struct rdtgroup *rdtgrp; + char *token, *config; + int ret =3D 0; + + /* Valid input requires a trailing newline */ + if (nbytes =3D=3D 0 || buf[nbytes - 1] !=3D '\n') + return -EINVAL; + + buf[nbytes - 1] =3D '\0'; + + rdtgrp =3D rdtgroup_kn_lock_live(of->kn); + if (!rdtgrp) { + rdtgroup_kn_unlock(of->kn); + return -ENOENT; + } + rdt_last_cmd_clear(); + + if (!resctrl_arch_mbm_cntr_assign_enabled(r)) { + rdt_last_cmd_puts("mbm_cntr_assign mode is not enabled\n"); + rdtgroup_kn_unlock(of->kn); + return -EINVAL; + } + + while ((token =3D strsep(&buf, "\n")) !=3D NULL) { + /* + * The write command follows the following format: + * =E2=80=9C:=3D=E2=80=9D + * Extract Assign config first. + */ + config =3D strsep(&token, ":"); + + ret =3D resctrl_process_assign(r, rdtgrp, config, token); + if (ret) + break; + } + + rdtgroup_kn_unlock(of->kn); + + return ret ?: nbytes; +} + /* rdtgroup information files for one cache resource. */ static struct rftype res_common_files[] =3D { { @@ -2266,9 +2428,10 @@ static struct rftype res_common_files[] =3D { }, { .name =3D "mbm_L3_assignments", - .mode =3D 0444, + .mode =3D 0644, .kf_ops =3D &rdtgroup_kf_single_ops, .seq_show =3D mbm_L3_assignments_show, + .write =3D mbm_L3_assignments_write, }, { .name =3D "mbm_assign_mode", --=20 2.34.1 From nobody Sun Dec 14 02:00:56 2025 Received: from NAM12-DM6-obe.outbound.protection.outlook.com (mail-dm6nam12on2077.outbound.protection.outlook.com [40.107.243.77]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 4809129B78D; Thu, 15 May 2025 22:56:23 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.243.77 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1747349785; cv=fail; b=j7E1X0rHK9J5wLRnrk9ly/UDcCzJ1OMkiWJGPRRw/4Haw0R677cTiOsaoQkG6iI5o8Ig4gR96XRVzgfonKAI53Nn+Efq0435jz8xQak0LYvkiekqV7WXYIAwyLWHnQD9V+DlVDpkZYso/zTKk1kovTlaGfyIJDvYUHriaMvjO+8= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1747349785; c=relaxed/simple; bh=C8KhxuDut1t1cm2NeTTrY0F1dq2aDsvSqmN3KpE1vYA=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=kb5l38pa/yZ1qjIM/M7jsKejZbGCDrjgxpWeLU28+yuJmPMQ53UY/JcssEgmFTxzHAHaDhd6doSWSadRtR+8X+DvLyvhWh4S5AvCnru+C6zACeIdEn4uicz0C6V43cIGlhGIDFFFnsB7oR6O2gvuBgtKO97NUtMWULRMXsl0Ydk= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=amd.com; spf=fail smtp.mailfrom=amd.com; dkim=pass (1024-bit key) header.d=amd.com header.i=@amd.com header.b=gB+dRsqE; arc=fail smtp.client-ip=40.107.243.77 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=amd.com Authentication-Results: smtp.subspace.kernel.org; spf=fail smtp.mailfrom=amd.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=amd.com header.i=@amd.com header.b="gB+dRsqE" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=qc0MKrXYvx8+V8QtIsUjnU87pOaOUFE//rzmuLzX+fNPWlzhi3A3JqpW6VWT0zf0nflTicx9wLxSA3lUUelTEkBFZnYmh/rBv3sjXaSQjDc8+9KgOfrhNHrI7f2QId2/p2r/9IPPTY0djkuV8RgUP6ZCUO4LFD4xzbrKfvzEmV0LEjWxy59xv7iIzrCm4Q+tfYN3Z3SQXziZWjeAycnbQbJv/F7mkbrGxibwUBl9vGD16qXPkmyILaaI1U32bZLhwGXvmBfy0HgYum5p8OiajZUvmRRepf+g/mEcMKPbqTkCTTOprUfp9qWXUGY+RT6pYODGrqBMOVaOGjyzKn1auw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=eYrqOL2HkNUlxYdwPifLiwqrjbMGwURY+c3E3QVrRJI=; b=x+GJFovPywOm+RzqVnsnFRninWjdn09e3evlA9YaqhkNBdBBODQtd+wzi1iPsd97hGLLNRCAEcTLpoS2sFZfrCeouKSjchqB2m6Wc3F37TCjNXO0LfXXesk3PWeTdU8+/5atl5ew+umIbVZ6DGoORB9BVxBqT8vKUZJ8wC5gK40ASG5eGrk/V/A/RKTh8msnnrIwHgf3HWBdTvOobvv2wRuZMY+jXuFrZJl3hvlbZoZQ9ngirj4haRdUR1LT95E9D+aBejAkqJ6h6BTW6SAkC1qSEC1zjOMEpNl9bssUWTH+N78iKBgvQIxkf4OIeRLj226/JUm30lnzDlucVZLkxw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=lwn.net smtp.mailfrom=amd.com; dmarc=pass (p=quarantine sp=quarantine pct=100) action=none header.from=amd.com; dkim=none (message not signed); arc=none (0) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amd.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=eYrqOL2HkNUlxYdwPifLiwqrjbMGwURY+c3E3QVrRJI=; b=gB+dRsqEccwbYvuaC58oeSdW7inhjO46hgAyvyVdaRxpLzbWgQCh6v6OSAZmNQDA2H+hZxlKc8x9j2Fz7SAdPsG122MBOA1IJsJAxaoMhXwXcNhVeqnLX4Wp2k9zKhFS9lgdR9P6bXas5PPpetrls99jHenNrtwR0qtK5rqCIqM= Received: from BL0PR02CA0017.namprd02.prod.outlook.com (2603:10b6:207:3c::30) by CY8PR12MB7433.namprd12.prod.outlook.com (2603:10b6:930:53::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8722.29; Thu, 15 May 2025 22:56:21 +0000 Received: from BN2PEPF000044A2.namprd02.prod.outlook.com (2603:10b6:207:3c:cafe::1b) by BL0PR02CA0017.outlook.office365.com (2603:10b6:207:3c::30) with Microsoft SMTP Server (version=TLS1_3, cipher=TLS_AES_256_GCM_SHA384) id 15.20.8746.16 via Frontend Transport; Thu, 15 May 2025 22:56:21 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 165.204.84.17) smtp.mailfrom=amd.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=amd.com; Received-SPF: Pass (protection.outlook.com: domain of amd.com designates 165.204.84.17 as permitted sender) receiver=protection.outlook.com; client-ip=165.204.84.17; helo=SATLEXMB04.amd.com; pr=C Received: from SATLEXMB04.amd.com (165.204.84.17) by BN2PEPF000044A2.mail.protection.outlook.com (10.167.243.153) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.8722.18 via Frontend Transport; Thu, 15 May 2025 22:56:21 +0000 Received: from bmoger-ubuntu.amd.com (10.180.168.240) by SATLEXMB04.amd.com (10.181.40.145) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.39; Thu, 15 May 2025 17:56:18 -0500 From: Babu Moger To: , , , , , , CC: , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , Subject: [PATCH v13 25/27] x86/resctrl: Hide the BMEC related files when mbm_cnt_assign is enabled Date: Thu, 15 May 2025 17:52:10 -0500 Message-ID: <1f86fadfa4fa0cb7daae506a8b0c22c1c3632ddd.1747349530.git.babu.moger@amd.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: References: Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-ClientProxiedBy: SATLEXMB04.amd.com (10.181.40.145) To SATLEXMB04.amd.com (10.181.40.145) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: BN2PEPF000044A2:EE_|CY8PR12MB7433:EE_ X-MS-Office365-Filtering-Correlation-Id: c5b4070c-a90c-4c03-c887-08dd9403b5d1 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|36860700013|1800799024|376014|7416014|82310400026; X-Microsoft-Antispam-Message-Info: =?us-ascii?Q?Z/rsb2sOo3yZgwVx/fOwI9+npU979TqYQ5rkh6TwE/PMktt0bontitSFhBWl?= =?us-ascii?Q?zJBwxYNhpCKgSHyH1wsC28fbYVm1yMWkUOG1W2q14DgXDJ7fyU74OUhU4Y/q?= =?us-ascii?Q?COg1kc3696bqjgUDCr1tStTkSrV9QgLeaUKv85jxhKOoTe64gkoN3c9GGkqg?= =?us-ascii?Q?brF6mCmQeqCM1NuGNAzjb+7OpAlReWrXemTzhqIgApPemeR+KPLOrvXtTe2u?= =?us-ascii?Q?Nexi3xr5dQ2teNg2FYOno0AdJO1Vd9s+mRarTKaqTeFkkdMFSdnjr7G9ey7m?= =?us-ascii?Q?og9oypGLJO/w3xuy4dTIIVdH3KX1RQRitEpLxnqvPrICq5LAnCH0rI2nxD+T?= =?us-ascii?Q?NsD/f4rau4WFLWyQ7dCn4lB23lTObztqMmCF3FRlhrrTg9Oz21GB7gTU4SHX?= =?us-ascii?Q?42yWr4djku4MAsLQJd4Jq/QBDlcXC5dK7xzNjvfpq9sNIICzVEDezkU91J1J?= =?us-ascii?Q?0XknMQs4R9OURRZe877/BzbiRjrZ9r/HsTj6WkIfm7CHGAS+q59oh9Wd/+fP?= =?us-ascii?Q?Kfe3470sRAILXmMOL+vhAbVKSdFXu6K3VFKTh1/WYvUtQf7IZymsB2t4vDHl?= =?us-ascii?Q?R0riUTqPxQl/agzMQFbzZpWC7RmAxnjngxMkELQamt1KNn6gHQ5W1xEtO+7h?= =?us-ascii?Q?E7wgdgkVzKUWzLCoXrBT+FDegMQKvKxYkdX5IrUeSeHDDVX9Kg9mYUFVpJmZ?= =?us-ascii?Q?6KpEW9VkKLbTIOV6JBhNyHY2sqAIP0p4LwI6am+j7OU3jHeA9NyqGMIgINv2?= =?us-ascii?Q?cLdE7hhf+vRCHmI8itWK5CrY2kHwekRRrl3Sl2i50bXKHcgTE+2DgtzGb7Ij?= =?us-ascii?Q?1xj+1EEcaWl+E+aoS3ATDMcin/9CxRfaDgsipItJbDKyJAXOTbnJCBsG+mpt?= =?us-ascii?Q?o0Mqoa1t7N5XiCBs0hqjIKRv2d/bzlylpJ7sNcB6oLswCQ460TMoq7GhYEq4?= =?us-ascii?Q?nYMFKmSwhZTLV030b1Asui8Zu8SKzTxMhxeNprjR0oqNzRpWVszm2+eiCAeW?= =?us-ascii?Q?f8HdMJoGJi7VhQ1tGuDuiO4mBDTYvP46lTIH6qrNBY3DACi1UTXJQ4fL5s9A?= =?us-ascii?Q?wjxfObu5yNCxSf1ZMKdO0oGjfKXWcVTMA0eCpaKHdHhiLwZqEkl1DmxRxIm9?= =?us-ascii?Q?jcvrcDxV4bDRhds8S11oipqDKIb/bjyuGbP88G79CqfOlRLMBV6U+kzsdGe1?= =?us-ascii?Q?ZNPJHFoE6Adzb6vy/EeBEJwhIzAirUl2WAAQvZ/iD+lU/W7M3rzPMDocLdhf?= =?us-ascii?Q?ZvgV6sDXkJ3bb8j6vFROgXJsybPM5kamWkQ4JGNOARbH02LsJCKXziHM6v2z?= =?us-ascii?Q?3c78xkYljCrM3nvdri2qHwr6RqpNvCN2W8VTijIC3Dzw81WGKbSN8ice61Ww?= =?us-ascii?Q?e/rCNodh5m5SnLPHl9IVlxb013lMSjfMHFhJuuo54Pe5RtLiBZLHZccxELGq?= =?us-ascii?Q?nJ8WRM0+vVg7FTSzviEn04q3G8CXbQbJMO2LBDG4q/cuwnyrOlWL3npuAxlf?= =?us-ascii?Q?SMSLsxch20DglyQ5kLoJy/j/QC81herFkOVe?= X-Forefront-Antispam-Report: CIP:165.204.84.17;CTRY:US;LANG:en;SCL:1;SRV:;IPV:CAL;SFV:NSPM;H:SATLEXMB04.amd.com;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(13230040)(36860700013)(1800799024)(376014)(7416014)(82310400026);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 15 May 2025 22:56:21.2201 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: c5b4070c-a90c-4c03-c887-08dd9403b5d1 X-MS-Exchange-CrossTenant-Id: 3dd8961f-e488-4e60-8e11-a82d994e183d X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=3dd8961f-e488-4e60-8e11-a82d994e183d;Ip=[165.204.84.17];Helo=[SATLEXMB04.amd.com] X-MS-Exchange-CrossTenant-AuthSource: BN2PEPF000044A2.namprd02.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: CY8PR12MB7433 Content-Type: text/plain; charset="utf-8" BMEC (Bandwidth Monitoring Event Configuration) and mbm_cntr_assign cannot be used simultaneously. When mbm_cntr_assign is active, suppress visibility of BMEC-related files to prevent confusion. The files /sys/fs/resctrl/info/L3_MON/mbm_total_bytes_config and /sys/fs/resctrl/info/L3_MON/mbm_local_bytes_config will not be visible when mbm_cntr_assign mode is enabled. Suggested-by: Reinette Chatre Signed-off-by: Babu Moger --- v13: New patch to hide BMEC related files. --- fs/resctrl/rdtgroup.c | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) diff --git a/fs/resctrl/rdtgroup.c b/fs/resctrl/rdtgroup.c index ea1782723f81..d6bf2a50a105 100644 --- a/fs/resctrl/rdtgroup.c +++ b/fs/resctrl/rdtgroup.c @@ -1815,6 +1815,33 @@ static ssize_t mbm_local_bytes_config_write(struct k= ernfs_open_file *of, return ret ?: nbytes; } =20 +static void resctrl_bmec_files_show(struct rdt_resource *r, bool show) +{ + struct kernfs_node *kn_config, *l3_mon_kn; + char name[32]; + + sprintf(name, "%s_MON", r->name); + l3_mon_kn =3D kernfs_find_and_get(kn_info, name); + if (!l3_mon_kn) + return; + + kn_config =3D kernfs_find_and_get(l3_mon_kn, "mbm_total_bytes_config"); + if (kn_config) { + kernfs_get(kn_config); + kernfs_show(kn_config, show); + kernfs_put(kn_config); + } + + kn_config =3D kernfs_find_and_get(l3_mon_kn, "mbm_local_bytes_config"); + if (kn_config) { + kernfs_get(kn_config); + kernfs_show(kn_config, show); + kernfs_put(kn_config); + } + + kernfs_put(l3_mon_kn); +} + static int resctrl_mbm_assign_mode_show(struct kernfs_open_file *of, struct seq_file *s, void *v) { @@ -2815,6 +2842,10 @@ static int rdtgroup_create_info_dir(struct kernfs_no= de *parent_kn) ret =3D resctrl_mkdir_counter_configs(r, name); if (ret) goto out_destroy; + + /* Hide BMEC related files if mbm_cntr_assign is enabled */ + if (resctrl_arch_mbm_cntr_assign_enabled(r)) + resctrl_bmec_files_show(r, false); } } =20 --=20 2.34.1 From nobody Sun Dec 14 02:00:56 2025 Received: from NAM11-DM6-obe.outbound.protection.outlook.com (mail-dm6nam11on2045.outbound.protection.outlook.com [40.107.223.45]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 22D83293732; Thu, 15 May 2025 22:56:36 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.223.45 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1747349799; cv=fail; b=ayQmr6BbjEfQIlcD9oQRrlcNUt0Xiptcvqj48ud88IKOsbEYK3VkTYEGYin6/Kcj0015Fe5kZZifeb9kIl4I8IMt5aUHUYPmVm9x2FMsHusbSZnxL+KW8Z82D60k/MthC35uR5PvUcviEkw0CiUbAIsnEkS4SDrf53Y3w9MbrQw= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1747349799; c=relaxed/simple; bh=UfEN1JBPzfQh/bG4aX8Kjd+zYoNK74/vZDIK0IsoHkw=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=TgBotmv10psAEX/805LvQSX6ejdAQZYYtLZahOjwT/jwMNuSGGHzbNi6tH9ur9JqB7d/tUSCVdVSR6GePC8svbOhcwKmfERiIHB2Qj10OwfAWLaJUcoxSKb7tDMbjB2e3o+J2lbq2pIP0pZdqnbIFD7ske2NcFhJiwLw+IlOraM= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=amd.com; spf=fail smtp.mailfrom=amd.com; dkim=pass (1024-bit key) header.d=amd.com header.i=@amd.com header.b=AVWi4F9w; arc=fail smtp.client-ip=40.107.223.45 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=amd.com Authentication-Results: smtp.subspace.kernel.org; spf=fail smtp.mailfrom=amd.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=amd.com header.i=@amd.com header.b="AVWi4F9w" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=F4UQLYPVso9t4a9DQZaeT8Ww9uQwg+f2Biez9WHuRhUcZ7Z4VfdYaMtYbeMJ6KFHLBt9hcpBnPxZ48YQiEzrcFU5uyrJpZEzYw/jrMXgSuFmRj6YCa4Ho/OP5WDrDHdE8cVo0M65QJ2nXrWbezL1RP3JzlxEMtpvoR0YX6FVej4eZHixS0AejzZA2lJSyYokllDMrHV3B0/Ovw1G9PGQEqG8J67+m6OHWY/uy56nAahvcaSotiUX/2owULA3O/gRg4ZtkGjz0OxboR5nxCNGJoXDJ8wEo2chg+TtfdKODnj9N/Qmp3OJH0pzZ+2X7YUL/JwE28BADULBULFQIkwaIg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=FJKeK/2Nh2+QKqoi1N/8RmFJzWmWMMSTZd3hbBqqmdc=; b=EvrK7TuAcEO0GNfK6a80nYsCKdLCiPyKFJ57u4G4SxoGoxrJJ05LhbpVgatF0CmF5yBpZZmoa43hgIe6Ps4ORXFjeHbZ06jMQyxpWQUjiuEjbSWboZI1F3NVOlGoMF4o9aVdJenVSD31GRPiOfKYLLATD3H5Tu6gf2JgyDDgxygMPg+WT//Zjrbqe3rLLXliUergDC3rgBly6T0v+iC3vL9yxloOZaTNgn694xBTBDhzV5jcqHY/luU+qroVIdeqVmh5p0NYW+TcD3qYlicAUWje8RMCk3g/FUmxXz8vj/oA/q96MIlq3plKj0IC7kNfv15EtUJ8O/qENKjrXpoLOw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=lwn.net smtp.mailfrom=amd.com; dmarc=pass (p=quarantine sp=quarantine pct=100) action=none header.from=amd.com; dkim=none (message not signed); arc=none (0) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amd.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=FJKeK/2Nh2+QKqoi1N/8RmFJzWmWMMSTZd3hbBqqmdc=; b=AVWi4F9wqi2ryWQmo42ybnlQf/ydj31GWEMXDoGFSUYEA559Qdv8oArukPG8G3gIx7pBH/TMiBplI+GTZWXV3mlgaXzDEVo9LHCHMBEaG7x0hxqXGcCC3XyOTdVzZA2/0d+d5vrOpWD7BrBR6TSn1peA6U7gckl/7+h10QiDZ5g= Received: from BN9PR03CA0173.namprd03.prod.outlook.com (2603:10b6:408:f4::28) by SJ5PPFFA661D690.namprd12.prod.outlook.com (2603:10b6:a0f:fc02::9ab) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8678.27; Thu, 15 May 2025 22:56:32 +0000 Received: from BN2PEPF000044A1.namprd02.prod.outlook.com (2603:10b6:408:f4:cafe::6e) by BN9PR03CA0173.outlook.office365.com (2603:10b6:408:f4::28) with Microsoft SMTP Server (version=TLS1_3, cipher=TLS_AES_256_GCM_SHA384) id 15.20.8722.25 via Frontend Transport; Thu, 15 May 2025 22:56:30 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 165.204.84.17) smtp.mailfrom=amd.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=amd.com; Received-SPF: Pass (protection.outlook.com: domain of amd.com designates 165.204.84.17 as permitted sender) receiver=protection.outlook.com; client-ip=165.204.84.17; helo=SATLEXMB04.amd.com; pr=C Received: from SATLEXMB04.amd.com (165.204.84.17) by BN2PEPF000044A1.mail.protection.outlook.com (10.167.243.152) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.8722.18 via Frontend Transport; Thu, 15 May 2025 22:56:30 +0000 Received: from bmoger-ubuntu.amd.com (10.180.168.240) by SATLEXMB04.amd.com (10.181.40.145) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.39; Thu, 15 May 2025 17:56:27 -0500 From: Babu Moger To: , , , , , , CC: , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , Subject: [PATCH v13 26/27] x86/resctrl: Introduce the interface to switch between monitor modes Date: Thu, 15 May 2025 17:52:11 -0500 Message-ID: <5b5662a8195efdba2254de221f441a700be795b0.1747349530.git.babu.moger@amd.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: References: Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-ClientProxiedBy: SATLEXMB04.amd.com (10.181.40.145) To SATLEXMB04.amd.com (10.181.40.145) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: BN2PEPF000044A1:EE_|SJ5PPFFA661D690:EE_ X-MS-Office365-Filtering-Correlation-Id: 40eafd9c-6def-4fa0-e031-08dd9403bb87 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|1800799024|82310400026|36860700013|7416014|376014; X-Microsoft-Antispam-Message-Info: =?us-ascii?Q?95qr5FjplHObnIGpKOlqqXy0hKelfPs6Op3nVh4hkf5Bm7DoBVf48g+//CTt?= =?us-ascii?Q?By2/mW8Wx7OyE6sGYwI20glBY2Ob8ojtwtINyhQ24ZKN+ZQWw38y5ULQqM3G?= =?us-ascii?Q?ZV5ShHI6rvb/DymSIvNDbPuv96Rjp/uOGhMZvUw433lp8qdUxvqf/h5YXtdk?= =?us-ascii?Q?5+cnRpFT9DhPHRUFW4e5bI0z4GNmZctU8xpwV7vX+NmcxVhQQT1SHvU+KBs7?= =?us-ascii?Q?M8nhrcdbDYdPCFKzK+fkCErk0Zg8Upgk9Ve7U+qOS9p/I5OO2bLJaF4cTEN7?= =?us-ascii?Q?N928qDWoJMI79rLuQoJoKaGrjj0G8S0/Jrlh76KMbxTno8yrEqaNHB0zbAQh?= =?us-ascii?Q?8uCPHrRm0tT8VvrkxWUPkdIy72RDIWViYVY9knnzVA/2Tvunacr+pUxJ6Vyr?= =?us-ascii?Q?UBeWsQhq7D/pmSnpSf6TdAgsZI37wXtmhRcSNlNri0hPusWAmEzZwKnnMfo0?= =?us-ascii?Q?hGudcACN6lCNkNlODSxaa9u49luocJVGDI+M0mp/N4JHp6CGbXFnVYXuSgBQ?= =?us-ascii?Q?MZVILhVIxNwRNKP090bP5ng+7Q3GvmJ8GpKaBaVGeCn7jXdgse/k0OXaxFzI?= =?us-ascii?Q?/RMKX09C8jBKVzNXH212XgfHE9CedE8x9jp9IZgZmbC4kaMetUZVBEPV9RrX?= =?us-ascii?Q?WeC3raPv5nsbieOgc5yLld5MZ2hYIJw8qjIZ4zHPdKJuec1F4i+e3PXlYbfh?= =?us-ascii?Q?FQK0JozFhRDDuyhTKvzyqMF5cyOF4l8qvf/FsTcgXxhVos4+EmfspLg/T/TI?= =?us-ascii?Q?YE6plPFyyOB4gTqRy0OSAJjvCrfkaWX65pGtxlQq5DyGEDvAUxwvAO+YsEpj?= =?us-ascii?Q?NQFL7TNpjwlXHTkUWIUUG9pbJKz69vO6+b+NkIjrI97AeF5SyRoKXJzZ7hMg?= =?us-ascii?Q?sPLvc8BvGMDuiEy5MhgW7JCEf4hFK+tv29/iFmNH5VEL6GFpqw4/KhJCnv4y?= =?us-ascii?Q?YP8PFHDjgR/c7BnuYWSwBinTlzzCWbANd1ZkkCnG4Msjk5WaXQfvsKg7xyUB?= =?us-ascii?Q?yVOdj5QSbmixgvD/yfSpt2cpTMEQ8rgOJMGxUm6gLqQ5zxlIChLLxMjT/k3X?= =?us-ascii?Q?OtpahWoSooqhf5NHkfyiYOvQtUrTBDkt6ITmkCogS1hG0KwmaL0laVTx5fwo?= =?us-ascii?Q?n02jvv3mAePk37dPRqyI6+cHGi+t1ALqNJD2KytWez7jbmJAJu90bpEQInek?= =?us-ascii?Q?EazefZ233V6S7cU8uwvoSQbqimdExj4pSR/CfaQ/wMbH5602QzbUH9higbzS?= =?us-ascii?Q?lusFE3YvpX9AV9R2aqbwcby4bcG+YkFoMXx+NeMqZsWiavjOYBEb49t0imts?= =?us-ascii?Q?Tzji0ii3N1UlPuJnZjKgP9SCz+hahvSXEVm4QQ0jUT6c3sjaaxKj8Zg1TpdK?= =?us-ascii?Q?KXEXEwv/rieDPd//i6qIMQ4pmEvZGbaHe2BEImkF+jGaWFRriJXJaJHQMuTZ?= =?us-ascii?Q?gjXS9t5lE9Q65tyVda1/1SAJYjEDEnLWZ++6xmxP7KNT3FgRzjXXPZB9C2U4?= =?us-ascii?Q?2+EKhYW5Wz5QRk0=3D?= X-Forefront-Antispam-Report: CIP:165.204.84.17;CTRY:US;LANG:en;SCL:1;SRV:;IPV:CAL;SFV:NSPM;H:SATLEXMB04.amd.com;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(13230040)(1800799024)(82310400026)(36860700013)(7416014)(376014);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 15 May 2025 22:56:30.8110 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 40eafd9c-6def-4fa0-e031-08dd9403bb87 X-MS-Exchange-CrossTenant-Id: 3dd8961f-e488-4e60-8e11-a82d994e183d X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=3dd8961f-e488-4e60-8e11-a82d994e183d;Ip=[165.204.84.17];Helo=[SATLEXMB04.amd.com] X-MS-Exchange-CrossTenant-AuthSource: BN2PEPF000044A1.namprd02.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: SJ5PPFFA661D690 Content-Type: text/plain; charset="utf-8" Resctrl subsystem can support two monitoring modes, "mbm_cntr_assign" or "default". In mbm_cntr_assign, monitoring event can only accumulate data while it is backed by a hardware counter. In "default" mode, resctrl assumes there is a hardware counter for each event within every CTRL_MON and MON group. Introduce interface to switch between mbm_cntr_assign and default modes. $ cat /sys/fs/resctrl/info/L3_MON/mbm_assign_mode [mbm_cntr_assign] default To enable the "mbm_cntr_assign" monitoring mode: $ echo "mbm_cntr_assign" > /sys/fs/resctrl/info/L3_MON/mbm_assign_mode To enable the "default" monitoring mode: $ echo "default" > /sys/fs/resctrl/info/L3_MON/mbm_assign_mode MBM event counters are automatically reset as part of changing the mode. Clear both architectural and non-architectural event states to prevent overflow conditions during the next event read. Signed-off-by: Babu Moger --- v13: Resolved the conflicts due to FS/ARCH restructure. Introduced the new resctrl_init_evt_configuration() to initialize the event modes and configuration values. Added the call to resctrl_bmec_files_show() hide/show BMEC related files. v12: Fixed the documentation for a consistency. Introduced mbm_cntr_free_all() and resctrl_reset_rmid_all() to clear counters and non-architectural states when monitor mode is changed. https://lore.kernel.org/lkml/b60b4f72-6245-46db-a126-428fb13b6310@inte= l.com/ v11: Changed the name of the function rdtgroup_mbm_assign_mode_write() to resctrl_mbm_assign_mode_write(). Rewrote the commit message with context. Added few more details in resctrl.rst about mbm_cntr_assign mode. Re-arranged the text in resctrl.rst file. v10: The call mbm_cntr_reset() has been moved to earlier patch. Minor documentation update. v9: Fixed extra spaces in user documentation. Fixed problem changing the mode to mbm_cntr_assign mode when it is not supported. Added extra checks to detect if systems supports it. Used the rdtgroup_cntr_id_init to initialize cntr_id. v8: Reset the internal counters after mbm_cntr_assign mode is changed. Renamed rdtgroup_mbm_cntr_reset() to mbm_cntr_reset() Updated the documentation to make text generic. v7: Changed the interface name to mbm_assign_mode. Removed the references of ABMC. Added the changes to reset global and domain bitmaps. Added the changes to reset rmid. v6: Changed the mode name to mbm_cntr_assign. Moved all the FS related code here. Added changes to reset mbm_cntr_map and resctrl group counters. v5: Change log and mode description text correction. v4: Minor commit text changes. Keep the default to ABMC when supported. Fixed comments to reflect changed interface "mbm_mode". v3: New patch to address the review comments from upstream. --- Documentation/filesystems/resctrl.rst | 25 ++++++++++- fs/resctrl/internal.h | 3 ++ fs/resctrl/monitor.c | 53 +++++++++++++++++++--- fs/resctrl/rdtgroup.c | 65 ++++++++++++++++++++++++++- 4 files changed, 138 insertions(+), 8 deletions(-) diff --git a/Documentation/filesystems/resctrl.rst b/Documentation/filesyst= ems/resctrl.rst index d779554a2f91..7c304821ce93 100644 --- a/Documentation/filesystems/resctrl.rst +++ b/Documentation/filesystems/resctrl.rst @@ -259,7 +259,10 @@ with the following files: =20 "mbm_assign_mode": Reports the list of monitoring modes supported. The enclosed brackets - indicate which mode is enabled. + indicate which mode is enabled. The MBM events (mbm_total_bytes and/or + mbm_local_bytes) associated with counters may reset when "mbm_assign_mode" + is changed. + :: =20 # cat /sys/fs/resctrl/info/L3_MON/mbm_assign_mode @@ -275,6 +278,16 @@ with the following files: "num_mbm_cntrs" file. Changing the mode may cause all counters on the resource to reset. =20 + Moving to mbm_cntr_assign mode require users to assign the counters to + the events. Otherwise, the MBM event counters will return 'Unassigned' + when read. + + The mode is beneficial for AMD platforms that support more CTRL_MON + and MON groups than available hardware counters. By default, this + feature is enabled on AMD platforms with the ABMC (Assignable Bandwidth + Monitoring Counters) capability, ensuring counters remain assigned even + when the corresponding RMID is not actively used by any processor. + "default": =20 In default mode, resctrl assumes there is a hardware counter for each @@ -284,6 +297,16 @@ with the following files: counters. This can result in misleading values or display "Unavailable" if no counter is assigned to the event. =20 + * To enable "mbm_cntr_assign" monitoring mode: + :: + + # echo "mbm_cntr_assign" > /sys/fs/resctrl/info/L3_MON/mbm_assign_mode + + * To enable "default" monitoring mode: + :: + + # echo "default" > /sys/fs/resctrl/info/L3_MON/mbm_assign_mode + "num_mbm_cntrs": The maximum number of monitoring counters (total of available and assigned counters) in each domain when the system supports mbm_cntr_assign mode. diff --git a/fs/resctrl/internal.h b/fs/resctrl/internal.h index a6069a5dfd49..d5edb28a8df7 100644 --- a/fs/resctrl/internal.h +++ b/fs/resctrl/internal.h @@ -404,6 +404,9 @@ int resctrl_unassign_cntr_event(struct rdt_resource *r,= struct rdt_mon_domain *d struct rdtgroup *rdtgrp, enum resctrl_event_id evtid); int mbm_cntr_get(struct rdt_resource *r, struct rdt_mon_domain *d, struct rdtgroup *rdtgrp, enum resctrl_event_id evtid); +void resctrl_reset_rmid_all(struct rdt_resource *r, struct rdt_mon_domain = *d); +void mbm_cntr_free_all(struct rdt_resource *r, struct rdt_mon_domain *d); +void resctrl_init_evt_configuration(struct rdt_resource *r, bool enable); =20 #ifdef CONFIG_RESCTRL_FS_PSEUDO_LOCK int rdtgroup_locksetup_enter(struct rdtgroup *rdtgrp); diff --git a/fs/resctrl/monitor.c b/fs/resctrl/monitor.c index b982540ce4e3..bebe83cf48d5 100644 --- a/fs/resctrl/monitor.c +++ b/fs/resctrl/monitor.c @@ -911,16 +911,13 @@ int resctrl_mon_resource_init(void) =20 l3_mon_evt_init(r); =20 - if (resctrl_arch_is_evt_configurable(QOS_L3_MBM_TOTAL_EVENT_ID)) { - mbm_total_event.mbm_mode =3D MBM_MODE_BMEC; + if (resctrl_arch_is_evt_configurable(QOS_L3_MBM_TOTAL_EVENT_ID)) resctrl_file_fflags_init("mbm_total_bytes_config", RFTYPE_MON_INFO | RFTYPE_RES_CACHE); - } - if (resctrl_arch_is_evt_configurable(QOS_L3_MBM_LOCAL_EVENT_ID)) { - mbm_local_event.mbm_mode =3D MBM_MODE_BMEC; + + if (resctrl_arch_is_evt_configurable(QOS_L3_MBM_LOCAL_EVENT_ID)) resctrl_file_fflags_init("mbm_local_bytes_config", RFTYPE_MON_INFO | RFTYPE_RES_CACHE); - } =20 if (resctrl_arch_is_mbm_local_enabled()) mba_mbps_default_event =3D QOS_L3_MBM_LOCAL_EVENT_ID; @@ -938,6 +935,8 @@ int resctrl_mon_resource_init(void) resctrl_file_fflags_init("mbm_L3_assignments", RFTYPE_MON_BASE); } =20 + resctrl_init_evt_configuration(r, true); + return 0; } =20 @@ -1010,6 +1009,25 @@ static void mbm_cntr_free(struct rdt_mon_domain *d, = int cntr_id) memset(&d->cntr_cfg[cntr_id], 0, sizeof(struct mbm_cntr_cfg)); } =20 +void mbm_cntr_free_all(struct rdt_resource *r, struct rdt_mon_domain *d) +{ + memset(d->cntr_cfg, 0, sizeof(*d->cntr_cfg) * r->mon.num_mbm_cntrs); +} + +/* + * Reset all non-architecture states for all the supported RMIDs. + */ +void resctrl_reset_rmid_all(struct rdt_resource *r, struct rdt_mon_domain = *d) +{ + u32 idx_limit =3D resctrl_arch_system_num_rmid_idx(); + + if (resctrl_arch_is_mbm_total_enabled()) + memset(d->mbm_total, 0, sizeof(struct mbm_state) * idx_limit); + + if (resctrl_arch_is_mbm_local_enabled()) + memset(d->mbm_local, 0, sizeof(struct mbm_state) * idx_limit); +} + /* * mbm_get_mon_event() - Return the mon_evt entry for the matching evtid. */ @@ -1119,6 +1137,29 @@ static int resctrl_free_config_cntr(struct rdt_resou= rce *r, struct rdt_mon_domai return 0; } =20 +/* + * Initialize the event modes and configuration values. + * + * total event is set to count all the supported memory transactions. + * local event is set to count all the local memory transactions. + */ +void resctrl_init_evt_configuration(struct rdt_resource *r, bool enable) +{ + if (resctrl_arch_mbm_cntr_assign_enabled(r)) { + mbm_total_event.mbm_mode =3D MBM_MODE_ASSIGN; + mbm_total_event.evt_cfg =3D MAX_EVT_CONFIG_BITS; + mbm_local_event.mbm_mode =3D MBM_MODE_ASSIGN; + mbm_local_event.evt_cfg =3D READS_TO_LOCAL_MEM | + NON_TEMP_WRITE_TO_LOCAL_MEM | + READS_TO_LOCAL_S_MEM; + } else { + if (resctrl_arch_is_evt_configurable(QOS_L3_MBM_TOTAL_EVENT_ID)) + mbm_total_event.mbm_mode =3D MBM_MODE_BMEC; + if (resctrl_arch_is_evt_configurable(QOS_L3_MBM_LOCAL_EVENT_ID)) + mbm_local_event.mbm_mode =3D MBM_MODE_BMEC; + } +} + /* * Unassign a hardware counter associated with @evtid from the domain and * the group. Unassign the counters from all the domains if @d is NULL else diff --git a/fs/resctrl/rdtgroup.c b/fs/resctrl/rdtgroup.c index d6bf2a50a105..c76d598e4d23 100644 --- a/fs/resctrl/rdtgroup.c +++ b/fs/resctrl/rdtgroup.c @@ -1872,6 +1872,68 @@ static int resctrl_mbm_assign_mode_show(struct kernf= s_open_file *of, return 0; } =20 +static ssize_t resctrl_mbm_assign_mode_write(struct kernfs_open_file *of, + char *buf, size_t nbytes, loff_t off) +{ + struct rdt_resource *r =3D rdt_kn_parent_priv(of->kn); + struct rdt_mon_domain *d; + int ret =3D 0; + bool enable; + + /* Valid input requires a trailing newline */ + if (nbytes =3D=3D 0 || buf[nbytes - 1] !=3D '\n') + return -EINVAL; + + buf[nbytes - 1] =3D '\0'; + + cpus_read_lock(); + mutex_lock(&rdtgroup_mutex); + + rdt_last_cmd_clear(); + + if (!strcmp(buf, "default")) { + enable =3D 0; + } else if (!strcmp(buf, "mbm_cntr_assign")) { + if (r->mon.mbm_cntr_assignable) { + enable =3D 1; + } else { + ret =3D -EINVAL; + rdt_last_cmd_puts("mbm_cntr_assign mode is not supported\n"); + goto write_exit; + } + } else { + ret =3D -EINVAL; + rdt_last_cmd_puts("Unsupported assign mode\n"); + goto write_exit; + } + + if (enable !=3D resctrl_arch_mbm_cntr_assign_enabled(r)) { + ret =3D resctrl_arch_mbm_cntr_assign_set(r, enable); + if (ret) + goto write_exit; + + /* Initialize event configuration details accordingly */ + resctrl_init_evt_configuration(r, enable); + + /* Update the visibility of BMEC related files */ + resctrl_bmec_files_show(r, !enable); + + /* + * Reset all the non-achitectural RMID state and assignable counters. + */ + list_for_each_entry(d, &r->mon_domains, hdr.list) { + mbm_cntr_free_all(r, d); + resctrl_reset_rmid_all(r, d); + } + } + +write_exit: + mutex_unlock(&rdtgroup_mutex); + cpus_read_unlock(); + + return ret ?: nbytes; +} + static int resctrl_num_mbm_cntrs_show(struct kernfs_open_file *of, struct seq_file *s, void *v) { @@ -2462,9 +2524,10 @@ static struct rftype res_common_files[] =3D { }, { .name =3D "mbm_assign_mode", - .mode =3D 0444, + .mode =3D 0644, .kf_ops =3D &rdtgroup_kf_single_ops, .seq_show =3D resctrl_mbm_assign_mode_show, + .write =3D resctrl_mbm_assign_mode_write, .fflags =3D RFTYPE_MON_INFO | RFTYPE_RES_CACHE, }, { --=20 2.34.1 From nobody Sun Dec 14 02:00:56 2025 Received: from NAM11-CO1-obe.outbound.protection.outlook.com (mail-co1nam11on2058.outbound.protection.outlook.com [40.107.220.58]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 35F5428DF3F; Thu, 15 May 2025 22:56:45 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.220.58 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1747349807; cv=fail; b=jm7/Y8gZ59Y7q9A7/5CZGFG+FtxM+CZfLtgecPye5Qu9p2I/tIIG1xPQa86VSmY1MnAToPnRhaxL22NrFLPEaXtvXI47cZ3w84CuB9Kr6FdQ3BvPnIO3tzRrRJXPXNtG+Lore/e9fhZIuI2GS7JODu9Y5wYfVBV2l5VGuYftmVg= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1747349807; c=relaxed/simple; bh=yNwAjLQq5goDe+M3AD0+Cx1N8LSlbveUTd65YM1zN3A=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=Y/zLXNKlrRR8XxVn/Cmr4j/7wjTVHCGI90OWtkC+9D7TThINGFtYJi2PuRkjxSRIS3/qYjwNA9O0A6x7lOJomTxN4+SHK2CTEllbgckvlKGo1BfQ7w1bKxuACeQZp/jqE9DcG4zdLm44g+plXq+ZdS09oxtjrnbB3VISGs7E99w= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=amd.com; spf=fail smtp.mailfrom=amd.com; dkim=pass (1024-bit key) header.d=amd.com header.i=@amd.com header.b=gJd603u7; arc=fail smtp.client-ip=40.107.220.58 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=amd.com Authentication-Results: smtp.subspace.kernel.org; spf=fail smtp.mailfrom=amd.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=amd.com header.i=@amd.com header.b="gJd603u7" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=lhdTetCwb44FnMQvUJ4S2X0dOkIKz244DTTwtXCBJTQjlF3iWGxII9ZEEQJHxZxJBm4xi01xm0l1Wf1FEH6kEluWlM2r8mPynPyfQaqGk44iJBBwW1OkUM/LbBrwj0qsUPCLhgzkTWqVKi17dAqHUgBlfe+QW36Jhc651HwKOfm5MtEH/5gYZOpELjK1vNB2qL/Ar6cRtrarlCaE04fnjllfnmLF3VaTzqCRNAzxpI4TtDu1E/8pybO2OmhSCpNdUN6ChxXf6VlsEpz/HR/R0hWI/BTskDkApcXVIdinZDa+vHI4w1Y9cTs8kVPA+cNuTSa5RpbPJ8350Rj8gw2xrA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=BvntYzuX7kmIuiyHIjwA+dmXfvvLztpMzl4BYtf0Nkw=; b=XnKZucXjEnrQnmae1kcePDAmuGX1MTyurUCyTCQWnryd19vVZqw2uE6x4z3fFWrI5Xu770KhsBPIlPeAsjlGsRx46vX5EeJiAhNwu6Lz/0cOippi17sHqJrvoz9tcAN5dPH9VcmhH71jsWwEAU49uVu/JI91Hx/PIx9gqfo4da+0WznTJus1L7vkt5Inb73mdRYcQYrSqyiYltpmXwn2kHwMkK3Er5kHWq5O1SRUhs4YN38JMezUo9d5R8HP0N6e7MFE1S88njAzAsGOYscIn4tnoXq/8IXHwnU+aasxIZ427SDVbCaUZTgJnYzexGOqYH5AwXR6qAdKuIQUHLMOlA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=lwn.net smtp.mailfrom=amd.com; dmarc=pass (p=quarantine sp=quarantine pct=100) action=none header.from=amd.com; dkim=none (message not signed); arc=none (0) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amd.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=BvntYzuX7kmIuiyHIjwA+dmXfvvLztpMzl4BYtf0Nkw=; b=gJd603u7wy/Px5RmNw3t36Ep3eFt5d5OC9PIswuo3V2QaCoHdYPSDHgwqLAzQj7kx9MgHWVyAC+ysf3MxcVrqEhdpHO/cyT0Ty8LcNKayi5OK62FzhIvhRLM5hqqnq6WfYzcbtYJ7ACtQH9L5Q4HuGTnjwLWgAf4kfi34fnjgMw= Received: from BN8PR12CA0012.namprd12.prod.outlook.com (2603:10b6:408:60::25) by SA0PR12MB4368.namprd12.prod.outlook.com (2603:10b6:806:9f::21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8722.31; Thu, 15 May 2025 22:56:41 +0000 Received: from BN2PEPF000044A3.namprd02.prod.outlook.com (2603:10b6:408:60:cafe::27) by BN8PR12CA0012.outlook.office365.com (2603:10b6:408:60::25) with Microsoft SMTP Server (version=TLS1_3, cipher=TLS_AES_256_GCM_SHA384) id 15.20.8699.26 via Frontend Transport; Thu, 15 May 2025 22:56:41 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 165.204.84.17) smtp.mailfrom=amd.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=amd.com; Received-SPF: Pass (protection.outlook.com: domain of amd.com designates 165.204.84.17 as permitted sender) receiver=protection.outlook.com; client-ip=165.204.84.17; helo=SATLEXMB04.amd.com; pr=C Received: from SATLEXMB04.amd.com (165.204.84.17) by BN2PEPF000044A3.mail.protection.outlook.com (10.167.243.154) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.8722.18 via Frontend Transport; Thu, 15 May 2025 22:56:40 +0000 Received: from bmoger-ubuntu.amd.com (10.180.168.240) by SATLEXMB04.amd.com (10.181.40.145) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.39; Thu, 15 May 2025 17:56:37 -0500 From: Babu Moger To: , , , , , , CC: , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , Subject: [PATCH v13 27/27] x86/resctrl: Configure mbm_cntr_assign mode if supported Date: Thu, 15 May 2025 17:52:12 -0500 Message-ID: <1e9785e00fe55987f8585aef8cbdedbc58e2b1ee.1747349530.git.babu.moger@amd.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: References: Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-ClientProxiedBy: SATLEXMB04.amd.com (10.181.40.145) To SATLEXMB04.amd.com (10.181.40.145) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: BN2PEPF000044A3:EE_|SA0PR12MB4368:EE_ X-MS-Office365-Filtering-Correlation-Id: 9ccd0999-9095-49d3-9e59-08dd9403c13b X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|376014|36860700013|82310400026|1800799024|7416014; X-Microsoft-Antispam-Message-Info: =?us-ascii?Q?6U1RGwNc2h9m+XEk+Tkn5ZfkpT79UATSvVjl7qRGAQDs6MoIvjSN03Lv844I?= =?us-ascii?Q?3bI/6lPsXeJvtnAtU+h8zFWH1dcWurDZaYP70fh0IGsOzGrrOvbyi0rXHjMT?= =?us-ascii?Q?M1qWz4jDOjZdkHo/s0qyAIWM8mxdFoy4uFZ8G9ieaVUIHSySdTIl0PozNo2k?= =?us-ascii?Q?5UymUnFJMCrHr7KHC+P5OopLPtiiof3aau42OGe6oOfBcGjCSete1eaJOFgf?= =?us-ascii?Q?Rpwcr2JGOsSwDUhtAxU4lCcvX8m72bho3cIx/Nls3bGw0idmQDiXQ018GzvC?= =?us-ascii?Q?gCf3R5bVhqGdFN7rmbcqoCSafs04kN9RH3ImdDHejPU4vvhLvqNAPy+vV4U1?= =?us-ascii?Q?gRBs7X445Id9hR0IIA1mqYx3x50fkwEW7to9NUaWNzDJnRTAs49yzsXNOEHJ?= =?us-ascii?Q?u03OYdYp/+6wE9g7vIxb3klBCrgT4CF1JselW7H5Hlpl5gmm8Hlia/84pew9?= =?us-ascii?Q?Iec+caZyLNrfZKGxtXfuw+PWqEEBXVpfwTxHCoT7qAyKuRqDXsOsVJ07HDnf?= =?us-ascii?Q?fiSFoQheCQ8St5I8JkoXmu6Yps8xgA22swhiBILUHpeR9xnTei4XxwGrELnm?= =?us-ascii?Q?G5jcFxzr6e3JUPpW6D++CNf5CQt1ZytqqKBUqCLf/aFm5anoi91s4YAUkj7M?= =?us-ascii?Q?HkPiomPOSCfbTObwT0njSYCaf2X7nSTVJ9g4sA6+k4n7grVZbAYQcgstLLTw?= =?us-ascii?Q?rb0j39E+Pvi5CiyaOxfObrUY//VvalAcpurlgcJMIBfNhBa22ns9CjLWQz5b?= =?us-ascii?Q?UjsxNsk7t0rN6I56yl39d+D18CalA9Q66WAL2ps8Bu/8j9fl80lIlrFdPUe3?= =?us-ascii?Q?d++WPoRYWWch5d3yBFK2IoxVLyHiHjkCMSEuGRDUo/Mp6sKh7Koky1jZnpGd?= =?us-ascii?Q?OeIknk5mt0++Kv+YZ7sOTmx0FwgoDf9CL8nFhx3mUG4HzT56xtJ8hv74fZUg?= =?us-ascii?Q?OikM2KTJRTBUp6rb+QlKFnaXkJrB7z3dZxjAMpbwByfLG8Q08fOsuy0Q6BWq?= =?us-ascii?Q?kcIG1ynRPrOk5m6FvH+dyXaP0mjyhkx6hmrlIFOuqg26AUJ4bVYYw3zMYQLe?= =?us-ascii?Q?2Int1ANH7FStkrxA9x3hUgrqW9pvjRk/fiSjMzbly0/hjS3PMpHw+r/zv38v?= =?us-ascii?Q?Xlrt6S9eolAJSQi3Z8QeK3LorX2EP9Y1CWjjRE9pBMyLZkc0RmXzShsh8wq1?= =?us-ascii?Q?6QEfNIK86nRo2RFPau3zJbi1SWnh7u6otu65CyDlfBItd1c19ZIjnHYEhLqu?= =?us-ascii?Q?l3T7mmFUBjaBqUuRafggCbvZadeSo/TeWscVy60Xa7lyHpsKxHyrW7McB8qj?= =?us-ascii?Q?BoB7tNeVblK1lbBFs0kolijWbafGBTvYS4KLQ3TzysdEhMz5daud0LrAA7AE?= =?us-ascii?Q?QaWkGx0apl7QIVa5MUlFTfyFbe25X8oY2XedxHwQJanGr/YEYT+3SVRN5Euq?= =?us-ascii?Q?FrRQfQrpV/PJJbXGw/+IIQ54lF892k8A8dPs4HbiilJF1rxK1LVzNdo7+Os+?= =?us-ascii?Q?oZs8UdF31s5PCHoW5l7qQ6gziGquibMqHb+i?= X-Forefront-Antispam-Report: CIP:165.204.84.17;CTRY:US;LANG:en;SCL:1;SRV:;IPV:CAL;SFV:NSPM;H:SATLEXMB04.amd.com;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(13230040)(376014)(36860700013)(82310400026)(1800799024)(7416014);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 15 May 2025 22:56:40.3773 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 9ccd0999-9095-49d3-9e59-08dd9403c13b X-MS-Exchange-CrossTenant-Id: 3dd8961f-e488-4e60-8e11-a82d994e183d X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=3dd8961f-e488-4e60-8e11-a82d994e183d;Ip=[165.204.84.17];Helo=[SATLEXMB04.amd.com] X-MS-Exchange-CrossTenant-AuthSource: BN2PEPF000044A3.namprd02.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: SA0PR12MB4368 Content-Type: text/plain; charset="utf-8" Configure mbm_cntr_assign mode on AMD platforms. On AMD platforms, it is recommended to use the mbm_cntr_assign mode, if supported, to prevent the hardware from resetting counters between reads. This can result in misleading values or display "Unavailable" if no counter is assigned to the event. The mbm_cntr_assign mode, referred to as ABMC (Assignable Bandwidth Monitoring Counters) on AMD, is enabled by default when supported by the system. Update ABMC across all logical processors within the resctrl domain to ensure proper functionality. Signed-off-by: Babu Moger --- v13 : Added the call resctrl_init_evt_configuration() to setup the event configuration during init. Resolved conflicts caused by the recent FS/ARCH code restructure. v12: Moved the resctrl_arch_mbm_cntr_assign_set_one to domain_add_cpu_mon(). Updated the commit log. v11: Commit text in imperative tone. Added few more details. Moved resctrl_arch_mbm_cntr_assign_set_one() to monitor.c. v10: Commit text in imperative tone. v9: Minor code change due to merge. Actual code did not change. v8: Renamed resctrl_arch_mbm_cntr_assign_configure to resctrl_arch_mbm_cntr_assign_set_one. Adde r->mon_capable check. Commit message update. v7: Introduced resctrl_arch_mbm_cntr_assign_configure() to configure. Moved the default settings to rdt_get_mon_l3_config(). It should be done before the hotplug handler is called. It cannot be done at rdtgroup_init(). v6: Keeping the default enablement in arch init code for now. This may need some discussion. Renamed resctrl_arch_configure_abmc to resctrl_arch_mbm_cntr_assign_co= nfigure. v5: New patch to enable ABMC by default. --- arch/x86/kernel/cpu/resctrl/core.c | 7 +++++++ arch/x86/kernel/cpu/resctrl/internal.h | 1 + arch/x86/kernel/cpu/resctrl/monitor.c | 8 ++++++++ 3 files changed, 16 insertions(+) diff --git a/arch/x86/kernel/cpu/resctrl/core.c b/arch/x86/kernel/cpu/resct= rl/core.c index 6859566398d6..b59f5db96016 100644 --- a/arch/x86/kernel/cpu/resctrl/core.c +++ b/arch/x86/kernel/cpu/resctrl/core.c @@ -514,6 +514,9 @@ static void domain_add_cpu_mon(int cpu, struct rdt_reso= urce *r) d =3D container_of(hdr, struct rdt_mon_domain, hdr); =20 cpumask_set_cpu(cpu, &d->hdr.cpu_mask); + /* Update the mbm_cntr_assign state for the CPU if supported */ + if (r->mon.mbm_cntr_assignable) + resctrl_arch_mbm_cntr_assign_set_one(r); return; } =20 @@ -532,6 +535,10 @@ static void domain_add_cpu_mon(int cpu, struct rdt_res= ource *r) } cpumask_set_cpu(cpu, &d->hdr.cpu_mask); =20 + /* Update the mbm_cntr_assign state for the CPU if supported */ + if (r->mon.mbm_cntr_assignable) + resctrl_arch_mbm_cntr_assign_set_one(r); + arch_mon_domain_online(r, d); =20 if (arch_domain_mbm_alloc(r->mon.num_rmid, hw_dom)) { diff --git a/arch/x86/kernel/cpu/resctrl/internal.h b/arch/x86/kernel/cpu/r= esctrl/internal.h index 3b0cdb5520c7..85ebf60a9f1c 100644 --- a/arch/x86/kernel/cpu/resctrl/internal.h +++ b/arch/x86/kernel/cpu/resctrl/internal.h @@ -214,5 +214,6 @@ bool rdt_cpu_has(int flag); void __init intel_rdt_mbm_apply_quirk(void); =20 void rdt_domain_reconfigure_cdp(struct rdt_resource *r); +void resctrl_arch_mbm_cntr_assign_set_one(struct rdt_resource *r); =20 #endif /* _ASM_X86_RESCTRL_INTERNAL_H */ diff --git a/arch/x86/kernel/cpu/resctrl/monitor.c b/arch/x86/kernel/cpu/re= sctrl/monitor.c index c3e15f4de0b4..51a99b8e69d6 100644 --- a/arch/x86/kernel/cpu/resctrl/monitor.c +++ b/arch/x86/kernel/cpu/resctrl/monitor.c @@ -436,6 +436,7 @@ int __init rdt_get_mon_l3_config(struct rdt_resource *r) cpuid_count(0x80000020, 5, &eax, &ebx, &ecx, &edx); r->mon.num_mbm_cntrs =3D (ebx & GENMASK(15, 0)) + 1; r->mon.mbm_assign_on_mkdir =3D true; + hw_res->mbm_cntr_assign_enabled =3D true; } =20 r->mon_capable =3D true; @@ -536,3 +537,10 @@ void resctrl_arch_config_cntr(struct rdt_resource *r, = struct rdt_mon_domain *d, memset(am, 0, sizeof(*am)); } } + +void resctrl_arch_mbm_cntr_assign_set_one(struct rdt_resource *r) +{ + struct rdt_hw_resource *hw_res =3D resctrl_to_arch_res(r); + + resctrl_abmc_set_one_amd(&hw_res->mbm_cntr_assign_enabled); +} --=20 2.34.1