From nobody Sat Feb 7 21:19:49 2026 Received: from NAM11-DM6-obe.outbound.protection.outlook.com (mail-dm6nam11on2086.outbound.protection.outlook.com [40.107.223.86]) (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 0AF6D1741C9; Tue, 6 Aug 2024 22:01:19 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.223.86 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1722981682; cv=fail; b=KRh6ww1y/3wRMcneRYn5zcORnwUZ9wmJsltTth3py6CEilCIEZh8/Pz3fYdCHgbWi4K+sun+66vR965+ZXlViNoVjmr0UlW2S/bCjN1OIh8qM0f8chqiIKvNq2OF0dtuzDjYWkcSE2phHymC9lG7vUDKzYg/+IXj50NCzXsYENg= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1722981682; c=relaxed/simple; bh=HhvtIO+1v3ip1SgrquzqqTlZGxdUMkemART2Ha4x8Hk=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=sHqreCNn2P9OLxNkuFFJKylfE+PamXiB3z+LQURKwJew+p6Qok31UzKxv6ws4Q23ZU6T9yV9jPYM7faQuvyTZt0tmswZ2PLIM0XYfl972/glcl5UvOl/ZjenaZNT+MDsbZW5UpV55obXVndLmldO6V77YsDH1P/WgVaBTMKxAXM= 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=K+p+npvY; arc=fail smtp.client-ip=40.107.223.86 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="K+p+npvY" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=CJgTM9hqTRn6mULfzm7ieVFhQyLEuTTOjJXWYN8lF6zs6k/B9Hl0Y5x0aSxAVonGG1rlyukOOmRs7WbhsnnR/1bftH3Od+UCrUs4XNphcmci+KfIwMouJ9DKsIPD0A/spZAnRlptbyLcm0MNgHiNfdr4y8I3uguFWJxnYdLPWqLqXuBxn1+QKsFYhN3mcylRY+6sQvwBvpUE9/67zQStCIZpo/oPyOP06LuKLOrb99XCj4p3FRTc35ErN82b9TVTBoCZ+o5xcb+PL+oV+UE4UUTkAj0SmjeLXHVk7WKfa+qL+ZODVpsVKvcEJDu3BtGtOdCjCrHz3JXSGndd6YWGrw== 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=NHH64LIbbtre7Zdtdv7NLazKdshn2F8/Lvht34dsMDw=; b=NBk7AUtkp3DoRBsRDB4Z26QeRqSkjIyFLGHZ/zrZsTyqBdYgX13wkaG5f6e8bIcWeXBHlicdN/wZD+bW1A9wdYLEKyhR/S+N9Da7ZJExSYZZw6y3IGRO2Tht1nZdyhDSNJPWs+lIFLgiUCJ2rRhMCm07u39QHc13JjMzIyGgCl/Tr3nB9ZF45GTyY2Q/iUXajozYE5sdpNJd56Go0BwHeZai/BpL2lXcufQU5m10l2Teh+wRfakhbasfD/wO9lAy1s9pO/E4HyO5uRJzRE9jN7mkrxDc51iGre6EN0CDHiAymTfaeqaW+DPxyZDFklfCicXw2yFYFrnyPJgSF3HU7Q== 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=NHH64LIbbtre7Zdtdv7NLazKdshn2F8/Lvht34dsMDw=; b=K+p+npvYcS0EjPANrYT7zw1fPYHgBcxoJ+1my49blkT0qgLVpEDCs1ViCJYfG4FXLYLqBSBpHOsP/ZXg8hvpIC103Y65Q3QYnXG1ZJ5Iy66oZPZhBs+oeNcDcGqW0OwstxdecBirN7rQs+t10omyNcmwinwcmk7L6o3r5/3yFTA= Received: from PH7PR02CA0003.namprd02.prod.outlook.com (2603:10b6:510:33d::31) by MN2PR12MB4173.namprd12.prod.outlook.com (2603:10b6:208:1d8::10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7828.29; Tue, 6 Aug 2024 22:01:16 +0000 Received: from SN1PEPF000397B2.namprd05.prod.outlook.com (2603:10b6:510:33d:cafe::73) by PH7PR02CA0003.outlook.office365.com (2603:10b6:510:33d::31) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7828.28 via Frontend Transport; Tue, 6 Aug 2024 22:01:15 +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 SN1PEPF000397B2.mail.protection.outlook.com (10.167.248.56) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.7828.19 via Frontend Transport; Tue, 6 Aug 2024 22:01:15 +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; Tue, 6 Aug 2024 17:01:13 -0500 From: Babu Moger To: , , , , , , CC: , , , , , , , , , , , , , , , , , , , , , , , , , , , , Subject: [PATCH v6 01/22] x86/cpufeatures: Add support for Assignable Bandwidth Monitoring Counters (ABMC) Date: Tue, 6 Aug 2024 17:00:38 -0500 Message-ID: <72b61576c5101f6d325c2384f838cb475c7aa576.1722981659.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: SN1PEPF000397B2:EE_|MN2PR12MB4173:EE_ X-MS-Office365-Filtering-Correlation-Id: b45be339-e6b7-4a24-5ce4-08dcb6634af8 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|36860700013|1800799024|7416014|376014|82310400026; X-Microsoft-Antispam-Message-Info: =?us-ascii?Q?QzO87bzBudajmk5sQbkYm7FEPbrikMbxtcLIe/t0n5rD4cJ7QPdH3idRvSer?= =?us-ascii?Q?R2+YOxthejpEFR4QBeheaRhAeOtAUrfdz3zpjBKCwokqJ9cgUml7x2RkmxkZ?= =?us-ascii?Q?Kvb9UbJXebxYd/NC+Rtibhu4SQb/TRRtgJre+EZDOJs0iJpZYatSroGEU+kk?= =?us-ascii?Q?8UWInVlhnag0JOcJpX9vFBvn1OJO6+/SUFoQ6IRxgbzv3xjEHQYu6/+H8h2X?= =?us-ascii?Q?o6Wy8QM25N8ec8qCg3wpEK0Et8YR06Qi9EGaYolGfgMrdO29ED87602hBNsV?= =?us-ascii?Q?PnvGPlp7O1aU9Ss+XnzjSPOVpnP8ZZFMqsVB3XjvUdbf89n8WUiulpM4cgKI?= =?us-ascii?Q?24SZcBP4OATGwHafJqZqGMl2816YR5wJjSBWRvZeAY0PP/7Q6DsEVhNViSH4?= =?us-ascii?Q?gv2adqDrlb+yoAefaajKKy+Xe8TxVNQHGFtGhpTmAPr2brQhL4LJwAUzaChe?= =?us-ascii?Q?aAHYjHxZAF3wAwKVS75YBDcP0zNjenOQHyfg5hMtxmmDF6hKJhkeDjoaNlLN?= =?us-ascii?Q?VGOZFh/PfE9hykAlkCxgAqV+0c0byiFCiy/Zr5dJ4YQzYTj/o1bBMZo+Fu2q?= =?us-ascii?Q?lek3mPsL3Ni0gEGuM0VZ1mCuzst0HXjUvU3/VSHFRtUgnLXiGc2TrvMyUzdw?= =?us-ascii?Q?f7oG1GB02wApoGsiSbQjtailtp/ZJuRsS+qhdgppSVTnGfa6xB8GN8mbYi5g?= =?us-ascii?Q?t1Zb88WQOzvS9xt4Rq3ILeR4vdPBZ4/hJIHzpAJebFAsQj/mVVcuCPXgWHKm?= =?us-ascii?Q?UsJ6UscRoiK9Xw9CwxBUqdjDTdBfBXi00iKT5l7YbhsZ5QYYmB4BokKkE0mA?= =?us-ascii?Q?mKtbJ8NsuNQQ0YlL/nNJbI7Zig77LFDHcqbKJz9IbpeAvh5LvduTryc/tpYz?= =?us-ascii?Q?AvSYY3X+8riUNfaYFyU7HsPBy4Ip5RqhZJyaWrHZClOvBMhuOZRarCeFfNLu?= =?us-ascii?Q?0tO4QLjxnQyJFvEG7Lp08j1/qf6eu2f+f//V5FyGQeKJ3HM1fRvEZxUL2iVG?= =?us-ascii?Q?Xn5Kj+o3c553aVC4vKYyQ36yUiKObw8cER7teqxwYL4wUjeYRpYRPIuUuFPr?= =?us-ascii?Q?fcAdcR1zarpIsBaQ8lB+Vs8DkIYOsm7pJ36I3+MDw0qe+i+uPFZJZohUB7YA?= =?us-ascii?Q?KFVp2eKn16hpmDE4x3c9dO/rIzZfwxDAAlyc+lOtEkrvtCPLbVvhCJZKY2Dr?= =?us-ascii?Q?n404pM25x/uGC57KK7pFhVKOgXXM8zrvZQi1LrvDGv5h+NZxh5iutunpj256?= =?us-ascii?Q?Anjpr6xMxaInU+4L0lSTeddlgMisW8v44EKHqaub9y4+XfwiXjtTe1e1RNw/?= =?us-ascii?Q?4xbBmyEUwNLQbfjWCe4SI1Tnc3SK5K4PIcUwsvkbMZN/relkoMSdEQN068xG?= =?us-ascii?Q?wAsBgGSIoFv/u6SZun9h4Vp0/ou+/o5F4dL3KeXQKt/TxkJApA=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)(7416014)(376014)(82310400026);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 06 Aug 2024 22:01:15.4794 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: b45be339-e6b7-4a24-5ce4-08dcb6634af8 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: SN1PEPF000397B2.namprd05.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: MN2PR12MB4173 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 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. Linux resctrl subsystem provides the interface to count maximum of two memory bandwidth events per group, from a combination of available total and local events. Keeping the current interface, users can enable a maximum of 2 ABMC counters per group. User will also have the option to enable only one counter to the group. If the system runs out of assignable ABMC counters, kernel will display an error. Users need to disable an already enabled counter to make space for new assignments. 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 Reviewed-by: Reinette Chatre --- Note: Checkpatch checks/warnings are ignored to maintain coding style. 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 | 3 +++ arch/x86/kernel/cpu/scattered.c | 1 + 3 files changed, 5 insertions(+) diff --git a/arch/x86/include/asm/cpufeatures.h b/arch/x86/include/asm/cpuf= eatures.h index dd4682857c12..9dc54d24e8a5 100644 --- a/arch/x86/include/asm/cpufeatures.h +++ b/arch/x86/include/asm/cpufeatures.h @@ -473,6 +473,7 @@ #define X86_FEATURE_CLEAR_BHB_HW (21*32+ 3) /* BHI_DIS_S HW control enable= d */ #define X86_FEATURE_CLEAR_BHB_LOOP_ON_VMEXIT (21*32+ 4) /* Clear branch hi= story at vmexit using SW loop */ #define X86_FEATURE_FAST_CPPC (21*32 + 5) /* AMD Fast CPPC */ +#define X86_FEATURE_ABMC (21*32+ 6) /* "" Assignable Bandwidth Monitoring= Counters */ =20 /* * BUG word(s) diff --git a/arch/x86/kernel/cpu/cpuid-deps.c b/arch/x86/kernel/cpu/cpuid-d= eps.c index b7d9f530ae16..5227a6232e9e 100644 --- a/arch/x86/kernel/cpu/cpuid-deps.c +++ b/arch/x86/kernel/cpu/cpuid-deps.c @@ -70,6 +70,9 @@ 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_ABMC, X86_FEATURE_BMEC }, { 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 c84c30188fdf..87f63e6b2994 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_PERFMON_V2, CPUID_EAX, 0, 0x80000022, 0 }, { X86_FEATURE_AMD_LBR_V2, CPUID_EAX, 1, 0x80000022, 0 }, { X86_FEATURE_AMD_LBR_PMC_FREEZE, CPUID_EAX, 2, 0x80000022, 0 }, --=20 2.34.1 From nobody Sat Feb 7 21:19:49 2026 Received: from NAM11-DM6-obe.outbound.protection.outlook.com (mail-dm6nam11on2071.outbound.protection.outlook.com [40.107.223.71]) (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 89A48175D49; Tue, 6 Aug 2024 22:01:26 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.223.71 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1722981688; cv=fail; b=D1u4Iv7Hj4MQ8P85LTsIo0JHKpk9CHlm6NLV9OY2TJl7RmTe2zL4C2P+GBWs8hQt/C0wZlEWu61wnQM26Z2tPL6Imw47U80/EwJvYNyX2USgVLxccpYmFXbqLVyQmWAu3BfSY5YahphF5PNxqiBx4SALZQyFjhJppbjrM2adzDE= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1722981688; c=relaxed/simple; bh=64i0stlMlNtrUcFXypFdFgjh4lXZANJHVINBe7qWXYw=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=UUrpfGEGSLf21IhMslS3Pvia42UhISMVGLkdJoApG2yjsKLMZ2BSgpKRARRrXPV5nL9vu8UTIo8FldCajC0ILopyXg2C4EjsqlNymy18QMZ+NnBOpYT8ohv9p+17I+PSCNMOdz+FRrFAbwHddIhuawT+UF1dl5BlJu4VkfaWFow= 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=3n/h0tRY; arc=fail smtp.client-ip=40.107.223.71 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="3n/h0tRY" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=j1D/RGAQWs6ysdBH2wvC74ftYWHfSF5PFJ/x7wRRHj834VDyI4JJ2nSdOyTRVCV9tqNCcptE6pn1OXfSysCOQfRRw/nTvXhZIPLOcsGvVikYas91iSbk6QDkAR4+PRUVFoTIl68UwrTtMNPfrphVk0+KECQobpu4FMn8e0TK2gwXbk9GMggWq/Zs2JfxuH5C3+uypXDKSFrdvbVUoEenJJq6r6TLFDle4m7wBAX2fCt68V7574DJLcru4Q9J6EJhkQie/VBsbS5EGpnEEfIMI5Ri3im3QNl/DGLcIoHPTjIA+7VdcbXxlwTOJlhcGhc1XHd55sTP2uxG01+DFWaHLA== 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=oTocGwrdRAYMvkHNg/Y9e+x7YokfWdg67s9eErxQn5Q=; b=Ow+9nTJbiYMh+iuwGahSGRXIDj7EjmEVjVXOBpBrg1yPwovm0b5PQprdqF8VMMDyGhE7nlNIjBPLPPgFvAFl4O6qSKaNfImq/zi78qxgTCmeFjRM7PXCf9C9i3frzZsP8Y94Q9cZGVvNsREp+yuuSYX19owVaexzRcHKtWg3kG2UV2/Fuo/Evh1n1lBNkwZw11ZEOa63Hue4W434KpkBzMIoXJVRF9P4jyOsGNwbeGVd4jqjL2yYJg05MfdDRSU7BYacQyLITecdhFPv2yhtw+byEPjLwGus+wsHS2bwBr3KGhEUxGdBgb6U89kyC5wfYrp/cMq1hz/MJhGx4mzKjQ== 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=oTocGwrdRAYMvkHNg/Y9e+x7YokfWdg67s9eErxQn5Q=; b=3n/h0tRYfrAfRmlQZ2YjH+KwN1aAGFcalmkj88uEGnfbVoctC0kRDqD7YrE/NkbRZ9lYx44KXUKtnrvK/44ZTA+hUh0IlWOt5lmvRQsyVkNhVPVPygjtfnKy7cnHWi2H1wQraHTrDKNSRvVnz0QWTIas5SuG/YtPE5sYrKo4h3c= Received: from SN6PR2101CA0014.namprd21.prod.outlook.com (2603:10b6:805:106::24) by MN2PR12MB4237.namprd12.prod.outlook.com (2603:10b6:208:1d6::7) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7828.29; Tue, 6 Aug 2024 22:01:23 +0000 Received: from SN1PEPF000397B1.namprd05.prod.outlook.com (2603:10b6:805:106:cafe::5e) by SN6PR2101CA0014.outlook.office365.com (2603:10b6:805:106::24) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7849.7 via Frontend Transport; Tue, 6 Aug 2024 22:01: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 SN1PEPF000397B1.mail.protection.outlook.com (10.167.248.55) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.7828.19 via Frontend Transport; Tue, 6 Aug 2024 22:01:22 +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; Tue, 6 Aug 2024 17:01:20 -0500 From: Babu Moger To: , , , , , , CC: , , , , , , , , , , , , , , , , , , , , , , , , , , , , Subject: [PATCH v6 02/22] x86/resctrl: Add ABMC feature in the command line options Date: Tue, 6 Aug 2024 17:00:39 -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: SN1PEPF000397B1:EE_|MN2PR12MB4237:EE_ X-MS-Office365-Filtering-Correlation-Id: 153db038-a8fe-49ef-44b9-08dcb6634f02 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|376014|7416014|82310400026|36860700013|1800799024; X-Microsoft-Antispam-Message-Info: =?us-ascii?Q?nhknu9Ca1AGIeycVn1ubQZG8IjinDjRt2MHjGJxIxNCi46BDH/crZ2Jb+74i?= =?us-ascii?Q?C1SzER54ykD00PXRULW7Zz0OFu2KnyPwOSrAPBouKp24ODC1MPSYNwZYugzf?= =?us-ascii?Q?b+IgvhMryXfNI+uITjY7sYQbaME+MdnwQ5fM1DzWx/MC5ZbV1jEOElQ8qfXU?= =?us-ascii?Q?N2H5r3K6SXmmye6cm7idrlpE+l3J2qDFf4RS+0NGk6qTlht0vHpvufWyDkTp?= =?us-ascii?Q?p6W4U387ZXmKyMTTHB42OZXshRDlYZJLZUWnINyUyv/p3lLhT1uzsQojR1j3?= =?us-ascii?Q?184Mmn+5rkQQ4Ap0g8f2ckYhadKChQxwZCwBLNsXeHd4pVvTSckdNNWLbT+K?= =?us-ascii?Q?nGTqEuZ1Xt1pWHuRF+sPqDyeMWCtdV+4zSEfj+KEXDpJCaK2JoTSnNvk5YTC?= =?us-ascii?Q?ZswuNpDSXwMT1lwkxKLHShPMNzJuZYP51UKiEwN6Tyeo8AcIFw4Pw6qEfFPG?= =?us-ascii?Q?ldY48ZkZupoIYR+Aa3wLa9s7xNrtisw3VcEdjwudATDYzpKLaC+XyMQPPm70?= =?us-ascii?Q?zSDl1i1W/KLcM7JPMg1zbD+6An93LGoNr7npD1ELL2riZuZ3yr5v+JlZdmv8?= =?us-ascii?Q?KUaqMTSY2l02L23EvMQl/41kHYrYbzzgxsuJvkG4PKMo+BSarJAl7QjCMD6K?= =?us-ascii?Q?1mgvhGqNDoAsehBmvXct23e2UF3mbdzvHaBf5QNnvaGmqt5k251NY+4g61RN?= =?us-ascii?Q?yLgK0AGeaX0EZE2i7caJiNA+cY5pqeG3cQNG66FPPdljLLJI7rFoGt44d/hs?= =?us-ascii?Q?6e/+lqRhwYhO0tHT1R66QgnlpxVSiCRu9r7Xkdi0WoMoS+bzt05pw+ryvdpp?= =?us-ascii?Q?+HiChGbBr7lZ8TYzBgYqc1Cr8VbkRjDWztiDXnWEUWjHLDZVwyUye64/TbKV?= =?us-ascii?Q?BoAQ5DhKfdNF6iEalfohD3icfKS8IQjz9pNXTnYPa2rWHx7+4aqIi8qeRue+?= =?us-ascii?Q?TGNSneCnlXMRxSzx54Wa9HN7CF0F8ibQGbALhaxoU83qioB2whdSgelanW1T?= =?us-ascii?Q?SQKZvjINq2NIZG1SymdZcxVGWQ1WKmaHyjzkeBCeLZBVOL3vLZpKCLHlvI14?= =?us-ascii?Q?TnGiNXn4EdtwCPntGD3RuD2/ydsuOxS9c89Q9UBOOwXRrgPPDTihLVK07N2v?= =?us-ascii?Q?CGxYiBrXdoN6QPl5EL6eoYboCFYQVGKsChbf2Yyn6Zgcdx4ns+CyleKEetvR?= =?us-ascii?Q?rK4KQA4UrXhBB2AnllYaHeIBk8AXRrm3NxF2OAapLks4vPjILXq72TcScjpD?= =?us-ascii?Q?o64Q8ZGd6lTNsEJmoUihGiVT/UcnUi+XcO7jqi46zB6UpdueY0yaaF5OllFk?= =?us-ascii?Q?Xml9jw0W5EtVmYdt2YKgwJIW51Cr51BByqpiKJIXZ8dQsJV887cUbWm9WgyL?= =?us-ascii?Q?vZvymoHHi0rBxyoQ+zSIVokyZJ3MZuir9jCl9h7o/2KUed4jdzk8ToitbKrM?= =?us-ascii?Q?isYC2mIJFg2/zE0f28KzjlHZP91s2tdl?= 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)(82310400026)(36860700013)(1800799024);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 06 Aug 2024 22:01:22.2396 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 153db038-a8fe-49ef-44b9-08dcb6634f02 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: SN1PEPF000397B1.namprd05.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: MN2PR12MB4237 Content-Type: text/plain; charset="utf-8" Add the command line option to enable or disable the new resctrl feature ABMC (Assignable Bandwidth Monitoring Counters). Signed-off-by: Babu Moger --- v6: No changes v5: No changes v4: No changes v3: No changes v2: No changes --- Documentation/admin-guide/kernel-parameters.txt | 2 +- Documentation/arch/x86/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 09126bb8cc9f..12cc0a26c82a 100644 --- a/Documentation/admin-guide/kernel-parameters.txt +++ b/Documentation/admin-guide/kernel-parameters.txt @@ -5604,7 +5604,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/arch/x86/resctrl.rst b/Documentation/arch/x86/re= sctrl.rst index a824affd741d..30586728a4cd 100644 --- a/Documentation/arch/x86/resctrl.rst +++ b/Documentation/arch/x86/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 1930fce9dfe9..9417d8bb7029 100644 --- a/arch/x86/kernel/cpu/resctrl/core.c +++ b/arch/x86/kernel/cpu/resctrl/core.c @@ -801,6 +801,7 @@ enum { RDT_FLAG_MBA, RDT_FLAG_SMBA, RDT_FLAG_BMEC, + RDT_FLAG_ABMC, }; =20 #define RDT_OPT(idx, n, f) \ @@ -826,6 +827,7 @@ static struct rdt_options rdt_options[] __initdata =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 Sat Feb 7 21:19:49 2026 Received: from NAM12-DM6-obe.outbound.protection.outlook.com (mail-dm6nam12on2065.outbound.protection.outlook.com [40.107.243.65]) (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 2C0AE176258; Tue, 6 Aug 2024 22:01:34 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.243.65 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1722981697; cv=fail; b=kFX+R9EhsIfoAzN43GYEVLr7obWSHQDGNy6jhWR/OVqpzZBNTdEg9SeMjZpeTaNboVcf40bmFk5QCwDvqnphXj8HqDexTbrwEOV1VV5rs47n5RWYz21gpQ5Y3fnY/kkBD/2a7tYgW9BgizKrMQ+zoVPz/QfxRlN9Qi2DmW2RMzU= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1722981697; c=relaxed/simple; bh=qNfh4CH6xN+ztSVYjf4UOf2ukTP4LVNyCP7eV252dBo=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=jww9UwCUtCqUdeHMwlp1cef62rrtsnpGOpRMoXFIDFog7J5vlLz1m4Y2da5k3KFfo7xbSbo9DmBw+KZ9NTBjF+HJo+QA5K3oeQM8VrTOsaD3UdnqOwLbs3l7XeF/eh/vbK4O9AVlda+EW+4Z560jEE44/B66w4mqNMNX/1DsGes= 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=lHslYEMM; arc=fail smtp.client-ip=40.107.243.65 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="lHslYEMM" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=hZF912n4izNKae4lKXZwRYcTfl1hPUyarHWB29XB6Lvc+ydFXRI0WNTB2fYGzVBP5qOzlswzL1clXUQfsJVeNfdkDA0vV+2Lx7WcpaPOzkrLZtjq4Be/xoLD2ohOM49ysjtguj9bl5nr+YcNgd/7g/o4RRKxfA7DqM9XqydnEdpbuUkby0IUbV3Mq3vsLQezvabCgft3P7OEIaie/z2OD/DsCVgrkmg6b6PC/dyyi5foPQZEUVkajg8T9lgbt8IGef4amCGm6xWVA1/Zst76Yq6RQBkADKn0L55FnollwySPq1fxJUHgySw+RssMlHqrZzuH/dMtIzA/3RRNiE3JdQ== 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=tLHXNrpDpZngrnCAhg9RbHTmm4sLrNGB0V58UWDthB4=; b=vAIjg77Z0qo1pPYmBUQ2POpar/PAAdWvwWMtIbnE2VB5dFPMdP7mnthWt4lI43fisS6K0la/9qwA45kU5VPjtYDB4j+sVckVDhjYLepiv1MygAYqJUPZU2oETz8IEFtzD4TFZjHDmrmxOQzmHElSqQ/PGZSz+f9hhqO78nErXOsBJ9NFni/U2YFKHkF02h1A96x/+zpkDHB+K7DYNOPgaf1lFhmZ3SzzbUrK/4deJjiSOnvmHtgQVcH+K/3NjoksvQnZMOP3Kai0pvSi7gp+nGmVWuTyAsFzcmUJogqWad8vFNXXyE+GxZffpUOM6SrBk2yBN8UzQTbtRZhve4yeuA== 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=tLHXNrpDpZngrnCAhg9RbHTmm4sLrNGB0V58UWDthB4=; b=lHslYEMMeKzhS8KHCI+HVKwrWvR9MJyp3MCSfANlnZHmz4XMEjjnRsnT9SuvBoIxHfC+nkYqPfuldWYbIQuyJM08t0W6omi4BSGb8aUglEan8R+KvKQvHOEQyhoRLcIMJW9N3QmuT2db5hHDi962xZDU+lFpszF7l46m2whSteY= Received: from PH3PEPF0000409A.namprd05.prod.outlook.com (2603:10b6:518:1::46) by CY5PR12MB6084.namprd12.prod.outlook.com (2603:10b6:930:28::7) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7849.13; Tue, 6 Aug 2024 22:01:30 +0000 Received: from SN1PEPF000397B2.namprd05.prod.outlook.com (2a01:111:f403:f90d::1) by PH3PEPF0000409A.outlook.office365.com (2603:1036:903:49::3) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7828.20 via Frontend Transport; Tue, 6 Aug 2024 22:01: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 SN1PEPF000397B2.mail.protection.outlook.com (10.167.248.56) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.7828.19 via Frontend Transport; Tue, 6 Aug 2024 22:01: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; Tue, 6 Aug 2024 17:01:28 -0500 From: Babu Moger To: , , , , , , CC: , , , , , , , , , , , , , , , , , , , , , , , , , , , , Subject: [PATCH v6 03/22] x86/resctrl: Consolidate monitoring related data from rdt_resource Date: Tue, 6 Aug 2024 17:00:40 -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: SN1PEPF000397B2:EE_|CY5PR12MB6084:EE_ X-MS-Office365-Filtering-Correlation-Id: 223c4989-7333-40d5-98ca-08dcb66353eb 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?fNpEjGlLREoyjSbCH3ALPB+3rzUXUP1OkcgqSyRMycp1FqQdXJiRpNWiB/TI?= =?us-ascii?Q?5chjjI5T1vzrgIMEk2ZN5z0H+AfSpMMqVYuvl4DIfH5FY0PnW6qy8fMt+zal?= =?us-ascii?Q?J6Uvh19iwEZTuskj5epEzA/TVPmSh1zZ2houd+BPlIEmTMhT5DjBQ0X0ZmbI?= =?us-ascii?Q?V86HbbRZVqvQaoPKXGf26lsJWYDI3eXOcuNIGJ1L0dIukT3xiPsevtZTdu+8?= =?us-ascii?Q?9E+cKS2gdus3C/PCasfY1uKMslAAUv9d3e2LgHKLwWxd+wOiIXAyvMW7JU2/?= =?us-ascii?Q?0cxj7jI08kvlNGoyDEkTrixqMB/+wxDKA1zTpmK87egjSB4Ylu5G9NQ+ze7u?= =?us-ascii?Q?EQsnsYseRqQ0U5WEdJhRcc9KOyK80zW76PhO1eiYQKmr5BAx38lMox82ZAV5?= =?us-ascii?Q?lk+qzsno3HKzBNPUtj1P5eW4YbJE49zxSAq7ri7pg8/5n9mYZCdD99AVy1Zn?= =?us-ascii?Q?Z/0Zq/cv8ZbPD8MaQiP8+BRl99yjjR7YzDxtvYx4SwX3kq9PLkFAkcH1bJRo?= =?us-ascii?Q?JCVD/sTbXpgiM5PIUIpw0vrAVsWD/2UxVZEH4XIc1zxzD5gOAvs0ujm2cWe1?= =?us-ascii?Q?DeTQuNkMyVEg9ClkfyoHxPMRLG9SijImr+Irw8tqVl0kdZBzkeWfwo0773Kc?= =?us-ascii?Q?tEJmSHqqzHCZAuyCp3VdfXbvlVAGxV/D/AZ57MsTFIFDn2wnIIsWGYjktXv3?= =?us-ascii?Q?KerUpo9Zk9NIvevTJPGWReaOk56PhSmSZ0OlcarAd1LeBkfaDaD7y7f5uEzZ?= =?us-ascii?Q?LDwnQRPXFx4k2qiCU8SSjbyyTfckzXmejOX2auoFCCFwXLEpivZb09OfBiLg?= =?us-ascii?Q?u1EgHHkMbuX/sg26cF+N+mukXKZN4wTUU5W0g6vyXHpAfDJfSPHeAMZloemv?= =?us-ascii?Q?CAZphy6U3SjzaDI2L6Zjew5BEAJGP0Seml2TUIiPzlim1+lznC2vQdNMP6xj?= =?us-ascii?Q?xvTopjD3wq0IJIE53iGRrDSuWA1mPh7ptL8jtHnMYWFCakCF2VOcpCGyDVb3?= =?us-ascii?Q?DICbDN5abyZ9EJtfuZ8WTGarD3ON98oe2sqVyeHCkPc5FloytIcEWwXWfZeT?= =?us-ascii?Q?7TA06PatkuPe8ypwTVQG6m4bakEFoyyzEq0rnDTJ+7a6Cr7555E834fGxm52?= =?us-ascii?Q?A6AY1qdUx8YuRSBMABLHFS+FBQLxV3F28W+KtdTfe4RkiGvmmBydojHaN2Si?= =?us-ascii?Q?pRwbwkjY3hp6j/c9FAlXLVEX4ryNHqKKZBgzKFNn353Xcn+0dz5oNwkybnAL?= =?us-ascii?Q?pxBD56PGg+xizYz9wqtLEWuLrWV0qM02KWL18A8qTU3nacX+8nyQ6Yn4dbTh?= =?us-ascii?Q?y7XFsiKWoeMTt7bK2MgNQWN2Y5aZ/Hj4DrOjlJs2ShDIfLUa1EnHYFNmt1df?= =?us-ascii?Q?AeZvbuXov3qcMU179kYe4MeBYKEvUY+u70tBjbzD//MFkq82BeYgUCY9fOgX?= =?us-ascii?Q?4KXpotRE+zWndhO2O65z3p78JDDm66un?= 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: 06 Aug 2024 22:01:30.4952 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 223c4989-7333-40d5-98ca-08dcb66353eb 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: SN1PEPF000397B2.namprd05.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: CY5PR12MB6084 Content-Type: text/plain; charset="utf-8" The cache allocation and memory bandwidth allocation feature properties are consolidated into cache and membw structures 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 --- 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 | 2 +- arch/x86/kernel/cpu/resctrl/monitor.c | 18 +++++++++--------- arch/x86/kernel/cpu/resctrl/rdtgroup.c | 8 ++++---- include/linux/resctrl.h | 15 +++++++++++---- 4 files changed, 25 insertions(+), 18 deletions(-) diff --git a/arch/x86/kernel/cpu/resctrl/core.c b/arch/x86/kernel/cpu/resct= rl/core.c index 9417d8bb7029..4a2d0955ccdc 100644 --- a/arch/x86/kernel/cpu/resctrl/core.c +++ b/arch/x86/kernel/cpu/resctrl/core.c @@ -617,7 +617,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 851b561850e0..795fe91a8feb 100644 --- a/arch/x86/kernel/cpu/resctrl/monitor.c +++ b/arch/x86/kernel/cpu/resctrl/monitor.c @@ -222,7 +222,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) @@ -297,11 +297,11 @@ void resctrl_arch_reset_rmid_all(struct rdt_resource = *r, struct rdt_mon_domain * =20 if (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 (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) @@ -1083,14 +1083,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 (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 (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 (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 /* @@ -1186,7 +1186,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) @@ -1201,7 +1201,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 diff --git a/arch/x86/kernel/cpu/resctrl/rdtgroup.c b/arch/x86/kernel/cpu/r= esctrl/rdtgroup.c index d7163b764c62..f9f3b5db1987 100644 --- a/arch/x86/kernel/cpu/resctrl/rdtgroup.c +++ b/arch/x86/kernel/cpu/resctrl/rdtgroup.c @@ -1097,7 +1097,7 @@ static int rdt_num_rmids_show(struct kernfs_open_file= *of, { struct rdt_resource *r =3D of->kn->parent->priv; =20 - seq_printf(seq, "%d\n", r->num_rmid); + seq_printf(seq, "%d\n", r->mon.num_rmid); =20 return 0; } @@ -1108,7 +1108,7 @@ static int rdt_mon_features_show(struct kernfs_open_f= ile *of, struct rdt_resource *r =3D of->kn->parent->priv; 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); @@ -3057,13 +3057,13 @@ static int mon_add_all_files(struct kernfs_node *kn= , struct rdt_mon_domain *d, struct mon_evt *mevt; int ret; =20 - if (WARN_ON(list_empty(&r->evt_list))) + if (WARN_ON(list_empty(&r->mon.evt_list))) return -EPERM; =20 priv.u.rid =3D r->rid; priv.u.domid =3D do_sum ? d->ci->id : d->hdr.id; priv.u.sum =3D do_sum; - list_for_each_entry(mevt, &r->evt_list, list) { + list_for_each_entry(mevt, &r->mon.evt_list, list) { priv.u.evtid =3D mevt->evtid; ret =3D mon_addfile(kn, mevt->name, priv.priv); if (ret) diff --git a/include/linux/resctrl.h b/include/linux/resctrl.h index b0875b99e811..1097559f4987 100644 --- a/include/linux/resctrl.h +++ b/include/linux/resctrl.h @@ -182,12 +182,21 @@ enum resctrl_scope { RESCTRL_L3_NODE, }; =20 +/** + * struct resctrl_mon - Monitoring related data + * @num_rmid: Number of RMIDs available + * @evt_list: List of monitoring events + */ +struct resctrl_mon { + int num_rmid; + 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 @@ -199,7 +208,6 @@ enum resctrl_scope { * @default_ctrl: Specifies default cache cbm or memory B/W percent. * @format_str: Per resource format string to show domain value * @parse_ctrlval: Per resource function pointer to parse control values - * @evt_list: List of monitoring events * @fflags: flags to choose base and info files * @cdp_capable: Is the CDP feature available on this resource */ @@ -207,11 +215,11 @@ 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; @@ -221,7 +229,6 @@ struct rdt_resource { int (*parse_ctrlval)(struct rdt_parse_data *data, struct resctrl_schema *s, struct rdt_ctrl_domain *d); - struct list_head evt_list; unsigned long fflags; bool cdp_capable; }; --=20 2.34.1 From nobody Sat Feb 7 21:19:49 2026 Received: from NAM12-MW2-obe.outbound.protection.outlook.com (mail-mw2nam12on2073.outbound.protection.outlook.com [40.107.244.73]) (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 45C87178367; Tue, 6 Aug 2024 22:01:41 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.244.73 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1722981703; cv=fail; b=CVhyx9l/QYLllfkLr0hB+wRsIhR1QZLIZFAdnrwDRK4IFq7384eJdmVG16LTrrOB0G9eNTvJvBs/7c8J99bhtlwW9rYwxsRNkSJrl/fo6GP37ggSEB4IT/wcdL1WwzkUnlEboBGIHIFU3zvZfpVQMqbkdYQ0nfdX/tub+pWaGOo= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1722981703; c=relaxed/simple; bh=NbWIzbzE7s6Ri7XnZW7Wz9oCJKnn1mutWo0j/dJWHqU=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=p1FUiJHI7zUKQuO9J9KSfjgiB8RVwWg5fH9MI1ObIHkIiq8cF8nekGd8uBfOoQB6KwsrgjIV7H4eJ2kSac0ZuvIPbsYdEW/iQuaCihpYKRY91hgU3yGaaezCz9JSzQNQlCf7waHHijDorSsipRiQDozz40kVbv82D/2AEijmH1k= 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=OSmjLn4V; arc=fail smtp.client-ip=40.107.244.73 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="OSmjLn4V" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=IAhO3e569JstEADeFiHLnxH+yJJCiq4JxjSWGoRS1lRZN/WQ+CcbaY0fBvfX841wlv2AMht4X6ziGVkLPAHJAa4oFIM35uR/k1f5trlt3bmszpS/I8DO1J1CTLyhkvcUoImfJyYYgOUckOVqx//nr7P+cwwecBBkdzSAXrDly5w3p7709mjTpcTOMHgtEKYUeQoiEHOxVHvRMVOQjemFX613hdhoGzFOiunT+Y1iAiW0BBJWAJQjBhMdgDH25tslFY1rDTQhhi+WP0W2Zl5UGEG6PXxaavvzEFVKwAMKui4JUzgR03zzwFnNU4RJvbp/m9zdV4U4KZ5DBKF3/UkKqw== 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=vhTYqUjgl3D1Z1jkJ56yVXOi4cxSBL1VgteBFkxvQXM=; b=Uv2kRhrIgICjvJin4SKzoNd5pzUucsQpKhiFI5ck42qDYzY/Mgxkj/GvKjTUIYdbjaF2AOQ/UI0fbAlp+GIpxvWKDpeWSeFFdjiTtamaZtaCGRXx1GviDeX+7YhE4ueTlWAXd+74Bnq/H8EFSGdkDacA/PRJyaWqDdXfLVN+6cTb6KgMdDjP4rlnn5WkZlta+p/bh1HGkq7LbCzT6MiJwNOy12p2r7rVodC0H1/mBl/FYBs4gmoBhuDUqxh3OdgWC/aHayPldTXH7WoodTc6yw3Sf7OynaMPUeGn/XKw5WIRLFhpczQf2ay9L7IrQUtXjzLKQRszfm8006eKU64+Pw== 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=vhTYqUjgl3D1Z1jkJ56yVXOi4cxSBL1VgteBFkxvQXM=; b=OSmjLn4VF9m8dcmfz5x1cITc+R+C+40DXWkyP9/pAWjiTwc5vEiWMqLybUvevKYPSa1TCmN5zPTuZjgP7HPPqzMBZ6ybqrX0T3iUQyFBJsAAoKb5FIWsn+hNwt+VYyzVM2ArhXeGyi8Ich9q8vWMqLd9R2vSMU2cW0nc+E/uZXs= Received: from SN6PR2101CA0004.namprd21.prod.outlook.com (2603:10b6:805:106::14) by SJ1PR12MB6147.namprd12.prod.outlook.com (2603:10b6:a03:45a::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7828.25; Tue, 6 Aug 2024 22:01:37 +0000 Received: from SN1PEPF000397B1.namprd05.prod.outlook.com (2603:10b6:805:106:cafe::79) by SN6PR2101CA0004.outlook.office365.com (2603:10b6:805:106::14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7849.7 via Frontend Transport; Tue, 6 Aug 2024 22:01: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 SN1PEPF000397B1.mail.protection.outlook.com (10.167.248.55) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.7828.19 via Frontend Transport; Tue, 6 Aug 2024 22:01: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; Tue, 6 Aug 2024 17:01:35 -0500 From: Babu Moger To: , , , , , , CC: , , , , , , , , , , , , , , , , , , , , , , , , , , , , Subject: [PATCH v6 04/22] x86/resctrl: Detect Assignable Bandwidth Monitoring feature details Date: Tue, 6 Aug 2024 17:00:41 -0500 Message-ID: <851bfbee0fd53631acae8d209796d52ce8051e68.1722981659.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: SN1PEPF000397B1:EE_|SJ1PR12MB6147:EE_ X-MS-Office365-Filtering-Correlation-Id: c34da4bb-1c46-422a-e48f-08dcb66357f7 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?IWT+Xz3H06ov8zxVoDOcLYUONg/NjpNIiKPCC37qS5jsUdD0uMwSN1Mq5CaE?= =?us-ascii?Q?sJxHyCHz0tkN680jF4xuh/w3CVVNtOQJDtRq+mnyDwGTRMNBLzyjL//ptr3d?= =?us-ascii?Q?6kBqS/f9KgvKT17THXj2XJxJE1vCT/biIqyC1U7E154On0WUEzhGqrboxko0?= =?us-ascii?Q?UNd7mIXTxHPyzpw6qL2ksYKIluBIK3UWPds6HzrqlX8qwFzkZA5Cj8hYtal6?= =?us-ascii?Q?W/GgFI2XM8LzbuNpcXNYhq632bpiFGmU95DAnxDLFLaWs0FVnjCnTGrtll/d?= =?us-ascii?Q?JZ/xmxAm7L3TwMIhOIhZTmJfmZadX1fJPP2rHpkfqCtrZOcdCkZdPhsEZNHn?= =?us-ascii?Q?uPPxxUA0K5xPRggFqZJ2G0fnyQxaFxIDeM+7aLmiX2Sks9QS/9EanRm+xcI6?= =?us-ascii?Q?ZzZaZ4Kx6diUyS2X61GEi9IxBBVdRLpm5qTE9MggAqqtO7Ws+DSpn993lBwW?= =?us-ascii?Q?JJgZsq91DXEzQa3pnMBy+T+Nv8eQ6ktonmPwJrpDFJqyg4d8Fnsu7hZLv5S/?= =?us-ascii?Q?WFgIRt80iSI/vCr/titG3w2Iu6mKj/mv4YfMOG4sfK5zdATHvcJBQhXpgJas?= =?us-ascii?Q?ftFPE0L5Cs0GrmxMbWeX39dptY1t6Zxru3Zb41bPkhoy9U0177uB25mFYX/e?= =?us-ascii?Q?f/uClLBAbhEG4vtft1au2PDuTPIal3SaWa4ovSex0zwe8QsfLqqGR8pmQSkw?= =?us-ascii?Q?vGlzxlRCQedoFikL4qYwcMLE9H6Es3ApfFzVwbvoEEw3xrwdhHRsMShC+lYQ?= =?us-ascii?Q?porsF/t1CbV7gQq0XzNx9Sdcv3VaIEeJ91GhYOeg9AZQygRSV2mTci/q753n?= =?us-ascii?Q?Lsf/MjAk/8B/+RFCPTuHVzZXUZv4rdQzobl62mXtSW230CPLP6KhklSE9GGv?= =?us-ascii?Q?RRg4IrpWI25cRncH7q79+lGz3R0FDbwsyg7SzYLuyp4oDFoSdqH5KHtDze++?= =?us-ascii?Q?Mqe96cMi+kgV70Sg3KeSISaYhNincycf5JrdFblrxQLB/VO1HFYgBDEnr3XX?= =?us-ascii?Q?0bMXkE/YFmIjyDUCWIg2G1i4ltVvrijuW0wn+cR3mofWaJvEvHcTzQ83aSwd?= =?us-ascii?Q?Qzhtpz9WMCUVelJqbxxxk99mq6peSFTBovImJZqWFtv/cdTekV7I8cd0NvuD?= =?us-ascii?Q?BTl/dBRiSRbChc6yU5AlFC8Qd9veHD2k43vjgNcgww9VTxHNkXTU2VDBjxTp?= =?us-ascii?Q?wZa3cxkL8mj4RRfH4VN8ve+kaW2WRlMIU4BCmGRbHF5QR5BhdiqJxm7HmQ1y?= =?us-ascii?Q?Ks3jdUixc3Fz9uBqqiK7aYg6mYYeZkGPnrZriDpAnvrZmfm8WjIXL+ZDBMJY?= =?us-ascii?Q?2IcOfYN9KMcCaXKHWQ2RbPyE4oB4c0D9XE/xWzy2u64vphoxpx9Ejs527boK?= =?us-ascii?Q?EOnxO/g4bSo1yLrMGsFJcWtCZvxuDZZKsTNIrn561EfJiZUBjw=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)(376014)(7416014)(82310400026);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 06 Aug 2024 22:01:37.2867 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: c34da4bb-1c46-422a-e48f-08dcb66357f7 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: SN1PEPF000397B1.namprd05.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: SJ1PR12MB6147 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 counters supported. Link: https://bugzilla.kernel.org/show_bug.cgi?id=3D206537 Signed-off-by: Babu Moger --- 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 | 12 ++++++++++++ include/linux/resctrl.h | 4 ++++ 2 files changed, 16 insertions(+) diff --git a/arch/x86/kernel/cpu/resctrl/monitor.c b/arch/x86/kernel/cpu/re= sctrl/monitor.c index 795fe91a8feb..88312b5f0069 100644 --- a/arch/x86/kernel/cpu/resctrl/monitor.c +++ b/arch/x86/kernel/cpu/resctrl/monitor.c @@ -1229,6 +1229,18 @@ int __init rdt_get_mon_l3_config(struct rdt_resource= *r) mbm_local_event.configurable =3D true; mbm_config_rftype_init("mbm_local_bytes_config"); } + + if (rdt_cpu_has(X86_FEATURE_ABMC)) { + r->mon.mbm_cntr_assignable =3D true; + /* + * Query CPUID_Fn80000020_EBX_x05 for number of + * ABMC counters. + */ + cpuid_count(0x80000020, 5, &eax, &ebx, &ecx, &edx); + r->mon.num_mbm_cntrs =3D (ebx & 0xFFFF) + 1; + if (WARN_ON(r->mon.num_mbm_cntrs > 64)) + r->mon.num_mbm_cntrs =3D 64; + } } =20 l3_mon_evt_init(r); diff --git a/include/linux/resctrl.h b/include/linux/resctrl.h index 1097559f4987..72c498deeb5e 100644 --- a/include/linux/resctrl.h +++ b/include/linux/resctrl.h @@ -185,10 +185,14 @@ enum resctrl_scope { /** * struct resctrl_mon - Monitoring related data * @num_rmid: Number of RMIDs available + * @num_mbm_cntrs: Number of monitoring counters + * @mbm_cntr_assignable:Is system capable of supporting monitor assignment? * @evt_list: List of monitoring events */ struct resctrl_mon { int num_rmid; + int num_mbm_cntrs; + bool mbm_cntr_assignable; struct list_head evt_list; }; =20 --=20 2.34.1 From nobody Sat Feb 7 21:19:49 2026 Received: from NAM10-BN7-obe.outbound.protection.outlook.com (mail-bn7nam10on2040.outbound.protection.outlook.com [40.107.92.40]) (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 8C963178367; Tue, 6 Aug 2024 22:01:49 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.92.40 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1722981711; cv=fail; b=Ke0yfJdou+1PbV0d0OLwVJ8vICtM3xerzU/s00+NRiI9EHLC0CmOsM+oWViqL2tzE0+IarJknvtjhlNTfFhtP+tmjcFhK+Nh0LkB44yPF09wVw9tjDcm0zdjxXhbkv2odoiBOfjKpuVelthrGewQ6oEgbfNn4BU28tHxxValmoE= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1722981711; c=relaxed/simple; bh=IoDdgETboZCuQUwpbvtog5loN92R1YQNJSkOnjwAf54=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=Ayc5IVUsLeStelS3TBstgbdFTJt5R5KTmxo0/Nbvz/bP9EL+/Jnq9B3Z+MwF5CQFJF7esruvx0NOCV1Go0c4HwrX2rEeTsJ9yhoRuJRle7ZDGCksH+5yiQJJvYYJToGDrHgzwrPqzMt2LqXO8OR+3K/r0rJW0bu7vbMjCETg3Cw= 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=A7e5oNvS; arc=fail smtp.client-ip=40.107.92.40 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="A7e5oNvS" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=VaS4sPGSIA2w0xqvH4IaSv/yf3v33jhBXqReCa43nZPOtN8/Qlxvt5vGdRjEZKKZBCy/9dfkUjJ+xDdtR5HYKSUQAeq9X5PTf84ID3+nC1LZOcrnVZkYEFg+U/9FreW5MCB42XOTPR87xK+HdlK9LvzLpEcQsDBzV+DovaphksKZGJUJgtSWXXmW0X/r4rNXUMV0w0k2DvNU6iIyb+/+Wp/XFquyNNk9L/YTnedEafQvzvDpE5jeFl4lS0+xloSD/AZhe4Ifr6aPIomJYET1Rd9h+M5c0lxuTmiAugGOXUI1IVZTF9YdBEvuv+s5fB8LP4/xxtYQMpjWGnQMzZg53w== 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=/grx1LEZem64veHctsoR4ENSjA0UKbOfkEgX6WsCPl4=; b=wEzQt6s+6Zt2R4SOr/+zugjNIGLyBKpNFsb+VDil13PhUZMijIPfKOI7iL1gzpfIuQzk6xzv5rVIKn4DHB79enmIOSoPv8ETA2x8PLKOzx5glzDyBVuSPYUX0DGgDVOJ8VNolx78o/2xgQzEG2UZtQ3CFO8n/E5Z7nd+3A0AJmNNaVgSTKjlzWI7q2oLo9eaoanTAtUmAjZcbIs3tDTd7CQ0xYR/A8bGpQz61IORK0W0mkioQG+jqUY+mvF+xH/fzeIwyuVY+6JAazmC2aVybqgAxF3CzVJ9D81IWEa7nppWOb2JgG8u7wKdfjgXRv2UdhpBykUDyogXeb45IfK9YQ== 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=/grx1LEZem64veHctsoR4ENSjA0UKbOfkEgX6WsCPl4=; b=A7e5oNvSQJyJjZrRDIGytw84jsmksnUeaMdk5mS1hqgJ8m1lZ0GmWym5Gb+8jHUlrh+mHlRAHJiVK41iJxXVNC7zLI89XM4vfeQTxfsDGp4tZBIIyNHmAgDeDlT85FCkcUC4swFT4wrfIJj87haJPYWF4vIQXeGvA/90IaUKlhE= Received: from PH7P220CA0140.NAMP220.PROD.OUTLOOK.COM (2603:10b6:510:327::17) by MN2PR12MB4486.namprd12.prod.outlook.com (2603:10b6:208:263::23) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7828.22; Tue, 6 Aug 2024 22:01:46 +0000 Received: from SN1PEPF000397AF.namprd05.prod.outlook.com (2603:10b6:510:327:cafe::15) by PH7P220CA0140.outlook.office365.com (2603:10b6:510:327::17) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7849.13 via Frontend Transport; Tue, 6 Aug 2024 22:01: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 SN1PEPF000397AF.mail.protection.outlook.com (10.167.248.53) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.7828.19 via Frontend Transport; Tue, 6 Aug 2024 22:01: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; Tue, 6 Aug 2024 17:01:43 -0500 From: Babu Moger To: , , , , , , CC: , , , , , , , , , , , , , , , , , , , , , , , , , , , , Subject: [PATCH v6 05/22] x86/resctrl: Introduce resctrl_file_fflags_init() to initialize fflags Date: Tue, 6 Aug 2024 17:00:42 -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: SN1PEPF000397AF:EE_|MN2PR12MB4486:EE_ X-MS-Office365-Filtering-Correlation-Id: 6cb63a85-7ade-4fe0-0b99-08dcb6635cb9 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|82310400026|376014|7416014|1800799024|36860700013; X-Microsoft-Antispam-Message-Info: =?us-ascii?Q?tcwKSzr64ip24dAKpRRCeLMJez24SEtzI44r60z64VefkrjRDpRKevY9OcWo?= =?us-ascii?Q?NOcxbFIgtZgOh4rigQvj98Yi8k+u/zCBWt7+jNJv58Sd9mZOPaeLYULNAkBH?= =?us-ascii?Q?AK17zl+j+DOi85ql6YbRcnDbnj0reqeyG/MzXiGTdsOYjLLDhjPM8xIi1u1p?= =?us-ascii?Q?0TzJft5ZY/MvyKy7wr4sio7yJQ2V8SKEffcHMYlaaU8vU3RfjcYRx+LZ8f5h?= =?us-ascii?Q?sF2Ko6slEGI/yHR1UIqv/plwNV4Og60ByMjFaNx6EYlvOrbVndQpBFMQiHBM?= =?us-ascii?Q?CduuWxng69MOZnBnk+/a+QJ63ERXSVDe4dBnWoXyUbNIowqnF5p53DD8s0DN?= =?us-ascii?Q?/Ymvyu6PH+o7ewEzXjzPLAPfx/sPjUaE8m32SXeQOFig5MNPlQmswfU2eEUK?= =?us-ascii?Q?jhjEtxVh+nBULi3VElaCD9QcIb5rnXxJ65oNpANOxG7c3iBVbBt8q8qRC2Cv?= =?us-ascii?Q?EMXSEt8TbAzQAsl8glSjtVFsDRlTV8pS5Vd5tzDDBM8i5HH8X4E12EoKxL2o?= =?us-ascii?Q?zPm0qEyY14jR+m1VLR+al8gwl4cZNVYhJNntCMFxCOtOGYLi++N2Z+TYJafP?= =?us-ascii?Q?jP0kB+1Py1UU9tC4wVcgzXrmUmTch3tQn59R0muOyrGvWJ4IJDsq2lsfuqJ1?= =?us-ascii?Q?ZKjrYrxO3c2Ov4KJLZRcBEOtgAMIcaBYPXl2ZnLvJLDGmgpild91xTJB7aSv?= =?us-ascii?Q?crZK0pTX5JE5WUUKJf/nqsAob8rGGPBxVOAW78H136T94EbHNzmnMmmfhyuL?= =?us-ascii?Q?fYkqSr3OIBPfyEfGFnvQeOQw79WGy7hbI7ezxYapDUTKfafUL7gefBT0rMjy?= =?us-ascii?Q?i29OklJuNOaSKNPA881Y/STQiobDX5vsV8gWnYBNPfUdCGBLIPMUZctoifCN?= =?us-ascii?Q?q71AksJ9CPmmMzYwn4ZT7NXsXgmh8iBrdjgmmD6ib0rEs9kT1FQ03TtpsyrJ?= =?us-ascii?Q?fFaZqn9SyruCLS3bW2oTYg/TQ0egp3rdFdcEznBhrfzRCGV+YBDh8XbKVPC2?= =?us-ascii?Q?K1SbvgeoemedY0uBS4nNFrbPQaSn15EGJ8jxk0asfFflxDWvaTppEbBWn7jA?= =?us-ascii?Q?du8LVjFYCnLBxauWsl4imLUxlwS2x3XpD3TW7hA9I8dFMF0EV+cJQmq6mXLV?= =?us-ascii?Q?T5t2MTQbHQmv6bFB/F57r9SWXr7mF03T7Yr4tcvleW9TaKl4gwYAxZGRSyl0?= =?us-ascii?Q?HZizIfoDT7C7Bbv4MDLEBtp5oKyXcuzRnlkWym2s7ESETkt36TMexmwAlEuo?= =?us-ascii?Q?ypnum+3Rc4SmKmoI+gVvry7hvSSVFxYJi36MfqB9II3+Wkj2+RoBNgvgjkGw?= =?us-ascii?Q?MUGiLHpVfePWI2XKhm0DYViwfQuMhVZ5bsuvercOu8D6pWNlHjETEzcMC267?= =?us-ascii?Q?PuyuJJPUoT+1aNDE/XjQKy7X8gL+5daPxTOY3mvgewLa89hN65xr5wBUXgNG?= =?us-ascii?Q?DVLCYHSj72Cp1EcLGeZlEnr6I221Tfmh?= 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)(7416014)(1800799024)(36860700013);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 06 Aug 2024 22:01:45.2478 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 6cb63a85-7ade-4fe0-0b99-08dcb6635cb9 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: SN1PEPF000397AF.namprd05.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: MN2PR12MB4486 Content-Type: text/plain; charset="utf-8" thread_throttle_mode_init() and mbm_config_rftype_init() both initialize fflags for resctrl files. Adding new files will involve adding another function to initialize the fflags. This can be simplified by adding a new function resctrl_file_fflags_init() and passing the file name and flags to be initialized. Consolidate fflags initialization into resctrl_file_fflags_init() and remove thread_throttle_mode_init() and mbm_config_rftype_init(). Signed-off-by: Babu Moger Reviewed-by: Reinette Chatre --- v6: Added Reviewed-by from Reinette. v5: Commit message update. v4: Commit message update. v3: New patch to display ABMC capability. --- arch/x86/kernel/cpu/resctrl/core.c | 4 +++- arch/x86/kernel/cpu/resctrl/internal.h | 4 ++-- arch/x86/kernel/cpu/resctrl/monitor.c | 6 ++++-- arch/x86/kernel/cpu/resctrl/rdtgroup.c | 16 +++------------- 4 files changed, 12 insertions(+), 18 deletions(-) diff --git a/arch/x86/kernel/cpu/resctrl/core.c b/arch/x86/kernel/cpu/resct= rl/core.c index 4a2d0955ccdc..ff5cb693b396 100644 --- a/arch/x86/kernel/cpu/resctrl/core.c +++ b/arch/x86/kernel/cpu/resctrl/core.c @@ -226,7 +226,9 @@ static bool __get_mem_config_intel(struct rdt_resource = *r) r->membw.throttle_mode =3D THREAD_THROTTLE_PER_THREAD; else r->membw.throttle_mode =3D THREAD_THROTTLE_MAX; - thread_throttle_mode_init(); + + resctrl_file_fflags_init("thread_throttle_mode", + RFTYPE_CTRL_INFO | RFTYPE_RES_MB); =20 r->alloc_capable =3D true; =20 diff --git a/arch/x86/kernel/cpu/resctrl/internal.h b/arch/x86/kernel/cpu/r= esctrl/internal.h index 955999aecfca..2bd207624eec 100644 --- a/arch/x86/kernel/cpu/resctrl/internal.h +++ b/arch/x86/kernel/cpu/resctrl/internal.h @@ -647,8 +647,8 @@ void cqm_handle_limbo(struct work_struct *work); bool has_busy_rmid(struct rdt_mon_domain *d); void __check_limbo(struct rdt_mon_domain *d, bool force_free); void rdt_domain_reconfigure_cdp(struct rdt_resource *r); -void __init thread_throttle_mode_init(void); -void __init mbm_config_rftype_init(const char *config); +void __init resctrl_file_fflags_init(const char *config, + unsigned long fflags); void rdt_staged_configs_clear(void); bool closid_allocated(unsigned int closid); int resctrl_find_cleanest_closid(void); diff --git a/arch/x86/kernel/cpu/resctrl/monitor.c b/arch/x86/kernel/cpu/re= sctrl/monitor.c index 88312b5f0069..5e8706ab6361 100644 --- a/arch/x86/kernel/cpu/resctrl/monitor.c +++ b/arch/x86/kernel/cpu/resctrl/monitor.c @@ -1223,11 +1223,13 @@ int __init rdt_get_mon_l3_config(struct rdt_resourc= e *r) =20 if (rdt_cpu_has(X86_FEATURE_CQM_MBM_TOTAL)) { mbm_total_event.configurable =3D true; - mbm_config_rftype_init("mbm_total_bytes_config"); + resctrl_file_fflags_init("mbm_total_bytes_config", + RFTYPE_MON_INFO | RFTYPE_RES_CACHE); } if (rdt_cpu_has(X86_FEATURE_CQM_MBM_LOCAL)) { mbm_local_event.configurable =3D true; - mbm_config_rftype_init("mbm_local_bytes_config"); + resctrl_file_fflags_init("mbm_local_bytes_config", + RFTYPE_MON_INFO | RFTYPE_RES_CACHE); } =20 if (rdt_cpu_has(X86_FEATURE_ABMC)) { diff --git a/arch/x86/kernel/cpu/resctrl/rdtgroup.c b/arch/x86/kernel/cpu/r= esctrl/rdtgroup.c index f9f3b5db1987..7e76f8d839fc 100644 --- a/arch/x86/kernel/cpu/resctrl/rdtgroup.c +++ b/arch/x86/kernel/cpu/resctrl/rdtgroup.c @@ -2020,24 +2020,14 @@ static struct rftype *rdtgroup_get_rftype_by_name(c= onst char *name) return NULL; } =20 -void __init thread_throttle_mode_init(void) -{ - struct rftype *rft; - - rft =3D rdtgroup_get_rftype_by_name("thread_throttle_mode"); - if (!rft) - return; - - rft->fflags =3D RFTYPE_CTRL_INFO | RFTYPE_RES_MB; -} - -void __init mbm_config_rftype_init(const char *config) +void __init resctrl_file_fflags_init(const char *config, + unsigned long fflags) { struct rftype *rft; =20 rft =3D rdtgroup_get_rftype_by_name(config); if (rft) - rft->fflags =3D RFTYPE_MON_INFO | RFTYPE_RES_CACHE; + rft->fflags =3D fflags; } =20 /** --=20 2.34.1 From nobody Sat Feb 7 21:19:49 2026 Received: from NAM10-MW2-obe.outbound.protection.outlook.com (mail-mw2nam10on2072.outbound.protection.outlook.com [40.107.94.72]) (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 1AE7F17839D; Tue, 6 Aug 2024 22:01:55 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.94.72 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1722981717; cv=fail; b=UabQHXiF6S8aQI8m6VFc5qlt+jSxg82ZRP4d8Ke+rDH8w9Xi2X/BAy9dy3He8vv7kTaVVR6sj4zSCnQX5VHtEbtXmWYPN6oeaq7XwNR6TQZXU3L9UFlY2+vGLcE5D5F0QvYovxUIp71TQ5d57zH7wywlw8IJkb7g95ipYh3CIiw= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1722981717; c=relaxed/simple; bh=okw6cJM/4I7gD/Sk1UhJriASy5BjXO9ghC1m9T8vKE8=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=YHHxMzyh6pvuxU/67+xh1HNfOG1cPWmC2oxZ35m68fJWqyKG2jHG7PQw3BV/stf5Z1zcJfld+91C1X1+TNWsbEvpmUhDvzq8gMuGcTrcewIXwMZzWtJX/K7gqwDmfl5yWjU7odCw9yCqRlqCRSuCWpm9aPtrXZbjBR/h9NnKlRI= 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=B2zYHvEw; arc=fail smtp.client-ip=40.107.94.72 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="B2zYHvEw" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=TpwCJWDq1hub7WC85ho7N0dAsuHmVBVIYDGPAZq2N2AS/s3iZXeP1LHC9+nO0g1vwed1FFzlKTTtWe1lHjMcXxwVxOF1iN6AtSSwruKj88dIEVLiE7bUG7vxhgRyH8CD5GRTwugS8GGDkh19JwSYX9i3AACpl1frlQ+gqVxwEhWMAqJDVgUb3Ti1grA97orjscFET7uo4CwI0acvRinRa+Gl6szOH9MXPWrbUV9PCNKLacFRZ6k4xkU8+TEikYa7/+QTklWVv4rqvSXYQIIKKyobGN+1a0uY9sNOqk0KabbX1TRA8PcJ325Msas9DnC1Eg6L0PwUvoUBOm0CmtFlZw== 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=fOtsYARouqgS+Tzr3CilimMzOnUPCEFzxEztq/0pQng=; b=xCONdPb7/oJ0FzC7CR/aeuT0xVBv+DE2Q0nPMQ9lY3cloT67hqr27ignJftmrV+BwIZV8/bhGBniwsXJgax3oAN4Jr212WZY+gw1ErE0qikUVBfDpxS1rjSsquB4Hk/3yYkZC1wHJrNOajy3FP+ZH23gpNnaaB6nSf2m6hdz6I2tSyYXxa04GEYThAnmhuWksA6YQgtRtDpLaZCnDH7i6/u+qfRuJXLLZrPfbwrYuxMzeLhNRFlvoFMUPhyUXZudZBfeEXAq9R0CIfUZyk5AZk8B/yrMgz09Woav9yFdQ/HDE8PfLoXeBqs6/hs1pzln7RL5zBZexoWZqwrVR73p8g== 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=fOtsYARouqgS+Tzr3CilimMzOnUPCEFzxEztq/0pQng=; b=B2zYHvEwSMLqyYUg2xVX9tuPHkQBUvxNFl0+DUwbFp5fTnIxJxBeKm08ROtBkaQGOo4fxQFJEfuOPR50hj7Uhf21tm4Y38K5pUcDmCVtI2OWWkA2zLzRs09UNS1Jc7zFBL8/XFxVxHTN9QMAdxmUk+JB/6Lmb+t6UtAVwIxgdXc= Received: from PH7P220CA0165.NAMP220.PROD.OUTLOOK.COM (2603:10b6:510:33b::14) by CY5PR12MB6372.namprd12.prod.outlook.com (2603:10b6:930:e::5) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7828.26; Tue, 6 Aug 2024 22:01:52 +0000 Received: from SN1PEPF000397B0.namprd05.prod.outlook.com (2603:10b6:510:33b:cafe::19) by PH7P220CA0165.outlook.office365.com (2603:10b6:510:33b::14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7849.12 via Frontend Transport; Tue, 6 Aug 2024 22:01:52 +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 SN1PEPF000397B0.mail.protection.outlook.com (10.167.248.54) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.7828.19 via Frontend Transport; Tue, 6 Aug 2024 22:01: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; Tue, 6 Aug 2024 17:01:50 -0500 From: Babu Moger To: , , , , , , CC: , , , , , , , , , , , , , , , , , , , , , , , , , , , , Subject: [PATCH v6 06/22] x86/resctrl: Add support to enable/disable AMD ABMC feature Date: Tue, 6 Aug 2024 17:00:43 -0500 Message-ID: <140e4e7bb26db9bbad3e37d910c0cea0060e99e2.1722981659.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: SN1PEPF000397B0:EE_|CY5PR12MB6372:EE_ X-MS-Office365-Filtering-Correlation-Id: aa1b186f-1505-43b9-f9b8-08dcb663610b 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?/wjPBg7qKUZ+4VXXlFyEnoKUHTey/NuHlgJPhgFvFtVMr2rkFeLNXGP1OK5R?= =?us-ascii?Q?/DLK1BviVq24IBe6Qi8NXgKNpPCSQuMJG8KBBEJ8fpFzERCpLcOKtW58/PHr?= =?us-ascii?Q?s6Xli3P5Qc6sYkPCjcAk9wXJ4xqXLQakwgZo5OuqdQBZ87FfAfg8IJugyH7b?= =?us-ascii?Q?MI3l9JCDHXXWa1obd7TdKy8Hh4Y236nQeocublCRpKE85X4LnlWfIbNVl4jR?= =?us-ascii?Q?bx0qMlWRH2J4St3ebwSPWeowoapicB8EWyYaVKT0qbDOYahHsYvkowIL71Eg?= =?us-ascii?Q?JdK7Q0h3HNAIiw6VfOQ3092K+aOqywwo0q3sldp1wE9c9yaL++R1Kt+QGpLm?= =?us-ascii?Q?153PeU94yAUIjgwuq4piWlZWUuj/3pWmkVkgungkz+DX+iOcheiKcI1eV3gD?= =?us-ascii?Q?qJfSDnqogFCc+3kPCUV+VmLTtk3LS5YwspQAO/T9hM6zaBJ5CO2hulLD/+6T?= =?us-ascii?Q?ofaaFD6lyaNa9MIUHfbEXuwuBayrk/+lGomGRpY1tqvJwhwdk14MzhKzJnXz?= =?us-ascii?Q?mqOAsqFvspk+KHvSUui4VA/sSQIZX5YXZZUeuMSPgFm7MTY5sIk3kGswdCH7?= =?us-ascii?Q?4z/pn/rz6hxmrwtb+/wObUZi+5FjsYSdReQKqewYpSHCpemQv0JlxsZLepKA?= =?us-ascii?Q?qgCLjY4QrkIcRh+SV25zabJM6extlxWEoInbvi09uUEa4lpXRYSVwo75Hzha?= =?us-ascii?Q?LnNWDtdlFTbdTRMUjJDEaWhLARI9mOHFLODUXNeYlLap6k9DW/+gIvbPde8C?= =?us-ascii?Q?C5yN1lpjDX7JUBNvdA1jzi9OM5xvEbEDnAZ3PK8Qrj8M7q31vAgp4WuRWjdK?= =?us-ascii?Q?RwWqrI0IFUmcb/IHHmzw8iFJi+5cE9bz1nB/hjGnkex69N4Uj2Om5J102wdc?= =?us-ascii?Q?6DnJG0J/Ujhm2YnThNQYFYHoE+ZSSkQWYN6c491YdCuxt6ISHHO41i1mFtY8?= =?us-ascii?Q?UE8l/NUb2gql9mevqrOgWox8hNghI/f6Pk7tdkFnnHFCPIz7B90/nsPplDG/?= =?us-ascii?Q?guZn0GCdfUPn40amP+Jkj+0V4sSpKG8FyB2fL1dQz+9KIMmG4Shkb37kRDEZ?= =?us-ascii?Q?SSd0Yb+53onJrecizZilDBEvzGrw15tVEWtV27uY0dF8WdEAcL2ivXhCrcRN?= =?us-ascii?Q?lBSjEfOF7lIgmC0i0geGlQBpVDi+2rp0aaGdkdhiWLeXH55QSlT4AWTNCjfb?= =?us-ascii?Q?Rk+KRDVqX+4USF4OiIGqfOzXzEVudRPOiRExIXfK8hiAx7ydXA0kj/Jszi+p?= =?us-ascii?Q?k7UrZ3cZWrx64bCpVl5twiPdOd4iS8m3aDJmOY5jsdMLBdSTL3yJ/W3zElw6?= =?us-ascii?Q?BPRuGV5uKVV2IokyZK1C7ml99mCSmXo0tHCpWD2N2snuj7WGp1y2hgPwVdCW?= =?us-ascii?Q?6Li0D0aMQG76cucWNp0k2w/iFh3yU0aFYP8f7ZRrK3f6oD0xRg=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)(7416014)(376014)(1800799024)(36860700013);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 06 Aug 2024 22:01:52.5178 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: aa1b186f-1505-43b9-f9b8-08dcb663610b 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: SN1PEPF000397B0.namprd05.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: CY5PR12MB6372 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. Reset the architectural state so that reading of hardware counter is not considered as an overflow in next update. 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 --- 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 | 13 ++++++ arch/x86/kernel/cpu/resctrl/rdtgroup.c | 57 ++++++++++++++++++++++++++ 3 files changed, 71 insertions(+) diff --git a/arch/x86/include/asm/msr-index.h b/arch/x86/include/asm/msr-in= dex.h index 82c6a4d350e0..d86469bf5d41 100644 --- a/arch/x86/include/asm/msr-index.h +++ b/arch/x86/include/asm/msr-index.h @@ -1182,6 +1182,7 @@ #define MSR_IA32_MBA_BW_BASE 0xc0000200 #define MSR_IA32_SMBA_BW_BASE 0xc0000280 #define MSR_IA32_EVT_CFG_BASE 0xc0000400 +#define MSR_IA32_L3_QOS_EXT_CFG 0xc00003ff =20 /* MSR_IA32_VMX_MISC bits */ #define MSR_IA32_VMX_MISC_INTEL_PT (1ULL << 14) diff --git a/arch/x86/kernel/cpu/resctrl/internal.h b/arch/x86/kernel/cpu/r= esctrl/internal.h index 2bd207624eec..154983a67646 100644 --- a/arch/x86/kernel/cpu/resctrl/internal.h +++ b/arch/x86/kernel/cpu/resctrl/internal.h @@ -56,6 +56,9 @@ /* Max event bits supported */ #define MAX_EVT_CONFIG_BITS GENMASK(6, 0) =20 +/* Setting bit 0 in L3_QOS_EXT_CFG enables the ABMC feature. */ +#define ABMC_ENABLE_BIT 0 + /** * cpumask_any_housekeeping() - Choose any CPU in @mask, preferring those = that * aren't marked nohz_full @@ -477,6 +480,7 @@ struct rdt_parse_data { * @mbm_cfg_mask: Bandwidth sources that can be tracked when Bandwidth * Monitoring Event Configuration (BMEC) is supported. * @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. @@ -491,6 +495,7 @@ struct rdt_hw_resource { unsigned int mbm_width; unsigned int mbm_cfg_mask; bool cdp_enabled; + bool mbm_cntr_assign_enabled; }; =20 static inline struct rdt_hw_resource *resctrl_to_arch_res(struct rdt_resou= rce *r) @@ -536,6 +541,14 @@ int resctrl_arch_set_cdp_enabled(enum resctrl_res_leve= l l, bool enable); =20 void arch_mon_domain_online(struct rdt_resource *r, struct rdt_mon_domain = *d); =20 +static inline bool resctrl_arch_get_abmc_enabled(void) +{ + return rdt_resources_all[RDT_RESOURCE_L3].mbm_cntr_assign_enabled; +} + +int resctrl_arch_mbm_cntr_assign_enable(void); +void resctrl_arch_mbm_cntr_assign_disable(void); + /* * To return the common struct rdt_resource, which is contained in struct * rdt_hw_resource, walk the resctrl member of struct rdt_hw_resource. diff --git a/arch/x86/kernel/cpu/resctrl/rdtgroup.c b/arch/x86/kernel/cpu/r= esctrl/rdtgroup.c index 7e76f8d839fc..6075b1e5bb77 100644 --- a/arch/x86/kernel/cpu/resctrl/rdtgroup.c +++ b/arch/x86/kernel/cpu/resctrl/rdtgroup.c @@ -2402,6 +2402,63 @@ int resctrl_arch_set_cdp_enabled(enum resctrl_res_le= vel l, bool enable) return 0; } =20 +/* + * Update L3_QOS_EXT_CFG MSR on all the CPUs associated with the resource. + */ +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); +} + +static void _resctrl_abmc_enable(struct rdt_resource *r, bool enable) +{ + struct rdt_mon_domain *d; + + /* + * Hardware counters will reset after switching the monitor mode. + * Reset the architectural state so that reading of hardware + * counter is not considered as an overflow in the next update. + */ + 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_enable(void) +{ + struct rdt_resource *r =3D &rdt_resources_all[RDT_RESOURCE_L3].r_resctrl; + struct rdt_hw_resource *hw_res =3D resctrl_to_arch_res(r); + + lockdep_assert_held(&rdtgroup_mutex); + + if (r->mon.mbm_cntr_assignable && !hw_res->mbm_cntr_assign_enabled) { + _resctrl_abmc_enable(r, true); + hw_res->mbm_cntr_assign_enabled =3D true; + } + + return 0; +} + +void resctrl_arch_mbm_cntr_assign_disable(void) +{ + struct rdt_resource *r =3D &rdt_resources_all[RDT_RESOURCE_L3].r_resctrl; + struct rdt_hw_resource *hw_res =3D resctrl_to_arch_res(r); + + lockdep_assert_held(&rdtgroup_mutex); + + if (hw_res->mbm_cntr_assign_enabled) { + _resctrl_abmc_enable(r, false); + hw_res->mbm_cntr_assign_enabled =3D false; + } +} + /* * We don't allow rdtgroup directories to be created anywhere * except the root directory. Thus when looking for the rdtgroup --=20 2.34.1 From nobody Sat Feb 7 21:19:49 2026 Received: from NAM02-DM3-obe.outbound.protection.outlook.com (mail-dm3nam02on2085.outbound.protection.outlook.com [40.107.95.85]) (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 12530171E61; Tue, 6 Aug 2024 22:02:06 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.95.85 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1722981728; cv=fail; b=H8toppk8jc6wkPvUxfGCR9LgjxfimElNz88sdnMVrI4aNYN3KxlehnuB09FyEQ5lZtmnTuiJ0wl6URJanZyVNzPWTPUtwAIO0qocQwCir62YIYQKivrXTVmVH/5j5cB8ofKXeSm2TvXOIys5qUyur2Lhtf4NHtlziFd7Ij/Kd7k= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1722981728; c=relaxed/simple; bh=rY95UJgg3m0PnYTv1w4zWZg48+jbWQSlvXwaBeZHKVM=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=g+EtVbaAErJgOCtnj2hSuPNRx/EDS9jzuuaVM/Jl5ia5PYfmSlsTRPkhFWQu1SRitKPrcZiC+zykLAy/d3mDPgQ5Vv1xzremkOU/IPx1Ma7X5XGKH9Caas7hPC94rKaZeooWBeKiwgd6jPUP2qj+EkWke6SZXPwrPA4r9aSaBms= 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=glaKrM1G; arc=fail smtp.client-ip=40.107.95.85 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="glaKrM1G" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=zR3IPLCnHuWag7r5036Wx8PuwFUbeO6VI6TS4UkWHqerh0YvdsgVafLJ9jfIEZH5j4JmdjJY5363zKC0o/FkY9rDXhaaEKSqxKieFcA0I47HNVggAtyVeP4AUiJ4CM6nyWGXl0veeJlJPC2z0Wj02D/xk9+bJPqZUdwANg6SCjCu6l0PR9XjLsDyJGbFWSfFM2Ez4YLH+5JKsATf9puyKm3kM+eMCUziwkzJ7j4eN0+8fdqmIsBhlOV28ic5GL33jJt+wTBdtw4R8HsxELekAjKaWAnKnPHj+qXTnSJOGYYoWDkDlDGZDrr+Scv8WYAnCIpbeoTfBFDHuVg2rx0X7Q== 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=6b5dgNdN/fCfaLPak6Z7DYz7QenB2BY++LPgjCTBw3M=; b=FkXjG5zxzbAbrMUgT6Q9UsDcev1g5EKpiRIIklqldG4sc0QInmYtLrS3sIgwqTNIXcoY74MXIMS1UJfIZ35+A6+3BmkLwwDTlDxpK3hVIIJRDwyXRDROfDPJprynDbENIAr4fIE1Sqm3w4xkIqDTnQAnOvawMUBpkKC9DxkZAdvhBGCA191c8UZMc0tSy5HyVegvZGjqU613aN8YLjkMmainUGqW39tNZveitByoKMCPZPxLt3f2mDfTu8oGab4GEx+4XnnOZGBPX/5ODrd4M00xFeUQbIH6utgAh7Z7NmcuTakvCaeLgqeyYkZKmFiFScDLiMENWOGzIQfdj9kVug== 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=6b5dgNdN/fCfaLPak6Z7DYz7QenB2BY++LPgjCTBw3M=; b=glaKrM1GD8XkqE18MEa6nnFprMUPIhAjv55Qt0UBkcDn/Fw44KqQ5fmeI6vsvtFy03Yqv7EpeoOksuw0NSZWSkPubaYdt2ingdx1t90zkYz/4phCTXsnOhM9zFSfvqjPUkyX63ub01fH7Y7vkDOWsvOJjbnRVLir4V6ulsKRm0k= Received: from PH7P220CA0150.NAMP220.PROD.OUTLOOK.COM (2603:10b6:510:327::13) by MN0PR12MB6223.namprd12.prod.outlook.com (2603:10b6:208:3c1::12) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7828.27; Tue, 6 Aug 2024 22:02:03 +0000 Received: from SN1PEPF000397AF.namprd05.prod.outlook.com (2603:10b6:510:327:cafe::d) by PH7P220CA0150.outlook.office365.com (2603:10b6:510:327::13) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7828.29 via Frontend Transport; Tue, 6 Aug 2024 22:02:03 +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 SN1PEPF000397AF.mail.protection.outlook.com (10.167.248.53) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.7828.19 via Frontend Transport; Tue, 6 Aug 2024 22:02:03 +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; Tue, 6 Aug 2024 17:01:58 -0500 From: Babu Moger To: , , , , , , CC: , , , , , , , , , , , , , , , , , , , , , , , , , , , , Subject: [PATCH v6 07/22] x86/resctrl: Introduce the interface to display monitor mode Date: Tue, 6 Aug 2024 17:00:44 -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: SN1PEPF000397AF:EE_|MN0PR12MB6223:EE_ X-MS-Office365-Filtering-Correlation-Id: aa344e07-c848-435f-f626-08dcb6636781 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?lYwm9SCRrLTqR/a8qLbZjmcnlbMX3USR8ykcQ7WrAaFnMH0FxA18YlrrGcuW?= =?us-ascii?Q?GvlXBFtHnbo13wKIDXTFURh42w44iVM5nQjFd0Kzmt4aURSU398CHK2OxAKJ?= =?us-ascii?Q?R37ML1JZxcBL9dSk8O6bhLKHcwwL9boqlQgQI0rGw/kyjEQD00TmY+h7J9WY?= =?us-ascii?Q?IquT/6pbj4GKFO3IfRtbjUkBa6RZP4ouISdb6RJj5fltGSCizrFGv77/1WNw?= =?us-ascii?Q?RRGpO3PO/3155HpddJxp9SFQbRv8Lyim7rPE7Q/IMyj8B63MKqkswgqMZRvS?= =?us-ascii?Q?z8smoColBUXy6t0pfC8S9KFJLPGKinwkQbaT+j2Tz+nPzl27Wy8QNu2GlLu0?= =?us-ascii?Q?l5lA2IyTJor6+ho8eOPPd0ldvBCrw4w+lebbn8yH553HAvFavGfxPr1vzg6v?= =?us-ascii?Q?YP+LtItVXowdSEkaxLV5I1A9J/wddHljzY7ekrQMekNlzVk/t+sCns4wTRU/?= =?us-ascii?Q?VTJG5jcaiwnjozjKPBWJ8GfloW1M71OoKvVAA2bU+l/j3bX9CEnpbT1CYmcA?= =?us-ascii?Q?mDNQ60/dMYFxOJBiV7L4V+bSQfWBbQgzZ94E28LRM1/zF6VaTdl7MAyj3B2r?= =?us-ascii?Q?ISe301DcXmFtatT2B5lEY5Zijm52rqCw5vgBTSMHXMCyb/Jh4urfjcB2O3L7?= =?us-ascii?Q?13xPrM3kQDZKNVI/apnVlVTNKmU5whRhP3KjOfpr0w0NbXmzUpXBNRxr2cHb?= =?us-ascii?Q?RajORdWCh56BpeM/lUPrpo9hjto+WJk7vO1CvVnJofz15Y2QHP7ABrFKknK5?= =?us-ascii?Q?ye2WweYdIh3fCFMVTMAehdqLb6UDGqCtQGpsHPNuarJbbKNwZDd5uFczOKQQ?= =?us-ascii?Q?DaJUBF8UEH/LHyh1cXPGjHeRkWDyH+YiUVI9DSedM7VFvns0bMnc3Hgs6U7i?= =?us-ascii?Q?R9cViMQzWNA0AGQETU2SGYKNs46CVKblwaAIoIdlmgtl4apbu21pt1EV/CTb?= =?us-ascii?Q?Wo2RCtKB4Vw2sO08JRPZz7ZORbpacdPcvkxt62ym2O9sqmm7vdN+OdCn/Qpp?= =?us-ascii?Q?HZ0IoT8m8fub3OU8hgl9/+Ue06XUROSPcsGB7Ezr3rmn4XS7OU13WUGsDMaI?= =?us-ascii?Q?ePmXGIbjZjrxja8ExlkypTOqVRswIkuNjzMq1GrVc/G3PK6lIFRMwPMtUdx9?= =?us-ascii?Q?Ut1uM61eN8qrpUuxt5gi/RoSr4nWZoai/t70eJDdA3yc7prq5dSxPTWnQGpG?= =?us-ascii?Q?7tDWApFbwFRwAOjhdnSJu39jrzODt0Irq0Ymxd0ZS59GdNTQUh66HSTEB8cT?= =?us-ascii?Q?KOyNMgzjuoW6DerWBVyHj8YlSYvuGLQI1OluIV8/TVq9zyRS2FKeC+VgcFBF?= =?us-ascii?Q?iIDUgDs21WSBSO/oBCRosZJ6IOTXQqbF6xiaLVzbE35ETPT0p40xcDdVbw0y?= =?us-ascii?Q?BHSm7Zycf1gUEjNh3n5hfYED7MC6odclK9vHpZPV/3oSVR3AzBfo5fiy6RcT?= =?us-ascii?Q?wjnLRu1FKEs/pste4xNRjnynDZZqsFLU?= 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: 06 Aug 2024 22:02:03.3418 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: aa344e07-c848-435f-f626-08dcb6636781 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: SN1PEPF000397AF.namprd05.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: MN0PR12MB6223 Content-Type: text/plain; charset="utf-8" The mbm_mode displays list of monitor modes supported. The mbm_cntr_assign is one of the currently supported modes. It is also called ABMC (Assignable Bandwidth Monitoring Counters) feature. ABMC feature provides option to assign a hardware counter to an RMID and monitor the bandwidth as long as it is assigned. ABMC mode is enabled by default when supported. Legacy mode works without the assignment option. Provide an interface to display the monitor mode on the system. $cat /sys/fs/resctrl/info/L3_MON/mbm_mode [mbm_cntr_assign] legacy Switching the mbm_mode will reset all the mbm counters of all resctrl groups. Signed-off-by: Babu Moger --- 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/arch/x86/resctrl.rst | 34 ++++++++++++++++++++++++++ arch/x86/kernel/cpu/resctrl/rdtgroup.c | 27 ++++++++++++++++++++ 2 files changed, 61 insertions(+) diff --git a/Documentation/arch/x86/resctrl.rst b/Documentation/arch/x86/re= sctrl.rst index 30586728a4cd..d4ec605b200a 100644 --- a/Documentation/arch/x86/resctrl.rst +++ b/Documentation/arch/x86/resctrl.rst @@ -257,6 +257,40 @@ 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_mode": + Reports the list of assignable monitoring features supported. The + enclosed brackets indicate which feature is enabled. + :: + + cat /sys/fs/resctrl/info/L3_MON/mbm_mode + [mbm_cntr_assign] + legacy + + "mbm_cntr_assign": + AMD's ABMC feature is one of the mbm_cntr_assign mode supported. + The 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 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. + + "Legacy": + Legacy mode works without the assignment option. The monitoring works + as long as there are enough RMID counters available to support number + of monitoring groups. + "max_threshold_occupancy": Read/write file provides the largest value (in bytes) at which a previously used LLC_occupancy diff --git a/arch/x86/kernel/cpu/resctrl/rdtgroup.c b/arch/x86/kernel/cpu/r= esctrl/rdtgroup.c index 6075b1e5bb77..d8f85b20ab8f 100644 --- a/arch/x86/kernel/cpu/resctrl/rdtgroup.c +++ b/arch/x86/kernel/cpu/resctrl/rdtgroup.c @@ -845,6 +845,26 @@ static int rdtgroup_rmid_show(struct kernfs_open_file = *of, return ret; } =20 +static int rdtgroup_mbm_mode_show(struct kernfs_open_file *of, + struct seq_file *s, void *v) +{ + struct rdt_resource *r =3D of->kn->parent->priv; + + if (r->mon.mbm_cntr_assignable) { + if (resctrl_arch_get_abmc_enabled()) { + seq_puts(s, "[mbm_cntr_assign]\n"); + seq_puts(s, "legacy\n"); + } else { + seq_puts(s, "mbm_cntr_assign\n"); + seq_puts(s, "[legacy]\n"); + } + } else { + seq_puts(s, "[legacy]\n"); + } + + return 0; +} + #ifdef CONFIG_PROC_CPU_RESCTRL =20 /* @@ -1901,6 +1921,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_mode", + .mode =3D 0444, + .kf_ops =3D &rdtgroup_kf_single_ops, + .seq_show =3D rdtgroup_mbm_mode_show, + .fflags =3D RFTYPE_MON_INFO, + }, { .name =3D "cpus", .mode =3D 0644, --=20 2.34.1 From nobody Sat Feb 7 21:19:49 2026 Received: from NAM11-CO1-obe.outbound.protection.outlook.com (mail-co1nam11on2079.outbound.protection.outlook.com [40.107.220.79]) (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 4CA37175D2C; Tue, 6 Aug 2024 22:02:14 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.220.79 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1722981736; cv=fail; b=HsAjLeqL8nj0Ji7xNXCpBSHSA1vsTUiOY16S2tvu7kFOSWA5kQ0/6iH26hKHjmWHAkk53U8/80h6CHHYSzxw3Rt2jrUlQXmVlO17uxJTO96ekcKe9/s13I4nyrsGR8CxEeKi/tUaPVf3JAfvHo7P563kc8vVLgcUYrhGa9Nr7oc= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1722981736; c=relaxed/simple; bh=nDmdUzKUuusuNc6o7R+mkJ+mniw9TfneVM5/6ki2k0I=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=aZkDdsky7rxLJfIBMRwFK+3kaU41XzSVL1fKRtjDOSxiJXZNznaXCSWhGYskX1epqtM4vHNsxC8Iy+69Ft7WXpthBD010Gj9CNPVmVkxYGlzZ4/EKm+gnEiXu4r0KYhrs+0qrTEvAPiEuKWeBZgiEhrfwxXsW36tWVzFijFNysc= 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=yXrc59Kg; arc=fail smtp.client-ip=40.107.220.79 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="yXrc59Kg" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=IpxvBvAzjl5dtJ7VBmbK1YXzPtIp6999fAElflg/ynER/r1Gt1w0kN4ejRJ18+aSrF1DXsnjK+Py+8mrWO/q8Bys+9WkIgmNQ3aeWnBxiY1jDwsjaDbmULban2iuxtM0Mt/xUyrv79WSYf3V8cddG+8sINA/17+Q+ToOxcsYs8/BCE09gwvBM8afgd0l58E3VLmZp/aoVk36rv8qPg9z/bLPWbxzXQdXQK+b8iJTNio9FGYqn3BzJO9jH70uS4nq5CoPrBSUapIXKS7WU+73nv84aFUG9IBru5Bx46BjVxNbOFF/Hnn+LV3UF1jv6ITmAHKeAu7eRc0xg4i4TWzMNg== 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=jKPizM1MsoU/qK2iulFWHtPUuY1SjFxmMvCh07dt8k4=; b=FWGx1PLo56H370AeZWBBi/KdEXygtzEoAmjNLqQE/4IMyMqhdA4hHHSy4+R2OJ+cxKjsmDP3wi3ouKsHGnJRz6s7kVY6JRgn0NhqmEJnuT5EiQ/Jq+eTjmQIQ7OxPk7SMjdhoYXvTa1ljglAvnk3qTKbd9ULrkQqpzpscesor5O/zMgHTUKWWg3X/XbuyUUhVV9F3JFDejYaO1Sbs+7KvOpVy6cItdVzocj85fxzV8W3k3yX+d3GrVEqpPLZZ4MrgOcNYgwU7xpUfAwZ6kR2Qye6GsIloWulqEaMTB5OuVD/bwBBT1/tU/C2prbNyLcneAxc3Q5+g6sErATuGRCZrQ== 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=jKPizM1MsoU/qK2iulFWHtPUuY1SjFxmMvCh07dt8k4=; b=yXrc59Kg69I4VSD9/hfzwvf1/8JlCmp8weG2rCVsKCvE3lDN2wXy61Pk2B1mp9dTOcQVCA+K12SqW1yEp+bEVYjPd1hMDjdnhQGmxuXHBF3jNezYn9mgfpLe8xvzCQJm6HSEXsMY9pWH2pmsS74FYlmNzu2HS4b1kQCzy0Ec8j8= Received: from PH7P220CA0145.NAMP220.PROD.OUTLOOK.COM (2603:10b6:510:327::9) by MN2PR12MB4160.namprd12.prod.outlook.com (2603:10b6:208:19a::19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7849.12; Tue, 6 Aug 2024 22:02:12 +0000 Received: from SN1PEPF000397AF.namprd05.prod.outlook.com (2603:10b6:510:327:cafe::f5) by PH7P220CA0145.outlook.office365.com (2603:10b6:510:327::9) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7828.28 via Frontend Transport; Tue, 6 Aug 2024 22:02: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 SN1PEPF000397AF.mail.protection.outlook.com (10.167.248.53) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.7828.19 via Frontend Transport; Tue, 6 Aug 2024 22:02:11 +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; Tue, 6 Aug 2024 17:02:06 -0500 From: Babu Moger To: , , , , , , CC: , , , , , , , , , , , , , , , , , , , , , , , , , , , , Subject: [PATCH v6 08/22] x86/resctrl: Introduce interface to display number of monitoring counters Date: Tue, 6 Aug 2024 17:00:45 -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: SN1PEPF000397AF:EE_|MN2PR12MB4160:EE_ X-MS-Office365-Filtering-Correlation-Id: 8a71f9fe-1069-464b-e497-08dcb6636c9e X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|1800799024|7416014|376014|82310400026|36860700013; X-Microsoft-Antispam-Message-Info: =?us-ascii?Q?dPq8CBEA59TPR6637bf2eY0GRnkNcsdrMyg640E2fZM5YvxLijhxskGD1inM?= =?us-ascii?Q?zZyxthHPOJVx2vowd4gZDemh58343XqtjrgbfE4+5CyiOh0F6TpOyTRnPrxS?= =?us-ascii?Q?bFP7W1YK+gIfjso8wcYGe/Z+7wixawkN7FsLDOkmf61oPrPkK7Zt1XaTGNyo?= =?us-ascii?Q?FvjVK0hdF8qX3+g/K0tG3DGZah0CtyJibYUIbjkmT0X2D9c1QARseNyIJJEH?= =?us-ascii?Q?jehQD9rlLehrkOi0sY/y8Izpna4m282IPINO7AEAJt+fP5olqV8UNlC5lLoW?= =?us-ascii?Q?GdkW8g0hqC+4f0bCKGcizh5kUWlqcaMfEXvxsPKqnVZ436ieWd2RYCxhK9xs?= =?us-ascii?Q?awuF3yJr+13+bZ4ua6zWQYwTA2qOeG0laq7jQ9ysgM1MHTHsLEdYPCDiT5wf?= =?us-ascii?Q?V7jBSpR0DCoVDd6jP5obEzOwlYKQu/3bT+CDmvNzx/GKXtFe3YTWJj6YzG4P?= =?us-ascii?Q?VLspDcLAfO+1USwwKx+4FOP5fEDvGP+1HxdaA28HDagMtYX9XN0O0gdlvMug?= =?us-ascii?Q?am2UZN/CEzxRbFYr6hOKKBZfuxEmUndUDA3dnrXuY54E46BYLst+j+3QrP6o?= =?us-ascii?Q?QORy6R3dRq4YtPN4y1YUTsJv0VhM10oMhARe9bW1ROBGFpxiajSktKn3nsfa?= =?us-ascii?Q?BdlH2a+eR28oLlzq+9KR/bYwEKaI++dk9k+ZH4N41//dGwfLiTnSF6qJBmMD?= =?us-ascii?Q?ElvkqnoKwFWyb9EWCmtspAWWd3bbgIvwiPlCVUcR12+iDMRaQgBZtxdFfHQi?= =?us-ascii?Q?tc2wMMHkHqgABxEzR6YEvOodSkX6EuhXliw3FZaADLQLmj+GwCN20VQpezPl?= =?us-ascii?Q?xVZ8l8kb57Eq43Lbji4/F5x689a5VA4EeSxexhzX4+5q+KgfFZZqplybCx2y?= =?us-ascii?Q?b3hrOu67Vu5PVANO6BLz0MOJQyDwmKJ7QIKQ3SK3THAwykdLd49Wju7yhfiI?= =?us-ascii?Q?N51BgQlvJjJaT4EKNIxkPCFKxTofT5Ji+D+9neahoVJmnnjR49b9ZNqWSKPo?= =?us-ascii?Q?kxSTsuz+0F55qN0/46KvXJJhWc6HjoSzr3efm7MlbjTOq2tYnw0q6ZDjlTia?= =?us-ascii?Q?+obIVqdAk5dc27mgiuBWVz9OICMtzOSSp2Ka8AijAU0gZfPQc2UmQHheTErE?= =?us-ascii?Q?hWraLb9DDlkJIeJT+5HMuNRLMDCqRRM7CsVDWeBBAMe99MUi5rDNMwgZGue7?= =?us-ascii?Q?rJx4YhQx3YQ/S6ZWEInDvIUdw54GXrxFwyoKjGw4xVz5pr1FQ4BLyDoA6wnc?= =?us-ascii?Q?hvK1Jqp9QZXH93Wdv3d21zv6jmXiVnARkSnedFu4o9UbHkVkQ9zsJIOLIjOJ?= =?us-ascii?Q?gBh9+VxhDo3Az8ZeFq1DIjWDJ7W/2Soe5uu24KMQ6SZ4IS0m1s3LeUd0au6d?= =?us-ascii?Q?7gxUX8TzKxYfwTZ5eJVsGdOw2q+hFKklgEgbFHfSmh3zaAMZsLzPzGuV8w3a?= =?us-ascii?Q?mVd5WEVT82zOGbashZ8hB3SJWvZ3mvWV?= 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)(376014)(82310400026)(36860700013);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 06 Aug 2024 22:02:11.9200 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 8a71f9fe-1069-464b-e497-08dcb6636c9e 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: SN1PEPF000397AF.namprd05.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: MN2PR12MB4160 Content-Type: text/plain; charset="utf-8" The ABMC feature provides an option to the user to assign a hardware counter to an RMID and monitor the bandwidth as long as the counter is assigned. Number of assignments depend on number of monitoring counters available. Provide the interface to display the number of monitoring counters supported. Signed-off-by: Babu Moger --- 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_counte --- Documentation/arch/x86/resctrl.rst | 3 +++ arch/x86/kernel/cpu/resctrl/monitor.c | 2 ++ arch/x86/kernel/cpu/resctrl/rdtgroup.c | 16 ++++++++++++++++ 3 files changed, 21 insertions(+) diff --git a/Documentation/arch/x86/resctrl.rst b/Documentation/arch/x86/re= sctrl.rst index d4ec605b200a..fe9f10766c4f 100644 --- a/Documentation/arch/x86/resctrl.rst +++ b/Documentation/arch/x86/resctrl.rst @@ -291,6 +291,9 @@ with the following files: as long as there are enough RMID counters available to support number of monitoring groups. =20 +"num_mbm_cntrs": + The number of monitoring counters available for assignment. + "max_threshold_occupancy": Read/write file provides the largest value (in bytes) at which a previously used LLC_occupancy diff --git a/arch/x86/kernel/cpu/resctrl/monitor.c b/arch/x86/kernel/cpu/re= sctrl/monitor.c index 5e8706ab6361..83329cefebf7 100644 --- a/arch/x86/kernel/cpu/resctrl/monitor.c +++ b/arch/x86/kernel/cpu/resctrl/monitor.c @@ -1242,6 +1242,8 @@ int __init rdt_get_mon_l3_config(struct rdt_resource = *r) r->mon.num_mbm_cntrs =3D (ebx & 0xFFFF) + 1; if (WARN_ON(r->mon.num_mbm_cntrs > 64)) r->mon.num_mbm_cntrs =3D 64; + + resctrl_file_fflags_init("num_mbm_cntrs", RFTYPE_MON_INFO); } } =20 diff --git a/arch/x86/kernel/cpu/resctrl/rdtgroup.c b/arch/x86/kernel/cpu/r= esctrl/rdtgroup.c index d8f85b20ab8f..ab4fab3b7cf1 100644 --- a/arch/x86/kernel/cpu/resctrl/rdtgroup.c +++ b/arch/x86/kernel/cpu/resctrl/rdtgroup.c @@ -865,6 +865,16 @@ static int rdtgroup_mbm_mode_show(struct kernfs_open_f= ile *of, return 0; } =20 +static int rdtgroup_num_mbm_cntrs_show(struct kernfs_open_file *of, + struct seq_file *s, void *v) +{ + struct rdt_resource *r =3D of->kn->parent->priv; + + seq_printf(s, "%d\n", r->mon.num_mbm_cntrs); + + return 0; +} + #ifdef CONFIG_PROC_CPU_RESCTRL =20 /* @@ -1936,6 +1946,12 @@ static struct rftype res_common_files[] =3D { .seq_show =3D rdtgroup_cpus_show, .fflags =3D RFTYPE_BASE, }, + { + .name =3D "num_mbm_cntrs", + .mode =3D 0444, + .kf_ops =3D &rdtgroup_kf_single_ops, + .seq_show =3D rdtgroup_num_mbm_cntrs_show, + }, { .name =3D "cpus_list", .mode =3D 0644, --=20 2.34.1 From nobody Sat Feb 7 21:19:49 2026 Received: from NAM10-BN7-obe.outbound.protection.outlook.com (mail-bn7nam10on2055.outbound.protection.outlook.com [40.107.92.55]) (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 188F4170A02; Tue, 6 Aug 2024 22:02:21 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.92.55 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1722981743; cv=fail; b=O6WCbrCc4XbohQb+LvUSAYbFzSkiK9JWUfsWumRGdByDbbLZ75s22eXRUIsl5O8X8oLAP7SN8G95rRJWybZsNA5gUV1qjwsfGOcin3O9eQVoPrksqqiiZnVDwEP956nPBkTbuNpG4MUXZDTHcC4vO2bm17Y8aXDWSJdaPyI8GtA= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1722981743; c=relaxed/simple; bh=L8gB2Ic+eRm/bZx5HN4xXj/b9msPSsotYTDPmW5iYmY=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=RtgoOZBImXvOQ8w2Zr9U/IMYjD2a8puLiUOk6fKPco1SBuU4Gh8dc9wYq34GoaPVp9XS/iLKmv8aucymCnd3caKk7b2gPAHDqlA9UT3ZHBxx40SqYUONTEwJA5d6xfpV+V/MkGccRZXqZAuNidR5/1rVI85LN7TOnUMKKYLZtOY= 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=MP7m55n9; arc=fail smtp.client-ip=40.107.92.55 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="MP7m55n9" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=EmhrRQIpiFwHngnC48JZRGCigxWEKyquBCFcWFRhl7LFJOnEs10ZgqniyAyAgSCioEpW8+/+klt4d2ymb+xuN0TXieLVoxWf3ifvfMQ0wIW6swc6rF9fhrXBr/ZvT17MfBtn3hsKdkFUJ9Rl9ZUQZg3y2tGW/Kj+QnR3+okzmFcquSuuKzNvNQ0xBT8iPl+3cku+MpyUWXC/AnQEQBEf77CLSVtjOYi2UNlFhQ4d3tpO2L1p6PmoMb2JHUoy1xd4IXV0YonT9RyZBTB7tG2CrUmdnYgutvtHnZPGXPZ/1Vt6nhScwpr9CU3fD4pNyHsSIVGi5r2bYzVYMjYOugUKIA== 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=chaZmqiJK292yC3DqytnWnFh15X6uYnKA8FqB6VgXdA=; b=uGJdFp0SVffUvDhaYUh7Gq7upSNLbRoX/n6ZuHufRnrg/w3YSwlLYbNQupY3Hwkj28gfblJghTjgUd9vJVPnhNvvwSuPlzN3kG1jShQh5pyqb+H3HXdND88gogYhKkxqSJWx6gsByzO22bQAx6KOJbj3H5nFulw47P5mQ9mTI5Gej61g9ewk8NWmLrO3eksGXdPHCWIjb5feCbbBFuwZoqvBCfcTxwNkNeaYws2lf14JXrtpPJZx2gICAaT6gA4T/m0CjzVNfan2f0QYI19V1APMUC4uaskUyC/j+QYx0BQku/VI52JMxl23AZtDTkFxoK/cjoSURBFiL88+J+z9MA== 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=chaZmqiJK292yC3DqytnWnFh15X6uYnKA8FqB6VgXdA=; b=MP7m55n9G5ynhGxtTzuACCPFapDiIQ1/6n0tUzKSxeylSkRSFvrvFKQB0WJmXKnHfbX2qZP5bZXpInR1HrXOf34HvkCegO+g3KPo2Z8CCESrUcyHFI58gqegrvcDAkksMjLy/O629CiBnXNVUbGq3PwCl7LRjnGa2M38wPU4noQ= Received: from PH7P220CA0131.NAMP220.PROD.OUTLOOK.COM (2603:10b6:510:327::33) 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.7807.28; Tue, 6 Aug 2024 22:02:18 +0000 Received: from SN1PEPF000397AF.namprd05.prod.outlook.com (2603:10b6:510:327:cafe::23) by PH7P220CA0131.outlook.office365.com (2603:10b6:510:327::33) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7849.13 via Frontend Transport; Tue, 6 Aug 2024 22:02:18 +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 SN1PEPF000397AF.mail.protection.outlook.com (10.167.248.53) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.7828.19 via Frontend Transport; Tue, 6 Aug 2024 22:02: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; Tue, 6 Aug 2024 17:02:13 -0500 From: Babu Moger To: , , , , , , CC: , , , , , , , , , , , , , , , , , , , , , , , , , , , , Subject: [PATCH v6 09/22] x86/resctrl: Introduce MBM counters bitmap Date: Tue, 6 Aug 2024 17:00:46 -0500 Message-ID: <2bdc7920f9dfc24994fe280649cf26dc566a7a90.1722981659.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: SN1PEPF000397AF:EE_|SN7PR12MB7933:EE_ X-MS-Office365-Filtering-Correlation-Id: bab95ec7-3a3a-43b7-575a-08dcb663707c X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|1800799024|36860700013|82310400026|7416014|376014; X-Microsoft-Antispam-Message-Info: =?us-ascii?Q?6fIp+1rJ7EP98kRH/vJ7PU94y4kn+xEgkgXD900TQXtKtQ99fqLA4Q5bzFkH?= =?us-ascii?Q?3Zu5vgxqxGCLe+7QQyoXdEDTJflejGd4wnUVIOrnVDtZRzQYo/qF8uSo390J?= =?us-ascii?Q?S9sMxQGtjtKvY2fKBanP6VCkdF927ala+mcc6V3kRKXB0XB2ime+B89mKpr4?= =?us-ascii?Q?HCgL7ZLNaR/hrYQBYSpHYz+/FnNsu7dEFojiZW1X+d7OQrjOb58/kJm6KSHk?= =?us-ascii?Q?5sfGOmCuaZQ3TDb9PqahScxsTgH4LMz3kzwpClGTcG1trBH6aIKFCAZjlw1A?= =?us-ascii?Q?hsPycsoJGx1e5qYgbQ8oslDJmIxtQeerCGy3I2aamWBY5vlf/lG7cT0zXND+?= =?us-ascii?Q?9xqocwmg6wLQ6vPE8JXCgjB+NJKUJTY2xk/v/xWG9tIxVBa2V/U2KlKWBqln?= =?us-ascii?Q?XBvE0j79nZ0LKBs+0om56HQHUf/3pUOCTeHcGgY3xA1uJNTBskVANxbsEaCW?= =?us-ascii?Q?abUIoDXahmHXi0NsF5LYuGjpMcPJ/IUBIpbtRWhw/1bQbmNsvQr5LfNJBoVz?= =?us-ascii?Q?wjAAo4slzdzGuZ1AJf+cw4Pgrb8DW1XtWk35F0g2k5v+6b6qxksWkHJYy354?= =?us-ascii?Q?XLP+RFhKmUaYwINILr24uE5BsPzZeHAu8kXfNSp9LcA1odwSi1Cl5NxYLHdl?= =?us-ascii?Q?rVhJEeyvlS/CUaDJSCdlfwjsW0eL1BTlU2Rt0pmcSjnNbthkZRCW5uNBhPkl?= =?us-ascii?Q?ponSpMqdFb9CYE7vLMHhCOqZeXmXOlAQfmnLkGrbqxZYX3dtyHlRT3WC1TmG?= =?us-ascii?Q?NzonurfrCy1J6056nPhU9Cc4RJyJ/h6yyuPVmyQxe9qY2tDFWMEMYxQXEygk?= =?us-ascii?Q?MVMVRR1PsG72WvMDvdd9vVkn9DzE4CJvoyFvoIYSVx8ehrMsYx+OEAaQlnjC?= =?us-ascii?Q?Zd7VLD1Ol75o8dIlimM8GqUS2DmADtleP7s5i0MXDimBjh4EYqmj6oPtqn59?= =?us-ascii?Q?ArUhvnGJrsHP635x/397WEWR0nHmj9IDx455YlKY6o/uF4gCE4nIABDT4BWS?= =?us-ascii?Q?DTXUCc2mfR/cXYEx1zwwlIjYWLqi5isd14W+jvsVk9xeh07nTjHwAmJNWzNu?= =?us-ascii?Q?EhHTkP3vqcwJrdUfEc4Q965LxaCAMsl2IDdPXhcn1kBKSdIpUeTp+0mY5NXf?= =?us-ascii?Q?G1d4lISTO0AHkDxYU4q/FsxNnj0nZtA/hKhsQs+oC7Ep/C/nSK5/ul1d0RzK?= =?us-ascii?Q?0i4VXdZ6l1mJP4Dp2s5B3uu4pWdS4v6YoXaKwK/XtWagWrAcpo86/Sl0Cwec?= =?us-ascii?Q?CLbP9T7ejli+KkI3uS+d48byOsE5rPs72bUhDXxLy9JwBjqbuDodNHAflWmi?= =?us-ascii?Q?zmL2Lckvh2aCRpk+pl1cupSHuKsPAEJ3fsk05aGrVcI1L6Rygpq/2HMNFMb+?= =?us-ascii?Q?Up8JiBeJ75NF0Ov6cndzLZxoekU4nzLsl7hdb038UaY93XeUVytBwyDq8yEV?= =?us-ascii?Q?BzCSoGTZ1FPLujrExGXMVGPxPPgEvLbm?= 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)(82310400026)(7416014)(376014);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 06 Aug 2024 22:02:18.4201 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: bab95ec7-3a3a-43b7-575a-08dcb663707c 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: SN1PEPF000397AF.namprd05.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: SN7PR12MB7933 Content-Type: text/plain; charset="utf-8" Hardware provides a set of counters when mbm_cntr_assignable feature is supported. These counters are used for assigning the events in resctrl group when the feature is enabled. Introduce mbm_cntrs_free_map bitmap to track available and free counters and set of routines to allocate and free the counters. Signed-off-by: Babu Moger --- v6: Removed the variable mbm_cntrs_free_map_len. This is not required. Removed the call mbm_cntrs_init() in arch code. This needs to be done at higher level. Used DECLARE_BITMAP to initialize mbm_cntrs_free_map. Moved all the counter interfaces mbm_cntr_alloc() and mbm_cntr_free() in here as part of separating arch and fs bits. v5: Updated the comments and commit log. Few renames num_cntrs_free_map -> mbm_cntrs_free_map num_cntrs_init -> mbm_cntrs_init Added initialization in rdt_get_tree because the default ABMC enablement happens during the init. v4: Changed the name to num_cntrs where applicable. Used bitmap apis. Added more comments for the globals. v3: Changed the bitmap name to assign_cntrs_free_map. Removed abmc from the name. v2: Changed the bitmap name to assignable_counter_free_map from abmc_counter_free_map. --- arch/x86/kernel/cpu/resctrl/internal.h | 2 ++ arch/x86/kernel/cpu/resctrl/rdtgroup.c | 33 ++++++++++++++++++++++++++ 2 files changed, 35 insertions(+) diff --git a/arch/x86/kernel/cpu/resctrl/internal.h b/arch/x86/kernel/cpu/r= esctrl/internal.h index 154983a67646..6263362496a3 100644 --- a/arch/x86/kernel/cpu/resctrl/internal.h +++ b/arch/x86/kernel/cpu/resctrl/internal.h @@ -662,6 +662,8 @@ void __check_limbo(struct rdt_mon_domain *d, bool force= _free); void rdt_domain_reconfigure_cdp(struct rdt_resource *r); void __init resctrl_file_fflags_init(const char *config, unsigned long fflags); +int mbm_cntr_alloc(struct rdt_resource *r); +void mbm_cntr_free(u32 cntr_id); void rdt_staged_configs_clear(void); bool closid_allocated(unsigned int closid); int resctrl_find_cleanest_closid(void); diff --git a/arch/x86/kernel/cpu/resctrl/rdtgroup.c b/arch/x86/kernel/cpu/r= esctrl/rdtgroup.c index ab4fab3b7cf1..c818965e36c9 100644 --- a/arch/x86/kernel/cpu/resctrl/rdtgroup.c +++ b/arch/x86/kernel/cpu/resctrl/rdtgroup.c @@ -185,6 +185,37 @@ bool closid_allocated(unsigned int closid) return !test_bit(closid, &closid_free_map); } =20 +/* + * Counter bitmap for tracking the available counters. + * ABMC feature provides set of hardware counters for enabling events. + * Each event takes one hardware counter. Kernel needs to keep track + * of number of available counters. + */ +static DECLARE_BITMAP(mbm_cntrs_free_map, 64); + +static void mbm_cntrs_init(struct rdt_resource *r) +{ + bitmap_fill(mbm_cntrs_free_map, r->mon.num_mbm_cntrs); +} + +int mbm_cntr_alloc(struct rdt_resource *r) +{ + int cntr_id; + + cntr_id =3D find_first_bit(mbm_cntrs_free_map, r->mon.num_mbm_cntrs); + if (cntr_id >=3D r->mon.num_mbm_cntrs) + return -ENOSPC; + + __clear_bit(cntr_id, mbm_cntrs_free_map); + + return cntr_id; +} + +void mbm_cntr_free(u32 cntr_id) +{ + __set_bit(cntr_id, mbm_cntrs_free_map); +} + /** * rdtgroup_mode_by_closid - Return mode of resource group with closid * @closid: closid if the resource group @@ -2748,6 +2779,8 @@ static int rdt_get_tree(struct fs_context *fc) =20 closid_init(); =20 + mbm_cntrs_init(&rdt_resources_all[RDT_RESOURCE_L3].r_resctrl); + if (resctrl_arch_mon_capable()) flags |=3D RFTYPE_MON; =20 --=20 2.34.1 From nobody Sat Feb 7 21:19:49 2026 Received: from NAM12-DM6-obe.outbound.protection.outlook.com (mail-dm6nam12on2040.outbound.protection.outlook.com [40.107.243.40]) (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 8DAD1170A02; Tue, 6 Aug 2024 22:02:28 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.243.40 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1722981750; cv=fail; b=PdFgPH8NyDPDRUJljt8sNq0UpVRLqL3o5Y8h0w/X066ku/g+5qmnaVsw3T6M7lU5SV0+xQhgf3fwbl2VJJGwYidabqB+UXG9GgouPDEPqGzyXCdp1yR+2R92rtcMaRTQ9Ogx5vUeXc710Y/f9ZLZnZsufPGGH87wWRxYWzYtq28= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1722981750; c=relaxed/simple; bh=CqU0znsNpN6csqO3ixeF6ajtoO1ymsXAdH46z8rAP50=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=hX2c7mHOwZDq4U5fRLGbgYA2QXkIX2YdcAbXWkjhRyFeEwpq4b5BPRfm6uEiIcUzLD6O2IKw6P5RLv7vudU5e8yCOWnaN0XmiVVbpKOJlXqE2q7YJbBIsuJXDfAHbbzHfJ/qJ56sB3hvegAC2A9xEBHvV85wz8nbrrquyIxCQ1o= 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=r5DUlnOL; arc=fail smtp.client-ip=40.107.243.40 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="r5DUlnOL" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=lbNtvdRXdhsECh68dNRR+6vfEDsacTbtNjHbppQzBe6PFxP26a2MBetTVqcvfbU1qfxt+YuNGPCjOeLH3rdFjNDFwVMy7Dyq00/+wk5DR8z06Iw8TyzPajPaWTLoatQoXmD8C1c4IBcmp0Z4AO4J63By4WeSQ7NtLGLsMVMGLlJ2tifzHClqSKfDCc6LBQbP29ZMfkPK29Fz9wPNWa+iGfYNbPWtHynfY36PPttLTWgTDqYTony0QZUkcDBkH35ULeq0hZ2G9fez4EH2IUKgDmyrGCZ/kaj6bgCbOSyHeznHN0hPXe6U0782EbhMCDP3CsZ+OeUXWFHB7h6hRCeguA== 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=3iubdRcBETQPHWR+Rf5QBUk/M26q58CDUzx8ej1IkuI=; b=nblAL/rC/gEbpSgSvVP+MJEqZaKJ9n5JZ3yMYr1Xnz9S4xogFlEKoRA02o3LKdWkVEPq3qyMd+4iBU9XzKDlsjoKS11r1kFA6ljbQxqu5Ia7obCq1mSYJv4aqQ/1Ts4J8QV7Wte1EqcAmuRN8DiVHSzY7UC/BiYIT3XzTc9r4Ckfm7nR1bzPMBTz4T7Hxi5TAAgiL5GDY4+/Q698Woj7qxRhtFvbBsXvYakGgTMM3m/NpgplZuq2QtaZZAgDkYBqkTHEp99ugSsulmdrelkEPFYmz5rOer2ds+49a8kX4zULrSRYoKr19xIJdbqeQqzk45VYBhgRR84fRMyu2QwmnQ== 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=3iubdRcBETQPHWR+Rf5QBUk/M26q58CDUzx8ej1IkuI=; b=r5DUlnOLex7lVyusUJb43pS9TZozm8vuZ3/H2Vd60zDpQIWO+O0jrLntYtSgPfEGQbuN+vP2p4y1THD3KWeER6Ww8zTAjrJ9yUyN+7/G3R7vTATLuFjeLeYnatzVLxum0HLsAdXGVwnlB9koG5GiE2EsL6JIdh3hYsEOXfgfCMs= Received: from SN6PR2101CA0008.namprd21.prod.outlook.com (2603:10b6:805:106::18) by BL3PR12MB6523.namprd12.prod.outlook.com (2603:10b6:208:3bf::15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7828.27; Tue, 6 Aug 2024 22:02:25 +0000 Received: from SN1PEPF000397B1.namprd05.prod.outlook.com (2603:10b6:805:106:cafe::3f) by SN6PR2101CA0008.outlook.office365.com (2603:10b6:805:106::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7849.6 via Frontend Transport; Tue, 6 Aug 2024 22:02:25 +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 SN1PEPF000397B1.mail.protection.outlook.com (10.167.248.55) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.7828.19 via Frontend Transport; Tue, 6 Aug 2024 22:02:24 +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; Tue, 6 Aug 2024 17:02:21 -0500 From: Babu Moger To: , , , , , , CC: , , , , , , , , , , , , , , , , , , , , , , , , , , , , Subject: [PATCH v6 10/22] x86/resctrl: Introduce mbm_total_cfg and mbm_local_cfg Date: Tue, 6 Aug 2024 17:00:47 -0500 Message-ID: <9f014a567d8b5a5c47a4e4438eae3de7f2633302.1722981659.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: SN1PEPF000397B1:EE_|BL3PR12MB6523:EE_ X-MS-Office365-Filtering-Correlation-Id: 52e6e254-f48e-42e0-8c7f-08dcb6637464 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|82310400026|376014|7416014|1800799024|36860700013; X-Microsoft-Antispam-Message-Info: =?us-ascii?Q?wnxauMwbQZNSj4QVchsMFbX01GjrGW18HFsFsAkvkK8Rr6CRJjlSqZPmmdrr?= =?us-ascii?Q?2PyR7TB9upBECMzB6+Ub2wZbkxUTTyKpsYuMXo5jai3r+AJEvNnoqs8e8r1m?= =?us-ascii?Q?yi3Z0zycy3f8K9zqwLNWX1GIAjgvdIukn1jJzY6V99glkWNYN6hPc3pE/ViR?= =?us-ascii?Q?qbhizmBOsn49mY+utcGeEyuSGPcqWyNIzY2hVvzSG/pGW29jhCkIoJu1LmQ5?= =?us-ascii?Q?YpZnseQwov9HGkJOGmvFn5X+H/egOe41l+kX+6yR8F9qijfrKMk8WkPboWnw?= =?us-ascii?Q?miFHtlTl35f8YS8bv5LUKpiaovKcUFtOe4Lp12q6zgJR/CEuOucFocPFGnta?= =?us-ascii?Q?4Z1WsVZHx42rszgLZDYBrD7gRicBaralHaccbJMqGqpb5PhSFAmXlJJJxmM9?= =?us-ascii?Q?rXW8LebZOkNmtSIAzqAsHTyMDU0QU5RpJR+5D+EsjTpi486hShtkilurcbaU?= =?us-ascii?Q?snRmMZr1KB0rGXptrdc1ylEOzx7TRUZij8jUZvBURlKS/gA8LfPPZyQuoKDw?= =?us-ascii?Q?/yGabtWCOzLiikvCv1cKraHgy72fowzGVUQTqEIHxFigdvFkNxqbnpWjdMTD?= =?us-ascii?Q?U7CBCYlm0YOQj8rBAF77rYj1Irs0eFuk9UKHZK0Gz8RsevsVSCwyDV4Raj38?= =?us-ascii?Q?CTtsnzrY1ZF814VTXCYB3GRrFNZAsy5nWH0RI/BzNKmmOlCTMzgU60lzRQqg?= =?us-ascii?Q?p45yoCRQkVoew3nkH9yi8o0b5hcqAnfCpza+v2i2Y0w+dnJkZON0cYtENoYu?= =?us-ascii?Q?a/A5tCiLvN1MQfrPzLa7Y8DRdAWmL/y0k7UAuVnPRtYytNzk69gbDctnpdi/?= =?us-ascii?Q?yXC2bFzacTAwnYyXcIUTT103mXnyyhWAjscANjd9ZmoggEltxGm6SZoHBl5C?= =?us-ascii?Q?6m1pQ7aT3ZyFiZyQaIRdUIdcRIKpexOHxHI52gqXatlV4gtsZ0QivZFE03Vt?= =?us-ascii?Q?ZQONJyPqAWHykRkA4Eap0QZ1ZeSmizJGu21070z7HkNCFWC2OeONSVevLIcp?= =?us-ascii?Q?IT26B7VAf4aaVaLaClor6ReGujDER2U/0no2enRmqZ5XtoIEp/btOOVNgJld?= =?us-ascii?Q?v941sGBpzDGU4MIv+aSCrwogwQ0dbl3zTWS5v6kHeXUXNo/o1ohUwwCJnMxC?= =?us-ascii?Q?NFN13CtEeGkFjVFcian6mgBJoakNVpimd9DjNz6IbiH47IerR0lhCevQ5MaE?= =?us-ascii?Q?mcvL1f4GJU+lvcLHncmiETYhdNBvBBbNZXEMJAQ1Y3Z7bTvGRgiwSzS5hepq?= =?us-ascii?Q?l6AVZ/TrfbtViMD7c9SQuoBCx0GN2l11K6yFFEaZq9yB1hjuQ3jlxB7NGha5?= =?us-ascii?Q?cLy704CNy0YaDwpW/dFC21uZAnvHKK1ctFWaRjdbPyue5ANnmgNCWii/mAG4?= =?us-ascii?Q?q8fXz8HO5b2+0IyIv2sDZbMv1nqoId0s5RbTzPmmG9ud1e9CL4+Vk4dYE/vq?= =?us-ascii?Q?4FBCZ5HqI/U=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)(7416014)(1800799024)(36860700013);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 06 Aug 2024 22:02:24.9750 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 52e6e254-f48e-42e0-8c7f-08dcb6637464 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: SN1PEPF000397B1.namprd05.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: BL3PR12MB6523 Content-Type: text/plain; charset="utf-8" If the BMEC (Bandwidth Monitoring Event Configuration) feature is supported, the bandwidth events can be configured to track specific events. The event configuration is domain specific. ABMC (Assignable Bandwidth Monitoring Counters) feature needs event configuration information to assign hardware counter to an RMID. Event configurations are not stored in resctrl but instead always read from or written to hardware directly when prompted by user space. Read the event configuration from the hardware during the domain initialization. Save the configuration information in rdt_hw_mon_domain, so it can be used for counter assignment. Signed-off-by: Babu Moger --- v6: Renamed resctrl_arch_mbm_evt_config -> resctrl_mbm_evt_config_init Initialized value to INVALID_CONFIG_VALUE if it is not configurable. Minor commit message update. v5: Exported mon_event_config_index_get. Renamed arch_domain_mbm_evt_config to resctrl_arch_mbm_evt_config. v4: Read the configuration information from the hardware to initialize. Added few commit messages. Fixed the tab spaces. v3: Minor changes related to rebase in mbm_config_write_domain. v2: No changes. --- arch/x86/kernel/cpu/resctrl/core.c | 2 ++ arch/x86/kernel/cpu/resctrl/internal.h | 9 +++++++++ arch/x86/kernel/cpu/resctrl/monitor.c | 26 ++++++++++++++++++++++++++ arch/x86/kernel/cpu/resctrl/rdtgroup.c | 4 +--- 4 files changed, 38 insertions(+), 3 deletions(-) diff --git a/arch/x86/kernel/cpu/resctrl/core.c b/arch/x86/kernel/cpu/resct= rl/core.c index ff5cb693b396..6fb0cfdb5529 100644 --- a/arch/x86/kernel/cpu/resctrl/core.c +++ b/arch/x86/kernel/cpu/resctrl/core.c @@ -619,6 +619,8 @@ static void domain_add_cpu_mon(int cpu, struct rdt_reso= urce *r) =20 arch_mon_domain_online(r, d); =20 + resctrl_mbm_evt_config_init(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/internal.h b/arch/x86/kernel/cpu/r= esctrl/internal.h index 6263362496a3..4d8cc36a8d79 100644 --- a/arch/x86/kernel/cpu/resctrl/internal.h +++ b/arch/x86/kernel/cpu/resctrl/internal.h @@ -56,6 +56,9 @@ /* Max event bits supported */ #define MAX_EVT_CONFIG_BITS GENMASK(6, 0) =20 +#define INVALID_CONFIG_VALUE U32_MAX +#define INVALID_CONFIG_INDEX UINT_MAX + /* Setting bit 0 in L3_QOS_EXT_CFG enables the ABMC feature. */ #define ABMC_ENABLE_BIT 0 =20 @@ -401,6 +404,8 @@ struct rdt_hw_ctrl_domain { * @d_resctrl: Properties exposed to the resctrl file system * @arch_mbm_total: arch private state for MBM total bandwidth * @arch_mbm_local: arch private state for MBM local bandwidth + * @mbm_total_cfg: MBM total bandwidth configuration + * @mbm_local_cfg: MBM local bandwidth configuration * * Members of this structure are accessed via helpers that provide abstrac= tion. */ @@ -408,6 +413,8 @@ struct rdt_hw_mon_domain { struct rdt_mon_domain d_resctrl; struct arch_mbm_state *arch_mbm_total; struct arch_mbm_state *arch_mbm_local; + u32 mbm_total_cfg; + u32 mbm_local_cfg; }; =20 static inline struct rdt_hw_ctrl_domain *resctrl_to_arch_ctrl_dom(struct r= dt_ctrl_domain *r) @@ -664,6 +671,8 @@ void __init resctrl_file_fflags_init(const char *config, unsigned long fflags); int mbm_cntr_alloc(struct rdt_resource *r); void mbm_cntr_free(u32 cntr_id); +void resctrl_mbm_evt_config_init(struct rdt_hw_mon_domain *hw_dom); +unsigned int mon_event_config_index_get(u32 evtid); void rdt_staged_configs_clear(void); bool closid_allocated(unsigned int closid); int resctrl_find_cleanest_closid(void); diff --git a/arch/x86/kernel/cpu/resctrl/monitor.c b/arch/x86/kernel/cpu/re= sctrl/monitor.c index 83329cefebf7..2f4d0c12b80d 100644 --- a/arch/x86/kernel/cpu/resctrl/monitor.c +++ b/arch/x86/kernel/cpu/resctrl/monitor.c @@ -1254,6 +1254,32 @@ int __init rdt_get_mon_l3_config(struct rdt_resource= *r) return 0; } =20 +void resctrl_mbm_evt_config_init(struct rdt_hw_mon_domain *hw_dom) +{ + unsigned int index; + u64 msrval; + + /* + * Read the configuration registers QOS_EVT_CFG_n, where is + * the BMEC event number (EvtID). + */ + if (mbm_total_event.configurable) { + index =3D mon_event_config_index_get(QOS_L3_MBM_TOTAL_EVENT_ID); + rdmsrl(MSR_IA32_EVT_CFG_BASE + index, msrval); + hw_dom->mbm_total_cfg =3D msrval & MAX_EVT_CONFIG_BITS; + } else { + hw_dom->mbm_total_cfg =3D INVALID_CONFIG_VALUE; + } + + if (mbm_local_event.configurable) { + index =3D mon_event_config_index_get(QOS_L3_MBM_LOCAL_EVENT_ID); + rdmsrl(MSR_IA32_EVT_CFG_BASE + index, msrval); + hw_dom->mbm_local_cfg =3D msrval & MAX_EVT_CONFIG_BITS; + } else { + hw_dom->mbm_total_cfg =3D INVALID_CONFIG_VALUE; + } +} + void __exit rdt_put_mon_l3_config(void) { dom_data_exit(); diff --git a/arch/x86/kernel/cpu/resctrl/rdtgroup.c b/arch/x86/kernel/cpu/r= esctrl/rdtgroup.c index c818965e36c9..02afd3442876 100644 --- a/arch/x86/kernel/cpu/resctrl/rdtgroup.c +++ b/arch/x86/kernel/cpu/resctrl/rdtgroup.c @@ -1609,8 +1609,6 @@ struct mon_config_info { u32 mon_config; }; =20 -#define INVALID_CONFIG_INDEX UINT_MAX - /** * mon_event_config_index_get - get the hardware index for the * configurable event @@ -1620,7 +1618,7 @@ struct mon_config_info { * 1 for evtid =3D=3D QOS_L3_MBM_LOCAL_EVENT_ID * INVALID_CONFIG_INDEX for invalid evtid */ -static inline unsigned int mon_event_config_index_get(u32 evtid) +unsigned int mon_event_config_index_get(u32 evtid) { switch (evtid) { case QOS_L3_MBM_TOTAL_EVENT_ID: --=20 2.34.1 From nobody Sat Feb 7 21:19:49 2026 Received: from NAM11-BN8-obe.outbound.protection.outlook.com (mail-bn8nam11on2068.outbound.protection.outlook.com [40.107.236.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 AD80C176228; Tue, 6 Aug 2024 22:02:34 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.236.68 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1722981756; cv=fail; b=MRWubd7sAwc6pgCgfZQQTbtHWHrU1VOS20SJgF06ZksBbEgkdXQyM1FKF7PFIN4K/LlLtYEVjyWKiJ32G5wrdZEaCiZG0tS9TTfFBombsVyjPouPgWRvwQEGUD9K0OtW9pwNH/6kVsbeLJ2NSQU0nLFArFoSe8lk+wWYGvoD3NY= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1722981756; c=relaxed/simple; bh=8GzP7MBOWnqTs0R7AXNf0NGaUSrA+v5aLKHcLUM435o=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=THTTpOJ2xHFZ5EX5hgDAF00odMSXwR6wBZspdsfOJje71q8FmT62KgsKUW2Gc5deUhRYTZYLQLY02eCTX79t6B7XVImi+0kz41Mvkve371NthVbzu6PiV6Bh94MqEM253MAfA1AUjwqSavepSn64DgHgdboH5DW7v+74GgqNBF4= 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=g8Jf6gTI; arc=fail smtp.client-ip=40.107.236.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="g8Jf6gTI" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=OZcCawZw8Fl3Jh/BrTSq5LaqyBSi0B4alTfVHhYXoIksGvPHOjDGwBwgXKlf8A/+nDvr1WcjQlM6OKlPylNswy1LHtO06IZe0njCQmp+TPdH13QX87hXoS9DgTSoFeTfkuSuaBw59ShzVop2dww/AZ9bXsFbnUcEeevjRM6aE3OPjMbJalzuXTz65JYNZ8xy4xR2HAfsNYwr5lT8EqAL8rf02BJEEHs5ZnzjA2XuBp2uy/pc1kDJAg7Mb0re1qSYEjWSsN/HM9a9oaOGdzc7HF36G47ksIeCxacW4o6Sk+2heeIu7d7xnHIFErTGVlb8OF8Z4DkDgw/wcjPs9RlrvA== 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=fMvi706/mQ9DRdcroxYPFTGH4CV7PENdEuiH2OhsJ0M=; b=bA0cwvRuPEI+owRTzIkJfeQfX4glWrnDeAzQBdtEIQ69MD5RF9GccUVUjhJ9pM69agP8G/H7Lp/s2XBcYryH3UF09AVKipSOJFfIafy+41G/WCHZ005x7yqcqW6QRkKhK4j5o1Aa3qvNHe7wfiU48FTmDfA9Nb4qjLl19QLf7uXmkIZZGFlzWpHLhVpN65pVrEWhiJ+MFGW7FZRV+nxy9yBvImpStmZ7e4PLX7ay+UobcFhZg4mZyY9mPz9RpJwcWr0DuF+fmp+b0YNGLWyRuEcwUjrqfZycETCGwBWwxG9pAZgPSqcYdsVoR6SyVZ3dXMmhJxfMfXm7S5OlBQ1NPw== 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=fMvi706/mQ9DRdcroxYPFTGH4CV7PENdEuiH2OhsJ0M=; b=g8Jf6gTI3+FALgC80an4oX0C0ANgeJW/RB/V4z+o4UZUgUT7qidDY2UHRMhBYZ5OS/MdgozoY2d7njT5gUdMfL6Yh00+G74b07FWrJXLkC2a3A1kK1YLkIXCZD9tnrt2u50rxabDwAq23XmNy1w1AcMH6uzHA7MliOYDIGIRUOA= Received: from SA9PR13CA0116.namprd13.prod.outlook.com (2603:10b6:806:24::31) by PH8PR12MB7135.namprd12.prod.outlook.com (2603:10b6:510:22c::11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7784.29; Tue, 6 Aug 2024 22:02:31 +0000 Received: from SN1PEPF000397B4.namprd05.prod.outlook.com (2603:10b6:806:24:cafe::f7) by SA9PR13CA0116.outlook.office365.com (2603:10b6:806:24::31) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7849.7 via Frontend Transport; Tue, 6 Aug 2024 22:02: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 SN1PEPF000397B4.mail.protection.outlook.com (10.167.248.58) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.7828.19 via Frontend Transport; Tue, 6 Aug 2024 22:02: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; Tue, 6 Aug 2024 17:02:29 -0500 From: Babu Moger To: , , , , , , CC: , , , , , , , , , , , , , , , , , , , , , , , , , , , , Subject: [PATCH v6 11/22] x86/resctrl: Remove MSR reading of event configuration value Date: Tue, 6 Aug 2024 17:00: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: SN1PEPF000397B4:EE_|PH8PR12MB7135:EE_ X-MS-Office365-Filtering-Correlation-Id: 1dba7810-fc8d-418f-9434-08dcb66377d9 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|82310400026|376014|7416014|36860700013|1800799024; X-Microsoft-Antispam-Message-Info: =?us-ascii?Q?KZSJyA+U6fKF1chmOKAmvamYT8rnYulWSY4CC4MUfmm3jQOLVrjqEAixo5Bo?= =?us-ascii?Q?pMSlaXQ4VMR7EFqhsrT8yoXCbR6WccBMUbYEJQhFqyzCt9D3nO+EG6ryyPAl?= =?us-ascii?Q?Kt/4cpjL8FlcVE0aCZT6xf1Ab3CFYKdTLPyXZ3PmLDUdzfyJDLlfSXTIAkb7?= =?us-ascii?Q?byxlbb1O6xtEpC6fXbh0ZQcTAFfN9exUlsiSZ1vly8K/vOmDCkFqYF9Lj0dt?= =?us-ascii?Q?Y9cKVh+aCUhxbm5fLvOlxCYToRfm5i/3fvPQxNxDNTzSj3u8hKy8zL5DQFPI?= =?us-ascii?Q?ohgkB5RO3jiHUWU97asSL2NcEa27Rlts5oskkJguYykyRKWmzjs0YZTuqh/Y?= =?us-ascii?Q?qsbXX+cO3I9JDaQHOrfbB1M9WfCBQZq1QeAyhCi+1by5kaxpasGt4wDsgTLF?= =?us-ascii?Q?svpyHARA8HDO/rs3tmO7OcMBPlxwYrXLpyWSMbu+rvz6OwfPrVc09HnY4VcH?= =?us-ascii?Q?LgvY1j/OxzVcSLm0l6nVbPt9PK5pV7eoEm3NIxj+GpuAjHzZd+UI4LSK6opq?= =?us-ascii?Q?ceqAFnICrmOzLDWYrYlSSmhJ6Lu3pOLoJf2FPxNG57G2euOZtLSjdhFOrWUk?= =?us-ascii?Q?b4ONM8wo/o/aoYPdDXn4eZ7zRMYgKB9CHZDge6HXES/NRVYIuvp1fVuS6/9n?= =?us-ascii?Q?tO0rVgh5UAm84sqex6xFEHdsxhvNqdgOaU0eS6WDBXvj5dRYjZyCuC1S6hgC?= =?us-ascii?Q?9+l2QDOhDeQsap1DJswtags755V6lL2kcfZ6ZwE8sJHH5GF5X4Z6mEnYaI7B?= =?us-ascii?Q?oJ8gxeKq8Jycj89LDgJzsdAmGhhYzJ2RWAE4vZvO+B77zEiiN6HQ9n9am3EA?= =?us-ascii?Q?+kMbwLLvQ+TvB5OXRGmanE9MorXFONfDtOAee+elQ+uF7Gi+gJHmbPWtp3fV?= =?us-ascii?Q?s9YWbyieQnHgW3eTle5XSQOpRIBiSUi8X1p+ZYuKYx2XGeZn2x1xfssVi5Ub?= =?us-ascii?Q?ZnlnIcznfavWiUnF5OwH/hNoemS5zr9QAKuvNYqEZUVnvtjmh0GAQKSuaS0F?= =?us-ascii?Q?85N7hiH3eegSu55mwkV+dDQ2r30iEsO9QqqCrvZjYabOEMlWhoO6t+ygqtUb?= =?us-ascii?Q?eJnZI4zafIqKu4GO/IJrC0YMrr+x8GOaDlkSleMfEMA2cmj4f3SoLaYAwPEC?= =?us-ascii?Q?0USpk21H1XbmfLdeULb/QhN2B2bxE9rXr0fDD+7nEEcejzvN4/toHiuloJSO?= =?us-ascii?Q?0qaaKohTV/Z749lumaJsnnYAQQ4sLjoI1VkWfRCwwRAbZnPkjdR6hZNTHfE1?= =?us-ascii?Q?YPFuZYm6FKiY5xej1QVBjuua9Eo3oXMd48T3VqcwPaeL+hQ9UPXzTOOcypRk?= =?us-ascii?Q?gHxFfeWpwZeZZTc7hGninDCxbYzV3XpWyEOsUmK5B4xSKSjND/42qYfAeMEE?= =?us-ascii?Q?nGlWwckLs2g0u3thJmYuo46kUAU4QJ5pBVciieVcy+o5c8InPw=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)(7416014)(36860700013)(1800799024);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 06 Aug 2024 22:02:30.7595 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 1dba7810-fc8d-418f-9434-08dcb66377d9 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: SN1PEPF000397B4.namprd05.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH8PR12MB7135 Content-Type: text/plain; charset="utf-8" The event configuration is domain specific and initialized during domain initialization. The values is stored in rdt_hw_mon_domain. It is not required to read the configuration register every time user asks for it. Use the value stored in rdt_hw_mon_domain instead. Introduce resctrl_arch_event_config_get() and resctrl_arch_event_config_set() to get/set architecture domain specific mbm_total_cfg/mbm_local_cfg values. Also, remove unused config value definitions. Signed-off-by: Babu Moger --- v6: Fixed inconstancy with types. Made all the types to u32 for config value. Removed few rdt_last_cmd_puts as it is not necessary. Removed unused config value definitions. Few more updates to commit message. v5: Introduced resctrl_arch_event_config_get and resctrl_arch_event_config_get() based on our discussion. https://lore.kernel.org/lkml/68e861f9-245d-4496-a72e-46fc57d19c62@amd.c= om/ v4: New patch. --- arch/x86/kernel/cpu/resctrl/internal.h | 21 ----- arch/x86/kernel/cpu/resctrl/rdtgroup.c | 104 ++++++++++++++----------- include/linux/resctrl.h | 4 + 3 files changed, 64 insertions(+), 65 deletions(-) diff --git a/arch/x86/kernel/cpu/resctrl/internal.h b/arch/x86/kernel/cpu/r= esctrl/internal.h index 4d8cc36a8d79..1021227d8c7e 100644 --- a/arch/x86/kernel/cpu/resctrl/internal.h +++ b/arch/x86/kernel/cpu/resctrl/internal.h @@ -32,27 +32,6 @@ */ #define MBM_CNTR_WIDTH_OFFSET_MAX (62 - MBM_CNTR_WIDTH_BASE) =20 -/* Reads to Local DRAM Memory */ -#define READS_TO_LOCAL_MEM BIT(0) - -/* Reads to Remote DRAM Memory */ -#define READS_TO_REMOTE_MEM BIT(1) - -/* Non-Temporal Writes to Local Memory */ -#define NON_TEMP_WRITE_TO_LOCAL_MEM BIT(2) - -/* Non-Temporal Writes to Remote Memory */ -#define NON_TEMP_WRITE_TO_REMOTE_MEM BIT(3) - -/* Reads to Local Memory the system identifies as "Slow Memory" */ -#define READS_TO_LOCAL_S_MEM BIT(4) - -/* Reads to Remote Memory the system identifies as "Slow Memory" */ -#define READS_TO_REMOTE_S_MEM BIT(5) - -/* Dirty Victims to All Types of Memory */ -#define DIRTY_VICTIMS_TO_ALL_MEM BIT(6) - /* Max event bits supported */ #define MAX_EVT_CONFIG_BITS GENMASK(6, 0) =20 diff --git a/arch/x86/kernel/cpu/resctrl/rdtgroup.c b/arch/x86/kernel/cpu/r= esctrl/rdtgroup.c index 02afd3442876..0047b4eb0ff5 100644 --- a/arch/x86/kernel/cpu/resctrl/rdtgroup.c +++ b/arch/x86/kernel/cpu/resctrl/rdtgroup.c @@ -1605,10 +1605,57 @@ static int rdtgroup_size_show(struct kernfs_open_fi= le *of, } =20 struct mon_config_info { + struct rdt_mon_domain *d; u32 evtid; u32 mon_config; }; =20 +u32 resctrl_arch_event_config_get(struct rdt_mon_domain *d, + enum resctrl_event_id eventid) +{ + struct rdt_hw_mon_domain *hw_dom =3D resctrl_to_arch_mon_dom(d); + + switch (eventid) { + case QOS_L3_OCCUP_EVENT_ID: + break; + case QOS_L3_MBM_TOTAL_EVENT_ID: + return hw_dom->mbm_total_cfg; + case QOS_L3_MBM_LOCAL_EVENT_ID: + return hw_dom->mbm_local_cfg; + } + + /* Never expect to get here */ + WARN_ON_ONCE(1); + + return INVALID_CONFIG_VALUE; +} + +void resctrl_arch_event_config_set(void *info) +{ + struct mon_config_info *mon_info =3D info; + struct rdt_hw_mon_domain *hw_dom; + unsigned int index; + + index =3D mon_event_config_index_get(mon_info->evtid); + if (index =3D=3D INVALID_CONFIG_INDEX) + return; + + wrmsr(MSR_IA32_EVT_CFG_BASE + index, mon_info->mon_config, 0); + + hw_dom =3D resctrl_to_arch_mon_dom(mon_info->d); + + switch (mon_info->evtid) { + case QOS_L3_OCCUP_EVENT_ID: + break; + case QOS_L3_MBM_TOTAL_EVENT_ID: + hw_dom->mbm_total_cfg =3D mon_info->mon_config; + break; + case QOS_L3_MBM_LOCAL_EVENT_ID: + hw_dom->mbm_local_cfg =3D mon_info->mon_config; + break; + } +} + /** * mon_event_config_index_get - get the hardware index for the * configurable event @@ -1631,33 +1678,11 @@ unsigned int mon_event_config_index_get(u32 evtid) } } =20 -static void mon_event_config_read(void *info) -{ - struct mon_config_info *mon_info =3D info; - unsigned int index; - u64 msrval; - - index =3D mon_event_config_index_get(mon_info->evtid); - if (index =3D=3D INVALID_CONFIG_INDEX) { - pr_warn_once("Invalid event id %d\n", mon_info->evtid); - return; - } - rdmsrl(MSR_IA32_EVT_CFG_BASE + index, msrval); - - /* Report only the valid event configuration bits */ - mon_info->mon_config =3D msrval & MAX_EVT_CONFIG_BITS; -} - -static void mondata_config_read(struct rdt_mon_domain *d, struct mon_confi= g_info *mon_info) -{ - smp_call_function_any(&d->hdr.cpu_mask, mon_event_config_read, mon_info, = 1); -} - static int mbm_config_show(struct seq_file *s, struct rdt_resource *r, u32= evtid) { - struct mon_config_info mon_info =3D {0}; struct rdt_mon_domain *dom; bool sep =3D false; + u32 val; =20 cpus_read_lock(); mutex_lock(&rdtgroup_mutex); @@ -1666,11 +1691,11 @@ static int mbm_config_show(struct seq_file *s, stru= ct rdt_resource *r, u32 evtid if (sep) seq_puts(s, ";"); =20 - memset(&mon_info, 0, sizeof(struct mon_config_info)); - mon_info.evtid =3D evtid; - mondata_config_read(dom, &mon_info); + val =3D resctrl_arch_event_config_get(dom, evtid); + if (val =3D=3D INVALID_CONFIG_VALUE) + break; =20 - seq_printf(s, "%d=3D0x%02x", dom->hdr.id, mon_info.mon_config); + seq_printf(s, "%d=3D0x%02x", dom->hdr.id, val); sep =3D true; } seq_puts(s, "\n"); @@ -1701,33 +1726,23 @@ static int mbm_local_bytes_config_show(struct kernf= s_open_file *of, return 0; } =20 -static void mon_event_config_write(void *info) -{ - struct mon_config_info *mon_info =3D info; - unsigned int index; - - index =3D mon_event_config_index_get(mon_info->evtid); - if (index =3D=3D INVALID_CONFIG_INDEX) { - pr_warn_once("Invalid event id %d\n", mon_info->evtid); - return; - } - wrmsr(MSR_IA32_EVT_CFG_BASE + index, mon_info->mon_config, 0); -} =20 static void mbm_config_write_domain(struct rdt_resource *r, struct rdt_mon_domain *d, u32 evtid, u32 val) { struct mon_config_info mon_info =3D {0}; + u32 config_val; =20 /* - * Read the current config value first. If both are the same then + * Check the current config value first. If both are the same then * no need to write it again. */ - mon_info.evtid =3D evtid; - mondata_config_read(d, &mon_info); - if (mon_info.mon_config =3D=3D val) + config_val =3D resctrl_arch_event_config_get(d, evtid); + if (config_val =3D=3D INVALID_CONFIG_VALUE || config_val =3D=3D val) return; =20 + mon_info.d =3D d; + mon_info.evtid =3D evtid; mon_info.mon_config =3D val; =20 /* @@ -1736,7 +1751,8 @@ static void mbm_config_write_domain(struct rdt_resour= ce *r, * are scoped at the domain level. Writing any of these MSRs * on one CPU is observed by all the CPUs in the domain. */ - smp_call_function_any(&d->hdr.cpu_mask, mon_event_config_write, + smp_call_function_any(&d->hdr.cpu_mask, + resctrl_arch_event_config_set, &mon_info, 1); =20 /* diff --git a/include/linux/resctrl.h b/include/linux/resctrl.h index 72c498deeb5e..ef08f75191f2 100644 --- a/include/linux/resctrl.h +++ b/include/linux/resctrl.h @@ -350,6 +350,10 @@ void resctrl_arch_reset_rmid(struct rdt_resource *r, s= truct rdt_mon_domain *d, */ void resctrl_arch_reset_rmid_all(struct rdt_resource *r, struct rdt_mon_do= main *d); =20 +void resctrl_arch_event_config_set(void *info); +u32 resctrl_arch_event_config_get(struct rdt_mon_domain *d, + enum resctrl_event_id eventid); + extern unsigned int resctrl_rmid_realloc_threshold; extern unsigned int resctrl_rmid_realloc_limit; =20 --=20 2.34.1 From nobody Sat Feb 7 21:19:49 2026 Received: from NAM11-DM6-obe.outbound.protection.outlook.com (mail-dm6nam11on2072.outbound.protection.outlook.com [40.107.223.72]) (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 13376179967; Tue, 6 Aug 2024 22:02:43 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.223.72 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1722981765; cv=fail; b=M33kN4G5QRNKMvgWBVM1R5vMd3Vv14xoLsawVtBXsg+c16iPmG5ympH5WbG72nlDUmkqHKR+YEt96ILsYQgwqwab9e3mEK74plk9iNbk/cDf7dtu4sFH9uQDOlIF5XAlmJkaVAinGJ0I97hcqUoF3aOeLlpIc7X4rlfUl3+OL18= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1722981765; c=relaxed/simple; bh=tdHjo9T4ycAO56/xBxZHmei05ipK5GzS1vleKOZ/z50=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=WULV/yHrtD9HVlTcVhPsScCJGDyU4nOG3x9O8W1VjBuVyBv7hFaRMY5XxzHCGoghhIwr5XL2mkf/Q4xx5aMVDJjOd3iyNMN45nSeL3f1a7EYU50g4f0cBZ+1eJPu1o3+cx3idurijaAw/1tD/81NCG646PZYu9zM/AsFLimhags= 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=yif36IZf; arc=fail smtp.client-ip=40.107.223.72 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="yif36IZf" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=DmpuB+f6WUIr0G7fsF/1I0g5WlpVReOzIQdD2oyAzWd/SI/Jrv4ZFJOzeryJjU9es53xZEjKMpMbbrRkwfXaKoaw7TI4V6tpB0o32ttpCXyKf7DZWbRKKo6SMybLI3Guo8ji/QPt7ICL5j5xgYYn6FF9DDMfKNbfMAMS/rHzLgvP7qYnN/UYWmA0tONrtBWtU33SNEHOM73q4P50g/r5KqFIQtui3Si4f7UYLhOpiJXm38oSY7vX6iV8fbNT+kUe11Hdcn1lpn3qcldIAyfkt8EZK2UJA00LN4cKcMHLb1RClmnHPGhRGx0en/fXgD/PTxok2+mCC8AYwdp0axOqeQ== 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=pexdJ/VZaAfU7NL0kG6dEUV7XURs0Rf1NSdEfVC3qAw=; b=ORdwd2EYaqEaXDFI1M3CbcwBNDNzzDI6s0NQzXrWtWOzlUWtFaFxZ1t+5HFMU/tCTUYiznxDBQrlsEOLIahH8ZBFcBgmnRAxzSAUvf0jHl4WTPbglh044HuEYgefHBno6+S3UfbyBH2LTgoYzN+WuWX47+AxVScpTr72i1pXZeSx9NyDqHIgf9ZwbL3yCnmEGypnTap3Mr2uJuiAZsuALoa9bg6pVqTxW5RQ96Wm6wVolrFm0uCl6fBc6VwVS1JrQq/HyJscSdgo2S2Lt9VQXIFuwuCUdRSgGklsjvhkeB+pf4hSgmGjErMWblTqTo2b1GXfZ9pHK04FY12u7LobYQ== 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=pexdJ/VZaAfU7NL0kG6dEUV7XURs0Rf1NSdEfVC3qAw=; b=yif36IZfNDMYWjryisqfsTR84Gp4kxYi6xkaqTppFvzPsvsPPZIf7Sv6YK0N4YmwJnFUn9H0+pDgGud7XqySJk4e5cTc4ehu/aywIeW1qlSlkWUZ62Ml0l29fKaVYXYAtOSrA5n/2RsiozuzHdGWZbiHESvGJp2QLt85OTSzojg= Received: from PH7P220CA0144.NAMP220.PROD.OUTLOOK.COM (2603:10b6:510:327::6) by DM3PR12MB9415.namprd12.prod.outlook.com (2603:10b6:8:1ac::7) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7828.26; Tue, 6 Aug 2024 22:02:38 +0000 Received: from SN1PEPF000397AF.namprd05.prod.outlook.com (2603:10b6:510:327:cafe::3f) by PH7P220CA0144.outlook.office365.com (2603:10b6:510:327::6) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7849.13 via Frontend Transport; Tue, 6 Aug 2024 22:02:38 +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 SN1PEPF000397AF.mail.protection.outlook.com (10.167.248.53) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.7828.19 via Frontend Transport; Tue, 6 Aug 2024 22:02: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; Tue, 6 Aug 2024 17:02:36 -0500 From: Babu Moger To: , , , , , , CC: , , , , , , , , , , , , , , , , , , , , , , , , , , , , Subject: [PATCH v6 12/22] x86/resctrl: Introduce mbm_cntr_map to track counters at domain Date: Tue, 6 Aug 2024 17:00: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: SN1PEPF000397AF:EE_|DM3PR12MB9415:EE_ X-MS-Office365-Filtering-Correlation-Id: 7fa50add-a1ad-44d3-1002-08dcb6637c36 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|7416014|376014|82310400026|36860700013|1800799024; X-Microsoft-Antispam-Message-Info: =?us-ascii?Q?YS+ROqJp9dUj8hfLCFT0PFtTLZS7fVbSAJKLvtYPkAZ/ZuVP+3vEk7rSd+TB?= =?us-ascii?Q?Fyq/0yzk+RhAL1Dwdkfu3yGrBvbwfY/3dEabwKuCSW9YYFAQxqGML0JbpVrP?= =?us-ascii?Q?o4TtRhROVgBZyVVDderXJ980AG8GV5sPN8mZkgqqs85SAo+7KmiYAOv5tlV5?= =?us-ascii?Q?FXD8BpREbqCtp7rDh3Nbnu+yAmIAeF/Ae3QslW5ZTn6Fy8PiRsAHF2aQlPe8?= =?us-ascii?Q?nzviOjlS8f828LmJleszUvAkMf28Gg44gY/BIOCWMBrRAtptoq3sGKrZ58na?= =?us-ascii?Q?Tl2BGZunvk4SNUcJ1VaEWQ9Wzta9Ugv4EPl2hdtWdbse4QMmZXZjmCMKPsgP?= =?us-ascii?Q?dIZbhOPgUrR2OSHxEcgpT4isn8dOFsNEPAbu01OYdXzP7RIvdDY3fT54uX8c?= =?us-ascii?Q?D2NQYEeSgOfIY98/zu/0Q5M4wdHXkNplUDryJC/Be+/HrjQfiel7mnfV4NOy?= =?us-ascii?Q?1nydq+AG6VEt16Tvt6tUfeFaWdgI90wH6Mr7o1kX9a8G9PrAKDns5COv6QyM?= =?us-ascii?Q?gdwVzwzQ3Ua0XXi3lshuskxlv3IEQY4jhuPK+/af2FlfdwzY6k4UnJZhVbwb?= =?us-ascii?Q?Lv7gqBnzXFxWwff1Hf+wm6sc1Msa8jGlAWO3Hz1JnkO5N5hN57CWg/oc56Fh?= =?us-ascii?Q?KozDP1m0jfDmMWnCfH5Bj2Lws1CTIU4wjVVSuc2BcvX5kccFJkkdDC7UMpjH?= =?us-ascii?Q?G/MU2eYCqq8c9pbqjqN4caxbbSH0ZfxvK17db6vk/yEFs8AoeiiaEqYvf6j5?= =?us-ascii?Q?1ANw0AHUkBClx/70u6ii57sHxaxJMkqBNkdQlfF9OcLubcrZYV5UVrnSfZmA?= =?us-ascii?Q?YYOaXavG214czyK9i9JJ7pXGFLZKfflHb1032ojvfag154F8ZOpWOuphDVvd?= =?us-ascii?Q?Oy3YG5jqjbuyc7wb400DoV/lDX1KV58l8E/7Svc/Jgv8xIIGziqTEGp9WdA0?= =?us-ascii?Q?cUjQX4JFa1QyIpSNWqKnyuk9RD4OXovzAJlX03rUmgl5K/gotKUITyJM73Og?= =?us-ascii?Q?ylpTrAsZMAqVhbqVw+5ercREcHaRpPUgpuoIL9hjAYP8mpe2l+jvOCK2PtT2?= =?us-ascii?Q?po3nzOB8wUZBu09K68nNmNLtzj3naz6KMVyv5LFBynVeMI3e5skDz0FT8X14?= =?us-ascii?Q?vsNa/ylH97k9sTYVrgeKWMgrOuIdPO9J7/pXpYuJ8HSNrTX9J2t0zlMAPYXR?= =?us-ascii?Q?r9+UoevsH00drSoY0lHClzl5aEIlzIpYOm/H1P49OxE6+co0u4upLRoD4FFn?= =?us-ascii?Q?AhrVrLQha7R0SnlQ2dxjqEEoMhhVqpnEqgcJvHSwR1enziKFCgyM6NoAAJWS?= =?us-ascii?Q?zijSUsO64HbGBOTlK5Tc5H+O52T7Q/gCmoHJ/oU/bIuRDAAvC1gkSLEWj9Fr?= =?us-ascii?Q?78lFewLa6uWt0VESfRMATpYMdDBzwgxMtGx9KU5l7thMnIXTjERRCXqh7Ceb?= =?us-ascii?Q?6I89aPBHg+Na81PcqtUfPmiVoKQWZsZM?= 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)(82310400026)(36860700013)(1800799024);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 06 Aug 2024 22:02:38.0921 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 7fa50add-a1ad-44d3-1002-08dcb6637c36 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: SN1PEPF000397AF.namprd05.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM3PR12MB9415 Content-Type: text/plain; charset="utf-8" The MBM counters are allocated at resctrl group level. It is tracked by mbm_cntrs_free_map. Then it is assigned to the domain based on the user input. It needs to be tracked at domain level also. Add the mbm_cntr_map bitmap in rdt_mon_domain structure to keep track of assignment at domain level. The global counter at mbm_cntrs_free_map can be released when assignment at all the domain are cleared. Signed-off-by: Babu Moger --- v6: New patch to add domain level assignment. --- arch/x86/kernel/cpu/resctrl/rdtgroup.c | 10 ++++++++++ include/linux/resctrl.h | 2 ++ 2 files changed, 12 insertions(+) diff --git a/arch/x86/kernel/cpu/resctrl/rdtgroup.c b/arch/x86/kernel/cpu/r= esctrl/rdtgroup.c index 0047b4eb0ff5..1a90c671a027 100644 --- a/arch/x86/kernel/cpu/resctrl/rdtgroup.c +++ b/arch/x86/kernel/cpu/resctrl/rdtgroup.c @@ -4127,6 +4127,7 @@ static void __init rdtgroup_setup_default(void) =20 static void domain_destroy_mon_state(struct rdt_mon_domain *d) { + bitmap_free(d->mbm_cntr_map); bitmap_free(d->rmid_busy_llc); kfree(d->mbm_total); kfree(d->mbm_local); @@ -4200,6 +4201,15 @@ static int domain_setup_mon_state(struct rdt_resourc= e *r, struct rdt_mon_domain return -ENOMEM; } } + if (is_mbm_enabled()) { + d->mbm_cntr_map =3D bitmap_zalloc(r->mon.num_mbm_cntrs, GFP_KERNEL); + if (!d->mbm_cntr_map) { + 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 ef08f75191f2..034fa994e84f 100644 --- a/include/linux/resctrl.h +++ b/include/linux/resctrl.h @@ -105,6 +105,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 + * @mbm_cntr_map: bitmap to track domain counter assignment */ struct rdt_mon_domain { struct rdt_domain_hdr hdr; @@ -116,6 +117,7 @@ struct rdt_mon_domain { struct delayed_work cqm_limbo; int mbm_work_cpu; int cqm_work_cpu; + unsigned long *mbm_cntr_map; }; =20 /** --=20 2.34.1 From nobody Sat Feb 7 21:19:49 2026 Received: from NAM02-DM3-obe.outbound.protection.outlook.com (mail-dm3nam02on2059.outbound.protection.outlook.com [40.107.95.59]) (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 E40E0179967; Tue, 6 Aug 2024 22:02:50 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.95.59 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1722981772; cv=fail; b=CCImUQ/m8Vapr1yILS9hqA/UuSJu5Ebkq6VZb4iZv7R//gHEeJOJz3VvIbBmGkt78uNXi+u1ZbO/uljVTDsthDJjIkFVn60h79uBP6OdmkBZLDVviKbtUbVfLGv2fnlGBqz6twnN7Amm7kXHcq/uMJE1hUW70Zbv6EEZCQ68mAI= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1722981772; c=relaxed/simple; bh=IinG8gP1k6CcxHMdwln0iF0TeDK8BZYIXsnaWKd9nb0=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=cyCF+4KCgGsQm8prACLwt9YFFKUUwXJSdbDtt9RAH37ucd7slgtSui1zFlo1Nqs4jR0fQhwwdJWzM9B3g3/5nJJ7qjMG+mGF+PUXC0Ew5k9WviqmdUIQsjSBHnTTtvv7evt2nusJMz3HJUjnQG1OwbRjzlqVgnqVzQuzpTrEwiA= 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=ZHdrcUps; arc=fail smtp.client-ip=40.107.95.59 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="ZHdrcUps" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=AhL78FQCXHiERGZ3dHKUN+azpsGy9bdsg7zJdWlt67nszhjCkB8XljnBTW8YjAZv1YSKcWYofT7PK2Cuf04S5GHWp4xA/IlkR2muyCXO+CpVq29ShAiMlmVPfL9RXq4rb4U58mfrm7qjWD89yLELwvjUOF59+S+o7ZnoyQpMnOvHPgQZFQ29lU0PMoctPF82vgrLrIIMFrtf6IaKSOEZ8ppo0RadzFT6VIZt/jGgYtwoKjYJgqhHKYQ90QzMY2N0NsLd9/vUog2itkxZ+ffTxmSXP2qeWMv/C0yrKObwUgiByE4FWjuxGKNYpUwUQVw8NS3q4GJJoa1qd2of/MrjGg== 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=sXycPah3sYIOtbSlm5Y7QF7232jqqdNb/yPhAFo7Op8=; b=PbeQ8Xr1fiWdD1Bx6pJuSSUxoVwpc08RuduVAiv54+i8ykVoIC7pWNdmBb2+VUYzmpHRAcJxvWzfM0ZYPNihgWTPEL7052u7hWRcMqcQPu3fMnX3vD/2Gxw6QbKyWhiGPWZ853Jpz/LCpc5OnDgY6YjqJzVTDd86g9doLHmwaqeLpvRdxq88Nwzv2KoS3/XJEWwtVqlbs2z5Vx3VMwR/JPef4hIxRGxqL9aL1A8jejumbNiz2caLNrlmZvIvP9+l3ify/yGsWmk3NUT2CB5dgEGjE692C3l1GWxvma6DU+NPcBmbfEMI0pn9VLMrFkTKGDt575ZnuySTk/oeA4+LjA== 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=sXycPah3sYIOtbSlm5Y7QF7232jqqdNb/yPhAFo7Op8=; b=ZHdrcUpsXxVRTPaHBesThJxAUUvPmf62uuavsfVSEUuaHs8KxcF+sN4Oe54w6vx5jGhQz41JaV58xD4aZgBM9iEjShKs4QCavv1HRk6OdpntXh1YpBen0mDhv6W+EkLpor4lMkyBiCT0UUAuQb0TYpUoSjdMM0scOLoQzsVV+4Q= Received: from SN7PR04CA0184.namprd04.prod.outlook.com (2603:10b6:806:126::9) by DS0PR12MB7898.namprd12.prod.outlook.com (2603:10b6:8:14c::20) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7828.24; Tue, 6 Aug 2024 22:02:47 +0000 Received: from SN1PEPF000397B5.namprd05.prod.outlook.com (2603:10b6:806:126:cafe::6c) by SN7PR04CA0184.outlook.office365.com (2603:10b6:806:126::9) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7828.22 via Frontend Transport; Tue, 6 Aug 2024 22:02:46 +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 SN1PEPF000397B5.mail.protection.outlook.com (10.167.248.59) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.7828.19 via Frontend Transport; Tue, 6 Aug 2024 22:02: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; Tue, 6 Aug 2024 17:02:44 -0500 From: Babu Moger To: , , , , , , CC: , , , , , , , , , , , , , , , , , , , , , , , , , , , , Subject: [PATCH v6 13/22] x86/resctrl: Add data structures and definitions for ABMC assignment Date: Tue, 6 Aug 2024 17:00:50 -0500 Message-ID: <337d3ed1eebc662dbc7e536aba49987c2396972e.1722981659.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: SN1PEPF000397B5:EE_|DS0PR12MB7898:EE_ X-MS-Office365-Filtering-Correlation-Id: 53dc04ac-cd36-476c-7e56-08dcb66380c7 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|82310400026|36860700013|7416014|376014|1800799024; X-Microsoft-Antispam-Message-Info: =?utf-8?B?YzlRL1YyeFh5aDNUZjdWOFZYTWg4VlZjREt0ajdaR1FFbWFlK2pIUE43Y1Zs?= =?utf-8?B?VHR0MXNlaDg2aG5lUkFQSFlnaWJJVHZOajluU0s0QVdiMkRGZjAvVFRadHVE?= =?utf-8?B?eWVmWWp4RUpvOVB4V0VyZGd0a0JGNmVHdHZrcFVPM0EySDZGMVRJckhyajJD?= =?utf-8?B?d2lPMERJY2M3clZjNm5tNkY5Z0dWOEllYUd4YkNGUGNiQi9DM0lOb2I1VUpn?= =?utf-8?B?a0FtSWd2ZFFsS2RKbWdXRzVyWTFjVE8xQnRzNno5QUd5SGxWeitaVEFFZk9T?= =?utf-8?B?cVFFUUJsaGRJY0J4Wm4yYTRUWjBrZFp0ZGl1V3BGSGFOcHBLeEdabXkrR2w0?= =?utf-8?B?Und5Z2FwR2xRZVhHQlo3cWplVFZseEh0S25MRjhhVldsRmRuTFhzTFhXYS9F?= =?utf-8?B?aHZPdkN6ajNuQnNBTW9pbGY4bkRzYUxsRVZXMnFYNXc5eGRZVlB5aHVkWWxU?= =?utf-8?B?WEtPSGlNSlJHZmxzM3RveGZIa3dMZzB6Zis1TGZ1KzNBb1J2ajhaQkh4R216?= =?utf-8?B?WW81TTJiUWwrYmk2UjVNRW8ybE5zd3dmSTdMazVldkl4c3RVNG5ENXl4U2h2?= =?utf-8?B?Y0VGcmdvdFIwS0t2T21oT2xiaTZiYWwzTmYwU0dkOEY0Y0c3MWFRbkZFTWxT?= =?utf-8?B?ejJSTHgvSUQ1OGJqSVVFcis4T2JQVGhLQURwREovOHJFQldpWVpsbXlTdENN?= =?utf-8?B?dERIdEhjWlo5SThhQ0tlZ0pWU0VpOWhwQ25uNUpWOTEvVDJ3TzFkN2p2cXp0?= =?utf-8?B?UUFKT0ZpblFrR3JQNldsN0R4UFo1TWMzaVU5SjR4VnM3SmhxbDhFZ250Ry8w?= =?utf-8?B?VUhzWTV6Z1FMTDNOL3V5OGJZRmtPRTkzN21XSWpudGpBOEJ4blh3Ry94eXIw?= =?utf-8?B?Q1hLVHM0eXlBbkNzNnRrS3RKL2pzSGVEalpxeVpGOFVTZ2haaFVZRmtjSE1o?= =?utf-8?B?RlpYNSs3VmNwajZLV0w2YkJ5YUNmd1U3VEtWODdoM2Vza0duT2hqVEZwNi9y?= =?utf-8?B?UWtPalRVd3ovRzk1bDRjTURkdVlQV1I2LzQyYTM2YVpWV3VveEhRdmZrNUxi?= =?utf-8?B?T1ZYTWZreVhQT25VU2lqMFl5angvMjg2RHF6NktuNjFhZkZRUXBQQ09RdkUy?= =?utf-8?B?TW92VFdvRU9qUzd0TUFja3A2YVpFdnZlNnRxMlQ4NEZXT3hkWkhGdHdzVUc2?= =?utf-8?B?TG9KT2g1Uk1jYzB2TXNZcUdKYmJFRHJOcXkrWkkvYno2RUMxNXYyWjJJQUVB?= =?utf-8?B?TlBXQjRKcmtObjFURUhQWS9laExCcGR6Vk5aWjdjRVpyY0RZVWlpOG9LSk1V?= =?utf-8?B?Ylc0eVZCNkpIVWlxcnBSWFJMVnhiaU14ZnRySUpBNHU3OS9FWTVZVmNTVExH?= =?utf-8?B?eTJhYmlCbWYxekZFN3JjQ25meFZnRWhWeDlua2xGbjltWFRYSGxDNzdiSHVn?= =?utf-8?B?cTMzaEloWENNY01XaXpzWGpMa3pUVi9TZ1RxUjRyWXdjTVI2aldnd1FVbmVy?= =?utf-8?B?MVdFb0dpUWFZTzUvZkxqOC9FZ0ttYW9WcElRVW5jSzR6dk5BMHo2Qk1TcnJh?= =?utf-8?B?bHpscDlscUVxc0Z5TjV5cTdtMUgxVmFYSHgyakJoa25aOGtEbll2UG9kUTNN?= =?utf-8?B?WmhqazNpbFhHS01nMGdiUUx5Q056Qjk4U2VVaGdFK252MnJWQ2lOZ052Z2pk?= =?utf-8?B?RjFQZEh3TFdmSjN4T215clBiSGJTeFlZZDlPYnJkcDgydVg2czh0d1J5Nzk5?= =?utf-8?B?bjZVdWJQUXFqNVlpWTJOdDhvOXFWNTNCYmhLNGFUQ1FYUHhOZzRkSlNmb2xR?= =?utf-8?B?WEJXL29ZVk40S3JXbDQySGVVWDQ5YVNmdnZMV1JHdlRnekp6MTVpb085d1lR?= =?utf-8?B?NExhaVlTZG5ncktEYnNzbE9zN1lLekJ2Wmw2eHR3ZS9VT3c9PQ==?= 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);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 06 Aug 2024 22:02:45.7561 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 53dc04ac-cd36-476c-7e56-08dcb66380c7 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: SN1PEPF000397B5.namprd05.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DS0PR12MB7898 The ABMC feature provides an option to the user to assign a hardware counter to an RMID 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 a pair of MSRs, L3_QOS_ABMC_CFG (C000_03FDh) and L3_QOS_ABMC_DSC (C000_3FEh). The counters are configured by writing to MSR L3_QOS_ABMC_CFG. Configuration is done by setting the counter id, bandwidth source (RMID) and bandwidth configuration supported by BMEC (Bandwidth Monitoring Event Configuration). L3_QOS_ABMC_DSC is a read-only MSR. Reading L3_QOS_ABMC_DSC returns the configuration of the counter id specified in L3_QOS_ABMC_CFG.cntr_id with rmid(bw_src) and event configuration(bw_type). Attempts to read or write these MSRs when ABMC is not enabled will result in a #GP(0) exception. Introduce data structures and definitions for ABMC MSRs. MSR L3_QOS_ABMC_CFG (0xC000_03FDh) and L3_QOS_ABMC_DSC (0xC000_03FEh) details. =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=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 Tracking 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 Configuration and tracking: CfgEn=3D1,CtrEn=3D0 : Configure CtrID and but no tracking the events yet. CfgEn=3D1,CtrEn=3D1 : Configure CtrID and start tracking events. 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 --- 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 | 2 ++ arch/x86/kernel/cpu/resctrl/internal.h | 26 ++++++++++++++++++++++++++ 2 files changed, 28 insertions(+) diff --git a/arch/x86/include/asm/msr-index.h b/arch/x86/include/asm/msr-in= dex.h index d86469bf5d41..5b3931a59d5a 100644 --- a/arch/x86/include/asm/msr-index.h +++ b/arch/x86/include/asm/msr-index.h @@ -1183,6 +1183,8 @@ #define MSR_IA32_SMBA_BW_BASE 0xc0000280 #define MSR_IA32_EVT_CFG_BASE 0xc0000400 #define MSR_IA32_L3_QOS_EXT_CFG 0xc00003ff +#define MSR_IA32_L3_QOS_ABMC_CFG 0xc00003fd +#define MSR_IA32_L3_QOS_ABMC_DSC 0xc00003fe =20 /* MSR_IA32_VMX_MISC bits */ #define MSR_IA32_VMX_MISC_INTEL_PT (1ULL << 14) diff --git a/arch/x86/kernel/cpu/resctrl/internal.h b/arch/x86/kernel/cpu/r= esctrl/internal.h index 1021227d8c7e..af3efa35a62e 100644 --- a/arch/x86/kernel/cpu/resctrl/internal.h +++ b/arch/x86/kernel/cpu/resctrl/internal.h @@ -589,6 +589,32 @@ union cpuid_0x10_x_edx { unsigned int full; }; =20 +/* + * ABMC counters can be 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 : Tracking enable bit. + * @cfg_en : Configuration enable bit. + */ +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_last_cmd_clear(void); void rdt_last_cmd_puts(const char *s); __printf(1, 2) --=20 2.34.1 From nobody Sat Feb 7 21:19:49 2026 Received: from NAM11-BN8-obe.outbound.protection.outlook.com (mail-bn8nam11on2071.outbound.protection.outlook.com [40.107.236.71]) (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 7552A179967; Tue, 6 Aug 2024 22:02:58 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.236.71 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1722981780; cv=fail; b=I796j3RZl8T3mgDP4+0lG0xWOsgcWzPkJNSWxbREQuBbZHinEP1G0lVugxMlcdFjUY2SWuerLQDOtCZd+JTpV40HUxt5pmoJRTOXTm5Ume3aHTnQRICkwvdK3ANj7eAPwXBNjepMGw97pCES4cRSqGkTH9fsutLIsekVWDifpJ8= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1722981780; c=relaxed/simple; bh=UTdTjwR05xDifqNlVbxEM1c8g1mFlMgfmMVxiGoKoJk=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=GIbYYxdFGUuY1WwRr3isY/WWep9NAqQ5q7zn8kGdxIf9yzyf8tKbiT80BOvFzCRTB+YZhNYTNZsE6FauiQhAAI8+ULyYYHboQoXnEyYMtpOJntScgN8ozI57lZVdy8jDPRXEn5P69VnZ3/ZnA6LTSXwho0R/Haly15D3o81lQRQ= 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=malPxV9X; arc=fail smtp.client-ip=40.107.236.71 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="malPxV9X" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=g+K86ROi/HXNKIFXI8M8HEpHHLwfj5X0wZaQKtfFR2LhmWjIOCyqa4ym/RWOkcPU5pf3jkZ/UTTl/kvrF8OfEu7IwIo0P7KV3XqgFaZV0XlGdDztg03hP6XJZHIvBO8ULPozmwteVNeWRub5TNOE64/yfNTpib9JQQ6WPlA2BrlVsN/WX0kiX89hC+HaJvnZNzXtLxfPSP898V+Mc42ahlvFMVB0f7RQO7gDiiy/dbULAm7Zosg5hseQ5rQz/CPmfdyUGvwFkrH8MGJ/OiQGrdH3gmvDJ1wUHBCcPOcj7zmliATkHkee0T22jfXoW3Wu7zfePmzkTLthy/jL0Q3S2g== 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=Q6VDyzw88vTpqfV24g+B5x/y7N4eAKIfS9+qtJjySOc=; b=izXr2hkx2eH9PF7r1T/wpYtV1RZyh4itytcOP/V2AaCOtPhEOdjLzekdmnVZs1SPnINW8pS7fdqwWU+XBpOg8j/qVM8skpQgt87XVu+CeWY5gg2R9dZWeOx8wVr9UDJJIYTCWB9i/LdFGHFQldlAEOznQ3gMsLjgFbOktUvjJyRwIxTwr8oId6jQXPcEH46pND0UnrFHF0ed7kHf8s5QqkFkwQrBEyOVphPzbn/VeVTAqGQF6BF9bzqFyRwK50fV2CZ3GysOkNcV12IcVNBVbUJLSYlepuog39yNppSHZbX0Eu2REG8ipqhIUB58ZyRChCnf0cHAofje5JBhYH5ftQ== 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=Q6VDyzw88vTpqfV24g+B5x/y7N4eAKIfS9+qtJjySOc=; b=malPxV9XgMaJLmDQxkKLrX7cmx/S0ULLdKCQiZSQuiyZ3VFkn9RNDxM5Y2I+tbzyKDj3HzW2BEijWacKMNMbv9L7AXMR2UJ57PDL069KQvHvHandpyDfOhzsdjkwKizkW1QvOncTt+Lq/ut2LKc40WDOrgvv/tzXlZ9wOWJ82Ds= Received: from PH7PR13CA0016.namprd13.prod.outlook.com (2603:10b6:510:174::9) by CH2PR12MB4327.namprd12.prod.outlook.com (2603:10b6:610:7d::13) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7828.27; Tue, 6 Aug 2024 22:02:54 +0000 Received: from CY4PEPF0000FCBF.namprd03.prod.outlook.com (2603:10b6:510:174:cafe::93) by PH7PR13CA0016.outlook.office365.com (2603:10b6:510:174::9) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7849.11 via Frontend Transport; Tue, 6 Aug 2024 22:02: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 CY4PEPF0000FCBF.mail.protection.outlook.com (10.167.242.101) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.7828.19 via Frontend Transport; Tue, 6 Aug 2024 22:02:53 +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; Tue, 6 Aug 2024 17:02:51 -0500 From: Babu Moger To: , , , , , , CC: , , , , , , , , , , , , , , , , , , , , , , , , , , , , Subject: [PATCH v6 14/22] x86/resctrl: Introduce cntr_id in mongroup for assignments Date: Tue, 6 Aug 2024 17:00:51 -0500 Message-ID: <5b8b1f354c2f4b5eda3fc7f2ba0d4d0b3744fb61.1722981659.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: CY4PEPF0000FCBF:EE_|CH2PR12MB4327:EE_ X-MS-Office365-Filtering-Correlation-Id: fea8b4ca-b1b6-4f8a-982e-08dcb6638575 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|36860700013|82310400026|376014|1800799024|7416014; X-Microsoft-Antispam-Message-Info: =?us-ascii?Q?I27X0ZEe5TIzJ427Lqz5YQIlIaf+FK26hKRoN7uNfkpet1vD5ldcccXrLTkp?= =?us-ascii?Q?86agXEZjY7X+b0vqBm8mlj4q1yJ7kjucqoaFULMSBxlKw45gSq4VOSvtxDV5?= =?us-ascii?Q?WkuCNk0pby9H6b2I/NnfbSQXMoaXz6swh1jSDKNOfRC8W2sDZtfiYHwE1oLL?= =?us-ascii?Q?9ccWn5c57Xtb5l1UwoXmHXDVIR6NQA8+C3wW2RFaG5R/goeof/XA2ni2sNtr?= =?us-ascii?Q?lMFwSMzoBFLNi6exb/+5Wq34/QT+RVk6qcezGqJy3L+qMRWKS7c98UV06Tip?= =?us-ascii?Q?0Mfs1ZbKRejcbledAsbE72F0MhopCCkivajT8pd7+6Yn0NitVrqIO/ScozAc?= =?us-ascii?Q?Uz7OQPGdleoJZYrPzAfZvDD7e3czSwQTdO/jeIFsWhqqyZ+3IFgQHuO7ICde?= =?us-ascii?Q?o//ZKfqsu38MRRsl5gPteTUxPdnGtJ+4JNW8PHY5/H89GUZGLaWI60c9oLgj?= =?us-ascii?Q?O2DyZ2T+X7EiOoKAglznv43pzr2UUfvWwuRVtmOCQDAdY4gjkJ97Vsuz75oq?= =?us-ascii?Q?6fT12el2cH4OVWmSTePABmZ7U1bAaKsUW0SBbTQuYxxvFyN3vC9/bGRfUT4v?= =?us-ascii?Q?noomomcS7adWE/GRlv98yxO1krsk1QEpmEKyJ8BfpRNPYSc7LqZE3hv1MufK?= =?us-ascii?Q?v/4oYrz/mwBdh87MHsqIk+SsaIRbLKHj73NqdeRklePScGqGXVBXJ/5GRngJ?= =?us-ascii?Q?DDy74FiXfidPpVfbzjDfPSrPN21SeDt7DXNIIOAKBSqHX9T0TsxRezg7Yxh5?= =?us-ascii?Q?W05vOvjnDPOHea9sZWvrH68WToti0A10OCUqz9Z8JesbstBy7mBD8T64Gg/Y?= =?us-ascii?Q?9Qa6JK4dFrtcJdLqMo68auGj0xKUK+37inP1JnJevKkrDMbcHtwTG1HRuv0i?= =?us-ascii?Q?00dEKv3dW5jA8Zrm7tBc8MKKmOIhzjEl0N+AT5Bg0UJx0/51XVLmqimfE3Lv?= =?us-ascii?Q?yOEiFk59cpbEZfpOSCOBUd1noQhtG2fqYI5IjbfOfvkmMbse2n7aTB8z8Fku?= =?us-ascii?Q?aYKX5LcXxxlF5p7qrNq6BycHMf4FelRrsaVoUQ0SgOoR9NLWbNBSDxJahx7E?= =?us-ascii?Q?Y+Mzykzayz2RszqpyRI6916gYcTUsVwoiqY59g+buPTold8/kniNO3b7PnbE?= =?us-ascii?Q?Od8/y3J1SpsGG6HDEaHogb/xadQaA2Cs6eqQTSOSudk084ltG5p8TjeouU1U?= =?us-ascii?Q?k3mC66jqfuH4YY5D8E1Xxyy4VBIexYNrs2xpFDRLykEouFQSOo7aRqXikE5M?= =?us-ascii?Q?FcdczRJj3RI8S+HYTibxSaU5QL2LBVp6kHS5NMaJDGmh9Frlmv4RVyi4v67F?= =?us-ascii?Q?57zPumHoMCw2U7qjZgPZHbUa2r/dbEBoXIq/hRMOMYPhVNGb1jpjKdZVgcPM?= =?us-ascii?Q?3FxMv5v96quW9xIwRAaKWzBAL6GRD8m4d11A+qHalO6EAbZlEkMsK3Xn9YRD?= =?us-ascii?Q?fzKaYN8AnxDzdxLymxVuji55T0OXPq8w?= 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)(376014)(1800799024)(7416014);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 06 Aug 2024 22:02:53.5611 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: fea8b4ca-b1b6-4f8a-982e-08dcb6638575 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: CY4PEPF0000FCBF.namprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: CH2PR12MB4327 Content-Type: text/plain; charset="utf-8" mbm_cntr_assignable feature provides an option to the user to assign a hardware counter to an RMID and monitor the bandwidth as long as the counter is assigned. There can be two counters per monitor group, one for total event and another for local event. Introduce cntr_id to manage the assignments. Signed-off-by: Babu Moger --- v6: New patch. Separated FS and arch bits. --- arch/x86/kernel/cpu/resctrl/internal.h | 7 +++++++ arch/x86/kernel/cpu/resctrl/rdtgroup.c | 6 ++++++ 2 files changed, 13 insertions(+) diff --git a/arch/x86/kernel/cpu/resctrl/internal.h b/arch/x86/kernel/cpu/r= esctrl/internal.h index af3efa35a62e..d93082b65d69 100644 --- a/arch/x86/kernel/cpu/resctrl/internal.h +++ b/arch/x86/kernel/cpu/resctrl/internal.h @@ -41,6 +41,11 @@ /* Setting bit 0 in L3_QOS_EXT_CFG enables the ABMC feature. */ #define ABMC_ENABLE_BIT 0 =20 +/* Maximum assignable counters per resctrl group */ +#define MAX_CNTRS 2 + +#define MON_CNTR_UNSET U32_MAX + /** * cpumask_any_housekeeping() - Choose any CPU in @mask, preferring those = that * aren't marked nohz_full @@ -210,12 +215,14 @@ enum rdtgrp_mode { * @parent: parent rdtgrp * @crdtgrp_list: child rdtgroup node list * @rmid: rmid for this rdtgroup + * @cntr_id: Counter ids for assignment */ struct mongroup { struct kernfs_node *mon_data_kn; struct rdtgroup *parent; struct list_head crdtgrp_list; u32 rmid; + u32 cntr_id[MAX_CNTRS]; }; =20 /** diff --git a/arch/x86/kernel/cpu/resctrl/rdtgroup.c b/arch/x86/kernel/cpu/r= esctrl/rdtgroup.c index 1a90c671a027..60696b248b56 100644 --- a/arch/x86/kernel/cpu/resctrl/rdtgroup.c +++ b/arch/x86/kernel/cpu/resctrl/rdtgroup.c @@ -3564,6 +3564,9 @@ static int mkdir_rdt_prepare_rmid_alloc(struct rdtgro= up *rdtgrp) } rdtgrp->mon.rmid =3D ret; =20 + rdtgrp->mon.cntr_id[0] =3D MON_CNTR_UNSET; + rdtgrp->mon.cntr_id[1] =3D MON_CNTR_UNSET; + ret =3D mkdir_mondata_all(rdtgrp->kn, rdtgrp, &rdtgrp->mon.mon_data_kn); if (ret) { rdt_last_cmd_puts("kernfs subdir error\n"); @@ -4118,6 +4121,9 @@ static void __init rdtgroup_setup_default(void) rdtgroup_default.closid =3D RESCTRL_RESERVED_CLOSID; rdtgroup_default.mon.rmid =3D RESCTRL_RESERVED_RMID; rdtgroup_default.type =3D RDTCTRL_GROUP; + rdtgroup_default.mon.cntr_id[0] =3D MON_CNTR_UNSET; + rdtgroup_default.mon.cntr_id[1] =3D MON_CNTR_UNSET; + INIT_LIST_HEAD(&rdtgroup_default.mon.crdtgrp_list); =20 list_add(&rdtgroup_default.rdtgroup_list, &rdt_all_groups); --=20 2.34.1 From nobody Sat Feb 7 21:19:49 2026 Received: from NAM02-DM3-obe.outbound.protection.outlook.com (mail-dm3nam02on2063.outbound.protection.outlook.com [40.107.95.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 A084317AE13; Tue, 6 Aug 2024 22:03:04 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.95.63 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1722981786; cv=fail; b=it4wCvCzrpd/mwlVkTfo5fuEB83WbXBw095Vrgrp1X6KoxXm/E+Fe2y5iO43WJRfzUOqg8ksDsjNRq/9QejOxOMhENq/ZBbT1XmHfWdXm5eovhAjemyFD/ORftHBlRUv0qyvT5Rkb4482nxP26ZzeLsfoSIZxywqXpIAryuTerc= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1722981786; c=relaxed/simple; bh=nyjvgsSOndT1Z3YxcJ0SxAxeytqPAiplGOFIg1v7Cs0=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=hoh5HFRm/ATSf5CMWQIS68G/84nT0Lt6wqwk0bi0x4UNnQhUs/jLMpDmIZGVtrrwlTiwJmZWEKpGfrm2kNJpIB/wQ6fOMErc4KiqZZTp1lS53ImF5A3m8WIcSbnI915IpmT8Am71iedDJORA77qUf4qLI6JWmrk8Fhn0fasv6PU= 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=y6W6SeSN; arc=fail smtp.client-ip=40.107.95.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="y6W6SeSN" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=cDqj/P2Tw1bd4T33rhLnPLYiyOAlj85BIQKf4n2PFsc7FUL0vx/pX0SAJUnMSN597I4tqrGE7Xy23Gv61qs/lws8IIBzbKbhU+i7UHxzvLygu6sTZwvw6WDTcc9U+mTQ+/5HIBWZwtrCecY9+2H8ACefgOXZiBA5tzOz6OJZW1j7xMCLS+2vdnZRL3GNYCCb0JjZugImdvaC7I5gTQKgS6WFsMpgJ06h5kz/7XqqQdeHVA1O9HUqw4G9ZNTGzP56YdLrJSH9d9xGge+tIWN34tnjOMiokVxUIP/SDxKdgdGXiqaZ+FoqAZOV0sryz+c4P3gghzkX4YZlhFa/3vQuOg== 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=xX9FyQBNCPIWmuqoDJkCnrveWezvLUlKx/VDKKRrtnQ=; b=jxE68xK7ZrJehBCAe6RZLXXLPaGGR0Ox0YroDjqTicW+uKB7wpkFRzaF5uLV4nn7YxH/JM/EIEpF8rPUtlHEsmTlrdzlhsvLcwxKPCFwhBW7+w3NxGAGrxb3ey1tL9Kj95RHc59UEiCpm4NDji3d1e9qUncV+Mru/i4sBAhPbZcj2cVMH3DMOSH1s3iAew6MCZt8BrZC2tjvjTCg6WInJzXz3a40171n9EYizAp+iK8vI5pMZ89nmF2MDcfGX1pZoEZzTlKWAY1vqsKX8jSxoj5wpdAwiA69h3sA9i81AV1jMLgmg4tKUK9nt05mhItrzQKjphFLSwWtLKjIGly8eg== 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=xX9FyQBNCPIWmuqoDJkCnrveWezvLUlKx/VDKKRrtnQ=; b=y6W6SeSN+i/7X/z05ZpD/JSsquLjSjbuSekOqRkDBdQm7UqaVsT70pGes4gyByc16iEXTn2binKzTDIvuc9GeGgaA8eBix2QqE+Lyqjc5M8vA86A7jrboAY6k+2nsB5ESVuT/fjUaP5fYy0YMTW/FiEUhyT8o62JCNsm3FwHD6E= Received: from PH7PR13CA0018.namprd13.prod.outlook.com (2603:10b6:510:174::22) by IA1PR12MB6212.namprd12.prod.outlook.com (2603:10b6:208:3e4::7) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7828.27; Tue, 6 Aug 2024 22:03:01 +0000 Received: from CY4PEPF0000FCBF.namprd03.prod.outlook.com (2603:10b6:510:174:cafe::2e) by PH7PR13CA0018.outlook.office365.com (2603:10b6:510:174::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7849.10 via Frontend Transport; Tue, 6 Aug 2024 22:03:01 +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 CY4PEPF0000FCBF.mail.protection.outlook.com (10.167.242.101) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.7828.19 via Frontend Transport; Tue, 6 Aug 2024 22:03:01 +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; Tue, 6 Aug 2024 17:02:59 -0500 From: Babu Moger To: , , , , , , CC: , , , , , , , , , , , , , , , , , , , , , , , , , , , , Subject: [PATCH v6 15/22] x86/resctrl: Add the interface to assign a hardware counter Date: Tue, 6 Aug 2024 17:00:52 -0500 Message-ID: <099ecbbe678dd44387a8962d0cb81e61500cd2fa.1722981659.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: CY4PEPF0000FCBF:EE_|IA1PR12MB6212:EE_ X-MS-Office365-Filtering-Correlation-Id: bc82d443-89cd-4f26-eb43-08dcb66389f9 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|1800799024|36860700013|82310400026|376014|7416014; X-Microsoft-Antispam-Message-Info: =?us-ascii?Q?rvucDlGychkWiISz1/COPoOblQAT3vkBVdnnQfSCfcLP2sjTHt7JHnkFjzff?= =?us-ascii?Q?Wf3rpRmxevJsBIB/jiw+2Wzjc2uweyqb1vyyTgdW0L9ShZA8nT/bmXmYbpaB?= =?us-ascii?Q?+FGKp0Shmhu0lOVgXJxrl+6NNQ3B3rF8RUN5lbJCkYQyCEdC+Q81lafVGP7t?= =?us-ascii?Q?1/b0TjIfVjREwcFyoS6bKa03853bfVR63egyzhFltZKQS/LxcqFyeBVigsy6?= =?us-ascii?Q?mJT4AriMf95ioLVc8d1+bx1cRD33X7SOu2VqGsSJWsB3gZJ/CERN0tkt5CDe?= =?us-ascii?Q?y1n1D3mcZZPsR2SBsBnhjuAz0+3TzFKOkS2k9z+RDGhR0Gm3QbdWnePE0RLL?= =?us-ascii?Q?5NtZNYGL4fe/R+7nh1P37tIXAXvPeav8Qp4wWtcWxNe6bvHZCviOCdgdVv79?= =?us-ascii?Q?wgSBgxCNqDuwpDcQiplAkM99/OTqbFGSZWTdnTHYYOLnRC75eiBEyZCPybcJ?= =?us-ascii?Q?t76Ymu798onBJigqFsdwbLyRYjJC5gsRlwn3UOKp3rF+Ma7YPYK3WzUvBwSF?= =?us-ascii?Q?qmwsF1Zmi8ZQ4qI/VT/VY6IMyeonsGN9i2CBbpE1nE52XMD4YHRwamBPge9c?= =?us-ascii?Q?9epLe4VKUN2Jl88FvQZvNfB+HgNuk16tk5Sdtp/SA0lbkt7vQVWQ8JPHxkX6?= =?us-ascii?Q?9Zj75zVCptpaDO4Ro/rvKmjiMaukAr3h319naoItHR/ZzuO9kOz20grW+71D?= =?us-ascii?Q?Vi4O1UVcU7SZrgpTvZK/d5rK0GIL+v79QO5ZC89TFQS6ko1C6yAxdTc4E/iv?= =?us-ascii?Q?GIHWq+t6x0W5lpxHm0/Ty6Sh0UKtzdfhmtijB8Bj/x0+49HufFMui2tYTGcv?= =?us-ascii?Q?X8UYNlLlVXA2J8kiSdXQsKuc5z7e4bP+P3FS2dMMrU82TINScwkfLOQRBHU2?= =?us-ascii?Q?MNDvSTjWcX4ikYQf/zQGcaTyejbShBfgQtBz4T/xnyRLU1u+JOqhheub9r0z?= =?us-ascii?Q?XLeQNUstiimEVPep3IuiY9Bs9NFIWeVLlZKcmIOplR4SJTW4Ln5flePJL5lp?= =?us-ascii?Q?x64WTstNhZ+D+QuAEqUQC9Oc/4G/eDsYAFW1KWRlVWQP36zPh5BFji7+XZHL?= =?us-ascii?Q?Z7SFO9nCZ7S47JlX6Qua/MLGXJTEvoGuVdgnCmsCN/JBF3/uAEydjPG8rdVK?= =?us-ascii?Q?AJP17VMJ5Jq5k9rR78X4IxZbr5sfaX69Dp4PSedQNfV6NjxuiJoTStjkzYIi?= =?us-ascii?Q?Oqf9jfY96gMKrqAUFuUcmCkmzsdjkB65Cyn7aCqWi+3hr60s4cqIf53hgVeV?= =?us-ascii?Q?esgsAJzXqkp2zq+UAP2zBKvISXA9IAjPVlUvasU4j9H4hvBFVJ9gS2Tagv7D?= =?us-ascii?Q?4xXb7V7BMlagUKmyfo4EsIiBq1n8IieHuwfzRY+X9owGPX9zcaOI7gtuJwDA?= =?us-ascii?Q?uSW0Pr0Z3S0eeDEqT3BaTFIqUd+XizYOVv+yVRhBilp03uSueA=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)(82310400026)(376014)(7416014);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 06 Aug 2024 22:03:01.1392 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: bc82d443-89cd-4f26-eb43-08dcb66389f9 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: CY4PEPF0000FCBF.namprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: IA1PR12MB6212 Content-Type: text/plain; charset="utf-8" The ABMC feature provides an option to the user to assign a hardware counter to an RMID 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. Counters are configured by writing to L3_QOS_ABMC_CFG MSR and specifying the counter id, bandwidth source, and bandwidth types. Provide the interface to assign the counter ids to RMID. 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 --- 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 changes are related to global assignment interface. v2: Minor text changes in commit message. --- arch/x86/kernel/cpu/resctrl/internal.h | 4 ++ arch/x86/kernel/cpu/resctrl/rdtgroup.c | 97 ++++++++++++++++++++++++++ 2 files changed, 101 insertions(+) diff --git a/arch/x86/kernel/cpu/resctrl/internal.h b/arch/x86/kernel/cpu/r= esctrl/internal.h index d93082b65d69..4e8109dee174 100644 --- a/arch/x86/kernel/cpu/resctrl/internal.h +++ b/arch/x86/kernel/cpu/resctrl/internal.h @@ -685,6 +685,10 @@ int mbm_cntr_alloc(struct rdt_resource *r); void mbm_cntr_free(u32 cntr_id); void resctrl_mbm_evt_config_init(struct rdt_hw_mon_domain *hw_dom); unsigned int mon_event_config_index_get(u32 evtid); +int resctrl_arch_assign_cntr(struct rdt_mon_domain *d, enum resctrl_event_= id evtid, + u32 rmid, u32 cntr_id, u32 closid, bool assign); +int rdtgroup_assign_cntr(struct rdtgroup *rdtgrp, enum resctrl_event_id ev= tid); +int rdtgroup_alloc_cntr(struct rdtgroup *rdtgrp, int index); void rdt_staged_configs_clear(void); bool closid_allocated(unsigned int closid); int resctrl_find_cleanest_closid(void); diff --git a/arch/x86/kernel/cpu/resctrl/rdtgroup.c b/arch/x86/kernel/cpu/r= esctrl/rdtgroup.c index 60696b248b56..1ee91a7293a8 100644 --- a/arch/x86/kernel/cpu/resctrl/rdtgroup.c +++ b/arch/x86/kernel/cpu/resctrl/rdtgroup.c @@ -1864,6 +1864,103 @@ static ssize_t mbm_local_bytes_config_write(struct = kernfs_open_file *of, return ret ?: nbytes; } =20 +static void rdtgroup_abmc_cfg(void *info) +{ + u64 *msrval =3D info; + + wrmsrl(MSR_IA32_L3_QOS_ABMC_CFG, *msrval); +} + +/* + * Send an IPI to the domain to assign the counter id to RMID. + */ +int resctrl_arch_assign_cntr(struct rdt_mon_domain *d, enum resctrl_event_= id evtid, + u32 rmid, u32 cntr_id, u32 closid, 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 *arch_mbm; + + 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; + + /* Update the event configuration from the domain */ + if (evtid =3D=3D QOS_L3_MBM_TOTAL_EVENT_ID) { + abmc_cfg.split.bw_type =3D hw_dom->mbm_total_cfg; + arch_mbm =3D &hw_dom->arch_mbm_total[rmid]; + } else { + abmc_cfg.split.bw_type =3D hw_dom->mbm_local_cfg; + arch_mbm =3D &hw_dom->arch_mbm_local[rmid]; + } + + smp_call_function_any(&d->hdr.cpu_mask, rdtgroup_abmc_cfg, &abmc_cfg, 1); + + /* + * Reset the architectural state so that reading of hardware + * counter is not considered as an overflow in next update. + */ + if (arch_mbm) + memset(arch_mbm, 0, sizeof(struct arch_mbm_state)); + + return 0; +} + +/* Allocate a new counter id if the event is unassigned */ +int rdtgroup_alloc_cntr(struct rdtgroup *rdtgrp, int index) +{ + struct rdt_resource *r =3D &rdt_resources_all[RDT_RESOURCE_L3].r_resctrl; + int cntr_id; + + /* Nothing to do if event has been assigned already */ + if (rdtgrp->mon.cntr_id[index] !=3D MON_CNTR_UNSET) { + rdt_last_cmd_puts("ABMC counter is assigned already\n"); + return 0; + } + + /* + * Allocate a new counter id and update domains + */ + cntr_id =3D mbm_cntr_alloc(r); + if (cntr_id < 0) { + rdt_last_cmd_puts("Out of ABMC counters\n"); + return -ENOSPC; + } + + rdtgrp->mon.cntr_id[index] =3D cntr_id; + + return 0; +} + +/* + * Assign a hardware counter to the group and assign the counter + * all the domains in the group. It will try to allocate the mbm + * counter if the counter is available. + */ +int rdtgroup_assign_cntr(struct rdtgroup *rdtgrp, enum resctrl_event_id ev= tid) +{ + struct rdt_resource *r =3D &rdt_resources_all[RDT_RESOURCE_L3].r_resctrl; + struct rdt_mon_domain *d; + int index; + + index =3D mon_event_config_index_get(evtid); + if (index =3D=3D INVALID_CONFIG_INDEX) + return -EINVAL; + + if (rdtgroup_alloc_cntr(rdtgrp, index)) + return -EINVAL; + + list_for_each_entry(d, &r->mon_domains, hdr.list) { + resctrl_arch_assign_cntr(d, evtid, rdtgrp->mon.rmid, + rdtgrp->mon.cntr_id[index], + rdtgrp->closid, true); + set_bit(rdtgrp->mon.cntr_id[index], d->mbm_cntr_map); + } + + return 0; +} + /* rdtgroup information files for one cache resource. */ static struct rftype res_common_files[] =3D { { --=20 2.34.1 From nobody Sat Feb 7 21:19:49 2026 Received: from NAM02-DM3-obe.outbound.protection.outlook.com (mail-dm3nam02on2049.outbound.protection.outlook.com [40.107.95.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 415A1176FAC; Tue, 6 Aug 2024 22:03:16 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.95.49 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1722981797; cv=fail; b=LhcfAlgFfum0Qpn8SO6oa22dfJbxHtC2dt3EIi3b2D2ujX1e/SSyJk3xX4RsAGgbSA0Rfzo7iCZsh43H70GKOurIkuxHh7UcdhmZer3HuCGNuNp6rHnM/vQ2QisLw3fgsO34kuZWZt5enj3JaVJoLSCRkqrfmbNS677uze008gk= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1722981797; c=relaxed/simple; bh=pli7r7CTjm9BcUqKudlKus/FYyBJxyDZGWvNQQ2I0ks=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=suPoyOMbU0DWTVu8IkZW87GAsLL3wugrUjj85q2wD8yegPgHI1Mo9VGywyQOo2Rj0ER3ScFMnPqKEWO0lde3OUOarBE8XLXzDuki2p7EyBOhIkm2oB+GZ0s5oVb3+Fjg28u8IuB45wiHivxXNLBIAWto+Anpk/4mEITfwYaWY3U= 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=ZFlW7P8A; arc=fail smtp.client-ip=40.107.95.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="ZFlW7P8A" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=c5KDkbQ6ueE3mNXtvHq6DWpLoHCHGa5PC0CIUGaYOA2Fh5c2EdT6WJxWx2WCInPKVTybm0CBmMv3k5xAldh7GNgNI4wA6WLWYqtv4NW31d9iSmNrv0H7u+XaVMrC/sMoDsQOLeij77mKJw1vhvlmk6aW3LizIcB8W1uzNU+qx4Z+28zqgfValpPRzOqer20ojZUEOkHvgFYSFPtmBu1FPXQ2kPE2NW/mYzoVXQecnZxn+nNMrD+J7YGtpLNakw9uZ8O+uKf0qXLkUpO6aUl8+7u5uvxH6Eqn++1Qip3iD7ldPjQEJ3kS6tRQZ8HqDtBNSvudhYvRItpWZmNnXoV4QQ== 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=DArFEDCS+dNE5mUsS+iZ5V7CzYdSI1OPb1mP7h/Mv7A=; b=KZElWQDWP1Ne4Pj6X52BYgDRH2pRAbCz/NGWzrfh5Tw0bQEWOqyd/gdQtRo5UhKP4deHRdOTgdRQujQeMQ/oq3LQPqAYawqSEC1kNo2KehTsqO4SZ4kGaZkG1+QL+2hOV4YlGKJP1BIhrqDhA4+KY0GFHSBKqDIja75NSQNoJae7Xep7UiW3A60phbHR4r/hwhmZwTDtd8IpmgcdJifO7LdIn/M8ZFEae7/7ETvaRRhD8LU+F4/nUnKbs3HBzw/5hMDeccPUux5oMfYfURTE7hdWcar2wCBMrEiN01mlHvowYhj+vq2hGjwJozZuws6pjx/bIZgkgKokb8cEPHG3Ng== 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=DArFEDCS+dNE5mUsS+iZ5V7CzYdSI1OPb1mP7h/Mv7A=; b=ZFlW7P8A0h0XmPugXstHUhVXbb9XkJ1kck/YuCQfQGfGInm5koB3b5gkwt330YJP2BTNeBRXkSUw3/HnebwL+sb4mdzXsWMWkG7RJudoeeY07f/7uObI8Xah57z2NGOX/KNSiCchlWMRwxvB58IhGSA2I9ilfx8bJldiA29sJ4s= Received: from PH8PR20CA0024.namprd20.prod.outlook.com (2603:10b6:510:23c::19) by CY8PR12MB8340.namprd12.prod.outlook.com (2603:10b6:930:7a::5) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7849.13; Tue, 6 Aug 2024 22:03:09 +0000 Received: from CY4PEPF0000FCC4.namprd03.prod.outlook.com (2603:10b6:510:23c:cafe::7a) by PH8PR20CA0024.outlook.office365.com (2603:10b6:510:23c::19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7828.26 via Frontend Transport; Tue, 6 Aug 2024 22:03:08 +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 CY4PEPF0000FCC4.mail.protection.outlook.com (10.167.242.106) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.7828.19 via Frontend Transport; Tue, 6 Aug 2024 22:03:08 +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; Tue, 6 Aug 2024 17:03:06 -0500 From: Babu Moger To: , , , , , , CC: , , , , , , , , , , , , , , , , , , , , , , , , , , , , Subject: [PATCH v6 16/22] x86/resctrl: Add the interface to unassign a MBM counter Date: Tue, 6 Aug 2024 17:00:53 -0500 Message-ID: <09da6e20b695086558d6cadefbc4830961e6e60b.1722981659.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: CY4PEPF0000FCC4:EE_|CY8PR12MB8340:EE_ X-MS-Office365-Filtering-Correlation-Id: bc01f782-09cf-4c32-2731-08dcb6638e78 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|1800799024|376014|82310400026|7416014|36860700013; X-Microsoft-Antispam-Message-Info: =?us-ascii?Q?OoDFoZTeTo9xrlROcVULtZCUostGaa17KLZF8MtxjgQPZVrTC6wpW5+rbs5I?= =?us-ascii?Q?tRzLhp5TH1tYL5WkO4s9c11C5sU5Ue7/0Tsf3SDuiUfKcwUNkcc/OqRExxRk?= =?us-ascii?Q?bSYMBk1jAUDClCmzJeWITB2g9wjuELT9c6Gqq0D038hgy217xtk6LSlVxdsr?= =?us-ascii?Q?8Ac2DG+8RuCDD9cGDUTk2V1k8XfSzIkBgZcaWnXw4HRKnXhw5vqIL3u1otGp?= =?us-ascii?Q?bhleTmB/pSAPwKXce5gfhmI1IOgNE5gv95+vEIkDcoi1Bb2DJl1yIVpQ+yAv?= =?us-ascii?Q?pos9EJGJmpvAARwrrFbRI+xzEGHF8Bp9hVvqA5bFVOc0bBerI0mTyI6I1R9g?= =?us-ascii?Q?/Bcvz8gtW3r1lEjbIS7m21dUPwUPtkfGOfnWHlJiAmHU7m5PR4ZpyPFqr8Iw?= =?us-ascii?Q?AgtqpzsXtNbqbIhKqVMjyADQoTI6b498ILH/CV5IlAfXjw9T6nD6tD8f+dQe?= =?us-ascii?Q?nliJIBO7hps6g37+gt7Rf4JV/nh3thk9lLf1w4sTQijbnxrZIpchc6ZTkDuq?= =?us-ascii?Q?L9xInbpU8txCwFY3pJZusfnfx7hEhWNWPKz5XB0mmRdGKk7dBiTxI8tFkZCT?= =?us-ascii?Q?hTj3+rtUii8AQ8BiXtlY0+pE16Icx3zpQhZNTYtxG4GLrJ93qxi3lpyZ2aW6?= =?us-ascii?Q?OFlcG27wuayAdzCUKInKj9JfWJkrWaUBxKXJGgGH2ReR6YqrPduLVRgJ8Fm6?= =?us-ascii?Q?DC73i1UuBlE9CTSn+oj7T7uCyTYBiuRe2iPHmV9L16Ib1YDq40ACUe2RrRLm?= =?us-ascii?Q?ZEPCJOOsnr6f8nj10/axHxveOnISgSr8r8X08FUeFNQVh4YdBjDNHf52y5+t?= =?us-ascii?Q?N/N2jf+CVcvk3d7ouzfDC3KZRv4EmiOV8Vy1xnprIo+FPBJnV9CNovrTFVnp?= =?us-ascii?Q?OoRcVocahQlGVUenviu3gOCWZIVBNY8cD6VN3p6tgqxiJ37jCma6E8lcp6N8?= =?us-ascii?Q?GZf2fok5qL1WVM3OxHzQjXHLSLK80k6wKM8LjdYVuIC9RCRuEaq8beYHoVpF?= =?us-ascii?Q?D6HGY0qiPJqxsHZIcVI9UyvG8ALXPwwRKK1YhvYMhWJ8NAYVMQS3ZRv+AVq8?= =?us-ascii?Q?h9GBsPDjn+uLIFnwwRhGGzbYkg9YU2KSBb0dqryyzfFWntkofagjl8X3TUOa?= =?us-ascii?Q?xtBve+l5dLfbFXnaFtOrtwhbkJIwbgYM9JsDTGZ6M/c2p4FVdzU+Wptueanw?= =?us-ascii?Q?YVY5g773HvRwA7wgykn8yFKstlMgFoFwmXSX8svdHlcR/QgAUtsohhu2/lq5?= =?us-ascii?Q?yIWuQdFcY+S6ppk0dGDArgRPjOA2TDtFVLsc1yZ5OLgNafU7X8TQo4GA6jbl?= =?us-ascii?Q?xA2TQD8bb0pvfYBZyRLfikcxMjO67oLCXyK1L/k1BadvMK3InzT7N+r42n6p?= =?us-ascii?Q?SQuCPtoG3t1O4P42eoAws6WmaMTghlt2W68jx1dQGptvWNGB7Q=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)(376014)(82310400026)(7416014)(36860700013);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 06 Aug 2024 22:03:08.6774 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: bc01f782-09cf-4c32-2731-08dcb6638e78 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: CY4PEPF0000FCC4.namprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: CY8PR12MB8340 Content-Type: text/plain; charset="utf-8" The ABMC feature provides an option to the user to assign a hardware counter to an RMID 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. Hardware provides only limited number of counters. If the system runs out of assignable counters, kernel will display an error when a new assignment is requested. Users need to unassign a already assigned counter to make space for new assignment. Provide the interface to unassign the counter ids from the group. Free the counter if it is not assigned in any of the domains. 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 --- 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. --- arch/x86/kernel/cpu/resctrl/internal.h | 2 + arch/x86/kernel/cpu/resctrl/rdtgroup.c | 52 ++++++++++++++++++++++++++ 2 files changed, 54 insertions(+) diff --git a/arch/x86/kernel/cpu/resctrl/internal.h b/arch/x86/kernel/cpu/r= esctrl/internal.h index 4e8109dee174..cc832955b787 100644 --- a/arch/x86/kernel/cpu/resctrl/internal.h +++ b/arch/x86/kernel/cpu/resctrl/internal.h @@ -689,6 +689,8 @@ int resctrl_arch_assign_cntr(struct rdt_mon_domain *d, = enum resctrl_event_id evt u32 rmid, u32 cntr_id, u32 closid, bool assign); int rdtgroup_assign_cntr(struct rdtgroup *rdtgrp, enum resctrl_event_id ev= tid); int rdtgroup_alloc_cntr(struct rdtgroup *rdtgrp, int index); +int rdtgroup_unassign_cntr(struct rdtgroup *rdtgrp, enum resctrl_event_id = evtid); +void rdtgroup_free_cntr(struct rdt_resource *r, struct rdtgroup *rdtgrp, i= nt index); void rdt_staged_configs_clear(void); bool closid_allocated(unsigned int closid); int resctrl_find_cleanest_closid(void); diff --git a/arch/x86/kernel/cpu/resctrl/rdtgroup.c b/arch/x86/kernel/cpu/r= esctrl/rdtgroup.c index 1ee91a7293a8..0c2215dbd497 100644 --- a/arch/x86/kernel/cpu/resctrl/rdtgroup.c +++ b/arch/x86/kernel/cpu/resctrl/rdtgroup.c @@ -1961,6 +1961,58 @@ int rdtgroup_assign_cntr(struct rdtgroup *rdtgrp, en= um resctrl_event_id evtid) return 0; } =20 +static int rdtgroup_mbm_cntr_test(struct rdt_resource *r, u32 cntr_id) +{ + struct rdt_mon_domain *d; + + list_for_each_entry(d, &r->mon_domains, hdr.list) + if (test_bit(cntr_id, d->mbm_cntr_map)) + return 1; + + return 0; +} + +/* Free the counter id after the event is unassigned */ +void rdtgroup_free_cntr(struct rdt_resource *r, struct rdtgroup *rdtgrp, + int index) +{ + /* Update the counter bitmap */ + if (!rdtgroup_mbm_cntr_test(r, rdtgrp->mon.cntr_id[index])) { + mbm_cntr_free(rdtgrp->mon.cntr_id[index]); + rdtgrp->mon.cntr_id[index] =3D MON_CNTR_UNSET; + } +} + +/* + * Unassign a hardware counter from the group and update all the domains + * in the group. + */ +int rdtgroup_unassign_cntr(struct rdtgroup *rdtgrp, enum resctrl_event_id = evtid) +{ + struct rdt_resource *r =3D &rdt_resources_all[RDT_RESOURCE_L3].r_resctrl; + struct rdt_mon_domain *d; + int index; + + index =3D mon_event_config_index_get(evtid); + if (index =3D=3D INVALID_CONFIG_INDEX) + return -EINVAL; + + if (rdtgrp->mon.cntr_id[index] !=3D MON_CNTR_UNSET) { + list_for_each_entry(d, &r->mon_domains, hdr.list) { + resctrl_arch_assign_cntr(d, evtid, rdtgrp->mon.rmid, + rdtgrp->mon.cntr_id[index], + rdtgrp->closid, false); + clear_bit(rdtgrp->mon.cntr_id[index], + d->mbm_cntr_map); + } + + /* Free the counter at group level */ + rdtgroup_free_cntr(r, rdtgrp, index); + } + + return 0; +} + /* rdtgroup information files for one cache resource. */ static struct rftype res_common_files[] =3D { { --=20 2.34.1 From nobody Sat Feb 7 21:19:49 2026 Received: from NAM02-BN1-obe.outbound.protection.outlook.com (mail-bn1nam02on2062.outbound.protection.outlook.com [40.107.212.62]) (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 800EF1779A4; Tue, 6 Aug 2024 22:03:22 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.212.62 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1722981804; cv=fail; b=lczDyWDa39OpzDXqAMriNWdhmFhZVLAyeYo1YuKvUCPIeWW8B7j8g0VGt5zW6qFMdNi8RJCXxldHZFjUz1NZYA282Rigv2cfXILFx6hEMEpxh5z9tIJ/wogk3tWPFMLoFK3YgkeZ/QkMYHxQ5DsH3hoTwvQk8d74vikDoAXabcU= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1722981804; c=relaxed/simple; bh=MOuQwSGNFscC86zTzkn80jMumpjdWUb9m1Tnq9hlEoo=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=nAgFypTp0DHS4/bOwVsjxIYFGRAHAn3fMulWIt7RPHsvIQtU7E6lqMxL3T+1nd8u5GYb9QQAKLHpvBdEORVTcX8gtMyDREp4Nk1fP9moYPnZRDaz+4/nbs4BmR3t+Pf2rQ3YdLY7ilQymq4+pP5DGJ7F48p/4S4LJwSfkeCIlsc= 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=FckzXpBB; arc=fail smtp.client-ip=40.107.212.62 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="FckzXpBB" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=cRJ8i1pvR0wqEsFghTOut7HTd4tcdtSUV+Z5pLnH1ZiI61tMLi3JXJIg7lXHclM5Fy9D4eht4M7hPphQLmIxDNnaOF7ja6+e+gFwFSzqhoTnckhqUCoZaaB5rNucFyDtl6NI5bPZW1i56N6l0JTSREe7odaChZ/flZKpLWjgADIMA58YRXR4Aq6J9Hu8jBRGzxJv88N2QmLT8itu6MPY1DH6aGzBr/lCA8MypjdCdK6MfpRqRKs2rYGLKE3MHrpOxZ5nKRc6OLyC6vX+mO217KNlGpSEnrH/YlqkCpLUjpjKXht+MzKTunyNwPiQqzCHRDkyg7z7ogzxB+7LTX76yQ== 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=bXcihIh9y5ASwQh2INcpxsX4hz8BHPj4tnsZYQP9SiM=; b=iwqdO/+JR1xsLx7il5pEdDgWpCLvyWdzVNA7Z4sAyml6MR9hqEOTkEoUFonka2TNwUEbhhaXdgTE1KxtfCmENSJHxnHwfHG7PwUDKAxba1gGLAq1BVOiLCdhS8hcuht4wfDxZDgXwVD+mpH8v8zV+RUgcayvHqEkKzb2xdbuPUOV7hh/xDb5T4H9qc7gAvVsh4vJQT8rD13EymsUZrwjdWKt2qwg3h2qPRDc8Gy9hv8Q0MukiTthYT9HW3+aWTKikdFlct1bxZSLW+Kl678HowNL5w8tf1tMSXTw5apax6Gy22W5je3Wt4HIPe48ykDQx8ko5a9+K7/t1LoW+zW5kw== 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=bXcihIh9y5ASwQh2INcpxsX4hz8BHPj4tnsZYQP9SiM=; b=FckzXpBB2osuRVcqee257zo8NF7Ef0arY8o55A5T+NHK+/mcLIoLko39OYrs65ilVEutHFD68wg7kS3AWTSZrGiFHUdwpfVIYuQXxSVZ8MAOdihIoq9QYH2R5sI5BtY4RtYdXPIVWuNhUGqFbAxVRPNe5ZrcngUCzaFugN3Pfl0= Received: from PH8PR20CA0015.namprd20.prod.outlook.com (2603:10b6:510:23c::8) by BY5PR12MB4083.namprd12.prod.outlook.com (2603:10b6:a03:20d::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7828.27; Tue, 6 Aug 2024 22:03:18 +0000 Received: from CY4PEPF0000FCC4.namprd03.prod.outlook.com (2603:10b6:510:23c:cafe::36) by PH8PR20CA0015.outlook.office365.com (2603:10b6:510:23c::8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7849.12 via Frontend Transport; Tue, 6 Aug 2024 22:03:18 +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 CY4PEPF0000FCC4.mail.protection.outlook.com (10.167.242.106) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.7828.19 via Frontend Transport; Tue, 6 Aug 2024 22:03:17 +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; Tue, 6 Aug 2024 17:03:14 -0500 From: Babu Moger To: , , , , , , CC: , , , , , , , , , , , , , , , , , , , , , , , , , , , , Subject: [PATCH v6 17/22] x86/resctrl: Assign/unassign counters by default when ABMC is enabled Date: Tue, 6 Aug 2024 17:00:54 -0500 Message-ID: <48e7516ccc04715d4fd6678cf00a99ccf43fba10.1722981659.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: CY4PEPF0000FCC4:EE_|BY5PR12MB4083:EE_ X-MS-Office365-Filtering-Correlation-Id: 91bdae0d-6009-4e3e-5e3c-08dcb6639400 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?tFJRfx3i6T6caiCQ+s7a2Tn0XCCNIv1cUUPmfC408YLI7vw17p9pKiTlbrKw?= =?us-ascii?Q?K7LcfQhEo9pJxnjdhsobUyw9cBtJFkN90WYalrVhukGypyXwVQmn/sbZI8o6?= =?us-ascii?Q?9e3RwVpHdyt2FM1s5qvyje84IiuGGu+1cP692CULjA7jWU1r+VzXQh7pfv0C?= =?us-ascii?Q?JR8p9knzpa/FxM7kJVuyddNfCtPP8kYnUbd5tduS70zlEO6qyPHSNvbrz3P0?= =?us-ascii?Q?hvdJPPirUTzBQqV1/E1MfSbwkJCYmp2r0zDCav9dJ2s7K2KolsVgWjxB6n1N?= =?us-ascii?Q?YChp7OF3ROATFPcglBOMjhTL0vjfuE8riP3o19faCU4OCddkh5owaAm2T2vt?= =?us-ascii?Q?UWImeqfIpqtNIoyAguXUdml+82bf1oxO10sVyk4hK+WYP4Ox+QKGP5ZLgfch?= =?us-ascii?Q?YwDpBLkPr8xz/DHHHsDvaPdAvoJRDC59EuLK9hxsOe+vIDBFDvsCNCAcEiWk?= =?us-ascii?Q?5s7kk/CdAKE8YzdeJeMmxdSzso/oPeWQXw+xB+H3FutNKyrLQxJ/5d+x7Y/X?= =?us-ascii?Q?ZK3Zo3AHxO6nZqsio1dxSmw4z9XhJFXi4wT5IF/zmp1SvyZpXWplOP6yk2zz?= =?us-ascii?Q?AzAvAiX6dPfKUyFx+RvwVU8zWKJ6id2VvZMZFQX2Mg/GcHRl78TWYNXHFlUA?= =?us-ascii?Q?6U+Yqi3lpwLUWHN0zvUJOfMwKQPmFLk8r1gYWn4lOo34JxfH9kO8ZPc7ufGH?= =?us-ascii?Q?OqC8Ef8fGoiQgEkbdwMLzuzcKYmdNniGmuPkp/4LEwvrieKuaP1XAXZkgF9N?= =?us-ascii?Q?2IHJ+TC3JjUNSoMyVmPqqLiFDkq2hWgqgF1rTmoz4oIA7hlmHIdudQ9aaXgd?= =?us-ascii?Q?nE/L+u4HP/g6z+7iQdU2s0UkawWyo5HFUWtDHliVX7yrUw8dsSKILI44U7vq?= =?us-ascii?Q?Tr1BsBv6jqxDy+BMDdPJPnZtWxtCs2SmcNkcqXGtNRGi8oJZ3r6Xqdwue+xh?= =?us-ascii?Q?jYTnQvykmAGe656f+59e/K9rmQ/VLrhiQovd5i50ZaQSHWj/kPtxkixeNJUf?= =?us-ascii?Q?Wg0Pe+sq7CrEbDE+2+GIcfZRVShihvqwtcxKTWa5B/uGQxNwrVDsrjLGWqk8?= =?us-ascii?Q?MNZwPewBdZipFHGuS/Sq8lQyAWp18eWJZ98lyDpPS4rR+6MlloczRAte+bLs?= =?us-ascii?Q?aO9BXqIRZflf4346AQzbP7e4afsOasZr8jdJ14azH5dyZ1fHtpYbRdD43aSI?= =?us-ascii?Q?HbTcydeaC2+xhFynxbQ+bf8+FiRmU8dLqjjjbN3IdKBBXhJaXYbCqZOBbD3M?= =?us-ascii?Q?zoegn5UCwSpJd6N/J9EWxPjQjhE5MoxZGTVsD73PchvOvME9ttBD9JPi42bH?= =?us-ascii?Q?iSk93FFf8yVMq2E8Gveltj8MrPPWap/n1h/lScJxNdiFMnnNPyIMU8V1/W2Z?= =?us-ascii?Q?cEu87UYUrwjba5wXBY6xnuHxTUZ0WZCvb12/kQIn+LI6MJLAW550A52J18iZ?= =?us-ascii?Q?YW1/5GuV/qT7rYYkUdfJc9pRSDpDRe5w?= 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: 06 Aug 2024 22:03:17.9587 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 91bdae0d-6009-4e3e-5e3c-08dcb6639400 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: CY4PEPF0000FCC4.namprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: BY5PR12MB4083 Content-Type: text/plain; charset="utf-8" Assign/unassign counters on resctrl group creation/deletion. Two counters are required per group, one for total event and one for local event. There are only limited number of counters for assignment. If the counters are exhausted, report the warnings and continue. It is not required to fail group creation for assignment failures. Users have the option to modify the assignments later. Signed-off-by: Babu Moger --- 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/rdtgroup.c | 55 ++++++++++++++++++++++++++ 1 file changed, 55 insertions(+) diff --git a/arch/x86/kernel/cpu/resctrl/rdtgroup.c b/arch/x86/kernel/cpu/r= esctrl/rdtgroup.c index 0c2215dbd497..d93c1d784b91 100644 --- a/arch/x86/kernel/cpu/resctrl/rdtgroup.c +++ b/arch/x86/kernel/cpu/resctrl/rdtgroup.c @@ -2908,6 +2908,46 @@ static void schemata_list_destroy(void) } } =20 +/* + * Called when new group is created. Assign the counters if ABMC is + * already enabled. Two counters are required per group, one for total + * event and one for local event. With limited number of counters, + * the assignments can fail in some cases. But, it is not required to + * fail the group creation. Users have the option to modify the + * assignments after the group creation. + */ +static int rdtgroup_assign_cntrs(struct rdtgroup *rdtgrp) +{ + int ret =3D 0; + + if (!resctrl_arch_get_abmc_enabled()) + return 0; + + if (is_mbm_total_enabled()) + ret =3D rdtgroup_assign_cntr(rdtgrp, QOS_L3_MBM_TOTAL_EVENT_ID); + + if (!ret && is_mbm_local_enabled()) + ret =3D rdtgroup_assign_cntr(rdtgrp, QOS_L3_MBM_LOCAL_EVENT_ID); + + return ret; +} + +static int rdtgroup_unassign_cntrs(struct rdtgroup *rdtgrp) +{ + int ret =3D 0; + + if (!resctrl_arch_get_abmc_enabled()) + return 0; + + if (is_mbm_total_enabled()) + ret =3D rdtgroup_unassign_cntr(rdtgrp, QOS_L3_MBM_TOTAL_EVENT_ID); + + if (!ret && is_mbm_local_enabled()) + ret =3D rdtgroup_unassign_cntr(rdtgrp, QOS_L3_MBM_LOCAL_EVENT_ID); + + return ret; +} + static int rdt_get_tree(struct fs_context *fc) { struct rdt_fs_context *ctx =3D rdt_fc2context(fc); @@ -2969,6 +3009,8 @@ static int rdt_get_tree(struct fs_context *fc) if (ret < 0) goto out_mongrp; rdtgroup_default.mon.mon_data_kn =3D kn_mondata; + + rdtgroup_assign_cntrs(&rdtgroup_default); } =20 ret =3D rdt_pseudo_lock_init(); @@ -2999,6 +3041,7 @@ static int rdt_get_tree(struct fs_context *fc) out_psl: rdt_pseudo_lock_release(); out_mondata: + rdtgroup_unassign_cntrs(&rdtgroup_default); if (resctrl_arch_mon_capable()) kernfs_remove(kn_mondata); out_mongrp: @@ -3258,6 +3301,8 @@ static void rdt_kill_sb(struct super_block *sb) resctrl_arch_disable_alloc(); if (resctrl_arch_mon_capable()) resctrl_arch_disable_mon(); + + rdtgroup_unassign_cntrs(&rdtgroup_default); resctrl_mounted =3D false; kernfs_kill_sb(sb); mutex_unlock(&rdtgroup_mutex); @@ -3849,6 +3894,8 @@ static int rdtgroup_mkdir_mon(struct kernfs_node *par= ent_kn, goto out_unlock; } =20 + rdtgroup_assign_cntrs(rdtgrp); + kernfs_activate(rdtgrp->kn); =20 /* @@ -3893,6 +3940,8 @@ static int rdtgroup_mkdir_ctrl_mon(struct kernfs_node= *parent_kn, if (ret) goto out_closid_free; =20 + rdtgroup_assign_cntrs(rdtgrp); + kernfs_activate(rdtgrp->kn); =20 ret =3D rdtgroup_init_alloc(rdtgrp); @@ -3918,6 +3967,7 @@ static int rdtgroup_mkdir_ctrl_mon(struct kernfs_node= *parent_kn, out_del_list: list_del(&rdtgrp->rdtgroup_list); out_rmid_free: + rdtgroup_unassign_cntrs(rdtgrp); mkdir_rdt_prepare_rmid_free(rdtgrp); out_closid_free: closid_free(closid); @@ -3988,6 +4038,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 /* @@ -4034,6 +4087,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 Sat Feb 7 21:19:49 2026 Received: from NAM12-MW2-obe.outbound.protection.outlook.com (mail-mw2nam12on2087.outbound.protection.outlook.com [40.107.244.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 72C1F17B41A; Tue, 6 Aug 2024 22:03:27 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.244.87 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1722981809; cv=fail; b=koQetwGIsi9ifoE8n8PEtrmxQVeeKKelZmI+6+bLBSlD5quqJqyPu4TEtJm8cGI3x1JdsG92Ypwd2dzwheqkWUsZ9BAoiK99+s8v8QhewI6NvirKm21q2dcuTAP+s5d/LN6uxjvbJRU9Ps8UAYI14wSoh2P5AeX4htcicBtI+dk= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1722981809; c=relaxed/simple; bh=1z43xcCe19W558VWFFZR/gULNawSj83Qmc3804+dW2Q=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=TnBBHgWXPtW+aQNtx49swkmYSIzL4Nd8QTvi0MDNb/jwPx2g1+kx8ZnzA/msHIiwcq41Vr1QwoqeMrq6lO3uqaLaJTbB9eT2MExcLq8EoSQ3TiXrFVOGm4X0m45xxJiDQFZFEaL1YlbKM7z65p18DV2h6POg0DB30csvQQug5F0= 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=kV2sRK5W; arc=fail smtp.client-ip=40.107.244.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="kV2sRK5W" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=RE/icdnXfjgJRoufzHdFVxkgbp8I7k3UghU4va/ZY+T+62O1L25TS2MUu4kGhg2rmDfu0izNairGZJNVaGZCO0907mYbh35y8e00Zm5nvdOS57MBQk+EyEh7wd7K2gileXWvRbD719TiiHjXmnWxmtmWiy6UpTfJ5b7HdmocEBGdk1oW8a9Vq/ItyYDifu78soeRSfStuqhxLiprW3pzaQIRbp/rxhAYlQKLil5yC+0nwdy95OnAAAzCjmFGAXuuy9EueBMiaKIE5Ms8W5j7n+vE9hEpPOvAJ3n6z2yk69L0vJcLpORzXFsfrppLVFJXA/ZWxu1Kq0WmgyDNloOl2w== 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=ngD9Klod5bPdyqwNWknmrJbwDt2Au2VkhoNI6hbNBok=; b=UXR5n7RyJNk2g0+fxNvlQjK8/PDN2+BoNzYwMeKYXLAc9Vnl1BZTSSh0w6vqWcLN+hNQp8/eBvHiC7wa52rtwOTfcsUhZl6mw6gwGdvmqafzFZK1zzsfNZQhz0IwH77uRp3hSzMk52tGrKYiD//8XZyUbwJOaBK2AoOGJkZvX/TnW/CcVwYXevofmw/pZv2LlWwSfluptAefp0blHBkrw3UyDldoFXjyjxQqDHPdy1BEyc1cHLdPtgVdHdQ7KEZnLapIZTO9LVfx0dHur6/z28yBE0QYjcZTdc1H6nFewveYmXGx3LvUYA4EYr6/b8019QQNreI5IzeunSa9EFKMUw== 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=ngD9Klod5bPdyqwNWknmrJbwDt2Au2VkhoNI6hbNBok=; b=kV2sRK5Wgx+PIKJNtg0RYaZSmq8xdyVwrGJEoDGpa6hz7K1brDQz5r18yeaNw5D1XFNV7H6NWBVB7NA+TBr5XngxOdz6AAWwEEWP/7bPH9UG2XoVMziRZvTaW/zyLsVWuC8pYmV7ZrULSfByyqKu6WaUqi3hz9LhwvOzU0u7LE0= Received: from PH8PR02CA0016.namprd02.prod.outlook.com (2603:10b6:510:2d0::25) by DS7PR12MB6071.namprd12.prod.outlook.com (2603:10b6:8:9d::11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7849.12; Tue, 6 Aug 2024 22:03:24 +0000 Received: from CY4PEPF0000FCC1.namprd03.prod.outlook.com (2603:10b6:510:2d0:cafe::95) by PH8PR02CA0016.outlook.office365.com (2603:10b6:510:2d0::25) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7828.27 via Frontend Transport; Tue, 6 Aug 2024 22:03:24 +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 CY4PEPF0000FCC1.mail.protection.outlook.com (10.167.242.103) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.7828.19 via Frontend Transport; Tue, 6 Aug 2024 22:03: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; Tue, 6 Aug 2024 17:03:22 -0500 From: Babu Moger To: , , , , , , CC: , , , , , , , , , , , , , , , , , , , , , , , , , , , , Subject: [PATCH v6 18/22] x86/resctrl: Report "Unassigned" for MBM events in ABMC mode Date: Tue, 6 Aug 2024 17:00:55 -0500 Message-ID: <5906d1a910c5e2bceb680c874e5e391618f6e313.1722981659.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: CY4PEPF0000FCC1:EE_|DS7PR12MB6071:EE_ X-MS-Office365-Filtering-Correlation-Id: b62fbf15-d54c-45b5-1ff6-08dcb6639776 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|1800799024|376014|36860700013|82310400026|7416014; X-Microsoft-Antispam-Message-Info: =?us-ascii?Q?2heeY/u0lp5DpR9FpeCqf6f1jVYBGCHeb93WcyzSVplPFFvrCtPvsEOC02PY?= =?us-ascii?Q?YviypeUvhrwdvydJDk60PxJHujxbv3sz89Yz6MiiaPX/NVwguN9Kn1mHOuZJ?= =?us-ascii?Q?jSjhW5UkTOOCJzeqM37YMLr8a1ChFqqZZ7RhY6kE0pkq8P/2CHcDJnSJQc/O?= =?us-ascii?Q?es8YRFOFeYgm2GTGoZPPWEheBFsz7KzhZgG/WQH1+lgowrzreT7psSuIH/WD?= =?us-ascii?Q?0cOB/Udw89oloMPN2WiI6UQa+b9u4Ue/rolochYJWcMHoMkVIBCPLNjj4GWE?= =?us-ascii?Q?628QGB9eLlRPSCV5ONXGOFpTgKOLPRN6YyA5GtZgiRVxdlFGSo/V22yj9yZj?= =?us-ascii?Q?4oguPnQNfxazT32tA6djKc/ndixxBcwT9xXE96z1Ado3TW7MKNw9f3FDCsNT?= =?us-ascii?Q?KyRaQBKjT6MMF+okinfTlSi80nrWio/MGWFci6QZrSmBsXalcvh+kLbFlb/c?= =?us-ascii?Q?3Q4V4cjbXCGlZgPBOEdkwA+TWdHf2aaIW4Ep4v6gnJO/27SyUla7WS1dsfzP?= =?us-ascii?Q?JkeX9TOVqeelaAy/hAEzMKKwEmy5M8zHnlTd/KYB5h0IsyCOdOBxv8cMeKFa?= =?us-ascii?Q?oat26wHhHSaAyFtYiwjDqvMxwfr7ER5ecDdrovDdwvSi3ZSW+Ia6493VcYRg?= =?us-ascii?Q?lW859q71QBvNdFIIhOFWq7B0jaY2oJ4sbTAjtXkYPJRcfiQo8ps2/gtACIx1?= =?us-ascii?Q?PRFK0OxSVCp84X038kPQqfz+IKrTKnOQnEmau+oJqDHYMdPVhAYBBgxNDND1?= =?us-ascii?Q?a3QiVhOuqUzFElUVwNzXqfq7lYnIFbFjtCLU6dXHorXD9i7lkHsniU3Gro9+?= =?us-ascii?Q?Q8lvq1yyGgA4lblDROgglQH8a/goTjzUSoVJgYm8MMKGmN8irjrFTd9JylGE?= =?us-ascii?Q?oz0xml4BTAR7Y2sjHLXB+df7gYAogcayIQnBbfajjXwjstZe+X6Tse3wBhEE?= =?us-ascii?Q?R3s4kZpRHIDlSBcj1icvbAymWk+YwIrtEsHHlkq+1+kjho4+j+CU864xqx8S?= =?us-ascii?Q?b94TyWqI3PzTIn7HEHWQY/uBnKb86tm3dFbwTPq1+xHAr4ULToArBsXC6j9O?= =?us-ascii?Q?cUgHsOZ3mRIBOcP4AGMRexeP8Cs27bSvBSeQ3qzNRIAOkUqydsf7xEJpvrdS?= =?us-ascii?Q?xYdKyQ6Bt9H3FunfHHpVFtsblUYpU8LciHECqPji6RvSTf8Ag8cdrbdRAWqE?= =?us-ascii?Q?geCZy45S9lRwsAt9CZpwzrvGkBwh7IOfCPaV1dAf7whUWXVlSi4CidynYAv1?= =?us-ascii?Q?O+C9WispJLyUYm3e16HbNjcwo8mzHZ7EZFeMaEF1Dc7pScebjOlHTC28zYYl?= =?us-ascii?Q?YKP8AYRow/12Fdc3+c0aylHkIZ+e5R5nc9mvtNWZuAEA0prC/GSdLdpk+f2I?= =?us-ascii?Q?uhs6Bc4cbWFMWyI1w5XfIXhphvsKejsR/tGxRT6lSeoDyTYUAzETk6bPl4jq?= =?us-ascii?Q?O27PCF/uIlbg/ScWVVr++HzKFLoYHRAX?= 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)(376014)(36860700013)(82310400026)(7416014);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 06 Aug 2024 22:03:23.7636 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: b62fbf15-d54c-45b5-1ff6-08dcb6639776 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: CY4PEPF0000FCC1.namprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DS7PR12MB6071 Content-Type: text/plain; charset="utf-8" In ABMC mode, the hardware counter should be assigned to read the MBM events. Report "Unassigned" in case the user attempts to read the events without assigning the counter. Signed-off-by: Babu Moger --- v6: Added more explaination in the resctrl.rst Added checks to detect "Unassigned" before reading RMID. v5: New patch. --- Documentation/arch/x86/resctrl.rst | 11 +++++++++++ arch/x86/kernel/cpu/resctrl/ctrlmondata.c | 13 ++++++++++++- 2 files changed, 23 insertions(+), 1 deletion(-) diff --git a/Documentation/arch/x86/resctrl.rst b/Documentation/arch/x86/re= sctrl.rst index fe9f10766c4f..aea440ee6107 100644 --- a/Documentation/arch/x86/resctrl.rst +++ b/Documentation/arch/x86/resctrl.rst @@ -294,6 +294,17 @@ with the following files: "num_mbm_cntrs": The number of monitoring counters available for assignment. =20 + Resctrl subsystem provides the interface to count maximum of two + MBM events per group, from a combination of total and local events. + Keeping the current interface, users can assign a maximum of two + monitoring counters per group. User will also have the option to + enable only one counter to the group. + + With limited number of counters, system can run out of assignable counter= s. + In mbm_cntr_assign mode, the MBM event counters will return "Unassigned" = if + the counter is not assigned to the event when read. Users need to assign a + counter manually to read the events. + "max_threshold_occupancy": Read/write file provides the largest value (in bytes) at which a previously used LLC_occupancy diff --git a/arch/x86/kernel/cpu/resctrl/ctrlmondata.c b/arch/x86/kernel/cp= u/resctrl/ctrlmondata.c index 50fa1fe9a073..ea918ce7c3ef 100644 --- a/arch/x86/kernel/cpu/resctrl/ctrlmondata.c +++ b/arch/x86/kernel/cpu/resctrl/ctrlmondata.c @@ -562,7 +562,7 @@ int rdtgroup_mondata_show(struct seq_file *m, void *arg) struct rdtgroup *rdtgrp; struct rdt_resource *r; union mon_data_bits md; - int ret =3D 0; + int ret =3D 0, index; =20 rdtgrp =3D rdtgroup_kn_lock_live(of->kn); if (!rdtgrp) { @@ -576,6 +576,15 @@ int rdtgroup_mondata_show(struct seq_file *m, void *ar= g) evtid =3D md.u.evtid; r =3D &rdt_resources_all[resid].r_resctrl; =20 + if (resctrl_arch_get_abmc_enabled() && evtid !=3D QOS_L3_OCCUP_EVENT_ID) { + index =3D mon_event_config_index_get(evtid); + if (index !=3D INVALID_CONFIG_INDEX && + rdtgrp->mon.cntr_id[index] =3D=3D MON_CNTR_UNSET) { + rr.err =3D -ENOENT; + goto checkresult; + } + } + if (md.u.sum) { /* * This file requires summing across all domains that share @@ -613,6 +622,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 --=20 2.34.1 From nobody Sat Feb 7 21:19:49 2026 Received: from NAM12-BN8-obe.outbound.protection.outlook.com (mail-bn8nam12on2068.outbound.protection.outlook.com [40.107.237.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 682E3176FDB; Tue, 6 Aug 2024 22:03:36 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.237.68 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1722981818; cv=fail; b=Gp5xc1Wk/p1v6Hm5XnZfuFd6y9hb8LQ7baR2unKZlqJQfdczLczYp2lWd84agrhmWGI7sA2fvlwIQS3j4U3EPWztUzd1/5fulAz3yKkamxLicJhkFRs7WfR1haftX+1Lu6yDv89NzQb0bz46uihgV/6Un2+vvRbXzp4VtXHX3I8= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1722981818; c=relaxed/simple; bh=mHbX5JYetqMw/hXe5qyEdJExcjwCbgWhEQeJw31C/iU=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=Cq8a7ZitfrZMdZvHsPx9g2bLLc2qxhU5ZzL3khusgGlJRuQAaGtwTOf8JEdhQxCbEonJFlVT0i9q/sAsBVKe6LO8NRNe0q2xA/QpkRat3/pQfQnzCgK6dLv4BtxNYlO4+iMUTapiBSdewFMbkxRGjlMBQ3r0IzFMMT6rmxNcg1U= 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=npG30UBH; arc=fail smtp.client-ip=40.107.237.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="npG30UBH" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=Nx38/i3YyBI4/L77vCysXxCrv8c5V0+9CuuHCQL2XP2DDCG71ZQdLtGx/aQixl1QUGWk2LGmgaZpYWC2pUQIpArDB053TElyl43B7ZWgQf60EoQc+f5tI1pJFsy0GfXCA2MZ1jOErVGRDEJ8oxoLMjEZPhwu6sWh1Guo2/JJKcLASZzWgXmNI4dQrmjleLOizy0+x79gn7wgpkYv0dxvn1c5RTGoC7kUB+YjSNaStwfLT7/MLgUt+vA940sfktA9jV4j0+iRRZkjecJKdttDTJHPMwTdijPG+E9u0ZG9B0JUe9dCTvdHbFfNVROpWwgP61PkCxRb5skchnJaON/tnw== 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=9r78anek0uaT/s8CX/EzS5YsOweokANxgaK/Mv0ttNA=; b=q+HXZmMVrFsMR5KxxLmG3k6vfYaHe0+ULd7fbHkz/XNHRxM0/t8UXQGV+/Du0gUVKBGC3gsPWJ51k3fVC+S/RCl/zJiWPWsfmBDt8P2V18zwsdwT9CNx18w9pR1SV0qE3Ka3//8bbdR8ImQPlYLPu5vEcxGxGqbOx9bq17ju+XYq24HYAdfApMY7xwFX8nBkjbHskFVASbroaVHtoEt/oxGkUBTxHRO10Q68Kb2GcSNJUK01qfZaWRua69fdDxctfyUdfxKoVwOhYOgSPMMe+e1DFJUiSYnZc/1UHUAVsn5RrHSkQ79WVEyPtRiXUjonUujoGkyoAzY1JfOdecYsFg== 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=9r78anek0uaT/s8CX/EzS5YsOweokANxgaK/Mv0ttNA=; b=npG30UBHx5yBCTZK0VP3EnCjtov1tn4Rv6YS6RArLTKeObnYbxCvNAIqdK4RcXqMRoB9H+OhcZKbxMs3VGT2C9iQoTwzdcCgPanM5Sc4AqenhsNez1xJVupy5v2xi97ylb21vScXeR8xvTrQ+4TkRbBNfaxMlLO0qeh6ei2f1NI= Received: from PH8PR02CA0004.namprd02.prod.outlook.com (2603:10b6:510:2d0::26) by MN2PR12MB4341.namprd12.prod.outlook.com (2603:10b6:208:262::24) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7828.26; Tue, 6 Aug 2024 22:03:31 +0000 Received: from CY4PEPF0000FCC1.namprd03.prod.outlook.com (2603:10b6:510:2d0:cafe::3f) by PH8PR02CA0004.outlook.office365.com (2603:10b6:510:2d0::26) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7849.13 via Frontend Transport; Tue, 6 Aug 2024 22:03:31 +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 CY4PEPF0000FCC1.mail.protection.outlook.com (10.167.242.103) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.7828.19 via Frontend Transport; Tue, 6 Aug 2024 22:03: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; Tue, 6 Aug 2024 17:03:29 -0500 From: Babu Moger To: , , , , , , CC: , , , , , , , , , , , , , , , , , , , , , , , , , , , , Subject: [PATCH v6 19/22] x86/resctrl: Introduce the interface to switch between monitor modes Date: Tue, 6 Aug 2024 17:00:56 -0500 Message-ID: <784eaa900b9e0778ddc534c04c7ded9466bfd19b.1722981659.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: CY4PEPF0000FCC1:EE_|MN2PR12MB4341:EE_ X-MS-Office365-Filtering-Correlation-Id: 2c08b469-32d9-43f1-9d81-08dcb6639c01 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|1800799024|36860700013|376014|7416014|82310400026; X-Microsoft-Antispam-Message-Info: =?us-ascii?Q?ZJiZsjFdB6FhIK4PltXEPq4qOayG6k9b9dEJtN3i4BsHdLpDD1b2AMawTcNZ?= =?us-ascii?Q?Kom66KXqXuKGbtlJCl7mK3ptYAsLWE49lJep5XS6HCMG06GR14tfiEtFVRbc?= =?us-ascii?Q?8jSbuEY6Ems66Wm6rnNxzHvG/LUG7qptPeF8b5AGD5NHR+YEDutkWuhrBjrj?= =?us-ascii?Q?3+h6tkk9WQkS3gmWBvErHPU/3wphuHZOlXRLr37YGRwNawQnciTgfSnIZoqy?= =?us-ascii?Q?u8jY5TFKQXyAZfFkAwMxAINPXsUdwwBVCwrw3DN0PZ5RgIngHXOZWA1zY8pJ?= =?us-ascii?Q?5OT7P8odB0tU3I9EWdCXYzHTAmc62jb8/pNAioxP0w7ypqR8R9nYAsDYNYI+?= =?us-ascii?Q?4zX43BKKj6DHSaHVMdxH/kXmZivH0uoZzDP+AG9QpXvcEi4uZV6Idu4RfR+I?= =?us-ascii?Q?6zIEt/ZRubtK1mhJXdTbFKw4ortuRxUZdXDJJdpAXPmhpnV/ltMkt0eLX469?= =?us-ascii?Q?X+aZlHU86RYzI/YpDjnNfvN+UYl3mvCu0rRVVk+FQagtntXdCokch6yRXoyE?= =?us-ascii?Q?Xmau4acLzoBwX1AC2Gfdi62IkDda/XjIWaeZpWqCvTO5EMra74aOnLlTt9ix?= =?us-ascii?Q?g5eE/LG+E3bgKJQoh56Q9IRyR1AtMAK18TxXNDUyG33GvAgaF7Cl6Q2zIgYi?= =?us-ascii?Q?zPJy2QP5fQ3mjc++aucM64AI8DwooHPWUCsSPnfWGqS9dO0wu+Bh/EGN23Id?= =?us-ascii?Q?9Iz6Y8gewWN3LYiKDMeABCnnVEXP0v8i42pOlgsHUm0xsxKjE9ZuxQ0Wi7z7?= =?us-ascii?Q?uhd+BmAxbauJ/raVSAbAmuSmN1PQc825w+8R01H0MNBTWA28Ea85DzSpw+Nk?= =?us-ascii?Q?2p7vII4ETm0Mw7gcC7X19+23H5l7YzB25y/ZJyp3fUyo40w22791oIMgs02+?= =?us-ascii?Q?LoOuCpAD1z7R13ZYaQJn0s3XfjyofXIdjTZHYzsqXAnLm+0kppVqjtB81i1p?= =?us-ascii?Q?O7TWNk8tpBO/LEg4odg6keP3+8kZjbs1jYvCYEJG6ydAgzTmDhdGTE0kNpQo?= =?us-ascii?Q?QJdW5pZMdshmIfNJGhLzpr9UGgL8F9Q9pLkNl/o/zjYtiBAF9qDUStsohN2R?= =?us-ascii?Q?3+4+6VkfM/+K3FPe3AM6n6FCaMqXGW3WJbpHf9juhI/DyjlFZNh5AL+x8GbF?= =?us-ascii?Q?z8B+O3bBwy3jFRh1ElRq1Uj58lHy6RlPlsjF2LPcsR7VldyC91NiGSmEK81a?= =?us-ascii?Q?xAhFhSvH44bommbZWUOagNNWbAAfq0J0U7EYkl2dEyEIdKnuo9bUTctE05I0?= =?us-ascii?Q?6FHJ+saNkCZJRliqSspinjDSbdoDyDv8dx+nYTF6M+Mnl4rTsKmSugoSCane?= =?us-ascii?Q?mJdEoCPP/ZVEU8EvQvUEgtCWmUVn4g2HMJjbFoB1iaJHxK/C4RbFP+J08bFK?= =?us-ascii?Q?sYRhU8hl46sbhDxUFuNda48Nd1sBSdCQ54bN/2YHFGSzhWrVzyEdZPQZ8Hrd?= =?us-ascii?Q?GJEk1aSQzyjsEiBxV0cV6AVqaq6HYqY1?= 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)(376014)(7416014)(82310400026);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 06 Aug 2024 22:03:31.3886 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 2c08b469-32d9-43f1-9d81-08dcb6639c01 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: CY4PEPF0000FCC1.namprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: MN2PR12MB4341 Content-Type: text/plain; charset="utf-8" Introduce interface to switch between ABMC and legacy modes. By default ABMC is enabled on boot if the feature is available. Provide the interface to go back to legacy mode if required. $ cat /sys/fs/resctrl/info/L3_MON/mbm_mode [mbm_cntr_assign] legacy To enable the "mbm_cntr_assign" mode: $ echo "mbm_cntr_assign" > /sys/fs/resctrl/info/L3_MON/mbm_mode To enable the legacy monitoring feature: $ echo "legacy" > /sys/fs/resctrl/info/L3_MON/mbm_mode MBM event counters will reset when mbm_mode is changed. Signed-off-by: Babu Moger --- 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/arch/x86/resctrl.rst | 15 +++++++ arch/x86/kernel/cpu/resctrl/rdtgroup.c | 62 +++++++++++++++++++++++++- 2 files changed, 76 insertions(+), 1 deletion(-) diff --git a/Documentation/arch/x86/resctrl.rst b/Documentation/arch/x86/re= sctrl.rst index aea440ee6107..d6d6a8276401 100644 --- a/Documentation/arch/x86/resctrl.rst +++ b/Documentation/arch/x86/resctrl.rst @@ -291,6 +291,21 @@ with the following files: as long as there are enough RMID counters available to support number of monitoring groups. =20 + * To enable ABMC feature: + :: + + # echo "mbm_cntr_assign" > /sys/fs/resctrl/info/L3_MON/mbm_mode + + * To enable the legacy monitoring feature: + :: + + # echo "legacy" > /sys/fs/resctrl/info/L3_MON/mbm_mode + + The MBM event counters will reset when mbm_mode is changed. Moving to + mbm_cntr_assign will require users to assign the counters to the events to + read the events. Otherwise, the MBM event counters will return "Unassigne= d" + when read. + "num_mbm_cntrs": The number of monitoring counters available for assignment. =20 diff --git a/arch/x86/kernel/cpu/resctrl/rdtgroup.c b/arch/x86/kernel/cpu/r= esctrl/rdtgroup.c index d93c1d784b91..66febff2a3d3 100644 --- a/arch/x86/kernel/cpu/resctrl/rdtgroup.c +++ b/arch/x86/kernel/cpu/resctrl/rdtgroup.c @@ -896,6 +896,65 @@ static int rdtgroup_mbm_mode_show(struct kernfs_open_f= ile *of, return 0; } =20 +static void rdtgroup_mbm_cntr_reset(struct rdt_resource *r) +{ + struct rdtgroup *prgrp, *crgrp; + struct rdt_mon_domain *dom; + + mbm_cntrs_init(r); + + list_for_each_entry(dom, &r->mon_domains, hdr.list) + bitmap_zero(dom->mbm_cntr_map, r->mon.num_mbm_cntrs); + + /* Reset the cntr_id's for all the monitor groups */ + list_for_each_entry(prgrp, &rdt_all_groups, rdtgroup_list) { + prgrp->mon.cntr_id[0] =3D MON_CNTR_UNSET; + prgrp->mon.cntr_id[1] =3D MON_CNTR_UNSET; + list_for_each_entry(crgrp, &prgrp->mon.crdtgrp_list, + mon.crdtgrp_list) { + crgrp->mon.cntr_id[0] =3D MON_CNTR_UNSET; + crgrp->mon.cntr_id[1] =3D MON_CNTR_UNSET; + } + } +} + +static ssize_t rdtgroup_mbm_mode_write(struct kernfs_open_file *of, + char *buf, size_t nbytes, + loff_t off) +{ + int mbm_cntr_assign =3D resctrl_arch_get_abmc_enabled(); + struct rdt_resource *r =3D of->kn->parent->priv; + 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 (!strcmp(buf, "legacy")) { + if (mbm_cntr_assign) + resctrl_arch_mbm_cntr_assign_disable(); + } else if (!strcmp(buf, "mbm_cntr_assign")) { + if (!mbm_cntr_assign) { + rdtgroup_mbm_cntr_reset(r); + ret =3D resctrl_arch_mbm_cntr_assign_enable(); + } + } else { + ret =3D -EINVAL; + } + + mutex_unlock(&rdtgroup_mutex); + cpus_read_unlock(); + + return ret ?: nbytes; +} + static int rdtgroup_num_mbm_cntrs_show(struct kernfs_open_file *of, struct seq_file *s, void *v) { @@ -2127,9 +2186,10 @@ static struct rftype res_common_files[] =3D { }, { .name =3D "mbm_mode", - .mode =3D 0444, + .mode =3D 0644, .kf_ops =3D &rdtgroup_kf_single_ops, .seq_show =3D rdtgroup_mbm_mode_show, + .write =3D rdtgroup_mbm_mode_write, .fflags =3D RFTYPE_MON_INFO, }, { --=20 2.34.1 From nobody Sat Feb 7 21:19:49 2026 Received: from NAM10-MW2-obe.outbound.protection.outlook.com (mail-mw2nam10on2048.outbound.protection.outlook.com [40.107.94.48]) (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 BDDC7176FB0; Tue, 6 Aug 2024 22:03:43 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.94.48 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1722981825; cv=fail; b=syJXGy5G+w2LpJGL0btwqxxYmwzcPq8ZYuwZYEL4UAXC44ynPyhnyQGaNA6jDjcbQbwjgQiLYHP58C3y2Q82IZIjcM1UbFkvcWLSamlMPSwuBGooKLo2w8nVk6AO4JZsZ8pdbZV7RiWPv2mt2+fY/BFKB7KB4qtP5u2uk3vLCd0= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1722981825; c=relaxed/simple; bh=p/J/LYGTOEAb0f2jWN9MIegJTCTXifk0DjehSEYJBbM=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=ATHoUMscMb2bS0W4Y8vzzj+2JYcPnjYD5B+ttapsEPBG9VMo63+ggn7IBQLzDZEAs9DN58TD4Ao5ggqCAuJRJ4D+lNdFNoyIpWshv4Jm2akIJilUvNcn4BqfhYsEbJkbJf4d1pbJyTuywFRpR0k7Wg+U6qgY0ugYd6SOcGYE0ao= 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=e1g770E+; arc=fail smtp.client-ip=40.107.94.48 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="e1g770E+" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=nAbI1OGsYTY6xBeYkWObjbQ37mrjtyGWMgcYDH7Hm/YXfjKe5PoTRxL/G0HByBVnBnlzpUngUH4c15ECuUSck5Ps3tbWMv3iOjPH6tgUG3UGYZkOyLgYK1z6vrwbLGEKwfD9CRNhkLD6J1B1zHPAcN/HvPBRCut5KwuqarNeYdoN2kIuKYwCfkYkj9y2KMFG7pzBR48kspY3/lyYzOZsNm72o7o36B2DOpzkcM4X4jL+hRqIukMZ2FlCu4X5YX5zYu75/8KdueeLz3DRnrSxqSXUYdSQNupjaYaHNF7080+7a3lvQZogJSnyNjQp9h4iZTDoIRkfY1ejI+vW6xlTqQ== 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=eS1ethcq9suAZA0pTe6zGF/wa7i4N0VHnwca7AyzQ+8=; b=s2DRVdxRt9qUnwxiUzZyh+aEpCuOoeTeEHNSBcI4PJjP3+ilR6Zu6VGecn0B1ykfSKmqdrHKY/0oORaVHuHyrPujRIcn0GjK2M8h8LwYQVDss7QX24gmgbfllGN6Hy3760TfRZdAKVEuFRCPREr6vYJxzn2nNBhZR9eoKrMEP2BekqZyCNasi+wsZSIjKiKu1LhfbkxnKhWnsmDCKjO4rGL3JUtsMTQsXR6c/z2ePwNY7XaCa/gSzAxuQqidkZ/PKk+ztHoE965IMVRTu3M2L4B9pq/cVzryzW2YzUyLX1NOduwBZilFMXXzbuyoqm5nlqmqf7ZrDmAdJHKdP7jWEg== 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=eS1ethcq9suAZA0pTe6zGF/wa7i4N0VHnwca7AyzQ+8=; b=e1g770E+OChv+W647IQmhQ/+5FIk+0oj7k4lTOxaWPgK6HrORV5tuJGNzYHTW/u9FL3eWWhbt6uTbOZ4ArP56eXEmd2MD762HeIQPf53757W8VtC4Psu7n19Ca5nEInLhs2evk327Ki+G+THRrVYPKwvBhWK4qlxbroW9PYhzqI= Received: from PH8PR22CA0003.namprd22.prod.outlook.com (2603:10b6:510:2d1::6) by MW4PR12MB6898.namprd12.prod.outlook.com (2603:10b6:303:207::6) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7828.22; Tue, 6 Aug 2024 22:03:39 +0000 Received: from CY4PEPF0000FCC0.namprd03.prod.outlook.com (2603:10b6:510:2d1:cafe::bf) by PH8PR22CA0003.outlook.office365.com (2603:10b6:510:2d1::6) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7828.27 via Frontend Transport; Tue, 6 Aug 2024 22:03: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 CY4PEPF0000FCC0.mail.protection.outlook.com (10.167.242.102) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.7828.19 via Frontend Transport; Tue, 6 Aug 2024 22:03: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; Tue, 6 Aug 2024 17:03:37 -0500 From: Babu Moger To: , , , , , , CC: , , , , , , , , , , , , , , , , , , , , , , , , , , , , Subject: [PATCH v6 20/22] x86/resctrl: Enable AMD ABMC feature by default when supported Date: Tue, 6 Aug 2024 17:00:57 -0500 Message-ID: <1061a60166f2fdb508aaf2dd9163b2bab3705063.1722981659.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: CY4PEPF0000FCC0:EE_|MW4PR12MB6898:EE_ X-MS-Office365-Filtering-Correlation-Id: a85769cf-0c63-42f9-cf29-08dcb663a089 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?ZS8AeIodI4KbzKjv9uXrNp1hf72GmZBLJjcE0uiic71GjXKMujD/uSa+KuEO?= =?us-ascii?Q?vQVeX+YLp9KNo140DsxCsE4YcJZoMi19WVpUWJzfBXLJ6TlAIlSOLNwxFICb?= =?us-ascii?Q?6fyftNh5+3pNd55U8gb86npXdxMu3e4TJ+8j+7EJUsxLl+ZkyH4Ua8rKoHza?= =?us-ascii?Q?CIy8ufl/TcAogmsXUkqROMuCU7gI+/AMnUXuRTiZahmqfw1EHueI8wEY82am?= =?us-ascii?Q?CMkD8DkXHFLjBzBHseH0wTZgksnjDl5ZWlE+MJd7t2l8XUk0lJl2AqY0AEK+?= =?us-ascii?Q?xDZjpXCAu1u+7R1d+ICEqyTOQlc28uURjgkAJ12hbm9/QYsoT22fso68JpRB?= =?us-ascii?Q?3AGeiFDWZyUPU8Z0zPgTazvknbknfv6BP5LFAr0BBpCbrBLVpxYPGcWBQCR7?= =?us-ascii?Q?+IHEEIb6thBRu6wjf6GLTWo9KpTRJWX2bW9FciytCeEHfoCD3HO6JfF3U3xL?= =?us-ascii?Q?aI5OJKAaktGDwwaKnxKEE8Q/JSLxTLesuVq0Mcy07LjW78z6HxroM97cY26C?= =?us-ascii?Q?1sxcq5nodz1kj4iXPpILBzflPrZ/mWGQykHJ2eVc/SujwA+D9Q+3tPAe+kss?= =?us-ascii?Q?UtG4j1AB0t+4oCRaJTTwiZc2dqwJr8s7KanOWurMU9NLEaUx2QP8nb9Avujz?= =?us-ascii?Q?rUSQENl/gTmBvi+9/68K/zT3CEGwNswDOBcIt4G7KtfPUSiyV7hu7iXAiA+Z?= =?us-ascii?Q?LGA6kbgezzE4ZaGO18/8TS41ZX8AiJwNu9Qw9v20NffAazaIvoHCf9jiKZIB?= =?us-ascii?Q?89QGep2BcFtyrxT3YkbIXskasvkjhC21gg0yQHHj9eCjUKREy9sIgzOKVfL/?= =?us-ascii?Q?3KkCCqyuOt97RaExVoYxQ3IRpD1qL7D1AGQBqxciBScVzoE+dJYxYgmoKI4w?= =?us-ascii?Q?F8IdEFeYDLwvaZ/M12J6EwsZhlPHoQ9v6op8QfA0ATr0d7brL6/MhxtLGVPE?= =?us-ascii?Q?5YrtqKrEVnud5g5645oqt/fzNAMpTIbNU8pCqZGfgzVcadvTMQELzmavjqAc?= =?us-ascii?Q?kCyWH2ZRUCegHXkwioAP/t7NG2ZONbkoD/LD/Au12V4mgNrQor3bt7UBFpuL?= =?us-ascii?Q?gfWc/n+p7NBG8drEwa6ZLhCfZJNthGV/3qLQYr4rz8eygmaSsOiM/lk64XlQ?= =?us-ascii?Q?xyJFNkJbGf0dmP8P2rwv80vOY5U3SjAj2upQIYscM/FnJjDWFgBDNzhhs/PT?= =?us-ascii?Q?pzaKRybIgaFeNC1/s1H3BxgDgPaPAF7aFGwBE6Brin0WbpRY57wsmPAbyIbw?= =?us-ascii?Q?nyAaW20Rk+QxaPwXaizwG5wvwtFM1PGAk4GjnRseKtnbw5POFoNWqa7JnDSL?= =?us-ascii?Q?/WIY+8Q3XqD30Bd9+oAGILa2gN4enMDkge2nf0kJeNJWGbf4NNIDthyiSduS?= =?us-ascii?Q?BhCgTjwO4pjgeMl03akx3UHJBf2ZJihpVjsnFI2RwtT6cqqBzSBkLw6Br2jQ?= =?us-ascii?Q?H3+e/cTJN8JHQayR0pSlPErUIMa7k3g9?= 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: 06 Aug 2024 22:03:38.9921 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: a85769cf-0c63-42f9-cf29-08dcb663a089 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: CY4PEPF0000FCC0.namprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: MW4PR12MB6898 Content-Type: text/plain; charset="utf-8" Enable ABMC by default when supported during the boot up. Users will not see any difference in the behavior when resctrl is mounted. With automatic assignment everything will work as running in the legacy monitor mode. Signed-off-by: Babu Moger --- 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 | 2 ++ arch/x86/kernel/cpu/resctrl/internal.h | 1 + arch/x86/kernel/cpu/resctrl/rdtgroup.c | 17 +++++++++++++++++ 3 files changed, 20 insertions(+) diff --git a/arch/x86/kernel/cpu/resctrl/core.c b/arch/x86/kernel/cpu/resct= rl/core.c index 6fb0cfdb5529..a7980f84c487 100644 --- a/arch/x86/kernel/cpu/resctrl/core.c +++ b/arch/x86/kernel/cpu/resctrl/core.c @@ -599,6 +599,7 @@ 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); + resctrl_arch_mbm_cntr_assign_configure(); return; } =20 @@ -620,6 +621,7 @@ static void domain_add_cpu_mon(int cpu, struct rdt_reso= urce *r) arch_mon_domain_online(r, d); =20 resctrl_mbm_evt_config_init(hw_dom); + resctrl_arch_mbm_cntr_assign_configure(); =20 if (arch_domain_mbm_alloc(r->mon.num_rmid, hw_dom)) { mon_domain_free(hw_dom); diff --git a/arch/x86/kernel/cpu/resctrl/internal.h b/arch/x86/kernel/cpu/r= esctrl/internal.h index cc832955b787..ba3012f8f940 100644 --- a/arch/x86/kernel/cpu/resctrl/internal.h +++ b/arch/x86/kernel/cpu/resctrl/internal.h @@ -685,6 +685,7 @@ int mbm_cntr_alloc(struct rdt_resource *r); void mbm_cntr_free(u32 cntr_id); void resctrl_mbm_evt_config_init(struct rdt_hw_mon_domain *hw_dom); unsigned int mon_event_config_index_get(u32 evtid); +void resctrl_arch_mbm_cntr_assign_configure(void); int resctrl_arch_assign_cntr(struct rdt_mon_domain *d, enum resctrl_event_= id evtid, u32 rmid, u32 cntr_id, u32 closid, bool assign); int rdtgroup_assign_cntr(struct rdtgroup *rdtgrp, enum resctrl_event_id ev= tid); diff --git a/arch/x86/kernel/cpu/resctrl/rdtgroup.c b/arch/x86/kernel/cpu/r= esctrl/rdtgroup.c index 66febff2a3d3..d15fd1bde5f4 100644 --- a/arch/x86/kernel/cpu/resctrl/rdtgroup.c +++ b/arch/x86/kernel/cpu/resctrl/rdtgroup.c @@ -2756,6 +2756,23 @@ void resctrl_arch_mbm_cntr_assign_disable(void) } } =20 +void resctrl_arch_mbm_cntr_assign_configure(void) +{ + struct rdt_resource *r =3D &rdt_resources_all[RDT_RESOURCE_L3].r_resctrl; + struct rdt_hw_resource *hw_res =3D resctrl_to_arch_res(r); + bool enable =3D true; + + mutex_lock(&rdtgroup_mutex); + + if (r->mon.mbm_cntr_assignable) { + if (!hw_res->mbm_cntr_assign_enabled) + hw_res->mbm_cntr_assign_enabled =3D true; + resctrl_abmc_set_one_amd(&enable); + } + + mutex_unlock(&rdtgroup_mutex); +} + /* * We don't allow rdtgroup directories to be created anywhere * except the root directory. Thus when looking for the rdtgroup --=20 2.34.1 From nobody Sat Feb 7 21:19:49 2026 Received: from NAM02-SN1-obe.outbound.protection.outlook.com (mail-sn1nam02on2074.outbound.protection.outlook.com [40.107.96.74]) (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 A8C2F173357; Tue, 6 Aug 2024 22:03:51 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.96.74 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1722981833; cv=fail; b=mCMgZolV0/aiygtTAC9KmHmtKEoWDQLtK6adhFpYYqmuT0ZsJXrBYRLl5gqMDSSiCt+PDARBT2KXuLKGwppNPkWOKa4h6PR8MMGFSzbq5jwF9G89e1BnYWQKcReGeOQRltZ3fQ2GQsh+Gv2VxYbsAggIo8li300rNfXKpwNQjdA= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1722981833; c=relaxed/simple; bh=B/dmYuK9vUPp1Ou+XfvZLk2fTttWQEHcsPO2W2K24wU=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=IWzEfvwXN0aXKrmJ3w43lbzBDIwoUk2E9XUuzmSIDPlptJbTbswSsVgRFNB1HvqNRP4dwIq7PC60//AGG6l3cyOJRCAbUe+dgkGU5bGJRU9NZDxv3BA0cmeqd2ZHfHLadIpqlT6HHPXcghi9wbOBecJBq1B01SO65KgFnLf8d/I= 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=HJT7+M2D; arc=fail smtp.client-ip=40.107.96.74 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="HJT7+M2D" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=JNdpukIExEq3LeDnpJmqGjT42GRxsT0x1hKkgfPTRsMc89lgiAuj44sKdPKT6LvYaU98LTQ2rGjybeWJ+bNzsrBxg1yNPvuAt1bU3qLKAodaoXfWxIVr3EByO2hVa/O1H5dkbAryUvfFPnK6ftIV8uLWx6unhF94ADFdYrmEjMEWV7iwg2uAHcz9/yZH2yOeH44Fhw8NE/E/A4iTrsVdp6urttZJqYk9zI+W6+Xd+TNnxtR4DUu/lmQeQlpeKFsRXS/zg3nFY/8bol5ciYfWxb48LBPcG2LxSq5KxkrlFi+SxD0+DPs1iYS1mKJFHgOsnYJpZBqUVd9HYuGPDV2dsA== 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=kMDKInZaoV3fLVyH3mxFmd5P67T+yiouA/+vv8Rmlpc=; b=ptUoo3vW1rXd+If6FJVPqldPPVanbmrVwVdzUfjEyYy0Qr4F8qw+GNDVwGf9cWo1DH7WynZf3vracjp3/e0jhv/acHdHyngCs8ApafTVnh6eGB+3qTzz3Hdc6BAyM1SMcfbIZPBPG1hD/HNuSPlIULJtbCDdZDjKI3dxxLd4C5PiKBaiwpTyPD8GNzeV4xPrHPRA3nN8MDkytqhnhRp5Om6mchH2l4qboZUfPtOX+vfKMj1p5QvZ9aIaXyLsv5yH85IYiBB/hfv7CHquRndRMzZfWjtfjpiFzpTY5HNGONUYKpJA+tIM8PiaTXzcFpyU1k87UwJsX9Ayb0vQUmlqsA== 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=kMDKInZaoV3fLVyH3mxFmd5P67T+yiouA/+vv8Rmlpc=; b=HJT7+M2DnQpS/285At0VPStcGCbiAAjXSJLIvenSbNxx0SKOa5O4WORtV1SxD7pKltQI5PxTX+gjOWVPOHN925sxEq3xf7NyEWMop25qcINY3Gff6HqWDhUtuFoMG1y90tEuf0uTnQTSv550BpBkaKg0qFwUmQSTC2R/V8ZASis= Received: from PH8PR22CA0013.namprd22.prod.outlook.com (2603:10b6:510:2d1::11) by SJ2PR12MB7821.namprd12.prod.outlook.com (2603:10b6:a03:4d2::21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7828.25; Tue, 6 Aug 2024 22:03:48 +0000 Received: from CY4PEPF0000FCC0.namprd03.prod.outlook.com (2603:10b6:510:2d1:cafe::c7) by PH8PR22CA0013.outlook.office365.com (2603:10b6:510:2d1::11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7849.13 via Frontend Transport; Tue, 6 Aug 2024 22:03:48 +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 CY4PEPF0000FCC0.mail.protection.outlook.com (10.167.242.102) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.7828.19 via Frontend Transport; Tue, 6 Aug 2024 22:03:47 +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; Tue, 6 Aug 2024 17:03:44 -0500 From: Babu Moger To: , , , , , , CC: , , , , , , , , , , , , , , , , , , , , , , , , , , , , Subject: [PATCH v6 21/22] x86/resctrl: Introduce interface to list monitor states of all the groups Date: Tue, 6 Aug 2024 17:00:58 -0500 Message-ID: <821b725e9f00b4d423cc28d777d66d5681e1ba29.1722981659.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: CY4PEPF0000FCC0:EE_|SJ2PR12MB7821:EE_ X-MS-Office365-Filtering-Correlation-Id: 62ffd8ad-5c22-4e3f-7c21-08dcb663a5e9 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|82310400026|36860700013|7416014|376014|1800799024; X-Microsoft-Antispam-Message-Info: =?us-ascii?Q?7VTM77KP+PJKdbM5X98wNEGy6yO60c5ZMyweOW0DK5yJzGZBqt8saTK9Wyv9?= =?us-ascii?Q?I7SrbamTwbq2W1RH5wdazyu1PUiUM4tOOjvva60Lm1stAbBURazkOPyv8xnw?= =?us-ascii?Q?3or3c/20D2L6yYn07mnxTBjRSdzqXKxM9gAMJA8gW2rNRoyaSpzCltNdNq8c?= =?us-ascii?Q?7EZ8L/bINMybdDlzpnkWdHxkGrDu3U0k8c7wHEbnbzQzg3p7x5JdML3B9xv3?= =?us-ascii?Q?VO6H6u10YQldyC831r3ia3NDcIYKq/hHL+palFc5pqMXBPGZaQ3UR5OVndsh?= =?us-ascii?Q?6EIfqbMH1tfB1CtYQCmrHuUo/Zu3VSYoUodAJiIVl3+YJ/AwAA+9ZbfXi78r?= =?us-ascii?Q?07LPVCUD9rA+a7cpdWCa/peHJkuW7lFD8wmsUuWtFoLIfwEZDO0D/fMLhtm6?= =?us-ascii?Q?r7WrHpW1altx7K2kB9hPZCV9CVQso1l37zsU7NbxkggFFvu+LxWaObHDwwX6?= =?us-ascii?Q?qcEGdHyCUm3oNxNuMIDPr7ejK23LLMv8tusgT83b2A8vhGZopmwzFjGjFzRJ?= =?us-ascii?Q?l2BvQViJUXiYF9jFsylhqFpNxd2IhE8q7Fj0GtL5AMkBdUllRBZG5HNMDDAZ?= =?us-ascii?Q?+VnKbbtZ+TnKj0SQUMZQfo5BSpIZlE5dxgnE38+nDs/Hki8ThS+UhANWFpIA?= =?us-ascii?Q?upx0Zz0Mj26YG9SNd8/ZYNS1W9iFy+opAB45FBIhZ3fIvU9rWLdtmz4XDnIU?= =?us-ascii?Q?ICxwV1F0lrBf3j3xAiV2SpiOu7K9H/ggVyjsyOdkznjrR9oWoNskpI/A9623?= =?us-ascii?Q?YfGcyteBgBpeptVSPsMdf1XLWfigOtRQ5D5fta8kNfMc+/J9nNXCzsO+pnPS?= =?us-ascii?Q?R6AhbhxI0EbRg5f5zlT561tdT3U0NPnn4ovFqP/iXE290J0QLRVzjZKDr5kv?= =?us-ascii?Q?Ce1xESKE2Rkoi6M9tiLc3QQIw/4xTp07KdYt8E+Wi+xldFqj/rG5l+U8jmiq?= =?us-ascii?Q?w346XCWDlvbSbQdjE+IQr79PsV7VMLrO1TBg/8cqv99DSmDUWvUHT1HXCtC4?= =?us-ascii?Q?Dii8M/Ns1jucR8vON++SxFMtCQoZjjvHtgX2YetC+thqNEEav8xWIBD7JvE6?= =?us-ascii?Q?L5beonvNiOAo2xdEEF2LD4rbfY0idpSQrsHizS46nyGIz8NKVi7CdVFxSq/f?= =?us-ascii?Q?HvXn1oPpX482yK9DLbQ2IB48+vMF7LUPYuOjrxAqIBjgqntj6bCgA0ViVMMX?= =?us-ascii?Q?G0AeycShD3+j3DHmVVz34+VPAwUH2wmR45A+ZQlP4Aj/b9i9XwZ447EAdvnB?= =?us-ascii?Q?/wGmBiuG6hRxBybIkhImgrEZ2wUktC6Xeg966ut0u0s6zDrYKa6KK6YWZE46?= =?us-ascii?Q?H4y1uCwXfXDJTha+CCo7lUp4Hnn7OkwMQCGsBdkxfmOssKSZYuILEXNKzAX/?= =?us-ascii?Q?S/GVO7tRpuVX1brXzfUZeuQ3Xdb8N3MiJ7P3Cy6IvXRrrahcPw=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)(7416014)(376014)(1800799024);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 06 Aug 2024 22:03:47.9921 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 62ffd8ad-5c22-4e3f-7c21-08dcb663a5e9 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: CY4PEPF0000FCC0.namprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: SJ2PR12MB7821 Content-Type: text/plain; charset="utf-8" Provide the interface to list the monitor states of all the resctrl groups in ABMC mode. Example: $cat /sys/fs/resctrl/info/L3_MON/mbm_control List follows the following format: "//=3D" Format for specific type of groups: - Default CTRL_MON group: "//=3D" - Non-default CTRL_MON group: "//=3D" - Child MON group of default CTRL_MON group: "//=3D" - Child MON group of non-default CTRL_MON group: "//=3D" Flags can be one of the following: t MBM total event is enabled l MBM local event is enabled tl Both total and local MBM events are enabled _ None of the MBM events are enabled Signed-off-by: Babu Moger --- v6: The domain specific assignment can be determined looking at mbm_cntr_ma= p. Removed rdtgroup_abmc_dom_cfg() and rdtgroup_abmc_dom_state(). Removed the switch statement for the domain_state detection. Determined the flags incremently. Removed special handling of default group while printing.. v5: Replaced "assignment flags" with "flags". Changes related to mon structure. Changes related renaming the interface from mbm_assign_control to mbm_control. v4: Added functionality to query domain specific assigment in. rdtgroup_abmc_dom_state(). v3: New patch. Addresses the feedback to provide the global assignment interface. https://lore.kernel.org/lkml/c73f444b-83a1-4e9a-95d3-54c5165ee782@intel= .com/ --- Documentation/arch/x86/resctrl.rst | 45 ++++++++++++++++ arch/x86/kernel/cpu/resctrl/monitor.c | 1 + arch/x86/kernel/cpu/resctrl/rdtgroup.c | 75 ++++++++++++++++++++++++++ 3 files changed, 121 insertions(+) diff --git a/Documentation/arch/x86/resctrl.rst b/Documentation/arch/x86/re= sctrl.rst index d6d6a8276401..113c22ba6db3 100644 --- a/Documentation/arch/x86/resctrl.rst +++ b/Documentation/arch/x86/resctrl.rst @@ -320,6 +320,51 @@ with the following files: the counter is not assigned to the event when read. Users need to assign a counter manually to read the events. =20 +"mbm_control": + Reports the resctrl group and monitor status of each group. + + List follows the following format: + "//=3D" + + Format for specific type of groups: + + * Default CTRL_MON group: + "//=3D" + + * Non-default CTRL_MON group: + "//=3D" + + * Child MON group of default CTRL_MON group: + "//=3D" + + * Child MON group of non-default CTRL_MON group: + "//=3D" + + Flags can be one of the following: + :: + + t MBM total event is enabled. + l MBM local event is enabled. + tl Both total and local MBM events are enabled. + _ None of the MBM events are enabled. + + Examples: + :: + + # mkdir /sys/fs/resctrl/mon_groups/child_default_mon_grp + # mkdir /sys/fs/resctrl/non_default_ctrl_mon_grp + # mkdir /sys/fs/resctrl/non_default_ctrl_mon_grp/mon_groups/child_non_de= fault_mon_grp + + # cat /sys/fs/resctrl/info/L3_MON/mbm_control + non_default_ctrl_mon_grp//0=3Dtl;1=3Dtl; + non_default_ctrl_mon_grp/child_non_default_mon_grp/0=3Dtl;1=3Dtl; + //0=3Dtl;1=3Dtl; + /child_default_mon_grp/0=3Dtl;1=3Dtl; + + There are four resctrl groups. All the groups have total and local MBM e= vents + enabled on domain 0 and 1. + + "max_threshold_occupancy": Read/write file provides the largest value (in bytes) at which a previously used LLC_occupancy diff --git a/arch/x86/kernel/cpu/resctrl/monitor.c b/arch/x86/kernel/cpu/re= sctrl/monitor.c index 2f4d0c12b80d..87537abedb01 100644 --- a/arch/x86/kernel/cpu/resctrl/monitor.c +++ b/arch/x86/kernel/cpu/resctrl/monitor.c @@ -1244,6 +1244,7 @@ int __init rdt_get_mon_l3_config(struct rdt_resource = *r) r->mon.num_mbm_cntrs =3D 64; =20 resctrl_file_fflags_init("num_mbm_cntrs", RFTYPE_MON_INFO); + resctrl_file_fflags_init("mbm_control", RFTYPE_MON_INFO); } } =20 diff --git a/arch/x86/kernel/cpu/resctrl/rdtgroup.c b/arch/x86/kernel/cpu/r= esctrl/rdtgroup.c index d15fd1bde5f4..d7aadca5e4ab 100644 --- a/arch/x86/kernel/cpu/resctrl/rdtgroup.c +++ b/arch/x86/kernel/cpu/resctrl/rdtgroup.c @@ -965,6 +965,75 @@ static int rdtgroup_num_mbm_cntrs_show(struct kernfs_o= pen_file *of, return 0; } =20 +static char *rdtgroup_mon_state_to_str(struct rdtgroup *rdtgrp, + struct rdt_mon_domain *d, char *str) +{ + char *tmp =3D str; + int index; + + /* + * Query the monitor state for the domain. + * Index 0 for evtid =3D=3D QOS_L3_MBM_TOTAL_EVENT_ID + * Index 1 for evtid =3D=3D QOS_L3_MBM_LOCAL_EVENT_ID + */ + index =3D mon_event_config_index_get(QOS_L3_MBM_TOTAL_EVENT_ID); + if (rdtgrp->mon.cntr_id[index] !=3D MON_CNTR_UNSET && + test_bit(rdtgrp->mon.cntr_id[index], d->mbm_cntr_map)) + *tmp++ =3D 't'; + + index =3D mon_event_config_index_get(QOS_L3_MBM_LOCAL_EVENT_ID); + if (rdtgrp->mon.cntr_id[index] !=3D MON_CNTR_UNSET && + test_bit(rdtgrp->mon.cntr_id[index], d->mbm_cntr_map)) + *tmp++ =3D 'l'; + + if (tmp =3D=3D str) + *tmp++ =3D '_'; + + *tmp =3D '\0'; + return str; +} + +static int rdtgroup_mbm_control_show(struct kernfs_open_file *of, + struct seq_file *s, void *v) +{ + struct rdt_resource *r =3D of->kn->parent->priv; + struct rdt_hw_resource *hw_res =3D resctrl_to_arch_res(r); + struct rdt_mon_domain *dom; + struct rdtgroup *rdtg; + char str[10]; + + if (!hw_res->mbm_cntr_assign_enabled) { + rdt_last_cmd_puts("ABMC feature is not enabled\n"); + return -EINVAL; + } + + mutex_lock(&rdtgroup_mutex); + + list_for_each_entry(rdtg, &rdt_all_groups, rdtgroup_list) { + struct rdtgroup *crg; + + seq_printf(s, "%s//", rdtg->kn->name); + + list_for_each_entry(dom, &r->mon_domains, hdr.list) + seq_printf(s, "%d=3D%s;", dom->hdr.id, + rdtgroup_mon_state_to_str(rdtg, dom, str)); + seq_putc(s, '\n'); + + list_for_each_entry(crg, &rdtg->mon.crdtgrp_list, + mon.crdtgrp_list) { + seq_printf(s, "%s/%s/", rdtg->kn->name, crg->kn->name); + + list_for_each_entry(dom, &r->mon_domains, hdr.list) + seq_printf(s, "%d=3D%s;", dom->hdr.id, + rdtgroup_mon_state_to_str(crg, dom, str)); + seq_putc(s, '\n'); + } + } + + mutex_unlock(&rdtgroup_mutex); + return 0; +} + #ifdef CONFIG_PROC_CPU_RESCTRL =20 /* @@ -2206,6 +2275,12 @@ static struct rftype res_common_files[] =3D { .kf_ops =3D &rdtgroup_kf_single_ops, .seq_show =3D rdtgroup_num_mbm_cntrs_show, }, + { + .name =3D "mbm_control", + .mode =3D 0444, + .kf_ops =3D &rdtgroup_kf_single_ops, + .seq_show =3D rdtgroup_mbm_control_show, + }, { .name =3D "cpus_list", .mode =3D 0644, --=20 2.34.1 From nobody Sat Feb 7 21:19:49 2026 Received: from NAM12-DM6-obe.outbound.protection.outlook.com (mail-dm6nam12on2075.outbound.protection.outlook.com [40.107.243.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 B594E173357; Tue, 6 Aug 2024 22:03:59 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.243.75 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1722981842; cv=fail; b=YbVnTtcCkEdlRIJrJTt35QHjc8aLNHhfYQyxmKBV13tLcRqsTnw4lPShwWiFV3slsXyhdqVqVv5GDXbwDnZH5WucMGUNRZkAI+YjIBU7VVCrc9cFkLUlMlre+LdmfChIs5IXpuaECoO8Kazs1nILYQuhRU/oAQk0PuR4fP6SXXg= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1722981842; c=relaxed/simple; bh=pukYNKCGZFaLeqFG/SNUDLDi9GGve9KZ5+48EQwT0qM=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=Eg21DFFQ0FtVW53aKmPPiIKPSbbLhTC8skxB6aw3lWX/B5qPZfX7MPeGKzVspCWnQkRlLqta8/4z+jvZwKaaz+5afOHZbZAIko3xbpx3VIIYZQsLdfmD5cnO9IZHeV58v1yimJM7f4OE5MxuBlICZSZR/a4+Rend4Fimi+xV3b0= 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=RZzlqQ1v; arc=fail smtp.client-ip=40.107.243.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="RZzlqQ1v" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=GoapMqk5Chz0Vg9il2FEd5cZP++Zpv5xJI/7Tvc9LT3AB/bPtVhXBDyNJSeDP0DXIbnPfKoY2O7laCcjw3bMLlzYTP2+lIpgjxaKQXCNBobweMjZABP9C6ctDXsarq//oejD9X08GxJgqPk6RPLNs+KeAQanWX78M8xhcO2zXbRAztib4fnFqQeV3LjK9P2t56N+6oFOu76m5AibGKOAsMkDRia+4HMc0SlNZHx/gd+SFBIA1TwSPkii9EiEBvjhLdE2+8m5CWcwstRM70U7yJSprfOnUxOPPbQlVfaXloMQDQJtb2DlBf59n7pVOLXBIdhCT6PStZaD4j/O4WJ+pA== 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=LhPTqwvH8C2aCDoj33RCAClXdHGAvH2asU50hzRb118=; b=sVagc4JOD1G2d34Nhy6hdULbdif7BdxRFOa0SAvF4HMRywwlY6RTyfGe9NbrPo50f022DziVL6pxpxlkMKmFvYo5BxsV4bezbB+fv6F4QUb+NfXKzc4kx0oAwBnU3i2ya2XQ8qjrm9tcxbiiceaIVA4Y8SpGGt4WpKhpc4odvjj1bABD51ZP7PlEZ+kevnuJl0XqOqhl7jmQWq1v6w7+FkQrnHPVyDeQaXAfqsnGIYVpUa20PDskx6L5lYBjnFCVoori5yMKZxMtfxbRh9R9l/a0mRm5BUqh5CEF8ZaLzSompcxgwabPqSODQnRGEss7CQ9X87++f3DS6zfVIft2ZQ== 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=LhPTqwvH8C2aCDoj33RCAClXdHGAvH2asU50hzRb118=; b=RZzlqQ1vWaa1sDJl2dlp195WPy3tDxaLnK9PDilVLkjUd2uwkk7d/P0MChdlbhjVTtPufRQS4kzV1zzSJagzqQ0CM5oMe0QamzAzTduD8eytDyHhFTh/hMHsVqF9UfglhwREvFOo35TmK+pdF2oYwxvamg74MrY2OSIeqIKRdIo= Received: from DM6PR10CA0034.namprd10.prod.outlook.com (2603:10b6:5:60::47) by PH0PR12MB7471.namprd12.prod.outlook.com (2603:10b6:510:1e9::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7828.22; Tue, 6 Aug 2024 22:03:54 +0000 Received: from CY4PEPF0000FCC3.namprd03.prod.outlook.com (2603:10b6:5:60:cafe::d9) by DM6PR10CA0034.outlook.office365.com (2603:10b6:5:60::47) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7828.29 via Frontend Transport; Tue, 6 Aug 2024 22:03:54 +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 CY4PEPF0000FCC3.mail.protection.outlook.com (10.167.242.105) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.7828.19 via Frontend Transport; Tue, 6 Aug 2024 22:03:54 +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; Tue, 6 Aug 2024 17:03:52 -0500 From: Babu Moger To: , , , , , , CC: , , , , , , , , , , , , , , , , , , , , , , , , , , , , Subject: [PATCH v6 22/22] x86/resctrl: Introduce interface to modify assignment states of the groups Date: Tue, 6 Aug 2024 17:00:59 -0500 Message-ID: <30a946c5ec042e66db675e9e57fe2cff971f570e.1722981659.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: CY4PEPF0000FCC3:EE_|PH0PR12MB7471:EE_ X-MS-Office365-Filtering-Correlation-Id: 28bdc730-904b-4393-51c9-08dcb663a97c X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|7416014|1800799024|376014|82310400026|36860700013; X-Microsoft-Antispam-Message-Info: =?us-ascii?Q?D8IFgkquDVB4AJVY+PiphssmrT79ob4vxTZUP0asGhcbLceqjoz7LNa3KOO8?= =?us-ascii?Q?TzVYhmIMOk3IdGakdsxMmnqlDte5tcTZ5VgRYizvbTAMNjPHmYQWvS8K1n6R?= =?us-ascii?Q?JfX5/232LE7XeAAvMV9FgBmpTlLUxMT3MrXo/iANMq7nuXI769jF0qIKR5A8?= =?us-ascii?Q?2lOSWAI9/qV4tTOeshgvJ246Gnt98QglUI9RA6KyKmc0hi1+04854QvLVpy4?= =?us-ascii?Q?tju70du6ad5ssEewDJ7vMZlQ3rfA0cpnBHM7kHEPR+Jw+gmXpmwFi9rKOuik?= =?us-ascii?Q?ymogThrhxjuLJsTZPEmZB+Q3/ie4D+rz5guBA+24ApqUA6TO+9TjYWB/Z40J?= =?us-ascii?Q?e/xJML2sPNHCUK9igpERBtg+CWH3AgQOs9zXvNBl7rZx7kN//gUTD3tfoqsb?= =?us-ascii?Q?ktCjMfPDRvEgG7wv2OexnaxLELJxGBFfenhb51I4zyR2SxYE4tOpI5DLuX3Q?= =?us-ascii?Q?gyCxHoFV6VKWKjw31WzAqohTxcnwo85f5rPOtCijsdTWc8jqoikMOQr0Rlqm?= =?us-ascii?Q?v+xLDdXxdrgqXzWtHnEufOnmeqDW5bxvhyHYbgqCB8RXxBKj3UAS63WaNpqk?= =?us-ascii?Q?1+7wNRQZrC6ctjyYr5PyEPk9hKp6yuahURj8AXLal2K9ZjJkkcSB16YI+Vyh?= =?us-ascii?Q?LUdZs1T1BL3vOe/gbQfxucyrM+e18mJhqLu+3Avu6VEt5toxkZW3uJcy71sl?= =?us-ascii?Q?L2AXqBM/8KF7iEHUCe62ArDxztcOmMJWlNErijqa9Q2SeftOb7jC3DaMzanL?= =?us-ascii?Q?8LykgXzLoibZAjasLa1xeA7nVOga2p33SuJ7fmdgozGTzCL2vRdU5puuJrhi?= =?us-ascii?Q?80Y6H43IS/mJn3BYjHLVU9Ju6snv9cwdqc5SWUaU5Bw3p5GryJ3iRPp+209i?= =?us-ascii?Q?qOf7v5L0bjeS8PIpuOH/FZwP887YATcMrUstCzZabkKZq3iciRSxznQ6ZbHA?= =?us-ascii?Q?AmQJH11jwhWJbhRnkGH8ivRVDURAkjFsbLDpahoJKaUMLQvUhYy3woxittc1?= =?us-ascii?Q?oWt1M6ZlkzSW9wmiHkPglzgAPWDatxU++wu84NOoDV9x+PJTPIUNPOTPLWlJ?= =?us-ascii?Q?U/e0cUrfYNKsW3zpzzQH9sU7VPC8tuGO65XqjGCsfBz3qCFRcWwWz3W6dzya?= =?us-ascii?Q?Vt6hFJkqSiwTF8VbJHl3aKVcjS+zr0hhFbOvW1JjEbGjf/PX+bLFysvwkzc0?= =?us-ascii?Q?x+o5UnGsHZZtXP4L1FF1B7MQRVxSX1PsTlJdxh4mehhvuIqUsP9dfwYlIG7H?= =?us-ascii?Q?HctIR8il6xJqNXN3FAZF3qi+XZALCfP+BUvj7D0Fi19RXk3Z/mlH//mZveNG?= =?us-ascii?Q?2lgNwYbmAjjr17CsTm8kruVUFdaHNtQ7RMpTgTJJSJ56obWjUusmwTfUNsSy?= =?us-ascii?Q?Qz8w4oGh9eGBfVj+6s9flY3xF2Gn5aaOeTzuNSPu22CZh52WPQ=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)(7416014)(1800799024)(376014)(82310400026)(36860700013);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 06 Aug 2024 22:03:54.0032 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 28bdc730-904b-4393-51c9-08dcb663a97c 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: CY4PEPF0000FCC3.namprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH0PR12MB7471 Content-Type: text/plain; charset="utf-8" Introduce the interface to assign MBM events in ABMC mode. Events can be enabled or disabled by writing to file /sys/fs/resctrl/info/L3_MON/mbm_control Format is similar to the list format with addition of opcode for the assignment operation. "//" Format for specific type of groups: * Default CTRL_MON group: "//" * Non-default CTRL_MON group: "//" * Child MON group of default CTRL_MON group: "//" * Child MON group of non-default CTRL_MON group: "//" Domain_id '*' will apply the flags on all the domains. Opcode can be one of the following: =3D Update the assignment to match the flags + assign a MBM event - unassign a MBM event Assignment flags can be one of the following: t MBM total event l MBM local event tl Both total and local MBM events _ None of the MBM events. Valid only with '=3D' opcode. Signed-off-by: Babu Moger --- v6: Added support assign all if domain id is '*' Fixed the allocation of counter id if it not assigned already. v5: Interface name changed from mbm_assign_control to mbm_control. Fixed opcode and flags combination. '=3D_" is valid. "-_" amd "+_" is not valid. Minor message update. Renamed the function with prefix - rdtgroup_. Corrected few documentation mistakes. Rebase related changes after SNC support. v4: Added domain specific assignments. Fixed the opcode parsing. v3: New patch. Addresses the feedback to provide the global assignment interface. https://lore.kernel.org/lkml/c73f444b-83a1-4e9a-95d3-54c5165ee782@intel= .com/ --- Documentation/arch/x86/resctrl.rst | 94 +++++++- arch/x86/kernel/cpu/resctrl/internal.h | 7 + arch/x86/kernel/cpu/resctrl/rdtgroup.c | 315 ++++++++++++++++++++++++- 3 files changed, 414 insertions(+), 2 deletions(-) diff --git a/Documentation/arch/x86/resctrl.rst b/Documentation/arch/x86/re= sctrl.rst index 113c22ba6db3..ae3b17b7cefe 100644 --- a/Documentation/arch/x86/resctrl.rst +++ b/Documentation/arch/x86/resctrl.rst @@ -346,7 +346,7 @@ with the following files: t MBM total event is enabled. l MBM local event is enabled. tl Both total and local MBM events are enabled. - _ None of the MBM events are enabled. + _ None of the MBM events are enabled. Only works with opcode '=3D' for = write. =20 Examples: :: @@ -365,6 +365,98 @@ with the following files: enabled on domain 0 and 1. =20 =20 + Assignment state can be updated by writing to the interface. + + Format is similar to the list format with addition of opcode for the + assignment operation. + + "//" + + Format for each type of groups: + + * Default CTRL_MON group: + "//" + + * Non-default CTRL_MON group: + "//" + + * Child MON group of default CTRL_MON group: + "//" + + * Child MON group of non-default CTRL_MON group: + "//" + + Domain_id '*' wil apply the flags on all the domains. + + Opcode can be one of the following: + :: + + =3D Update the assignment to match the MBM event. + + Assign a MBM event. + - Unassign a MBM event. + + Examples: + :: + + Initial group status: + # cat /sys/fs/resctrl/info/L3_MON/mbm_control + non_default_ctrl_mon_grp//0=3Dtl;1=3Dtl; + non_default_ctrl_mon_grp/child_non_default_mon_grp/0=3Dtl;1=3Dtl; + //0=3Dtl;1=3Dtl; + /child_default_mon_grp/0=3Dtl;1=3Dtl; + + To update the default group to assign only total MBM event on domain 0: + # echo "//0=3Dt" > /sys/fs/resctrl/info/L3_MON/mbm_control + + Assignment status after the update: + # cat /sys/fs/resctrl/info/L3_MON/mbm_control + non_default_ctrl_mon_grp//0=3Dtl;1=3Dtl; + non_default_ctrl_mon_grp/child_non_default_mon_grp/0=3Dtl;1=3Dtl; + //0=3Dt;1=3Dtl; + /child_default_mon_grp/0=3Dtl;1=3Dtl; + + To update the MON group child_default_mon_grp to remove total MBM event= on domain 1: + # echo "/child_default_mon_grp/1-t" > /sys/fs/resctrl/info/L3_MON/mbm_c= ontrol + + Assignment status after the update: + $ cat /sys/fs/resctrl/info/L3_MON/mbm_control + non_default_ctrl_mon_grp//0=3Dtl;1=3Dtl; + non_default_ctrl_mon_grp/child_non_default_mon_grp/0=3Dtl;1=3Dtl; + //0=3Dt;1=3Dtl; + /child_default_mon_grp/0=3Dtl;1=3Dl; + + To update the MON group non_default_ctrl_mon_grp/child_non_default_mon_= grp to + unassign both local and total MBM events on domain 1: + # echo "non_default_ctrl_mon_grp/child_non_default_mon_grp/1=3D_" > + /sys/fs/resctrl/info/L3_MON/mbm_control + + Assignment status after the update: + non_default_ctrl_mon_grp//0=3Dtl;1=3Dtl; + non_default_ctrl_mon_grp/child_non_default_mon_grp/0=3Dtl;1=3D_; + //0=3Dt;1=3Dtl; + /child_default_mon_grp/0=3Dtl;1=3Dl; + + To update the default group to add a local MBM event domain 0. + # echo "//0+l" > /sys/fs/resctrl/info/L3_MON/mbm_control + + Assignment status after the update: + # cat /sys/fs/resctrl/info/L3_MON/mbm_control + non_default_ctrl_mon_grp//0=3Dtl;1=3Dtl; + non_default_ctrl_mon_grp/child_non_default_mon_grp/0=3Dtl;1=3D_; + //0=3Dtl;1=3Dtl; + /child_default_mon_grp/0=3Dtl;1=3Dl; + + To update the non default CTRL_MON group non_default_ctrl_mon_grp to un= assign all + the MBM events on all the domains. + # echo "non_default_ctrl_mon_grp//*=3D_" > /sys/fs/resctrl/info/L3_MON/= mbm_control + + Assignment status after the update: + #cat /sys/fs/resctrl/info/L3_MON/mbm_control + non_default_ctrl_mon_grp//0=3D_;1=3D_; + non_default_ctrl_mon_grp/child_non_default_mon_grp/0=3Dtl;1=3D_; + //0=3Dtl;1=3Dtl; + /child_default_mon_grp/0=3Dtl;1=3Dl; + "max_threshold_occupancy": Read/write file provides the largest value (in bytes) at which a previously used LLC_occupancy diff --git a/arch/x86/kernel/cpu/resctrl/internal.h b/arch/x86/kernel/cpu/r= esctrl/internal.h index ba3012f8f940..5af225b4a497 100644 --- a/arch/x86/kernel/cpu/resctrl/internal.h +++ b/arch/x86/kernel/cpu/resctrl/internal.h @@ -46,6 +46,13 @@ =20 #define MON_CNTR_UNSET U32_MAX =20 +/* + * Assignment flags for ABMC feature + */ +#define ASSIGN_NONE 0 +#define ASSIGN_TOTAL BIT(QOS_L3_MBM_TOTAL_EVENT_ID) +#define ASSIGN_LOCAL BIT(QOS_L3_MBM_LOCAL_EVENT_ID) + /** * cpumask_any_housekeeping() - Choose any CPU in @mask, preferring those = that * aren't marked nohz_full diff --git a/arch/x86/kernel/cpu/resctrl/rdtgroup.c b/arch/x86/kernel/cpu/r= esctrl/rdtgroup.c index d7aadca5e4ab..8567fb3a6274 100644 --- a/arch/x86/kernel/cpu/resctrl/rdtgroup.c +++ b/arch/x86/kernel/cpu/resctrl/rdtgroup.c @@ -1034,6 +1034,318 @@ static int rdtgroup_mbm_control_show(struct kernfs_= open_file *of, return 0; } =20 +/* + * Update the assign states for the domain. + * + * If this is a new assignment for the group then allocate a counter and u= pdate + * the assignment else just update the assign state + */ +static int rdtgroup_assign_update(struct rdtgroup *rdtgrp, enum resctrl_ev= ent_id evtid, + struct rdt_mon_domain *d) +{ + int ret, index; + + index =3D mon_event_config_index_get(evtid); + if (index =3D=3D INVALID_CONFIG_INDEX) + return -EINVAL; + + if (rdtgrp->mon.cntr_id[index] =3D=3D MON_CNTR_UNSET) { + ret =3D rdtgroup_alloc_cntr(rdtgrp, index); + if (ret < 0) + goto out_done; + } + + /* Update the state on all domains if d =3D=3D NULL */ + if (d =3D=3D NULL) { + ret =3D rdtgroup_assign_cntr(rdtgrp, evtid); + } else { + ret =3D resctrl_arch_assign_cntr(d, evtid, rdtgrp->mon.rmid, + rdtgrp->mon.cntr_id[index], + rdtgrp->closid, 1); + if (!ret) + set_bit(rdtgrp->mon.cntr_id[index], d->mbm_cntr_map); + } + +out_done: + return ret; +} + +/* + * Update the unassign state for the domain. + * + * Free the counter if it is unassigned on all the domains else just + * update the unassign state + */ +static int rdtgroup_unassign_update(struct rdtgroup *rdtgrp, enum resctrl_= event_id evtid, + struct rdt_mon_domain *d) +{ + struct rdt_resource *r =3D &rdt_resources_all[RDT_RESOURCE_L3].r_resctrl; + int ret =3D 0, index; + + index =3D mon_event_config_index_get(evtid); + if (index =3D=3D INVALID_CONFIG_INDEX) + return -EINVAL; + + if (rdtgrp->mon.cntr_id[index] =3D=3D MON_CNTR_UNSET) + goto out_done; + + if (d =3D=3D NULL) { + ret =3D rdtgroup_unassign_cntr(rdtgrp, evtid); + } else { + ret =3D resctrl_arch_assign_cntr(d, evtid, rdtgrp->mon.rmid, + rdtgrp->mon.cntr_id[index], + rdtgrp->closid, 0); + if (!ret) { + clear_bit(rdtgrp->mon.cntr_id[index], d->mbm_cntr_map); + rdtgroup_free_cntr(r, rdtgrp, index); + } + } + +out_done: + return ret; +} + +static int rdtgroup_str_to_mon_state(char *flag) +{ + int i, mon_state =3D 0; + + for (i =3D 0; i < strlen(flag); i++) { + switch (*(flag + i)) { + case 't': + mon_state |=3D ASSIGN_TOTAL; + break; + case 'l': + mon_state |=3D ASSIGN_LOCAL; + break; + case '_': + mon_state =3D ASSIGN_NONE; + break; + default: + break; + } + } + + return mon_state; +} + +static struct rdtgroup *rdtgroup_find_grp(enum rdt_group_type rtype, char = *p_grp, char *c_grp) +{ + struct rdtgroup *rdtg, *crg; + + if (rtype =3D=3D RDTCTRL_GROUP && *p_grp =3D=3D '\0') { + return &rdtgroup_default; + } else if (rtype =3D=3D RDTCTRL_GROUP) { + list_for_each_entry(rdtg, &rdt_all_groups, rdtgroup_list) + if (!strcmp(p_grp, rdtg->kn->name)) + return rdtg; + } else if (rtype =3D=3D RDTMON_GROUP) { + list_for_each_entry(rdtg, &rdt_all_groups, rdtgroup_list) { + if (!strcmp(p_grp, rdtg->kn->name)) { + list_for_each_entry(crg, &rdtg->mon.crdtgrp_list, + mon.crdtgrp_list) { + if (!strcmp(c_grp, crg->kn->name)) + return crg; + } + } + } + } + + return NULL; +} + +static int rdtgroup_process_flags(struct rdt_resource *r, + enum rdt_group_type rtype, + char *p_grp, char *c_grp, char *tok) +{ + int op, mon_state, assign_state, unassign_state; + char *dom_str, *id_str, *op_str; + struct rdt_mon_domain *d; + struct rdtgroup *rdtgrp; + unsigned long dom_id; + int ret, found =3D 0; + + rdtgrp =3D rdtgroup_find_grp(rtype, p_grp, c_grp); + + if (!rdtgrp) { + rdt_last_cmd_puts("Not a valid resctrl group\n"); + return -EINVAL; + } + +next: + if (!tok || tok[0] =3D=3D '\0') + return 0; + + /* Start processing the strings for each domain */ + dom_str =3D strim(strsep(&tok, ";")); + + op_str =3D strpbrk(dom_str, "=3D+-"); + + if (op_str) { + op =3D *op_str; + } else { + rdt_last_cmd_puts("Missing operation =3D, +, -, _ character\n"); + return -EINVAL; + } + + 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 */ + list_for_each_entry(d, &r->mon_domains, hdr.list) { + if (d->hdr.id =3D=3D dom_id) { + found =3D 1; + break; + } + } + + if (!found) { + rdt_last_cmd_printf("Invalid domain id %ld\n", dom_id); + return -EINVAL; + } + +check_state: + mon_state =3D rdtgroup_str_to_mon_state(dom_str); + + assign_state =3D 0; + unassign_state =3D 0; + + switch (op) { + case '+': + if (mon_state =3D=3D ASSIGN_NONE) { + rdt_last_cmd_puts("Invalid assign opcode\n"); + goto out_fail; + } + assign_state =3D mon_state; + break; + case '-': + if (mon_state =3D=3D ASSIGN_NONE) { + rdt_last_cmd_puts("Invalid assign opcode\n"); + goto out_fail; + } + unassign_state =3D mon_state; + break; + case '=3D': + assign_state =3D mon_state; + unassign_state =3D (ASSIGN_TOTAL | ASSIGN_LOCAL) & ~assign_state; + break; + default: + break; + } + + if (assign_state & ASSIGN_TOTAL) { + ret =3D rdtgroup_assign_update(rdtgrp, QOS_L3_MBM_TOTAL_EVENT_ID, d); + if (ret) + goto out_fail; + } + + if (assign_state & ASSIGN_LOCAL) { + ret =3D rdtgroup_assign_update(rdtgrp, QOS_L3_MBM_LOCAL_EVENT_ID, d); + if (ret) + goto out_fail; + } + + if (unassign_state & ASSIGN_TOTAL) { + ret =3D rdtgroup_unassign_update(rdtgrp, QOS_L3_MBM_TOTAL_EVENT_ID, d); + if (ret) + goto out_fail; + } + + if (unassign_state & ASSIGN_LOCAL) { + ret =3D rdtgroup_unassign_update(rdtgrp, QOS_L3_MBM_LOCAL_EVENT_ID, d); + if (ret) + goto out_fail; + } + + goto next; + +out_fail: + + return -EINVAL; +} + +static ssize_t rdtgroup_mbm_control_write(struct kernfs_open_file *of, + char *buf, size_t nbytes, + loff_t off) +{ + struct rdt_resource *r =3D of->kn->parent->priv; + char *token, *cmon_grp, *mon_grp; + int ret; + + if (!resctrl_arch_get_abmc_enabled()) + return -EINVAL; + + /* 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(); + + while ((token =3D strsep(&buf, "\n")) !=3D NULL) { + if (strstr(token, "//")) { + /* + * The CTRL_MON group processing: + * default CTRL_MON group: "//" + * non-default CTRL_MON group: "//flags" + * The CTRL_MON group will be empty string if it is a + * default group. + */ + cmon_grp =3D strsep(&token, "//"); + + /* + * strsep returns empty string for contiguous delimiters. + * Make sure check for two consecutive delimiters and + * advance the token. + */ + mon_grp =3D strsep(&token, "//"); + if (*mon_grp !=3D '\0') { + rdt_last_cmd_printf("Invalid CTRL_MON group format %s\n", token); + ret =3D -EINVAL; + break; + } + + ret =3D rdtgroup_process_flags(r, RDTCTRL_GROUP, cmon_grp, mon_grp, tok= en); + if (ret) + break; + } else if (strstr(token, "/")) { + /* + * MON group processing: + * MON_GROUP inside default CTRL_MON group: "//" + * MON_GROUP within CTRL_MON group: "//" + */ + cmon_grp =3D strsep(&token, "/"); + + /* Extract the MON_GROUP. It cannot be empty string */ + mon_grp =3D strsep(&token, "/"); + if (*mon_grp =3D=3D '\0') { + rdt_last_cmd_printf("Invalid MON_GROUP format %s\n", token); + ret =3D -EINVAL; + break; + } + + ret =3D rdtgroup_process_flags(r, RDTMON_GROUP, cmon_grp, mon_grp, toke= n); + if (ret) + break; + } + } + + mutex_unlock(&rdtgroup_mutex); + cpus_read_unlock(); + + return ret ?: nbytes; +} + #ifdef CONFIG_PROC_CPU_RESCTRL =20 /* @@ -2277,9 +2589,10 @@ static struct rftype res_common_files[] =3D { }, { .name =3D "mbm_control", - .mode =3D 0444, + .mode =3D 0644, .kf_ops =3D &rdtgroup_kf_single_ops, .seq_show =3D rdtgroup_mbm_control_show, + .write =3D rdtgroup_mbm_control_write, }, { .name =3D "cpus_list", --=20 2.34.1