From nobody Sat Feb 7 21:14:46 2026 Received: from NAM10-DM6-obe.outbound.protection.outlook.com (mail-dm6nam10on2088.outbound.protection.outlook.com [40.107.93.88]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 97D02194ADC; Wed, 3 Jul 2024 21:48:58 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.93.88 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1720043340; cv=fail; b=XpLErwubj4EG13laxPkGMDiEgtELZFafonGqD+lzVy5E1BAoLg7Vg6zqyKnQBdDso0tAXkqp/7tdtu0iv+vexfvhkZQ0zRafn9ELOawpNsE9MK413y05UD89M10ibCGKDEVjG77aWKB4j0P7Op6sldmNVkLClgx1eLFF//ykYjw= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1720043340; c=relaxed/simple; bh=DW3JfpjkGmWr993HI3WaZTyQm3v4l/yNsfORZSzQjqM=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=orl+iLVIu7oZb8tBin4dIhl4+6RuprgjRoJ0AuCZWhUyIt8W4qUetGejA6EEtQ5i2cAId+cLz8QXqyxCYSIW55caj4XpqX6M+GY9preckpLG8PxSSJR5t0MYK8iNJ+8yRNv2OrVrFHaq3djd90QcfXd3sEM6N4wuHW9UAqg1fok= 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=kWTZwmv4; arc=fail smtp.client-ip=40.107.93.88 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=amd.com Authentication-Results: smtp.subspace.kernel.org; spf=fail smtp.mailfrom=amd.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=amd.com header.i=@amd.com header.b="kWTZwmv4" ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=WSJgJUkNU28DKJ/uBIh/nJE06vTWguxmHwbnzW+cyrkDQ9/HqbbvhnWe9Gvmqt2AMSGGSTK2Z3Ydgif6HLSo8N75jGRWAVCkRf6/pVlBhDkmeU/Lve7s0hSSCyhpQjsUmZV0KT0wXJl2Qwdlj22qHG8UBzul6IxmIyLt9vt0e6pZVHiPAPTgEjdoiuVVNWJM3+gjvDW1KUdOCypKuVqPfnH3vCPAkY+7hutn9KsxmJQiE3mKRav24gyq+gDTWv2/Wde998GiaCbUh/51Pv62IHKtApXtEqB2nVMY6BIvOAKXB5r+0+4CO58rd+Sfbq/2lk1OJ49H1uQMGWNEfYmHlQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; 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=LEa1cBR5TVudI351X7bacIH/aULKFbWylsK88rpLnls=; b=VBQx4pGcwi5jkbv0XBWaBj6r25jgO+jwyLN7J32zVAjQsICGd2xr7asOA6NNdTagBQccxsNmYcvEiVYwGvm/Djx4mVU33HXgP7cf4A2VHaboWWlvb2Swfqn74S936Q/gNGYPZvD6yOQlpUytdzeB+WV/9YCzydk4knTRHeXz8o0jUetU+orPy4xKe3ay9KPowPFtjMOz4UFd35/NYmqx1GlWmAa6ZjqPENnaVJ41gVNCafm6vqUnvCo7M5m85EAKX0xRhwabzSJeSO1xCE85XhQ2NnC9G+BSiuJkhFnKTEEAA0rIVpbLnzRAQJvhLZeA6/OU2E7g9mvqRUHWv/qC6Q== 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=LEa1cBR5TVudI351X7bacIH/aULKFbWylsK88rpLnls=; b=kWTZwmv4Vfw2k9jSE071jWKIucq3zjhFL0oys65UR4RnFk7jdd/UA+taYCaFkbOaOfE5P9zKtfyjdAo+XsWhZvRMvJl1XfaaXQmHPmtshl2JNl11X5rZxD1zRtF/R2WYEohjz9Q0Bl5XFFCEnjPYDdTYvkYst4e2WWWF7rUrW/w= Received: from DS0PR17CA0024.namprd17.prod.outlook.com (2603:10b6:8:191::29) by SN7PR12MB7225.namprd12.prod.outlook.com (2603:10b6:806:2a8::12) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7719.29; Wed, 3 Jul 2024 21:48:52 +0000 Received: from DS3PEPF000099E1.namprd04.prod.outlook.com (2603:10b6:8:191:cafe::e1) by DS0PR17CA0024.outlook.office365.com (2603:10b6:8:191::29) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7741.25 via Frontend Transport; Wed, 3 Jul 2024 21:48: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 DS3PEPF000099E1.mail.protection.outlook.com (10.167.17.196) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.7741.18 via Frontend Transport; Wed, 3 Jul 2024 21:48: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; Wed, 3 Jul 2024 16:48:50 -0500 From: Babu Moger To: , , , , , , CC: , , , , , , , , , , , , , , , , , , , , , , , , , , , , Subject: [PATCH v5 01/20] x86/cpufeatures: Add support for Assignable Bandwidth Monitoring Counters (ABMC) Date: Wed, 3 Jul 2024 16:48:12 -0500 Message-ID: <724d0234ca56d71f9d8d893806870181d027f556.1720043311.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: SATLEXMB03.amd.com (10.181.40.144) To SATLEXMB04.amd.com (10.181.40.145) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DS3PEPF000099E1:EE_|SN7PR12MB7225:EE_ X-MS-Office365-Filtering-Correlation-Id: f9c97f83-21be-41f2-0338-08dc9ba9ee26 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|1800799024|376014|7416014|82310400026|36860700013; X-Microsoft-Antispam-Message-Info: =?us-ascii?Q?bf0xIPc0fyiquF3qY9i3OoVPsqwllcZzdu/xJ3F5V49U56lLgP6FgBkbw0ZN?= =?us-ascii?Q?zqPkyJTsl5pZJ0C1kBErXb8Zf7dUOFqBxJKrq2NaMHC1Yg+lah7zTIpdlq+/?= =?us-ascii?Q?H1txewehAN5UJfZMjS7jlz5jlAJPw5IdD/uY3KpPJlccByOQOOq2rLV+GQis?= =?us-ascii?Q?sJP/r/YJia2N5Uy/hdSJ3t2AI6bem2s6UOIhxeLND/RkuRjMgX93z6ZYtD4p?= =?us-ascii?Q?uqSqaQhUpTiiez/Nt6DxF5inVG8IPUJqX2gfOg/pjaqaPRFC8gAzUIOt1ZZZ?= =?us-ascii?Q?Z5iiu7Svl/wnrtTKWdyUFwWYy7FdNXU8JVqPym/ASbh936DOA4P3SfPkYeMe?= =?us-ascii?Q?jMJrFA/+ByaEIJTmbo8m3ptJ09JxRQiitOF9RtbsOk4AIEq954sBxCkjza1h?= =?us-ascii?Q?tfK0QTDY3HgRHc5FISYwH0qmtwt+gr6kAZLhGNH2kHuwSfFKhEqIlrOcv/pJ?= =?us-ascii?Q?w2daD2voZ7nrEhNGKi6iP6P6SQJo9ceCY3qxGpscEuRVsMAZsrvELmvZqj/D?= =?us-ascii?Q?HuYkGjCM/187bRy6Q247ycC/BqegSOx9MdR17p7hB1cUjJ0urQcwXoDKoILe?= =?us-ascii?Q?tmuNulNNInj3L0M9RZlMymXRM5GXi0bbuFGJBb2ysF2iDjoa0clwWJrR54+t?= =?us-ascii?Q?+fkCVB3VngJQlM1P0Mmi9tU8aZJWIWwWQjwsV3eLIEiiSIYaGEBtsQHX3tad?= =?us-ascii?Q?v+9pTGInaTzd3GQuvLTvV916yVVH/AHV7zO2gu+Uzl5/FVQlfEVNelfK8eNC?= =?us-ascii?Q?HVmrY1VzNL7HkT0vbikZggKZ+klf6coNwuwqXpUCpdInUhKigkwo5e7PFzDL?= =?us-ascii?Q?K6uRAzHk/juAqiWw4Th604WmMIYqYIPYv580dFqtj+a+wtTvVUQNssuDl9Yr?= =?us-ascii?Q?SqlHlQMjwpOiZng5IW3uweBMAGE6IAUbp10CbX0Ri9Xw92+9NzHAeae3m/JF?= =?us-ascii?Q?rFqIbojk4/IMNtW6dbgYndE6DyWwxc8tNzogED1K9D0qB1lZX6NAMbiNEWZK?= =?us-ascii?Q?ruKdd2ukY/xUSfM2A7lwFvYWq5mR0mGPDKBUIfrre2YunsDbXYnDihjCHN7u?= =?us-ascii?Q?KqZsTMDBLF+xvFR2wz5X041zQQzlRJG2JVJY/PkkRRmfa99XbcQhSuYLi4dM?= =?us-ascii?Q?B+ithcO48xgzHXOw3onDQmnQikHq7B4zRnYpL4M7Gde4J8ffhJQJCxfzdRxR?= =?us-ascii?Q?wpcHjL9w9dLsQ7HwuXc7JLnzSK9hKm4oXWNxGRJ2YXuzGcg43jY4XwBPegnp?= =?us-ascii?Q?dTDNPheMBWyNYJTB3C7I4fdT3d+m8db1Fwl0+BmMfyDk6WptksiC3tFLq+Nk?= =?us-ascii?Q?ZfenWYYLv8rsDkM9pasA4ypAmvg/sUkn2hu600lWNyCljFgk287vm8Yoskdc?= =?us-ascii?Q?CLtKRtKBxfd9Y8fa0UtX9/QeH72b?= 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)(7416014)(82310400026)(36860700013);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 03 Jul 2024 21:48:52.5920 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: f9c97f83-21be-41f2-0338-08dc9ba9ee26 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: DS3PEPF000099E1.namprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: SN7PR12MB7225 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). Note: Checkpatch checks/warnings are ignored to maintain coding style. Link: https://bugzilla.kernel.org/show_bug.cgi?id=3D206537 Signed-off-by: Babu Moger Reviewed-by: Reinette Chatre --- 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 6007462e03d6..d7e1764cbab7 100644 --- a/arch/x86/include/asm/cpufeatures.h +++ b/arch/x86/include/asm/cpufeatures.h @@ -471,6 +471,7 @@ #define X86_FEATURE_BHI_CTRL (21*32+ 2) /* BHI_DIS_S HW control available= */ #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_ABMC (21*32+ 5) /* "" 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 af5aa2c754c2..411b18c962bb 100644 --- a/arch/x86/kernel/cpu/scattered.c +++ b/arch/x86/kernel/cpu/scattered.c @@ -48,6 +48,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:14:46 2026 Received: from NAM12-BN8-obe.outbound.protection.outlook.com (mail-bn8nam12on2086.outbound.protection.outlook.com [40.107.237.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 A7D3C194C85; Wed, 3 Jul 2024 21:49:03 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.237.86 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1720043345; cv=fail; b=ths1q7w5vBf1ZqW9kNiKFS+becowXmx+z60G5OPJu3p9/3N/MEu11lxPH5d+/UyvVzPJp98wWdPFx5DLZA+YtKB7jHzRxEmRCN/ndyr8c69AVTXpWZBB6fexJALk4BEH/FtNTbvMeTNJs8aGc/uzhlnUtOTEmSBV7pjQeg+ngoo= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1720043345; c=relaxed/simple; bh=tQT3kHBskIfSKApKtr7cn472lGe0F82osBAxmzozRGA=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=vE2iKSuTCGEtuZCgq6vEEmAA0TZJVxL1WzZ5MX8ixbqU+W7PiHVwfCC40RVazC/RZ6D7tu0xrkXiqw3R3JGtHhv3gvDVo0PJVX8+SHGMMQvsyNfFm5glwKiJuePn+Yb/qR+nxv4bRnHJT/Efbt0Lfi2Zju7cLULiluqGZ7iJqTo= 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=3W2XY/Lz; arc=fail smtp.client-ip=40.107.237.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="3W2XY/Lz" ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=VKujm/3DRS34JOUAAjSDfhunBY9qk+e8EFa2iK/NwLPmo3nfI731allixC5y7fGJL1YHjP9IavVr2hYLNKz7UJXqIxGmr43WucztOeOFbdpik9QY16Ro/h4DPJewqwClaYPcKg8UdA/aOkA8GM8EXzlXJEW8mM3yxSu0/7Opbasbh5HrKcOdGS1WRfHJdWf+tflddbI3wC6ecuwcFO089NbGQz+WcwD4+E8t7ov8AiHK5ArGf9DJNKi75WjuToyFY+XY16poIUWS7SkXWe3XvopSUZjHCm/WaAoh11kYugXb2QcmULADCfz1yt6X+P9q5mChMaGulWhl7q3xaHNgVw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; 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=0/0t8fyR0+cqEa6HDEEYAG0LzrJ5syOg97hqt/f/DKk=; b=mfr2jYOOJgzopsl6cXcttDQXmHoko2eEujRs4+nE5mNTCiB/H6HE2eZm4/+arN6/JfASPSluqXA7/SZB3Z/g+NUmjjmiwGq2eY5M+8GdXvi8aOBeAqfVCdbVLSz3+FQfOZL/VT4p88aQnrUDWJeRW4dhxswfWzRte5xDPZwd0jWVCZaqGQ242SosFPNe9n+eD36fGb0WeiPQkqwSo3UXZhMHuhL4b0FinCWp7GsdYJBp7xvDVFeeSCtaYXYjtaMG08UMYe98JjQB9vo9bLAnu5X1nxzVsp4JzokttgSA6M3ogvEsD8N8GiDeFLeegp8qe287fCIbDexR5iviY0+WMA== 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=0/0t8fyR0+cqEa6HDEEYAG0LzrJ5syOg97hqt/f/DKk=; b=3W2XY/LzDrngQ8Yqvo3TygLrq3kpW4k+MhBUxD8lFdVb+wUCmJzIvXMTNB/ryQ6h4iAvVn4Q5k/OniUxLmXnwp93OC+ADBkzoDRIZWO5xot/gBwi6mV7tpx7sddMD+y5PHv3O42CVbDuwnqlmzD6JDBFNwMSppgdF7r70SnZby8= Received: from CH0P221CA0020.NAMP221.PROD.OUTLOOK.COM (2603:10b6:610:11c::21) by DM6PR12MB4435.namprd12.prod.outlook.com (2603:10b6:5:2a6::23) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7719.39; Wed, 3 Jul 2024 21:49:00 +0000 Received: from DS3PEPF000099E0.namprd04.prod.outlook.com (2603:10b6:610:11c:cafe::1) by CH0P221CA0020.outlook.office365.com (2603:10b6:610:11c::21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7741.25 via Frontend Transport; Wed, 3 Jul 2024 21:49:00 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 165.204.84.17) smtp.mailfrom=amd.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=amd.com; Received-SPF: Pass (protection.outlook.com: domain of amd.com designates 165.204.84.17 as permitted sender) receiver=protection.outlook.com; client-ip=165.204.84.17; helo=SATLEXMB04.amd.com; pr=C Received: from SATLEXMB04.amd.com (165.204.84.17) by DS3PEPF000099E0.mail.protection.outlook.com (10.167.17.203) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.7741.18 via Frontend Transport; Wed, 3 Jul 2024 21:49:00 +0000 Received: from bmoger-ubuntu.amd.com (10.180.168.240) by SATLEXMB04.amd.com (10.181.40.145) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.39; Wed, 3 Jul 2024 16:48:58 -0500 From: Babu Moger To: , , , , , , CC: , , , , , , , , , , , , , , , , , , , , , , , , , , , , Subject: [PATCH v5 02/20] x86/resctrl: Add ABMC feature in the command line options Date: Wed, 3 Jul 2024 16:48:13 -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: SATLEXMB03.amd.com (10.181.40.144) To SATLEXMB04.amd.com (10.181.40.145) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DS3PEPF000099E0:EE_|DM6PR12MB4435:EE_ X-MS-Office365-Filtering-Correlation-Id: 4d720448-6461-4711-b87c-08dc9ba9f2ec X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|376014|7416014|36860700013|1800799024|82310400026; X-Microsoft-Antispam-Message-Info: =?us-ascii?Q?JlZMS8RvAcloW3baGz1eq3xlXeX2XdQRD+SoErZLSDd/hgL4C/dS+f3T+147?= =?us-ascii?Q?J0fR4QrCxGTDiPx4L1vfH/MT77EvROxcTllAFdj4EWQnT+eC5nXuIwveT5LP?= =?us-ascii?Q?sFxrG2lGNXPB9J8shP8DC9tw0I3ZrNTlMOLhRNKitq6cTdXEq1520DW0rSOz?= =?us-ascii?Q?8rOfJI1n/XU/iObrpChpZA2fSB2ooDr7VPyGyWRB/NBa79l/ECEnSyYB1feS?= =?us-ascii?Q?EH9EqIR0v2pkDTu2ATu6W8eP8UV+Uk1Nk8rkfLA5gTC4XllzU4Z5DvNxdvHy?= =?us-ascii?Q?q5fko846fKMvWEb+ylfyteTrDJvhDJmIEyBjYz8C5zo1ETauAFn4e+hZcnGe?= =?us-ascii?Q?0DSqDF3QDdQYbmCuaCUYN4ggoLmpDMMtuAQdkaz7QC4/BkL+9tO9IwII4Q0r?= =?us-ascii?Q?IVPlMYD7mqewrEJOGZY7Hpp/w+m8PU5sm9+u20VNJvRVI4yJlqjeWTs2cW70?= =?us-ascii?Q?TXbabGayQqoyk3mw7ii+hQgc+gi8ZeoY6yn5tYYUR1wMS9sdFr9WCXxLA/sP?= =?us-ascii?Q?l70SyYfwEX8wJLHFUnHdRuXp1EPK5OV1+3Z2AuXuV1rmkYGA1aNmaAWd18Gh?= =?us-ascii?Q?tI/uFHL/UO/u+746NPdNSKy+e3CEaPYAlcdPCQ16zer+IaHqZNF5HxHE07N1?= =?us-ascii?Q?suZCxQylmG0sKDhD+Uway/9juqppdy0+52iU+i+qwMxp3hiLThDRukwJGjRy?= =?us-ascii?Q?T5IwxUvvFA4Tjle2H4xZ8sCfpK+6ZNHOyAS/tO6Ag7SnXOzaFIKVnXpb3FBu?= =?us-ascii?Q?RFfLdBmoDRNlyystv8/ljXPkBdeJB3gHzN9gqq653fpMRVlSZJrNj32gzjxq?= =?us-ascii?Q?ab7oNDJ6Jc27oEBSymg0+varvMzoYi/FWk9otvizifD+eyZ63SWmPC78IYfn?= =?us-ascii?Q?b6UCYl4t2aqfM9dZCjpl132Sid8NhyB1+O4lD68F6xoZ0mqlGr4stvVUOX2C?= =?us-ascii?Q?bQsoDg43pb3HDiwlP+a68MNsIchjiXz1tL5eb294l3hlJIBjK2U/z7vqaIzy?= =?us-ascii?Q?Uu5n712irNMwJqEbuzs8+5uvbbH0qmKUNRIiOSRsrcQZYv9ACdq4ua6jzYjZ?= =?us-ascii?Q?k8o55kcceBUlvidvTOZAemEcPlsVBnR5pT4zyGhQq+V0I6oYUUG8Unk23GmX?= =?us-ascii?Q?sJ5vfxYVv52PWmNryHdzn6kiY+IUawrmCfGl8Ga2w6ajl8ik2vFyYnw9hvfi?= =?us-ascii?Q?JWwseNlT25HjrBYLOuBeqMYZmIMT7yhv/woQOF+mqKlihteFlE4fWoNlPYjj?= =?us-ascii?Q?dPWgX1FBrS0o+rqt/QoWMz8iNwc6N9t+nmEyfW6Vr+dibYLAgIo/GFlm4bAb?= =?us-ascii?Q?6wZuLuU0Qy208E9ahbwQ8m65op76gVLRD92QAL7+7fa2fFuRKqJmWmB+hVql?= =?us-ascii?Q?MfRjanLtWRQ6riAHYQURH3ZRzKSf/sINv8YxWkx8C5fnucRxOD0o6WiCsymj?= =?us-ascii?Q?1Bt2vPReWQuiQvxbYcGZsNbeXXBgETAw?= 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)(36860700013)(1800799024)(82310400026);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 03 Jul 2024 21:49:00.6208 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 4d720448-6461-4711-b87c-08dc9ba9f2ec 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: DS3PEPF000099E0.namprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM6PR12MB4435 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 --- 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 2d6eacea85bd..291d9c47f74d 100644 --- a/Documentation/admin-guide/kernel-parameters.txt +++ b/Documentation/admin-guide/kernel-parameters.txt @@ -5597,7 +5597,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:14:46 2026 Received: from NAM10-BN7-obe.outbound.protection.outlook.com (mail-bn7nam10on2057.outbound.protection.outlook.com [40.107.92.57]) (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 9E95B193097; Wed, 3 Jul 2024 21:49:14 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.92.57 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1720043356; cv=fail; b=L8arwcwRHuE0iwv5oY4jJs7V4tL0psPRT0S6u3BaDCS91PTf1EKEayEY+ZT2EtzhDjJ6T+nsVuLqKUCgJHBIv41Icg7PeFhqJHjDw0RL1VXV7N576RGN8DITQAGlF9PLfkv6feGrUeUb/UOjmchIrIsC2oJ48Xs6rl1IJcvBmMs= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1720043356; c=relaxed/simple; bh=1e4e6e629+lln4gti8bMtesL+csS2HGD/mb9aKmpC00=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=YoUaxzYLzd9rNyVR5vR+4SxQNpRjVanK7PzmX39JIu2uDpGAgwFpG4cX+zg63Sb6rFTooGLKnGsqQJpuXHUlqy2Qsg5tDLG4H75ml0PYNVF0cwGGw6ByiiY/slZboGdRsgpyrRB+uokTVtWwVtaeRmte9DA8bgGbfUdOowBHY8s= 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=0yuOQRf+; arc=fail smtp.client-ip=40.107.92.57 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="0yuOQRf+" ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=kN9aDebHpLQ9rvegI+BLFVCd/GdL82XA07Nw/s/+m/yWNJp+qfPcdhtjMtbfaSFXPkgjiAqN65RTqfvjYb+28h8U8HQHOBKPPiRhdgyKJW3HlbLg3/lZUvJb1Q25I9Y6oyW6KrQbu0UY0XYMR4nXneYH94pRtQB8gpaPPUv25twHCysLRL2gtPGdJkpRLty6ONJywnGmxFdJ3aqovghT1iuTwqBI8/m3Bmv7dS3ej8kdX5PZ1hpGKA4rL2kDhefuzQ39ZCg4HSYjgVFypyZ9v1Y/m9aBb/B5gjCl5NO+C/FNCxb/x0IDf8BlS0kPv4KZOGZoNXmbEUGOG8g8HyaI2g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; 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=9Zu64DXufjZim0l//kho2tnMMIMnDOOJom6l32u7RLU=; b=VfKyYxgBCMjbwkavVWJu7qVeEAr/ukTfRQNqqJqhLgKHWhbUpMLEbc8q/9ChGaWwenxAZEayN+U8mPFcfeRx8TmxriZwNJeLTd2CvwlodKZy7RyEG7/7xEVOYNwmvoNc7fbj3GOJTPrqehgQ0ECCT9jct/knDlERldx8VlVDWmtlmq7DWJv8hp0yPhMjXolHhHfIta89V/30Fhl+lW/dMIRg+RlZFiigRFjGUNTLC/0lk9ByqxFlTnQV0RihsNKXmm7WBxZzMyWld9dDNhFF0zMINdfIVVYLsZm+/hyvoeyrCnLlIuPLqpv8ODgWQnSZDabiHyR7TOvo3kt3s155dw== 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=9Zu64DXufjZim0l//kho2tnMMIMnDOOJom6l32u7RLU=; b=0yuOQRf+1/FyEueWAZh+GikAJhL6P+JT+ayZBfKr31dac+xkEfed7ukmlqePH5G/WhIKm6Tb9QuZfVJJGqNOLtntYn6pevlEv7Z95Y7zLwddGIQHxWOosdDzQvYgo+u/q4QE0SbkMoWJNBqJaVwEArkgZF6KK3FulxtZXLZJvX4= Received: from DS0PR17CA0016.namprd17.prod.outlook.com (2603:10b6:8:191::7) by PH7PR12MB7332.namprd12.prod.outlook.com (2603:10b6:510:20f::9) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7719.33; Wed, 3 Jul 2024 21:49:08 +0000 Received: from DS3PEPF000099E1.namprd04.prod.outlook.com (2603:10b6:8:191:cafe::54) by DS0PR17CA0016.outlook.office365.com (2603:10b6:8:191::7) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7741.25 via Frontend Transport; Wed, 3 Jul 2024 21:49: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 DS3PEPF000099E1.mail.protection.outlook.com (10.167.17.196) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.7741.18 via Frontend Transport; Wed, 3 Jul 2024 21:49: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; Wed, 3 Jul 2024 16:49:06 -0500 From: Babu Moger To: , , , , , , CC: , , , , , , , , , , , , , , , , , , , , , , , , , , , , Subject: [PATCH v5 03/20] x86/resctrl: Consolidate monitoring related data from rdt_resource Date: Wed, 3 Jul 2024 16:48:14 -0500 Message-ID: <29280097cecb6a4717d7e8a19249c9790684f67f.1720043311.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: SATLEXMB03.amd.com (10.181.40.144) To SATLEXMB04.amd.com (10.181.40.145) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DS3PEPF000099E1:EE_|PH7PR12MB7332:EE_ X-MS-Office365-Filtering-Correlation-Id: 0df71c2e-8bd1-4017-94d7-08dc9ba9f797 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|376014|82310400026|7416014|1800799024|36860700013; X-Microsoft-Antispam-Message-Info: =?us-ascii?Q?GQcsoEWm+g0tsRakJaYUSFn+4hGRYbFo9+Qc7kGwM7hA/pcOtr96Wa49om+O?= =?us-ascii?Q?aWvRIL6COrHCV+r5wnMDyZ/m0CMAGPm8OXeaHPaOTzMqzjgsB8HYXaSmPwUj?= =?us-ascii?Q?n0rcQcXJlbuiDa8naeLAiliegfkVPYcBnjzJfrxCYGlaMXJUMDCBNPirQMy7?= =?us-ascii?Q?iLw9Pb9w8KMtqB2LdYzZFVaFKuvisgZ8BnRjqVzU2uJw9mFutilNo8P7we2o?= =?us-ascii?Q?DMMXiSHG6SapdGoa2ryer6SauMAescbBqC8/e+a62vBxMb9/+kS87QPJIN1v?= =?us-ascii?Q?K9LKKmgb++p7QrHjcS77iJbiEjDTzdkkGmqOdWwv5icZeUPow4ZNKYuOqxl7?= =?us-ascii?Q?afGLVuSHg/fnO4BT8Gu/ijAGNSzY3pIR4KrzoLuKoQzps6qTLe0TIxJ3Oy6l?= =?us-ascii?Q?GMdnKlgAUxOcXIzoYeD+4HO7rX/r8sgJbfNl7fHpgnVsNy9SVQE9MHgycgNG?= =?us-ascii?Q?CK7RNxlUrX8DSxP2erWAyW7C7gAl6dkbNQh0Mnfuaepj87hP31Z8L7LMkuof?= =?us-ascii?Q?wjzhQkBEeX7t3KwqjKlRfC5i4dkY5N66QRLZ1Z8YiAAaLmK5FZ9ZahAEuC3V?= =?us-ascii?Q?9yOioiWzSRcqMjK/EfJj5LOx/Vv8EPkHVQAE6R3wbsdRuRz9wLNHyZv4zHya?= =?us-ascii?Q?bGs0FUuUH/ccm0aZ7xtBqqo2w5JxtX42p4Ei1WuQ3DzA13UiNeCVR0ZaGyoY?= =?us-ascii?Q?9d+FGUsLC7MHcPukeBoo0n/vBtkzddFDDqSKpyA6J37fTmQGDNkKYqLIm13R?= =?us-ascii?Q?J/8jDRZBqn3EaTJtSNows4bGdbyaB3zVJt3sqyzN4F5AbRX4GqbEcpNPyP6B?= =?us-ascii?Q?F5sYkJl9juxUdNyL8StnCpXlDvqcoKXe2YI0Li2r8kVA8u/Sb6Hz+oPZ+Pt3?= =?us-ascii?Q?JSnWYdKJA9Uv4Yw3vk/TVA+Ff54J1U+R7Vu2TdPwEXM95Tv1pBk6SoVGGRlr?= =?us-ascii?Q?+P6Y4XIwdbUWO2m0wyCaUpoeTVp/SALuO0i4BkCcXyoU+flgEBH9qn8bA1oE?= =?us-ascii?Q?pPK2WacqqsuBH3Qt2BNUSL6sfYQAVP80KWqkEPDssFzalbsU0kASv20Bjlc6?= =?us-ascii?Q?dDK+SYgoZTH8Y71ihGWFv1XIKtAIMCM/UMitnHj7zxu52QuqtOjZs3QFnpBQ?= =?us-ascii?Q?k3F1Mug6ZZyEnseUsPhi4pGR1svKCpeHBfvSgb5AlVtD19dI4tLtHtzKoq5R?= =?us-ascii?Q?lvgxoT4dfeOEvV9hqiTIL45MGqcQwDaazuJNLEPIC/7Yp8wkAoXLvKvGuHXD?= =?us-ascii?Q?3Jz0hZm/jT1CI4ZdMbhqNZ/wnutl0U3h9FyVqA6xOV4TIuDXmeeAdXdFS1Wk?= =?us-ascii?Q?djB+fP2RNNNS1T0TN2jn5IaJRhCuY7zfeUcCSVyHL3ecM0IdW9G+NVG2VjwM?= =?us-ascii?Q?i/ughRkW5akfVqkX1UXOIoweyrHNM9Ro6jyCH9GO05doXdk4AHgayipGiHaQ?= =?us-ascii?Q?44uRCwr2+Rk05WrTgy24DeFPNVws5wVW?= 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)(82310400026)(7416014)(1800799024)(36860700013);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 03 Jul 2024 21:49:08.4514 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 0df71c2e-8bd1-4017-94d7-08dc9ba9f797 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: DS3PEPF000099E1.namprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH7PR12MB7332 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 into separate structure. Suggested-by: Reinette Chatre Signed-off-by: Babu Moger --- 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 | 13 +++++++++++-- 4 files changed, 25 insertions(+), 16 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..e43fc5bb5a3a 100644 --- a/include/linux/resctrl.h +++ b/include/linux/resctrl.h @@ -182,6 +182,16 @@ 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 @@ -207,11 +217,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 +231,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:14:46 2026 Received: from NAM10-BN7-obe.outbound.protection.outlook.com (mail-bn7nam10on2051.outbound.protection.outlook.com [40.107.92.51]) (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 5A6E0194A72; Wed, 3 Jul 2024 21:49:22 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.92.51 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1720043363; cv=fail; b=qWXNPxphYiOi25J91Za9awS+OcDL6Qxdv8SydEJhMRBsapoO5XJsjI1dD7L1T0xvUTU/tpTEoVJ76/4otUcxEjfMCqNo2MetFxlWvb0CoNoxfGaWufAjRl5HZcnPqg3Uenv6IvWJLzSbB13BMxib9jKY6AOFPeQhRAvM3vnXpaw= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1720043363; c=relaxed/simple; bh=v2T81gf12uokqE9TtCJwDCCKgNeFIMTR08x+NJY45eI=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=Uf8UgyEK7W5ooY15heU9hGo1IKUfsUJOuhz1b6QNi3M5WDTmBP+2u36gj4F9yq4EO3qYm3ia0qZp903P3He7cMJKUYwZWe1AYTNvqVU2ea9yV4x2j0V98eFflBXAGV/NneDMOsKrwYilgq2br272Ni+oO3eaUVF/wVX2xvUTWWs= 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=ptty/wQh; arc=fail smtp.client-ip=40.107.92.51 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="ptty/wQh" ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=AhE4Xma25lncIfJmNna1zXaZG6YlpmKFQfJvzNRSK6WJFm1H6Lya2pjIHP/PUHvouBHk78SwsNkKgPYvFKI41w7w+s5LCw8ibYSD+aldEqXwUOw220SVxPWQ473JzZKrXGEow0VqxiQYWBeSEzZCOVB9qFyVcnCoURIPgGFLZQM4NmqGpS8mb9/o7nuGxfjK85mWGVodSd7EsFX3Xr9SNK38PUzXjJQ1+OQ7YBPdiCBd01FRpQPescPgXF/FFcw81+FxfNuWDZpru3DqIbddjhLEItSVdNLCLoOPMd08xl8+OdMmIaCXhXWpn2rLwuot7tR8tsXZqR40M9ITMxnP5Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; 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=a3W5ZMUAY9rs8zbUUr8VDko1yjGJEUhyQBastIWdCtM=; b=ipqgJOslyvIbemoOpOkh0AQf34PN6JRpQLCzhueDtfd5H/bnNs8+dxXv+2ci1ZR2nOqVkx/YJzqzibcI9EKHUbXw93HTx8gZN8u/8BQL2A0AlIJ9/CuXS6Xu+NidfbO1DvMZJvUyzYAAlfVoK0x/JrgfbkKmnErHc/r/sYR0UFwX3Eaf3UGsR2xnkxRXvFeObI62IEk+4D3yCixCH8I1DyxTSKeRcQAvVA3ivthbgDY2158vIhHp1D9jAQl7fleyo5Bl0Zvu+tVWnI865PjeY5YIKGjBsUszaUR/4V6udS0bDowLz8oHDy6ojZJTwGClzUwUCpYrXJN1pPY//0shEQ== 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=a3W5ZMUAY9rs8zbUUr8VDko1yjGJEUhyQBastIWdCtM=; b=ptty/wQhmmfFpU6UbhS/TKY9xcsSoQpMJhNl6NjJpxgS6vzzWW5DtXG6P+QdktsykQPkEPgy9pPBFTfGnnsXzT//ZcifVy7AMOYM1mv4KR/mENrdVcqBMcFpAH1rHYPtoJ5U36ymBl8U7glTvXs/YOx39IcRIvwU9FJoxVpazHg= Received: from DM6PR06CA0053.namprd06.prod.outlook.com (2603:10b6:5:54::30) by SJ2PR12MB8941.namprd12.prod.outlook.com (2603:10b6:a03:542::15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7719.33; Wed, 3 Jul 2024 21:49:19 +0000 Received: from DS3PEPF000099DD.namprd04.prod.outlook.com (2603:10b6:5:54:cafe::e9) by DM6PR06CA0053.outlook.office365.com (2603:10b6:5:54::30) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7741.25 via Frontend Transport; Wed, 3 Jul 2024 21:49:16 +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 DS3PEPF000099DD.mail.protection.outlook.com (10.167.17.199) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.7741.18 via Frontend Transport; Wed, 3 Jul 2024 21:49:16 +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; Wed, 3 Jul 2024 16:49:14 -0500 From: Babu Moger To: , , , , , , CC: , , , , , , , , , , , , , , , , , , , , , , , , , , , , Subject: [PATCH v5 04/20] x86/resctrl: Detect Assignable Bandwidth Monitoring feature details Date: Wed, 3 Jul 2024 16:48:15 -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: SATLEXMB03.amd.com (10.181.40.144) To SATLEXMB04.amd.com (10.181.40.145) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DS3PEPF000099DD:EE_|SJ2PR12MB8941:EE_ X-MS-Office365-Filtering-Correlation-Id: 3447ca83-b542-48da-a064-08dc9ba9fc5c X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|36860700013|82310400026|7416014|376014|1800799024; X-Microsoft-Antispam-Message-Info: =?us-ascii?Q?SakYoNy7NMTavGeG+xqs+aeH2L0goqq2ygL7JnkKuB2K9VbkVeY1UUGzau1A?= =?us-ascii?Q?/inqX6lzVBMGIYAhK8II3HVIOwyhzFtlZvRukwrMG4CAgzMng6AP7+lfArbq?= =?us-ascii?Q?qwrZuXx8wyzD7fR/0Bh6XOBHmQVrqTohH1kelAJukG/2KnK8j9HgBZWkiZvF?= =?us-ascii?Q?C4JvS7jzxpktyJ30HoHNxICyAdiAoCecA/DPLr2PfSt2CcXzJ5aUq3epFSV5?= =?us-ascii?Q?QXvAGPyLAKaWFBehFC1EDgEcfU1bGGI68UwgDdc+6ANTa9FDhFgwp3uW297n?= =?us-ascii?Q?k3tEEAgvH2jKIrDFui+jl/nwevm8LV87L0ZJkLZByEb5iqK8DAXQuGh21guw?= =?us-ascii?Q?lGA6T8LbCw37cRIy6Mvy0eu6WNu+cg3NoEMOWfA5Czrnx9FwIl9g7G+nhqS6?= =?us-ascii?Q?fg3QQmtofeOBs1CvOdCW4Ol2u5uYPL81RtcI4/qFCEroIVUioYbMPtLVYuee?= =?us-ascii?Q?l9a4XCARTZX1Yc/RSJ8KeJCv9HVTOE/EopOpTGz80j6ec0e9ljtaTeTDaFaq?= =?us-ascii?Q?nC8AAxrNqtlbM2C6AdqoiElJV0UPoiBK7gjxTbS1yWY15srW3BrtrWMLRbTw?= =?us-ascii?Q?OZ0WHSvUFsogkbRXRPe3eVrLDEUsN+av2umjDqgpOoSIuIGSxpASkARJCF1x?= =?us-ascii?Q?tm6+H5rezkD7mRXWvq5ostScIkvbvCgJoR/7xPd+P5QjzWmGqhZiSomQVpWM?= =?us-ascii?Q?Tyys1kLDmQGcBm1Nq2OobHglupYlXVXuYBJt0B7vSPyu4LsTfMaGYHIhJfH6?= =?us-ascii?Q?+NyXB2gRaM+K16C6pcDjjkJH+fE85wR2b0PUptbrpWCqCqDRaEax6DWvdPQA?= =?us-ascii?Q?Z4pd+20HOGyqBV2ElZayUK3+EivDFISUreCGNPiv7S+kYfdcvQHJrZQUfoGi?= =?us-ascii?Q?qksgdNrTzpZu6v58j9v54URTtLoQoPGC/eccT4vQVfMQSjiyLoYxCDOG6C2r?= =?us-ascii?Q?aGM6knPVGmYKHDigoy/D3vPzTK2mdG8TXfk64pXJ5F+mE+NGlAXCG24sVP5G?= =?us-ascii?Q?d63o4wxmd3oVuiSIsuwWppoVtxRbYJjsZGVceEOBDdi2VPHVQ/rXPx0nqNN2?= =?us-ascii?Q?WWTCeyS7D1RVWotNoRiJk8LA1+4R4DR+yFdlRO5+Suqak8KptUyx8D/6Dymk?= =?us-ascii?Q?QQ6AuVZAKdGmK1ihAjPDSME6lprhD7nETS0Wkpxe8mlTZNifkn/K8NSS8swF?= =?us-ascii?Q?wam0akUFz1xQaIKvIrOpNxb9tOAZZAeJuv6O9VxRq8jrNzJTnVb0DMc4Rksy?= =?us-ascii?Q?uy+pRQZK15cE35usTGzDQj/jNq0vNZbI8rS4/lmt6FZN9bJmAESSNoWt9HJd?= =?us-ascii?Q?VAGWXZblNLm2/rRJi2tnYI3lQ1rYBgdwLthkdu6eL4374cMYTOZJLm8jTAIJ?= =?us-ascii?Q?ZyGLa//uL8zDT0t2LMCOZIDCAxAH?= 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)(7416014)(376014)(1800799024);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 03 Jul 2024 21:49:16.4381 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 3447ca83-b542-48da-a064-08dc9ba9fc5c 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: DS3PEPF000099DD.namprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: SJ2PR12MB8941 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). Link: https://bugzilla.kernel.org/show_bug.cgi?id=3D206537 Signed-off-by: Babu Moger --- 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..87d40f149ebc 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.abmc_capable =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 e43fc5bb5a3a..62f0f002ef41 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 + * @abmc_capable: Is system capable of supporting monitor assignment? * @evt_list: List of monitoring events */ struct resctrl_mon { int num_rmid; + int num_mbm_cntrs; + bool abmc_capable; struct list_head evt_list; }; =20 --=20 2.34.1 From nobody Sat Feb 7 21:14:46 2026 Received: from NAM10-BN7-obe.outbound.protection.outlook.com (mail-bn7nam10on2048.outbound.protection.outlook.com [40.107.92.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 A11D619644B; Wed, 3 Jul 2024 21:49:27 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.92.48 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1720043369; cv=fail; b=l5pt6NRCBWj3l+lQXBvftadVEcixPknYmBolkJ+ojiANtYR0AqoQOdnryQuERiwpZZwLErBM/dItBoCPu5g5KkNz+nJHM2FdA2apgIgTgKPyLXO7F0H3buZIZUdITt2OsmM0jgzBCWI3D6Zo3nyMtL/coudAOzbYTgo8Lj/WQrM= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1720043369; c=relaxed/simple; bh=cwScgK/RXyM3g8zbsHm0p18P/Tdju4CKKpgce08bhD4=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=tCEuDovMJoTuDbbE2tzQ2do+vWVAI6X3fKmMlYD17DrX3BGDNVGEbJ0u8BiVWI6cwlCnhMR2eLux6z2WkYX4cN3pGuYABFB/aRKiSALJDrVGdGPy0TemV5OHbxIT5keHycEJW1vCTcOoIZ4YqzlJKCkV345Y2Cg8PxLtPSlcJ1s= 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=BgHe4qKE; arc=fail smtp.client-ip=40.107.92.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="BgHe4qKE" ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=NENv9JO2erGN+wwBDrNzxFuNMoLpI7Hkjs2XNnd+nCq7cW2HDE/M+6yFLHoyYcjW5sajNHxKAcIvBZ0njOXQtzL/qndghaXXHlGKtYLk8q91gYLS7EVEIG61O7EJeuVux1oACEZu20Z6W2Hj4/h27RTrys7xmGtBxO97ZasQElXVkBz0q2PsV1bxmEzjlWKwAlLPRNRF+wqrwcs+/JydZ+jeTD2PrSrdfbCBY28na8L7BKwYLfqMBO/Uk9U/IrTLWgt8tyT0dxg4karyBI7T7voqN1fQxhaOwp8J+ZOnSPRgRIHJky3EaalK/U/LR4gsggE1P3gFEyDw5E+ccMkR6w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; 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=HqJ9HnsGW1kbvvrSfY/pBETCPk3G1zfLOdHQ5iqZHdo=; b=GP3voC6ZDEYrwWu24gaSWOSDO+cBdN2jCzumpwWHfV/WPJzMiJuamE/Q7F7w0MVTg7TsAGp1CedRFrl/K7+ig90Xc5EGmil/lyhyK8iEQ1aaOLjD5lXVCL56dUMVMVPzi5UTlHt6mqOA5q4mGz20RxNm9sjKRKmut1Qdt6pUH/T4N9q0MozErik9gVxtJzhmTVwnvGA1bzi4Pq4TwgwIMEN060p8mNygH+cheqrlVVFZn58IhU3v5p8ezWQmpw5patJYjtasO94/Jh6FxUv89m3FZsP0TQoNomjTfkCJoJ8k8X9ef3SPElg2fRgRFDX4SGi6DD1B7ppc7zG4MxaBYg== 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=HqJ9HnsGW1kbvvrSfY/pBETCPk3G1zfLOdHQ5iqZHdo=; b=BgHe4qKEq/GHcKqQukoTEBWf/pWBRPD9JZxt8wO1dqc86b1FBeGKeoMYMS5WDjvagznIk4TWpWEWl3SR1Aw9PqQYL9CNujtz3Q9j/pG5CNhTf2SRdw2vqRn+EUp8vZeI3X3c4jt/FEnIhDR4pl5gTVRUUHbb2+q8pb2P2a3dYj4= Received: from CH5P221CA0011.NAMP221.PROD.OUTLOOK.COM (2603:10b6:610:1f2::21) by BL1PR12MB5707.namprd12.prod.outlook.com (2603:10b6:208:386::10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7719.29; Wed, 3 Jul 2024 21:49:24 +0000 Received: from DS3PEPF000099DF.namprd04.prod.outlook.com (2603:10b6:610:1f2:cafe::5f) by CH5P221CA0011.outlook.office365.com (2603:10b6:610:1f2::21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7741.25 via Frontend Transport; Wed, 3 Jul 2024 21:49: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 DS3PEPF000099DF.mail.protection.outlook.com (10.167.17.202) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.7741.18 via Frontend Transport; Wed, 3 Jul 2024 21:49: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; Wed, 3 Jul 2024 16:49:22 -0500 From: Babu Moger To: , , , , , , CC: , , , , , , , , , , , , , , , , , , , , , , , , , , , , Subject: [PATCH v5 05/20] x86/resctrl: Introduce resctrl_file_fflags_init() to initialize fflags Date: Wed, 3 Jul 2024 16:48:16 -0500 Message-ID: <9176ca716368fb433c956ae72d70f0f16278248a.1720043311.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: SATLEXMB03.amd.com (10.181.40.144) To SATLEXMB04.amd.com (10.181.40.145) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DS3PEPF000099DF:EE_|BL1PR12MB5707:EE_ X-MS-Office365-Filtering-Correlation-Id: 35ecea15-f642-4f32-32e5-08dc9baa0110 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|36860700013|376014|7416014|1800799024|82310400026; X-Microsoft-Antispam-Message-Info: =?us-ascii?Q?Iqg2goJ5IOocjOgFcyTrmvGesXgmk5d7QAXyygn4nVtlZ5hl7BIq61wozwDa?= =?us-ascii?Q?6JRLJBZsKEYU05QYonvXS5TL1JvdQ19QBxnlWqqtzSZ9/dbQ7KYgRwjagmSZ?= =?us-ascii?Q?+jLdw7079/dixVo/BYeuQgGM1lctOYN2qfNuCHS3p+5zh5G0Fi/J9pdYvK01?= =?us-ascii?Q?JAn+VEqnI7bTNxU2AMypG+kSMgkLS0vSP99VKJhGsENHWINP0kxpTjb2DSVk?= =?us-ascii?Q?+l/Xdl3ZkIYGfYJhCUGAjRiCkTXX20q9qLAf6nWEMD//lVtn1cO1r30LgUIm?= =?us-ascii?Q?D2jGct8Xmn2gUtU5hn1QiNF9IXLXcvDy9jAyVuEPM5JUowxHXuOpX1WyEpvd?= =?us-ascii?Q?SAUQJrWxmtwEMarcnFiTwXFTGOIlH3BmPYg6bmiWZ/LJI4UffpEE/cujXtut?= =?us-ascii?Q?iTIMfZ7P8FVHrNPtwe2MTTyxRMUIgoqc3igminbXGu6wKhBmhV+a6y8Jl+sg?= =?us-ascii?Q?dMrpVdXNLMG2eo+Tzkb8/MrJheakYyJV6SvlcArPwxYJfOzPkjVQuW5gkI3m?= =?us-ascii?Q?gruZiE+SlCZ1Jnu4I3Ut/10NvArLJTKzi54i88yZ0iFSSSbspWh8hbLoiKr9?= =?us-ascii?Q?6Slw99wVao2PQ+da/Kidgev3pCOQPvscFuRsouCdNxMre0J62fw4hgr+xYPb?= =?us-ascii?Q?XSwKqoYZ+o8gM4aAF+y+qrgs6U1QCRYBCOspXeY0K4JTG623+L84gGwMyW1g?= =?us-ascii?Q?VmZJ7ww8mK/XIaeecB/YmH/Llam/TvnVkMk2nIgIqFbvbBPlWcqToXNyKJwl?= =?us-ascii?Q?0mW83OlxgQM39l3YrhbLkLn9jjm8w1WS/gRJjYNxVbos2o47KL2CMSxqpd30?= =?us-ascii?Q?q2Le7QwGvGmvRhP+DBk5sC8Q2dHjVX3ZzscHpgtt8cEc/jbFrr69k6AZFo8R?= =?us-ascii?Q?dTaAYLCtd/f3PTzqVMe2GJKwrAfcMKEGgJ+mX5C8OUj5Ib/xSu2dOh1NeacW?= =?us-ascii?Q?t+0pZoinCKxLAezEawG8qvmBKQfV/+u+xzg6EXGqs7auWv/zj17Lw8VJ9HUA?= =?us-ascii?Q?ewyXzpCTh1RO0dA/+iiYAYa3YdryGlG0xjC8wqRUmFff6ErNmK/PPbabwnq/?= =?us-ascii?Q?QWK4tWef2GjXzuRVyMw1xmKvwd3NovHE92zJaENUbbrrFBq3i6IiuHa0w6X8?= =?us-ascii?Q?x/ffcmKS1luHF95Y1NR6Mv+lS5Z5OYxJdxG4cjJlr8Ld+Mb3uoMXRBE35Up+?= =?us-ascii?Q?Mp8xrXYChHhQfdKPcq7ZgJR8ZMgXqz2j7t6CwUgSQ4iXpohnQaJTFRXH0XaR?= =?us-ascii?Q?VTXft3IFL8TYbOAWFswssNCEvteDHfYaXrt7e6OlhBo3PDuIgbmWbQW3EJ+V?= =?us-ascii?Q?wIEi7ys0WcaY3EFT/7OZMsCLWVASKKm/bPPfti+l/tvUCC/0p2rQgdEswrFu?= =?us-ascii?Q?KDG9sOzpGkKyu+SghjAWnihjbL4lHlICXZEFrztQwwsya50N28Wivmv0LfWw?= =?us-ascii?Q?AUiGh9IBwiTQxjzuicy1rUTqK2WwILKL?= 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)(376014)(7416014)(1800799024)(82310400026);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 03 Jul 2024 21:49:24.3414 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 35ecea15-f642-4f32-32e5-08dc9baa0110 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: DS3PEPF000099DF.namprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: BL1PR12MB5707 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 --- 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 87d40f149ebc..12793762ca24 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:14:47 2026 Received: from NAM04-DM6-obe.outbound.protection.outlook.com (mail-dm6nam04on2073.outbound.protection.outlook.com [40.107.102.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 9F466194A5B; Wed, 3 Jul 2024 21:49:36 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.102.73 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1720043378; cv=fail; b=P08gB19nPwCv1FBAbQw4I6qIeOXq21B9OcclxPyMQIDmx53QS6ZKAAaL4lL+eYo/xoVvimXhg1zk6AjgJC8fOa27BkTZVnba0l4g9aZF7WqZ37ymxskr4hqxWHF7MUHdfz9FjmnIhCoX+StyA/MCPhki7U2ZZAcNDZ0f21CBqH4= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1720043378; c=relaxed/simple; bh=ctiS8aM0JSe0iH8iyLO7UJ//xc5tnTVH865Z9MikSD0=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=Um+VHt1z7QkP0GOeuRn+C4uR5oZYv6lG0sWnpPhWpTdPPYH7LmjeD7/Nx6ddEQL6CjidqFEYmshwfNO0sSRPdL0F2+BW0Itw51rpoj44bN4sD0971BONHmRpzNZr6yqBjgMLOd7UmHnrxV5akWaZG5Pfzw8TyF6xGuuVdcnRSAk= 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=jxAo63C7; arc=fail smtp.client-ip=40.107.102.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="jxAo63C7" ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=mLVGsCYkkTICpXZazK22QIWUK14Q9T5ZwPPm38z3hJKooNPWkuF1zNEU/P1wQI/VCeZkhhUcR8Oe04448typNYsOqYk2cWr+jlE52XvDqVzSUwHt5WGbS2olVCge6pGUK7kqcdEHBjFKIBzK/gGPaH3ea4N1e/2GBFZLX1limZ7twPRozrePYkIQfEEqCiAxUedkQ72M37DJ4M3CttZz886C74COzNrjn0++cTB34Yjed1OZx1XcTJg2jo5XkcvzS48j8+iMcdU+NFChjhJY3NM+IPBVJccDmQizPPcdpB1gdjNwuwQW0D7ErUtbf0mlXwjzMpTMgI7CodeFm+S02Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; 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=lEXkGucI87O6F1seTTwWieLSd5A5cBS1ifBJuM81v7k=; b=Cjjcg5X8YubUHfV/ovaI9lwSsoLtdr5k/2/uYwLu+TW+e7bsqJdvlOPuPsqH+Rhf0djnAnUN/yfGXDO1MEsi6T6iQhC+Z7Af3ZNQ+/R36JstO9n3OR1GsQ84UQieelnra6+bZBy1N8xMdh7NUPgBT0b6LwOdJSMqdGgkRBoFO7RT5gJFn0vM1BZVSyJbQceqK3Pbc4irVYtg+PMRmBPA7XGTzovflsb3orWzEQ6BjrEtjzJjYJ5w7zke+q2c0RhUp/MYY/BdMEfvJBue2Lk73robLW+iisNyriuvyaDlBKb9tmHZnWRgRM9jL0xiRzxUhsXNxKZjpfG2rB2O7TveQA== 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=lEXkGucI87O6F1seTTwWieLSd5A5cBS1ifBJuM81v7k=; b=jxAo63C7ltOnDE8MjYxgqybGI4OOZtsVpEmVvckuOdbkqi8GdXAFfKLb0EOzPPMGCPNzY9iET7Ytb9AdBCzPSB965SA2vCZNHCnTxuM4VzIURIQDua8u3MYguOmZ5JTBty8FQTl1NvdFWZOQ/mzN9Uvcx1Y3auPPBnzwHAT7dOw= Received: from CH2PR05CA0025.namprd05.prod.outlook.com (2603:10b6:610::38) by PH8PR12MB6841.namprd12.prod.outlook.com (2603:10b6:510:1c8::21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7741.23; Wed, 3 Jul 2024 21:49:32 +0000 Received: from DS3PEPF000099DE.namprd04.prod.outlook.com (2603:10b6:610:0:cafe::81) by CH2PR05CA0025.outlook.office365.com (2603:10b6:610::38) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7741.25 via Frontend Transport; Wed, 3 Jul 2024 21:49:32 +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 DS3PEPF000099DE.mail.protection.outlook.com (10.167.17.200) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.7741.18 via Frontend Transport; Wed, 3 Jul 2024 21:49:32 +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; Wed, 3 Jul 2024 16:49:30 -0500 From: Babu Moger To: , , , , , , CC: , , , , , , , , , , , , , , , , , , , , , , , , , , , , Subject: [PATCH v5 06/20] x86/resctrl: Add support to enable/disable AMD ABMC feature Date: Wed, 3 Jul 2024 16:48:17 -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: SATLEXMB03.amd.com (10.181.40.144) To SATLEXMB04.amd.com (10.181.40.145) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DS3PEPF000099DE:EE_|PH8PR12MB6841:EE_ X-MS-Office365-Filtering-Correlation-Id: 5c7d176a-1c42-4af2-8a08-08dc9baa05c7 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|36860700013|376014|7416014|82310400026|1800799024; X-Microsoft-Antispam-Message-Info: =?us-ascii?Q?O6UkHnJP97BBmGmDYSzACssjMCmHvcgQjyJoVRyo2H4LLE2IOSyh7zY8zgN6?= =?us-ascii?Q?e6OHcnWWya+apcS+94+RTK3yncGlUQ+Dwhok3MtHoyw6AwE+hcW0+CZqaRSO?= =?us-ascii?Q?NA5AvOYIWjuOaqD9VwXkDifFZ8s5RMXz67fBBWKlpAFYcYxOzL+qVNWwnaf/?= =?us-ascii?Q?63xPnkLMc+fRa1mYx00otyf43aF4oioLST1mb2FCgKOc30FZ51UIPKrG7jBt?= =?us-ascii?Q?JM+QZ5k152NYfKGZNEXeqYtzvxv9sAOeV24ThfIGFbmZ4YJpN9O9AX1SaT9A?= =?us-ascii?Q?fEd6c3uh/l3pLqsuscphqv0FACAIXN3rVHNiwvCYk43Bt2b4h1G4N3hidkfx?= =?us-ascii?Q?/y/kkah3sjsV/9zFaT1SikFub2pfRft60kLnW/8S10NgVHOHX4uv/kZlsfzs?= =?us-ascii?Q?lONBpIRUkwe8pejz3lOG4TkMb9Qj/E5EOvOgzYBHI+rErlWcSrxr32AtCCqv?= =?us-ascii?Q?XkUHRJSXC/EBu0LGuUAfqlpze1Lna1xFLEAZ4GyowY3lj7692XJ8bTxrc2lx?= =?us-ascii?Q?zhDT/m+Bsqxoz3rqfOVrt1hIYUCQX/IDH3GHi1jm8Y02OTlz+5JvBVm2RCmA?= =?us-ascii?Q?IdiSNbyFjt5SMIa2fd4egah7YHsKdude29pXdn3KE9aIkGcIE1yxAzaFeBmy?= =?us-ascii?Q?ATy9yjcQBnNCDGq3aWGC2cLpX6zY3vy25uRsUU/ICK1/rh42yEh2NYQOs8+t?= =?us-ascii?Q?EaDW7fXu5pfE5u4MnPH2+YA+g3DsOAlA5yrezr7mU6KLmz1mFtP9uWSGKz5R?= =?us-ascii?Q?MSgSXZAMuuAdZerlZiE/uthWutoTAG5Tr0bBycEWDCV3T1m433KjLZvdLoBb?= =?us-ascii?Q?6gIbDQuqltMsGoamv2cm7RFpqdw+0JvlaEu39u7pd8BJoBW39H4rM1Ns3lDW?= =?us-ascii?Q?zP13LKYMaI/g4OoRhy8ccnRFb5kSPqz+LIPI5ERr3xq+AVt2Ocf9NF+UilOI?= =?us-ascii?Q?aMb4Jg1i2rON8tlGIOxK02LbKHCVtdEQEU6sb8H6BWm2aF2oSmd1qku034wt?= =?us-ascii?Q?Apht26Fb3ddwXX2ufj0DsEwW2c4A/nGP12yh7JLAu1nRjaWFoJymaJmPW5ie?= =?us-ascii?Q?024dlStZynXbHtNOOMZdbqY3e/08W2Xj2Bx8o4LS670W+3uJajFFoAj5B4EZ?= =?us-ascii?Q?DAepqGQfA4XVAS5IfhjmkOtaeyNiRyP9oZ5LjEbBwQQasm76fzbgqjtXYXqd?= =?us-ascii?Q?jrFqueOCrYJey3Aqup9IbgJ7NE2Q9fcYi6NLBeogj30l+EvzBJeNhvPQGTuY?= =?us-ascii?Q?68vIf0dgt2sEpxtt2hPDwc5GGMiJVwTU60d1s+EqsC7y1SW9Qcs3BR7IUQ2m?= =?us-ascii?Q?z4x24qzxX/TcJIoxiR2PXSas9dJuDYEcHPwH77Oj14PvBQurW/vmz6lXkE/9?= =?us-ascii?Q?QhtK0OJlXHPNxiBnHm8itjbyQK9H?= 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)(376014)(7416014)(82310400026)(1800799024);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 03 Jul 2024 21:49:32.2382 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 5c7d176a-1c42-4af2-8a08-08dc9baa05c7 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: DS3PEPF000099DE.namprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH8PR12MB6841 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). Signed-off-by: Babu Moger Link: https://bugzilla.kernel.org/show_bug.cgi?id=3D206537 --- 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 | 66 ++++++++++++++++++++++++++ 3 files changed, 80 insertions(+) diff --git a/arch/x86/include/asm/msr-index.h b/arch/x86/include/asm/msr-in= dex.h index 01342963011e..263b2d9d00ed 100644 --- a/arch/x86/include/asm/msr-index.h +++ b/arch/x86/include/asm/msr-index.h @@ -1174,6 +1174,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..0ce9797f80fe 100644 --- a/arch/x86/kernel/cpu/resctrl/internal.h +++ b/arch/x86/kernel/cpu/resctrl/internal.h @@ -97,6 +97,9 @@ cpumask_any_housekeeping(const struct cpumask *mask, int = exclude_cpu) return cpu; } =20 +/* Setting bit 0 in L3_QOS_EXT_CFG enables the ABMC feature */ +#define ABMC_ENABLE BIT(0) + struct rdt_fs_context { struct kernfs_fs_context kfc; bool enable_cdpl2; @@ -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 + * @abmc_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 abmc_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].abmc_enabled; +} + +int resctrl_arch_abmc_enable(void); +void resctrl_arch_abmc_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..471fc0dbd7c3 100644 --- a/arch/x86/kernel/cpu/resctrl/rdtgroup.c +++ b/arch/x86/kernel/cpu/resctrl/rdtgroup.c @@ -2402,6 +2402,72 @@ 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; + u64 msrval; + + rdmsrl(MSR_IA32_L3_QOS_EXT_CFG, msrval); + + if (*enable) + msrval |=3D ABMC_ENABLE; + else + msrval &=3D ~ABMC_ENABLE; + + wrmsrl(MSR_IA32_L3_QOS_EXT_CFG, msrval); +} + +static int _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); + } + + return 0; +} + +int resctrl_arch_abmc_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); + int ret =3D 0; + + lockdep_assert_held(&rdtgroup_mutex); + + if (r->mon.abmc_capable && !hw_res->abmc_enabled) { + ret =3D _resctrl_abmc_enable(r, true); + if (!ret) + hw_res->abmc_enabled =3D true; + } + + return ret; +} + +void resctrl_arch_abmc_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->abmc_enabled) { + _resctrl_abmc_enable(r, false); + hw_res->abmc_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:14:47 2026 Received: from NAM10-DM6-obe.outbound.protection.outlook.com (mail-dm6nam10on2042.outbound.protection.outlook.com [40.107.93.42]) (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 A7992194A5B; Wed, 3 Jul 2024 21:49:43 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.93.42 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1720043385; cv=fail; b=GVK7d19rpiq4eRr1yyHKafkIw9iaf8nQs0Cnowg1MveueedjOuMX+Y4im7YVhkrgdf3vLoMlJ+M+a6rzQfshjq4qGuoKkq0ia74oN+nidqTkbVbdTZTNslpqYnEJi2ZNi60V5EfhTarZI0crzDFNTLEi8YzxnWgS8mZx9e9FYNk= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1720043385; c=relaxed/simple; bh=RkJ8H1x2lB85H4tGXceYPBeFAQaYqAAu3jTVc8326LI=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=Aq+6ok2gjDuh12D7UA9i6rcrrgaqDfxDBD0ncpdq2DX2PAezP5Z44RJeLD1vFEDiijPznjBLTA+sLV0Aj/bthlq/nPEsa6IKsGpN+K9eh7hV+p44XM156mE67MqpmBCAhSET7TBxWtw3I+8pmXGSTH8CVGQrw19bqa2zdEVch5o= 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=aNUBabUt; arc=fail smtp.client-ip=40.107.93.42 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="aNUBabUt" ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=UQjBoxpZrzXNcDo2uV0Y6oUXHH5dyhfYBLZoSkF7oA7EizZg5qz4noHSghJrLNUgAJn0HLdpyWSKY76Nz1FfGp70lJ1ds3p4SWeGDN58haJdOh6BV0x5jrvs2kQUCIWFse6u08yNxzwZzEd7IDXcydBMfcYEkmn1uzHUxwiIoc/7fb4TRpBJexa6xqNoejGqFui4MOnd7u9bg0TFwuWGLF6qZ0K0if6E0af2CtWVPFXhMWKlN70D6At6z7EA/m1ug2osKyyrNYeMh6fUCdgStuxMNHKn4pZ7HhY8IfgkM9hi5E2z3JgOMs8ROVPwZbuTk+8YSKFQ8v8Nnr+6vXOCug== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; 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=grRtu/eAEl4GcQEYXVeNV6HK8O9ANuGmhQ53NOkm7wM=; b=cnhv9picIFzMoIDiu3oMhD2eJ2raHWbW3B4qctdTb3Dq6xerphgDjhaZf6bjAyEA9CvcvlU5JtkgRy0pqMznKh+mgzpHnaldRMa6vO73iQBu8zzuZa+MDxG4T+Mp4TxrC6l+IntFdm5KPxNitp15z0a8OX+0j1npWg45PJd3Iz+G/pEYLavc+6Jv7Tl2myDmxspp7UXSzvB7ih0XlqMImS7B4J/Lt2zqJAMlgrhrZSVMfXNyEhfl7CtjK9t6zjo0bSFFuJSRy9SVxvIDuiClwAB9bAy5OIxLULrHxGbs9KxbfmUIilTYOAoW2VRRqC3X9mPOQAgfkCRJWKt5+kGNtQ== 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=grRtu/eAEl4GcQEYXVeNV6HK8O9ANuGmhQ53NOkm7wM=; b=aNUBabUt/jrCltrDCmtLQEL8JYeVPhO0cxbPYN2str26wzNeoSBiq6DGSXru4K7Yt5XBdzO5jRduYUxUVYOgluIAWkp/2TGFRvO+bk/3LCDbp2kaKbIE5K0pAtD/oXcoeXihV3XHIjaf2wRT6S7jQWMYWtJoMJl9ZUa7E9p+w80= Received: from DM6PR18CA0017.namprd18.prod.outlook.com (2603:10b6:5:15b::30) by PH0PR12MB8097.namprd12.prod.outlook.com (2603:10b6:510:295::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7719.33; Wed, 3 Jul 2024 21:49:40 +0000 Received: from DS3PEPF000099DC.namprd04.prod.outlook.com (2603:10b6:5:15b:cafe::68) by DM6PR18CA0017.outlook.office365.com (2603:10b6:5:15b::30) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7741.25 via Frontend Transport; Wed, 3 Jul 2024 21:49:40 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 165.204.84.17) smtp.mailfrom=amd.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=amd.com; Received-SPF: Pass (protection.outlook.com: domain of amd.com designates 165.204.84.17 as permitted sender) receiver=protection.outlook.com; client-ip=165.204.84.17; helo=SATLEXMB04.amd.com; pr=C Received: from SATLEXMB04.amd.com (165.204.84.17) by DS3PEPF000099DC.mail.protection.outlook.com (10.167.17.198) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.7741.18 via Frontend Transport; Wed, 3 Jul 2024 21:49:40 +0000 Received: from bmoger-ubuntu.amd.com (10.180.168.240) by SATLEXMB04.amd.com (10.181.40.145) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.39; Wed, 3 Jul 2024 16:49:38 -0500 From: Babu Moger To: , , , , , , CC: , , , , , , , , , , , , , , , , , , , , , , , , , , , , Subject: [PATCH v5 07/20] x86/resctrl: Introduce the interface to display monitor mode Date: Wed, 3 Jul 2024 16:48:18 -0500 Message-ID: <4b8e3a4dcd8b6c7d7ce80a54cd2a129cbd2eedda.1720043311.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: SATLEXMB03.amd.com (10.181.40.144) To SATLEXMB04.amd.com (10.181.40.145) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DS3PEPF000099DC:EE_|PH0PR12MB8097:EE_ X-MS-Office365-Filtering-Correlation-Id: 067094b0-ebe2-46f7-57f3-08dc9baa0a76 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|36860700013|82310400026|7416014|376014|1800799024; X-Microsoft-Antispam-Message-Info: =?us-ascii?Q?Mi/Ge6AAcu/lTUyN0lAQyOwgCszkkAnypzaAUYJIz5GOkipyhwFrayK4yvV8?= =?us-ascii?Q?R0q74xm0Hj1QruLPrqWKdf3FoGNA3/+S3fYLZ/gGW+L/8tZUQU6SeIM/3qVu?= =?us-ascii?Q?BeYBU/SuKVT0NdzHSzd91ILp3OTANWCoNpTNrY6mFXAMV/4NzxTew71B2FRF?= =?us-ascii?Q?W0QCzTGONUiG/TBIEEREta07zgpUKGxtSJdduO1qr0y0axRyl6qdKh+eHkUq?= =?us-ascii?Q?Fteo1Gqr3EtNfvebBoHozg+bC2fZ6EH7cZyJzhHBF8+cD0LzTKjYFpTPsnjD?= =?us-ascii?Q?CD5mlK3+r3Q4w7R1lUGYpdaqnn6rBShFl85/UQNtxDHrQbchI6ebnFVQLSG0?= =?us-ascii?Q?yXBQgM+/4CiyxXSF7dwbkKfPaQ3dCWlLnPFbXvmzW7npkDBiNGBJhb9xUE4b?= =?us-ascii?Q?3WoPljLcFnjhmeTwd+XFtr8FgN2WEpBhY3YCsYYK/2JjsJu8nB+6l9rMPW/f?= =?us-ascii?Q?rqiwpHXXonY/AXjI5eSJJHyBhxIyxUMxeAj1Xvios8AkoBEAoqXqxmO1CZxY?= =?us-ascii?Q?1hXUA+UmxEdLD/HXREuPv+kOJqpTmF1vBa+12B32e0X7WAsY5xAgJ8WORZa4?= =?us-ascii?Q?3TNEVG013EZzthnwqAHrXUk/mVU2O9AfSf7EG45kYBSqmoHKuRqqpP3UgXw+?= =?us-ascii?Q?FdxE0FCZfoEIU6iloGoyINF/SnlTHhyOvpbGY2bjGHxhWFVsZfGnHkVg0vfH?= =?us-ascii?Q?iSN3EK2IMDnlxI8FoEp9tXVx2zJ2ob6iXe83ieIsyWz8m4lDDKDdkECf7nVr?= =?us-ascii?Q?zJauf771USc4aIx+cc00n2yBG9LVY0lnCNVHFvQZI3+h3YeOfeKSleZvCrv7?= =?us-ascii?Q?HJdYSBcyXeLgW1bauU6k1LThLRz6/EkLMCXdz1vonEn1XCVOUQpx7noBHLs8?= =?us-ascii?Q?Ft77uKu4Z5vTadKlZg17mLvHlcDyMo0WXy3FiGqJtEDChbQFSSRP1BCvCRma?= =?us-ascii?Q?IF647enEJdYIVa7cIEbPfwBQWmtzZJJhEh85NlSTleWxHH6g6BmLhvfHDq3D?= =?us-ascii?Q?dSTlEYG0WY753HJZAKQXPP9jU/aws5FjKZKpBVRnWuye6otaKPu1H6iw8qol?= =?us-ascii?Q?6qEabxztGJlGmA9glAkZ0lUFdc8IelTE7bpuDUBYCZXss0lgCWzEwFogQSY2?= =?us-ascii?Q?j2/KakOTfuvg0YgbIRrXbTaYh/JNsd8hhmPggVYN/k8JOd5Loe8NBiYjwLfH?= =?us-ascii?Q?T3m4EYIGIEMzYlcT1lSDcX6pK5EOXS786fSxbjpf4HM8HuxA9z49oWS+Llvp?= =?us-ascii?Q?vE5+vmfUWR78m7PAZmml/ooPFcIFJZ5Wy4le2SK4MdVn1mE0MtRtpJ0taesj?= =?us-ascii?Q?7kxddnvtjBjyNvMgyHIq0bAJ7EcKjRYMk6RLO7UOb53lx6YN5KjUsxeVc5Ei?= =?us-ascii?Q?Jl4YaO/PiL65eBNqNSlOTnSa11l5YyjoFjznkP/cPhcbDy+BOPtHelZlesle?= =?us-ascii?Q?kFzVVMm0tiexl3NySVkFx/Ptc4G2FfPg?= 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)(7416014)(376014)(1800799024);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 03 Jul 2024 21:49:40.0947 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 067094b0-ebe2-46f7-57f3-08dc9baa0a76 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: DS3PEPF000099DC.namprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH0PR12MB8097 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. ABMC mode is enabled by default when supported. System can be one mode at a time (Legacy monitor mode or ABMC mode). Provide an interface to display the monitor mode on the system. $cat /sys/fs/resctrl/info/L3_MON/mbm_mode [abmc] legacy Signed-off-by: Babu Moger --- 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 | 30 ++++++++++++++++++++++++++ arch/x86/kernel/cpu/resctrl/monitor.c | 2 ++ arch/x86/kernel/cpu/resctrl/rdtgroup.c | 26 ++++++++++++++++++++++ 3 files changed, 58 insertions(+) diff --git a/Documentation/arch/x86/resctrl.rst b/Documentation/arch/x86/re= sctrl.rst index 30586728a4cd..108e494fd7cc 100644 --- a/Documentation/arch/x86/resctrl.rst +++ b/Documentation/arch/x86/resctrl.rst @@ -257,6 +257,36 @@ 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 + [abmc] + legacy + + 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. + + Without ABMC enabled, monitoring will work in "legacy" mode + without assignment option. + "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 12793762ca24..6c4cb36b4b50 100644 --- a/arch/x86/kernel/cpu/resctrl/monitor.c +++ b/arch/x86/kernel/cpu/resctrl/monitor.c @@ -1245,6 +1245,8 @@ int __init rdt_get_mon_l3_config(struct rdt_resource = *r) } } =20 + resctrl_file_fflags_init("mbm_mode", RFTYPE_MON_INFO); + l3_mon_evt_init(r); =20 r->mon_capable =3D true; diff --git a/arch/x86/kernel/cpu/resctrl/rdtgroup.c b/arch/x86/kernel/cpu/r= esctrl/rdtgroup.c index 471fc0dbd7c3..3988d7b86817 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.abmc_capable) { + if (resctrl_arch_get_abmc_enabled()) { + seq_puts(s, "[abmc]\n"); + seq_puts(s, "legacy\n"); + } else { + seq_puts(s, "abmc\n"); + seq_puts(s, "[legacy]\n"); + } + } else { + seq_puts(s, "[legacy]\n"); + } + + return 0; +} + #ifdef CONFIG_PROC_CPU_RESCTRL =20 /* @@ -1901,6 +1921,12 @@ static struct rftype res_common_files[] =3D { .seq_show =3D mbm_local_bytes_config_show, .write =3D mbm_local_bytes_config_write, }, + { + .name =3D "mbm_mode", + .mode =3D 0444, + .kf_ops =3D &rdtgroup_kf_single_ops, + .seq_show =3D rdtgroup_mbm_mode_show, + }, { .name =3D "cpus", .mode =3D 0644, --=20 2.34.1 From nobody Sat Feb 7 21:14:47 2026 Received: from NAM04-DM6-obe.outbound.protection.outlook.com (mail-dm6nam04on2077.outbound.protection.outlook.com [40.107.102.77]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 1D5C6194C61; Wed, 3 Jul 2024 21:49:50 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.102.77 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1720043392; cv=fail; b=cpcC/TEeIAxTPvciWxXwS/laEu3vbKTfHM1oT+bA/pLtGtGxqGNIVIoOx+V5hjPra+6MjHAqw8eVuuxIWF1dEg161Yl76RfeamhfOw6o6hrdGga24DEmZd2hG4Ckys2ftNSJh/vvFh851FhS/9+0lJHrDXxlMtPsj+PwPWJdFvk= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1720043392; c=relaxed/simple; bh=aTY3ucYLUeYS0GHnz1dp8/gaq/1g0xdl/W5HYM9ljWE=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=XGtdMER5XnwRjW/iCUDVRewu77ErbdKG8KedBbyD8L4SKF96s6TOKIfDRnXnR/3XdTJ74yGn5lp5JIOxumJ/Go76pkcq5wiFsoMi0/WPYOHN8wJ2MGEXoZ088plDPk9xdOVNTI5lSQhKf6dw5r3f3CwLL6SSwakGkXDnl/kkb64= 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=Kc2a6TNe; arc=fail smtp.client-ip=40.107.102.77 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=amd.com Authentication-Results: smtp.subspace.kernel.org; spf=fail smtp.mailfrom=amd.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=amd.com header.i=@amd.com header.b="Kc2a6TNe" ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=l6gVi+U1sg6jPxuZmgoo4IeCgXEO6dlPsvra5oCF0WQ7+OTpveF4MntjPrlCJbXvY1YzUKdeQ7r+X2yONYUZ7zAC2/JPxeeLaJCcPaDqiQG+zi1wD19YLwGAzEqhNwUkAKbZ2An7k9EGNhvpXxw/v7NO6NK98IMJRgHe267Wxgxuidntjqgr1eZj8EEgDZg1Xoq6liPW66icYtCnanikJuHe61iELCtzUmWczvLy4eDsAuGXH1UimPhA7N8/+AhAuaBDTmHs4y1Tye6WY4nUDh/Ej7UmJ8DE+njJTgvzAztJc86s4lT6VdyosIAiMBWq+jenvriTg6VMX/M5V4ffzQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; 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=xO7IZ5QrroWa0unSifp/19Xmelu1dtZeWnsQdKSl+x8=; b=kzsB/cA0JG3A73kbMdDez21PZRwaoqSTB5sprpWRq+J7YRDMPdiyVWHjdMcUiBuhX5kzn+PNvA0tbJxFGKeAeuzXGQtGEYO7HVkw4LvKM2W1voqBeOfFPEhrXwB/8WsmHN6XrkXYtoGKArJJjVub6NsYUylma3TGMFZBdprHwyCR1ksVnTIWCb9AaRj+vLG5Qoq/1g+hCm657dL8v2VrAhyJRpOu6fNyeE1aHRkGhAQToJui5bu3nInbD2gs88HvOq+FzeYtlR71YjVJ7++6ZRc5NTYyeYXuHAG3Pa8ZnigIKNkjlnkjBf9RMO34S0tTU1O8lWVkmtmcr4Ev1Fh0Mg== 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=xO7IZ5QrroWa0unSifp/19Xmelu1dtZeWnsQdKSl+x8=; b=Kc2a6TNe1rjmukIiQiwnyI9j/ER7lnEXYek8iV8apKd+5yfn4rdWKmXFKdJOAGdpZMMAu7XDHMzL0KihPF6HdW8dPbkMPM5g9E7euriRyKKd+EMoOJ04/soPH7duou+1A9UppGX9QGmfz/x8XDCdJlUHC9ulA7OrBwJK//f1XOA= Received: from DM6PR17CA0027.namprd17.prod.outlook.com (2603:10b6:5:1b3::40) by MW6PR12MB8867.namprd12.prod.outlook.com (2603:10b6:303:249::6) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7719.29; Wed, 3 Jul 2024 21:49:48 +0000 Received: from DS3PEPF000099DB.namprd04.prod.outlook.com (2603:10b6:5:1b3:cafe::69) by DM6PR17CA0027.outlook.office365.com (2603:10b6:5:1b3::40) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7741.26 via Frontend Transport; Wed, 3 Jul 2024 21:49: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 DS3PEPF000099DB.mail.protection.outlook.com (10.167.17.197) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.7741.18 via Frontend Transport; Wed, 3 Jul 2024 21:49: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; Wed, 3 Jul 2024 16:49:46 -0500 From: Babu Moger To: , , , , , , CC: , , , , , , , , , , , , , , , , , , , , , , , , , , , , Subject: [PATCH v5 08/20] x86/resctrl: Introduce interface to display number of monitoring counters Date: Wed, 3 Jul 2024 16:48:19 -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: SATLEXMB03.amd.com (10.181.40.144) To SATLEXMB04.amd.com (10.181.40.145) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DS3PEPF000099DB:EE_|MW6PR12MB8867:EE_ X-MS-Office365-Filtering-Correlation-Id: 5016b3eb-ecc0-4982-2695-08dc9baa0f29 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?gSHz068H9b7kVLMgCwXnopQGCSjKQ00YfnnRsjL096V4KYfzFKzsZQ1cNRm2?= =?us-ascii?Q?MTtoDsDzSYL6oHsY/y7r4EgwDWsvZhWdposILnpqA1vhVTQaKe4bbilZ9tm+?= =?us-ascii?Q?7kuNc4jpDWHm9+3eiu+2ofu+Mdo5ebTfhrVYFJDV6dNzWW7XKs+0bLTCd25G?= =?us-ascii?Q?OIc5EycEcl0e62TnMSYYjqhgVrHqjgVwsmt+t6W6BfZHkJwZ5L/zUeRE6wQn?= =?us-ascii?Q?4Yztq5B2uEYjodIfdDYRW34VqByDp5Y6C6BpBjhp3vsaZKCCGWb6S9/1M3w3?= =?us-ascii?Q?rCf2+xti2sAgUT+5OzaNaW4IHCht3xJA/O+5AmI23gn5lyQPadMHljq9l/7q?= =?us-ascii?Q?wvPn+i+Qk5oABzBpJUrBODke0dlRGhk6b39LP61lNpC9u067T2XHblkoGfcL?= =?us-ascii?Q?rtAgGrYydwpaVtpxhPEbaA3aD9Wxcl8xwIKmT6RiK78LJhQraCuaL0P8UyA1?= =?us-ascii?Q?Ql64zxwpxe5QfgAXlEXD3SWE8wvwAKdHQfvsyOOJZd/vyZGiRJfQCGWvpioI?= =?us-ascii?Q?DtApYCfzj2oe/u6J3p0N19FCATTGOFUR2LRbX8vDt18C4sa9p1+VXw89dYT+?= =?us-ascii?Q?W2IlY1FTkZnCy2Bza0PgNTY4YaqOF9tycCxNsAonEhAVuYL+ASSSmwODBto1?= =?us-ascii?Q?qQIc98QUBAOLT1E9CQrIKZFzv71O2/7Lp6eDO7bn4A+TsIrnyDFc/G1njXF1?= =?us-ascii?Q?vV7ksfsRqLbslmLlFVbx1t+NnS/mHucC+W1ThZJIZYwE6umac1n2h9xGLoBc?= =?us-ascii?Q?Baq+iJxgic3TWU8h8mCcWE96kaakgfCHgLkXWjRek7kDfJP9J+naVl12ZfqC?= =?us-ascii?Q?mbF5FnraDVI6vt6MI/S48dS89AvFfnqfv59otURwo+pky56sZYdBRLKuJpoL?= =?us-ascii?Q?ytXGp4eLkpo3Z/zRXv7YZ9y9/4xNTFD6ICttH64I4T/CnOWvF+Gb6GbcAKi7?= =?us-ascii?Q?LV8VL3P8jzMzKhGww2iTF7ZOQzxEVdFRYQMtQ/TVr6q2u2eyfHRwSpmLGndX?= =?us-ascii?Q?57gXLda8cozUcUYQ/HZx2XJVy3Hn/VsoVC4XRjO1tKe5mQQ8A625WL9NO54Z?= =?us-ascii?Q?vIyL49n/m4QjfBuF3q+tVzMiITTqTg6F+yxWZeH6cZ1Mpu6uqSBm19bfeeuW?= =?us-ascii?Q?OGGADjjNSwl51Qmc8TVKvjIn+FlbchUpFFQchErkganfdf/3YAJJWjkNM/U8?= =?us-ascii?Q?JAwsh0XqhABx7YvVO43XAX6pCrvkhvoKHYsInVKHmaQSDwSgkuTjCSR3d4H8?= =?us-ascii?Q?j9P2jVvLajCyCkX1DQaBjOgJaNVjrhi683UywzAfoAUiV8EqUmSmvk1GuEr+?= =?us-ascii?Q?KUhqE2eltcXDF1+KfGy0LB/GZXc+W4+lDy47Osj8Q2c+ZIn9Bh2S3g3vdM7t?= =?us-ascii?Q?AK9B2vhg1doGCNTAoKQ7GAnZ5FB2ewkJajVrUaYPnpyJz8lIkllRiMnsrem8?= =?us-ascii?Q?o37zYLkaeXesA1AwmUg2z0vD8wbniLHJ?= 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: 03 Jul 2024 21:49:47.9774 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 5016b3eb-ecc0-4982-2695-08dc9baa0f29 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: DS3PEPF000099DB.namprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: MW6PR12MB8867 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 --- 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_counters. --- 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 108e494fd7cc..4907d0758118 100644 --- a/Documentation/arch/x86/resctrl.rst +++ b/Documentation/arch/x86/resctrl.rst @@ -287,6 +287,9 @@ with the following files: Without ABMC enabled, monitoring will work in "legacy" mode without assignment option. =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 6c4cb36b4b50..7a93a6d2b2de 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 3988d7b86817..4f47f52e01c2 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 /* @@ -1935,6 +1945,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:14:47 2026 Received: from NAM10-MW2-obe.outbound.protection.outlook.com (mail-mw2nam10on2083.outbound.protection.outlook.com [40.107.94.83]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 7F7D4194A66; Wed, 3 Jul 2024 21:50:01 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.94.83 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1720043403; cv=fail; b=K5wdMSXKMCxGZYVcX8m1sJddsBUSN5UuVQ9l4Ml6nr1Nc7tAMw2lWdgoqfF2IDBz8GOQ2sgfhMUHbXQgdTEgzuYFFRozIxaZSj2+XTdNnIq61NYCrtt4btf2hZFBiBMtlPk6GCNp/LnXGl7GIlrgchc2djQHpJdFah/3Zkg0W9c= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1720043403; c=relaxed/simple; bh=kOO7S3N2zsPYJ0jlpVzUhekJWXSIcawH81mlTkjv6so=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=uXVsFMpQ0T8kYS9w2jro9ohNhGG/ur0sZ8dExscJAmZgueGrZv8RYRQiQYdK5jNFvAXAD1hB7hlLw2NAk7+K9d78jFhoYWURgSJiWNUxCWEhY8I4NHEm0aNaNu1NyD+KxJ82kLuVC2y3dEiiKFWgzEva030y+nW6BMHM1nQBoCA= 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=M+rA8Dh4; arc=fail smtp.client-ip=40.107.94.83 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=amd.com Authentication-Results: smtp.subspace.kernel.org; spf=fail smtp.mailfrom=amd.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=amd.com header.i=@amd.com header.b="M+rA8Dh4" ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=P4llurGmQWEY7ADHTL2fejYfjtZeGxrsB/492IaYwGgiWB6pM5b3jsjhdVrkTORepSxVyK7Bp3zQ6G/j7SUKHnLSo/iRIjV4ldxcMw0NB7QxWJWeXWIKiypvlSDQjG35tYLNTWaPpwYQXlxE6xLdjgigeQ6g3cHUpPV4ficoN9Q9vrgiuDWQ1/fgOxw+djgulhJY2GQY9pBMdPIN+GYkXD+AeZW9v0s4/Lddz85924CqdpvqUs8RQCMpwmq+16qL7IL8ELnQRcIv7Pb2jeRdx8LBIE3E647dTnrH6Jwt5E2yHZ3dyKXK5BAIvFq5Q9iJhpa0GN7ljLvKlMG81Pacdw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; 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=8A0L5Ot4zFFzsW0CCxFbud1lSs9VqhQIGBAVaxrGnEI=; b=fsG4Tdsr4RpZ8KfTF0t1n2Wb0Bl2FxkySW814fjfoUfiFlc8zQxYjBnYnykg17kM5AFqMWw3TYENRsQlv+lLFAv+fOIhA5yGNAGs+YGeE8NdA+FHc6TOdejNAXTzEgeC4zc5F467IqbMtEOnJ/A7BR3vGQTZUcQ+j4mov81ZwZNYG8DTlXSYA7rz/Vbb59OKYB8CfI9Eeg2adzxVoChwi3251YtIn+B15jYWJB/TRjPi9Xsvl+TBfymxbaLehFDXiJrE31cTaYOupaNBdxcTqffy0QMLjBNNDweIRHZNV1W/wxNfxMfqa4Ht6zjsqukwDWypAadn2FEBzlsqBnhQ8w== 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=8A0L5Ot4zFFzsW0CCxFbud1lSs9VqhQIGBAVaxrGnEI=; b=M+rA8Dh4aLtF6EOhkIHY3t5zsCmTbdV7+lGYEjHOIvtOf9lJAlkNG3v0lEUS/zfgqS/rfgfWZBI3QbcljZ2zd9aMMnlo3SvdoMYKiEQ2R05htwBs0goV6R2HzhXntUr8cMMDE2Cu0ojRaIVurgv2zt9jcKzm4k5oMGo1B/0hh8A= Received: from DM6PR06CA0048.namprd06.prod.outlook.com (2603:10b6:5:54::25) by LV8PR12MB9452.namprd12.prod.outlook.com (2603:10b6:408:200::8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7719.39; Wed, 3 Jul 2024 21:49:56 +0000 Received: from DS3PEPF000099DD.namprd04.prod.outlook.com (2603:10b6:5:54:cafe::2a) by DM6PR06CA0048.outlook.office365.com (2603:10b6:5:54::25) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7741.23 via Frontend Transport; Wed, 3 Jul 2024 21:49:55 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 165.204.84.17) smtp.mailfrom=amd.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=amd.com; Received-SPF: Pass (protection.outlook.com: domain of amd.com designates 165.204.84.17 as permitted sender) receiver=protection.outlook.com; client-ip=165.204.84.17; helo=SATLEXMB04.amd.com; pr=C Received: from SATLEXMB04.amd.com (165.204.84.17) by DS3PEPF000099DD.mail.protection.outlook.com (10.167.17.199) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.7741.18 via Frontend Transport; Wed, 3 Jul 2024 21:49:55 +0000 Received: from bmoger-ubuntu.amd.com (10.180.168.240) by SATLEXMB04.amd.com (10.181.40.145) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.39; Wed, 3 Jul 2024 16:49:54 -0500 From: Babu Moger To: , , , , , , CC: , , , , , , , , , , , , , , , , , , , , , , , , , , , , Subject: [PATCH v5 09/20] x86/resctrl: Initialize monitor counters bitmap Date: Wed, 3 Jul 2024 16:48:20 -0500 Message-ID: <28866653751deb8405f575e40df6f08affdb25d6.1720043311.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: SATLEXMB03.amd.com (10.181.40.144) To SATLEXMB04.amd.com (10.181.40.145) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DS3PEPF000099DD:EE_|LV8PR12MB9452:EE_ X-MS-Office365-Filtering-Correlation-Id: bb394016-aa05-4fd5-b993-08dc9baa13e0 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|82310400026|1800799024|36860700013|7416014|376014; X-Microsoft-Antispam-Message-Info: =?us-ascii?Q?8tRSCxYiVy9f57xYsJkhpUFpS5gmxbRXP0PxhnJgk4TXFT4zcsdvuwhbQLQv?= =?us-ascii?Q?5f0wbxLfy++4KwRhoHXut2oFqVfq31gpTQRGXAy847bg3uMWJb0TnOWvhTDG?= =?us-ascii?Q?JMwA6l6Pdf/vHBPQxPIo2gOe2PauVG9kZycYEgzjdE0P1DMMiOyoqYdcWp+A?= =?us-ascii?Q?32AcR/FKq2N+bfZpk8yz8hTM1F8N5CqBSPVT9pGn/yYRZw/ODRZXnaYkl9ac?= =?us-ascii?Q?imKABrf+J+M0aiGZxH0sFh4MhK9hoECuItM4vMMngl/aWyCDPJ40BcUy7rex?= =?us-ascii?Q?U4QQSeIMj0uAWk5C/VHHImMdY5973Yxkp9l+uPxuzRXsJ3qXu3OZUp5K1Nxn?= =?us-ascii?Q?mABqraGttqtIjE4qFQr7pPdcZX+tFR/0Jd9UNM6jjReL5DORL3wcx7Ei7Hit?= =?us-ascii?Q?guHXkqcEAaro1bcK08GLVmmF08dk/ZZuusq4aT3bEXWpNTOXs9KtdTqs6oCd?= =?us-ascii?Q?xw1ZD42RaDyxIWygcDLm0SPXX+mDyeTMD210X2ykqE2umVLEY9xGvrk7CrRU?= =?us-ascii?Q?Gfkme9ROtlINgmih8y4qSx44V4jT/48lbGzZOGtAteF7L9U04nEUvMFUhn1S?= =?us-ascii?Q?/O1aAM7bFLxGqIRJygBXEMMJu9+MEVfYYw379k2/UtBTltlKvmREErrpeYiZ?= =?us-ascii?Q?hb4JFaoyuNu4UobU36IdFu23MLs/qZQVXVGD88NmLr5tLC/F7FqorAmNUvfc?= =?us-ascii?Q?91pmFkw71HE7LrxxO7nk9vGrjQYexOTD8Ac7b077rFFKNvv/1HMKbPKQgLJ1?= =?us-ascii?Q?Q1hziCgYtUlHik/In9WtgReakdmCMHTEM26vSyyl/lXMjzeMCGsYXb9hpb01?= =?us-ascii?Q?sgyphScPFYBjdFMrqIeGymUt9FQv3zCdmPyuvN4Jl7iR/mGAcHL3N7jMROE0?= =?us-ascii?Q?QqhhPXwQN+7K7JMLNNjPUxBMd8yXKIkwjmKN+RReObD637jIsZWuMQOwR9vD?= =?us-ascii?Q?8yw59SBV7DZ1Ohh1AkbEoTSnTP3mSuVkgjKoonLd3IVUtbtR/E5n8TDXQ/dj?= =?us-ascii?Q?q/Bp8EGNUFn+cr9ItRWcHrwYLKUdu1lDu/TlWRxr0WFyK/z6oCdX2+tCXUKP?= =?us-ascii?Q?B1Z85eilgVxHLNP7l8v7vzRpsszgV7TWn0adtTdCtFmMW52OnyZ9iPFPOoSc?= =?us-ascii?Q?pVYkdqT+8scNvaMIYRQv8pJIZcJKKGXdCYHmGKNJm7/qz/yzIVZrr125aanL?= =?us-ascii?Q?GnHVkpSFrRPHPAG7065Wogs4CPdESGzCFTn7zrYuXawAcNsx5DUp7jPZANC3?= =?us-ascii?Q?MOTmxM65h9begXbs3I9GEJId8zJPFuixmOE728ygPuSjMDXqOnLBdjyFd3uV?= =?us-ascii?Q?Tisv4aRxkhzJ0MmWIJPBL4KGO2DMcBu2fKTQn2REwVuAcMTxg1jsAKAWS4hh?= =?us-ascii?Q?tb5oXnez0KnTtX/0k3vci0Rz5W1ov199yiITEL88g/b+/vd+Ms2+tToGNDAZ?= =?us-ascii?Q?UD+zEfo+Ea/y7457z9X9TwBYST+WKNT3?= 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)(36860700013)(7416014)(376014);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 03 Jul 2024 21:49:55.9070 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: bb394016-aa05-4fd5-b993-08dc9baa13e0 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: DS3PEPF000099DD.namprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: LV8PR12MB9452 Content-Type: text/plain; charset="utf-8" Hardware provides a set of counters when the ABMC feature is supported. These counters are used for enabling the events in resctrl group when the feature is enabled. Introduce mbm_cntrs_free_map bitmap to track available and free counters. Signed-off-by: Babu Moger --- 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/rdtgroup.c | 29 ++++++++++++++++++++++++-- 1 file changed, 27 insertions(+), 2 deletions(-) diff --git a/arch/x86/kernel/cpu/resctrl/rdtgroup.c b/arch/x86/kernel/cpu/r= esctrl/rdtgroup.c index 4f47f52e01c2..b3d3fa048f15 100644 --- a/arch/x86/kernel/cpu/resctrl/rdtgroup.c +++ b/arch/x86/kernel/cpu/resctrl/rdtgroup.c @@ -185,6 +185,23 @@ bool closid_allocated(unsigned int closid) return !test_bit(closid, &closid_free_map); } =20 +/* + * Counter bitmap and its length for tracking 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 unsigned long mbm_cntrs_free_map; +static unsigned int mbm_cntrs_free_map_len; + +static void mbm_cntrs_init(void) +{ + struct rdt_resource *r =3D &rdt_resources_all[RDT_RESOURCE_L3].r_resctrl; + + bitmap_fill(&mbm_cntrs_free_map, r->mon.num_mbm_cntrs); + mbm_cntrs_free_map_len =3D r->mon.num_mbm_cntrs; +} + /** * rdtgroup_mode_by_closid - Return mode of resource group with closid * @closid: closid if the resource group @@ -2466,6 +2483,12 @@ static int _resctrl_abmc_enable(struct rdt_resource = *r, bool enable) { struct rdt_mon_domain *d; =20 + /* + * Clear all the previous assignments while switching the monitor + * mode. + */ + mbm_cntrs_init(); + /* * Hardware counters will reset after switching the monitor mode. * Reset the architectural state so that reading of hardware @@ -2724,10 +2747,10 @@ static void schemata_list_destroy(void) =20 static int rdt_get_tree(struct fs_context *fc) { + struct rdt_resource *r =3D &rdt_resources_all[RDT_RESOURCE_L3].r_resctrl; struct rdt_fs_context *ctx =3D rdt_fc2context(fc); unsigned long flags =3D RFTYPE_CTRL_BASE; struct rdt_mon_domain *dom; - struct rdt_resource *r; int ret; =20 cpus_read_lock(); @@ -2756,6 +2779,9 @@ static int rdt_get_tree(struct fs_context *fc) =20 closid_init(); =20 + if (r->mon.abmc_capable) + mbm_cntrs_init(); + if (resctrl_arch_mon_capable()) flags |=3D RFTYPE_MON; =20 @@ -2800,7 +2826,6 @@ static int rdt_get_tree(struct fs_context *fc) resctrl_mounted =3D true; =20 if (is_mbm_enabled()) { - r =3D &rdt_resources_all[RDT_RESOURCE_L3].r_resctrl; list_for_each_entry(dom, &r->mon_domains, hdr.list) mbm_setup_overflow_handler(dom, MBM_OVERFLOW_INTERVAL, RESCTRL_PICK_ANY_CPU); --=20 2.34.1 From nobody Sat Feb 7 21:14:47 2026 Received: from NAM11-BN8-obe.outbound.protection.outlook.com (mail-bn8nam11on2089.outbound.protection.outlook.com [40.107.236.89]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id B896F194A66; Wed, 3 Jul 2024 21:50:11 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.236.89 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1720043413; cv=fail; b=Irt7w0PUb+UyTTuuwC8qBpdhUzLXVGGCStgSzxmdAg7SUxEViGOch2lfVx8m6EGmu20byPLmCdiFLbVlFTQs5y2X9yGRNejOTG/bhztiHN8DSLuuA60CoG7fjeUqxUA9IdnQ8ffO+7psgdWEdTnw9ZR29vhfFcOht2RJ+HCWhE4= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1720043413; c=relaxed/simple; bh=QA6xzUGhXw80Ls4wj7GG77b8I6JaGxMVrjb0TSvzLjo=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=uwAaUZHgXVwbYg/ImmwIkMoHAWxigZzn8t5TBcS5XCcR4cYvv+g8ZagD7fPuKrDcw6+yvqDbUgUW4iJNkptAW4JGhwuwTl8B3gk5exyIC+lYMFjUqkVI3RDK2faJ4kjX/ZiY1qwWVyXbbz71r7ZufRrSjfOzq1If4HSVHR5amro= 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=2qOo6Buj; arc=fail smtp.client-ip=40.107.236.89 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=amd.com Authentication-Results: smtp.subspace.kernel.org; spf=fail smtp.mailfrom=amd.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=amd.com header.i=@amd.com header.b="2qOo6Buj" ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Pv74cYaWw25k3RfB2aZzzVmoe6c0SU/6yzeLrAxR3PxpwcVeJCsKps13M+DUd8NDkGVjcLDD34CQ3344uw+xzd3A78hAFTCtt9VAD1mVmeRdmLMM3g3UmpBL3YITeNajdSRrRgmTlG58lIbz7PXOUm7g1MSTYaxIf1KMs/MI26/qNCf/43rp1mhy/QpgSRBHLFTZu1fM9+G7opOtokgcJf9+N3OtpUBQJ4FvV7xuCgF+o0xp5Hfk8q9ctiQX4cH9MhD2lGXNdNLq1cv1bw3nYOJEEfKHCpCBK1DZJUln/Lq5JWLYtJg73rWswXzj9Q1Pds5McyD6Z6GOuq0zPpEkNA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; 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=gG8PlnCkarpGFCTQcIWsmfHAbayM+scnDA83UKDljvw=; b=PVF6OwpX9/J+yQ/HHp/ym2tk4zjokaadsuYh1yULG3jLdj5U6RI05fnhTlpgcEsOgQTHB8wF0X5r1jMMXah6ggyI0xLZ2+RM8N60/8G6pRkqvB2GcaSLd17Qjt7oba2ltxHgaQczO3cbGYkELUOZtoLzd5Aw8JKBvnJPDcMbqaKeVsduW0E7+XK5IocyKzWsoVPg4rZa4pkZg90JRoTMNDH1EHN4/QRktjDGvHRTlR3wCXCGXtG1rD0zIwYn6GA+TM0mwTv1aeaEDTRWkU2u9E4lCUOUsv1R1f2moA4967qjT9x1K5UCThFTYMNL0RCL9iN8sruqR+uW2bRZKHwVNQ== 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=gG8PlnCkarpGFCTQcIWsmfHAbayM+scnDA83UKDljvw=; b=2qOo6BujU4w9I2QKy5TBEH2rutYl3YHIU+5LIsg6tyj5UsCt5Ydwvq2D81FHOgpo8RpGrFL7pI9lpXniL8yQT9uuncD3PF8UA9KT6CjAb/CCDOoU5pFy8bhjek8uavdqWbbPTTB0xU+xL56/Pr7ErbN4NPJC+S3X/B7ZRYpgFZk= Received: from DS7PR07CA0022.namprd07.prod.outlook.com (2603:10b6:5:3af::24) by PH7PR12MB5685.namprd12.prod.outlook.com (2603:10b6:510:13c::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7741.25; Wed, 3 Jul 2024 21:50:04 +0000 Received: from DS3PEPF000099E1.namprd04.prod.outlook.com (2603:10b6:5:3af:cafe::25) by DS7PR07CA0022.outlook.office365.com (2603:10b6:5:3af::24) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7741.25 via Frontend Transport; Wed, 3 Jul 2024 21:50: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 DS3PEPF000099E1.mail.protection.outlook.com (10.167.17.196) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.7741.18 via Frontend Transport; Wed, 3 Jul 2024 21:50: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; Wed, 3 Jul 2024 16:50:01 -0500 From: Babu Moger To: , , , , , , CC: , , , , , , , , , , , , , , , , , , , , , , , , , , , , Subject: [PATCH v5 10/20] x86/resctrl: Introduce mbm_total_cfg and mbm_local_cfg Date: Wed, 3 Jul 2024 16:48:21 -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: SATLEXMB03.amd.com (10.181.40.144) To SATLEXMB04.amd.com (10.181.40.145) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DS3PEPF000099E1:EE_|PH7PR12MB5685:EE_ X-MS-Office365-Filtering-Correlation-Id: 0f6efcf2-a703-4f25-ff55-08dc9baa1891 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|36860700013|1800799024|7416014|82310400026; X-Microsoft-Antispam-Message-Info: =?us-ascii?Q?WzB1U7EI6H0DU0in4wxZm2r690+EQRZwQ/R6HJjSCu3Cug0Pvwnw1czKr3dB?= =?us-ascii?Q?Yq1os93HGzbHNZeniXsuFsAXWmbmUeS/1a+bVeENqXv3gShy0zjNtpc4QK/2?= =?us-ascii?Q?YAdyTbjkfxyrjuCuWLkl23qeqGeLvfR1JLFuMbr2uKCkGPu3QCgim4V9oRWN?= =?us-ascii?Q?5Kp6FOF2rXAUdgwvGMvSNWsBIosg8hNNRVvsYU7u9EhR6m7XZhdhEbELJuxM?= =?us-ascii?Q?FWp2g0M0g2BGrk5226pmz37GY8ik6dTndOe+yeAMs1dEkgqzphmlE/jvAN7C?= =?us-ascii?Q?lsLW9uR+yA1WQvvHHBIfPnZZoXjSbSk0JVplif8E+DzyUkR0LYsD9fLKmjpL?= =?us-ascii?Q?t3dl+hk7ey7SOVSmlENvbhbs0RW9EY94bbe936RaHBnDb6/wRhcjrtp5M4TE?= =?us-ascii?Q?eMoQzEGni984wPVB9XNw8+beQ4UQodmi7cB5kE9g0vV1T7fpTgs6gJJVS6Et?= =?us-ascii?Q?T1ZkRCjPyUpeQcTKJ8lyHyCgDX2HqnG3mKg0lhmEzNPj+Hz58FN7aMGyT3xI?= =?us-ascii?Q?sTyX0Ezs24WE4UMmNz/UczCRoPtdytm0tRN/oihIQ/z+PwjWH30J6JT1Q5TY?= =?us-ascii?Q?i19dIVpPTcbmPOJW6RJa3ruBrnhuHUO6RsjINd/qqk5dtwoo9aA47ujXKz7k?= =?us-ascii?Q?1d4y8LVkKpvzj2TygUj5vcag8dQ++NAG0/8SDyJgK/8kYbWqvPSUjOZYbnYZ?= =?us-ascii?Q?I6ETaxSpOF4v3+H2/oY5DP6NLnG5lVq12pfmcV85bMvIwZ0+q3+5+dN6dS83?= =?us-ascii?Q?y3AiEF0xEc1OrauimJgW567t0Arol6T0zGD27RJJNWPyTr5rDVBCzU5MSNiJ?= =?us-ascii?Q?ugi9QkXsnlEkHi5b3US+pQqRivFXdMyhHF+rS1pPriRx9Vle4FPzh/xXtraB?= =?us-ascii?Q?rQL3dsJLRl0iJxUCHWacE0WVRqO1vvsB9Qf4KXqtIPeyp4aMjXhBYSEcSFDr?= =?us-ascii?Q?kB0BlL1Fi/bymv0CsHjKozZ/s2ZphbFbEbRIyF5dIvFm+w5bMPLAIsMtsNwq?= =?us-ascii?Q?K1GPDIVxtTTdmB68V/xu4ohaj/BMzVUs4ouZKmW9gq/K2iDMZnuTTsmAUXwe?= =?us-ascii?Q?8npTzrrmtcu5e4sBUM17a1Tv93aa9W9q4g8pDq1pUeWEWDbefcZqBBYn3EIC?= =?us-ascii?Q?et4Iajj85L28vqsRPtxY7a5mNnpkAzvjjisgejj+fUw3rU9hXVPndyLcA0Rl?= =?us-ascii?Q?zgGQhzO5lrwYaCzeKpJaYdSTyUKv80x4HysNd17WTnEe+7t9eK3R0Gvms8FC?= =?us-ascii?Q?PFcNwXTZcLMO/udYZ+q4yrapYo55FmJVRuw34oiOPw5YgYYJXNHZJB2SMGKN?= =?us-ascii?Q?LM34bMFKHVINr0KEZADpaHjPRQaA9lsu+uEWtmhoJeJn7td4exX/2D3A5RSm?= =?us-ascii?Q?3BJI6rd8u19msvvrj481NMwDJmZMIyDBZf64yHWHImZjQABmdAYoUBTvuC5r?= =?us-ascii?Q?y6lis0HOwFo=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)(82310400026);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 03 Jul 2024 21:50:03.7640 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 0f6efcf2-a703-4f25-ff55-08dc9baa1891 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: DS3PEPF000099E1.namprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH7PR12MB5685 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 the rdt_hw_domain, so it can be used for counter assignment. Signed-off-by: Babu Moger --- 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 | 6 ++++++ arch/x86/kernel/cpu/resctrl/monitor.c | 22 ++++++++++++++++++++++ arch/x86/kernel/cpu/resctrl/rdtgroup.c | 2 +- 4 files changed, 31 insertions(+), 1 deletion(-) diff --git a/arch/x86/kernel/cpu/resctrl/core.c b/arch/x86/kernel/cpu/resct= rl/core.c index ff5cb693b396..6265ef8b610f 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_arch_mbm_evt_config(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 0ce9797f80fe..4cb1a5d014a3 100644 --- a/arch/x86/kernel/cpu/resctrl/internal.h +++ b/arch/x86/kernel/cpu/resctrl/internal.h @@ -401,6 +401,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 +410,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) @@ -662,6 +666,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); +void resctrl_arch_mbm_evt_config(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 7a93a6d2b2de..b96b0a8bd7d3 100644 --- a/arch/x86/kernel/cpu/resctrl/monitor.c +++ b/arch/x86/kernel/cpu/resctrl/monitor.c @@ -1256,6 +1256,28 @@ int __init rdt_get_mon_l3_config(struct rdt_resource= *r) return 0; } =20 +void resctrl_arch_mbm_evt_config(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; + } + + 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; + } +} + 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 b3d3fa048f15..b2b751741dd8 100644 --- a/arch/x86/kernel/cpu/resctrl/rdtgroup.c +++ b/arch/x86/kernel/cpu/resctrl/rdtgroup.c @@ -1606,7 +1606,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:14:47 2026 Received: from NAM10-BN7-obe.outbound.protection.outlook.com (mail-bn7nam10on2061.outbound.protection.outlook.com [40.107.92.61]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 90EEB194A66; Wed, 3 Jul 2024 21:50:19 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.92.61 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1720043421; cv=fail; b=iz648ePigDTOrQY7JgyhP9FIXKwvTQjv0pqNHmaf6zqloxvyXdNf/6shptmAjPFo3wClY+mC7v2ddwmrNsdfNxiR0lsflhztB+8cgZg4YzGX7d/fWYocsspcLC7iizE9JwHWG9iprbUmccwNbwSGR+QzNDAP90LRsPeQ+OhhZFs= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1720043421; c=relaxed/simple; bh=2PWLq78NZ6Xq24cKpkfwlTtKGT4Ly0m1wEmSDYtNjsk=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=O4xKc1Qd5jd68fJ8XQ91nOETHHo43KYRFAMR1Iy4R3wcn8qj/AT0xcuRLWcFevb9Am760RxOvsd6cvObpelijEeblPGAHnt3tCOj2DOowUmhp5CTv5+C8EjMu8LQoFHtxI+8qgEIclogsmC0mviQRp0+Giw0DXzJbwO8UKaC6pg= 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=Xom7nzrO; arc=fail smtp.client-ip=40.107.92.61 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=amd.com Authentication-Results: smtp.subspace.kernel.org; spf=fail smtp.mailfrom=amd.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=amd.com header.i=@amd.com header.b="Xom7nzrO" ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=aOWzKEqkrNJfTCHfWqt6hetAL2U35vWpjpiYCMO5s9PQr6RcngD5H2RQdnP6Tqu+VrZK/KBPVIOMGhJxEppFnzNUSxCSVPCxPXrbfSnib3YeJFgAlgUu0YJR7E3rqw68Wn59C10CmUgp52gx/N3q86PpFWxZMBSYN2pm+u4ZVCFojbqOnZ+WCadeJEC+BS9DOW3bEppuX8x+gVCGn2US/fwWRSWjIXSJiVimFVh6gtPkFEolsm77sojvzSWnyFVBkvl2tsGRcXXAfzRo62qBxeUfYnUTA/eNGYtnsnK8R1QvNhIhn4/OQ/+vo02ART6JXKeXoGNYyILqX5dH5i3kTw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; 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=ZMIaxpPoF+o2vqLCnBKaK3fIqX5OWC9KpObp/1myZfU=; b=UPUGghHQLTYhvXjJn7WSAheFQCwxd3TOm30PmrLtsA9yOSoYsQE1++pxyy7oIkJyu5pXonSp0bAQyX9KuRvnTwYo77kwd/qedIofsze55WzcZ1BGrC7UrmZ8oxpL5jXLnjwA0HI4AnIkE9tgD1VIw1lit88ITAmhd7UhSz6RJg6rbbs3/wM3YgDEjNe7Cz7pVIqo5bDdFIqJdOiRpk7Vxdni5UJEQaUmh82Zt6BEKg0uql19IkVFhoGaWa89Uq4TOita0hUQI+bF2LtM6XEgvH6H2wU1pgb151Q0t0E4IkwqzwWnx36sbhFqjAO2yWBT1TIbqYeYZ1ruOb9oM0R3Eg== 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=ZMIaxpPoF+o2vqLCnBKaK3fIqX5OWC9KpObp/1myZfU=; b=Xom7nzrOuNXbrkQY8GmKEPkL1ltufroz1OcTH+pDyoKYnewzg7R9XbF1Xi7T0Ux/FdBG+W1OMPC0mt2Ssp3RfV1HmsD9GfFpX2ws1LCGIfl3BOmQ8dO5stBw1iO8Xuey/YzJFEAl/1r6ei+LnpnzsOxGaNIe4+/88RItpUrgO0M= Received: from BYAPR04CA0026.namprd04.prod.outlook.com (2603:10b6:a03:40::39) by CH2PR12MB4199.namprd12.prod.outlook.com (2603:10b6:610:a7::13) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7719.36; Wed, 3 Jul 2024 21:50:13 +0000 Received: from CY4PEPF0000E9D9.namprd05.prod.outlook.com (2603:10b6:a03:40:cafe::99) by BYAPR04CA0026.outlook.office365.com (2603:10b6:a03:40::39) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7741.23 via Frontend Transport; Wed, 3 Jul 2024 21:50:13 +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 CY4PEPF0000E9D9.mail.protection.outlook.com (10.167.241.72) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.7741.18 via Frontend Transport; Wed, 3 Jul 2024 21:50:12 +0000 Received: from bmoger-ubuntu.amd.com (10.180.168.240) by SATLEXMB04.amd.com (10.181.40.145) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.39; Wed, 3 Jul 2024 16:50:09 -0500 From: Babu Moger To: , , , , , , CC: , , , , , , , , , , , , , , , , , , , , , , , , , , , , Subject: [PATCH v5 11/20] x86/resctrl: Remove MSR reading of event configuration value Date: Wed, 3 Jul 2024 16:48:22 -0500 Message-ID: <82e8c5c888220b7659d7cd57fb291412ba62b120.1720043311.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: SATLEXMB03.amd.com (10.181.40.144) To SATLEXMB04.amd.com (10.181.40.145) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CY4PEPF0000E9D9:EE_|CH2PR12MB4199:EE_ X-MS-Office365-Filtering-Correlation-Id: 33bd312c-21fa-4933-21d8-08dc9baa1ddf X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|1800799024|376014|36860700013|7416014|82310400026; X-Microsoft-Antispam-Message-Info: =?us-ascii?Q?iwm++pE70fo1/GYceZfkF0XHdECPpA03eV4YmF8VqwvtIepNm3jS5wlX+aGR?= =?us-ascii?Q?z2Ds+2qJ3s0qKJH6DMyGim/nswq9KZipNYqYdOqEzyMf2vEJXrDaDXD0t8ew?= =?us-ascii?Q?wyFuWRmMxvcZJhQIrIKcljRQUbqMPNhkRo1QvyLj8+uiz/rT8TpT79pMf9f9?= =?us-ascii?Q?xcIOb2V4iR/KzlN4xzoPHXVVCdzc8ocdP6t8KZv+jLAuHlmXmOgOwt+se5VT?= =?us-ascii?Q?gTk23Q5Uytc1frWJsWwTHDv+tEAECd+EhmuugU9gKkHDTufNKWXRghjPDQZF?= =?us-ascii?Q?yBTMm2MgvGLElr7BIRW4HcgRNYpdjCJtIFg1zHVF/XFuPlVoWFc3t7EvLQOn?= =?us-ascii?Q?CsGJcFCZUSZp4F2NB4NaW+ZyjxC3+ZL63kfX3s6oH2kmGBebYFlfK0/+2IXk?= =?us-ascii?Q?1bzgYBBxQcPkrTfP2JHbTWSI2F5lU3B8cmEq/ALjM5cGjWJQ8UcWpuFUbgWr?= =?us-ascii?Q?grAyhWNH4tkWcAeawoKTUjvvV2Ua2RkkkvT8rmrxvaEF7v9TjlSg2j2O/Ul9?= =?us-ascii?Q?nlX2kRNSG9IPz0yvOgopElaaSP0uEgyMBY5JleJNZVXDMzs0s5BrUVQ9EReW?= =?us-ascii?Q?uOK+uhxd/kwSlo/hsGfHfsuJkAAx6yf7u6FGrL2SnEr67/GLcI8UO/19BCji?= =?us-ascii?Q?BRBGpwZZ9etgzTuLPr4Q03h5kAWs1UsjyY1HRDd9MgpnmawSM9SkHJdyka2w?= =?us-ascii?Q?hi25qIR93lgdU2yamkNaZpr/kYArKbxnjYVDmCXsV4gvKeerIXJh1dz5xljZ?= =?us-ascii?Q?tBIjRTUHs2WfwEyEGNAsNib68Nb01QWwkHR5LFk6I1ir9OwIVyXZavcsMHdC?= =?us-ascii?Q?yRsiNxV7zJPr3GVwcCo6yXTJ+hzTDvdpkoDjRUdCadoDODX4aukX5Qvb2eBk?= =?us-ascii?Q?nL9HfWrufNvmXfa2EMB31cSEfFgeYA7fkvyu/FSoOCu0zupiw+yAjPq+OFOy?= =?us-ascii?Q?2BqZMls2iu07ofpyx3Ojj+mcyNT/MkVki4lzr974dSiE2ilDRebyIPASMGa0?= =?us-ascii?Q?+8LvlO5DO9vRT7jtdd9H2iCxVvkEJYNealfNjsBVf4d4Un0ea801/ic4RVbp?= =?us-ascii?Q?BMfFK16NIf4Lo9E7qp1OQA06PupcIt6y8hHq7MfrHxY3zO/jYf65U7ahZoIg?= =?us-ascii?Q?wkSnMF3l4x+QE+78l0O9gpBRMH5oIMLHlUu1koQk8DDHmo82eQtq2JouuybP?= =?us-ascii?Q?nk/ghzRLHSE9c9YqmqJzJKFLUjPpWmKACNuprbyGKeHb+2KC4nySTG9XWmfe?= =?us-ascii?Q?z5TgXYBCKbASeBbZ60x1EK1RvBZBTO+v3e1KFQUtEB4M2rmc0DMHTIzINPiP?= =?us-ascii?Q?ZmNRuZyN5kOGPmncDe7AITG/7gziRuvPYVm8JDgUfe37myuO+ygvb6aoZgAC?= =?us-ascii?Q?b25g0AdA7qQ1ohhWCfvIpADHFzl8KnAcJnkPsQwXNY0BoCewTQ=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)(36860700013)(7416014)(82310400026);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 03 Jul 2024 21:50:12.6425 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 33bd312c-21fa-4933-21d8-08dc9baa1ddf 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: CY4PEPF0000E9D9.namprd05.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: CH2PR12MB4199 Content-Type: text/plain; charset="utf-8" The event configuration is domain specific and initialized during domain initialization. It is not required to read the configuration register every time user asks for it. Use the value stored in rdt_mon_hw_domain instead. Also update the configuration value when user writes it. 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. Signed-off-by: Babu Moger --- 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/rdtgroup.c | 112 +++++++++++++++---------- include/linux/resctrl.h | 4 + 2 files changed, 72 insertions(+), 44 deletions(-) diff --git a/arch/x86/kernel/cpu/resctrl/rdtgroup.c b/arch/x86/kernel/cpu/r= esctrl/rdtgroup.c index b2b751741dd8..91c5d45ac367 100644 --- a/arch/x86/kernel/cpu/resctrl/rdtgroup.c +++ b/arch/x86/kernel/cpu/resctrl/rdtgroup.c @@ -1591,10 +1591,59 @@ 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 +#define INVALID_CONFIG_VALUE UINT_MAX + +unsigned int 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_VALUE) { + pr_warn_once("Invalid event id %d\n", mon_info->evtid); + 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; + } +} + #define INVALID_CONFIG_INDEX UINT_MAX =20 /** @@ -1619,33 +1668,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; + int val; =20 cpus_read_lock(); mutex_lock(&rdtgroup_mutex); @@ -1654,11 +1681,13 @@ 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) { + rdt_last_cmd_puts("Invalid event configuration\n"); + 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"); @@ -1689,33 +1718,27 @@ 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}; + int 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) { + rdt_last_cmd_puts("Invalid event configuration\n"); + return; + } + if (config_val =3D=3D val) return; =20 + mon_info.d =3D d; + mon_info.evtid =3D evtid; mon_info.mon_config =3D val; =20 /* @@ -1724,7 +1747,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 62f0f002ef41..f017258ebf85 100644 --- a/include/linux/resctrl.h +++ b/include/linux/resctrl.h @@ -352,6 +352,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); +unsigned int 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:14:47 2026 Received: from NAM10-DM6-obe.outbound.protection.outlook.com (mail-dm6nam10on2049.outbound.protection.outlook.com [40.107.93.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 7E50519AA75; Wed, 3 Jul 2024 21:50:23 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.93.49 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1720043425; cv=fail; b=LcsHVQ3aZnDrtfKh6XaRxXZJe5+WPHvBbUc9gXpUtXsuFbowi84BhYXrkXwsTcIzyYnFaE6MxUNS+Av6YxeEMTrEoXlcMqMGZ8EPtImTpGmP8f3eAVfJOpnlh1LN+uIb6GlxpjaxOlU4EuvdbPN/eAsABJ7AO60jL6kw3K4m02I= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1720043425; c=relaxed/simple; bh=7lV7MB2lP+UzWuY7xVl9JQN8Kc8+d5BzbamUIdhS98E=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=iVqFC3KnGrY6E9r4VSDuqYsF84MvAe6td2zXPhs1Bgi07bGjQvsndF0Reweup0VdO7/IUHPiEuYjVq716685ZJvcvSjgh4kwuGNDk5Jasm1DfYqtudzipIq9onZzn7WZfvSoUm+AxnWFdEvwLvvbS2+h8gFP0CKUbAEd/nqBy1Q= 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=yRWvjTa8; arc=fail smtp.client-ip=40.107.93.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="yRWvjTa8" ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=AHalk4Tm2mdkb36AMFV1H5jNBeSeq06zyUq/uhjUsY1Hst1E7oNrFpF5IP+8bRS9FIoqt11teAQmG5CvJJGck5HbyFV3yHc3V9xvF+OhiQKnNbE3KdNXoVTpXv6lwCONijuZqAu8UuoXhQ5q8pR1W1tFaSu/5TottjKake5RtbGacKtlPr+9cs3k4eTPlYpig5Do7duTKDdoGTOrE73iRUCywLz/6D/Nu3MND5W2dFUuFO08qoow4xXCGHZ0T/9PlaD2RtbSmehCH8Yj/Zios8S7air/SIEjIfV+zNDUf7pCl+PEn1WmvPbhyY1R8WNH/+ZV3guSRLMFG9uXJH/CrA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; 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=waMoxOkYqoYygQWCPIxEkR8KrW1ZK8vcJbArrbtbbYM=; b=LVkqRW8edMsJx/rEMdTLF+4RvUow7JJH/QDCqyScIcP5a4C1tYf8XQFE8wqNJMOGnvIfS+vRPAEQJ+h158jbUi+7NzHhRqe9han05KSaQE4/a3hKRXzuILGYBfX6k7T8tWcvGY01x9mmulJpDAAPHhXwIig3HBdcjo0B5Zcgm3OGGRljWYa7/WP8g8HqfHPPXk4RrorvuHg2+hAhQHMnmmo9rlfUITHo/DQR3J96B2AkBxf+7aLPbgeq7OqEz8geHd3g6DuCU86Bo3PHPblOCt6WqVBmL5djLf0lVHAeIpIOBz+X+zUPHLj0ND9ZvOv6YQ877hv9kyxWPPabW44ghQ== 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=waMoxOkYqoYygQWCPIxEkR8KrW1ZK8vcJbArrbtbbYM=; b=yRWvjTa8vp+u3ykJeo1zg3AmJeXzTzqHRXU6jWzvcRRTcbX94Rjv5RrId3QSD7nPhLewXZzwRN5w8YwSiSbNJHhVJQYOuV51icAunxEj/PfMB0OYvYEuL6WNsDtXvBEmMh2ywlLYeCxVWdpABMtW2zUSDQHGeA239l+ZhQP5so4= Received: from CH0P221CA0003.NAMP221.PROD.OUTLOOK.COM (2603:10b6:610:11c::7) by BY5PR12MB4291.namprd12.prod.outlook.com (2603:10b6:a03:20c::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7741.25; Wed, 3 Jul 2024 21:50:20 +0000 Received: from DS3PEPF000099E0.namprd04.prod.outlook.com (2603:10b6:610:11c:cafe::8) by CH0P221CA0003.outlook.office365.com (2603:10b6:610:11c::7) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7741.26 via Frontend Transport; Wed, 3 Jul 2024 21:50:19 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 165.204.84.17) smtp.mailfrom=amd.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=amd.com; Received-SPF: Pass (protection.outlook.com: domain of amd.com designates 165.204.84.17 as permitted sender) receiver=protection.outlook.com; client-ip=165.204.84.17; helo=SATLEXMB04.amd.com; pr=C Received: from SATLEXMB04.amd.com (165.204.84.17) by DS3PEPF000099E0.mail.protection.outlook.com (10.167.17.203) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.7741.18 via Frontend Transport; Wed, 3 Jul 2024 21:50:19 +0000 Received: from bmoger-ubuntu.amd.com (10.180.168.240) by SATLEXMB04.amd.com (10.181.40.145) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.39; Wed, 3 Jul 2024 16:50:17 -0500 From: Babu Moger To: , , , , , , CC: , , , , , , , , , , , , , , , , , , , , , , , , , , , , Subject: [PATCH v5 12/20] x86/resctrl: Add data structures and definitions for ABMC assignment Date: Wed, 3 Jul 2024 16:48:23 -0500 Message-ID: <236652202801ad8760d6828ee4d4c6f91d009884.1720043311.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: SATLEXMB03.amd.com (10.181.40.144) To SATLEXMB04.amd.com (10.181.40.145) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DS3PEPF000099E0:EE_|BY5PR12MB4291:EE_ X-MS-Office365-Filtering-Correlation-Id: b53ea900-6aed-4e87-66d6-08dc9baa21fe X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|1800799024|7416014|376014|36860700013|82310400026; X-Microsoft-Antispam-Message-Info: =?utf-8?B?R0w0V3p0cGVoMTUwMFEzWEw5U0NkZHhYWmJUc2NNQU95TmhzRVNSa3hpOUZP?= =?utf-8?B?ZzYyK2xpZVA0UEdITUZSaklUWEFHd25Vd05odFIvTEFuenlEOWNzQ0t2Y0My?= =?utf-8?B?V2hZWllHb21ZVDBJMW5sSFdCQzBuZGNwNXVkZUczZE91OGRLdXhwcFRPdFNB?= =?utf-8?B?N1FoY3ROMERhNnFLQWloWXVFMEhzR2dqck9XYzluMXU1Tkd4bmtUV2ZBcmJ0?= =?utf-8?B?MzRKRmkxMXc5VHlyWnM5RmlMNHovdU56MGFzTUlVN0N3TmJnN0d0VHAxYzBK?= =?utf-8?B?OHNiWGlMZ1pMbDlBeEZ3UGxVQTB4bkJMVXhReEhsT1p2VVlIbkdHVllGK0FF?= =?utf-8?B?cVNUNDlzei80SVRwaU5FeTRRYWhDbW1iR1hlR0xYRllKSzVsU3ViK21FekpW?= =?utf-8?B?cnJ5RHN4bnlrNEFUQjc5VVRaek10UDh1dG03eHR3cEg2eFVGbW9HNElmR3do?= =?utf-8?B?NXMrR1V1NXJtSVMwbWZtRGJhYkZpYS9UZ3EzRUMrTWpwWCtRWG96SEswcktG?= =?utf-8?B?eU1PMDdQMzd5OVliR3phRW5kVysvRmJhUU5rZGs2OTJJS3dYbC85WTU1aXl5?= =?utf-8?B?L2lDb25YL0tpL05NSjMyWlh5VitONDdsTXRQRlY3bUhqTkZrNjI0NExqZGxY?= =?utf-8?B?UW50OWw1THpReDJpaGRaNklrejU3MjZ0YWN5d3U1NlNBWkxTMGc3SC9ycngr?= =?utf-8?B?M3BzVmZLS2J2RFJOZHN4YjA4cmI3T003Z0dIN29xd1VpSEczVGhVZVBYa2c1?= =?utf-8?B?L2lWOC9iZkI5WjJUblRGa3poTXB5aERPenJXQUVPSTJsS2dQMUgyVEI0NGkx?= =?utf-8?B?V0lNcTdBUER1cUlTcXk1Wk5GK2t5Nlc1QndnZ2xNVE5XU2ZINTgrSEF6V2t4?= =?utf-8?B?b3paaEVyeStkKzI0aDIxTWpzQVBYYlhUc0xsdXhta3BnSHFzSVowbHMwZWUx?= =?utf-8?B?ZDV2M1V4Q2JlRnJwbVZlK0NSbzFrekVoWVg3ZlBwa0NCRnY3aGNBemQwV2xq?= =?utf-8?B?U0ROZmxnSUZQV1J1S0JRUzArSnBwU0NFNlFCS0p6dzEySlI1M2JpRjEwQVo2?= =?utf-8?B?ODM3dUkrWFZVeEhzSnlxZUM2VnNTZzRZVEJIdnZxR3Zxc2twSFlFVmh5YktK?= =?utf-8?B?SHVaUzZRb3RoNVdBbytoY0J2YlZjVnYvS0xFL2YxUFliT1B5R2VXMWJHNllK?= =?utf-8?B?eFdiNDZrbTZzK2RRK1ZLc2tLR0VCdFFwbWs1QnlhK1hZK3lhTmRYS3NpTEZa?= =?utf-8?B?UkRyZmJ0T1hyREkwWUtjaGYwYmZjM3R5bmRWWHo4YVIxQjJDRnR2bTJMMnAy?= =?utf-8?B?WGVNRWtSVEFhODRwNkVDT3BMNW04OExYdk5FZFhyOTNYZThpVi92ZUpBeXRo?= =?utf-8?B?OWFHV1R2UzlEcHNVODRLRW03eG1obXF6d3ZhNGZOMW1sYTdGZVVER0xxRy9R?= =?utf-8?B?anV6eHl2Q3ZvSm9HRmJsRlFLOE9Tb3lIYmR0a0J5OVRiM3dZRGczQ2FaWnQ4?= =?utf-8?B?eEZ0cEtRdCtlQlRacUk3MUJ6b3JKZmJSVzcwS0hRTGNWNE5UK2ZOd2RHUGNh?= =?utf-8?B?eDZCSTN2S2R2Ykdxa1A4QUJTc3FQMDd3ZVFLaWhxZzVIRVRoYkNQbzBSOVN4?= =?utf-8?B?WWllLzFzYlRlTk9ha1U5eC9SRFJxSjFqa0hudHh3bytwYjUyTGxNTGtQS3or?= =?utf-8?B?RHphREN3Yy9UTzBqVk5qUWh1RC9PMWVDdGlGMFR1SDRub3JBQ0FoaUxiczh5?= =?utf-8?B?cm1FYy9pYXpCWXZLRjhma1VjaFRMT0lJRTBNcDJNeDBJbnhsWndzZEpyZWlN?= =?utf-8?B?aktYMVNUTkJ4M1FuL3BES2NXN0ZMNnMvTjA0Z1FET3NhTDRjbndWRHc2a0xG?= =?utf-8?Q?DDJKPFO539UCO?= 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)(36860700013)(82310400026);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 03 Jul 2024 21:50:19.5583 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: b53ea900-6aed-4e87-66d6-08dc9baa21fe 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: DS3PEPF000099E0.namprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: BY5PR12MB4291 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 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). Reading L3_QOS_ABMC_DSC returns the configuration of the counter id specified in L3_QOS_ABMC_CFG. 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 assignments. 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 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). Signed-off-by: Babu Moger Link: https://bugzilla.kernel.org/show_bug.cgi?id=3D206537 --- 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 | 40 ++++++++++++++++++++++++++ arch/x86/kernel/cpu/resctrl/rdtgroup.c | 18 ++++++++++++ 3 files changed, 60 insertions(+) diff --git a/arch/x86/include/asm/msr-index.h b/arch/x86/include/asm/msr-in= dex.h index 263b2d9d00ed..5e44ff91f459 100644 --- a/arch/x86/include/asm/msr-index.h +++ b/arch/x86/include/asm/msr-index.h @@ -1175,6 +1175,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 4cb1a5d014a3..6925c947682d 100644 --- a/arch/x86/kernel/cpu/resctrl/internal.h +++ b/arch/x86/kernel/cpu/resctrl/internal.h @@ -100,6 +100,18 @@ cpumask_any_housekeeping(const struct cpumask *mask, i= nt exclude_cpu) /* Setting bit 0 in L3_QOS_EXT_CFG enables the ABMC feature */ #define ABMC_ENABLE BIT(0) =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) + +#define MON_CNTR_UNSET U32_MAX + +/* Maximum assignable counters per resctrl group */ +#define MAX_CNTRS 2 + struct rdt_fs_context { struct kernfs_fs_context kfc; bool enable_cdpl2; @@ -228,12 +240,14 @@ enum rdtgrp_mode { * @parent: parent rdtgrp * @crdtgrp_list: child rdtgroup node list * @rmid: rmid for this rdtgroup + * @cntr_id: ABMC counter ids assigned to this group */ struct mongroup { struct kernfs_node *mon_data_kn; struct rdtgroup *parent; struct list_head crdtgrp_list; u32 rmid; + u32 cntr_id[MAX_CNTRS]; }; =20 /** @@ -607,6 +621,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) + * to track this counter id. + * @bw_src : Bandwidth Source (RMID or CLOSID). + * @reserved1 : Reserved. + * @is_clos : BwSrc 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) diff --git a/arch/x86/kernel/cpu/resctrl/rdtgroup.c b/arch/x86/kernel/cpu/r= esctrl/rdtgroup.c index 91c5d45ac367..d2663f1345b7 100644 --- a/arch/x86/kernel/cpu/resctrl/rdtgroup.c +++ b/arch/x86/kernel/cpu/resctrl/rdtgroup.c @@ -2505,6 +2505,7 @@ static void resctrl_abmc_set_one_amd(void *arg) =20 static int _resctrl_abmc_enable(struct rdt_resource *r, bool enable) { + struct rdtgroup *prgrp, *crgrp; struct rdt_mon_domain *d; =20 /* @@ -2513,6 +2514,17 @@ static int _resctrl_abmc_enable(struct rdt_resource = *r, bool enable) */ mbm_cntrs_init(); =20 + /* 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; + } + } + /* * Hardware counters will reset after switching the monitor mode. * Reset the architectural state so that reading of hardware @@ -3573,6 +3585,8 @@ static int mkdir_rdt_prepare_rmid_alloc(struct rdtgro= up *rdtgrp) return ret; } rdtgrp->mon.rmid =3D ret; + rdtgrp->mon.cntr_id[0] =3D MON_CNTR_UNSET; + rdtgrp->mon.cntr_id[1] =3D MON_CNTR_UNSET; =20 ret =3D mkdir_mondata_all(rdtgrp->kn, rdtgrp, &rdtgrp->mon.mon_data_kn); if (ret) { @@ -4128,6 +4142,10 @@ 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:14:47 2026 Received: from NAM02-SN1-obe.outbound.protection.outlook.com (mail-sn1nam02on2059.outbound.protection.outlook.com [40.107.96.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 AB0CE19AD5D; Wed, 3 Jul 2024 21:50:30 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.96.59 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1720043432; cv=fail; b=pwhwQZuKXQzAw2jbqOFrrI0lyasDgcwaJ4tdt0nP5sQILI10XBYiFiaGPGr0D1xNIofaH7wZxiTW8rKDloPnfYAUPOxY3dF7akmzLdM2f8Lbpo2h2YnSwixgtdURfUr/lN+nleWQ1v3s+IsFypl8tFww4X9oo19Mduo6aWHb2fM= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1720043432; c=relaxed/simple; bh=x0TMpQeQ6gW9b93zYowgFIvoINIwGqveSKHctIZPyC4=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=TvX1/HW7/jv02d1/mtI9Q0kgLmjq5MIBN5CYFUz0h1rdprdihGdsvXfYLEPOXGO13lqtOJTKLCYhH+60hcJHlVjlo3hnQPzdoYHtUkIbB5r2LnIvXZoRcVFDhrym594vINAHcC7jT93X1Em9jN9Ngby7tJ2ZednSukFTqBxZw7I= 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=L/RL3tCW; arc=fail smtp.client-ip=40.107.96.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="L/RL3tCW" ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=JMey0ZwxxAKdRrXbC6dzWCRKEazOvB6RHoT90wL46qW6QtQpkhXzQkzUTnOfL79c06Vi3gyRvUZgYT/9qyQJ3ZD5cQ7wSFSy1FVsVgV6XZpgJtusqT6I0kuIbaUCtLRumbbgi6R9prE4a128TGZ7JwNhHOCbr0C+UHa2FFjOXSwS/cvZNmbse1w1bOQzjyBO2GOLBITdN9lqiuInHxENY0IM8ucnDwKbG2+q7JhdsvNoNF2QPMIVXMSCg2bgGJWOnolq34aS7EFhH0TMXq/AdvfDpABGKqnARBxDSExXzF99KSP6Y/cXyJy/+UZL3ZuQJ4Ol7DUbpJU3OWLm9Clhqw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; 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=rpgKAXoGLl21U2Pjr5zmefcE0wRxZcjLJNTSQhUKp70=; b=OxIT4vmZ4+fFLEmJRr5g7uKkItsbuljtx6tL3AgTMyO+7Aaj139WZN1BHgyJy4ULqTEEdWKXxNlzbGA9CnUWX1BpQ1jEh65rZzlSsWX1qftZygftPlo16wt/Fen3kAblDlCmS+MlOVQgq+4Qf8o8o4TkajC8FLRKmOWhxU01xqLvYriBUgJOZMTQxM/HzJmJUlMP7kcCEyWfgAkdApWS4nn48JrBXHNQ5eJtzJGbMDY4zTfhqZJs3/vsVKd2Mubbx1iyQbds5qUW57l9FccX3sDndqxChsfvJE8wppIKhzj2RtecTFViODICgjvucElNh2adapJmJMFkezCYeqgytg== 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=rpgKAXoGLl21U2Pjr5zmefcE0wRxZcjLJNTSQhUKp70=; b=L/RL3tCWWSGo86VLRNlWxinRz79em+VG2qBKYRwiIN8m77NlTtokBqFcpitwUx4mF7vyAMpJO4sRCSxKyKd3RlPmv7rhDulJQow0zpTplQZ4/2Y0Jo1JsK6+rAiHs4H4zx8HPmi38SQulMsd0ejQp+krBN+JYZwGH1j7hVg4P2I= Received: from DM6PR17CA0013.namprd17.prod.outlook.com (2603:10b6:5:1b3::26) by SN7PR12MB8771.namprd12.prod.outlook.com (2603:10b6:806:32a::20) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7719.29; Wed, 3 Jul 2024 21:50:27 +0000 Received: from DS3PEPF000099DB.namprd04.prod.outlook.com (2603:10b6:5:1b3:cafe::87) by DM6PR17CA0013.outlook.office365.com (2603:10b6:5:1b3::26) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7741.26 via Frontend Transport; Wed, 3 Jul 2024 21:50:27 +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 DS3PEPF000099DB.mail.protection.outlook.com (10.167.17.197) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.7741.18 via Frontend Transport; Wed, 3 Jul 2024 21:50:27 +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; Wed, 3 Jul 2024 16:50:25 -0500 From: Babu Moger To: , , , , , , CC: , , , , , , , , , , , , , , , , , , , , , , , , , , , , Subject: [PATCH v5 13/20] x86/resctrl: Add the interface to assign hardware counter Date: Wed, 3 Jul 2024 16:48:24 -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: SATLEXMB03.amd.com (10.181.40.144) To SATLEXMB04.amd.com (10.181.40.145) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DS3PEPF000099DB:EE_|SN7PR12MB8771:EE_ X-MS-Office365-Filtering-Correlation-Id: e155e612-6d91-4e56-d1d5-08dc9baa26b6 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?m72LVBgPl8mB4h7eYstPETzjX80H36LVnyMlLYGAIfZtGDabISqEXaaEzNMG?= =?us-ascii?Q?bmVHNBsZNlVRKcfl36GaUe02g1w6P2V6fBaAgHqmEwuxuOQrLtlzHr/kYFLs?= =?us-ascii?Q?kGJJz5RBu3YYJAdF0sfatIyHPvtzQBr102BantFEWPyjAfeHjuQAUcKI18rb?= =?us-ascii?Q?gprX04ePOyx+ZX63kssBIkVfetxaR2gTsrw74paEUXblsNPVr6mhjSmW6zCS?= =?us-ascii?Q?QFY8jB5SKvgTSy9bbiMaGuEr1jklXMSWRzWFK4hA6fSY8XSnFFV+IP4+Ltdt?= =?us-ascii?Q?tUQxSp83tZtpyZRw2Nj8HsNOpvGhavkbEvwPKKYCYaD5EEkn8T8YFe1tAohF?= =?us-ascii?Q?XHKO0AkRi+aEPdgXmdRd4oYuNZGcwqKBlZE7LR2ZBiOM4ImlXl6ux9nTxzEC?= =?us-ascii?Q?uSERt6xqop8vVbKWPzmHdBkrrV5aAZveZbWKav6fGVSNcI9VHFBCQ+FKap01?= =?us-ascii?Q?8ccnpHTVps/2qrgOULzxPpt4Tk1CNzfRM2IHj3kFJU/VblGcNEG55LmGyaqk?= =?us-ascii?Q?PsE+QyH6RIfJGolZWLAjzDRpJD7hWVBkqJZxP9Iu5RN5kqWBeedL6m/XSv2Z?= =?us-ascii?Q?7Io17/arJGVzQ0grBN/QPnDIIBC38W+2nIBtlRB8e5aY/mtcQrmC4SeVEBFL?= =?us-ascii?Q?haOTxOYub3uS3oL5JxIc3hKNEXWA7x2XuB+cqwGI4+mG2+o6C6iKVJ8GCVUW?= =?us-ascii?Q?bkaJC7UYNiTI+lIBNJZNVaJhLNNXPwcJsZAz1pQ7R9CKS1nSz5XLh+luRkNv?= =?us-ascii?Q?rLdP5wPqM675AlCOeFgLGz1r8AOmlJLyjjUcrgZtxAJAsYCO3rZ/N3GCPhVc?= =?us-ascii?Q?VIomVq5dFM57tF9zUCFriPiXFcJAxCf0S7GF7cZgJb8aoXWAyhNaq3LeXMz0?= =?us-ascii?Q?7YuTQ5UA5N70HswAt8VMkRj+AFSLeS116CJvtWtY3ZkoorV83eLd1XA5Kmtw?= =?us-ascii?Q?GvQt40Pu0RpQN4QO1Or/ug62W+mjmhIrFOlJ6LQ2/D9BgLQFcHCX5M67umfw?= =?us-ascii?Q?4gWY+qiCrhpTj65t7wHRtttVlvbu+XZWGjPuGyNsiJoJUm5/SSyNgE5gOOXy?= =?us-ascii?Q?sfvegfdbxPjW8clbZSmFd8+lTYvUHq/nIR6ibcxzwVZpICN96693vCL+5TZc?= =?us-ascii?Q?rsWvajc52HQDfg1O0KmMVnFttzUBhRQvtekXs0DY2DseFz3VVLJUFCRxLRbX?= =?us-ascii?Q?p+VQWhILkC17xF9bN7sk0gMZua70fi3gX8rnGr9Z+z7KXJ69CsnXfu7DoJl2?= =?us-ascii?Q?KK2LQr2YiKkJgDlTyc93PipNGzxunYNVYAhQuExtqj4lSKSyVPFtLcdJWod+?= =?us-ascii?Q?OtM9CJ8dJCR85SheiMIDdqomKWTh6yhmRZ9P/rLVAa95Wdo1gJnKdkb5o9f+?= =?us-ascii?Q?sYxFkVuz7KdPmV1MXQOa7tkuS9u8?= 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: 03 Jul 2024 21:50:27.4778 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: e155e612-6d91-4e56-d1d5-08dc9baa26b6 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: DS3PEPF000099DB.namprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: SN7PR12MB8771 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. Individual 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). Signed-off-by: Babu Moger Link: https://bugzilla.kernel.org/show_bug.cgi?id=3D206537 --- 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 | 3 + arch/x86/kernel/cpu/resctrl/rdtgroup.c | 96 ++++++++++++++++++++++++++ 2 files changed, 99 insertions(+) diff --git a/arch/x86/kernel/cpu/resctrl/internal.h b/arch/x86/kernel/cpu/r= esctrl/internal.h index 6925c947682d..66460375056c 100644 --- a/arch/x86/kernel/cpu/resctrl/internal.h +++ b/arch/x86/kernel/cpu/resctrl/internal.h @@ -708,6 +708,9 @@ void __init resctrl_file_fflags_init(const char *config, unsigned long fflags); void resctrl_arch_mbm_evt_config(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, u32 evtid, u32 rmid, + u32 cntr_id, u32 closid, bool enable); +int rdtgroup_assign_cntr(struct rdtgroup *rdtgrp, 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/rdtgroup.c b/arch/x86/kernel/cpu/r= esctrl/rdtgroup.c index d2663f1345b7..44f6eff42c30 100644 --- a/arch/x86/kernel/cpu/resctrl/rdtgroup.c +++ b/arch/x86/kernel/cpu/resctrl/rdtgroup.c @@ -202,6 +202,19 @@ static void mbm_cntrs_init(void) mbm_cntrs_free_map_len =3D r->mon.num_mbm_cntrs; } =20 +static int mbm_cntr_alloc(void) +{ + u32 cntr_id =3D find_first_bit(&mbm_cntrs_free_map, + mbm_cntrs_free_map_len); + + if (cntr_id >=3D mbm_cntrs_free_map_len) + return -ENOSPC; + + __clear_bit(cntr_id, &mbm_cntrs_free_map); + + return cntr_id; +} + /** * rdtgroup_mode_by_closid - Return mode of resource group with closid * @closid: closid if the resource group @@ -1860,6 +1873,89 @@ static ssize_t mbm_local_bytes_config_write(struct k= ernfs_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, u32 evtid, u32 rmid, + u32 cntr_id, u32 closid, bool enable) +{ + 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 enable ? 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; +} + +/* + * Assign a hardware counter id to the group. Allocate a new counter id + * if the event is unassigned. + */ +int rdtgroup_assign_cntr(struct rdtgroup *rdtgrp, u32 evtid) +{ + struct rdt_resource *r =3D &rdt_resources_all[RDT_RESOURCE_L3].r_resctrl; + int cntr_id =3D 0, index; + struct rdt_mon_domain *d; + + index =3D mon_event_config_index_get(evtid); + if (index =3D=3D INVALID_CONFIG_INDEX) { + rdt_last_cmd_puts("Invalid event id\n"); + return -EINVAL; + } + + /* 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(); + if (cntr_id < 0) { + rdt_last_cmd_puts("Out of ABMC counters\n"); + return -ENOSPC; + } + + rdtgrp->mon.cntr_id[index] =3D cntr_id; + + list_for_each_entry(d, &r->mon_domains, hdr.list) + resctrl_arch_assign_cntr(d, evtid, rdtgrp->mon.rmid, + cntr_id, rdtgrp->closid, 1); + + 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:14:47 2026 Received: from NAM10-DM6-obe.outbound.protection.outlook.com (mail-dm6nam10on2072.outbound.protection.outlook.com [40.107.93.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 BFBE21946D4; Wed, 3 Jul 2024 21:50:39 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.93.72 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1720043441; cv=fail; b=LYdzCy78uaOID1XUbKIO8bf44lfmcYchAes4tUI/i0vkTfAD5iqJ2tqfPHiWyZFhs9RJxuFdGaUyesyjPNguYld29t7WZlAAv6j+u5M+t/9k3PGIGTgrsXuvbLKtIWOBLZT3F94en3snHFCBUGm7ISOUezJLGsOga7wFl12fNXU= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1720043441; c=relaxed/simple; bh=qxSJlsBSAsQgDbwXnFbFqkS2/SrffzR44KAfjNQ15S4=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=ppkVoAJdFqJmJh4WLeUnDDhkEuXAAPw4JkctqvotTBk5DXS+rmHR2Iyxaj/PeLKr3bEO5jodxTgEAv0pcFg/xk6qqjWr8prYZHQbPB7ty0RbScyVI3x4xz5Qxk9n9uZmOqH9tylAjHzKRwAWJa7dZOKfk7ZX75kVn0UE7qHYP/g= 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=T4pk9iPq; arc=fail smtp.client-ip=40.107.93.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="T4pk9iPq" ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=ZX7r1q3ROjzHjIkLs/+mw4P2nqJaakridHd54WzkErbaatkwMIbNdu05HCCinggdfLnp747/cNbEd/jtkSo5p8SFs6ExrqTU21p4OaacCjyaW8RSra4TE0D2+jiUD5uAOZcGxYJLOuMHXKEvz/NsfKK9JFA2sFdiqQ/rS1nIYlPVoiqiF8zGlW+6TJdHaoMWxO+JT0f9ferpL2EWOsYvATGStXQN9REaD4NvuGmG79vpl0d9+shg9aTlLaq0at033RXqF5bO3QDSQ48AI1gTRdepTF3lva/g8auyj+wwXAnIaiHE+1moqj5AHZvN4H/wCb5G9oXGEScczyCMKbsGMQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; 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=HkxZZU7BVaEho0FMkpgLS9Vf5ou/ipcrWZcYK6TOcZM=; b=eqPrpKhjg3OSHus4uT4qLpwhdVLeFQoB83eBWwDQIgV1522ZJilSiSmrAmEHMs9t5W6v+uGE7ul7Lzwh6Eej2kC082zGgIHhlJlbaayHAvQsbi57b66CmYfoO/rbyPNWfZccxo56CQYhK0ixLYRZGmKp31r8TVTMXrs/r2JMvSRpc5aK9R4CidA/JyjzQBWaTD6vBnAXY33IasTuJXcOjiClQkY5Nt1df9TVbvbC6WFpTD+hr/cEhqQic/sHdC9hC8Dg+h0FlTO0YXPm708ExPhXyAT6FDX3TH8S36YzKCH2v23dcgyV3o8OULq7Qx2tG4PbJZMhGwN1wBTaBhGOJA== 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=HkxZZU7BVaEho0FMkpgLS9Vf5ou/ipcrWZcYK6TOcZM=; b=T4pk9iPqBwUHdVk+aO1d7YALxCe2IyPcRSNYblRr5Y6bE9wV3yyw1qHJq4SlSUaCi08nA2uF5UX8Q3/5Y+SyySVnN5e/KbNp9tdXRBPvn8B7UlrxBqtB3D/Pt45PQFPtRuyCkE1NWxS48m2t+Dd9ORuYMcl36X0dbrPqF+vgn3o= Received: from CH2PR05CA0021.namprd05.prod.outlook.com (2603:10b6:610::34) by PH7PR12MB5974.namprd12.prod.outlook.com (2603:10b6:510:1d9::19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7719.32; Wed, 3 Jul 2024 21:50:35 +0000 Received: from DS3PEPF000099DE.namprd04.prod.outlook.com (2603:10b6:610:0:cafe::57) by CH2PR05CA0021.outlook.office365.com (2603:10b6:610::34) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7762.8 via Frontend Transport; Wed, 3 Jul 2024 21:50:35 +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 DS3PEPF000099DE.mail.protection.outlook.com (10.167.17.200) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.7741.18 via Frontend Transport; Wed, 3 Jul 2024 21:50:35 +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; Wed, 3 Jul 2024 16:50:33 -0500 From: Babu Moger To: , , , , , , CC: , , , , , , , , , , , , , , , , , , , , , , , , , , , , Subject: [PATCH v5 14/20] x86/resctrl: Add the interface to unassign hardware counter Date: Wed, 3 Jul 2024 16:48:25 -0500 Message-ID: <9036479261abaa3255c9fe3ce460c590142672c5.1720043311.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: SATLEXMB03.amd.com (10.181.40.144) To SATLEXMB04.amd.com (10.181.40.145) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DS3PEPF000099DE:EE_|PH7PR12MB5974:EE_ X-MS-Office365-Filtering-Correlation-Id: ef07ff2e-9c2d-4161-f579-08dc9baa2b62 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|376014|36860700013|7416014|1800799024|82310400026; X-Microsoft-Antispam-Message-Info: =?us-ascii?Q?dEVHHDtMHFudpX91SXBezqQZUtAATOX4DtfNc8W8mQO/54olLYaVgzTk6Av4?= =?us-ascii?Q?Zef9ciyGGLLsuPWIsTwBTb9x7tpVFUsMjHxw9S716/hag0Bl//GlnMUbtCem?= =?us-ascii?Q?t+FbBUwsCIn6juqMq+iFZXoGkyqcO0G8LykLO3QMaCAaLeZRheZ7XwSqwUTs?= =?us-ascii?Q?3u1C/ckokaMx4x3qQsrVDEVD5DopFEKTEpmj2EENcMBrnskrKs6JWvXWNCm3?= =?us-ascii?Q?gf5k8/bse1Q+4PlOSzSDXDjlbEdFXU/7bDQq6WqlWhL5bCcGlAQ2wBsOmM8X?= =?us-ascii?Q?D8x+SR7Z9EmyolZDSN17hogBf0qCB2eqZJDV7J8Tg4WoZHhRfpIxEDlbaxpp?= =?us-ascii?Q?NvFiGmmKtdzArFZFfbneHWlZ9cKfM8kQxQ9J1tQDdmkzZgWPWwPIPkJPJR4i?= =?us-ascii?Q?hk2zmroj6Oc6SAdmRjRg3s0kewXG4pv/x0ihVhKg66hEq9IyL2Ge25qpmiIl?= =?us-ascii?Q?EC+QLK0uXUnsdWjYjWoY4K4dOl4VgoarP54xuVFCcQWN/kCRHhuCGdHH1gIl?= =?us-ascii?Q?rDCloTuwIQw3ght45WP1QIoKMHRI7ftSTJ5bE2KhEq0fnSYF6H6lHH3FgnKt?= =?us-ascii?Q?gGKYezRhMivQHhIEwwFYNyh1O/mC+7GS8yE8wDb/kPUbJ4zQHMA2uWKtMSWP?= =?us-ascii?Q?S4CeqSa53YY1c3J5bHlNX4oTus3FhrdhndcG95AbrlquckU6dZY+dKlMKq3I?= =?us-ascii?Q?QCDaB75ZtmRtQgXQveUcQ3HIa13Jc0sCn57dtzqPJL0yIvf+pvdNmLz0Va+J?= =?us-ascii?Q?T1KQvLZnta3/+84rwnak8PFzSSlst6Y1Xt6uWOW4T/MrjL91sQyYiElO/l4S?= =?us-ascii?Q?9JTQIizj7lmfjcPhGXnPzApVCvuMb7HbbhmYZwsEV+urLwe7087i73hADMNS?= =?us-ascii?Q?Rf+cJ7/4XqxkWdbU+PqM7An/8VHrSDvgw5BR+sArGqTb42AQqFpPyTKPVGYF?= =?us-ascii?Q?hqP7vLfuWBRhcpnbyETSsYlNt/xG28f2HvF9rAh7i1iZ04ZVx3kpbqd8bMWm?= =?us-ascii?Q?RuqZBwD7hdwtqFZA/kngk15vqbJyr2U6Qm1bRynVuyCfZg8VbOzCDzEYTo6x?= =?us-ascii?Q?k1OZsGOwN8NpnJCM+mezpHKjBASHOz9H1rAYPZaq0c62WTaA92po9r3wAMxC?= =?us-ascii?Q?jkMyu7L/kDZnx2U/frWrUFPyo67AQ1AHCXQ/kjRApXSZgXJ5w82J9ndYNCSD?= =?us-ascii?Q?bQBumtLhW/rMl/DhquO7I41dLL+3TTI54ztkcwn0JZ/ye+e6KmSmnqn6dfjX?= =?us-ascii?Q?os/lTfbk8o2YP23+Rx+wvczddWp33Ij6h6jOFdkPK4wsEcxZWAsnuPAZ6mCI?= =?us-ascii?Q?CJiTMSgLz65pw+hYabSpUE67aDwQT6FZGvGr4lBELv3nTzog0ru3KDSK/Qj6?= =?us-ascii?Q?QPVEOXM9a7iRUrdu/fNHoHBV4Vuc?= X-Forefront-Antispam-Report: CIP:165.204.84.17;CTRY:US;LANG:en;SCL:1;SRV:;IPV:CAL;SFV:NSPM;H:SATLEXMB04.amd.com;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(13230040)(376014)(36860700013)(7416014)(1800799024)(82310400026);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 03 Jul 2024 21:50:35.3481 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: ef07ff2e-9c2d-4161-f579-08dc9baa2b62 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: DS3PEPF000099DE.namprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH7PR12MB5974 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. 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). Signed-off-by: Babu Moger Link: https://bugzilla.kernel.org/show_bug.cgi?id=3D206537 --- 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 | 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 66460375056c..beb005775fe4 100644 --- a/arch/x86/kernel/cpu/resctrl/internal.h +++ b/arch/x86/kernel/cpu/resctrl/internal.h @@ -711,6 +711,8 @@ unsigned int mon_event_config_index_get(u32 evtid); int resctrl_arch_assign_cntr(struct rdt_mon_domain *d, u32 evtid, u32 rmid, u32 cntr_id, u32 closid, bool enable); int rdtgroup_assign_cntr(struct rdtgroup *rdtgrp, u32 evtid); +int rdtgroup_unassign_cntr(struct rdtgroup *rdtgrp, u32 evtid); +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 44f6eff42c30..ffde30b36c1a 100644 --- a/arch/x86/kernel/cpu/resctrl/rdtgroup.c +++ b/arch/x86/kernel/cpu/resctrl/rdtgroup.c @@ -215,6 +215,11 @@ static int mbm_cntr_alloc(void) return cntr_id; } =20 +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 @@ -1956,6 +1961,34 @@ int rdtgroup_assign_cntr(struct rdtgroup *rdtgrp, u3= 2 evtid) return 0; } =20 +/* Unassign a hardware counter id from the group. */ +int rdtgroup_unassign_cntr(struct rdtgroup *rdtgrp, u32 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) { + pr_warn_once("Invalid event id %d\n", evtid); + 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, 0); + + /* Update the counter bitmap */ + mbm_cntr_free(rdtgrp->mon.cntr_id[index]); + rdtgrp->mon.cntr_id[index] =3D MON_CNTR_UNSET; + } + + 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:14:47 2026 Received: from NAM10-DM6-obe.outbound.protection.outlook.com (mail-dm6nam10on2045.outbound.protection.outlook.com [40.107.93.45]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 8B4D9194138; Wed, 3 Jul 2024 21:50:46 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.93.45 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1720043448; cv=fail; b=tXDg3/BiTDpWugAmhwtDgr36RsWds/wMbqbcq3raTA22c61QwuvsaPcY6HQOHbfZZaD8wVAjOw3hamBSkSbnFNdOWdV24EYxUCxNak/uUaThPNW2+G46aVZKymXWbrQ2N2dtR2XkwwwAMHNYsuSh1GFUCkT7CgiWpQdmxcgVWfI= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1720043448; c=relaxed/simple; bh=ueeR/v17tt2/NF3j/g6m77xrQ7qe+xv1AvBpoL/SCRU=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=Ry/s63JSHk5LA3uwRhdbtzmXYLfXafmqF66HBm7YmSGzf+L6Xe4X4A9ka5+wyBxiBFNhLIery8KRQC6Ps0TpQlwdpQoACwwlG/uWycWJ02JUE5V+XNkbI/8BPQeY1U/LjK6MSanN8/mhLjhqb1tH97xTFTJ3JDKdXTndTul2RHo= 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=QJYvkQge; arc=fail smtp.client-ip=40.107.93.45 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=amd.com Authentication-Results: smtp.subspace.kernel.org; spf=fail smtp.mailfrom=amd.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=amd.com header.i=@amd.com header.b="QJYvkQge" ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=PjkGDZU5x/BtZvFrx8PJsMypVe8NWAspgBkx75JAiol8j7XvZSKTvMDO17ainnCnumW0c5Y8zQiro7s5VFhg6OCOTYz8+JKpsIrHhoYd/qsgwTCPbC6EbfacsTaun2jQ1jje/vluA9Zp5sasDtdyJgTPNu20H8PjwYC6XMRmb5ZimXtqbVQ79L5oGLgkb6RoqwJyxyp1FF6jZ10LStwJ9zZTiM+01igZqsG+jHKGHXyONNjLUgz5NyVjpYPJBRId8HxRkv63Wae4Y7TemAoS7ERH49JHJaW10mgiroUN05GGDwwtOVbXASNuuALWXlQHLChTQB/yxW4opXLd+2zMTg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; 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=9dLfW1g5byqMkzRWdhSp+40r/32qXfjNHpEwsqP8xWs=; b=hIHBhraAv3n5WMLueTnOAsfqhOkHFmHPKqpq7eaDScsbnFnkFk3APgp1MpkOfUNfJGnndyPHMCEWY7icx5mEQb60Lez1gEtz3SyNenCYevSrCHjyUSdy/jm/Wna7Zg4V1GyS4e3qp2eWsbvgbZtETsZFikBjOkQujYqBszszciF+JkRgPLlk8o08N+aDbMX4PL43ck0KLdic1AxGlrhvnFI5n2ms2PlbsbtyoF6aqG0P1X6uCWU7e3KhkPDuYGl7F1HpE3PxhDGrOgJEmr+iL7zJoWLir2Y9iSxI4lr91n9jLVrNZ/018Zv98t/NIVOGsnljauxREl4UUtcwqCuVag== 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=9dLfW1g5byqMkzRWdhSp+40r/32qXfjNHpEwsqP8xWs=; b=QJYvkQgeEF0EgG/lehKp30EEsa6OhBH/acw7B2/Oe40nwJSZTwbN02+Wu/RimOXq+lp/YhXzlnOB5QI1eWC9sC6HunnIPo7CgcDrqFjY4Xp/F/P66iUU2mHLft+9YiQVHxN7k69edRu4lRw+M4dKc9feFyaTy/C7zcZWOlsFzps= Received: from CH3P220CA0029.NAMP220.PROD.OUTLOOK.COM (2603:10b6:610:1e8::11) by CYYPR12MB8938.namprd12.prod.outlook.com (2603:10b6:930:c7::11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7719.29; Wed, 3 Jul 2024 21:50:44 +0000 Received: from DS3PEPF000099E2.namprd04.prod.outlook.com (2603:10b6:610:1e8:cafe::e6) by CH3P220CA0029.outlook.office365.com (2603:10b6:610:1e8::11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7741.23 via Frontend Transport; Wed, 3 Jul 2024 21:50:43 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 165.204.84.17) smtp.mailfrom=amd.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=amd.com; Received-SPF: Pass (protection.outlook.com: domain of amd.com designates 165.204.84.17 as permitted sender) receiver=protection.outlook.com; client-ip=165.204.84.17; helo=SATLEXMB04.amd.com; pr=C Received: from SATLEXMB04.amd.com (165.204.84.17) by DS3PEPF000099E2.mail.protection.outlook.com (10.167.17.201) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.7741.18 via Frontend Transport; Wed, 3 Jul 2024 21:50:43 +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; Wed, 3 Jul 2024 16:50:41 -0500 From: Babu Moger To: , , , , , , CC: , , , , , , , , , , , , , , , , , , , , , , , , , , , , Subject: [PATCH v5 15/20] x86/resctrl: Assign/unassign counters by default when ABMC is enabled Date: Wed, 3 Jul 2024 16:48:26 -0500 Message-ID: <89b7b4c59f3389034337301c1741ce224e19061e.1720043311.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: SATLEXMB03.amd.com (10.181.40.144) To SATLEXMB04.amd.com (10.181.40.145) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DS3PEPF000099E2:EE_|CYYPR12MB8938:EE_ X-MS-Office365-Filtering-Correlation-Id: 55b2afcd-e5cb-4628-5681-08dc9baa3028 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|82310400026|1800799024|36860700013|376014|7416014; X-Microsoft-Antispam-Message-Info: =?us-ascii?Q?wUGIEvoY1UE/M0daVJ2mkelpJ+R0C4bZ0YhvoPF6WVyxdQ9sqzQzMfuZVSjn?= =?us-ascii?Q?ZePrkfdEjvSdsBRHJghQjb4s2qzU5ZZFH9ekUaMeNrA4239ExFch5vKGw9L2?= =?us-ascii?Q?lM0RX7cxwFFSkzTw0lxtPTECtuc3XOYD4fP1CqaryA+vSCwlYuvJANBiWiPr?= =?us-ascii?Q?WUTdd/0M9BtiLvk1U0AdbYfooevy4I1ixyGteZZ5VeqaFRdmeCOrfFfLzA8o?= =?us-ascii?Q?7lUZpKlud/mcO/p8dx5EAylizrE4zndDWntPd6QPr4nFxnCAe6TJDadwlqFR?= =?us-ascii?Q?I4jWPhBoBg3qHktWJMihd2mNouQtOZd1XMKdYTWIP7phTAHUBzDlLKEo2g2E?= =?us-ascii?Q?44nRbmXHfufyhhMZ6l6YznEh6HNw04cZw7CrtkzzfZJ04JRpIBW0jFxwSKM/?= =?us-ascii?Q?Vm/gWRzetTbaRFdT3BzP7IBpbD9eBVgJyCA9I+jtY4C4dNFG0UkwYQMdsoT3?= =?us-ascii?Q?Nv25vjTLioaZv5+brQwPp1bX0D6LoOVgUwNcZbq4TKGCEjvUTBJs29LI98w8?= =?us-ascii?Q?lSvEd0cjAbHwDxr7RltCCypfX/8OoCyklGfOkRay2oMFixJOwBt/i0T2SlT0?= =?us-ascii?Q?f1LPaLLWOWRKtH1r5fsKS2BVedJrWJcAKxA/FN6oGUg+1IHdJs1BQukRm2GV?= =?us-ascii?Q?UkkS8WunQkpR1aLeRHr9HRjHfcaxkfI1FpEtaOaxEDpUBq/QtSD4JbzUGdBF?= =?us-ascii?Q?UKxVntX1C6R0mrsdTj4lFmvSKnuRG4vul09CcGWrQRf32SncCFn2DoJKXgqx?= =?us-ascii?Q?RqLdgPGNTS1gmJxSrELFASUyCyUkhIlmZuDdFNKt4W1L6IkqxwJ8zI1AkhD/?= =?us-ascii?Q?VUXq1w+4NDkq52zX1OeSlCAOc8TYLMltUb8ycAqB1ysZGT48CAXZjQ77ELBy?= =?us-ascii?Q?Xw2esaoOy86SnJ6p2TE8pZmc/2gxJT0OQHZVD+fi0cFqo2NC+55sOoxOiR7W?= =?us-ascii?Q?2L//vEPWB+56yDasibcyOyc64sXc96gjjv1c8eiszBp3mmaWEKlXJPKQ9ZKx?= =?us-ascii?Q?8jnrtN91Ob2R98mTQPS2rV9kcuJ1MzCOL1DySFGSJdC0f1siR3kIjLUBOty0?= =?us-ascii?Q?/7fTza1OE1bTN6pwIL676HmjV1lXmDe4dxMSf8/JquKQ+UFhnCLrZQOibnJV?= =?us-ascii?Q?Pe3XaWo9F6//VegzuLwS46amm0jkVTg3kdGM+qcZnwj2nbEDzPolNlmhsaLp?= =?us-ascii?Q?/OkeWPrEk5dvF79wA1NtC3oPz/2tNqhCDCxGKwlu1U3QyLg2bMHGFHJ7EGIK?= =?us-ascii?Q?PXgP8TPxOYZZxBpjXTRPqFMfWeHLdulXf8I7jUsSj/6H/znu+61TXH9l8lf4?= =?us-ascii?Q?zQpS8IB65bDnmyTL/SfgKlYUlCPfJpC39t8Lp3Qh/T5HHPO1lqPuTGToqBnE?= =?us-ascii?Q?a+iL6BKCVwz05f23W4ya3JLBji0yiZNoJ7GekhmEkLtdXtImGBPRsrOg9qQi?= =?us-ascii?Q?qT3r/Mn3CTQRQek33zT+pvr9mhX171uU?= 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)(36860700013)(376014)(7416014);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 03 Jul 2024 21:50:43.3369 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 55b2afcd-e5cb-4628-5681-08dc9baa3028 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: DS3PEPF000099E2.namprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: CYYPR12MB8938 Content-Type: text/plain; charset="utf-8" Assign/unassign counters on resctrl group creation/deletion. 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 --- 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 | 78 ++++++++++++++++++++++++++ 1 file changed, 78 insertions(+) diff --git a/arch/x86/kernel/cpu/resctrl/rdtgroup.c b/arch/x86/kernel/cpu/r= esctrl/rdtgroup.c index ffde30b36c1a..475a0c7b2a25 100644 --- a/arch/x86/kernel/cpu/resctrl/rdtgroup.c +++ b/arch/x86/kernel/cpu/resctrl/rdtgroup.c @@ -2910,6 +2910,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_resource *r =3D &rdt_resources_all[RDT_RESOURCE_L3].r_resctrl; @@ -2972,6 +3012,16 @@ static int rdt_get_tree(struct fs_context *fc) if (ret < 0) goto out_mongrp; rdtgroup_default.mon.mon_data_kn =3D kn_mondata; + + /* + * Assign the counters if ABMC is already enabled. + * 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. + */ + if (rdtgroup_assign_cntrs(&rdtgroup_default) < 0) + rdt_last_cmd_puts("Monitor assignment failed\n"); } =20 ret =3D rdt_pseudo_lock_init(); @@ -3246,6 +3296,8 @@ static void rdt_kill_sb(struct super_block *sb) cpus_read_lock(); mutex_lock(&rdtgroup_mutex); =20 + rdtgroup_unassign_cntrs(&rdtgroup_default); + rdt_disable_ctx(); =20 /*Put everything back to default values. */ @@ -3850,6 +3902,16 @@ static int rdtgroup_mkdir_mon(struct kernfs_node *pa= rent_kn, goto out_unlock; } =20 + /* + * Assign the counters if ABMC is already enabled. + * With the limited number of counters, there can be cases + * only on assignment succeed. It is not required to fail + * here in that case. Users have the option to modify the + * assignments later. + */ + if (rdtgroup_assign_cntrs(rdtgrp) < 0) + rdt_last_cmd_puts("Monitor assignment failed\n"); + kernfs_activate(rdtgrp->kn); =20 /* @@ -3894,6 +3956,17 @@ static int rdtgroup_mkdir_ctrl_mon(struct kernfs_nod= e *parent_kn, if (ret) goto out_closid_free; =20 + /* + * Assign the counters if ABMC is already enabled. + * With the limited number of counters, there can be cases + * only on assignment succeed. It is not required to fail + * here in that case. Users have the option to assign the + * counter later. + */ + + if (rdtgroup_assign_cntrs(rdtgrp) < 0) + rdt_last_cmd_puts("Monitor assignment failed\n"); + kernfs_activate(rdtgrp->kn); =20 ret =3D rdtgroup_init_alloc(rdtgrp); @@ -3989,6 +4062,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 /* @@ -4035,6 +4111,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:14:47 2026 Received: from NAM12-MW2-obe.outbound.protection.outlook.com (mail-mw2nam12on2044.outbound.protection.outlook.com [40.107.244.44]) (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 8B640194138; Wed, 3 Jul 2024 21:50:53 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.244.44 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1720043455; cv=fail; b=EpKhMMSeCufdXxYvA2rr4YbiHJi2GWKRkeAdu9m7EXelMkmk0r0ZqdqYfFCtnZ49F4/UlQJGytA67auUI/ZBnMceNKmESEJ8vvf3vqPwa9ZgZMPurQrjyq0eSH2ng1EzHO5TEdv8GGLRMHg/eJCig9luHInFDHh3P3WPg3I8v84= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1720043455; c=relaxed/simple; bh=0E4jmm5o0/08fu9af0EbfKH4+M13JiFEQBz9QMfNNWM=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=N6EItQgBWyZU4bGEO+POOvlzVs3reS+EgiMybmp4qY8xhTBHi3FYksfUYMhCr1SORgmLgLspSVY3/Bc4G5p0Uj+Vlek5eGpiBjHJTsWafu2SOatxLAivfQAndbrVGda965mFcJFdjYEpxm4VBfVO+fRyo8Ck336vEn18ZRv7mak= 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=sEEG51ZK; arc=fail smtp.client-ip=40.107.244.44 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="sEEG51ZK" ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=RO+UI8vRcxBi60cU8AlNo4Ljh2Zs9qODZG9YeD/TO020++4ovZod76eaXIUgxxF+vsASGJ2mCtcVFl8bnRIlQHO+vlMb1O6lZw0d8CfGxRIS96lAoWgdyV/RmJclZYmRSAZg3ir8FgncoJykmZztMPTuHYiVaTQgEc1HFcRnaUjopryxwtOlkhnO6MpoH7NFFEgHBoZsyaEcdkkIj4mQEhER3fXiB2JXFE3WXA58ynsmOB42y/1Y+j0jFK0h87UxpSuRqjMEj8T1jjfLVMGEujdror2jf+TET/TZrHGjIs/d9xwW5XjEzNxcPqPyNgk2CEfUQ0iBbB8iEvKpWTvXRA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; 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=TNLee2lvEWFK0kue5F6Eth46zv8Zkifo5L+rpe3Lpmk=; b=eLhL749eTF3QdB3AzOIlZqGA1nRZl9Zv5EHGxquFBtbWZOpHK5yhyyXW7nzOhd4/dISUesZLzWcj8+vVbGv0vt4PB7dbl70ovVhiauxdhyj8tSjFqCZUT5vOZ53V9VAXskm/EMSqtbQvreyAsDS6mOsbsL05e5mhTiVmloqkrw9AbldL3zOvk0C82eP9PoEgM+E5SCnrpm1EQoe2xfBD+VZx+cApX0CuaKJvU8mflr9tWIbXY+mgn0A0eLTfQBcyxxDM5r8wi3hKEgJgvCaQSqD61RwPRiu2ko7uaHQWj5tNBPT18zGNDRNpQ2Yl999sPjPt2zAFS3FRs46pxdnDeQ== 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=TNLee2lvEWFK0kue5F6Eth46zv8Zkifo5L+rpe3Lpmk=; b=sEEG51ZKX7Quv9OrSojCj9Kndf7nWxoZe9OKc5jih2ccod4KdQJsiFkOVYLNVKOKAfMocpUa1ae1/Q8Vc0SVdCV/RO06Va++GIPO7Ga7FmlCwrc4sMjMWFQ+wmaji+l2ysF4Cnodd15uQ9qBLK6g2T0s4MsWo0Mo9OEjSS8eETw= Received: from DS7PR07CA0019.namprd07.prod.outlook.com (2603:10b6:5:3af::7) by DM4PR12MB6421.namprd12.prod.outlook.com (2603:10b6:8:b7::19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7719.32; Wed, 3 Jul 2024 21:50:51 +0000 Received: from DS3PEPF000099E1.namprd04.prod.outlook.com (2603:10b6:5:3af:cafe::bf) by DS7PR07CA0019.outlook.office365.com (2603:10b6:5:3af::7) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7741.25 via Frontend Transport; Wed, 3 Jul 2024 21:50:51 +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 DS3PEPF000099E1.mail.protection.outlook.com (10.167.17.196) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.7741.18 via Frontend Transport; Wed, 3 Jul 2024 21:50:51 +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; Wed, 3 Jul 2024 16:50:49 -0500 From: Babu Moger To: , , , , , , CC: , , , , , , , , , , , , , , , , , , , , , , , , , , , , Subject: [PATCH v5 16/20] x86/resctrl: Report "Unassigned" for MBM events in ABMC mode Date: Wed, 3 Jul 2024 16:48:27 -0500 Message-ID: <81ca60c0029ba63fab7cfd6903ad115fad1d29fc.1720043311.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: SATLEXMB03.amd.com (10.181.40.144) To SATLEXMB04.amd.com (10.181.40.145) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DS3PEPF000099E1:EE_|DM4PR12MB6421:EE_ X-MS-Office365-Filtering-Correlation-Id: 0ba7b62d-e230-461e-177a-08dc9baa34ca X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|36860700013|82310400026|7416014|376014|1800799024; X-Microsoft-Antispam-Message-Info: =?us-ascii?Q?TFXARq2osde6/ctSjBvOoVOOK03V6gwNRnkPvheuSkb8Yy715XSHPpHHY4IP?= =?us-ascii?Q?4g7zDvD1gB41dttDB9mTI8WoG15Gmh+QI/lodCDnAkw5XbsK9I7V8cSM+0i2?= =?us-ascii?Q?XPP8kqeA2Ujrt7kXqGoF5s6j7slGpS8eRRcu1NNa+TkV6CUyWC83OfpCNZ2o?= =?us-ascii?Q?KXgOgHKYs/fIZnInOb8cULdJLFWca65syTeoZXocwHigrgROO/85iRNbUZY0?= =?us-ascii?Q?knuiFI86DfuRynEF5Y+Teo7T7P0ZN0Bb47ZGq5vHZfdUGbTZDYfyhk52rbkZ?= =?us-ascii?Q?UoopNTZspHOu+sXLz7+MJwtMka9S5qZM97UyAxfAit6B0wxjmu59Jc3ugr0s?= =?us-ascii?Q?YP4MRnjjmjaBwKPl/vNnGajbJT0PWCv0+fGN+bOKmACgsSCi+Bn7LI8AtesT?= =?us-ascii?Q?rwP2Yi3SUEERbbfk0FFEMvvuKJzNPbQu8mNIv4Xum9EceaS+JqqE1K7cWo5M?= =?us-ascii?Q?H8Li9ErsPFJBEaoz3fQFys5+66Nhz3vKlK/keJ8SX8/aB1HJVEELmJii8aqs?= =?us-ascii?Q?HkokOUWWk4PHroyoR7xfB6qiIPNviSchpvBVkOb8XHVuYQjXGpTnOgARPbGv?= =?us-ascii?Q?QVDQCr2dfdhNLPftDLaxRet8NQnxoAyYz2mq7zUo9/FbZxD2BaZTB4MXFMBU?= =?us-ascii?Q?sY/KGDmYUUXt8y5snxZyLb7b5w24izdM9IVEvfpmCv6ofATBmlxfIb+rw9nk?= =?us-ascii?Q?fIyTIJSyS+U+p3X21Xtvtd9bFN39kA/rcjwO9ZkamopLlPfl48S7LbQtLQdg?= =?us-ascii?Q?K7PxJiMqPqSShTNkMGlZJlX2N6ofOcIzCSvz3WgbWcwz6vnEj2vaeLtoD79v?= =?us-ascii?Q?PraBuqZdEPdBdmMd4/8ySe7TrGeHLOYtulbtn8iM5oYhOXZRq5gMPmdnXLm7?= =?us-ascii?Q?dqGcp6cUz8LkqhvHWAlWl6zXMBOtfdW0ctHHpZEB7AosaIVlikuu2D6e4rY0?= =?us-ascii?Q?QK4cXGUYi+lpkWxT2bYmQelTb0VOnMCwgrXGwemXJhOgmw6wvuLd185Ml5Ic?= =?us-ascii?Q?/qKnnyF2ekE58huq1a3Xp6ka7h5HSj251W2EEQZlhS+yodPN9hS5n/kNHEjR?= =?us-ascii?Q?w3ksxO1D48kkjJL3XTCgPC3YUo3HD4OFblLPYUrJkcVWgItbtM+WZZoEExug?= =?us-ascii?Q?wmVq8XKVZEF3Xe32oxNuZDKTecCiaYd1A66iDIUFXIQaQJSHQRusO/Zo6Tta?= =?us-ascii?Q?I4Y0UiWDNGSopXOxP5e2YxRSVsqL7dCXCveZFJGCgfn5s+j7m6Q05ffj3w7b?= =?us-ascii?Q?lOUeVzXA9g3gQ8gVCJnaroSa94xKNMsEwLB0kpPCzGId8XiqxD8/SjTucbfB?= =?us-ascii?Q?lLcBoJeoSMj698+hR1T+csGkx9RVVY6V/fX2/9VeoIah3KWjoPEUiMw+XDCw?= =?us-ascii?Q?MLOko8U/LxDpHsoeDeTSTe7CXEuFh6k4wJRDWUZOCotZiWlaaF2alLUjuu9t?= =?us-ascii?Q?a1DfNGJ35YdHHrukbpYDqOrF3oZSvTRX?= 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)(7416014)(376014)(1800799024);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 03 Jul 2024 21:50:51.1079 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 0ba7b62d-e230-461e-177a-08dc9baa34ca 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: DS3PEPF000099E1.namprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM4PR12MB6421 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 --- v5: New patch. --- Documentation/arch/x86/resctrl.rst | 4 ++++ arch/x86/kernel/cpu/resctrl/ctrlmondata.c | 19 ++++++++++++++----- 2 files changed, 18 insertions(+), 5 deletions(-) diff --git a/Documentation/arch/x86/resctrl.rst b/Documentation/arch/x86/re= sctrl.rst index 4907d0758118..11b7a5f26b40 100644 --- a/Documentation/arch/x86/resctrl.rst +++ b/Documentation/arch/x86/resctrl.rst @@ -284,6 +284,10 @@ with the following files: until the user unassigns it manually. There is no need to worry about counters being reset during this period. =20 + In ABMC mode, the MBM event counters will return "Unassigned" if + the hardware counter is not assigned to the event. Users need to + assign a counter manually to read the events. + Without ABMC enabled, monitoring will work in "legacy" mode without assignment option. =20 diff --git a/arch/x86/kernel/cpu/resctrl/ctrlmondata.c b/arch/x86/kernel/cp= u/resctrl/ctrlmondata.c index 50fa1fe9a073..e60b469b7d12 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) { @@ -609,12 +609,21 @@ int rdtgroup_mondata_show(struct seq_file *m, void *a= rg) =20 checkresult: =20 - if (rr.err =3D=3D -EIO) + if (rr.err =3D=3D -EIO) { seq_puts(m, "Error\n"); - else if (rr.err =3D=3D -EINVAL) - seq_puts(m, "Unavailable\n"); - else + } else if (rr.err =3D=3D -EINVAL) { + if (resctrl_arch_get_abmc_enabled()) { + index =3D mon_event_config_index_get(evtid); + if (rdtgrp->mon.cntr_id[index] =3D=3D MON_CNTR_UNSET) + seq_puts(m, "Unassigned\n"); + else + seq_puts(m, "Unavailable\n"); + } else { + seq_puts(m, "Unavailable\n"); + } + } else { seq_printf(m, "%llu\n", rr.val); + } =20 out: rdtgroup_kn_unlock(of->kn); --=20 2.34.1 From nobody Sat Feb 7 21:14:47 2026 Received: from NAM12-MW2-obe.outbound.protection.outlook.com (mail-mw2nam12on2050.outbound.protection.outlook.com [40.107.244.50]) (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 C65C518C324; Wed, 3 Jul 2024 21:51:03 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.244.50 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1720043465; cv=fail; b=tNak4ghh6imza9+30nEd7jKgRpDXF386JYVo9RMmgAPg9vtbV202afgExKj3eP5V9Bpu/cN0WVloo3tDl6C9cRX0N3RvbCkdIgwrJjAA2vozhYqQB68VZ8BQ9pJEFvra0oz7yCEHFhQq+gMTX2AFHjagOeFF10TCnIrJcnLH7mo= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1720043465; c=relaxed/simple; bh=f/HA/QX6zsMaNfWQOxMrh8GDt6ran5sR3ITfr4p9R+E=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=PJCvgpt3ht6OiagR0Y+SDjvwlerOSMRzicUkf53VywMTpU+egnXXNjzZzUhQA6P8ETU6pD9U4MWswrGJPzJfOOiFuAjdWSw+iGhQbzSRUL6oTLFkh7F/iwXxo4uUB6E93io0Cqw1ejUaIjMdxm3PMd0psk9JAmVoEAVt9OjR0ro= 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=3FzDf8eb; arc=fail smtp.client-ip=40.107.244.50 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="3FzDf8eb" ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=VaC/cVNUUOHMS5QBuoxl7GwYiumYRp17q9gQ26uu25V/ToMggdr5vU+whWPd8gc05cqXCa2GPfIUBIXRBHObWecw0Wo22SxjBNU4Q1dPMRWn/PyZq99WUgkgB7GiUAGhVZsq3eRJzyhuaOncUKHc+pYO/DE4cnemBaxvy2hBH2+1uiKHItO4AlwolJyfZJ2oBeV73y4xYF5bMvxxssLVZMOSTTaSBkwD49A4YVSJc8VYbqkRHVrq2uMQwU0yyV7du2Xsypz5VGqMfKk06dgOpBaEl0r+ViVpYQXPCuDlohfMB+/ETJg4cpQ0znM4CjrLXAYeeYz2IBvcKSXD35hA4g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; 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=yCiFcgbTGtyAX2wkmjQHp1CwB9DcWvfaBtFqiqTBEsI=; b=NsiCj54qRZqU+5t9fJ1ookdIEPXmo6y5t9oWXuf72C7m1lt0a7dof7lyvR9Rq0vrcooQmGQlUVSna12ZLfylJFAX4agZ+HJDUADJW9Su2qlE4a0EwHH2toCWUwJaM5/DzRFqAMLSWaCHpKnPUo0uRYFrnwb8j6c9wfcd1asTlC46VhtazqizSsVgFlapswzy84rJ6ajWQbD67nr0gs1suAj0VKVjveLbyzcfIFmIRrjO+D9HOI8A0aqbRwo+1wCsl2yHBa47G+0mcYhrHF0JlXqm6uOS4lUfPccXft1smLXszAgbSGBhnN/vLXcmBZWgTe2h/vooGg4rCHWw3E9BNQ== 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=yCiFcgbTGtyAX2wkmjQHp1CwB9DcWvfaBtFqiqTBEsI=; b=3FzDf8ebjR+xhQpOZvGCCh2fh5BWNu20E7HAnQ9PpK6RuncGar4IBbAUBhQTA1zdl2Nd7XnkBbo9NrQ/IOFnbI46tEdaQ9y0Ne0ev1PDBKCbQ4hG9tDXgRMa1qTUOFQVDSfKiJgNyWUsXs+h0mnoDdad4NBOzi0ZZt80t1BntZc= Received: from CH2PR05CA0021.namprd05.prod.outlook.com (2603:10b6:610::34) by DS0PR12MB9399.namprd12.prod.outlook.com (2603:10b6:8:1b8::9) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7741.23; Wed, 3 Jul 2024 21:50:59 +0000 Received: from DS3PEPF000099DE.namprd04.prod.outlook.com (2603:10b6:610:0:cafe::af) by CH2PR05CA0021.outlook.office365.com (2603:10b6:610::34) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7762.8 via Frontend Transport; Wed, 3 Jul 2024 21:50:59 +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 DS3PEPF000099DE.mail.protection.outlook.com (10.167.17.200) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.7741.18 via Frontend Transport; Wed, 3 Jul 2024 21:50:59 +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; Wed, 3 Jul 2024 16:50:57 -0500 From: Babu Moger To: , , , , , , CC: , , , , , , , , , , , , , , , , , , , , , , , , , , , , Subject: [PATCH v5 17/20] x86/resctrl: Introduce the interface switch between monitor modes Date: Wed, 3 Jul 2024 16:48:28 -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: SATLEXMB03.amd.com (10.181.40.144) To SATLEXMB04.amd.com (10.181.40.145) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DS3PEPF000099DE:EE_|DS0PR12MB9399:EE_ X-MS-Office365-Filtering-Correlation-Id: e2b4745f-348a-4db9-1a8e-08dc9baa3992 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|7416014|376014|1800799024|82310400026|36860700013; X-Microsoft-Antispam-Message-Info: =?us-ascii?Q?ykFPAnPfLBmT2+p7N7qMD+VyQqzkES6NdedzMdtg4+Yq7TTskdmeAPEHD0DG?= =?us-ascii?Q?tC1gThAVtk7GN+VXMdIzQ06l/mfYe+yiVIr3Ds1b7IplgiLb1SatXz4G1vxR?= =?us-ascii?Q?RcOnvnhrx4UK60ng3NJUs5M66XKNQIH4k+Q7UwsNPFcONkcTT3ZR3MwDZZzU?= =?us-ascii?Q?e0wnF1Y+o1MmUbIdUVpvf5k0pJAkQRvzWs/N5NkAEVUonx/DGeRcV/Z+dC+C?= =?us-ascii?Q?gSRBHqqnn9f0hAdaGEvS21MLQuSLCQnyC5afVrJxsL1Y+xAt4xl7fhFQBZn7?= =?us-ascii?Q?SmGJQ1ClqvRhyXhSXDLCNposeEQMYwuqBCDKm0uxpZXfCchq0VFOvYOyfhOg?= =?us-ascii?Q?XD+xhbuW+bboc8QOpGihkSP94NtMG9PwV8iK7rYdRlL3FUsHT9GJvhZ0jLcb?= =?us-ascii?Q?+LwrCZoFuBLVHoJyntsPaLhBHYrvsceClqGH15jQaIiK9Vu/arSxhXHQ54Ps?= =?us-ascii?Q?ZVcCDhTRwa0hdnSBCIsqlR03SCoVT94fVwzFDh+VwL6QTkUD3fQaVDrb5q0Q?= =?us-ascii?Q?5kw7L8mI6Z76hUeVSzLeRJ6aLZM/kY2qgiVfFR1IjeJ1OO+8FNqIBe6oZ5tO?= =?us-ascii?Q?fkp9EgKarhmPcU3+k44vxD8oKRGSAuxwEu/BMGEPuFJKN049o0PZS7gubimt?= =?us-ascii?Q?apMtEJXmP8jHa+RqGVcB4xdtYp/CmVyf2niUYi9wBg0TjqjqzixAVQ/hAesH?= =?us-ascii?Q?zF1eEHg94EzZtKfipLUNmbubg+6wMgkCq5Npc4HYQni0dPh1E/kgI81OYb8I?= =?us-ascii?Q?t2KuGIX7RiHn3+DttVkJ8N61LgGNCwO9LiTUupu+lYjVdpX73tEAMp2vGV7I?= =?us-ascii?Q?0kCoZTeXig2ypF+V7dUk9lGIMOUm8Rbm7+ek0FFrKKrNPqzsPIJrTY6lXmRq?= =?us-ascii?Q?99EKfFAbx4VoRFc6vz9hUQwR4bIBcD3u4XgprHvPu9S4XKWO0VsDfPHyZAAC?= =?us-ascii?Q?xiYoEneDMopSU8QvIItD0G3R6JggtABd8A/9Dvw6lcjuPCmMRlyXpdOxGyin?= =?us-ascii?Q?2UywjKRsKBSfeWUN1ch1b4VwRZvVbqxPKvunXicrXjCCgcDxnJVelUirj6jP?= =?us-ascii?Q?muGEiscHwpDDzvR3aWR5XzHQKSzBgXh4eYz4EN34dYU6npjbgnRibKWDFj8z?= =?us-ascii?Q?FR3AMCbnEX5+r+7LZm6VBg0uTAzkWbHAY9ePfzTnsRbGVs5opYsF6ofqTkaQ?= =?us-ascii?Q?3DT44odtv6dkXwURnyIr+SCzhkVBAdltcvyIoxqv//ES31lgzvpeO+0cb8mF?= =?us-ascii?Q?y3LEN9XA5AJVTqpv31Dd3+EVlhd2vyqKxtOGHFjwf9c3bNOIcQUkCq9xf5jW?= =?us-ascii?Q?aWNp6QSb4mseUQhyGP0RQ/O4OG734339cIMRIheqCgrcX5m6OVgKC9/RAcVj?= =?us-ascii?Q?HczdkiHmX6pHooj2CHLfMNUhcSk4KyhOKzK0RqmQtimnRKmEiGD+F9ArPWh7?= =?us-ascii?Q?h51j5a6l1KGq2XHawm/2BcO2NCn9/9d5?= X-Forefront-Antispam-Report: CIP:165.204.84.17;CTRY:US;LANG:en;SCL:1;SRV:;IPV:CAL;SFV:NSPM;H:SATLEXMB04.amd.com;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(13230040)(7416014)(376014)(1800799024)(82310400026)(36860700013);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 03 Jul 2024 21:50:59.0514 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: e2b4745f-348a-4db9-1a8e-08dc9baa3992 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: DS3PEPF000099DE.namprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DS0PR12MB9399 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 [abmc] legacy To enable the legacy monitoring feature: $ echo "legacy" > /sys/fs/resctrl/info/L3_MON/mbm_mode Signed-off-by: Babu Moger --- 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 | 10 +++++++ arch/x86/kernel/cpu/resctrl/rdtgroup.c | 37 +++++++++++++++++++++++++- 2 files changed, 46 insertions(+), 1 deletion(-) diff --git a/Documentation/arch/x86/resctrl.rst b/Documentation/arch/x86/re= sctrl.rst index 11b7a5f26b40..4c41c5622627 100644 --- a/Documentation/arch/x86/resctrl.rst +++ b/Documentation/arch/x86/resctrl.rst @@ -291,6 +291,16 @@ with the following files: Without ABMC enabled, monitoring will work in "legacy" mode without assignment option. =20 + * To enable ABMC feature: + :: + + # echo "abmc" > /sys/fs/resctrl/info/L3_MON/mbm_mode + + * To enable the legacy monitoring feature: + :: + + # echo "legacy" > /sys/fs/resctrl/info/L3_MON/mbm_mode + "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 475a0c7b2a25..531233779f8d 100644 --- a/arch/x86/kernel/cpu/resctrl/rdtgroup.c +++ b/arch/x86/kernel/cpu/resctrl/rdtgroup.c @@ -910,6 +910,40 @@ static int rdtgroup_num_mbm_cntrs_show(struct kernfs_o= pen_file *of, return 0; } =20 +static ssize_t rdtgroup_mbm_mode_write(struct kernfs_open_file *of, + char *buf, size_t nbytes, + loff_t off) +{ + struct rdt_resource *r =3D of->kn->parent->priv; + int ret =3D 0; + + if (!r->mon.abmc_capable) + 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(); + + if (!strcmp(buf, "legacy")) + resctrl_arch_abmc_disable(); + else if (!strcmp(buf, "abmc")) + ret =3D resctrl_arch_abmc_enable(); + else + ret =3D -EINVAL; + + mutex_unlock(&rdtgroup_mutex); + cpus_read_unlock(); + + return ret ?: nbytes; +} + #ifdef CONFIG_PROC_CPU_RESCTRL =20 /* @@ -2103,9 +2137,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, }, { .name =3D "cpus", --=20 2.34.1 From nobody Sat Feb 7 21:14:47 2026 Received: from NAM12-MW2-obe.outbound.protection.outlook.com (mail-mw2nam12on2060.outbound.protection.outlook.com [40.107.244.60]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 87DB8194AC4; Wed, 3 Jul 2024 21:51:10 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.244.60 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1720043473; cv=fail; b=P7Vonf0WfbnvYlPAIR575XJNJkfxRSs32WjvascrEkfdl1VGeRYA5tMcdeLBK+lY6Wz/ZysEDqenIexrBQn9kvG5SSTArEVX8U142chOs+4zkeIcAMHTmUo9/j93uSM88K8a+E6uInBuwE0JXlBWu67172pzg+lJezS9zI+8aYE= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1720043473; c=relaxed/simple; bh=CU6SO0kAXbQnO9dniZsPY1sqLqVPLOCkBJgApCvboOM=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=CTA4Q4hGllsRyF8KWVmHgIuhLTGVFH/g0tqETIvUzRVmEbnoNdP305orII4XmGdlzfm4/3I+JnDQeD+7D9+dsWfAtufYTG7aZ8AiTGausln9/L3qBLFM/SeB7iBuw6b8+bAuuxtZSrWt2ZA00oHRc/ldN0c+bIP17HDlLrZYSI0= 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=MOvVHy5l; arc=fail smtp.client-ip=40.107.244.60 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=amd.com Authentication-Results: smtp.subspace.kernel.org; spf=fail smtp.mailfrom=amd.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=amd.com header.i=@amd.com header.b="MOvVHy5l" ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=GzGLjwf1l7N3+8Sbc4SgDNozVdWX7kRsz5CzFKeZOXEyoB77/3Uwkd9LDIQ/9uMyH/yaAvx2AbexqvKW2rUYbzssrH1KfxOcYrTaSZFOZZ8BfIM2WrfkoBwsOq0CXHKHyQM+seXNUb2TnFkseh6JLa3SJkDdsNLM8Abm+J68e81OrII8QqW6p9lc7sKW1D/eX9G0RWbdRT5R215xAGu5y7RNRahCKtKoXVRF18ZLIYSYHhOjSh2zH/78KY4pbYRAJWDB5GY3/8ylsxArWJ3mpFqS+XRR5/Ze46diSfLlL+RWwXLV6hPMRtCI0iQ9apk7AWAnDjOulzCpQJRsTfbfIg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; 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=+SmqqyToPrcIZfWLknPF8X29VVoSLT/I9ubg2MjOVII=; b=mVBIUd+4atPqY1bjo0PaKyH+SoMRM+DeXXuH9vbeIBmb8pDhWHMy8aJN14w5RsHBUWugNqbX8DSvQ1lMTqNkcqkYp2HQNsLhlrQ4kuvyOrXmxeE/Idmy0BpG5ofbfbpHGeQxFQ9/Yoaf4EFRigXvslkn0zIjSM/Q9v1QFPe++hT50H3ilXLZ3NS18AVn32iTCiw9zRdCflW5Ra+HXcMRPKp8J3FKMedrdsOcPlfoMVT1fs2ggzyOLXwhQUmQ4IqaBhxYRW0emoQ2lKF5KTzVmjsSiR6s51YmYAwI4y95wpJwvb4Z7t35sNSq3LqIdhpm2r7c6hgNTYxHslgoUk5Ieg== 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=+SmqqyToPrcIZfWLknPF8X29VVoSLT/I9ubg2MjOVII=; b=MOvVHy5lSDfN0Osuin6Sah49QJzaOVo1ttfNn9xX2HtLj/vCpGvhp61nL4qTopiw7t+7t+ngrstUqdkKySjLuhPeOa6PLDgYSfmNl1srSMabaPR/RDkZz8xGFORvrTyX8W5hiNo46E7GzF5PtqvEwdAFVEz3MevBwOl0Dxl4WAg= Received: from DM6PR02CA0140.namprd02.prod.outlook.com (2603:10b6:5:332::7) by SA1PR12MB8642.namprd12.prod.outlook.com (2603:10b6:806:383::11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7741.25; Wed, 3 Jul 2024 21:51:07 +0000 Received: from DS3PEPF000099DD.namprd04.prod.outlook.com (2603:10b6:5:332:cafe::c1) by DM6PR02CA0140.outlook.office365.com (2603:10b6:5:332::7) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7741.27 via Frontend Transport; Wed, 3 Jul 2024 21:51:07 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 165.204.84.17) smtp.mailfrom=amd.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=amd.com; Received-SPF: Pass (protection.outlook.com: domain of amd.com designates 165.204.84.17 as permitted sender) receiver=protection.outlook.com; client-ip=165.204.84.17; helo=SATLEXMB04.amd.com; pr=C Received: from SATLEXMB04.amd.com (165.204.84.17) by DS3PEPF000099DD.mail.protection.outlook.com (10.167.17.199) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.7741.18 via Frontend Transport; Wed, 3 Jul 2024 21:51:06 +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; Wed, 3 Jul 2024 16:51:05 -0500 From: Babu Moger To: , , , , , , CC: , , , , , , , , , , , , , , , , , , , , , , , , , , , , Subject: [PATCH v5 18/20] x86/resctrl: Enable AMD ABMC feature by default when supported Date: Wed, 3 Jul 2024 16:48:29 -0500 Message-ID: <9f03d5661a4f054124cc7ae1903207714c5188ee.1720043311.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: SATLEXMB03.amd.com (10.181.40.144) To SATLEXMB04.amd.com (10.181.40.145) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DS3PEPF000099DD:EE_|SA1PR12MB8642:EE_ X-MS-Office365-Filtering-Correlation-Id: 86930aea-d815-4db9-d287-08dc9baa3e40 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|7416014|82310400026|1800799024|376014|36860700013; X-Microsoft-Antispam-Message-Info: =?us-ascii?Q?ibnFNYBFKav35d9rkY+UFBjaSFVVLiJmWgs5JB0xALPaJ+OaIRBbrdr5r0Kj?= =?us-ascii?Q?QPvnWPrYyJopfsriaI8Jo+t6RTMNA6nlGhQpso5m6uprHhPpPeDzKaf38sdo?= =?us-ascii?Q?yuVGjUYyAQWIwMAwyiZWgtlAHFqLql8Ry4mNewpOxmLUn8oRJm76SdXT0wXv?= =?us-ascii?Q?RHAmIaNa+5diH8pDllO7I2DEWALOJuDUZEGoxmNFWRZtFJrHcmC9i3I0lm5P?= =?us-ascii?Q?cuVBcK1SYkY2XMJZOe8p/nIMi/CVjssy3A/t/5SLyQLdvzu0y1XruRwFUSLq?= =?us-ascii?Q?FNCl58u/dp1Ckhpb4F+YO0DYVAxAH7wQ2Ak00zhudodox7ssrwP7K3LKhglU?= =?us-ascii?Q?JMONP6UsNMtHrSZ0ooH/A0jp8K17nllscK81+LiImSeFq2uFr9fPS9cm5PfP?= =?us-ascii?Q?Hluqq1WGZyxsYpDNRJs6O/utDs+ZPSFMRCuoS5FAW+qm6oGM5CdoRQETjq/I?= =?us-ascii?Q?FPb6MyV4zWv3lusXqiO+mUe3+F9J+jDOqRYsrkLPAZRkEnS5B6UQ9Sm+Lc1s?= =?us-ascii?Q?ZLYHOenUFkTK/121wzNCaTnifmx1PhX8YZfJ7lh6BWDdI5IMI+O//0ZEybWY?= =?us-ascii?Q?JIftDrLrtm1WaArGLzje9MYgqLjbUj8yBDhix+uz0vpgaEXlla87CgCt7ydU?= =?us-ascii?Q?izPcrbt4jmQG7IdM9gTNWLiDzhuScNrc4L5FE6Q9d+Fonva26dqfpC9pkWFk?= =?us-ascii?Q?YM+YvxMTDvZ/yayGUlRNq7qjVx+GWVyLsI4sQtLHXt+X9Xyx6fBBSk0HkAax?= =?us-ascii?Q?SDk617CoP9ebFRYT9p1s8vHOmM413eS9KGk9y0TljqmFSD3WdRzpC20zZZjI?= =?us-ascii?Q?5nv+ITdYhjDFPY5gj3OKHNG5lvHJRg7RPU6Oaa/lekRbhQcGy1hzWFLipfcR?= =?us-ascii?Q?ghenYYaXwpHEiyGhOV5AVnZbDshuoDwy8TE+WkFDJeqOagu+O1vVlIEKzyUC?= =?us-ascii?Q?392gCm1YeT65dIMBvSf85bUtqd8E34AVELicdgSf84UScLANtheR5bp/CsJ9?= =?us-ascii?Q?CVAa/NB7Av7by8eJmxLeplw88Q1oGZ5nvzS6kdcDArmZcbVwHDL8hmPQ3GlV?= =?us-ascii?Q?Xc2tFod8f+a2hy2XG9nkeBFgZXnoAJB79tfA6Y9l2ebx41PtontTRLXZH1ms?= =?us-ascii?Q?3r/yeOel3KhlN/CeLsHePZKqIdR+Wd/JRMWqq8pJCE6scaWfOvnmbWhaAEbh?= =?us-ascii?Q?zqX109BafIY7PB0gEoPjthlTzZjE/rErcXzATqMQQljm9AMuB6Cs5HXQ7+Cy?= =?us-ascii?Q?3OAeV2FyPkK3jD4zREH8GS/DrdTV3w8K/bBH65MW0xhxR5/1YZ7RZitCyclX?= =?us-ascii?Q?1IMJMYJ8R2ZAyf2P1Rb7iiQRS42xqmuXlwp3BECAlmokqtXmJ4E/CQZm+fLc?= =?us-ascii?Q?aMuA9DAk6J4n+QlIJdis4JRRy3FWWcN8ajtvzAUxCgZWRr6JWC9qY9SzJuCG?= =?us-ascii?Q?Sbv7GXpGCa9u57A5cCY112v5uJJzh52f?= 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)(82310400026)(1800799024)(376014)(36860700013);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 03 Jul 2024 21:51:06.9855 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 86930aea-d815-4db9-d287-08dc9baa3e40 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: DS3PEPF000099DD.namprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: SA1PR12MB8642 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 --- 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 6265ef8b610f..b69b2650bde3 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_configure_abmc(); 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_arch_mbm_evt_config(hw_dom); + resctrl_arch_configure_abmc(); =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 beb005775fe4..0f858cff8ab1 100644 --- a/arch/x86/kernel/cpu/resctrl/internal.h +++ b/arch/x86/kernel/cpu/resctrl/internal.h @@ -707,6 +707,7 @@ void rdt_domain_reconfigure_cdp(struct rdt_resource *r); void __init resctrl_file_fflags_init(const char *config, unsigned long fflags); void resctrl_arch_mbm_evt_config(struct rdt_hw_mon_domain *hw_dom); +void resctrl_arch_configure_abmc(void); unsigned int mon_event_config_index_get(u32 evtid); int resctrl_arch_assign_cntr(struct rdt_mon_domain *d, u32 evtid, u32 rmid, u32 cntr_id, u32 closid, bool enable); diff --git a/arch/x86/kernel/cpu/resctrl/rdtgroup.c b/arch/x86/kernel/cpu/r= esctrl/rdtgroup.c index 531233779f8d..d978668c8865 100644 --- a/arch/x86/kernel/cpu/resctrl/rdtgroup.c +++ b/arch/x86/kernel/cpu/resctrl/rdtgroup.c @@ -2733,6 +2733,23 @@ void resctrl_arch_abmc_disable(void) } } =20 +void resctrl_arch_configure_abmc(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.abmc_capable) { + if (!hw_res->abmc_enabled) + hw_res->abmc_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:14:47 2026 Received: from NAM12-MW2-obe.outbound.protection.outlook.com (mail-mw2nam12on2061.outbound.protection.outlook.com [40.107.244.61]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 48354194AD7; Wed, 3 Jul 2024 21:51:17 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.244.61 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1720043480; cv=fail; b=hJZgDL+Uwe7rtd8Iy8giI6jP4DTB21KRwfrtNyWzTMKqVs0NQfw+pKHaf/aHSjTQOhvkS7rvX82xkOhD+ew9iJ6OGCS1yb9afcv71UjbjYk3oXNhv4784c8M3yT1pqDkEmumy9U8TBvdfaYXTFwVQUW6ZYfuom7kd2AzA35GXko= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1720043480; c=relaxed/simple; bh=Ao9rI6HmNjfmU+cDoY2K0GJLhfLJwncWR7yYMaW4DZ0=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=ValZQMmTmZynFyINA0AOG5//VfhqP06NzZ6mGTQoYJbEVK4ksakacq9YSJiBeunCoMEyh9ovXv1As7EzEMuT12aKqK4h7Y+cxuxXf86bkR/oxSAruptuyJXMt5VdWRi1UB5i4lQIWqMgxsBIw7SSRkIRpZ9JC68SFaGKLekU9ZI= 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=lk4OU/WD; arc=fail smtp.client-ip=40.107.244.61 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=amd.com Authentication-Results: smtp.subspace.kernel.org; spf=fail smtp.mailfrom=amd.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=amd.com header.i=@amd.com header.b="lk4OU/WD" ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=hTU1qEwGumSsCh1wIt7YzSqMQCyI/3p14PZrne/NW3H70rn0ewsdFdwr/h9F5aTV9fRt5t+z4NXNw73AIRp+MbiyleRYZ/aunGrMqR3NuEKbXjI8ezfSW4CVNu0cpwmFLCEWpxJ4y3H8pAG1EpRPWYzAeGI9NkPChDQ2gFC4aVHug4nkoTMp9NaBSk5eAZYZJeNgQKcnaTXrPsTwyEaihrnWnAl5uMv+w3UcmzuXtwGNH0s9b6HthxLh6ncUFMoJ1rwhmrGb5QOkkIoNoIgTuXRTxvHZZ1WtiCiZqbzJMhorbis+YXYpBiM+zgvh+dREAL5IgKI6Zvpd3gWiQYiD3w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; 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=cYDJJCSfWvlSp0DbP2n02ZCGoHjQcL7La07xiVn8JK4=; b=Vf1hnE+ssF7C9LZCL4S4R7Vr5tHEF7uDx+HzMygczy0OIVoSFRy8AzK3rxuhc3xrrj/J1vYmCwi9kehHnX7DhfG5ek8IgKDXBPepqQUOIESUsNUNVM/iBCK7EOeDV5fTtOReAMz29mUlujH+vNZjT5NgAzZCUFzzjWD9LYSh8G9rAI6705xhLP1xGYQFM4pwqklJWAw2y6BbXdti5Ur2DdDqhE0pPcpmabRRU49FUq/q0sy8YGZIn0f6N3EeoNWS+FJ9HXJqO3vJdc24KlG+gPcWWQLtQ4rnoeYQxgCRTMKjSoIwwSeAVuwXzzQuuW9NNATgSBeJnvhzru0FWY540g== 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=cYDJJCSfWvlSp0DbP2n02ZCGoHjQcL7La07xiVn8JK4=; b=lk4OU/WDfi1Wx4wABcXU6HjilpZMdk2eDnuWLiOzrGCA1RoOY7unqlYM/17U79ZifAO4sU0+k9oIXCpfVEwxbwUBhpKpUeutySsa43zTFXx/WXTvJfNm7019BOXTsDJ9/2CJhC05rgRz+bgiWaajcmMlVuTnKNuQ23xe/Ochyxs= Received: from DM6PR02CA0139.namprd02.prod.outlook.com (2603:10b6:5:332::6) by SJ2PR12MB8782.namprd12.prod.outlook.com (2603:10b6:a03:4d0::21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7719.33; Wed, 3 Jul 2024 21:51:15 +0000 Received: from DS3PEPF000099DD.namprd04.prod.outlook.com (2603:10b6:5:332:cafe::c2) by DM6PR02CA0139.outlook.office365.com (2603:10b6:5:332::6) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7719.34 via Frontend Transport; Wed, 3 Jul 2024 21:51: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 DS3PEPF000099DD.mail.protection.outlook.com (10.167.17.199) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.7741.18 via Frontend Transport; Wed, 3 Jul 2024 21:51: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; Wed, 3 Jul 2024 16:51:13 -0500 From: Babu Moger To: , , , , , , CC: , , , , , , , , , , , , , , , , , , , , , , , , , , , , Subject: [PATCH v5 19/20] x86/resctrl: Introduce interface to list monitor states of all the groups Date: Wed, 3 Jul 2024 16:48:30 -0500 Message-ID: <3be66db2dbbe2d231fd5afbe6c7f092278b5a903.1720043311.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: SATLEXMB03.amd.com (10.181.40.144) To SATLEXMB04.amd.com (10.181.40.145) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DS3PEPF000099DD:EE_|SJ2PR12MB8782:EE_ X-MS-Office365-Filtering-Correlation-Id: f2f7f601-7bc0-4236-2437-08dc9baa4322 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|1800799024|82310400026|36860700013|376014|7416014; X-Microsoft-Antispam-Message-Info: =?us-ascii?Q?o7M0hAc4DAIwVAJ3v9xWY8iH0SRqr547vE+xoTBYfBlahsactXhuERwmU7wj?= =?us-ascii?Q?PFXW1oRAgCmMsWr+RnSSfDc+lgEhQ17OqTTPK2VACsj7wCsEI5ta6zFXHIRY?= =?us-ascii?Q?bUlTdEGSFGvn5pG3ySGCUuqNLypSNNSH8qBEFTUtxqcPIJXBnSjV8Vdnq9V1?= =?us-ascii?Q?Ai+A9HGl22CQeE72bDBoZzEuOEtf4wHseszgKA+XM3xnXTCFfYs6vOkvEILM?= =?us-ascii?Q?taf43Rqb2qvG3P042Um+3Z/pM00OHDz1DzoQKlplDcYZtUHALM6WL1nY4kJC?= =?us-ascii?Q?F1VyiV85VWUdZFBYjlUWPrYYv6U8NXzcbEizMiYCl2jRTCEVJND/f1qadqi7?= =?us-ascii?Q?tnLbx2ZkR/oo7Y7VErxd/DAcrCSLTXT3WijtVyvZI2aEY1lawCK29IuY5t7j?= =?us-ascii?Q?vAj8eNIN2F3Jf4aFurHzvGrGs9eWTOoRantXLR5/rX5cKrhFvn0O1yQQTprf?= =?us-ascii?Q?TKKevyLIepXbQayg3VlyqHCjllsVdF7OwDWVOCHSoRCBRU9GlQoP7YgiOe5v?= =?us-ascii?Q?+6KPsW78/LxO853GgSaHdt/wMbCuu61oquxX9taHvnouBQ5pk9SQLrWBX5CA?= =?us-ascii?Q?na0lcXFh250Ef3x21SsaoKZRWwGOXWFjDL4EtGv6ynq3FdxkMWgsMD8NKvNz?= =?us-ascii?Q?wN817Mhxy59NWUowhWSyJVhYe5Tohk8SpHdZXGZ79/cckbcdfaTRqVissCeF?= =?us-ascii?Q?wVI1Zvur0eEuAQwQrHUjP+nJFjEEqr+yQn3yfL9WjEtlby6OOUAK3unJvvPF?= =?us-ascii?Q?hXAqbzPbTftz7/F/aH1K3FFEvb9lcSGv4GswuV/3pu+0JOila+QzrYaPAEww?= =?us-ascii?Q?3SfGu9TP/C8pkW4MYuB0IWDXccSTd7TEqFPLpOB2iy64t7mcig2wjP+NwidK?= =?us-ascii?Q?sxZjv1sJsZw76cFtwBzE7g/yNgdzE0yGzVI9GZ3FXBh2cQaYMF7kSyn98kkY?= =?us-ascii?Q?vEJfPXC7lI8k/sQzBCyuMSMbGjHfj04cGQpMH4xvSYI7uD8r7wFcxy2jyzMJ?= =?us-ascii?Q?FldI+3L3HHppJ5wGOkKTznRpKsaIA3Dw1Ci+mBJFZD3ecDd7oXOqu/6A1qh1?= =?us-ascii?Q?khKpzZuh/EYuHGexVYeWPXczuOU2bzOz0y0aNvvmx7mNdo8bgBalrcQUYzPU?= =?us-ascii?Q?F3ug3ChvjF1T+ufyVtyu7JvDqFA3vSWAM9khIlHBwwpKfRj+O+uC7m4aeK3o?= =?us-ascii?Q?9kd8EkJ5VViuNTXFxDeLY//V0MP3FQ4gCjfsqMxJM0BsrULQxwusNBDNIg8U?= =?us-ascii?Q?Z5CcBX2zJkraa73g9kc8T/q6KIOa5C70u4HYZIDvShOIYjNg52L2A0AHd743?= =?us-ascii?Q?gWtjLF9TZ6aE8nb1ZeYyXEWpCx6qiVGKnbUws8IlohGhi0QFJt2gr7nNZ0g/?= =?us-ascii?Q?MI748aZ2IZH+p9RSOviP387QGJtRHPhjYyhAAXbyEQYyWlm9Bw=3D=3D?= X-Forefront-Antispam-Report: CIP:165.204.84.17;CTRY:US;LANG:en;SCL:1;SRV:;IPV:CAL;SFV:NSPM;H:SATLEXMB04.amd.com;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(13230040)(1800799024)(82310400026)(36860700013)(376014)(7416014);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 03 Jul 2024 21:51:15.1730 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: f2f7f601-7bc0-4236-2437-08dc9baa4322 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: DS3PEPF000099DD.namprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: SJ2PR12MB8782 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 --- 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 | 54 ++++++++++ arch/x86/kernel/cpu/resctrl/monitor.c | 1 + arch/x86/kernel/cpu/resctrl/rdtgroup.c | 130 +++++++++++++++++++++++++ 3 files changed, 185 insertions(+) diff --git a/Documentation/arch/x86/resctrl.rst b/Documentation/arch/x86/re= sctrl.rst index 4c41c5622627..05fee779e109 100644 --- a/Documentation/arch/x86/resctrl.rst +++ b/Documentation/arch/x86/resctrl.rst @@ -304,6 +304,60 @@ with the following files: "num_mbm_cntrs": The number of monitoring counters available for assignment. =20 +"mbm_control": + Available when ABMC features are supported. + Reports the resctrl group and monitor status of each group. + + List follows the following format: + "//=3D" + + Format for specific type of grpups: + + * 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 event= s are + enabled on domain 0 and 1. + + non_default_ctrl_mon_grp// - This is a non-default CTRL_MON group. + + non_default_ctrl_mon_grp/child_non_default_mon_grp/ - This is a child mo= nitor + group of non-default CTRL_MON group. + + // - This is a default CTRL_MON group. + + /child_default_mon_grp/ - This is a child monitor group of default CTRL_= MON group. + "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 b96b0a8bd7d3..684730f1a72d 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 d978668c8865..0de9f23d5389 100644 --- a/arch/x86/kernel/cpu/resctrl/rdtgroup.c +++ b/arch/x86/kernel/cpu/resctrl/rdtgroup.c @@ -944,6 +944,130 @@ static ssize_t rdtgroup_mbm_mode_write(struct kernfs_= open_file *of, return ret ?: nbytes; } =20 +static void rdtgroup_abmc_dom_cfg(void *info) +{ + u64 *msrval =3D info; + + wrmsrl(MSR_IA32_L3_QOS_ABMC_CFG, *msrval); + rdmsrl(MSR_IA32_L3_QOS_ABMC_DSC, *msrval); +} + +/* + * Writing the counter id with CfgEn=3D0 on L3_QOS_ABMC_CFG and reading + * L3_QOS_ABMC_DSC back will return configuration of the counter + * specified. + */ +static int rdtgroup_abmc_dom_state(struct rdt_mon_domain *d, u32 cntr_id, + u32 rmid) +{ + union l3_qos_abmc_cfg abmc_cfg =3D { 0 }; + + abmc_cfg.split.cfg_en =3D 0; + abmc_cfg.split.cntr_id =3D cntr_id; + + smp_call_function_any(&d->hdr.cpu_mask, rdtgroup_abmc_dom_cfg, + &abmc_cfg, 1); + + if (abmc_cfg.split.cntr_en && abmc_cfg.split.bw_src =3D=3D rmid) + return 0; + else + return -1; +} + +static char *rdtgroup_mon_state_to_str(struct rdtgroup *rdtgrp, + struct rdt_mon_domain *d, char *str) +{ + char *tmp =3D str; + int dom_state =3D ASSIGN_NONE; + + /* + * 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 + */ + if (rdtgrp->mon.cntr_id[0] !=3D MON_CNTR_UNSET) + if (!rdtgroup_abmc_dom_state(d, rdtgrp->mon.cntr_id[0], rdtgrp->mon.rmid= )) + dom_state |=3D ASSIGN_TOTAL; + + if (rdtgrp->mon.cntr_id[1] !=3D MON_CNTR_UNSET) + if (!rdtgroup_abmc_dom_state(d, rdtgrp->mon.cntr_id[1], rdtgrp->mon.rmid= )) + dom_state |=3D ASSIGN_LOCAL; + + switch (dom_state) { + case ASSIGN_NONE: + *tmp++ =3D '_'; + break; + case (ASSIGN_TOTAL | ASSIGN_LOCAL): + *tmp++ =3D 't'; + *tmp++ =3D 'l'; + break; + case ASSIGN_TOTAL: + *tmp++ =3D 't'; + break; + case ASSIGN_LOCAL: + *tmp++ =3D 'l'; + break; + default: + break; + } + + *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; + int grp_default =3D 0; + char str[10]; + + if (!hw_res->abmc_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; + + if (rdtg =3D=3D &rdtgroup_default) { + grp_default =3D 1; + seq_puts(s, "//"); + } else { + grp_default =3D 0; + 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) { + if (grp_default) + seq_printf(s, "/%s/", crg->kn->name); + else + 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 /* @@ -2156,6 +2280,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:14:47 2026 Received: from NAM04-MW2-obe.outbound.protection.outlook.com (mail-mw2nam04on2044.outbound.protection.outlook.com [40.107.101.44]) (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 9EAD8194AC2; Wed, 3 Jul 2024 21:51:26 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.101.44 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1720043488; cv=fail; b=Zy2rF1Gj8fH378W39YjOlzu9R4yy4zYVEK+S3k+DnXf3WgQj7beAUKTlY1U4njEIzU87nW3ZtkEIZ25IarUBxDnDeXaqJ5CyjjILvRWCR6zUkJBcCf0NLNh4+S/NdsLXK5AZE4idtf8yZzoToCZOCVT/WuplazZsj/Gi+ICCRUQ= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1720043488; c=relaxed/simple; bh=ez74uEXJQjDKAjZWTWltz6AlHYKJQpaISZMoBnjzZeI=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=B6FNj2wIImf5tyZvfB97G67iReZDnqjuepmzsRoujoDOFO/gmhmV7TkMciYQi1c+SgZhRRECLRVsct5u+w3gaG0j3KSmIr1jZkHtXr8HXmcwEvKHI5ruuTOQtEgCnoTs7/8U3WOQ4cSC4PNQT1l7VGQBqOlYPhgQQmUCrSu4smw= 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=brKOHcOp; arc=fail smtp.client-ip=40.107.101.44 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="brKOHcOp" ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=oPssGzH4q+oo0QeZURJUiRUOLUBh1ASA8aXySC7Po72a+WbQNwenHDaFMOJ+7Az5wkJ98HIf8b0r9qPWmnDEiEY+l0uM8OTH9fyh6Ni6ATIOmZB9NlCzoO5n7id1++QCfKwwH8bErEwYhYuXWzi1gy2Qyz1MQz2pahxnHA1PdEPeWiDywyKpaE5NV5v0/ItjmIkfm5H22jZNpgF3UL5LU8I6GB7vBakO8vYRQExblkN6PiFQ1XOKHRJ8hOW1ebq+ghv88fPWUbvqDTht5m/yeo10Gf+Bi7s812VAPKm8Pi9RDypZg/11Ahpudemqu5QNN+dqOrcQNlnE5jRvty1J9g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; 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=rK+E7FmSud0CYmjxuahPKNHj4bNImm5Ncs4Rdp8g2Js=; b=ZxKpCqvJpnnwlj4z8SMMzTLUWoGF+Ef1H6eOhPCkQdXYtXu9gPF3TGW5d0KoHu9kI99006/i1h3Bln3h7dH63qf0MnffXvvtNuSa//M/fYb6IeaDkShvYPpvFfn1+ZXzhv1pA88sxb/yGVfgOrMC10GkOoWwEmho5fTnAiMRS5MH5083qhlAgVvSw1e590l62lUUgDROAGID5JqUmff2Jlylw+W0XGrJKh5gqF4QmDGZtRtpCvvaiuJINJn4iRuFYo7MsSITs5YX1Gdx5lhy4s4znNCdgsEPjt00fIJxVvDpL52yDc69ELYzw3EmRRHB+SCgHSbX/A+p72o8rbSLig== 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=rK+E7FmSud0CYmjxuahPKNHj4bNImm5Ncs4Rdp8g2Js=; b=brKOHcOpFQEGyqzFAzQ25J0nXSbPSmnbq7wVICzTS55Ymk7rKyB8jSpCZqkICP4UDGiN9wlNm64K2+OlKz9vlknWdYkMjMuRDgTbd1OYCKzqzf2P/6EcubOoX3yrVAJrAIQSbHmJlqiEri0mUygIxUZwpVk0OfrBswFNy8h6nfQ= Received: from SN7PR18CA0026.namprd18.prod.outlook.com (2603:10b6:806:f3::18) by CH0PR12MB8505.namprd12.prod.outlook.com (2603:10b6:610:193::21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7719.26; Wed, 3 Jul 2024 21:51:23 +0000 Received: from SN1PEPF0002BA4C.namprd03.prod.outlook.com (2603:10b6:806:f3:cafe::82) by SN7PR18CA0026.outlook.office365.com (2603:10b6:806:f3::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7741.25 via Frontend Transport; Wed, 3 Jul 2024 21:51: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 SN1PEPF0002BA4C.mail.protection.outlook.com (10.167.242.69) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.7741.18 via Frontend Transport; Wed, 3 Jul 2024 21:51: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; Wed, 3 Jul 2024 16:51:21 -0500 From: Babu Moger To: , , , , , , CC: , , , , , , , , , , , , , , , , , , , , , , , , , , , , Subject: [PATCH v5 20/20] x86/resctrl: Introduce interface to modify assignment states of the groups Date: Wed, 3 Jul 2024 16:48:31 -0500 Message-ID: <49aa5321f6e81825a0e9e44cef06c243634e341a.1720043311.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: SATLEXMB03.amd.com (10.181.40.144) To SATLEXMB04.amd.com (10.181.40.145) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: SN1PEPF0002BA4C:EE_|CH0PR12MB8505:EE_ X-MS-Office365-Filtering-Correlation-Id: a76bcd91-069a-409f-f117-08dc9baa47fd X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|376014|82310400026|36860700013|1800799024|7416014; X-Microsoft-Antispam-Message-Info: =?us-ascii?Q?SK5um9buvovfPlPI73cUG9iNP+2RP1QjrJNSVElH2oc1Xc5+A7HC1JtUGqS8?= =?us-ascii?Q?N4ranF3wsUZftd+Rr6M7DsNlpJPcV4ELaqpPg59Uv7YjtHPKddwtjb09uoZA?= =?us-ascii?Q?uFdpRI/+kmND/nK42CjKbRJTQo/9ufCA7/EhmsVGyC9/yTY+KTN+Y5RUnrlg?= =?us-ascii?Q?exuOQSm0iVH+w+mR2+2enp4+mvqtE8U6CB5H21qPTR9nfjsal68Tz0ulEEyh?= =?us-ascii?Q?Zs6ULmcSnRVzKakgD0Aa/+YV/FlwpufmhCWnXXAv9qK08TXlYn7AanPzgro3?= =?us-ascii?Q?RF2SnBf+Dd8THvrgpSso972qs/DWnC5XfL1zEMRm1WRIimU5WcprUvHCdBPm?= =?us-ascii?Q?Qe0ywiwIMZiPpo2ZAg1nO1+aTP320KDhnssP09PKhu1o27tpYLeu8az6fv1e?= =?us-ascii?Q?1BmvDAtekLJNHFLwk82EqLd/53taM3Crt1R2OyzjdA229+sREhkpPiX1pRxB?= =?us-ascii?Q?jgaT8E3TUNgx8/pvLBvm4Rntw3b1/QB8z+QWwtmr859Dtj9DZKQfTYHzlQlZ?= =?us-ascii?Q?8GIDqmNaMLazG0Ov8fjcPib5fwG3mC1MofLdsCuEniq4KqsRVRJ1qcq0zvHu?= =?us-ascii?Q?ATY0bsiDOTDjV4xhpRV4d5CNJQoR8Vu/1wcrW7A1fqsRU3M5PnLL84YY2U77?= =?us-ascii?Q?NngGv9Xh/S5f3fEsfmxty5dsIBo6g8ywcFIQ6r76v5xFkysfZKPP6J47tyNB?= =?us-ascii?Q?Di9dHIrTv1mVlYIV8qxTgRsOOoHZTxF0rYl3kigIY1RvQBZD1PUv5gl6R3aT?= =?us-ascii?Q?GE1XtVCpOmpuw9ilU55tRMNvpCBNW4KoJEOAS/ZLxHZoFMybNxQb0cHA7uda?= =?us-ascii?Q?cVLrcf/tFj66qmOPwpSBkT8aUJNajMkKtUqX3fj/g2H6gLNZvznOlDq3xxEy?= =?us-ascii?Q?bO1o6YmCoZzMwXgs7ZtWJVqF9M2fYXT0SCHP+8ciyvY0hQY2EtgDNa8CS9p+?= =?us-ascii?Q?VS32aqb+mgwC/qtLG+yqiowxetl/6yrvl3c/eJAtGSY9VwrowsmodRYHDdYv?= =?us-ascii?Q?xsipcnbBoYIGN1EfyBM2ZMWQSto+VsgIFq6oS11MATJGpTYRsh/KKPPMGzZT?= =?us-ascii?Q?tA1iuoBxNL/W8eJDoAwmPilaEa9GezvnfzKsEYo2R//9oYVFfs/T0Cqc5Elq?= =?us-ascii?Q?Vfz+2uYKIZ11x7noj/sg/tBdCmircx/nBwRZ9QnbIA66zzm3QE/OwtX7tLzP?= =?us-ascii?Q?gnYmXaMN4yDpV7X1nin/YYp5U5gVHxtOSy6rEXPgbavM/Rq7P2njnqlOUxsN?= =?us-ascii?Q?DynMh7QkreEP3KNpklTd+CCDkJrTWppzNlwoUiB7fdfBR/YR8LUaSoKckcN/?= =?us-ascii?Q?w2/pvXRjppMX0DhDvPRRRFD8I7Ekq5ZyeBwu7BVxIu3iqQd2GHBnbUiYziuV?= =?us-ascii?Q?40jfqB/I/1FPQV01nO9WJyThCMU99sb2vDMS9tfhOA+Hjid0DQ=3D=3D?= X-Forefront-Antispam-Report: CIP:165.204.84.17;CTRY:US;LANG:en;SCL:1;SRV:;IPV:CAL;SFV:NSPM;H:SATLEXMB04.amd.com;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(13230040)(376014)(82310400026)(36860700013)(1800799024)(7416014);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 03 Jul 2024 21:51:23.3556 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: a76bcd91-069a-409f-f117-08dc9baa47fd 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: SN1PEPF0002BA4C.namprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: CH0PR12MB8505 Content-Type: text/plain; charset="utf-8" Introduce the interface to enable 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 op-code 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: "//" Op-code can be one of the following: =3D Update the assignment to match the flags + enable a new state - disable a new state Assignment 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. Valid only with '=3D" opcode. Signed-off-by: Babu Moger --- 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 | 81 +++++++- arch/x86/kernel/cpu/resctrl/rdtgroup.c | 250 ++++++++++++++++++++++++- 2 files changed, 329 insertions(+), 2 deletions(-) diff --git a/Documentation/arch/x86/resctrl.rst b/Documentation/arch/x86/re= sctrl.rst index 05fee779e109..5a621235eb2b 100644 --- a/Documentation/arch/x86/resctrl.rst +++ b/Documentation/arch/x86/resctrl.rst @@ -331,7 +331,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: :: @@ -358,6 +358,85 @@ with the following files: =20 /child_default_mon_grp/ - This is a child monitor group of default CTRL_= MON group. =20 + Assignment state can be updated by writing to the interface. + + Format is similar to the list format with addition of op-code 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: + "//" + + Op-code can be one of the following: + :: + + =3D Update the assignment to match the flags. + + Add a new state. + - delete a new state. + + 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 enable only total 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 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 + remove both local and total 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 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; + "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 0de9f23d5389..84c0874d7872 100644 --- a/arch/x86/kernel/cpu/resctrl/rdtgroup.c +++ b/arch/x86/kernel/cpu/resctrl/rdtgroup.c @@ -1068,6 +1068,253 @@ static int rdtgroup_mbm_control_show(struct kernfs_= open_file *of, return 0; } =20 +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: + mon_state =3D ASSIGN_NONE; + 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(enum rdt_group_type rtype, char *p_grp, = char *c_grp, char *tok) +{ + struct rdt_resource *r =3D &rdt_resources_all[RDT_RESOURCE_L3].r_resctrl; + 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+-"); + + 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; + } + + 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 resctrl_arch_assign_cntr(d, QOS_L3_MBM_TOTAL_EVENT_ID, + rdtgrp->mon.rmid, + rdtgrp->mon.cntr_id[0], + rdtgrp->closid, 1); + if (ret) + goto out_fail; + + if (assign_state & ASSIGN_LOCAL) + ret =3D resctrl_arch_assign_cntr(d, QOS_L3_MBM_LOCAL_EVENT_ID, + rdtgrp->mon.rmid, + rdtgrp->mon.cntr_id[1], + rdtgrp->closid, 1); + + if (ret) + goto out_fail; + + if (unassign_state & ASSIGN_TOTAL) + ret =3D resctrl_arch_assign_cntr(d, QOS_L3_MBM_TOTAL_EVENT_ID, + rdtgrp->mon.rmid, + rdtgrp->mon.cntr_id[0], + rdtgrp->closid, 0); + + if (ret) + goto out_fail; + + if (unassign_state & ASSIGN_LOCAL) + ret =3D resctrl_arch_assign_cntr(d, QOS_L3_MBM_LOCAL_EVENT_ID, + rdtgrp->mon.rmid, + rdtgrp->mon.cntr_id[1], + rdtgrp->closid, 0); + 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; + struct rdt_hw_resource *hw_res; + int ret; + + hw_res =3D resctrl_to_arch_res(r); + if (!hw_res->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'; + rdt_last_cmd_clear(); + + cpus_read_lock(); + mutex_lock(&rdtgroup_mutex); + + 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 consicutive 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(RDTCTRL_GROUP, cmon_grp, mon_grp, token); + 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(RDTMON_GROUP, cmon_grp, mon_grp, token); + if (ret) + break; + } + } + + mutex_unlock(&rdtgroup_mutex); + cpus_read_unlock(); + + return ret ?: nbytes; +} + #ifdef CONFIG_PROC_CPU_RESCTRL =20 /* @@ -2282,9 +2529,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