From nobody Wed Feb 11 05:40:54 2026 Received: from NAM11-BN8-obe.outbound.protection.outlook.com (mail-bn8nam11on2066.outbound.protection.outlook.com [40.107.236.66]) (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 E49FE216388; Wed, 22 Jan 2025 20:21:02 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.236.66 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1737577266; cv=fail; b=YKxngV6w611RoUD06k1FCfxWWE1YixnUtgAwbbXW3Xg2nDXwSFCAppqQfVwTAkya0nexyuaGKHvFFvS04JPy8pOI0Ae03equWgdjldZ6Tjoof9n5Ii5VEu6zXfxfvIqfW7iUSNRy35xh48m545vqOO6JP5gEdrOJZkCr/e+omWA= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1737577266; c=relaxed/simple; bh=sLKWU8d0tEZQAoC1WKQH5FWVfryBf2/M2RhDCe4Fc/s=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=A2W4AEDBGck0XwRtE7a2A0orgJeLx0Tvv3+KQ9uI6ItnOhHaa+zpVV1qrZ+cELbxHi8vcXYoT9Lxnl10kTYApWIy/BRuI1bfXhA3kU/ZjjCEcAZRxPqI1iGVcIsygLkqAJbC7EG9P2tLnkd1ANYvuTAQT74M4VR3WTJEZkGdceQ= 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=BcZjbznO; arc=fail smtp.client-ip=40.107.236.66 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="BcZjbznO" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=v9Bbap5OtjDBWokqH6h2j85YeBNnp09ZuW30cgp4aDbAHTD1wDry489KTvBEU7XFVfLM73vJEoD2JWCjH6tVjGZ974yKtzwNxA+xGbkqzqzeEUafJSWwVzWN7eZwK5/f9oYcEdX2T270qL/zAOP8x+lz9KL0DDkV78I+nAnN6Qz42emKztNTgivxeY3o3vyRwezBnB+k9GvqQ20pwc0soSeHZPxlobc+gacIqFtMik2a9IyscV8kTyV4U+/5jWywbw6GHGsSEKzPwmrEn9+dvIfk+1Fs13jThGvkGEt853rhgX9PWmzfJFmOOpI/W8qURKY0mT4QnUh0ba/0hwpkYw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=BIF+MWco3I3RyTP66fMGZ41wCeX6L72UQdUYIHwqvjA=; b=WjKa+b5kiv3KGZbNkRC3ROHKiYpYAs1QDyAoP7cjAcGvpHctOa90wrdsKa/r9q1ebNdZlipNfJGS9ktaUhjlIAq0LeqjVAM6tS8MidnZ0xVrc23g+44pIXHob1CPPzM4oI7IZFdxNlBoqFYunoqOvrS9TqYOQG+d92Xvd338NvPG1ZAY/vBb4DhtbI3dMIseegBK1Hbl3Fsl9ERy5l9S+TxLfPfGgMQl9UEo7JwdB6Qtux70eWVeJY8ulxLAmJ+7yODXoC3xD1+aKe0yfgiNgdZW3F6rghSH46uyvZXJQWbUByMm7I5DWJUFUKeeyklndrIBfDrjuooAi7qZU7tzhg== 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=BIF+MWco3I3RyTP66fMGZ41wCeX6L72UQdUYIHwqvjA=; b=BcZjbznOQlSW3rhcIZ748bOFyiUx6bgb6EDCpguW8RtQny2jjCMbtYdgqDXEa0fEpphSSjty0+v8Q59wj8rI/p+XOT8LAy3hchqFoinZmJEfZYmoX6IKEQissAlsDP4vIg0T3I0oCCOfJ/58b/GEkgLvNZxgXX/biNtl/hzjPsQ= Received: from CH0PR03CA0445.namprd03.prod.outlook.com (2603:10b6:610:10e::31) by IA0PR12MB8695.namprd12.prod.outlook.com (2603:10b6:208:485::8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8377.16; Wed, 22 Jan 2025 20:20:57 +0000 Received: from CH1PEPF0000A345.namprd04.prod.outlook.com (2603:10b6:610:10e:cafe::8f) by CH0PR03CA0445.outlook.office365.com (2603:10b6:610:10e::31) with Microsoft SMTP Server (version=TLS1_3, cipher=TLS_AES_256_GCM_SHA384) id 15.20.8356.22 via Frontend Transport; Wed, 22 Jan 2025 20:20:57 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 165.204.84.17) smtp.mailfrom=amd.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=amd.com; Received-SPF: Pass (protection.outlook.com: domain of amd.com designates 165.204.84.17 as permitted sender) receiver=protection.outlook.com; client-ip=165.204.84.17; helo=SATLEXMB04.amd.com; pr=C Received: from SATLEXMB04.amd.com (165.204.84.17) by CH1PEPF0000A345.mail.protection.outlook.com (10.167.244.8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.8377.8 via Frontend Transport; Wed, 22 Jan 2025 20:20:57 +0000 Received: from bmoger-ubuntu.amd.com (10.180.168.240) by SATLEXMB04.amd.com (10.181.40.145) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.39; Wed, 22 Jan 2025 14:20:55 -0600 From: Babu Moger To: , , , , , , , CC: , , , , , , , , , , , , , , , , , , , , , , , , , , Subject: [PATCH v11 01/23] x86/resctrl: Add __init attribute to functions called from resctrl_late_init() Date: Wed, 22 Jan 2025 14:20:09 -0600 Message-ID: X-Mailer: git-send-email 2.34.1 In-Reply-To: References: Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-ClientProxiedBy: SATLEXMB04.amd.com (10.181.40.145) To SATLEXMB04.amd.com (10.181.40.145) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CH1PEPF0000A345:EE_|IA0PR12MB8695:EE_ X-MS-Office365-Filtering-Correlation-Id: b09f06d0-ff67-4f89-d6b4-08dd3b2247d7 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|36860700013|1800799024|7416014|376014|82310400026; X-Microsoft-Antispam-Message-Info: =?us-ascii?Q?NoADu3ixoKtqdm1CXUJQKmJqgpIHnIYdoFOZUf0m2LUr08GSIxsZp2yiHbyl?= =?us-ascii?Q?qG6Iim1L9g46C8jboRfAABzaKJUeZ3CrlH9p5s3TH1ii3ETJxrjh+8W/q84V?= =?us-ascii?Q?RkRRGoXWoBLqI7FpV6+qHk8nvcgtKtrVjs4i8g0xfgHrmdc9u/FlfPMIQF2V?= =?us-ascii?Q?HZsjDGvLL34qXDXsSJ560iSh20a4DtHXt1QmCmJ5gGjXDXA+gkjf6mZAdGkH?= =?us-ascii?Q?C1lUr4LVp3wcW6K1A0Nj7ayb5YoGGmtrsN/7JBrHKfxUrQdk/zWEk07mcqlI?= =?us-ascii?Q?AQ3cOUwR8ugcH0yVCHH+IcZYWPcga3fgga1o75SRLw2go+mgN2GmJexbvdeE?= =?us-ascii?Q?LHt4Lf361IOKkp1YqW1jFIrEXkESAFXvJMrs0ABP6LxvLDlcl8C6CCBmO6++?= =?us-ascii?Q?hUrUl4YdawHUWjToJbeXHc7n2Q8jHS5qOakb1yeobM1SptHW18XDWBtWUigI?= =?us-ascii?Q?UuHvdsQSO6/Hx1MQt/9k1WAR2MRMx/5UUt8EbpQvavxsoW+ycI9ySK0Yd2N/?= =?us-ascii?Q?1lrcsmVYh0xdQ+dLxZ4xVkTK4UUmuILVrtUy+l7vxW7eV7qgG/YwwBgxhqo4?= =?us-ascii?Q?cVRCplnouYsEke92fwXvSlitKHyubwOJGWryAc8Hc5XCusTmzllXKpJxrR5n?= =?us-ascii?Q?baAwbNuWljLV6H85eOk0QQTkuxgQAc4LB2e+8tWUKMyno7wZmimILt9LWFsx?= =?us-ascii?Q?+k+N2FYu9LURkQX8ZpWH+HcKBLVaiXnUYYVOMxJJU6jorWen7mfE3xD4X/io?= =?us-ascii?Q?KgMM9YbYYOfOLG5QI2U422EwTSv67qndFhblef3tAD5Lxl4ix5EVsO/aO0a/?= =?us-ascii?Q?CqcyCan6p7UripG25vawV9BFdczBz6prfxZI+0l6G9VHeTEWadTQAlBAlNsv?= =?us-ascii?Q?KWIDEMgk1H4CCojF7RxhqGlWLzALWNCeoO2NMS62eq8uQuq0lFKJ5InWEkIQ?= =?us-ascii?Q?12F05jKwcn9CVF6UFWVZ2YzyjdpIMwuw6TQpWjkPuFiDaYINQTUtuOQcDDPe?= =?us-ascii?Q?ZARCiSEj2Gea2QSczqhgVcIWrkz4Tt9t6nHLAsrTWbrUNiv0efcQxastU3fH?= =?us-ascii?Q?GeFErPkyFcV5nqSSjWikL0qAKTVhW9SrKK79rTXeuN8QkikwSwSNp8LA8MzA?= =?us-ascii?Q?9q0kdpefj2F7vKO0NAZmlAyG+PLukwU4WnJZqjvvYm3oTTHzf7k3iJdvGBfN?= =?us-ascii?Q?Snr5UzPa6y5PMazHwddB3blL9/gWsdzNkIKbX6JcYMkdvky9ev+LFZOUGr3U?= =?us-ascii?Q?WmqRh6vnJEdt+u7NyI+hxJhh1pA0jIdLpKz5MExeslxHQXKkuy/ELqIvhawj?= =?us-ascii?Q?kFsjOBJOhbpXEnuCkkl/6QONE7GTDgwBo6Ai7jT3tQYkdrk9aXgJrWZULHxh?= =?us-ascii?Q?l89DdPPwo2Zpl/lSh1OFyARl7MvSUkP8mxfZGCKgrxSrkc9EGXu31zhfX3bb?= =?us-ascii?Q?YipueaD1YY6iF/yQobWnNOxdGX3i+ieMeMR7UL8EnxGoJdX/jlwvDGdKysDO?= =?us-ascii?Q?4PQAsD9/hQ8pojY=3D?= X-Forefront-Antispam-Report: CIP:165.204.84.17;CTRY:US;LANG:en;SCL:1;SRV:;IPV:CAL;SFV:NSPM;H:SATLEXMB04.amd.com;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(13230040)(36860700013)(1800799024)(7416014)(376014)(82310400026);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 22 Jan 2025 20:20:57.5951 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: b09f06d0-ff67-4f89-d6b4-08dd3b2247d7 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: CH1PEPF0000A345.namprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: IA0PR12MB8695 Content-Type: text/plain; charset="utf-8" resctrl_late_init() has the __init attribute, but some of the functions called from it do not have the __init attribute. Add the __init attribute to all the functions in the call sequences to maintain consistency throughout. Fixes: 6a445edce657 ("x86/intel_rdt/cqm: Add RDT monitoring initialization") Fixes: def10853930a ("x86/intel_rdt: Add two new resources for L2 Code and = Data Prioritization (CDP)") Fixes: bd334c86b5d7 ("x86/resctrl: Add __init attribute to rdt_get_mon_l3_c= onfig()") Suggested-by: Reinette Chatre Signed-off-by: Babu Moger Reviewed-by: Reinette Chatre --- v11: No changes. v10: Text changes. Added __init attribute to cache_alloc_hsw_probe() Followed function prototype rules (preferred order is storage class before return type). v9: Moved the patch to the begining of the series. Fixed all the call sequences. Added additional Fixed tags. v8: New patch. --- arch/x86/kernel/cpu/resctrl/core.c | 10 +++++----- arch/x86/kernel/cpu/resctrl/internal.h | 2 +- arch/x86/kernel/cpu/resctrl/monitor.c | 4 ++-- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/arch/x86/kernel/cpu/resctrl/core.c b/arch/x86/kernel/cpu/resct= rl/core.c index 3d1735ed8d1f..f0a331287979 100644 --- a/arch/x86/kernel/cpu/resctrl/core.c +++ b/arch/x86/kernel/cpu/resctrl/core.c @@ -145,7 +145,7 @@ u32 resctrl_arch_system_num_rmid_idx(void) * is always 20 on hsw server parts. The minimum cache bitmask length * allowed for HSW server is always 2 bits. Hardcode all of them. */ -static inline void cache_alloc_hsw_probe(void) +static inline __init void cache_alloc_hsw_probe(void) { struct rdt_hw_resource *hw_res =3D &rdt_resources_all[RDT_RESOURCE_L3]; struct rdt_resource *r =3D &hw_res->r_resctrl; @@ -277,7 +277,7 @@ static __init bool __rdt_get_mem_config_amd(struct rdt_= resource *r) return true; } =20 -static void rdt_get_cache_alloc_cfg(int idx, struct rdt_resource *r) +static __init void rdt_get_cache_alloc_cfg(int idx, struct rdt_resource *r) { struct rdt_hw_resource *hw_res =3D resctrl_to_arch_res(r); union cpuid_0x10_1_eax eax; @@ -296,7 +296,7 @@ static void rdt_get_cache_alloc_cfg(int idx, struct rdt= _resource *r) r->alloc_capable =3D true; } =20 -static void rdt_get_cdp_config(int level) +static __init void rdt_get_cdp_config(int level) { /* * By default, CDP is disabled. CDP can be enabled by mount parameter @@ -306,12 +306,12 @@ static void rdt_get_cdp_config(int level) rdt_resources_all[level].r_resctrl.cdp_capable =3D true; } =20 -static void rdt_get_cdp_l3_config(void) +static __init void rdt_get_cdp_l3_config(void) { rdt_get_cdp_config(RDT_RESOURCE_L3); } =20 -static void rdt_get_cdp_l2_config(void) +static __init void rdt_get_cdp_l2_config(void) { rdt_get_cdp_config(RDT_RESOURCE_L2); } diff --git a/arch/x86/kernel/cpu/resctrl/internal.h b/arch/x86/kernel/cpu/r= esctrl/internal.h index 20c898f09b7e..05358e78147b 100644 --- a/arch/x86/kernel/cpu/resctrl/internal.h +++ b/arch/x86/kernel/cpu/resctrl/internal.h @@ -634,7 +634,7 @@ int closids_supported(void); void closid_free(int closid); int alloc_rmid(u32 closid); void free_rmid(u32 closid, u32 rmid); -int rdt_get_mon_l3_config(struct rdt_resource *r); +int __init rdt_get_mon_l3_config(struct rdt_resource *r); void __exit rdt_put_mon_l3_config(void); bool __init rdt_cpu_has(int flag); void mon_event_count(void *info); diff --git a/arch/x86/kernel/cpu/resctrl/monitor.c b/arch/x86/kernel/cpu/re= sctrl/monitor.c index 94a1d9780461..1c7b574bf0cd 100644 --- a/arch/x86/kernel/cpu/resctrl/monitor.c +++ b/arch/x86/kernel/cpu/resctrl/monitor.c @@ -979,7 +979,7 @@ void mbm_setup_overflow_handler(struct rdt_mon_domain *= dom, unsigned long delay_ schedule_delayed_work_on(cpu, &dom->mbm_over, delay); } =20 -static int dom_data_init(struct rdt_resource *r) +static __init int dom_data_init(struct rdt_resource *r) { u32 idx_limit =3D resctrl_arch_system_num_rmid_idx(); u32 num_closid =3D resctrl_arch_get_num_closid(r); @@ -1077,7 +1077,7 @@ static struct mon_evt mbm_local_event =3D { * because as per the SDM the total and local memory bandwidth * are enumerated as part of L3 monitoring. */ -static void l3_mon_evt_init(struct rdt_resource *r) +static __init void l3_mon_evt_init(struct rdt_resource *r) { INIT_LIST_HEAD(&r->evt_list); =20 --=20 2.34.1 From nobody Wed Feb 11 05:40:54 2026 Received: from NAM11-BN8-obe.outbound.protection.outlook.com (mail-bn8nam11on2070.outbound.protection.outlook.com [40.107.236.70]) (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 D35772144A2; Wed, 22 Jan 2025 20:21:14 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.236.70 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1737577276; cv=fail; b=hLIZoneznf185Ik6yoq3DC8+YqBz1DvcF1fTrCmUurc66wkQQlsElSV9m1TVuv0Fr2XFqz/0SV6FBUXnzos920ZGNyfWmMWzAuSVL/l0m/hbLP5ykhul5fax4eOrkdlHuN0X656yW7EBG2y0ZSMGUeNsysz79zTxW2EqYFTNKsw= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1737577276; c=relaxed/simple; bh=NGFmmvvBDDewCP74TnRf62SU3eg4/4n7Gu5D7Q/BT+4=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=fgkz9ojd0kBuzy9VgSzfTU4j55Qlkit465kNP9YuzfV9f6yQYSCLHUVBJ5UWEee1ZbvcCFwAMQyJ6ZlwxD+m2a/XQXejlyFa6Mqe2kdTAogdxEwCedjH8aVLL6WNQxZDCQ9ChmqW/u2C0m7QHLZTnhBGgjvFB/337eiYTKBztzs= 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=SLX18sHG; arc=fail smtp.client-ip=40.107.236.70 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="SLX18sHG" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=fLdzDqppj9pPAs7zJ8NFUBWPD9NTOOaLTQul9VuxA8VmvGTSnkDtUq6yjbxIfrmEKcvgZTh+oiVuSHo644d7VP2Sd6pFi4S5oZHva6e9NIOWm3ExQW7PALk9kgDvvObZ4i+MWOF0NrNgLwTyiDtvsGCijMTGGKcYC3G/F73FmwHpAkJDTZDyVkoC3t2dDceg3BhS46ZJgvcgYEtAzkCvJrq+PojBVKkNy4OWDdVnU9BXOqpmAF7ucJFc63OcBKFw6WheoT53nzCbJPqa9yxUjnTTJCp3yEDSagYwwOYxs2JdeWg5oTNpNwJ2FhMQFoQb2xOXvnQTqFv90v6eGQW18g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=584/9aDQ6GCzsyD9pQIrlTl2SCi0YRxJlSW6lSfe4b8=; b=RpGBZKdz9jAGUAFFuanwZM4Cff6Z1kFYzHWS9upEA5dRp5Abk2NZ2/hnEgFgtgc4cw5Q633Mwn76xf4PL9ZSN9lQMuuAX7K63urp9cy+WwgJe39hEKHzwKwAtmyp0bCdNfz9J/bhMRfs2tx6dU0tCRGJ4TCm51CagQ022QHyH3tVbDcKEIq1z+1OqzfJ1lYSZPX8yXpvwg9q1+4HsUvYv7FotSTzZeUqrdDqTFJa3F63FlZSQTkyEfYDvUJsXw2y0mqJh/+qtGtL+1CRr8V4Ye5UJX+6JrtQH62M7xmww8yO48Z6R/0IHC6belsgjhjN85lnHt+FgRGy6sB6HtGu+g== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=lwn.net smtp.mailfrom=amd.com; dmarc=pass (p=quarantine sp=quarantine pct=100) action=none header.from=amd.com; dkim=none (message not signed); arc=none (0) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amd.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=584/9aDQ6GCzsyD9pQIrlTl2SCi0YRxJlSW6lSfe4b8=; b=SLX18sHG1ebB/9oWs30rclr1R0TZ2jIHEzC6ls933MCIPdAtq1qUuA3IPfTb2BpzU8aaSLQsmCfseFX5zpC8fNW7udNsTWLDSDyggFWIp1zvWYcZ55YuB6XM4hfyUg2unuiGWlZJo/2uTpxtEI60WWoaR65gu6Dd4oYbWVSVvsk= Received: from CH0PR03CA0444.namprd03.prod.outlook.com (2603:10b6:610:10e::12) by SA3PR12MB7975.namprd12.prod.outlook.com (2603:10b6:806:320::11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8356.21; Wed, 22 Jan 2025 20:21:06 +0000 Received: from CH1PEPF0000A345.namprd04.prod.outlook.com (2603:10b6:610:10e:cafe::24) by CH0PR03CA0444.outlook.office365.com (2603:10b6:610:10e::12) with Microsoft SMTP Server (version=TLS1_3, cipher=TLS_AES_256_GCM_SHA384) id 15.20.8377.14 via Frontend Transport; Wed, 22 Jan 2025 20:21:06 +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 CH1PEPF0000A345.mail.protection.outlook.com (10.167.244.8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.8377.8 via Frontend Transport; Wed, 22 Jan 2025 20:21: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, 22 Jan 2025 14:21:03 -0600 From: Babu Moger To: , , , , , , , CC: , , , , , , , , , , , , , , , , , , , , , , , , , , Subject: [PATCH v11 02/23] x86/cpufeatures: Add support for Assignable Bandwidth Monitoring Counters (ABMC) Date: Wed, 22 Jan 2025 14:20:10 -0600 Message-ID: X-Mailer: git-send-email 2.34.1 In-Reply-To: References: Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-ClientProxiedBy: SATLEXMB04.amd.com (10.181.40.145) To SATLEXMB04.amd.com (10.181.40.145) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CH1PEPF0000A345:EE_|SA3PR12MB7975:EE_ X-MS-Office365-Filtering-Correlation-Id: 17a0d95f-986b-412f-c0d7-08dd3b224d13 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|36860700013|82310400026|1800799024|376014|7416014|13003099007; X-Microsoft-Antispam-Message-Info: =?us-ascii?Q?MBf9IZukvwhkhzImL0/kso4+zEVzfwpCceiNxhuIzjDSRhl3QH8nCoLqkJD/?= =?us-ascii?Q?YNpUNzIZuwJOTXcXwB01cSzKlH+dL+SNRI6dPlDBUMo3ud+OuCH225M6pGQi?= =?us-ascii?Q?5OF3fslx1S5gAJ4XJsdhbHctN9XaqBUT96oBIPmmHMR5LkQyrjsXr7kNTGBv?= =?us-ascii?Q?d4D4ydpRPye/pJWoz35OGPsxaznu2ZjIyQ86tI4b45vZ03gRGLdFY8deM/wL?= =?us-ascii?Q?+R6R6Whe1XLF53auk5qn2yxeNO1PVeLtU99lf0GSI4kiQNrwdQMWdEqN4OAC?= =?us-ascii?Q?vqt/kvBiSbcP4C2NTkaUooAhsu2tY4S8rcLjEghHMD/21ty371jYRekJtvWE?= =?us-ascii?Q?JN/448WfQWmu+u/FFH96ZEuRc0YpvQZGGdMWDH0c60WkQyszsdTLtYaUp3Wh?= =?us-ascii?Q?XJPT8UuLg5F1s5dq98i0ohnhT98KJui4AuTo3t7wMaxkE/SwQQx7WWuYnDMR?= =?us-ascii?Q?SfHXG/6W8Rp3zrEA+es5nA9VUQOpcVZLiq5S7M5yPXPraDanjSlNRz3RTN0B?= =?us-ascii?Q?7rgnogSWkVki2Y3KnmR4GEH35sWzfwzzI+mBhvGdIXx67Sghvp92saD6kGiO?= =?us-ascii?Q?qt6Qlgp1iBMn63pgjyEn+Cv+HCDYHDjBrjxvdGhUdvkSBpql/5aoKU4C74lJ?= =?us-ascii?Q?XXQ1mOsTAfpCYAGyEPG4yzh+c6WcRw+nrMyl6gQAG8ZJZXD7y1qdM/Uc/hsB?= =?us-ascii?Q?6sfOmXaVMlD1QimFO1+ZjBHqFAQbRq5kkDbraf02eJW75Hvl7wvQUHjlbcRl?= =?us-ascii?Q?9PXO/XFDkKWHS9SxFruR+gIIZAep5sebXN7aaR54H162nQDor4lS/BUUxGl6?= =?us-ascii?Q?YiOq9/98PkBaYho2sR7wx3c88TBaSkSd7ejcpEXzaq912dIq3lXTwZfb5+H+?= =?us-ascii?Q?JTUKoLnSCaKqI8vW2GQJbm9JovN4Sy5qiIg1VokixZ3Pc8t80hr29r3knqQQ?= =?us-ascii?Q?tekAFXFoEeZrZlQlnRp050XXjmbzGhVlJJFXiEnLt0To8AQzVYVJoSvnJo19?= =?us-ascii?Q?fCNAZKlLgBo4qL4wf81w2sKoONhw3Ij850dgZ31U4Zv/X8f32obFitUyNeQ3?= =?us-ascii?Q?McZFOghtqS1w5pXkhgI/3BAvwPuwHBTiU26Mqqg0Bhh2bzY3Ew8r67PwnqGL?= =?us-ascii?Q?QG2t3zyYX8WLsvFqkxFHTbtF7Kv57lum8E3DoUsQoohYnn2hlH81y0dVXjS6?= =?us-ascii?Q?Os2Kc1j0B7UxaqrxiGGv+IEV88hhh11crTxc94A107wtx4jwrpgV1tg/QRF0?= =?us-ascii?Q?fKPAzOWMMJ+/0u/RMhDPmtU78lBv95QlhjLYoXidi2f9MgzKs+igxPnqF1rN?= =?us-ascii?Q?tHrH0kimkhrlitkROCTSQAbEOZaAtWT8QU7FEDe51BYpiCcqyYWKobNTo6o8?= =?us-ascii?Q?8hdI/BHDWKQFOw8o35SuHASN3ZNuCHH/icCwA2Zxvy7fM2/zQQqQnlQAqIT1?= =?us-ascii?Q?bq2ib6ycfuaVv70Bta7AbIgkieME+DiQ?= X-Forefront-Antispam-Report: CIP:165.204.84.17;CTRY:US;LANG:en;SCL:1;SRV:;IPV:CAL;SFV:NSPM;H:SATLEXMB04.amd.com;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(13230040)(36860700013)(82310400026)(1800799024)(376014)(7416014)(13003099007);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 22 Jan 2025 20:21:06.3764 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 17a0d95f-986b-412f-c0d7-08dd3b224d13 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: CH1PEPF0000A345.namprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: SA3PR12MB7975 Content-Type: text/plain; charset="utf-8" Users can create as many monitor groups as RMIDs supported by the hardware. However, bandwidth monitoring feature on AMD system only guarantees that RMIDs currently assigned to a processor will be tracked by hardware. The counters of any other RMIDs which are no longer being tracked will be reset to zero. The MBM event counters return "Unavailable" for the RMIDs that are not tracked by hardware. So, there can be only limited number of groups that can give guaranteed monitoring numbers. With ever changing configurations there is no way to definitely know which of these groups are being tracked for certain point of time. Users do not have the option to monitor a group or set of groups for certain period of time without worrying about RMID being reset in between. The ABMC feature provides an option to the user to assign a hardware counter to an RMID, event pair and monitor the bandwidth as long as it is assigned. The assigned RMID will be tracked by the hardware until the user unassigns it manually. There is no need to worry about counters being reset during this period. Additionally, the user can specify a bitmask identifying the specific bandwidth types from the given source to track with the counter. Without ABMC enabled, monitoring will work in current mode without assignment option. Linux resctrl subsystem provides the interface to count maximum of two memory bandwidth events per group, from a combination of available total and local events. Keeping the current interface, users can enable a maximum of 2 ABMC counters per group. User will also have the option to enable only one counter to the group. If the system runs out of assignable ABMC counters, kernel will display an error. Users need to disable an already enabled counter to make space for new assignments. The feature can be detected via CPUID_Fn80000020_EBX_x00 bit 5. Bits Description 5 ABMC (Assignable Bandwidth Monitoring Counters) The feature details are documented in APM listed below [1]. [1] AMD64 Architecture Programmer's Manual Volume 2: System Programming Publication # 24593 Revision 3.41 section 19.3.3.3 Assignable Bandwidth Monitoring (ABMC). Link: https://bugzilla.kernel.org/show_bug.cgi?id=3D206537 Signed-off-by: Babu Moger Reviewed-by: Reinette Chatre --- Note: Checkpatch checks/warnings are ignored to maintain coding style. v11: No changes. v10: No changes. v9: Took care of couple of minor merge conflicts. No other changes. v8: No changes. v7: Removed "" from feature flags. Not required anymore. https://lore.kernel.org/lkml/20240817145058.GCZsC40neU4wkPXeVR@fat_crat= e.local/ v6: Added Reinette's Reviewed-by. Moved the Checkpatch note below ---. v5: Minor rebase change and subject line update. v4: Changes because of rebase. Feature word 21 has few more additions now. Changed the text to "tracked by hardware" instead of active. v3: Change because of rebase. Actual patch did not change. v2: Added dependency on X86_FEATURE_BMEC. --- arch/x86/include/asm/cpufeatures.h | 1 + arch/x86/kernel/cpu/cpuid-deps.c | 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 508c0dad116b..7950a420170f 100644 --- a/arch/x86/include/asm/cpufeatures.h +++ b/arch/x86/include/asm/cpufeatures.h @@ -483,6 +483,7 @@ #define X86_FEATURE_AMD_FAST_CPPC (21*32 + 5) /* Fast CPPC */ #define X86_FEATURE_AMD_HETEROGENEOUS_CORES (21*32 + 6) /* Heterogeneous C= ore Topology */ #define X86_FEATURE_AMD_WORKLOAD_CLASS (21*32 + 7) /* Workload Classificat= ion */ +#define X86_FEATURE_ABMC (21*32 + 8) /* Assignable Bandwidth Monitoring C= ounters */ =20 /* * BUG word(s) diff --git a/arch/x86/kernel/cpu/cpuid-deps.c b/arch/x86/kernel/cpu/cpuid-d= eps.c index 8bd84114c2d9..7e4d63b381d6 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 16f3ca30626a..3b72b72270f1 100644 --- a/arch/x86/kernel/cpu/scattered.c +++ b/arch/x86/kernel/cpu/scattered.c @@ -49,6 +49,7 @@ static const struct cpuid_bit cpuid_bits[] =3D { { X86_FEATURE_MBA, CPUID_EBX, 6, 0x80000008, 0 }, { X86_FEATURE_SMBA, CPUID_EBX, 2, 0x80000020, 0 }, { X86_FEATURE_BMEC, CPUID_EBX, 3, 0x80000020, 0 }, + { X86_FEATURE_ABMC, CPUID_EBX, 5, 0x80000020, 0 }, { X86_FEATURE_AMD_WORKLOAD_CLASS, CPUID_EAX, 22, 0x80000021, 0 }, { X86_FEATURE_PERFMON_V2, CPUID_EAX, 0, 0x80000022, 0 }, { X86_FEATURE_AMD_LBR_V2, CPUID_EAX, 1, 0x80000022, 0 }, --=20 2.34.1 From nobody Wed Feb 11 05:40:54 2026 Received: from NAM02-DM3-obe.outbound.protection.outlook.com (mail-dm3nam02on2051.outbound.protection.outlook.com [40.107.95.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 5812E21639D; Wed, 22 Jan 2025 20:21:17 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.95.51 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1737577280; cv=fail; b=egJxgj0osT1aYOinQWk5wqMifJiu91eLFFb4ItTKNJIaFyXRmJV/xEUil65KOD/xvv0vF/8l3r2lK1Rw7BZwkGvfehXRtBCJCrrROfu256o6D804uhbzbffc8fgJig6JiM6buKLdNnG0S7XlopONB+36DAKnlmBckCqqfScO74k= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1737577280; c=relaxed/simple; bh=c3ibRZPhnv/x45kZV0Uj73kdYfcAosbgX4geagTYwZk=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=V6y3gShzpY4HCRHxMxy5uaKoC49X+uD1ktUZEavpuyEv+eZfuQjXA2lG5R1y5oygUAfMxIyCzNJsT3nBGNBjh1kbph/q0dPxYKPpNNDTWFIDHIsy8j+QPsiz4Dqlc1i5OrMmV+/DEr7t+/8zhWGAjP4Pw3BxFFtdHPieuVhSTCE= 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=I0N0azTk; arc=fail smtp.client-ip=40.107.95.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="I0N0azTk" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=QEkWZ9g/aKzZvvBaEDNyLjodMq5wqoLVi0qWde/I1yXuFUzXXRMVN+7XHoKJutEIT2EoZNAjTmqIqtcn8NbF0AdTSRIvurcW4rmmb1rq1S0t/SsewJAhvv93UfJecRdEorXJToK0meBMIv6oFbVEDqoDRaRpq88atLEVeC8gjk2QCd+h6+ve/6a5TBGAradzsvyw7MD9lmRI1fBNgBww5r//A+s9Q1w8Rl0fLs5WJOcXT66nocnVGh7rV1v+WfCLENMbCXjtKQAq12o6kTnl3CzbdqXyXXpZwNTYAhkyOzJy6ZCRimIT0SwZvVfgAzqWMwMU8Cwo5/wyL/8zmVVEaw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=nUIwkxnz9qu5tmJvtezsGOpnaWlzCiQ+JSOh9CL4Z+s=; b=eiLWbVd7MCTMcfcWaOwM6quGMACmwjqHc3ohZ7ACMl+3BLDZ2pjeR8mw4AiBgHokIt21rSP1MOAw0dUjYqFd0QLqtXP1s3PCqyVPrWbXQKqELT+1Q8+w1N1qjNeTuCj9GieIBDMrmVqTbcKFkKjtzbYrD1mSQsdg3f0melxDJVxa8+k1moc2m3s18I8yqxJ3dnzM8W2XNkIMItCYhF97F+xfw819Kt+dh82dY9ej80Pl9W7uroo3JOq2hkESJEk/3+d1ZLuD2K3dRjIIkmGz0gQ3LBZF2Lb2b4YbUP53iyMDvmIb+z2pqt2qwjzDk2jSTp1c5UzTPvv5tihMMclSgg== 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=nUIwkxnz9qu5tmJvtezsGOpnaWlzCiQ+JSOh9CL4Z+s=; b=I0N0azTksFKCBwXqwp6SwPAKtC2QnkM6n6YRdQbpeuMMQXGj6jXBJMDDyrKeEBNjj3Gm9aqNHg0tG4HbWrWerRfKrbO+F95DXQ1gdhmKgqHha16X6xOoJMHoMasaAmMAvM4Fsfz8zLN3LZepx3Z1RFIkTox5/hVf8mpsTyn1peI= Received: from CH0PR03CA0427.namprd03.prod.outlook.com (2603:10b6:610:10e::30) by PH0PR12MB7094.namprd12.prod.outlook.com (2603:10b6:510:21d::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8377.17; Wed, 22 Jan 2025 20:21:14 +0000 Received: from CH1PEPF0000A347.namprd04.prod.outlook.com (2603:10b6:610:10e:cafe::5a) by CH0PR03CA0427.outlook.office365.com (2603:10b6:610:10e::30) with Microsoft SMTP Server (version=TLS1_3, cipher=TLS_AES_256_GCM_SHA384) id 15.20.8356.22 via Frontend Transport; Wed, 22 Jan 2025 20:21:14 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 165.204.84.17) smtp.mailfrom=amd.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=amd.com; Received-SPF: Pass (protection.outlook.com: domain of amd.com designates 165.204.84.17 as permitted sender) receiver=protection.outlook.com; client-ip=165.204.84.17; helo=SATLEXMB04.amd.com; pr=C Received: from SATLEXMB04.amd.com (165.204.84.17) by CH1PEPF0000A347.mail.protection.outlook.com (10.167.244.7) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.8377.8 via Frontend Transport; Wed, 22 Jan 2025 20:21:13 +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, 22 Jan 2025 14:21:11 -0600 From: Babu Moger To: , , , , , , , CC: , , , , , , , , , , , , , , , , , , , , , , , , , , Subject: [PATCH v11 03/23] x86/resctrl: Add ABMC feature in the command line options Date: Wed, 22 Jan 2025 14:20:11 -0600 Message-ID: X-Mailer: git-send-email 2.34.1 In-Reply-To: References: Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-ClientProxiedBy: SATLEXMB04.amd.com (10.181.40.145) To SATLEXMB04.amd.com (10.181.40.145) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CH1PEPF0000A347:EE_|PH0PR12MB7094:EE_ X-MS-Office365-Filtering-Correlation-Id: 3f9c8ccf-bbb7-4fbd-f673-08dd3b22518c X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|7416014|36860700013|376014|82310400026|1800799024; X-Microsoft-Antispam-Message-Info: =?us-ascii?Q?57jGUH7XBn4zies4sdtpPZA53ZwGrH4uAGBV6scIcXBWvcwbLP0fhHggaty3?= =?us-ascii?Q?sZafLDqHhTG+1bcp2+WxjoYic0MqFkgAzN342PNFRCoDjgZvRxX90MKCTK2q?= =?us-ascii?Q?NAKNoLGtKkf0gFEI3Rr+Lq0qasfxRs7XV+9ZIp4TgP3n3h8z1c+blR25OuwC?= =?us-ascii?Q?5wVEz7dAhnOtHrIhdEEB+BUVCk3HM+MeJEvcQeUyWjkj0OBRVO/a67HYuo8x?= =?us-ascii?Q?K935AZT6YMf08KRs4npZCDpHj0t4vRtsSnJwPYcflY0bWmPqtI9XOrTuKpjL?= =?us-ascii?Q?QVztv48h9a7D66nv+f1FamGAwWeuBsSlr1SzYwX+/IkvUX3OpOLepEbN7KZh?= =?us-ascii?Q?jNuFdItZGW+qJJRoylAa0eQtXlsJ/3xZgNZncnELWrwXLm7GxYDDG2Boatkz?= =?us-ascii?Q?JGvD0CdhzzBM0S+uIjh6MHidzPE/ew5keNuJfJu5jdT0U5XopcTDdlXpM8vv?= =?us-ascii?Q?JhQpceFv3NeRVvUpDV0+Y7Yzdbw78UovF46bIQfL+gML3V5FHl/pWo2EceYp?= =?us-ascii?Q?T9pBsjWnTgvYsFOxJpEiyOgj1Lsyhif07IRriG4UFe8AQ9N7l49hLACjCIQY?= =?us-ascii?Q?gcee2mbsCpYRu135JSMfs07Ab4ONsR6RSlUKKL4D4La445VOqSsulYp138sE?= =?us-ascii?Q?ZduLte61V8fv1zM4TM+1J5aj0QQyBbx5sjWu0crlI8bP/51XJbwiPByNToYr?= =?us-ascii?Q?l73IOEUkObJgMWlJQ75ZozPuA3FG6cGW1LulYbE+2Vyx0LIDoyKIExd5tl+w?= =?us-ascii?Q?zL/nnVhE0yPJ8P59c3JygFt0ed4l9RUMZr7AaO/A2B/KRho7Q/2ms/RCJMr5?= =?us-ascii?Q?GeQxlDyGxW/8uRF3F0U6vpXFFgDvhbkU/SvkctBrpBuAfhGbbhHBxT5aSIgl?= =?us-ascii?Q?oXlrbnOOWVMySG2Y++Zq/d5iPOXCudQC5/rdrrlBwH86fqEKKbnkyOF7LK6i?= =?us-ascii?Q?zgVPbmIUy7dIMw/tOst+5mrd7L3m6ColUdvYCAUJpCIDnVBp6v6C5Q5Sjyr1?= =?us-ascii?Q?oY/MdvLieydfW4WOs93Zj8SFh2l6bpYPCmq1gEGvx6+jWx7ikct7zXuG4jTj?= =?us-ascii?Q?7LjXY62zFqPpJIgFF1DJt08PCr0Vxp29FYMOcE1LL7ma2v06b0T4SttWONUV?= =?us-ascii?Q?rHKjzEolTyGlvA5BKpr3P2VK//X2EeZ7jzsriXKchLdgKt1lilvePnudI8EE?= =?us-ascii?Q?Q12EIkpqV5sLnKwG/wuZ1ejTE4Z3DEMjG6YEAqc4SOJJiTT2AIusoY3a0KLx?= =?us-ascii?Q?Vs8gel/0Z9k5C38kWxmB0FtMHyeIbDWLriOp4ch6LT5w5ZDJ6Qk+lCpebHO5?= =?us-ascii?Q?LsC81OIrO0565ggeXlICfeUPtCO/0teAMiGsMb1dzVc2IWM/B0GMUq/Revhm?= =?us-ascii?Q?EMirwqD4HbAC1V9IUah7jGaRRWgitYaLgMaYf2gj/yf+7FdaTyN0+bPNdsQO?= =?us-ascii?Q?ZiIudTCX6rHDl7IOlU126Fwwa7BtLVwsKWXOCAJctGXT3E683oH/IXq11Hiz?= =?us-ascii?Q?AY8VFRVmNUUbJQ4=3D?= X-Forefront-Antispam-Report: CIP:165.204.84.17;CTRY:US;LANG:en;SCL:1;SRV:;IPV:CAL;SFV:NSPM;H:SATLEXMB04.amd.com;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(13230040)(7416014)(36860700013)(376014)(82310400026)(1800799024);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 22 Jan 2025 20:21:13.7722 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 3f9c8ccf-bbb7-4fbd-f673-08dd3b22518c 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: CH1PEPF0000A347.namprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH0PR12MB7094 Content-Type: text/plain; charset="utf-8" Add the command line option to enable or disable exposing the ABMC (Assignable Bandwidth Monitoring Counters) hardware feature to resctrl. Signed-off-by: Babu Moger Reviewed-by: Reinette Chatre --- v11: No changes. v10: No changes. v9: No code changes. Added Reviewed-by. v8: Commit message update. v7: No changes v6: No changes v5: No changes v4: No changes v3: No changes v2: No changes --- Documentation/admin-guide/kernel-parameters.txt | 2 +- Documentation/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 05f5935eeac8..154a93c080f5 100644 --- a/Documentation/admin-guide/kernel-parameters.txt +++ b/Documentation/admin-guide/kernel-parameters.txt @@ -5854,7 +5854,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 6768fc1fad16..fb90f08e564e 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 f0a331287979..97511cc132d6 100644 --- a/arch/x86/kernel/cpu/resctrl/core.c +++ b/arch/x86/kernel/cpu/resctrl/core.c @@ -811,6 +811,7 @@ enum { RDT_FLAG_MBA, RDT_FLAG_SMBA, RDT_FLAG_BMEC, + RDT_FLAG_ABMC, }; =20 #define RDT_OPT(idx, n, f) \ @@ -836,6 +837,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 Wed Feb 11 05:40:54 2026 Received: from NAM12-MW2-obe.outbound.protection.outlook.com (mail-mw2nam12on2080.outbound.protection.outlook.com [40.107.244.80]) (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 C8D9E2163B0; Wed, 22 Jan 2025 20:21:25 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.244.80 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1737577287; cv=fail; b=ulMU4y6J+kkCA4KoUXFA5W8JRHyESMll4tABZnaL2WvBpImYOYmD5KhMr1UO82OGkAYwHY2WWjQW4dJEb9xO6icIARmm6rbNQSjopNORXpPnuVfhJqOHS2AHt+CSd1gsy1t7/Sni5eBFZqTCSuM+kedNiW5p6trnQpTgnyhAVmo= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1737577287; c=relaxed/simple; bh=gPcfWCASFm+z0iO5oiEajbiliUh05GbU1w97pKUggqU=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=C8qLJNdx6jQBz0UZ34VAGuo8MH/xQYOQLWZRWeLwU3cxLXlhFxXDnlDSQ79vW3xKuXkyxRcWP1KveuAIb6rY6lxC11PvHXopoNnKDgBIhXcMUQrknQmsUJpv7QzQq9BUR4D8AZOd5etubev+QWaaVDr00AZW+zia26OglVSn/dA= 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=xJG/l0jz; arc=fail smtp.client-ip=40.107.244.80 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="xJG/l0jz" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=Y0dE4Xi96Ftdmz8Hnoa1+ZJdEdb7jrPReIbbZE217EncixcwZ1E+O9RftltccAS0uKMUc4S2VlOnklxLxMOOXEhszvnyBaR9FVk/nt/g/P7J7l1wOlvinh5DfEmuyNxlgNYD9mybt4kPIpiMt95XU/RnlkfP3RXhY1xjfTDVpT0WzmcrguL4nivWJIAfnrzwrdbsEXCzNGpXeEgjIKcJpdZkCDuwCfDHn/1Oinm80c82LQAurxGP1hyV/aunUCR6gvytRAUBZg1Fntv3Sp6SvSOjD+uaYhNvJRJRPodEsaPTZmxAJ1Ad1cROhYvmeBLJng04Y6Haer8YrE88jc8hzw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=bNhlxFEOdSMGP5MRfIGoRpoaBahr4HOKt83Sx7+SOmU=; b=qfPtlIXAyW/DEjb5B9t/ac7DcSQKhxEE2t+KQv4dIj+JSwiId7Lu3Pj4xIaIXGmttI0d305TFCtL/Q2aUIfS8irgkDUjhZpC+NsnWrXuulZXTZGDqXGD2ocHbRCmxBCznN9Jt6+fYETYQqQjKw9yiYLT+gtTZr0SVc2NrPFdQPQ8vI16k9ZdV2MtP14GHbDpGCqvktLIjv1kZG/8Uiz0xwFuLJNHZCK5KjG9+Z1zdKfjBUQSdwcbYVZ1O+9OjIqvkL1wClNOxub67ZbAdEMsHdRNfsUdWWNds8CHKqzNOt4GjdqBYN7PCYgPtdDCBesyW3piuXpa2+bAA2I8BqMcbA== 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=bNhlxFEOdSMGP5MRfIGoRpoaBahr4HOKt83Sx7+SOmU=; b=xJG/l0jzqOGZf48SPkLZAMqxlv/nIF7zompRzq7n/PlmcLCVAhy3Qb3hQI+5R1n5c5uHORFi7HjddXCgxW1bvV+0gfuMg0pZqphHfQ8ysijFL3zo8gOoohBl5nLtOvXkmlP34X3dM5BPgk2gwQvqh2j3gpa9yg+0mFmE50MBTuI= Received: from CH0PR03CA0426.namprd03.prod.outlook.com (2603:10b6:610:10e::10) by IA0PR12MB8981.namprd12.prod.outlook.com (2603:10b6:208:484::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8377.16; Wed, 22 Jan 2025 20:21:21 +0000 Received: from CH1PEPF0000A345.namprd04.prod.outlook.com (2603:10b6:610:10e:cafe::1c) by CH0PR03CA0426.outlook.office365.com (2603:10b6:610:10e::10) with Microsoft SMTP Server (version=TLS1_3, cipher=TLS_AES_256_GCM_SHA384) id 15.20.8356.22 via Frontend Transport; Wed, 22 Jan 2025 20:21:21 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 165.204.84.17) smtp.mailfrom=amd.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=amd.com; Received-SPF: Pass (protection.outlook.com: domain of amd.com designates 165.204.84.17 as permitted sender) receiver=protection.outlook.com; client-ip=165.204.84.17; helo=SATLEXMB04.amd.com; pr=C Received: from SATLEXMB04.amd.com (165.204.84.17) by CH1PEPF0000A345.mail.protection.outlook.com (10.167.244.8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.8377.8 via Frontend Transport; Wed, 22 Jan 2025 20:21:21 +0000 Received: from bmoger-ubuntu.amd.com (10.180.168.240) by SATLEXMB04.amd.com (10.181.40.145) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.39; Wed, 22 Jan 2025 14:21:19 -0600 From: Babu Moger To: , , , , , , , CC: , , , , , , , , , , , , , , , , , , , , , , , , , , Subject: [PATCH v11 04/23] x86/resctrl: Consolidate monitoring related data from rdt_resource Date: Wed, 22 Jan 2025 14:20:12 -0600 Message-ID: <823ba5e1632d136359a6edc864bde68b46a13fe2.1737577229.git.babu.moger@amd.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: References: Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-ClientProxiedBy: SATLEXMB04.amd.com (10.181.40.145) To SATLEXMB04.amd.com (10.181.40.145) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CH1PEPF0000A345:EE_|IA0PR12MB8981:EE_ X-MS-Office365-Filtering-Correlation-Id: 84f7b143-0f63-4bb5-df8c-08dd3b225631 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|82310400026|36860700013|376014|7416014|1800799024; X-Microsoft-Antispam-Message-Info: =?us-ascii?Q?MJK0Hp7p2Cxn9NHRVe8rFlorcmFfvEDMBIi261r13xsDhgPTU7LFNNNengNg?= =?us-ascii?Q?f7B3nVezmWyQRAkcodrtq9hFRBmfcZfI7/pYAtBHCXhHqUqnVXqOym2cdi6s?= =?us-ascii?Q?l84AwThRWvvP5uG2AjW0miwMPFMLVcdVLrPka2VJk/qHDxU0ryZtpolxKIMn?= =?us-ascii?Q?qCkyXWJkpmOo3awaMrfpQelKFWH8qrzxRBDuABWFrXyTGvhrH4+8tAwHASV1?= =?us-ascii?Q?hRZ3rh8TXl4bhQFa32LuPFxllZY97KfKXZDd7zaHfLcR3Sf6gm30QkHVVsJs?= =?us-ascii?Q?SKtEPL1n+JT28L9ceG17xe2ppdBq7D37ZGish/YyCyeOFxzxmu0Lw5I3egUE?= =?us-ascii?Q?IvBebezgPcCeA4FHGqRtLnV12I573LRQept8I31ofHgmjKopeirWjBm+aAzl?= =?us-ascii?Q?OaFq38gpS1Egu1bc7DwqSDXKkb4Xt5ovwFI4/wrgbqvTXEfxgTAdPsr0CfG/?= =?us-ascii?Q?QUilLu/qGr8IK89YVgpTcMnY06C4HpzSjCaNdm+oqWWjHsr75NBu//Sgtukw?= =?us-ascii?Q?uSdHNRSE1OxtR72tzA/+86qxdL41yCGwrb9Lv7Hc6zx6dlMnTWcsPUN8GYmC?= =?us-ascii?Q?P7BB0/vApkBlbj6tx0kyQD+x8iEhWDRjoy8PkteYTs3OSfd+/m9+ZwLEs5KM?= =?us-ascii?Q?NOZl5R6CxJ3MsOOdF/DSrvadhAam9YISchDj5l8iQcXtrDRCe8xovOPDTHDH?= =?us-ascii?Q?L1ATPTIdDonZNpXq2QsFUDu31KaIcc74ZNmOQDboOFZsqKoIeElmvOYtXVZj?= =?us-ascii?Q?QseZYZUUzuo9cywg9vOCPxXABqZ4rIytZXFdJbqoKFAGKA/5a06aaColki2W?= =?us-ascii?Q?I/TjoHX0EfQnqc9/WzYiYLCd0Jca6K1EsOmYnm7nrN66ImBZzN0Xue5peQli?= =?us-ascii?Q?KpGbUKGnE7VTSH8hoGZ2CSFXwNFA+HMEhqngvCPVPOPMJu3X7DsMQWGOujfW?= =?us-ascii?Q?JGUCJSFd1JN9CckCNiQ8KGXluVr7gdI77sRZHxcLSY8ifz7/rQjQYiFEQfA3?= =?us-ascii?Q?9Outgpm7cchmVkkThM9k8bx7tHQV1qkVfbYWkDqpmtBmG95yGy500fm8STW5?= =?us-ascii?Q?cFGGYBDH+V3zTwoMuysheac1bCxLyhCvO1PJH1eQSQlvr50rjSbbLERJOI8q?= =?us-ascii?Q?B4tZjJahrYyLUpW6PsdtSPhAn6SRKyUbr8l01xHdYaslNP6fT9qKXWpVq1eL?= =?us-ascii?Q?xGgrB1Tf1Xdc4tdjiZYNiVmX2FZG0HOlh63XASLgHQoK86FYnMWWznYNX3tZ?= =?us-ascii?Q?bLNtyU60y7Tc3vQRa3hbLPOm0LXrg+dHocHnq3Wy+K2D/QWl9Cpv67VasvYh?= =?us-ascii?Q?r1w8kiDkfc2EG8XdvOgaCM6MO9QWwnltnEIg3scj1975v24Z2SvvkRCrO0M0?= =?us-ascii?Q?6HPaJ8hb+Jw3xycdbou18kCN0WE8DBlUQKB1j6EMQp4YxXbMmwoSfwhuQe0j?= =?us-ascii?Q?LQLSa4N/AT4rOBqnt5/ACEddwVh+jISUZRAu5eXcSBQsma2tMywOe17NgPIS?= =?us-ascii?Q?H9H8N5wRAjeW6s0=3D?= X-Forefront-Antispam-Report: CIP:165.204.84.17;CTRY:US;LANG:en;SCL:1;SRV:;IPV:CAL;SFV:NSPM;H:SATLEXMB04.amd.com;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(13230040)(82310400026)(36860700013)(376014)(7416014)(1800799024);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 22 Jan 2025 20:21:21.5639 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 84f7b143-0f63-4bb5-df8c-08dd3b225631 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: CH1PEPF0000A345.namprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: IA0PR12MB8981 Content-Type: text/plain; charset="utf-8" The cache allocation and memory bandwidth allocation feature properties are consolidated into struct resctrl_cache and struct resctrl_membw respectively. In preparation for more monitoring properties that will clobber the existing resource struct more, re-organize the monitoring specific properties to also be in a separate structure. Suggested-by: Reinette Chatre Signed-off-by: Babu Moger Reviewed-by: Reinette Chatre --- v11: No changes. v10: No changes. v9: No changes. v8: Added Reviewed-by from Reinette. No other changes. v7: Added kernel doc for data structure. Minor text update. v6: Update commit message and update kernel doc for rdt_resource. v5: Commit message update. Also changes related to data structure updates does to SNC support. v4: New patch. --- arch/x86/kernel/cpu/resctrl/core.c | 4 ++-- arch/x86/kernel/cpu/resctrl/monitor.c | 18 +++++++++--------- arch/x86/kernel/cpu/resctrl/rdtgroup.c | 8 ++++---- include/linux/resctrl.h | 16 ++++++++++++---- 4 files changed, 27 insertions(+), 19 deletions(-) diff --git a/arch/x86/kernel/cpu/resctrl/core.c b/arch/x86/kernel/cpu/resct= rl/core.c index 97511cc132d6..cb7feb7c990f 100644 --- a/arch/x86/kernel/cpu/resctrl/core.c +++ b/arch/x86/kernel/cpu/resctrl/core.c @@ -124,7 +124,7 @@ u32 resctrl_arch_system_num_rmid_idx(void) struct rdt_resource *r =3D &rdt_resources_all[RDT_RESOURCE_L3].r_resctrl; =20 /* RMID are independent numbers for x86. num_rmid_idx =3D=3D num_rmid */ - return r->num_rmid; + return r->mon.num_rmid; } =20 /* @@ -627,7 +627,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 1c7b574bf0cd..0c481501b8c5 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) @@ -1079,14 +1079,14 @@ static struct mon_evt mbm_local_event =3D { */ static __init 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 /* @@ -1183,7 +1183,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) @@ -1198,7 +1198,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 6419e04d8a7b..f91fe605766f 100644 --- a/arch/x86/kernel/cpu/resctrl/rdtgroup.c +++ b/arch/x86/kernel/cpu/resctrl/rdtgroup.c @@ -1106,7 +1106,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; } @@ -1117,7 +1117,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); @@ -3068,13 +3068,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 d94abba1c716..3c2307c7c106 100644 --- a/include/linux/resctrl.h +++ b/include/linux/resctrl.h @@ -182,16 +182,26 @@ enum resctrl_scope { RESCTRL_L3_NODE, }; =20 +/** + * struct resctrl_mon - Monitoring related data of a resctrl resource + * @num_rmid: Number of RMIDs available + * @evt_list: List of monitoring events + */ +struct resctrl_mon { + int num_rmid; + struct list_head evt_list; +}; + /** * struct rdt_resource - attributes of a resctrl resource * @rid: The index of the resource * @alloc_capable: Is allocation available on this machine * @mon_capable: Is monitor feature available on this machine - * @num_rmid: Number of RMIDs available * @ctrl_scope: Scope of this resource for control functions * @mon_scope: Scope of this resource for monitor functions * @cache: Cache allocation related data * @membw: If the component has bandwidth controls, their properties. + * @mon: Monitoring related data. * @ctrl_domains: RCU list of all control domains for this resource * @mon_domains: RCU list of all monitor domains for this resource * @name: Name to use in "schemata" file. @@ -199,7 +209,6 @@ enum resctrl_scope { * @default_ctrl: Specifies default cache cbm or memory B/W percent. * @format_str: Per resource format string to show domain value * @parse_ctrlval: Per resource function pointer to parse control values - * @evt_list: List of monitoring events * @fflags: flags to choose base and info files * @cdp_capable: Is the CDP feature available on this resource */ @@ -207,11 +216,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 +230,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 Wed Feb 11 05:40:54 2026 Received: from NAM12-MW2-obe.outbound.protection.outlook.com (mail-mw2nam12on2055.outbound.protection.outlook.com [40.107.244.55]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id A9536215769; Wed, 22 Jan 2025 20:21:35 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.244.55 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1737577297; cv=fail; b=IDMBN9sZ1+CS1TsxT5sLsFX5dATZpLTYtTHT+ZGo65SzP8OQMINCXkZOcRYtf0jXm5PVVbwbGwGkFvh23XPwDwPDVS4Uykt92BrhLls80Tw6O/EviNQmawuuz9CuoQqghNCyKAmjQadPsJSqhc9p4bPsgyjzhKgE4xirvu6GzIU= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1737577297; c=relaxed/simple; bh=EmHa1o3we3R/Mcrn2+6XVGwfUNyEtZCM+B7Y2JohYrI=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=eLzrXDKLEczHKXkJxP+BJyEiCDhYm932/lyxumgoEq/DZyK2b26oGOrrt4ptbI/ErEhgCPGsoiZftOl1APlcXxyIAAadf3ufK2zS3/U0WtKHsseDicl7fYbZ4XCI8Uf/kezFKB0nh2qkpklheQqpfb4MmO2wZoWEja0eBa9O594= 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=h0CjpIzu; arc=fail smtp.client-ip=40.107.244.55 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=amd.com Authentication-Results: smtp.subspace.kernel.org; spf=fail smtp.mailfrom=amd.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=amd.com header.i=@amd.com header.b="h0CjpIzu" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=yGPBwF5p3mEtQEOJBPLoJR5DL9zZtnfBxiQ7BSjAWYKk1h39C3wu3sKLjz0Pl2KQ7JvWi/nncnTARj1N303mJj/DLv5iSuqvA45r2MfuyriD2paPpqLB7najGu/pEwh+XPDWwfXTfOrdvR1JuUr+Eg4+Rh6qvY0zd4KSBDalU8NINsjwbNHFlG1ALb9qyPqrcFRDHx0INJ4z+ySfOu3snjFYxHcwYXzYK+FpFrOHHzViX7yinBmRLkg8LEfeRk+3NLxtjyu4P0jxWOpfKnxK78AuLUzQpB4b4gff/Mwg3GCQs8YwKXfDJ/6jLjbq47OhCkg6qJmLxUhohrFfk191Jw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=73T2ElaSlrHc4Ty8BpLcMkX9p70oHsoYdRnbyFtRnSA=; b=VSU06URObZAXcfdfWiZsoLU0sYSyUaH5qIPVi93gDIbzBnyu+E9wCY9kxY9+CqUJh6gR6YBzNWe3QAqBL+5A8VTD/pdK0bkhh2BU7L/MZajgN3+GAj/4Sta6ZQt8NstiD3sb6TXSJ7Wawjwg9KuYW4iZLIAMz7MDlH9dlADQxNYV3CKxqT+UcZTTYxh0/e4+jUlCA7NDX46qetrHwkMPXnMLGndeZ2ohdHtr4N4y6EGFqem0pXF7eFQap05Da7or5ZDrSR3fwYTn7HtKnwVkrln3m9bhANDC3TKBAbqIY6TYBfd/57TXouAlMIfg5Qzic9xrpbExlW63XiqPwzYojg== 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=73T2ElaSlrHc4Ty8BpLcMkX9p70oHsoYdRnbyFtRnSA=; b=h0CjpIzuNK5nFWwOlhY1GO9yWyj0dpZ7+RyXJmhfwRk9gw5YeWb4ZMxfTFQjNUgvhnE7udkln+vneqro9R5uHdJgDKBRDebvXSvkfmmgGIxMQCB+sTK8ZGra1s7cq7zVEKU/xBznpTePPtWTAQn9Y+AKsnnOcd4cy2iTsYqfNdI= Received: from CH2PR07CA0033.namprd07.prod.outlook.com (2603:10b6:610:20::46) by IA1PR12MB6602.namprd12.prod.outlook.com (2603:10b6:208:3a2::7) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8356.21; Wed, 22 Jan 2025 20:21:29 +0000 Received: from CH1PEPF0000A34A.namprd04.prod.outlook.com (2603:10b6:610:20:cafe::da) by CH2PR07CA0033.outlook.office365.com (2603:10b6:610:20::46) with Microsoft SMTP Server (version=TLS1_3, cipher=TLS_AES_256_GCM_SHA384) id 15.20.8377.14 via Frontend Transport; Wed, 22 Jan 2025 20:21:29 +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 CH1PEPF0000A34A.mail.protection.outlook.com (10.167.244.5) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.8377.8 via Frontend Transport; Wed, 22 Jan 2025 20:21:29 +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, 22 Jan 2025 14:21:27 -0600 From: Babu Moger To: , , , , , , , CC: , , , , , , , , , , , , , , , , , , , , , , , , , , Subject: [PATCH v11 05/23] x86/resctrl: Detect Assignable Bandwidth Monitoring feature details Date: Wed, 22 Jan 2025 14:20:13 -0600 Message-ID: <0935b01834646e550e67e842613290b610ebf8f5.1737577229.git.babu.moger@amd.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: References: Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-ClientProxiedBy: SATLEXMB04.amd.com (10.181.40.145) To SATLEXMB04.amd.com (10.181.40.145) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CH1PEPF0000A34A:EE_|IA1PR12MB6602:EE_ X-MS-Office365-Filtering-Correlation-Id: 51553b7b-5ba5-4679-48c4-08dd3b225adb X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|36860700013|82310400026|1800799024|376014|7416014|13003099007; X-Microsoft-Antispam-Message-Info: =?us-ascii?Q?MLtn2pOMahTkmw2Yi1DNIPvzana6Ii9kEVeVUt3odri6J3TdY9m6XAmIDPBp?= =?us-ascii?Q?OScLOmdcHSudT99YrJxbWDM+EO/+s3XrA1jRmSp4K2DbAaC17zBwEDnVauCc?= =?us-ascii?Q?iULaxfh3Gt4jqh5pMSHtvd9jvFtjnZwmK8uz0YQgW2kEI/9Hzj5ZWiiBd9/S?= =?us-ascii?Q?UAmr3sWXnAVE3A0jTOrxZ2FhfyLzQjyd2mWWd27HBy+mAFwYcKUzU+IKjx/p?= =?us-ascii?Q?Xv6GD+MZ1W3DA2eyxyoCUabWHoaxgPuBZGV3z8f4ORMhjzKjh0R22zSiS9br?= =?us-ascii?Q?mKuEqFA0L3IYSvkFqgYSzxzHcEmcQHQnSDI0RrvkC6ww8xxiGjpopG3kBe9d?= =?us-ascii?Q?2xHLfMNyZ28AX8X6m8IDehJtUhovj1+WTUKNeotFj1ydQjQGZtpf4+31bNZX?= =?us-ascii?Q?Nr6p41kYnN+VwJ8ttFgVuJ/bYsbFtYDMl/RXw9fhd0qkGNw8be/tTZ3XNzBE?= =?us-ascii?Q?hfZYHbSscmw9KcdhDGZbPice47YmavCJKZaXK4Hj88PcvGzpW4DLdOGNvG07?= =?us-ascii?Q?IU3ogY3CnsjF4oug0uNHOicjPIcyAytUmjPKvi6sPK0teto/YPI+rSGJks+d?= =?us-ascii?Q?bUdVqPLfx9AG9Iv3JS+/XM+GqJOqdugufOaQV0u5iWXEU4YUMQJblnpNUCbf?= =?us-ascii?Q?mnpAEMEXfONlTpyZXebsRQtow5Te2pVozCh+d4pZ6QObZM6simXNSp6BNHIF?= =?us-ascii?Q?T1X6NoeeQJgZhEWVLjBuh2ArZBqJeC0tl98DtACefa1mcsCDwE/XPuOh+AL0?= =?us-ascii?Q?KaYDgz5jvFAfuRqbmjnnga5M4W2sspKlktawlCs/fDypJULR9IS3xoZyED8p?= =?us-ascii?Q?YUNIHXTrGApUo036QfLl28Uj4Wgv+tVt/fP7+rgjie6gNIbbHrBh0KSYHUrj?= =?us-ascii?Q?V4w/9M55P7XjK60a/d4toLqQGMJjzJ5PRa+XXVayLsIaXdyDkqOgI21gQv5x?= =?us-ascii?Q?vpidgjBHZWPLf5V2AwhuvjydmS8dx9cjzGCIUSTt7wzJnH+pD2jd8Aph7we9?= =?us-ascii?Q?BJMnka3GqHcjnHQoM0A8xntA01bdmLWXJvz0i/MFDL96s9CBXAKijDkWtws/?= =?us-ascii?Q?9tNAzHBiA45XRkSwmrlpxNYfwEiVp2CmmVWwdj6GeV4W4ME+OPn8BBsdaiEw?= =?us-ascii?Q?SfX7z34XYqv3Db1CAVIEaqDtjOUDlfJrz4yNEHBByH4qXdccOEBqyNx+YGcP?= =?us-ascii?Q?kDfa7OhME4kWx7aEloV1w4qWutOixGtCiwo1AmJsjExreSbHtr+9jWOvVPm7?= =?us-ascii?Q?SGGvw+VJeO0OyY2oXt2FQxQWxQFtH9KxPSmV5jH5/ginP1ZPVSXUBL4w0KyH?= =?us-ascii?Q?AcC80jDzeHTgUldifcwibIE4oKIVF/0VgHqP8+L9XT+elEV2Gu0sokSYmVjh?= =?us-ascii?Q?GF3kD333HM1l+DVErWo9l3PNKIg74M0qE8f4fNth2QGu589flizYzZvO338y?= =?us-ascii?Q?adS4f0ZqXrw=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)(82310400026)(1800799024)(376014)(7416014)(13003099007);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 22 Jan 2025 20:21:29.4944 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 51553b7b-5ba5-4679-48c4-08dd3b225adb 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: CH1PEPF0000A34A.namprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: IA1PR12MB6602 Content-Type: text/plain; charset="utf-8" ABMC feature details are reported via CPUID Fn8000_0020_EBX_x5. Bits Description 15:0 MAX_ABMC Maximum Supported Assignable Bandwidth Monitoring Counter ID + 1 The feature details are documented in APM listed below [1]. [1] AMD64 Architecture Programmer's Manual Volume 2: System Programming Publication # 24593 Revision 3.41 section 19.3.3.3 Assignable Bandwidth Monitoring (ABMC). Detect the feature and number of assignable monitoring counters supported. Link: https://bugzilla.kernel.org/show_bug.cgi?id=3D206537 Signed-off-by: Babu Moger Reviewed-by: Reinette Chatre --- v11: No changes. v10: No changes. v9: Added Reviewed-by tag. No code changes v8: Used GENMASK for the mask. v7: Removed WARN_ON for num_mbm_cntrs. Decided to dynamically allocate the bitmap. WARN_ON is not required anymore. Removed redundant comments. v6: Commit message update. Renamed abmc_capable to mbm_cntr_assignable. v5: Name change num_cntrs to num_mbm_cntrs. Moved abmc_capable to resctrl_mon. v4: Removed resctrl_arch_has_abmc(). Added all the code inline. We dont need to separate this as arch code. v3: Removed changes related to mon_features. Moved rdt_cpu_has to core.c and added new function resctrl_arch_has_abm= c. Also moved the fields mbm_assign_capable and mbm_assign_cntrs to rdt_resource. (James) v2: Changed the field name to mbm_assign_capable from abmc_capable. --- arch/x86/kernel/cpu/resctrl/monitor.c | 6 ++++++ include/linux/resctrl.h | 4 ++++ 2 files changed, 10 insertions(+) diff --git a/arch/x86/kernel/cpu/resctrl/monitor.c b/arch/x86/kernel/cpu/re= sctrl/monitor.c index 0c481501b8c5..c3d7d4c3009a 100644 --- a/arch/x86/kernel/cpu/resctrl/monitor.c +++ b/arch/x86/kernel/cpu/resctrl/monitor.c @@ -1228,6 +1228,12 @@ int __init rdt_get_mon_l3_config(struct rdt_resource= *r) resctrl_file_fflags_init("mbm_local_bytes_config", RFTYPE_MON_INFO | RFTYPE_RES_CACHE); } + + if (rdt_cpu_has(X86_FEATURE_ABMC)) { + r->mon.mbm_cntr_assignable =3D true; + cpuid_count(0x80000020, 5, &eax, &ebx, &ecx, &edx); + r->mon.num_mbm_cntrs =3D (ebx & GENMASK(15, 0)) + 1; + } } =20 l3_mon_evt_init(r); diff --git a/include/linux/resctrl.h b/include/linux/resctrl.h index 3c2307c7c106..511cfce8fc21 100644 --- a/include/linux/resctrl.h +++ b/include/linux/resctrl.h @@ -185,10 +185,14 @@ enum resctrl_scope { /** * struct resctrl_mon - Monitoring related data of a resctrl resource * @num_rmid: Number of RMIDs available + * @num_mbm_cntrs: Number of assignable monitoring counters + * @mbm_cntr_assignable:Is system capable of supporting monitor assignment? * @evt_list: List of monitoring events */ struct resctrl_mon { int num_rmid; + int num_mbm_cntrs; + bool mbm_cntr_assignable; struct list_head evt_list; }; =20 --=20 2.34.1 From nobody Wed Feb 11 05:40:54 2026 Received: from NAM12-BN8-obe.outbound.protection.outlook.com (mail-bn8nam12on2040.outbound.protection.outlook.com [40.107.237.40]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id A965D2163AB; Wed, 22 Jan 2025 20:21:45 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.237.40 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1737577307; cv=fail; b=AcZ86CYA3y9z3a7+IoTaANRUIn84VOlnYvqc7VXtRKqLnbdDWPq6I4tndchYJu2Rp3bh8DsUcW77XMqM7GQxoTkwHxTjFO5vWCAqQJxEEHEygFl8gyW2jblgEk+toztAnZOidjc9sKaj9wRAbSpbFsRCxIPh/bfQcVoYTycyPd4= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1737577307; c=relaxed/simple; bh=Tkc1Pza9XBe5MTWfN5sIhN/mawSOtp3ZEqCIs42Ekco=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=nLY6BYaDRXhosRl6lkktth/3QDt73v/fyN3WjxZ4QlYkx4lxzoFRGUA2MpomPFde1Nbrv6OQD3tjkMDJNQdjIz3afs8VgZhRNh02Jul4KfHFzPTyaiiFk4jUloZtkSDsqjCUm+kWiXSuZmab1Lzgs30EWLa91s8fwKVT0JYs+hQ= 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=qmMrlqNU; arc=fail smtp.client-ip=40.107.237.40 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=amd.com Authentication-Results: smtp.subspace.kernel.org; spf=fail smtp.mailfrom=amd.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=amd.com header.i=@amd.com header.b="qmMrlqNU" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=qxynwybFT8+SF29mRcuibzcDCLEb9J0KxM/ZOPGllagVLIaOR/eW/RFUirBXvwQ6eAeESzBdbnnqLYhOvAo5vk5yaNeNPbjRDkjWSZkd8wkMuw4gzcvYFbgopZDNS+Ez+st/544drn/ecMyvjoCvQiYdDYCW0qzhkh9qtGAe+KqHSuR0MmLJ8KWsdlcIE778XKh825naPm8UbCrd1BGxHY4VMu0oBI/0k+5MLBtGPnx35JhG6hqRh0SmQLWm3FCjsIo41uhY4GEZCKLSoeMnkgcY9ELVnBy56dA0Biq2hddNDo6bUyhgtzofGmxxjJ5Zfhn2iDO9edxurqJR2AeqXg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=GeJrSxNzHHp4Yi4hU5T+dUxnDxFoOhn2vqkKO/+hGdM=; b=avk8VDjS/w2X+LTsVSN2rFf+y6Dls1L/56YjEebS1LTAKKdYehOdpn1DZO4E1omLy7Nby/DN8klkLRAceIZjWdXKCLkbLPpZgUuZ0qhGiC89QKq2zfXcLph3ACn03c30re1weyhd9cybRkFpATqImkUBjboJGQvRgcP0SdjVBeienMnLTeju/SR35FUD+4QprOxZviRt9V75eMqqCoLHbEJI5yCxC4krZS78TwVw1oGzdxqNYDsDqG5cS/gNV4yTSMqfFeBvtiLYjQtpcMDzSKWv7CS9S1UhnsYvx0Uam3CxUkCOmG56LD9yz8X9IkUJ1aptx9HYn91wS947XHt1eQ== 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=GeJrSxNzHHp4Yi4hU5T+dUxnDxFoOhn2vqkKO/+hGdM=; b=qmMrlqNUDsYXmAfUI2P4vpVfEbMD0g2AB3eVC2usGWgC4TF4w2vFk5imb0HObITDV8sKQlZso7ijRdH+IgypScquxO2jhb5fLZ+zB5TdBqX0pEN99pBhh51+nFy7QR7lYSJaYt67o79bPdp6VZD7YegskYC1B3IFN907lJoRkjA= Received: from CH2PR12CA0004.namprd12.prod.outlook.com (2603:10b6:610:57::14) by IA1PR12MB6386.namprd12.prod.outlook.com (2603:10b6:208:38a::14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8356.21; Wed, 22 Jan 2025 20:21:37 +0000 Received: from CH1PEPF0000A346.namprd04.prod.outlook.com (2603:10b6:610:57:cafe::b4) by CH2PR12CA0004.outlook.office365.com (2603:10b6:610:57::14) with Microsoft SMTP Server (version=TLS1_3, cipher=TLS_AES_256_GCM_SHA384) id 15.20.8377.17 via Frontend Transport; Wed, 22 Jan 2025 20:21:37 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 165.204.84.17) smtp.mailfrom=amd.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=amd.com; Received-SPF: Pass (protection.outlook.com: domain of amd.com designates 165.204.84.17 as permitted sender) receiver=protection.outlook.com; client-ip=165.204.84.17; helo=SATLEXMB04.amd.com; pr=C Received: from SATLEXMB04.amd.com (165.204.84.17) by CH1PEPF0000A346.mail.protection.outlook.com (10.167.244.11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.8377.8 via Frontend Transport; Wed, 22 Jan 2025 20:21:37 +0000 Received: from bmoger-ubuntu.amd.com (10.180.168.240) by SATLEXMB04.amd.com (10.181.40.145) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.39; Wed, 22 Jan 2025 14:21:35 -0600 From: Babu Moger To: , , , , , , , CC: , , , , , , , , , , , , , , , , , , , , , , , , , , Subject: [PATCH v11 06/23] x86/resctrl: Add support to enable/disable AMD ABMC feature Date: Wed, 22 Jan 2025 14:20:14 -0600 Message-ID: <920cafec1920358ad0c8af2e78a8f8bbd8c0b77d.1737577229.git.babu.moger@amd.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: References: Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-ClientProxiedBy: SATLEXMB04.amd.com (10.181.40.145) To SATLEXMB04.amd.com (10.181.40.145) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CH1PEPF0000A346:EE_|IA1PR12MB6386:EE_ X-MS-Office365-Filtering-Correlation-Id: 4723c8cf-7abf-42f3-8bd1-08dd3b225fa3 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|1800799024|376014|7416014|36860700013|82310400026|13003099007; X-Microsoft-Antispam-Message-Info: =?us-ascii?Q?fgDc5o1x1hH+aweIwH0rFdl0O3IhF1CQX8r6d39vn0fNcZAmNrQipUokSRBe?= =?us-ascii?Q?8bnib8nQIJO3ztG6OSgxg3p8Vs/4z2joP690C8/xl29aKP6qp/waGA3Y2BC+?= =?us-ascii?Q?1mxcThhKuCHEFgxhEdKwe4fQ4hSaiZqEBz7SZZmCXJPonEzv2HS3Tn3q5hAT?= =?us-ascii?Q?KzSnjQIMhWpz3LqjyExstgev89InY2kBnBUH9teCVZi8t46UJ0jZqPqZ2KmZ?= =?us-ascii?Q?jpeEN0G9PJe2f7ZPqF45ogMAH/BrTkjMzwLrXtQXq3Gbs9mIchesa8WjGPtx?= =?us-ascii?Q?0uIXXa69nDD6SCWrHpBgksCjxcMqnpXMVkBkfmDaSgFStoL1ZRzxkFBOuyYR?= =?us-ascii?Q?nWhQTqSrVsFdzz//e9Makd+XGY/uAyQoWTJnperHAQZ2k0llH7sIl8Vqce52?= =?us-ascii?Q?9+9GEqmYGCKSxW5PgMAwwsV8rsbLSf+Oe/svhPWy9HGwT9mVtupwja1N9PBM?= =?us-ascii?Q?QQQAEc7fSBE/7W1NCalfsNWXb4kkFqa5bSQ6zFkHtwx1W/wxGpx0kEpkDqYe?= =?us-ascii?Q?xVw8gy9KGadCiqbux2LQ7o+35NcYY3MzKJ3J3XOD/VrcWSIhN5HaOq/gHmVj?= =?us-ascii?Q?ye0+9zWVEQik2zpgEwuEQjte+NMNF8qibDd987oE42ZzOY133QUxarEA7Kjq?= =?us-ascii?Q?Af4jbiQFUs/BRUaia0qSxggMADTmP6zhS7JqNkGx57vXawJeJJKt82JzHTc3?= =?us-ascii?Q?mJRRibqw+jOF0cGjNBsJlZmyuHWLyGgpIl0HojFPY4H2CXMRpV4b6wcGQ/dW?= =?us-ascii?Q?HYCw4z6WS+7ePwTKoyqi4J1G6bhcKTHSH4za88emf3fcaVcR0hBIKlYW3Uq7?= =?us-ascii?Q?MykYUbN3OV2UJA7dEh+fqXcy2O58uOA8HCtRwImD92V38IO5dwIYFumxK9gy?= =?us-ascii?Q?sOPm7LfjspDgUH2oMqCNhlyHHFd0fLQxkSYtN7tRt0nAM53EFOGAX+cL/clc?= =?us-ascii?Q?lqP9cUNG6X6CEcw4aALkh+lsA8Xk8JpF0N0j7QHNhJivDNCagafgbKmrd5zK?= =?us-ascii?Q?pfjog2WzXyl0uBx2PSpCpF/vQesELmvD/9YX9qUqTs/LKEiWp3S6M2SN+oDD?= =?us-ascii?Q?wnciS59N57sYHhkHe+lBtICBqQKYdcAjtYYDnj6/d1VbaahMMQhhhxi9r9u6?= =?us-ascii?Q?V1Be4kbNiihJ+islAZv7Yw4YIVyG2sbI5iWQ7tS8kh+WVAUy97Jskhabrsoa?= =?us-ascii?Q?hKPfHOd4Zp6u5OzUFXFSyffYG+sWzvSoEph6sQXtJ39I6PxtQwye8KyiaLbh?= =?us-ascii?Q?0MhZTmqt7Urgrk0AQAN4l3s24ucSICJInGaiKrk50Q5zFFO+c0dqNCK+23VG?= =?us-ascii?Q?DP8BkrfWVos3a7bZav1oAfl40gQd6ngfgY+snl7xviRTvFHK5s3FUQvIzHIA?= =?us-ascii?Q?4+GdABKIRx5+MwTeLetFjOd+RQQyLkfmYNoHOq7tvtM1XyQDQzNcbxuSlJIP?= =?us-ascii?Q?KNYE3Cj6GPj28F9khxrI3tYa5BQoAyDz?= 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)(36860700013)(82310400026)(13003099007);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 22 Jan 2025 20:21:37.5021 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 4723c8cf-7abf-42f3-8bd1-08dd3b225fa3 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: CH1PEPF0000A346.namprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: IA1PR12MB6386 Content-Type: text/plain; charset="utf-8" Add the functionality to enable/disable AMD ABMC feature. AMD ABMC feature is enabled by setting enabled bit(0) in MSR L3_QOS_EXT_CFG. When the state of ABMC is changed, the MSR needs to be updated on all the logical processors in the QOS Domain. Hardware counters will reset when ABMC state is changed. The ABMC feature details are documented in APM listed below [1]. [1] AMD64 Architecture Programmer's Manual Volume 2: System Programming Publication # 24593 Revision 3.41 section 19.3.3.3 Assignable Bandwidth Monitoring (ABMC). Link: https://bugzilla.kernel.org/show_bug.cgi?id=3D206537 Signed-off-by: Babu Moger --- v11: Moved the monitoring related calls to monitor.c file. Moved the changes from include/linux/resctrl.h to arch/x86/kernel/cpu/resctrl/internal.h. Removed the Reviewed-by tag as patch changed. Actual code did not change. v10: No changes. v9: Re-ordered the MSR and added Reviewed-by tag. v8: Commit message update and moved around the comments about L3_QOS_EXT_CFG to _resctrl_abmc_enable. v7: Renamed the function resctrl_arch_get_abmc_enabled() to resctrl_arch_mbm_cntr_assign_enabled= (). Merged resctrl_arch_mbm_cntr_assign_disable, resctrl_arch_mbm_cntr_assi= gn_disable and renamed to resctrl_arch_mbm_cntr_assign_set(). Moved the function definition to linux/resctrl.h. Passed the struct rdt_resource to these functions. Removed resctrl_arch_reset_rmid_all() from arch code. This will be done from the caller. v6: Renamed abmc_enabled to mbm_cntr_assign_enabled. Used msr_set_bit and msr_clear_bit for msr updates. Renamed resctrl_arch_abmc_enable() to resctrl_arch_mbm_cntr_assign_enab= le(). Renamed resctrl_arch_abmc_disable() to resctrl_arch_mbm_cntr_assign_dis= able(). Made _resctrl_abmc_enable to return void. v5: Renamed resctrl_abmc_enable to resctrl_arch_abmc_enable. Renamed resctrl_abmc_disable to resctrl_arch_abmc_disable. Introduced resctrl_arch_get_abmc_enabled to get abmc state from non-arch code. Renamed resctrl_abmc_set_all to _resctrl_abmc_enable(). Modified commit log to make it clear about AMD ABMC feature. v3: No changes. v2: Few text changes in commit message. --- arch/x86/include/asm/msr-index.h | 1 + arch/x86/kernel/cpu/resctrl/core.c | 5 ++++ arch/x86/kernel/cpu/resctrl/internal.h | 7 +++++ arch/x86/kernel/cpu/resctrl/monitor.c | 36 ++++++++++++++++++++++++++ 4 files changed, 49 insertions(+) diff --git a/arch/x86/include/asm/msr-index.h b/arch/x86/include/asm/msr-in= dex.h index 9a71880eec07..fea1f3afe197 100644 --- a/arch/x86/include/asm/msr-index.h +++ b/arch/x86/include/asm/msr-index.h @@ -1197,6 +1197,7 @@ /* - AMD: */ #define MSR_IA32_MBA_BW_BASE 0xc0000200 #define MSR_IA32_SMBA_BW_BASE 0xc0000280 +#define MSR_IA32_L3_QOS_EXT_CFG 0xc00003ff #define MSR_IA32_EVT_CFG_BASE 0xc0000400 =20 /* AMD-V MSRs */ diff --git a/arch/x86/kernel/cpu/resctrl/core.c b/arch/x86/kernel/cpu/resct= rl/core.c index cb7feb7c990f..3f847728aa7a 100644 --- a/arch/x86/kernel/cpu/resctrl/core.c +++ b/arch/x86/kernel/cpu/resctrl/core.c @@ -405,6 +405,11 @@ void rdt_ctrl_update(void *arg) hw_res->msr_update(m); } =20 +bool resctrl_arch_mbm_cntr_assign_enabled(struct rdt_resource *r) +{ + return resctrl_to_arch_res(r)->mbm_cntr_assign_enabled; +} + /* * rdt_find_domain - Search for a domain id in a resource domain list. * diff --git a/arch/x86/kernel/cpu/resctrl/internal.h b/arch/x86/kernel/cpu/r= esctrl/internal.h index 05358e78147b..ca69f2e0909f 100644 --- a/arch/x86/kernel/cpu/resctrl/internal.h +++ b/arch/x86/kernel/cpu/resctrl/internal.h @@ -56,6 +56,9 @@ /* Max event bits supported */ #define MAX_EVT_CONFIG_BITS GENMASK(6, 0) =20 +/* Setting bit 0 in L3_QOS_EXT_CFG enables the ABMC feature. */ +#define ABMC_ENABLE_BIT 0 + /** * cpumask_any_housekeeping() - Choose any CPU in @mask, preferring those = that * aren't marked nohz_full @@ -479,6 +482,7 @@ struct rdt_parse_data { * @mbm_cfg_mask: Bandwidth sources that can be tracked when Bandwidth * Monitoring Event Configuration (BMEC) is supported. * @cdp_enabled: CDP state of this resource + * @mbm_cntr_assign_enabled: ABMC feature is enabled * * Members of this structure are either private to the architecture * e.g. mbm_width, or accessed via helpers that provide abstraction. e.g. @@ -493,6 +497,7 @@ struct rdt_hw_resource { unsigned int mbm_width; unsigned int mbm_cfg_mask; bool cdp_enabled; + bool mbm_cntr_assign_enabled; }; =20 static inline struct rdt_hw_resource *resctrl_to_arch_res(struct rdt_resou= rce *r) @@ -658,4 +663,6 @@ void resctrl_file_fflags_init(const char *config, unsig= ned long fflags); void rdt_staged_configs_clear(void); bool closid_allocated(unsigned int closid); int resctrl_find_cleanest_closid(void); +int resctrl_arch_mbm_cntr_assign_set(struct rdt_resource *r, bool enable); +bool resctrl_arch_mbm_cntr_assign_enabled(struct rdt_resource *r); #endif /* _ASM_X86_RESCTRL_INTERNAL_H */ diff --git a/arch/x86/kernel/cpu/resctrl/monitor.c b/arch/x86/kernel/cpu/re= sctrl/monitor.c index c3d7d4c3009a..a7526306f5e4 100644 --- a/arch/x86/kernel/cpu/resctrl/monitor.c +++ b/arch/x86/kernel/cpu/resctrl/monitor.c @@ -1261,3 +1261,39 @@ void __init intel_rdt_mbm_apply_quirk(void) mbm_cf_rmidthreshold =3D mbm_cf_table[cf_index].rmidthreshold; mbm_cf =3D mbm_cf_table[cf_index].cf; } + +static void resctrl_abmc_set_one_amd(void *arg) +{ + bool *enable =3D arg; + + if (*enable) + msr_set_bit(MSR_IA32_L3_QOS_EXT_CFG, ABMC_ENABLE_BIT); + else + msr_clear_bit(MSR_IA32_L3_QOS_EXT_CFG, ABMC_ENABLE_BIT); +} + +/* + * Update L3_QOS_EXT_CFG MSR on all the CPUs associated with the monitor + * domain. + */ +static void _resctrl_abmc_enable(struct rdt_resource *r, bool enable) +{ + struct rdt_mon_domain *d; + + list_for_each_entry(d, &r->mon_domains, hdr.list) + on_each_cpu_mask(&d->hdr.cpu_mask, + resctrl_abmc_set_one_amd, &enable, 1); +} + +int resctrl_arch_mbm_cntr_assign_set(struct rdt_resource *r, bool enable) +{ + struct rdt_hw_resource *hw_res =3D resctrl_to_arch_res(r); + + if (r->mon.mbm_cntr_assignable && + hw_res->mbm_cntr_assign_enabled !=3D enable) { + _resctrl_abmc_enable(r, enable); + hw_res->mbm_cntr_assign_enabled =3D enable; + } + + return 0; +} --=20 2.34.1 From nobody Wed Feb 11 05:40:54 2026 Received: from NAM11-DM6-obe.outbound.protection.outlook.com (mail-dm6nam11on2082.outbound.protection.outlook.com [40.107.223.82]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 76F4721660E; Wed, 22 Jan 2025 20:21:51 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.223.82 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1737577313; cv=fail; b=hEisgGk8IdwDV9oJvdAkiJMqLJe4z74dpfdWO7Tda3wfLS1YI2R4ohEGbRX6I3EBSVSzy77IgaTTryB2PqzL/YTKe0D8+nbv8LOWfg9nbUrITDjPpgWaG1oVG0NVjgQTaVIeZmGyUed/j3/9ZuaRXInTXGb9BSH/jJSU1HwmWl8= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1737577313; c=relaxed/simple; bh=ceb9jGKKZa1HQiQRF3SyjVyf4xc/Dw03n42280Gc5js=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=ee7AuaObFgk7S4eC9qqHlII+ADuHhUwhz6WQr8IvNJ1xky46Fb0HVmHgs7bK1G+f+Qso1o2IQn3+9/a4K3/ihwzmXff1WhSOlpl70ifWRSALFPqEGN/OiLbKLdeYRQyyYPyHhiAjM3Aj26L4vpchSIRUvBQ/H6mweaXX9UryQxA= 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=KSQx9evn; arc=fail smtp.client-ip=40.107.223.82 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=amd.com Authentication-Results: smtp.subspace.kernel.org; spf=fail smtp.mailfrom=amd.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=amd.com header.i=@amd.com header.b="KSQx9evn" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=nVbx7dH6ar6xBLlEeFlQWXgrtWhe6KulsOToQOviMQXvYI1TQn7K0QVyOc6VOzNEeQmUX00xscGPUwNlW5imNO5YmolZn0qhcbOxtvZIRIMNTHlJ0L5CNx9UsLHBxXhIR7HTHs3leE831gKMsnx0YOhLhsziMMnI99DnK6Gg0VF461q4tHoqqHIh+27Gj260aOlbVKsP/UmCojSkmQA1MznKfVEv0SlMVxtRQv/99yGLdGt9/4jJY9MnYdsyWT/ZqqhEhdjP3tpYaXaUFU2ACdZgDAPgkRscQ485eoP+/8dhB6HYcF+B+O4bsyw7PBYCOSX0v6NHYJxCQJ2xdWrRPQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=n/DVGkCOU6FmltBb4sux5IQxF4FsDAW9MweRnNk/HB0=; b=JIglGqWS3XuRu57d8NgCh9qUvspF/UWV+3aUnETyrukL/QGMBd3mQ8wWPVSk6q94FbVAxRNBf/Dd2IdCGAzi9fwMFvYH+FwMpMRJcFpvqCtdHv1zs0zDAg3a35EZfCnRln2Y3bi95zApzRp4aiO+4IBX2CMcKpFoD8FJkTaZxj8wTk1KEWk8JHXo8iWdZ5pF6UjkK90kyZ1w7xnZay0rfLqGY2AmzzpR6B8AWdymzihLdv7y+o5hQxi3IlKOVkuJdbtWsHkEuJrzKyxHD8lBCFEOR9tEqCyGuqVaAACjrkU8cJp1OOdHW7WAnxe6RJy7Q/d2ScJLYr4oEWrYXbjbdg== 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=n/DVGkCOU6FmltBb4sux5IQxF4FsDAW9MweRnNk/HB0=; b=KSQx9evniqayk9xG5BqzPKWm84XKxznjB3bi+1BZSzNDERc+YgHwVg/bJF0DHqSASfc8n+P1Tq/SyvpClPsCASjyl84MLU5wsVft8fynv7XIqmU1WIV2hKBWUxqWYu9j2B7hLKIpk2rMlhrTIT2eSRwzh4j2C4KOLulyGEoNO3k= Received: from CH2PR15CA0023.namprd15.prod.outlook.com (2603:10b6:610:51::33) by SJ1PR12MB6026.namprd12.prod.outlook.com (2603:10b6:a03:48b::21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8377.17; Wed, 22 Jan 2025 20:21:45 +0000 Received: from CH1PEPF0000A349.namprd04.prod.outlook.com (2603:10b6:610:51:cafe::df) by CH2PR15CA0023.outlook.office365.com (2603:10b6:610:51::33) with Microsoft SMTP Server (version=TLS1_3, cipher=TLS_AES_256_GCM_SHA384) id 15.20.8377.14 via Frontend Transport; Wed, 22 Jan 2025 20:21:45 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 165.204.84.17) smtp.mailfrom=amd.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=amd.com; Received-SPF: Pass (protection.outlook.com: domain of amd.com designates 165.204.84.17 as permitted sender) receiver=protection.outlook.com; client-ip=165.204.84.17; helo=SATLEXMB04.amd.com; pr=C Received: from SATLEXMB04.amd.com (165.204.84.17) by CH1PEPF0000A349.mail.protection.outlook.com (10.167.244.9) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.8377.8 via Frontend Transport; Wed, 22 Jan 2025 20:21:45 +0000 Received: from bmoger-ubuntu.amd.com (10.180.168.240) by SATLEXMB04.amd.com (10.181.40.145) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.39; Wed, 22 Jan 2025 14:21:43 -0600 From: Babu Moger To: , , , , , , , CC: , , , , , , , , , , , , , , , , , , , , , , , , , , Subject: [PATCH v11 07/23] x86/resctrl: Introduce the interface to display monitor mode Date: Wed, 22 Jan 2025 14:20:15 -0600 Message-ID: X-Mailer: git-send-email 2.34.1 In-Reply-To: References: Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-ClientProxiedBy: SATLEXMB04.amd.com (10.181.40.145) To SATLEXMB04.amd.com (10.181.40.145) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CH1PEPF0000A349:EE_|SJ1PR12MB6026:EE_ X-MS-Office365-Filtering-Correlation-Id: 79f29242-0b11-4f0d-ab61-08dd3b226460 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|376014|1800799024|7416014|36860700013|82310400026; X-Microsoft-Antispam-Message-Info: =?us-ascii?Q?TXjge5SfGErpvxBoq7CcS3tBoDp2qSy12xVYNwWyimgEyod7mGO1w1uRNyGy?= =?us-ascii?Q?juGzhvhCoSHQZOGm4tR0c9fxvUqUQzSgJzRYUv16AZv9+ldSzLxLXNTtO0Ou?= =?us-ascii?Q?xYzwvxY4ybnZ5dKR/daCBxe4lhq9SsHH7C1/5jOq/Vufcdxfore3rSKam8oH?= =?us-ascii?Q?IJkLF2qNVD5pAf6h8MH7GYJaThQ9HLs3guCjt8+pZBU8sr231DptHxXb2LbS?= =?us-ascii?Q?lRCgDTxcg/NKaSM4VsZxVZDIJTWAH/5dxkcoIrzT50AMJF6Lpp/nmv/paaHs?= =?us-ascii?Q?aUydtSVJrSeSM/syBdrD8P+DXkJ+kkevvjc6Oa2eUgS3CS7JqDmuUEHmzt1Q?= =?us-ascii?Q?sh08d5j6DhzVnRgR9Zk4Y00TlfCyzXEcS0mKLNzmwN6SgT6+fKC3CgKVJJ4l?= =?us-ascii?Q?SU3Z63IVSF8LDLoY3bdTrw0RgGZm5zeYg8K6QJpEYKtMuTyhNA5czNnn8tVk?= =?us-ascii?Q?FE0Lb1+ZO6eJT79bZj8MWWbae1dOx1X1uqE1n25i8gNGBzFNJLi0e4HDa9PZ?= =?us-ascii?Q?YKP663dF8VsYWkq+KspkUBx1pQ5XkKVnz/ecnXxqsAfm+UVxAGhr2IyaWViP?= =?us-ascii?Q?Hstn0OgaT4qv5XUpxpxGfeYbm3SOMnZzfqVuCJ2q2IIDzcZaCRjzCPHeJBLW?= =?us-ascii?Q?9G97e17yBGrmsbubjwjqhTa2b+sc1qCxyR0Vk+PYYTl/jdK6jt/sUa6Ysah2?= =?us-ascii?Q?RQLMWetjpk9j3YqD7HvrLGLTe3ivX8dGTXQ4K0Dm4u1ZeF3x8Bl/h4BOOhMa?= =?us-ascii?Q?5VHbWKDDESTWgv1fXrkUEvSFrr47acfugHLd4/vDCTj0EFd8k2deg0JD2HY1?= =?us-ascii?Q?qO2uwNM3503FRXwowkJVQOJP0u1v1jVAnxnBlT2CWL1b6a8+6Ys1pApWeN4O?= =?us-ascii?Q?arr+E2iG55ijJx1l05H+RX0DetuQR5RqNMbKHacc/usSo9qAodiBnTVfTenB?= =?us-ascii?Q?6Y3Y2ZSbULth/9DZiwT0EyMG3oW/+YERX8sksA4zR7ukStIoV+prc15H73gY?= =?us-ascii?Q?owMVJOLMzk6Dd2XinmpKrmNwELhZXdeOUEw9YWAjsMEEZyze52b0n4tZDGDK?= =?us-ascii?Q?8JSRvovm+f4F6/CB2LlUXCAJnGDbLzHsiXq52/SzlOnKFTR1+cfegJmAkkjw?= =?us-ascii?Q?2etne2+OSOM6D7ns4WW8NHMeqTIECa7b3a9Dly00yPOr6XjF0d9runQmcGp+?= =?us-ascii?Q?FZ/7tFj2sH2/9Q8E2IoTcikO4vdFCG0W/FqgNxJuWitYQ8hVTMXd8xTphIS2?= =?us-ascii?Q?WZ94iQ13dotXGnTNBbPL7XyAZOi03gTAWJ9ZFOwjkA+FjVfvY+LkZJg1IDmL?= =?us-ascii?Q?96iUJ4BuEhsRTp6fvH087vS2KY3LfM07uNx2w8a3GGcyR6CAiqwUWKtVKdNI?= =?us-ascii?Q?Ac/r2VjJGjnQnyyMJ0VXPaWfJHZV3vDpbR8h5929SuxdNT48jcTos3mF/uu9?= =?us-ascii?Q?8P7h0Wux2oERy5agxgE68B/zlC9fqKO5TyME7yzCBKRHxUhpa4IaHVrYRIWg?= =?us-ascii?Q?J33IhXg4ioaAOWs=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)(1800799024)(7416014)(36860700013)(82310400026);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 22 Jan 2025 20:21:45.4524 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 79f29242-0b11-4f0d-ab61-08dd3b226460 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: CH1PEPF0000A349.namprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: SJ1PR12MB6026 Content-Type: text/plain; charset="utf-8" Introduce the interface file "mbm_assign_mode" to list monitor modes supported. The "mbm_cntr_assign" mode provides the option to assign a counter to an RMID, event pair and monitor the bandwidth as long as it is assigned. On AMD systems "mbm_cntr_assign" is backed by the ABMC (Assignable Bandwidth Monitoring Counters) hardware feature and is enabled by default. The "default" mode is the existing monitoring mode that works without the explicit counter assignment, instead relying on dynamic counter assignment by hardware that may result in hardware not dedicating a counter resulting in monitoring data reads returning "Unavailable". Provide an interface to display the monitor mode on the system. $ cat /sys/fs/resctrl/info/L3_MON/mbm_assign_mode [mbm_cntr_assign] default Signed-off-by: Babu Moger --- v11: Renamed rdtgroup_mbm_assign_mode_show() to resctrl_mbm_assign_mode_sho= w(). Removed few texts in resctrl.rst about AMD specific informati0n. Updated few texts. v10: Added few more text to user documentation clarify on the default mode. v9: Updated user documentation based on comments. v8: Commit message update. v7: Updated the descriptions/commit log in resctrl.rst to generic text. Thanks to James and Reinette. Rename mbm_mode to mbm_assign_mode. Introduced mutex lock in rdtgroup_mbm_mode_show(). v6: Added documentation for mbm_cntr_assign and legacy mode. Moved mbm_mode fflags initialization to static initialization. v5: Changed interface name to mbm_mode. It will be always available even if ABMC feature is not supported. Added description in resctrl.rst about ABMC mode. Fixed display abmc and legacy consistantly. v4: Fixed the checks for legacy and abmc mode. Default it ABMC. v3: New patch to display ABMC capability. --- Documentation/arch/x86/resctrl.rst | 26 +++++++++++++++++++++ arch/x86/kernel/cpu/resctrl/rdtgroup.c | 31 ++++++++++++++++++++++++++ 2 files changed, 57 insertions(+) diff --git a/Documentation/arch/x86/resctrl.rst b/Documentation/arch/x86/re= sctrl.rst index fb90f08e564e..b5defc5bce0e 100644 --- a/Documentation/arch/x86/resctrl.rst +++ b/Documentation/arch/x86/resctrl.rst @@ -257,6 +257,32 @@ with the following files: # cat /sys/fs/resctrl/info/L3_MON/mbm_local_bytes_config 0=3D0x30;1=3D0x30;3=3D0x15;4=3D0x15 =20 +"mbm_assign_mode": + Reports the list of monitoring modes supported. The enclosed brackets + indicate which mode is enabled. + :: + + # cat /sys/fs/resctrl/info/L3_MON/mbm_assign_mode + [mbm_cntr_assign] + default + + "mbm_cntr_assign": + + In mbm_cntr_assign, monitoring event can only accumulate data while + it is backed by a hardware counter. The user-space is able to specify + which of the events in CTRL_MON or MON groups should have a counter + assigned using the "mbm_assign_control" file. The number of counters + available is described in the "num_mbm_cntrs" file. Changing the mode + may cause all counters on a resource to reset. + + "default": + + In default mode, resctrl assumes there is a hardware counter for each + event within every CTRL_MON and MON group. On AMD platforms, it is + recommended to use mbm_cntr_assign mode if supported, because reading + "mbm_total_bytes" or "mbm_local_bytes" will report 'Unavailable' if + there is no counter associated with that event. + "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 f91fe605766f..3880480a41d2 100644 --- a/arch/x86/kernel/cpu/resctrl/rdtgroup.c +++ b/arch/x86/kernel/cpu/resctrl/rdtgroup.c @@ -854,6 +854,30 @@ static int rdtgroup_rmid_show(struct kernfs_open_file = *of, return ret; } =20 +static int resctrl_mbm_assign_mode_show(struct kernfs_open_file *of, + struct seq_file *s, void *v) +{ + struct rdt_resource *r =3D of->kn->parent->priv; + + mutex_lock(&rdtgroup_mutex); + + if (r->mon.mbm_cntr_assignable) { + if (resctrl_arch_mbm_cntr_assign_enabled(r)) { + seq_puts(s, "[mbm_cntr_assign]\n"); + seq_puts(s, "default\n"); + } else { + seq_puts(s, "mbm_cntr_assign\n"); + seq_puts(s, "[default]\n"); + } + } else { + seq_puts(s, "[default]\n"); + } + + mutex_unlock(&rdtgroup_mutex); + + return 0; +} + #ifdef CONFIG_PROC_CPU_RESCTRL =20 /* @@ -1910,6 +1934,13 @@ static struct rftype res_common_files[] =3D { .seq_show =3D mbm_local_bytes_config_show, .write =3D mbm_local_bytes_config_write, }, + { + .name =3D "mbm_assign_mode", + .mode =3D 0444, + .kf_ops =3D &rdtgroup_kf_single_ops, + .seq_show =3D resctrl_mbm_assign_mode_show, + .fflags =3D RFTYPE_MON_INFO, + }, { .name =3D "cpus", .mode =3D 0644, --=20 2.34.1 From nobody Wed Feb 11 05:40:54 2026 Received: from NAM04-MW2-obe.outbound.protection.outlook.com (mail-mw2nam04on2076.outbound.protection.outlook.com [40.107.101.76]) (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 74914214239; Wed, 22 Jan 2025 20:21:59 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.101.76 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1737577322; cv=fail; b=WdH69qhtAh0FMHV/PovzXafpt/VcBSg88O9YkEORXjyUfGmFHetX90wg7vdtDRETn2KGUSl8RKwjKac+ta5mD5inoH0KjvNPrpnu+KcmBD/sQyVBUNNDFKwWc26N6KhBOO2Xg7pme3fPOJab+fTTpeg0s9wktF26e8Yrh9AfFpg= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1737577322; c=relaxed/simple; bh=aWdLgCCYmu12eFzU1iUT5VmYloffErGCyd6aD7Rq6U4=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=QRlIudaoETbSBkPOeqIpXGyKCSPVT4/QJGbVgO3+sHVtavOexAbMJdEWOMifoYWubOaOwZxUPwTk+M62ThxeCn3rEkuaLRXWmhCprAJ1JdQZiShlq3dXIYGC5tXHiHpW0B7qvBm6ZI5sqFu14G/2nOI/vU/y0DFmMUQGRnqSWlE= 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=ebc7ALTG; arc=fail smtp.client-ip=40.107.101.76 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="ebc7ALTG" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=Ttjs6+xE3lfmqmHP9qU+uJmoLwP441eyTgmjkXn2Fq4PU4nTz9GyIhg6SRrlPrVGiGgnIh7m0al5j38mc0Hd3CPh5DD/THgPT5pTL8grM0VQH2Q+XBIjXnNW5V0dM1oBqUaFfS83tNsSZ3rs/TpPJDGt8SJvBSjZiKSyM+dLMnrjT46etfjT6oQdPzkwxX4mJozXr7/4b2DfpBqcpB2JVTjwqB5nzLRjG2/v4ltOyU1tpgK9kf0GxkZjWQDEWzGHBVE30j6zR3Cqcv1iq7YeTmFAujtCmccObG6N0oMa+sfV0mj10bHTeHGh1OpokrJymsPaN/834dDFeEFLaFAAYg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=bBMoDuCGL2klLlJllsOfPD2mA/hNLZ0Er0dFNMcBduk=; b=MhFkjkR8BNmZB5pZJUpLe9aHMxJjFRWdgJMomDeRo3lNfSukXp6itFX9wThglKq3FG7ScbPkBoyJzaw26tpCthSDBI109bGMJihoRlBwT1tVwdKxhAiYUCHM1fmSlOg4L8HtmNVUVvhY8VAM2SApbshIxsyNfiSvLJV1SMBtSQv2q9AQh/DXwKMSp53fldQRnExD7ffl/GgzPe8XTRSDlHh5w2UBmRT78TwxOjnJ1ZkqyXWiaQsmAeOWsRR1Az6VfCKAhuAnEgyqRRgadlP9s6mTmRDir8HuhKscCdJML6VK+G4QEqbOjbZw2BWVvMofgNUeKko4X1swBOM/yqQjeg== 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=bBMoDuCGL2klLlJllsOfPD2mA/hNLZ0Er0dFNMcBduk=; b=ebc7ALTGmezxIalc8Krc8wvx0WP1B1L22Zh3tHASr0mMETp3CDDy/FWO0JNkmsarjf+qyJRELtYTNC/MCa8PVtyL5H6vVOV9n7P+PH7qTcFG0Xl7mayuF42kOx79uBkOE1Dt7VNzzGZ3qWP8+uUnViidlJLRU0Z2vWC8EG6MOwM= Received: from CH0PR03CA0420.namprd03.prod.outlook.com (2603:10b6:610:11b::25) by PH8PR12MB7182.namprd12.prod.outlook.com (2603:10b6:510:229::21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8356.21; Wed, 22 Jan 2025 20:21:54 +0000 Received: from CH1PEPF0000A348.namprd04.prod.outlook.com (2603:10b6:610:11b:cafe::4c) by CH0PR03CA0420.outlook.office365.com (2603:10b6:610:11b::25) with Microsoft SMTP Server (version=TLS1_3, cipher=TLS_AES_256_GCM_SHA384) id 15.20.8377.14 via Frontend Transport; Wed, 22 Jan 2025 20:21:53 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 165.204.84.17) smtp.mailfrom=amd.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=amd.com; Received-SPF: Pass (protection.outlook.com: domain of amd.com designates 165.204.84.17 as permitted sender) receiver=protection.outlook.com; client-ip=165.204.84.17; helo=SATLEXMB04.amd.com; pr=C Received: from SATLEXMB04.amd.com (165.204.84.17) by CH1PEPF0000A348.mail.protection.outlook.com (10.167.244.4) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.8377.8 via Frontend Transport; Wed, 22 Jan 2025 20:21:53 +0000 Received: from bmoger-ubuntu.amd.com (10.180.168.240) by SATLEXMB04.amd.com (10.181.40.145) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.39; Wed, 22 Jan 2025 14:21:51 -0600 From: Babu Moger To: , , , , , , , CC: , , , , , , , , , , , , , , , , , , , , , , , , , , Subject: [PATCH v11 08/23] x86/resctrl: Introduce interface to display number of monitoring counters Date: Wed, 22 Jan 2025 14:20:16 -0600 Message-ID: <80457612b98078bd7786c73f83775e4de86c699e.1737577229.git.babu.moger@amd.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: References: Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-ClientProxiedBy: SATLEXMB04.amd.com (10.181.40.145) To SATLEXMB04.amd.com (10.181.40.145) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CH1PEPF0000A348:EE_|PH8PR12MB7182:EE_ X-MS-Office365-Filtering-Correlation-Id: 13146f76-db35-40d9-feb9-08dd3b226916 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|7416014|82310400026|376014|36860700013|1800799024; X-Microsoft-Antispam-Message-Info: =?us-ascii?Q?/JnuRsKxkBpNLUh7EKY3hD4j0RY/q6tWi/CWqaaj8uBVST+jjkHiBfy/ceMQ?= =?us-ascii?Q?uWVy7OebVloX42vk0HnSIhfXQF6Z/f+KLPBRTWyotyveD9CYJpv79RwN62Pe?= =?us-ascii?Q?EPBHCyKYhBY5BaxNF4CO2jR+aE4leekO74YXEK71jHrN/vB897eZZhGNrEbG?= =?us-ascii?Q?uHGvwBCouRduLKfOW5gpI18I3zK8yyPwjtKLwPCOkVVjbQr/tvpNRMsSyYNf?= =?us-ascii?Q?CWJMfv9PX7nAR4t8EqeXRlfskbDxbd+0FPed7GAIFpdBeoxf2rTEEuMg+mrL?= =?us-ascii?Q?nYGhx6aHQyKjK2TMO/cLUf/nCPzm2vk0Z6Xiub8rJBOFirKS2sgBrQYspL+n?= =?us-ascii?Q?CY0M5pmBhkY+x2wg0TeqSewf46BIt1Rygcc/ChRCnWFqnwtnfau5ivK0Nmwv?= =?us-ascii?Q?dWvWI1T4rb3Esvi3udvsxoL8RQeAOrm4XdaOyjiIG3xeus0uy222bdZCIRXw?= =?us-ascii?Q?+OvJs/UEsjf0oUFpbPibD23CIDYf67gWWB74wA8unHZggfkkGMZUW+LyLRaj?= =?us-ascii?Q?Z0HmPaTKkoVqhkBUAwnUoQSi581MQZKf3UjC6+upNulHsCsefRWijfUB2MkV?= =?us-ascii?Q?deL0nfEclfJuC3N/E7h/W7kK/m+0I9L2UrQ0h6Ei4BORdcMhHKJfptiIlCN8?= =?us-ascii?Q?uDdGGIZiaddNJGvoEHNOU5TzPWyZxE/VziUw7Q9SO0VhhBHs925Wvh2a/ejK?= =?us-ascii?Q?xIUI8Ce3qhBG2O634ewcfGD19k2FMawcXk+GVZeDdG50gruzJJ1PkkpjeFpU?= =?us-ascii?Q?LwGDajN5HBBwcv4rGA+YKQzlq4H56Kld4q20N8MGl/0aSTVshNGsTKcHr6yS?= =?us-ascii?Q?Jkn4i3dyuRKbQEBshwEqno6POWZy/zANbMYlgvjp5gGM8NQH1OhVLZY5wuMi?= =?us-ascii?Q?8NCkrw0zgaHzGUir5Hzd79FrG0nt+HGCIwtm1Hv4m/TgmswGCNHY8CfQ67SM?= =?us-ascii?Q?GNVZ9v9/m6hnYuD1GlLumHvz8CQv6Z0eTntVSUxFCh0nQD9X2ga4Q8Q2pztT?= =?us-ascii?Q?a5KL6g+u8Z1s7Daypcde+w66gs0hE8t4snJW5W/4jzeRL6O0jGEjKFGR6EK2?= =?us-ascii?Q?Rs1M2bITuFxHUEvxja7IZqzyILY8EGVmRBFpJsb2BwlpWbAD4VL934DM9+mI?= =?us-ascii?Q?YdTN6t7DCFEH3Bs/peyfc/i0Zf1TVmZIlqGTM7eGN5m0KxPCAJsKz2idJJbF?= =?us-ascii?Q?Jt4/Rz7e7mjCtINtaGL5bqHG5B42598G8M4OLHLWsbrOG8DCilH9qZBxcz0C?= =?us-ascii?Q?Suyv/2jCoKFy3d13ijPVNRc+wNBs4ZFFddtplNiLbY+e+u++rPVxjGJhpxw2?= =?us-ascii?Q?MUR1eu6f7j7McYV4vS3pbf3NsAFTAKJdj0Pn/bmiKRNHp/4Q1CZZTjtBOJR2?= =?us-ascii?Q?gVQzCIidGZcfVdVrc8vLeis0flJQPLNJ7E5odDhogvDqaI2xQ4b51QRaFzcf?= =?us-ascii?Q?ijRFLiKlXS4XZRzPwi3UIiQgZeIxD5heaSqcz1UUl+1vsRon8hrgHdyYK5v7?= =?us-ascii?Q?xneJrCVwNci5jP4=3D?= X-Forefront-Antispam-Report: CIP:165.204.84.17;CTRY:US;LANG:en;SCL:1;SRV:;IPV:CAL;SFV:NSPM;H:SATLEXMB04.amd.com;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(13230040)(7416014)(82310400026)(376014)(36860700013)(1800799024);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 22 Jan 2025 20:21:53.3738 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 13146f76-db35-40d9-feb9-08dd3b226916 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: CH1PEPF0000A348.namprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH8PR12MB7182 Content-Type: text/plain; charset="utf-8" The mbm_cntr_assign mode provides an option to the user to assign a counter to an RMID, event pair and monitor the bandwidth as long as the counter is assigned. Number of assignments depend on number of monitoring counters available. Provide the interface to display the number of monitoring counters supported. The resctrl file 'num_mbm_cntrs' is visible to user space when the system supports mbm_cntr_assign mode. Signed-off-by: Babu Moger --- v11: Renamed rdtgroup_num_mbm_cntrs_show() to resctrl_num_mbm_cntrs_show(). Few monor text updates. v10: No changes. v9: Updated user document based on the comments. Will add a new file available_mbm_cntrs later in the series. v8: Commit message update and documentation update. v7: Minor commit log text changes. v6: No changes. v5: Changed the display name from num_cntrs to num_mbm_cntrs. Updated the commit message. Moved the patch after mbm_mode is introduced. v4: Changed the counter name to num_cntrs. And few text changes. v3: Changed the field name to mbm_assign_cntrs. v2: Changed the field name to mbm_assignable_counters from abmc_counter. --- Documentation/arch/x86/resctrl.rst | 16 ++++++++++++++++ arch/x86/kernel/cpu/resctrl/monitor.c | 1 + arch/x86/kernel/cpu/resctrl/rdtgroup.c | 16 ++++++++++++++++ 3 files changed, 33 insertions(+) diff --git a/Documentation/arch/x86/resctrl.rst b/Documentation/arch/x86/re= sctrl.rst index b5defc5bce0e..31ff764deeeb 100644 --- a/Documentation/arch/x86/resctrl.rst +++ b/Documentation/arch/x86/resctrl.rst @@ -283,6 +283,22 @@ with the following files: "mbm_total_bytes" or "mbm_local_bytes" will report 'Unavailable' if there is no counter associated with that event. =20 +"num_mbm_cntrs": + The number of monitoring counters available for assignment when the + system supports mbm_cntr_assign mode. + :: + + # cat /sys/fs/resctrl/info/L3_MON/num_mbm_cntrs + 32 + + The resctrl file system supports tracking up to two memory bandwidth + events per monitoring group: mbm_total_bytes and/or mbm_local_bytes. + Up to two counters can be assigned per monitoring group, one for each + memory bandwidth event. More monitoring groups can be tracked by + assigning one counter per monitoring group. However, doing so limits + memory bandwidth tracking to a single memory bandwidth event per + monitoring 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 a7526306f5e4..5f87fc1650e5 100644 --- a/arch/x86/kernel/cpu/resctrl/monitor.c +++ b/arch/x86/kernel/cpu/resctrl/monitor.c @@ -1233,6 +1233,7 @@ int __init rdt_get_mon_l3_config(struct rdt_resource = *r) r->mon.mbm_cntr_assignable =3D true; cpuid_count(0x80000020, 5, &eax, &ebx, &ecx, &edx); r->mon.num_mbm_cntrs =3D (ebx & GENMASK(15, 0)) + 1; + 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 3880480a41d2..9b09189ef2d1 100644 --- a/arch/x86/kernel/cpu/resctrl/rdtgroup.c +++ b/arch/x86/kernel/cpu/resctrl/rdtgroup.c @@ -878,6 +878,16 @@ static int resctrl_mbm_assign_mode_show(struct kernfs_= open_file *of, return 0; } =20 +static int resctrl_num_mbm_cntrs_show(struct kernfs_open_file *of, + struct seq_file *s, void *v) +{ + struct rdt_resource *r =3D of->kn->parent->priv; + + seq_printf(s, "%d\n", r->mon.num_mbm_cntrs); + + return 0; +} + #ifdef CONFIG_PROC_CPU_RESCTRL =20 /* @@ -1941,6 +1951,12 @@ static struct rftype res_common_files[] =3D { .seq_show =3D resctrl_mbm_assign_mode_show, .fflags =3D RFTYPE_MON_INFO, }, + { + .name =3D "num_mbm_cntrs", + .mode =3D 0444, + .kf_ops =3D &rdtgroup_kf_single_ops, + .seq_show =3D resctrl_num_mbm_cntrs_show, + }, { .name =3D "cpus", .mode =3D 0644, --=20 2.34.1 From nobody Wed Feb 11 05:40:54 2026 Received: from NAM11-BN8-obe.outbound.protection.outlook.com (mail-bn8nam11on2058.outbound.protection.outlook.com [40.107.236.58]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 6B2002163A1; Wed, 22 Jan 2025 20:22:05 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.236.58 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1737577328; cv=fail; b=ciRBeKdbA+uMNZ+O6Uf62Ip9rluIkmxOYul+nxpDK7SJcH9cXphGyfJOzLGsqMmjjIzlf/Fi6BFNHGz13kazZHg7sxLjR8/MGgxc21fxK3GgqQ1XFX0c1rfbuwmZnofJFJz6IK9UArT9akMCqLyt/dQCwYkqJRsbBmg5VMTewJc= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1737577328; c=relaxed/simple; bh=724yg2XsMzM6EMneWPBrPxlFGp5g7lpDz1O8r+7qkVQ=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=qp7KBwDoKKJJyl9Ce4Shgl8+7NHGWLNkDAKSsPefJfU3K4y4aNtGReDjeJzuczdE0y143sCuVFYPiJHGsAjgPkoWAolm5narMamBgQFGcqK2W+Nsg9GgPbGSk9DFtzvH6ENymn3XQsUUXq9usuHu2wRr1hVMltfnWZxfOZEniTE= 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=zUZ+AcNc; arc=fail smtp.client-ip=40.107.236.58 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=amd.com Authentication-Results: smtp.subspace.kernel.org; spf=fail smtp.mailfrom=amd.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=amd.com header.i=@amd.com header.b="zUZ+AcNc" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=xIoQgt2EAx4FwvnYlOHuK7w88+wbrLPqsDlMgEEKyS1+KjlpF3FYLlCpFYbxQ8/hJQoKjIqv5fWgB5LlrsI8M0Wa06cfZxRZU2HdjN/zo1hciQwrC6BkXRd1wAbmKTAF7wc+AwH8AzlxRfPZlf8WGdyRjxY4pFupxUb5Tjrf+u3s4/ySo3Jp4GbAmDqV9cFgCxPAizPuzqbfVd7mTqDoGhbSuAyWoRgxSS1yRgwKlXgZge5GhBUrAv56/rXwGZqrPOrN8uIVosQD4fA4QHJErXNWIL+B/FE8MKelj7bHpf12uViFdtamDkGxgtXBooTgsdccuKstPncE55JIfEzofg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=kdWChno04F0RlkEkDzPMHdgjpXF4ECHactTNUuV9+UY=; b=ZKwTBKNSZaDl77C9slcfTXmcwQkHqjLfE/n3gkDes1uRPGlTzKHW0z15y/Q6QMwjyYBEj174WSMAEAB98ZGSLDm5Wpz2ANZoSB18/tnqOnL6gbszzdnNSjjNJ8GP+TZ5toZxPq7u46RedUibaEJBrM6HCA7+UYQQNtIhPrTyFi47/l4PiTAuILlpgpPQrzKlf2aMV4T9vqgyiITFFX88iphHz3/yScT+HwVR8FKqGOrqL1i3wgO9Y43bypC5hSvLPHLyRczUnR/uC6sW3vs+Q4ffaTQrC6yMTiaa4rXOjsjm7YjDdMf2f1lcGxH0PuIeZNu0vRsX+vps/f8Rqf2wkQ== 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=kdWChno04F0RlkEkDzPMHdgjpXF4ECHactTNUuV9+UY=; b=zUZ+AcNcSmu9PVu7GBj5ktVkv9uY7A5zl/X2PU+jE4d8QVIrp1qi4XhuITw2/K4qVE6NAGoxBhXWm+C4WukQw87dXt6aXDJ3AKNVH1W9f/t2eYS77GN4iMbgmj/rB42G6cqtByKgF0e6RwivWiwUZ5v+aQiuZuW2KtqCMRlXj2I= Received: from CH2PR12CA0015.namprd12.prod.outlook.com (2603:10b6:610:57::25) by MN2PR12MB4160.namprd12.prod.outlook.com (2603:10b6:208:19a::19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8377.17; Wed, 22 Jan 2025 20:22:01 +0000 Received: from CH1PEPF0000A346.namprd04.prod.outlook.com (2603:10b6:610:57:cafe::6b) by CH2PR12CA0015.outlook.office365.com (2603:10b6:610:57::25) with Microsoft SMTP Server (version=TLS1_3, cipher=TLS_AES_256_GCM_SHA384) id 15.20.8356.22 via Frontend Transport; Wed, 22 Jan 2025 20:22:01 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 165.204.84.17) smtp.mailfrom=amd.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=amd.com; Received-SPF: Pass (protection.outlook.com: domain of amd.com designates 165.204.84.17 as permitted sender) receiver=protection.outlook.com; client-ip=165.204.84.17; helo=SATLEXMB04.amd.com; pr=C Received: from SATLEXMB04.amd.com (165.204.84.17) by CH1PEPF0000A346.mail.protection.outlook.com (10.167.244.11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.8377.8 via Frontend Transport; Wed, 22 Jan 2025 20:22:01 +0000 Received: from bmoger-ubuntu.amd.com (10.180.168.240) by SATLEXMB04.amd.com (10.181.40.145) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.39; Wed, 22 Jan 2025 14:21:59 -0600 From: Babu Moger To: , , , , , , , CC: , , , , , , , , , , , , , , , , , , , , , , , , , , Subject: [PATCH v11 09/23] x86/resctrl: Introduce mbm_total_cfg and mbm_local_cfg in struct rdt_hw_mon_domain Date: Wed, 22 Jan 2025 14:20:17 -0600 Message-ID: <6b62d3fbf5d0e96038ece3be5c2d4b6da79b621f.1737577229.git.babu.moger@amd.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: References: Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-ClientProxiedBy: SATLEXMB04.amd.com (10.181.40.145) To SATLEXMB04.amd.com (10.181.40.145) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CH1PEPF0000A346:EE_|MN2PR12MB4160:EE_ X-MS-Office365-Filtering-Correlation-Id: 878a85b4-b27d-4c44-ca79-08dd3b226de5 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?e0YL5FhOTXBeiZpShRMNBxI+JntI3QGzAKbOHayKbGwtdMHnuAG7L3HdvZuM?= =?us-ascii?Q?3RqWZ5GHcuASeGzXt85ddmrTktKpncea0B7u2VxpeUF8yJYpe7ybiQui3kh4?= =?us-ascii?Q?SnV2MP8LAWsnRb6JmKLVVJwictLtZzaPLKKpUv3ZpJH6rFo3EClvtyilxG0t?= =?us-ascii?Q?yCMlYe0SfqQeactymid4jTSgVlzBoFIIszTy5IkQbjiRxRfhP87lzF2yIJMd?= =?us-ascii?Q?ak1ePyfpLkB5s8zSHF12/Gx0EsdHty7uh8RZCm6TrKxJfWlpOU+VXuxcWq6i?= =?us-ascii?Q?KjavgVsWwDMaOUy8aHM5/f3BR9NJL2Ea6YExtfXKDe0kvIKgbLgirf3b5smu?= =?us-ascii?Q?xz1P2G0zHWCepXjXrL+FTvzmt0eUe9mMoIuzUXTZV6pY5VS8J9wwETQn6tuF?= =?us-ascii?Q?fNMLY5Zx1UBuTjQvOWb8ZBTwfcR7AyzAw5CAzJpNQGpnDO3vJYl+Hj59uAKl?= =?us-ascii?Q?b691LSGv+2uVU59LBQcRlIQ1mVRuURO+Xwrkw0rMmnVuqUAUZwrwhQI0Laba?= =?us-ascii?Q?jcBTaGnY+XVdMDOnx28k19hNWD7HOpTw3qykFl7dL7Gcytc1tG1TkRgGxqxN?= =?us-ascii?Q?aXFCKhHJYQmJoDir4XAs6G3ycXVi3+3C5EDwDhb1cda0tXlVHYdOX/qYZi4T?= =?us-ascii?Q?Hryede9X90jMbRaf2RfQ5xBxy3NXQIYZYdMaIK+8AwVomgPsIuWEzkp0uEgE?= =?us-ascii?Q?FXiK8ZmeeNFKhjuQNhTwO2nuShCucpjtn3jMpkolpgTnvs9LFI0zbt51VPZf?= =?us-ascii?Q?Y0xdQTX+GxItiN+ZE4RpFD8xSImiKkfzbZg/hO/pcLV+sgQHKm7kha4g3Yg9?= =?us-ascii?Q?P2jbErQ5AaJYqL/Sb69OE1dV0NahmkTGWgDl/jReGbb7/VOQxtyQMc5LLtL9?= =?us-ascii?Q?Pirho0Xkk42NHcllzlrNJxpcJkAS1qphdLfEbRvOWjnfftzLA7z8ZGIp1O9n?= =?us-ascii?Q?td7nPpeJ9c7sVynr6ehKX/hb2j4E1JaU6LAEG7bZQ4Z3zQTuxMGmzWHYfcMx?= =?us-ascii?Q?sujMmnYE6szCWfU7yMYgMrOxZpOCUksVfXc8bzrmUDTDtSnl3uFrAR0KHLEu?= =?us-ascii?Q?Dfoe0Hdtm0frd+UdqFCq7ofvw5SxWIu5SULeeHw3Lx0GzyQy+YG5H1sUoZI/?= =?us-ascii?Q?Z5oaTshNRM4+HGyDJB7YUm2ml8EP90+DqHKMUzJHB0Kk9AWJgtjlhmQ23gcg?= =?us-ascii?Q?HBoXv06zttMOjFxg6PzQmAyLKMB0Y0mo1x7AJSx0FY8qd5eZ787Dz6ZQIvEM?= =?us-ascii?Q?7eKqKk/VS6OO6U4Grx0se+xoyBmpNXrghRJQyfTdlTaLgG4kL+LO+YqWe8yZ?= =?us-ascii?Q?xCGUvbr69ERuGvBfFnbP5D0jdnkxjdaGHXUh5sbyqls1VyeGXxU/sU9358nj?= =?us-ascii?Q?hzctuMfdjJDtZ4lMzOIeaZ/5KTloVQ0qAF5yRCT7N1VL7VgwuzgoV3xCCgMz?= =?us-ascii?Q?Q6/XdRALS/KIxN/2XU0pEQksHKR+MB768tULyHgjasc20lKzqktQQFAIdi9e?= =?us-ascii?Q?sVIjYxX2+z+mPyU=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)(7416014)(82310400026)(36860700013);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 22 Jan 2025 20:22:01.4243 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 878a85b4-b27d-4c44-ca79-08dd3b226de5 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: CH1PEPF0000A346.namprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: MN2PR12MB4160 Content-Type: text/plain; charset="utf-8" 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 a 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 value in struct rdt_hw_mon_domain, so it can be used for counter assignment. Signed-off-by: Babu Moger Reviewed-by: Reinette Chatre --- v11: Resolved minor conflicts due to code displacement. Actual code didnt change. v10: Conflicts due to code displacement. Actual code didnt change. v9: Added Reviewed-by tag. No other changes. v8: Renamed resctrl_mbm_evt_config_init() to arch_mbm_evt_config_init() Minor commit message update. v7: Fixed initializing INVALID_CONFIG_VALUE to mbm_local_cfg in case of err= or. v6: Renamed resctrl_arch_mbm_evt_config -> resctrl_mbm_evt_config_init Initialized value to INVALID_CONFIG_VALUE if it is not configurable. Minor commit message update. v5: Exported mon_event_config_index_get. Renamed arch_domain_mbm_evt_config to resctrl_arch_mbm_evt_config. v4: Read the configuration information from the hardware to initialize. Added few commit messages. Fixed the tab spaces. v3: Minor changes related to rebase in mbm_config_write_domain. v2: No changes. --- arch/x86/kernel/cpu/resctrl/core.c | 2 ++ arch/x86/kernel/cpu/resctrl/internal.h | 9 +++++++++ arch/x86/kernel/cpu/resctrl/monitor.c | 26 ++++++++++++++++++++++++++ arch/x86/kernel/cpu/resctrl/rdtgroup.c | 4 +--- 4 files changed, 38 insertions(+), 3 deletions(-) diff --git a/arch/x86/kernel/cpu/resctrl/core.c b/arch/x86/kernel/cpu/resct= rl/core.c index 3f847728aa7a..22399f19810f 100644 --- a/arch/x86/kernel/cpu/resctrl/core.c +++ b/arch/x86/kernel/cpu/resctrl/core.c @@ -632,6 +632,8 @@ static void domain_add_cpu_mon(int cpu, struct rdt_reso= urce *r) =20 arch_mon_domain_online(r, d); =20 + arch_mbm_evt_config_init(hw_dom); + if (arch_domain_mbm_alloc(r->mon.num_rmid, hw_dom)) { mon_domain_free(hw_dom); return; diff --git a/arch/x86/kernel/cpu/resctrl/internal.h b/arch/x86/kernel/cpu/r= esctrl/internal.h index ca69f2e0909f..ab28b9340ee7 100644 --- a/arch/x86/kernel/cpu/resctrl/internal.h +++ b/arch/x86/kernel/cpu/resctrl/internal.h @@ -56,6 +56,9 @@ /* Max event bits supported */ #define MAX_EVT_CONFIG_BITS GENMASK(6, 0) =20 +#define INVALID_CONFIG_VALUE U32_MAX +#define INVALID_CONFIG_INDEX UINT_MAX + /* Setting bit 0 in L3_QOS_EXT_CFG enables the ABMC feature. */ #define ABMC_ENABLE_BIT 0 =20 @@ -403,6 +406,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. */ @@ -410,6 +415,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) @@ -665,4 +672,6 @@ bool closid_allocated(unsigned int closid); int resctrl_find_cleanest_closid(void); int resctrl_arch_mbm_cntr_assign_set(struct rdt_resource *r, bool enable); bool resctrl_arch_mbm_cntr_assign_enabled(struct rdt_resource *r); +void arch_mbm_evt_config_init(struct rdt_hw_mon_domain *hw_dom); +unsigned int mon_event_config_index_get(u32 evtid); #endif /* _ASM_X86_RESCTRL_INTERNAL_H */ diff --git a/arch/x86/kernel/cpu/resctrl/monitor.c b/arch/x86/kernel/cpu/re= sctrl/monitor.c index 5f87fc1650e5..8917c7261680 100644 --- a/arch/x86/kernel/cpu/resctrl/monitor.c +++ b/arch/x86/kernel/cpu/resctrl/monitor.c @@ -1244,6 +1244,32 @@ int __init rdt_get_mon_l3_config(struct rdt_resource= *r) return 0; } =20 +void arch_mbm_evt_config_init(struct rdt_hw_mon_domain *hw_dom) +{ + unsigned int index; + u64 msrval; + + /* + * Read the configuration registers QOS_EVT_CFG_n, where is + * the BMEC event number (EvtID). + */ + if (mbm_total_event.configurable) { + index =3D mon_event_config_index_get(QOS_L3_MBM_TOTAL_EVENT_ID); + rdmsrl(MSR_IA32_EVT_CFG_BASE + index, msrval); + hw_dom->mbm_total_cfg =3D msrval & MAX_EVT_CONFIG_BITS; + } else { + hw_dom->mbm_total_cfg =3D INVALID_CONFIG_VALUE; + } + + if (mbm_local_event.configurable) { + index =3D mon_event_config_index_get(QOS_L3_MBM_LOCAL_EVENT_ID); + rdmsrl(MSR_IA32_EVT_CFG_BASE + index, msrval); + hw_dom->mbm_local_cfg =3D msrval & MAX_EVT_CONFIG_BITS; + } else { + hw_dom->mbm_local_cfg =3D INVALID_CONFIG_VALUE; + } +} + void __exit rdt_put_mon_l3_config(void) { dom_data_exit(); diff --git a/arch/x86/kernel/cpu/resctrl/rdtgroup.c b/arch/x86/kernel/cpu/r= esctrl/rdtgroup.c index 9b09189ef2d1..ddecaa51cec4 100644 --- a/arch/x86/kernel/cpu/resctrl/rdtgroup.c +++ b/arch/x86/kernel/cpu/resctrl/rdtgroup.c @@ -1591,8 +1591,6 @@ struct mon_config_info { u32 mon_config; }; =20 -#define INVALID_CONFIG_INDEX UINT_MAX - /** * mon_event_config_index_get - get the hardware index for the * configurable event @@ -1602,7 +1600,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 Wed Feb 11 05:40:54 2026 Received: from NAM10-DM6-obe.outbound.protection.outlook.com (mail-dm6nam10on2070.outbound.protection.outlook.com [40.107.93.70]) (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 974C52165E3; Wed, 22 Jan 2025 20:22:18 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.93.70 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1737577340; cv=fail; b=FuSa/BAAzNBMSAgP8xXmJlLm7dmQzDVUFC2kkMDYfb4AJUB4nLexTJUe8uREPfiwddOMt0Fjv9Dvl3ph9ScXViURhCRXpVqLv/CMRsp+pQIobQuYQ3R9WfBEn7Usm8lugF7hyUfjuwz0F0fTOj8j9Itc7ZXidiACKtBw7/dC9vg= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1737577340; c=relaxed/simple; bh=qvPu5KWW4PKi3FD9b6IdkicfdhmwQpQWCacPOyNJovc=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=rTYaGES/T9eYOERvDbJ9d0pGJXU6o/BEpT9r1gIdLjXG5hhr0LGvpFt3HWfwzQLnOW/TebDT3ZxOkX+qzRLIdnVu3dG3Gw10qSUN5aO6KM88ll+1FDyFR+1I3JLjCkZJpsvzbLehzw5UK9cgP/kcXdqFphGcBulvX8C0kcFC+rI= 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=idFzCJhk; arc=fail smtp.client-ip=40.107.93.70 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="idFzCJhk" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=AXyDc4WGPNAigKkND4aBPZw7RmRnF5YDbE5ZDpWBWaJVkrQX3iJi6BqWiE318gVcZmNgO4bl3ClKIDkqW+eOsMER3FoBTQl+NRGZ2//uxBzuqTjjQCS0oAVu07/oYmHAD4wNDiy0teA+4RshvkPB7WDi3BziPTMSGcuXtqjI8f+e2mAI9Hu3ZNV06nvWS8yJBwIB+LQ52kUrKwV0kF75Okej2kNJ7AhCwdL6OgIqL4U7bdD/l5KZZDZh3KZmvc/j6B1sptcPHJ3m/Rjugrxv4bgknhopUVOxCbqgYPAFqgBpzgbPeWl87fLTGITDHwjCB9B0RAbpnFJ1NnEZf/s7HA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=9XSh7jAA+V4w9FOygA7QFhN2QOWkrFRgnpck9QGpOmU=; b=T5y0sG6shO+I3BQhzKLSRjXnkwL5U/bEO/NoSwoft9t1j3FDfYBXzWkW+DIypAcsHyEVYILTt2Sn/fFO9n5eZ8VwP3aL28UJNz+oJkW2WRNn7NlHJuwxCAzopSsdys1mn9UjByiRFTMfoLtWq+qH3iBbyrtABT1MqfWK4T5ndn6TBddxnVkUwFC/Fq7DIfSKIBlxIaFZ1qQVj3DSdGGtKbq2qfLJKnXbE+lcziOyVmX3yugmI8vyuKs5G9gKoRPBIl1yJCBnTsseMO/24bDAAma9WRh8+WZgLAc4JCtI0npnisRzoZlwVaoyTjEbb1KgG/qiKeMSnmUa395bZAtX4A== 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=9XSh7jAA+V4w9FOygA7QFhN2QOWkrFRgnpck9QGpOmU=; b=idFzCJhkBo3QhTjPhIVOFr077an0TguI8CRgLeJZ5vnWUqXF75Q4Tgmv5HbV8PeGeDpbMvI1K2cWYVgJ63iV3DMg6fksqMoX9TFN/OJwYGq0m8JP6jCiZlXPKHGfNUD1L1iGJ0aCB2W3WZICyfejTadJD4xTukEii61o5B+PQJg= Received: from BN9PR03CA0519.namprd03.prod.outlook.com (2603:10b6:408:131::14) by MW4PR12MB6708.namprd12.prod.outlook.com (2603:10b6:303:1ed::5) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8377.16; Wed, 22 Jan 2025 20:22:13 +0000 Received: from BN2PEPF00004FBF.namprd04.prod.outlook.com (2603:10b6:408:131:cafe::63) by BN9PR03CA0519.outlook.office365.com (2603:10b6:408:131::14) with Microsoft SMTP Server (version=TLS1_3, cipher=TLS_AES_256_GCM_SHA384) id 15.20.8377.14 via Frontend Transport; Wed, 22 Jan 2025 20:22: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 BN2PEPF00004FBF.mail.protection.outlook.com (10.167.243.185) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.8377.8 via Frontend Transport; Wed, 22 Jan 2025 20:22:13 +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, 22 Jan 2025 14:22:07 -0600 From: Babu Moger To: , , , , , , , CC: , , , , , , , , , , , , , , , , , , , , , , , , , , Subject: [PATCH v11 10/23] x86/resctrl: Remove MSR reading of event configuration value Date: Wed, 22 Jan 2025 14:20:18 -0600 Message-ID: X-Mailer: git-send-email 2.34.1 In-Reply-To: References: Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-ClientProxiedBy: SATLEXMB04.amd.com (10.181.40.145) To SATLEXMB04.amd.com (10.181.40.145) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: BN2PEPF00004FBF:EE_|MW4PR12MB6708:EE_ X-MS-Office365-Filtering-Correlation-Id: 666f9e1b-2b12-48af-5330-08dd3b2274d0 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|1800799024|376014|7416014|36860700013|82310400026|13003099007; X-Microsoft-Antispam-Message-Info: =?us-ascii?Q?daZeyCaI80b2xDQAMPcfJ3EA+grGAqO8JApyhq9eN1K58oDWv5dvSi6Rrug+?= =?us-ascii?Q?gNPMwv4iWONM1nFaacN4EfkTGlbW/+m/0yCQ/yEPvFhSHoiEoIlNDuzJmZrE?= =?us-ascii?Q?C+48GN/Dsx/6kHIgJ00dWIy/N9lMMp9JRaZIH6cZBzEZhLFbkI35HlZHNS61?= =?us-ascii?Q?ELavQE/DdGz+9G9ahhsqxFA4FzlHciPhIn1QfFIPt+ykgx38o62xjesfDsUR?= =?us-ascii?Q?qHSGgG/rRh9lfodnBcBh3Cp7zEx8HcmEFOBvHoeorVsSMPDY2gdcEt8QBRTu?= =?us-ascii?Q?D4je1EbtJ0B61eaOUkrcWyvjgVnZ3OzKLxbjfahFdzg6qPcjeP1DqH+czcMK?= =?us-ascii?Q?0Ki4G/glwn+sXRdTUEZjhX3ByN6Mdfzy0SG/HSaOjPeemboDk2LxzJTlz3VG?= =?us-ascii?Q?ttqiFAkegCguShyryFkARsheRB9f5DZ/Usw5j8ikdvKgavjcRzZL3VKndnyC?= =?us-ascii?Q?9m29BkfBVO0os2mDUBdeClg1T6cbfq3CWsJcECHKaYhK8M+O24jLQ31Lzf+r?= =?us-ascii?Q?yJ/Edv9Ndq9lgMg5Q6m4SuWq8oT+IB1/VyfH5YJXk1bj57JGMuszOZHYrqrL?= =?us-ascii?Q?6owQ7xxkAp7HFKN/wAyG2EjF5Ufb/05gwnPF6xIUCF/hoMjenWizFwXlY1NT?= =?us-ascii?Q?jWl5247UTCOMVR8fHC+ZRV0cMihqNUceT+SRNg3LHHSd/8ItJ5FOHKKyxkA+?= =?us-ascii?Q?W5mweXn8VsQd4HixET8EUNjG+AkiX2Tl96hkK/u2hB7XeK9II3mSUYA98Npf?= =?us-ascii?Q?RI1HNuwBCujDVx/QWsjCoGYGZuy2g4J8XfI+dXR0jzO9XvT3fIK5a/pNUP4C?= =?us-ascii?Q?HeGUVfnN88mJMjukHg4UNMqqhOVPqvKSU5FEGz3HIitUpswPx6AGpEbblt24?= =?us-ascii?Q?4nVvo2YChlypcdE113dHHwsVZvAreffrX2oM+Zy3xOjeevWo5eHyjwYREemt?= =?us-ascii?Q?4iuN7Sk2I0MPY+LH3g+pqLoIAFtBCAzuZvgAGZDuGT2X6EitiGvuMG03SmIn?= =?us-ascii?Q?Rsgbz94GhOB3mShcZPveUsuDHUmj7DRT8HC8PdDygv+3qjVmih5JxDsVg3Rj?= =?us-ascii?Q?YX5TW6GOd3OaAls4RxFE48GJiDtxildFamApM7Bjqk5fzfrQZ94qS/sgNht/?= =?us-ascii?Q?oNbLoO/KEryaEpVy4kpz5n60Rs03tNl2Fw42IZ5nLtA0tdpmMEtwhXw30fcp?= =?us-ascii?Q?CCoKieeTtYKeo6PxSW32xUGwTnmMwf6/GEi+ilvJjTfgzFCBfUJ/iwBLzQ0o?= =?us-ascii?Q?mqX95l1Yuw9u7LMJ2eanBOn6lRj7/Bk6A0WfaZTMxK98jX5SSMXMkNTaC/Qt?= =?us-ascii?Q?jksrrqHzOJoUN30hBCWqOlX8ARFR5ebb4trAm2GnBvrnROdkpJiTM640D/4K?= =?us-ascii?Q?jb4YA37gn04Nwq+O5eJ1Kx06RgJyzuryBcibNfUWD+xBYoNeixnoN3cnK3uV?= =?us-ascii?Q?y8NhAJi37ZlKW1N/saNcbkYO40OeTFPH6/xJS9u+rM1ky5FMhtHgjqvFNCYX?= =?us-ascii?Q?Oz3LH+Y8QBvTO50=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)(7416014)(36860700013)(82310400026)(13003099007);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 22 Jan 2025 20:22:13.0590 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 666f9e1b-2b12-48af-5330-08dd3b2274d0 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: BN2PEPF00004FBF.namprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: MW4PR12MB6708 Content-Type: text/plain; charset="utf-8" The event configuration is domain specific and initialized during domain initialization. The values are stored in struct rdt_hw_mon_domain. It is not required to read the configuration register every time user asks for it. Use the value stored in struct rdt_hw_mon_domain instead. Introduce resctrl_arch_mon_event_config_get() and resctrl_arch_mon_event_config_set() to get/set architecture domain specific mbm_total_cfg/mbm_local_cfg values. Signed-off-by: Babu Moger --- v11: Moved the mon_config_info structure definition to internal.h. Moved resctrl_arch_mon_event_config_get() and resctrl_arch_mon_event_c= onfig_set() to monitor.c file. Renamed local variable from val to config_val. v10: Moved the mon_config_info structure definition to resctrl.h. v9: Removed QOS_L3_OCCUP_EVENT_ID switch case in resctrl_arch_mon_event_con= fig_set. Fixed a unnecessary space. v8: Renamed resctrl_arch_event_config_get() to resctrl_arch_mon_event_config_get(). resctrl_arch_event_config_set() to resctrl_arch_mon_event_config_set(). v7: Removed check if (val =3D=3D INVALID_CONFIG_VALUE) as resctrl_arch_even= t_config_get already prints warning. Kept the Event config value definitions as is. v6: Fixed inconstancy with types. Made all the types to u32 for config value. Removed few rdt_last_cmd_puts as it is not necessary. Removed unused config value definitions. Few more updates to commit message. v5: Introduced resctrl_arch_event_config_get and resctrl_arch_event_config_get() based on our discussion. https://lore.kernel.org/lkml/68e861f9-245d-4496-a72e-46fc57d19c62@amd.c= om/ v4: New patch. --- arch/x86/kernel/cpu/resctrl/internal.h | 15 +++++++ arch/x86/kernel/cpu/resctrl/monitor.c | 46 +++++++++++++++++++ arch/x86/kernel/cpu/resctrl/rdtgroup.c | 61 +++++--------------------- 3 files changed, 72 insertions(+), 50 deletions(-) diff --git a/arch/x86/kernel/cpu/resctrl/internal.h b/arch/x86/kernel/cpu/r= esctrl/internal.h index ab28b9340ee7..cfaea20145d0 100644 --- a/arch/x86/kernel/cpu/resctrl/internal.h +++ b/arch/x86/kernel/cpu/resctrl/internal.h @@ -605,6 +605,18 @@ union cpuid_0x10_x_edx { unsigned int full; }; =20 +/** + * struct mon_config_info - Monitoring event configuratiin details + * @d: Domain for the event + * @evtid: Event type + * @mon_config: Event configuration value + */ +struct mon_config_info { + struct rdt_mon_domain *d; + enum resctrl_event_id evtid; + u32 mon_config; +}; + void rdt_last_cmd_clear(void); void rdt_last_cmd_puts(const char *s); __printf(1, 2) @@ -674,4 +686,7 @@ int resctrl_arch_mbm_cntr_assign_set(struct rdt_resourc= e *r, bool enable); bool resctrl_arch_mbm_cntr_assign_enabled(struct rdt_resource *r); void arch_mbm_evt_config_init(struct rdt_hw_mon_domain *hw_dom); unsigned int mon_event_config_index_get(u32 evtid); +void resctrl_arch_mon_event_config_set(void *info); +u32 resctrl_arch_mon_event_config_get(struct rdt_mon_domain *d, + enum resctrl_event_id eventid); #endif /* _ASM_X86_RESCTRL_INTERNAL_H */ diff --git a/arch/x86/kernel/cpu/resctrl/monitor.c b/arch/x86/kernel/cpu/re= sctrl/monitor.c index 8917c7261680..6fe9e610e9a0 100644 --- a/arch/x86/kernel/cpu/resctrl/monitor.c +++ b/arch/x86/kernel/cpu/resctrl/monitor.c @@ -1324,3 +1324,49 @@ int resctrl_arch_mbm_cntr_assign_set(struct rdt_reso= urce *r, bool enable) =20 return 0; } + +u32 resctrl_arch_mon_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_mon_event_config_set(void *info) +{ + struct mon_config_info *mon_info =3D info; + struct rdt_hw_mon_domain *hw_dom; + unsigned int index; + + index =3D mon_event_config_index_get(mon_info->evtid); + if (index =3D=3D INVALID_CONFIG_INDEX) + return; + + wrmsr(MSR_IA32_EVT_CFG_BASE + index, mon_info->mon_config, 0); + + hw_dom =3D resctrl_to_arch_mon_dom(mon_info->d); + + switch (mon_info->evtid) { + case QOS_L3_MBM_TOTAL_EVENT_ID: + hw_dom->mbm_total_cfg =3D mon_info->mon_config; + break; + case QOS_L3_MBM_LOCAL_EVENT_ID: + hw_dom->mbm_local_cfg =3D mon_info->mon_config; + break; + default: + break; + } +} diff --git a/arch/x86/kernel/cpu/resctrl/rdtgroup.c b/arch/x86/kernel/cpu/r= esctrl/rdtgroup.c index ddecaa51cec4..18110a1afb6d 100644 --- a/arch/x86/kernel/cpu/resctrl/rdtgroup.c +++ b/arch/x86/kernel/cpu/resctrl/rdtgroup.c @@ -1586,11 +1586,6 @@ static int rdtgroup_size_show(struct kernfs_open_fil= e *of, return ret; } =20 -struct mon_config_info { - u32 evtid; - u32 mon_config; -}; - /** * mon_event_config_index_get - get the hardware index for the * configurable event @@ -1613,33 +1608,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; struct rdt_mon_domain *dom; bool sep =3D false; + u32 config_val; =20 cpus_read_lock(); mutex_lock(&rdtgroup_mutex); @@ -1648,11 +1621,8 @@ static int mbm_config_show(struct seq_file *s, struc= t 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); - - seq_printf(s, "%d=3D0x%02x", dom->hdr.id, mon_info.mon_config); + config_val =3D resctrl_arch_mon_event_config_get(dom, evtid); + seq_printf(s, "%d=3D0x%02x", dom->hdr.id, config_val); sep =3D true; } seq_puts(s, "\n"); @@ -1683,33 +1653,23 @@ static int mbm_local_bytes_config_show(struct kernf= s_open_file *of, return 0; } =20 -static void mon_event_config_write(void *info) -{ - struct mon_config_info *mon_info =3D info; - unsigned int index; - - index =3D mon_event_config_index_get(mon_info->evtid); - if (index =3D=3D INVALID_CONFIG_INDEX) { - pr_warn_once("Invalid event id %d\n", mon_info->evtid); - return; - } - wrmsr(MSR_IA32_EVT_CFG_BASE + index, mon_info->mon_config, 0); -} =20 static void mbm_config_write_domain(struct rdt_resource *r, struct rdt_mon_domain *d, u32 evtid, u32 val) { struct mon_config_info mon_info =3D {0}; + u32 config_val; =20 /* - * Read the current config value first. If both are the same then + * Check the current config value first. If both are the same then * no need to write it again. */ - mon_info.evtid =3D evtid; - mondata_config_read(d, &mon_info); - if (mon_info.mon_config =3D=3D val) + config_val =3D resctrl_arch_mon_event_config_get(d, evtid); + if (config_val =3D=3D INVALID_CONFIG_VALUE || config_val =3D=3D val) return; =20 + mon_info.d =3D d; + mon_info.evtid =3D evtid; mon_info.mon_config =3D val; =20 /* @@ -1718,7 +1678,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_mon_event_config_set, &mon_info, 1); =20 /* --=20 2.34.1 From nobody Wed Feb 11 05:40:54 2026 Received: from NAM02-BN1-obe.outbound.protection.outlook.com (mail-bn1nam02on2042.outbound.protection.outlook.com [40.107.212.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 DDF342165FF; Wed, 22 Jan 2025 20:22:21 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.212.42 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1737577343; cv=fail; b=ogx2RP+Px6i3KalbWhCXpfAz+/jrnl7fxDUd8Y5tS8P6FXrPiQHKM871CzfWfj0WgUGrirvveYE5XA1vddnseQwMkrSTSv/+UIKLTheFuxwsqCb1D9W9muTMp8D8VgufAENUSByw4HUOGVW1RkqTTeuRO85s/BXgb99cDVowYsQ= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1737577343; c=relaxed/simple; bh=pwAy1eMX7WGYkbhPjCSRNyrXUWuZM54g3Q88QCTv2R0=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=O2bUeIZiT/0pXZxTYJcHeHkcqhzSKAq3UWLtg0ocK4L1efjHjE9vlr8MDKAvwdNUqzVDPXCa0SXLd7RWc4ad62FI39bsxQDBVc6W30tPKFmAQiwPIsYnxqtwHJU2M8Nj7G5KynnkDoTyl+JfxMxc2vLKuD89z0YXH2XLSGOzsL8= 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=e9Kw8znI; arc=fail smtp.client-ip=40.107.212.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="e9Kw8znI" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=UdwT1LdULxcCY0CXQ+0XkvzDEJNSwHS7hmS/QMNEUkjaJhYIdqtWA7MpxXNMIMPiBscU9iz8bjk5eUkTxo/h5qALsKwEFp/SOQqdre1tXRuFnW6oty+reaBPmPAZTu2vWObvrYJmMTH1gYs+z/2QxeuazNjVnlQZDUloNoYXDQI0ZRfJbIcUUse/EERUKpIxUqIVp7TZXzn8r1ceSl/KopZ9FGiWycGvhJC9HVu7n8YulOL9pqmiRvogCIDbzn0NRqV/QX8TxtWY4q7WiQn5HxpCiV4eYNTpUQ2T9QXvCxBCH2Gcf9TaNVDLA/5UvvLBelust1wP98fb4wg0zvsMkw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=l9xAXyItUXdy7/sk9ZCdVC0L0JI+gyjZ3lqKPQsnYgQ=; b=EX9WlOkigcV7IBvNoKmuzWZefLTspuBBJk4k1zfhKjmMPRo+4M0QoiJXGHcZJz95qoMza7mSpoOtpKJlS1jzTikHWiJi3sky8PDRQvCYC7A3zES8Zmc+RqrMj7YrSaMQR3a5KXTZV2lKPNqYZk44u58i+K20MtrSr+V2AhFkF57eFs5D60PBSb4AFE1OyyNdllk6drxGBrWeq2v2iWws03ZDBmhGpNiEypOUYlvz8AK4WKMkOc30byWeps+cXuTB/V1UWs6tpNDNX9I0Gqu6xDRMpHDK1bdMaYI4zAoN77kAqq+IGBlyfWCmSP0zQljYqcoep9KTQ85L0Aq3YQS0AQ== 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=l9xAXyItUXdy7/sk9ZCdVC0L0JI+gyjZ3lqKPQsnYgQ=; b=e9Kw8znIJ6vCvZ2orLKFq9+ZGv+1xRVP6RRSBBdsoBe0teX8xTyT62awgjDs9aqz6hDMjYDVEOZa+W9iFCvP9h+GxnRzQAT1wlWcA3aGFrPBoAeGRy6qBNF+mWz3TpBK/MnYXCNow+YM2cFSb/i01xaa6W5v5y34azE/9qT/dkI= Received: from CH2PR12CA0008.namprd12.prod.outlook.com (2603:10b6:610:57::18) by DS7PR12MB5864.namprd12.prod.outlook.com (2603:10b6:8:7b::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8356.22; Wed, 22 Jan 2025 20:22:17 +0000 Received: from CH1PEPF0000A346.namprd04.prod.outlook.com (2603:10b6:610:57:cafe::cf) by CH2PR12CA0008.outlook.office365.com (2603:10b6:610:57::18) with Microsoft SMTP Server (version=TLS1_3, cipher=TLS_AES_256_GCM_SHA384) id 15.20.8356.22 via Frontend Transport; Wed, 22 Jan 2025 20:22:17 +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 CH1PEPF0000A346.mail.protection.outlook.com (10.167.244.11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.8377.8 via Frontend Transport; Wed, 22 Jan 2025 20:22:17 +0000 Received: from bmoger-ubuntu.amd.com (10.180.168.240) by SATLEXMB04.amd.com (10.181.40.145) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.39; Wed, 22 Jan 2025 14:22:15 -0600 From: Babu Moger To: , , , , , , , CC: , , , , , , , , , , , , , , , , , , , , , , , , , , Subject: [PATCH v11 11/23] x86/resctrl: Introduce mbm_cntr_cfg to track assignable counters at domain Date: Wed, 22 Jan 2025 14:20:19 -0600 Message-ID: <30652061d4a21eb5952a1323b76ca70927412a30.1737577229.git.babu.moger@amd.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: References: Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-ClientProxiedBy: SATLEXMB04.amd.com (10.181.40.145) To SATLEXMB04.amd.com (10.181.40.145) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CH1PEPF0000A346:EE_|DS7PR12MB5864:EE_ X-MS-Office365-Filtering-Correlation-Id: 8d3e85bb-f4a6-42a6-8b72-08dd3b22775e X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|82310400026|36860700013|1800799024|376014|7416014; X-Microsoft-Antispam-Message-Info: =?us-ascii?Q?mB52dwCywUhnQcP476b5IOMBQ14d1U5H2jrRhM10bsRnkFrLlBGxE82kTDAe?= =?us-ascii?Q?VXYQe7o50Otnm9vTdY+I7XfIkEJ0nuraOEp8PoJuJehIqiPADGc1gecDPmiQ?= =?us-ascii?Q?n7Bcle6E3Va8g1+rVSYSQojfzDm+wLbty4dDk3Rupgm3o23XODFrew+e38fG?= =?us-ascii?Q?3ssv1NnY+JfdUBDDQQCSBIPptKYVmRdbpAVh6wtG/o7HFTxp6xhljE0s5rqy?= =?us-ascii?Q?ahPSlN6F5mQfQtFewbWpXMVvScogxWJdeRedN9WPv1CcdERlFEjE1UY2JKz4?= =?us-ascii?Q?NWOINm+xLRBtw95C/GXi3PqSJU0q98FftZQyLPUfgiuRXU/XDylzB0e716Gx?= =?us-ascii?Q?5cLk3Um/nlChqamFRlsyUnao36h1CLytQ8kXzCyliNTxVgyqFrTrRCw7wjCZ?= =?us-ascii?Q?Ie0DlA8dgEbin7Yf55Yvyf7T7Lsuj4Jt6Mb/1O9uVymHHm2CaLWi31g+oU33?= =?us-ascii?Q?GWtveQgHA7EMy22E6UUIwZB4j5g98LU3OoaRxnzbR9G+EZbFU9ZU0HNB6R4u?= =?us-ascii?Q?8mOI5QkPuLeYoM06oBBMQCXSaVgcWHxJuiMjFLa9QqxTwH6CdkqUKFb3vzEh?= =?us-ascii?Q?n+v9/YcoU+n+XIBPvt/dbZBHwMOfuI80r3aZZH2qZdCbFCHXVWpjvl+SNBTv?= =?us-ascii?Q?DteO7RkFPUCV2Wb3o3Wwa+fKZ80m5bzCcdu9s7qL8kP4mlMyu0WA0lH3GiCj?= =?us-ascii?Q?mMT/k9sYIG8CjoA//kkV1JAFmA4iFBuTGEykcr3/gBRW57wvqn/GZp1qRQdQ?= =?us-ascii?Q?o2RQtEOfMheRjUdKeCpFMOfXhDAO7QfoWCal8p/HjPaHUFTk70ZneC4SpHAP?= =?us-ascii?Q?Zue+MsZRcBjWDkUOK+DszilWOBaWjLaFkXs8dvtxZZ4NWT+AtbWms0MQm1Bt?= =?us-ascii?Q?5tEky/QkLYpEyTFQqYQpgqGbT6CWsJtG7moAEfRWAuNQ9J7V3pVtzMN0bWZo?= =?us-ascii?Q?504wh5Zr9AFvtYrece4Of7SFEVqTHIkyFo4uNGHHFbclmd6/vb9oxZtELK2z?= =?us-ascii?Q?3WDJULfl/FlTWJQNOhSyXDg7YwNgkUtqYptEqKcgjSOl5gSMxzS9swefDhdZ?= =?us-ascii?Q?/xZFD0OEqWfG9IBCXRtNIw5kBbTt+YSwY4TAGVu0GI7nmWB5FZ9QxVt7y2OB?= =?us-ascii?Q?O3gcJFNZjgUnhEYX3tEGJNEIgqs6xszC5ZWnQXUXFdk2lzS8hUPIBm8n13Vl?= =?us-ascii?Q?FKwnxp9i+2SQXV4/w0d+jdfejmUiVQJ1d27AAIzsPEoWQ4V3wlkbyg9GHuKB?= =?us-ascii?Q?shk6uqyHf8J9u4BrDY45TScN1bh95z5oCLqrmeEeX6GvFmHXU+Q0rg3gPKsB?= =?us-ascii?Q?slr+yabrcJ8St7WP5tAIb/ZnGX2ThAIR8u1ll2a2nPbv1J/H/Zo90DoREEOe?= =?us-ascii?Q?Hr58SCi5SISA5lbZbxdsBRNiYk5AZ2iofTqBiOVJHoVKS/3ZDpQIx1bO62tf?= =?us-ascii?Q?uGA74eC6JBiVhGL5e623azCmMr7MBHtK?= X-Forefront-Antispam-Report: CIP:165.204.84.17;CTRY:US;LANG:en;SCL:1;SRV:;IPV:CAL;SFV:NSPM;H:SATLEXMB04.amd.com;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(13230040)(82310400026)(36860700013)(1800799024)(376014)(7416014);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 22 Jan 2025 20:22:17.3152 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 8d3e85bb-f4a6-42a6-8b72-08dd3b22775e 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: CH1PEPF0000A346.namprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DS7PR12MB5864 Content-Type: text/plain; charset="utf-8" In mbm_cntr_assign mode hardware counters are assigned/unassigned to an MBM event of a monitor group. Hardware counters are assigned/unassigned at monitoring domain level. Manage a monitoring domain's hardware counters using a per monitoring domain array of struct mbm_cntr_cfg that is indexed by the hardware counter ID. A hardware counter's configuration contains the MBM event ID and points to the monitoring group that it is assigned to, with a NULL pointer meaning that the hardware counter is available for assignment. There is no direct way to determine which hardware counters are assigned to a particular monitoring group. Check every entry of every hardware counter configuration array in every monitoring domain to query which MBM events of a monitoring group is tracked by hardware. Such queries are acceptable because of a very small number of assignable counters. Suggested-by: Peter Newman Signed-off-by: Babu Moger --- v11: Refined the change log based on Reinette's feedback. Fixed few style issues. v10: Patch changed completely to handle the counters at domain level. https://lore.kernel.org/lkml/CALPaoCj+zWq1vkHVbXYP0znJbe6Ke3PXPWjtri5A= FgD9cQDCUg@mail.gmail.com/ Removed Reviewed-by tag. Did not see the need to add cntr_id in mbm_state structure. Not used i= n the code. v9: Added Reviewed-by tag. No other changes. v8: Minor commit message changes. v7: Added check mbm_cntr_assignable for allocating bitmap mbm_cntr_map v6: New patch to add domain level assignment. --- arch/x86/kernel/cpu/resctrl/rdtgroup.c | 11 +++++++++++ include/linux/resctrl.h | 14 ++++++++++++++ 2 files changed, 25 insertions(+) diff --git a/arch/x86/kernel/cpu/resctrl/rdtgroup.c b/arch/x86/kernel/cpu/r= esctrl/rdtgroup.c index 18110a1afb6d..75a3b56996ca 100644 --- a/arch/x86/kernel/cpu/resctrl/rdtgroup.c +++ b/arch/x86/kernel/cpu/resctrl/rdtgroup.c @@ -4009,6 +4009,7 @@ static void __init rdtgroup_setup_default(void) =20 static void domain_destroy_mon_state(struct rdt_mon_domain *d) { + kfree(d->cntr_cfg); bitmap_free(d->rmid_busy_llc); kfree(d->mbm_total); kfree(d->mbm_local); @@ -4082,6 +4083,16 @@ static int domain_setup_mon_state(struct rdt_resourc= e *r, struct rdt_mon_domain return -ENOMEM; } } + if (is_mbm_enabled() && r->mon.mbm_cntr_assignable) { + tsize =3D sizeof(*d->cntr_cfg); + d->cntr_cfg =3D kcalloc(r->mon.num_mbm_cntrs, tsize, GFP_KERNEL); + if (!d->cntr_cfg) { + bitmap_free(d->rmid_busy_llc); + kfree(d->mbm_total); + kfree(d->mbm_local); + return -ENOMEM; + } + } =20 return 0; } diff --git a/include/linux/resctrl.h b/include/linux/resctrl.h index 511cfce8fc21..9a54e307d340 100644 --- a/include/linux/resctrl.h +++ b/include/linux/resctrl.h @@ -94,6 +94,18 @@ struct rdt_ctrl_domain { u32 *mbps_val; }; =20 +/** + * struct mbm_cntr_cfg - assignable counter configuration + * @evtid: MBM event to which the counter is assigned. Only valid + * if @rdtgroup is not NULL. + * @rdtgroup: resctrl group assigned to the counter. NULL if the + * counter is free. + */ +struct mbm_cntr_cfg { + enum resctrl_event_id evtid; + struct rdtgroup *rdtgrp; +}; + /** * struct rdt_mon_domain - group of CPUs sharing a resctrl monitor resource * @hdr: common header for different domain types @@ -105,6 +117,7 @@ struct rdt_ctrl_domain { * @cqm_limbo: worker to periodically read CQM h/w counters * @mbm_work_cpu: worker CPU for MBM h/w counters * @cqm_work_cpu: worker CPU for CQM h/w counters + * @cntr_cfg: assignable counters configuration */ struct rdt_mon_domain { struct rdt_domain_hdr hdr; @@ -116,6 +129,7 @@ struct rdt_mon_domain { struct delayed_work cqm_limbo; int mbm_work_cpu; int cqm_work_cpu; + struct mbm_cntr_cfg *cntr_cfg; }; =20 /** --=20 2.34.1 From nobody Wed Feb 11 05:40:54 2026 Received: from NAM10-MW2-obe.outbound.protection.outlook.com (mail-mw2nam10on2054.outbound.protection.outlook.com [40.107.94.54]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id D92AB2165F3; Wed, 22 Jan 2025 20:22:30 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.94.54 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1737577352; cv=fail; b=Y+cQ3rXkjt0lSPwYOcJpZEObREwiMjC1WzJ7am2clhDW4wrzoRmQcLSxFsmXeE+YND7vpPX4U7O4uIktG1KIz1HH6Iyw4mTQruxf+KwBe8vD00MOhw0bPjENcGg075uorwIQD+IwQejYpk60dhddwwsD/771mwxTZksqwfRRYJo= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1737577352; c=relaxed/simple; bh=Ypy+C6yBYbJAnwgjbwpyCFNLRyTySB9SF8HzvcuG4yw=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=MsejubKw7+cH1FWD1FhvMjJPTuQNpUrZWo40riWsmpxq2kFKGYkn5Pzi8dM9aa/4ffrrN2kwviZr/XxPkwoSBaQUc/rStPNzHk+ILFqB8r0TrAjgVjMhFxL7S2AbcONTmS5LLtAWJvEu7QghZHUmLUINoQPdZA2K8jIMr0I4SgQ= 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=kVhR4oIR; arc=fail smtp.client-ip=40.107.94.54 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=amd.com Authentication-Results: smtp.subspace.kernel.org; spf=fail smtp.mailfrom=amd.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=amd.com header.i=@amd.com header.b="kVhR4oIR" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=rIB6UGcR4JKi8VOri1Zp5sq95qQ9ak7TYnAq6NtdTmlg+A2kBY1B7bDiLzZjDmQCrhUnVdXVXbIwkXrvEuPr6KbaroghGIKdZf+27J/crOxPH/hIHVyDHDBi8ZnabMgiWOgmnfXTdV8Zba+I7a58aFENO0V/4qtoSUmpnXKJlw9oz4tHXxD1KJfvtBbhtrucAfAGLVR0IbKdng28NVoWjHGgC8JojhaqEDCYB8wCkoEfcx4wsmRfUtBDsGZRzW60Wg27BcZStSTY3g5TpD0q54qiX/kcrGCxExjoMAyMVI9yrHV11IzsBcTd4EbWIzv1pqwMdBFdyso8ILoMMLSmVQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=SrVoTaYv6/n0OQiZR3sz21BPT7zAIdu6p7ctNSXXouQ=; b=Lbrq009QJMcckAHlZql67Ieo6A6vYVNdTLRUPBYQm4kX3+OS2gj6pOyN9hjGv5rbj/C6idnwIXTw1GlXz3qdpHr3dJvNoO+CkhQRdf4YP39KXku0Snec5DjSJ10VD1n9dLaM6ltKuewI/z/s3pajmFSMFLVt3iImR9IduNuVF1dlns0osymOAb2kgZASSUI4u+hnNjQY3KiDKuBp0o/0HabJ71k3PD0zim3JVMYHFfTpwWxnajtpAnnTeqLrSwyK53a8Pd/fl+rJFXlKQrMoo/V9EBPp20d4mSlXePrhrNlhVPqDcclzzGV+0TWFMcpZdvPonnHlyMzP85QEuffwpA== 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=SrVoTaYv6/n0OQiZR3sz21BPT7zAIdu6p7ctNSXXouQ=; b=kVhR4oIRMSTN6dLtR+qQc6x6jI4KqiTSz7QaOrEMZZNvSd3TVIWD21PGXrPBAkIivabFtYMZICECVP4gXxO1LqZFnZyakYw+k6a3cxQQCu/m0UoGjooEdRbjMbHHqxPHMP2TC+g+LJ5VYPoI+vA1Xlf9AZ7hjhoSAWbEBaiY41U= Received: from CH2PR07CA0016.namprd07.prod.outlook.com (2603:10b6:610:20::29) by IA1PR12MB7520.namprd12.prod.outlook.com (2603:10b6:208:42f::8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8377.16; Wed, 22 Jan 2025 20:22:26 +0000 Received: from CH1PEPF0000A34A.namprd04.prod.outlook.com (2603:10b6:610:20:cafe::39) by CH2PR07CA0016.outlook.office365.com (2603:10b6:610:20::29) with Microsoft SMTP Server (version=TLS1_3, cipher=TLS_AES_256_GCM_SHA384) id 15.20.8356.21 via Frontend Transport; Wed, 22 Jan 2025 20:22:26 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 165.204.84.17) smtp.mailfrom=amd.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=amd.com; Received-SPF: Pass (protection.outlook.com: domain of amd.com designates 165.204.84.17 as permitted sender) receiver=protection.outlook.com; client-ip=165.204.84.17; helo=SATLEXMB04.amd.com; pr=C Received: from SATLEXMB04.amd.com (165.204.84.17) by CH1PEPF0000A34A.mail.protection.outlook.com (10.167.244.5) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.8377.8 via Frontend Transport; Wed, 22 Jan 2025 20:22:25 +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, 22 Jan 2025 14:22:23 -0600 From: Babu Moger To: , , , , , , , CC: , , , , , , , , , , , , , , , , , , , , , , , , , , Subject: [PATCH v11 12/23] x86/resctrl: Introduce interface to display number of free counters Date: Wed, 22 Jan 2025 14:20:20 -0600 Message-ID: X-Mailer: git-send-email 2.34.1 In-Reply-To: References: Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-ClientProxiedBy: SATLEXMB04.amd.com (10.181.40.145) To SATLEXMB04.amd.com (10.181.40.145) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CH1PEPF0000A34A:EE_|IA1PR12MB7520:EE_ X-MS-Office365-Filtering-Correlation-Id: 1742ceeb-a660-4e8d-91a7-08dd3b227c7c X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|1800799024|36860700013|7416014|376014|82310400026; X-Microsoft-Antispam-Message-Info: =?us-ascii?Q?1eAl/X5z0g+8kSaZipaoMfYr7xexIDX0LvITPkemegGmXhMXiLFB3pHTzFP5?= =?us-ascii?Q?PPmbbtolLZi9suDiCtGHc+zcGB+nQWOZlYNz/3yzO+RnOfpRV73UJ6282YE3?= =?us-ascii?Q?6tNA6cmG11KV+P0T+59i7oQV6ckriuRbdZo8MoEaonmv6rMyOwLGj48D3Xk1?= =?us-ascii?Q?mIwj7G1pwFAMMQDvg0ypaNPHjtRhmgurFSkP2ABLieemS+2XhZAzhLlCYO8v?= =?us-ascii?Q?61275VLhiaw5NdOcteYSG4pknhAfnQEncOxn8o24giw4YO+L0Eb6QFfZnuFN?= =?us-ascii?Q?4qY1FpjADgBz8NggrCilbMWNLn8S4nPhvlzSlnxIimgaNt/w5ILleXCjBk5W?= =?us-ascii?Q?AG6n4dmwOXYcGrpIMrcOq5C3olmyUUnRCV47TMXLPW3GDwrcaMOfRSoE5Hq1?= =?us-ascii?Q?3FvgNiVFgQUUbPPspvhlSUEAB47ghCdRcKPv5rziLe/pljH276bOQlIN6bs2?= =?us-ascii?Q?EudjQJdhFLtFAviBNKgWGxpYn6AoXWZdkwn8oKSVxAKAomsglyvCqiJcMh/Y?= =?us-ascii?Q?701k3R/FGvRgf4sRzCRlyIG9Bx1myanGfNT+KKFMB+r7+LsQKTmVXDD0OCuj?= =?us-ascii?Q?6PT1O2g7CxsITsX4DQuuUYZTsrXdy3eeuYjO9438WS3Vrta8VGvDbOxHP6c2?= =?us-ascii?Q?DWdwcU3SduiGCZJhd+swzPZnSoy3Mh81WRn0SxpzqlcDjjAgpxoWf4+xiNuu?= =?us-ascii?Q?RP8XyYz+F7BuQIkz7eNq5Wkn+A8xyHKqcZ7PEroAmtkjF20MEPJwr294+fy2?= =?us-ascii?Q?PKI2ECr9T1hGF7ApPy2JC02IQYQmQVXGhVb3U4vgEXKyq0W4IMR4NWfAKkye?= =?us-ascii?Q?QETGslhCkPUpQMEUwApWy0QBxGsqU/G5jJrrPnN+Tf7UDGXmv9uBRhkDoReu?= =?us-ascii?Q?5x9rAmoDglT8ZV9WwCv8dfjItNRGYBITDMp1sdGW1+zLyuetsJB9ppl22LGY?= =?us-ascii?Q?kehJdVU2QB6jJzuUObGdP5129KI7AKrLlemLNTbLv2vcHN7D/hIkcyI/bSeS?= =?us-ascii?Q?WXVFFwd6volCZWE8I0iXYWFiIQlz/y2oKzoeXkG+A+U53wCCz4Q3B44u+OYc?= =?us-ascii?Q?vay068wLMnMlnKCSEhfPbnG5OXw1+wF/i904p0QJLLSj3Xrc3vhLksUiUdtN?= =?us-ascii?Q?4H1XJr/IYan5WaujGrQ6VsZ+A83G14U2ONarggjNAV1Bx/ZZM8L9xHY2/rDi?= =?us-ascii?Q?dc4Y08mNq8cvvjlU4HXR49mOQmujTMUWnNJ0+JW4YN/CBRGrwugwAp/+OATQ?= =?us-ascii?Q?f8fRF4v6v01KLxP1pALtvF8Y8mSYx0Iz3RhSSDTt1SsS7I4YNX+WsZ8nT7lD?= =?us-ascii?Q?OzvqSmbmGhaTAV0O3j/qL+nDfW1rpLy3UZWzIrOBecv8UBH9G3+OwLo0Wh/G?= =?us-ascii?Q?TOjzVMzfBkzDTh8XESXTL/9X54K2Tst5fxJrseBbeJXM6/qeKPITvSXaQeZn?= =?us-ascii?Q?GlkyquRmeQoCzDVBxVIfiaVx02G/oz+f?= X-Forefront-Antispam-Report: CIP:165.204.84.17;CTRY:US;LANG:en;SCL:1;SRV:;IPV:CAL;SFV:NSPM;H:SATLEXMB04.amd.com;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(13230040)(1800799024)(36860700013)(7416014)(376014)(82310400026);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 22 Jan 2025 20:22:25.9006 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 1742ceeb-a660-4e8d-91a7-08dd3b227c7c 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: CH1PEPF0000A34A.namprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: IA1PR12MB7520 Content-Type: text/plain; charset="utf-8" Provide the interface to display the number of monitoring counters available for assignment in each domain when mbm_cntr_assign is enabled. Signed-off-by: Babu Moger --- v11: Rename rdtgroup_available_mbm_cntrs_show() to resctrl_available_mbm_cn= trs_show(). Few minor text changes. v10: Patch changed to handle the counters at domain level. https://lore.kernel.org/lkml/CALPaoCj+zWq1vkHVbXYP0znJbe6Ke3PXPWjtri5A= FgD9cQDCUg@mail.gmail.com/ So, display logic also changed now. v9: New patch --- Documentation/arch/x86/resctrl.rst | 8 +++++ arch/x86/kernel/cpu/resctrl/monitor.c | 1 + arch/x86/kernel/cpu/resctrl/rdtgroup.c | 46 ++++++++++++++++++++++++++ 3 files changed, 55 insertions(+) diff --git a/Documentation/arch/x86/resctrl.rst b/Documentation/arch/x86/re= sctrl.rst index 31ff764deeeb..99cae75559b0 100644 --- a/Documentation/arch/x86/resctrl.rst +++ b/Documentation/arch/x86/resctrl.rst @@ -299,6 +299,14 @@ with the following files: memory bandwidth tracking to a single memory bandwidth event per monitoring group. =20 +"available_mbm_cntrs": + The number of monitoring counters available for assignment in each + domain when mbm_cntr_assign mode is enabled on the system. + :: + + # cat /sys/fs/resctrl/info/L3_MON/available_mbm_cntrs + 0=3D30;1=3D30 + "max_threshold_occupancy": Read/write file provides the largest value (in bytes) at which a previously used LLC_occupancy diff --git a/arch/x86/kernel/cpu/resctrl/monitor.c b/arch/x86/kernel/cpu/re= sctrl/monitor.c index 6fe9e610e9a0..f2bf5b13465d 100644 --- a/arch/x86/kernel/cpu/resctrl/monitor.c +++ b/arch/x86/kernel/cpu/resctrl/monitor.c @@ -1234,6 +1234,7 @@ int __init rdt_get_mon_l3_config(struct rdt_resource = *r) cpuid_count(0x80000020, 5, &eax, &ebx, &ecx, &edx); r->mon.num_mbm_cntrs =3D (ebx & GENMASK(15, 0)) + 1; resctrl_file_fflags_init("num_mbm_cntrs", RFTYPE_MON_INFO); + resctrl_file_fflags_init("available_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 75a3b56996ca..2b86124c336b 100644 --- a/arch/x86/kernel/cpu/resctrl/rdtgroup.c +++ b/arch/x86/kernel/cpu/resctrl/rdtgroup.c @@ -888,6 +888,46 @@ static int resctrl_num_mbm_cntrs_show(struct kernfs_op= en_file *of, return 0; } =20 +static int resctrl_available_mbm_cntrs_show(struct kernfs_open_file *of, + struct seq_file *s, void *v) +{ + struct rdt_resource *r =3D of->kn->parent->priv; + struct rdt_mon_domain *dom; + bool sep =3D false; + u32 cntrs, i; + int ret =3D 0; + + cpus_read_lock(); + mutex_lock(&rdtgroup_mutex); + + if (!resctrl_arch_mbm_cntr_assign_enabled(r)) { + rdt_last_cmd_puts("mbm_cntr_assign mode is not enabled\n"); + ret =3D -EINVAL; + goto unlock_cntrs_show; + } + + list_for_each_entry(dom, &r->mon_domains, hdr.list) { + if (sep) + seq_puts(s, ";"); + + cntrs =3D 0; + for (i =3D 0; i < r->mon.num_mbm_cntrs; i++) { + if (!dom->cntr_cfg[i].rdtgrp) + cntrs++; + } + + seq_printf(s, "%d=3D%d", dom->hdr.id, cntrs); + sep =3D true; + } + seq_puts(s, "\n"); + +unlock_cntrs_show: + mutex_unlock(&rdtgroup_mutex); + cpus_read_unlock(); + + return ret; +} + #ifdef CONFIG_PROC_CPU_RESCTRL =20 /* @@ -1916,6 +1956,12 @@ static struct rftype res_common_files[] =3D { .kf_ops =3D &rdtgroup_kf_single_ops, .seq_show =3D resctrl_num_mbm_cntrs_show, }, + { + .name =3D "available_mbm_cntrs", + .mode =3D 0444, + .kf_ops =3D &rdtgroup_kf_single_ops, + .seq_show =3D resctrl_available_mbm_cntrs_show, + }, { .name =3D "cpus", .mode =3D 0644, --=20 2.34.1 From nobody Wed Feb 11 05:40:54 2026 Received: from NAM10-BN7-obe.outbound.protection.outlook.com (mail-bn7nam10on2077.outbound.protection.outlook.com [40.107.92.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 EB7542163B7; Wed, 22 Jan 2025 20:22:39 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.92.77 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1737577361; cv=fail; b=kAWDajgXJiP1/x3Gld0H4zyd59Mrh0bXy++YbYb6JmfQCxAzJMjXYsQdmfSZcfH3L9CfUam5M4iYEEPU1vLQ8T2vBvBdzqbdoDbR9TjlhZAMvhPV8raIfTtxaJrnbZMYY0Gf7ffbZAbWHQnH29dd8imbc6Q3kRplpoj+esKZe4s= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1737577361; c=relaxed/simple; bh=BZ1kMCjcnzaTbr6aaVvNJuo/j1rlt7lU/5gBdE6fw9o=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=QwCkGclSAKXejunq5dRy45zLHElOcDxKY9INO68KKWZvCOW1WmdduL/3ZznPxY7PIYaMUW/5RbnyAunhiDxGag+CF/slbd5yHHAkweHTq9+5BVWbGR8VoHB/psPduItSvto8XysaSjOasnk37Y7uQUsxmBL2pzsVX7aUPceXCPY= 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=mXJGXnzL; arc=fail smtp.client-ip=40.107.92.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="mXJGXnzL" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=I7WHF2X3oYRhg9HxUmKEumwXKDddOuT2s5XsyWDIXvBEG1nuxtcU82JFP9g6jLqYTIyfbr5LUi6mhyobL34sc75tWzWH7jtVle1HsK5pQX07j+gt7FV8LTINbhGyx6HGqQy3Jv2fbS5FZ5eSCBU+UowNPXfPMIl50biouWl0i/r7SE4NKw38GuWYrRTkEQtMjiKhQVHpOop7DnHJym1/QUfjpgRMAVWQhseXK9rZH+x2NT89UbdtH9ouOOkdW0pl8+VCMfBuijH2Jnw1NFdnTFor9SnLjP4Fz2QWNyJKKBtHtzb4dP43zKqgQXURWC4uB7af8VWdbzH0EDneSqT4BA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=jZRHuq+BZRB2+A7KilFnGt3RC+0JHmxkohxLAVW/ijk=; b=Cuebdw+Lg8nQKMVouMRNCWP/TCrxo4vdkqxa/cWF2PhdeIeIE5zCzVNqWtPVlM195sFS/9oTE0dtwGWnuRKsGM21xudfV0lLWF27++2WzfZNxfQ5Ao4cmnYcpR4KFTYc0XIK9Ci6t6DM+y+692GEzMRvHE6WZ1pdFtNSkEsVOCn8tPnoVJ2LfplY41DnVRIOacfZa3TEhB7oNSLHG4AHsh8g4+GCr3G6IEtH1OEhVlM+4b6hT5D3qoWSn1quRr6oJKtwyQJjwwgtXggiLRUv4+sTyX5PuN4gJkX8yrdyGDxxv8tnSBSm+Z8JE48vO+egjE8D2s/3KMXRoLC/KYEf8Q== 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=jZRHuq+BZRB2+A7KilFnGt3RC+0JHmxkohxLAVW/ijk=; b=mXJGXnzLDCzNQsbvVZ00uO7EvAXy4hSI8rGakxjFdj6vFWAepP9flyn+SBXqoMMs1It62VPnPeUU+KGPc8q2aCvCsqC9ePWgQLsle46U0Y2EB2Vy00C3xUHGa4K9EvrFED0c8aVp1ug4pUaV5K0X85PvTpVPhc5OzQYQTjoBXko= Received: from CH0PR03CA0320.namprd03.prod.outlook.com (2603:10b6:610:118::25) by IA1PR12MB9500.namprd12.prod.outlook.com (2603:10b6:208:596::17) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8356.21; Wed, 22 Jan 2025 20:22:36 +0000 Received: from CH1PEPF0000A34B.namprd04.prod.outlook.com (2603:10b6:610:118:cafe::f7) by CH0PR03CA0320.outlook.office365.com (2603:10b6:610:118::25) with Microsoft SMTP Server (version=TLS1_3, cipher=TLS_AES_256_GCM_SHA384) id 15.20.8356.22 via Frontend Transport; Wed, 22 Jan 2025 20:22:36 +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 CH1PEPF0000A34B.mail.protection.outlook.com (10.167.244.10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.8377.8 via Frontend Transport; Wed, 22 Jan 2025 20:22: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, 22 Jan 2025 14:22:32 -0600 From: Babu Moger To: , , , , , , , CC: , , , , , , , , , , , , , , , , , , , , , , , , , , Subject: [PATCH v11 13/23] x86/resctrl: Add data structures and definitions for ABMC assignment Date: Wed, 22 Jan 2025 14:20:21 -0600 Message-ID: <27c267e80f224296eb37a5212ad6e6cbe8584c19.1737577229.git.babu.moger@amd.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: References: Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-ClientProxiedBy: SATLEXMB04.amd.com (10.181.40.145) To SATLEXMB04.amd.com (10.181.40.145) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CH1PEPF0000A34B:EE_|IA1PR12MB9500:EE_ X-MS-Office365-Filtering-Correlation-Id: 15221b69-b39b-4612-81b6-08dd3b228268 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|1800799024|7416014|36860700013|82310400026|376014|13003099007; X-Microsoft-Antispam-Message-Info: =?utf-8?B?VS94QlRhcnZ1bVNST1gvcm5HRE81b1EwYm5lK1o1SEQrb2oyU0dPSG5tQ1I2?= =?utf-8?B?WjFGNlI1Y2xxTm9nVkh5K2ZyTXN2cGdwaXd4QXFnN1E2L05pZXZHb0RHYUt0?= =?utf-8?B?SnRlL3RSeElMVnRmV1dNak1LQWsvbzVwRWVoYm1ZSUtwbytGK0RQUjB2T21l?= =?utf-8?B?SXBuLzV4MUJLd0xYZi9uSjlMU2ViMjhFKzRVYk4wZ2hGTGxVdTB6WTFvOFY5?= =?utf-8?B?NE5vUHhyVDRZTlJhcEdLUWdSMnRyeW1kcjU0TzZrTDVGZEFpWUdlUHg2dU5n?= =?utf-8?B?dDhSTnRreCtlMUt4T1dBK1VjQTF3R0VYdGVlNmFMMStHVFM3TzRTTHAwRDhr?= =?utf-8?B?bzV3dkJaMlRUTUtzaWVwS1g1Skt0UmlpRCtrdVd0dGc0eVhtblo4dklBV1NR?= =?utf-8?B?MTFZYXdPcnIxSmZrRFY5VmxxVVFBMXR1bzdJdHlPaldjNXZjeFl4TzRhTHdn?= =?utf-8?B?U0VTWHNQKzNGc3IwWHZBUjNMb1UzNWIyV3oranRKcEQvVEFjU2ljTVJrOUdL?= =?utf-8?B?WTRMcm8vcStxS3NaTXhyUVZqT2N6eGgxTXJCNnJIbnR1bmVYcTBtQkxCbnh1?= =?utf-8?B?MnUvL3N3czE0ejFOdEtGeG5aZ2V6Umc2WGtXdEtxckx5MGh2R1VIYitqYTF0?= =?utf-8?B?TGxaTmdZeW9vTkpQc3FCRnN0NnoyRlc5SzZxcjNSMElET1hhOWd3WWhTOTkw?= =?utf-8?B?Mm1MVXc2K0E5MUx5R2Jrdndnd3pIL1gvbGtVTXlvR00rblJMYjZOS1cwbHNL?= =?utf-8?B?bDRmT3FHQjRvZHdkQktoRDRVVStZRDJPTjFpQ05pMmd0eVBTSVJzTllzZ2Nr?= =?utf-8?B?UGRsRUFnQTNjTk5jaWZJRUdOencxdVdQanNJK1Rkcit0MDVCNjYvbHNaR3hu?= =?utf-8?B?UTlJalBSc1hjS2tEOUZNcHNnU2Z3eWloazR3Rm00QUk2cnNNdFZIV0Y3bTNF?= =?utf-8?B?Y3JDK1pZYTJSZ00xYjF1VkJPZlhlYlZpb0h5QnlOMTB2N3I4eWF0eUI0d0tR?= =?utf-8?B?c1ZiUVl2MnNwcjhZNDB0RlhjeU9aQm54K0U2NkxJUzJOb1dNOUJnR1p3aGdS?= =?utf-8?B?Z3Z3M0ppck1LK2MyQXk3eG05NTQ5WUp5MmNZajVBTTBHbnR1bm9ocGp2QVE1?= =?utf-8?B?MVd2ZHpCVTgwT1pBZFU3Unh3NTVjN1RpcG1oK0hBWEx1Nk54UWNHOFovWlht?= =?utf-8?B?SCt3dkRsc2J5L0EzcmZLa2xidGs1ckhJbmlEeTVSWWliQklSaUM2YWtibW5M?= =?utf-8?B?bkhnVzdEZWluMEpEaWVleE1GV1Q5RUJwYnNnL0VTTnE1STY0cWdVVmE4S0x1?= =?utf-8?B?S3Nlb0NYdkd3bnUweUVoS3EvcVh4N3dxSUZSRTY4WnVydW1QbUh3dEJGRnVN?= =?utf-8?B?NXQvUkhQUkRuVEx6ekIrbHc1Yk1TWkJyUG5UdWh1cUJjeW1oRkVTbEZ2elU2?= =?utf-8?B?bTBON0c0UXZFR3l1c29KRkZpVGxUY09FTlp1WFVtb05iTnE2M1VpeHRNWVRl?= =?utf-8?B?S2I3TjN4S1dWWXcxUnBGaG05ZEdvQ1NtaHgrRkNVbXBtNHcyV0Z2d3ZyTU44?= =?utf-8?B?WHJONWdHNEFGUm55U21aRjROOGt3dkRuYXpPRDFtZGJXbTVTQlo2clhEUEVk?= =?utf-8?B?emtTWmV4UE1WTWQvWlF0SVZBbk52RVdRUENmbFZ5SGRXNUl0cVVQVTdGaGg3?= =?utf-8?B?NktMNXZsK2hwQTQ5VGJjRUlucTBJWjNKc01iYWFEckpBNGxJS1BnVmFhN0JE?= =?utf-8?B?Q2xBVHZhQ0FxdTNWT1Y0bkdBUHh6Vzd5bTVnUko4QUcrdzNxRVJnOXN1SGtx?= =?utf-8?B?MDl4VVgxK2dvbzNJUzM5ZzJXb0JGQmVGU2szaG1ua3dkYzZlTlU5MEVaam5B?= =?utf-8?B?c0JUdkJGTXc1SDdzcllOYzR4cFFlUEFWcVdCK1g4a3lnYUEvR0ZNS0pXOUx6?= =?utf-8?Q?93eZXVAyvQg0iEAuLIQOB1i5/HEzJdUs?= 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)(36860700013)(82310400026)(376014)(13003099007);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 22 Jan 2025 20:22:35.8354 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 15221b69-b39b-4612-81b6-08dd3b228268 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: CH1PEPF0000A34B.namprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: IA1PR12MB9500 The ABMC feature provides an option to the user to assign a hardware counter to an RMID, event pair and monitor the bandwidth as long as the counter is assigned. The bandwidth events will be tracked by the hardware until the user changes the configuration. Each resctrl group can configure maximum two counters, one for total event and one for local event. The ABMC feature implements an MSR L3_QOS_ABMC_CFG (C000_03FDh). Configuration is done by setting the counter id, bandwidth source (RMID) and bandwidth configuration supported by BMEC (Bandwidth Monitoring Event Configuration). Attempts to read or write the MSR when ABMC is not enabled will result in a #GP(0) exception. Introduce the data structures and definitions for MSR L3_QOS_ABMC_CFG (0xC000_03FDh): =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D Bits Mnemonic Description Access Reset Type Value =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D 63 CfgEn Configuration Enable R/W 0 62 CtrEn Enable/disable counting R/W 0 61:53 =E2=80=93 Reserved MBZ 0 52:48 CtrID Counter Identifier R/W 0 47 IsCOS BwSrc field is a CLOSID R/W 0 (not an RMID) 46:44 =E2=80=93 Reserved MBZ 0 43:32 BwSrc Bandwidth Source R/W 0 (RMID or CLOSID) 31:0 BwType Bandwidth configuration R/W 0 to track for this counter =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D The feature details are documented in the APM listed below [1]. [1] AMD64 Architecture Programmer's Manual Volume 2: System Programming Publication # 24593 Revision 3.41 section 19.3.3.3 Assignable Bandwidth Monitoring (ABMC). Link: https://bugzilla.kernel.org/show_bug.cgi?id=3D206537 Signed-off-by: Babu Moger Reviewed-by: Reinette Chatre --- v11: No changes. v10: No changes. v9: Removed the references of L3_QOS_ABMC_DSC. Text changes about configuration in kernel doc. v8: Update the configuration notes in kernel_doc. Few commit message update. v7: Removed the reference of L3_QOS_ABMC_DSC as it is not used anymore. Moved the configuration notes to kernel_doc. Adjusted the tabs for l3_qos_abmc_cfg and checkpatch seems happy. v6: Removed all the fs related changes. Added note on CfgEn,CtrEn. Removed the definitions which are not used. Removed cntr_id initialization. v5: Moved assignment flags here (path 10/19 of v4). Added MON_CNTR_UNSET definition to initialize cntr_id's. More details in commit log. Renamed few fields in l3_qos_abmc_cfg for readability. v4: Added more descriptions. Changed the name abmc_ctr_id to ctr_id. Added L3_QOS_ABMC_DSC. Used for reading the configuration. v3: No changes. v2: No changes. --- arch/x86/include/asm/msr-index.h | 1 + arch/x86/kernel/cpu/resctrl/internal.h | 35 ++++++++++++++++++++++++++ 2 files changed, 36 insertions(+) diff --git a/arch/x86/include/asm/msr-index.h b/arch/x86/include/asm/msr-in= dex.h index fea1f3afe197..e753a3332496 100644 --- a/arch/x86/include/asm/msr-index.h +++ b/arch/x86/include/asm/msr-index.h @@ -1197,6 +1197,7 @@ /* - AMD: */ #define MSR_IA32_MBA_BW_BASE 0xc0000200 #define MSR_IA32_SMBA_BW_BASE 0xc0000280 +#define MSR_IA32_L3_QOS_ABMC_CFG 0xc00003fd #define MSR_IA32_L3_QOS_EXT_CFG 0xc00003ff #define MSR_IA32_EVT_CFG_BASE 0xc0000400 =20 diff --git a/arch/x86/kernel/cpu/resctrl/internal.h b/arch/x86/kernel/cpu/r= esctrl/internal.h index cfaea20145d0..acac7972cea4 100644 --- a/arch/x86/kernel/cpu/resctrl/internal.h +++ b/arch/x86/kernel/cpu/resctrl/internal.h @@ -617,6 +617,41 @@ struct mon_config_info { u32 mon_config; }; =20 +/* + * ABMC counters are configured by writing to L3_QOS_ABMC_CFG. + * @bw_type : Bandwidth configuration (supported by BMEC) + * tracked by the @cntr_id. + * @bw_src : Bandwidth source (RMID or CLOSID). + * @reserved1 : Reserved. + * @is_clos : @bw_src field is a CLOSID (not an RMID). + * @cntr_id : Counter identifier. + * @reserved : Reserved. + * @cntr_en : Counting enable bit. + * @cfg_en : Configuration enable bit. + * + * Configuration and counting: + * Counter can be configured across multiple writes to MSR. Configuration + * is applied only when @cfg_en =3D 1. Counter @cntr_id is reset when the + * configuration is applied. + * @cfg_en =3D 1, @cntr_en =3D 0 : Apply @cntr_id configuration but do not + * count events. + * @cfg_en =3D 1, @cntr_en =3D 1 : Apply @cntr_id configuration and start + * counting events. + */ +union l3_qos_abmc_cfg { + struct { + unsigned long bw_type :32, + bw_src :12, + reserved1: 3, + is_clos : 1, + cntr_id : 5, + reserved : 9, + cntr_en : 1, + cfg_en : 1; + } split; + unsigned long full; +}; + void rdt_last_cmd_clear(void); void rdt_last_cmd_puts(const char *s); __printf(1, 2) --=20 2.34.1 From nobody Wed Feb 11 05:40:54 2026 Received: from NAM12-MW2-obe.outbound.protection.outlook.com (mail-mw2nam12on2053.outbound.protection.outlook.com [40.107.244.53]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id E6BC5217650; Wed, 22 Jan 2025 20:22:45 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.244.53 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1737577367; cv=fail; b=hYCZpDhR6gD37mVJ+XG7R4UOxXnY4gKn0gAKWBx5lHAvujzPWwmgPvYuYMOBaWPvRJ3QRB2m8DiUcoaBF79V13JkkIH1EeO68oUBN812ylx849nC6FppHLqbaELZYdrQOBRipzZss5WYTCpmUQkr0CLz6f60Q2bEtJF2Yl64Z98= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1737577367; c=relaxed/simple; bh=gDf5ctQu9T03Zw1e/1xUxcxP7tvtyDM8agu2isvkt5I=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=Kib+cHzpRRWTOUplcQK5qRTVUKfHgrOfZyFc7NAK6K5gqunqiqQNScySPgI2el5NflF5OmHbKPd3kGCRBknp0qQhl6oRFckmiYuzVXLLltKkFq2rVdYllLwXM+5WSDz4dV3eelfk/JagFKmq8OhtPN4WLycZgW7m9DOyzTaOpcU= 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=Rm+HqhGm; arc=fail smtp.client-ip=40.107.244.53 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=amd.com Authentication-Results: smtp.subspace.kernel.org; spf=fail smtp.mailfrom=amd.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=amd.com header.i=@amd.com header.b="Rm+HqhGm" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=se10gngT1QAD3nAEYGA1zWBBqkbkOtV4XglwSdAi6EOW/X2IW5DL0CRiBBe3b83zo5gYhMSQlsPARwzJSZLwFKIjHarrNCgkHjy1Is1Dusug+zdQklHx4MZowpPNg6ArqmAuA8rNWnkPnS+L8vq81MfHMmz7SoE1fWc+6qJT/JnbE5V6llLAKpkk2+iWgaRXYEmp8MPebJwa2xReuxyoFdHcFx1F3YhzcCZbVqzcI5MjV5PwA3vLcqm0ZmFE+RjCh/GmLhsBjduOE4KY5nXd7i4NVx/1yQvzHv+q2Pz6BM0ivYvJgl8liDoBhkwiECL1kdW2qHu0Nj7gQCM+oJmFkg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=NldGWrSe+l/6V6uxIG10ecigrz2lLAJmP6Zb5xBW8C4=; b=Ri1GDPbhKNJxHxBLfwsoA4vaxELmQa460dlgq1WjZBd0P1/7UMRtue9sn3rTJyZMN3ZRlrXhlWFCtBDiSaSSto6yiwrrjI00LXdTlIzjCM0g7Bg+NSVq73sJvwYObXyxMxZVwukrE2z8U3R0wEgSak/11NYmVy4+hbMskqXBZ57Baix7RdauZf5ELZfDHMZiV5tfMyQZ+J5SnWaWno+m7J9MIRBddlmffMvJ9eBrVzhK+VveziDi6TDtqEgbO+EpG2VGq4x7y63jK2tj2g5mF216bTDZ3MlLnhQ3o1c3Bg5HvBfsqUCe0NqOOi92j1c1B6ZIkIJZi8OBc4qZmRo/yw== 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=NldGWrSe+l/6V6uxIG10ecigrz2lLAJmP6Zb5xBW8C4=; b=Rm+HqhGmkyHcJzEBLjUTkTBdQqP0lHFNDGe98CykGsQIjOgk/jG6qm/zXLkMv1K1HJyvs+pgPAbuD+H2Kaq6SHTMxcm/SolobfoRa8bQZBHnxNHDhh/IEBuPpJDN8Fx4iBS4la6+Nbpm/hgI01sYyE26MJp4efnuoJ03IwWBEPA= Received: from CH2PR07CA0001.namprd07.prod.outlook.com (2603:10b6:610:20::14) by PH7PR12MB7281.namprd12.prod.outlook.com (2603:10b6:510:208::6) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8356.21; Wed, 22 Jan 2025 20:22:42 +0000 Received: from CH1PEPF0000A34A.namprd04.prod.outlook.com (2603:10b6:610:20:cafe::ee) by CH2PR07CA0001.outlook.office365.com (2603:10b6:610:20::14) with Microsoft SMTP Server (version=TLS1_3, cipher=TLS_AES_256_GCM_SHA384) id 15.20.8356.22 via Frontend Transport; Wed, 22 Jan 2025 20:22:42 +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 CH1PEPF0000A34A.mail.protection.outlook.com (10.167.244.5) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.8377.8 via Frontend Transport; Wed, 22 Jan 2025 20:22:42 +0000 Received: from bmoger-ubuntu.amd.com (10.180.168.240) by SATLEXMB04.amd.com (10.181.40.145) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.39; Wed, 22 Jan 2025 14:22:40 -0600 From: Babu Moger To: , , , , , , , CC: , , , , , , , , , , , , , , , , , , , , , , , , , , Subject: [PATCH v11 14/23] x86/resctrl: Implement resctrl_arch_config_cntr() to assign a counter with ABMC Date: Wed, 22 Jan 2025 14:20:22 -0600 Message-ID: X-Mailer: git-send-email 2.34.1 In-Reply-To: References: Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-ClientProxiedBy: SATLEXMB04.amd.com (10.181.40.145) To SATLEXMB04.amd.com (10.181.40.145) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CH1PEPF0000A34A:EE_|PH7PR12MB7281:EE_ X-MS-Office365-Filtering-Correlation-Id: bef3080e-1c17-4d95-8078-08dd3b22862e X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|36860700013|1800799024|82310400026|376014|7416014; X-Microsoft-Antispam-Message-Info: =?us-ascii?Q?ej7P/tqOIT+qfn3ZRzSlEuIsghes+jvKDg2rYHmEZueUvM1+FLHWwwdaceTK?= =?us-ascii?Q?ALqbu2F1IhKb5c3L3h0EKlxtFgMv9PRWtVGg++LP7DquhukApnPSfHjXYWy3?= =?us-ascii?Q?NaR2ytH2Vp8c6G6zkOw8sFVWn9nEgq69j5eo6I2WCIccEIPjo4k/tvaqeIOK?= =?us-ascii?Q?EzXfuE8B9hviXBn/j//X7ID16DjtGZzU4Qe8zqbwS6m/V5OobPWxiGYw1UdL?= =?us-ascii?Q?pSPlWaQckMQnbC1Lg+nYdRrSZcgpIdRJ7AElq7nAYbCoLccOqGGtOEsRBuh9?= =?us-ascii?Q?Y+BxnxfqdNMBajHBb/WrwACgotnZBloGAasqODESYVfR2VZv1CpiVNLiDVUP?= =?us-ascii?Q?EAzuEPe03MvVBQQN+L/bLaJAyizSwEeGsF0JQNOl9i4H9wKcOYY3//SF6CuK?= =?us-ascii?Q?TbeAjjIBejOagnM37EISALl3ujmIWxCCGy1UQIs+W9tHTQQUyV6dJq1Xify/?= =?us-ascii?Q?OdjY1jcmMGDCUGp+oxua/P3KJFQ1BzXlhy0uPh35+xGsEGLMbZgbBqTpahwX?= =?us-ascii?Q?1qiQcMfdk+7VH1Uv1GGtJqsq+nAXqnJ6zBJugt0T+InM9NGxzA7vKrfOUnJA?= =?us-ascii?Q?Q55+wupPnPgQgC3q8uH5YNMh0mlsvOtDpLYYe3LJe9lt5AjnjNfTD7FU3pvB?= =?us-ascii?Q?vkO13LBBAUBjTHlwBLEiXZ6c/0gJ4tNDfP/h4Ap7n2qOEf2hwEc8MA0uuiWd?= =?us-ascii?Q?Bv+K763moNkIcFFwfNwBB2uMFMGQ2m1+ghGxiwwQQm2EkczujBV6a0eJFu1Y?= =?us-ascii?Q?dW/58JHrl9lANHBXH+4TlmSLyOWkwwSt0LTcICvMsBZB25S7nMV/SmBR7ISu?= =?us-ascii?Q?1YWuDnGiD+M8oMrDZXT/00mrBk+SasIMn06SZ7CS5Y6NdqE5VyA3bVYbh7z/?= =?us-ascii?Q?9T7GSODK4h0xCTTjjsGtanytH068djWn5l1JDiVx+JKsTOF65nxtdY5PBs1l?= =?us-ascii?Q?rlbiSNBnQvgg/5v6C2PWl7R+PM1geEFzOG1QMc9vuu8TF2sHCcXMKW7+7QRz?= =?us-ascii?Q?L/Jej+kx1/OB3NZHbvLJkBjKPeSHk9VwX8TdUvZ+ofegIKNKlWdsDe3DsLXm?= =?us-ascii?Q?tBMBA8KbsUZ/PVIQd7rhW8uMOhoFvjfYMR3HxEyZh4I/D1MAZh70dm0fqxFE?= =?us-ascii?Q?VlIiqT95TLa1ROUdc53HGp2YjkPt57IR+svetJ2m6iKRl5JgtFpGPA77R4Oe?= =?us-ascii?Q?N0Xe+9g9/tRzEZhGMzypH3rUKmBZPJqbZuDF8TVfBwbbDLoQqvJ5Is4ug4I2?= =?us-ascii?Q?zmZIssT00ISkOCsb6A9vl4id4csCWpchR8AeE2Daf1lVtdOWtBs+8ixCDv2n?= =?us-ascii?Q?Z4uyvfWFPF5pW6mObe02l1cH0MajiwBOjebMtMGgHU+9XcLl76+FYaMiMK58?= =?us-ascii?Q?fRUVjdOc3UiOHgflJKlq1ijJ6w/EadaNX8yxHI2qBMNilb/uIsMsvqnReAWT?= =?us-ascii?Q?SuW91/gwWbcnt56mH1YrL0w3LRaMXHVP?= X-Forefront-Antispam-Report: CIP:165.204.84.17;CTRY:US;LANG:en;SCL:1;SRV:;IPV:CAL;SFV:NSPM;H:SATLEXMB04.amd.com;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(13230040)(36860700013)(1800799024)(82310400026)(376014)(7416014);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 22 Jan 2025 20:22:42.1818 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: bef3080e-1c17-4d95-8078-08dd3b22862e 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: CH1PEPF0000A34A.namprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH7PR12MB7281 Content-Type: text/plain; charset="utf-8" The ABMC feature provides an option to the user to assign a hardware counter to an RMID, event pair and monitor the bandwidth as long as it is assigned. The assigned RMID will be tracked by the hardware until the user unassigns it manually. Implement an architecture-specific handler to assign and unassign the counter. Configure counters by writing to the L3_QOS_ABMC_CFG MSR, specifying the counter ID, bandwidth source (RMID), and event configuration. The feature details are documented in the APM listed below [1]. [1] AMD64 Architecture Programmer's Manual Volume 2: System Programming Publication # 24593 Revision 3.41 section 19.3.3.3 Assignable Bandwidth Monitoring (ABMC). Link: https://bugzilla.kernel.org/show_bug.cgi?id=3D206537 Signed-off-by: Babu Moger --- v11: Moved resctrl_arch_assign_cntr() and resctrl_abmc_config_one_amd() to monitor.c. Added the code to reset the arch state in resctrl_arch_assign_cntr(). Also removed resctrl_arch_reset_rmid() inside IPI as the counters are reset from the callers. Re-wrote commit message. v10: Added call resctrl_arch_reset_rmid() to reset the RMID in the domain inside IPI call. SMP and non-SMP call support is not required in resctrl_arch_config_cn= tr with new domain specific assign approach/data structure. Commit message update. v9: Removed the code to reset the architectural state. It will done in another patch. v8: Rename resctrl_arch_assign_cntr to resctrl_arch_config_cntr. v7: Separated arch and fs functions. This patch only has arch implementatio= n. Added struct rdt_resource to the interface resctrl_arch_assign_cntr. Rename rdtgroup_abmc_cfg() to resctrl_abmc_config_one_amd(). v6: Removed mbm_cntr_alloc() from this patch to keep fs and arch code separate. Added code to update the counter assignment at domain level. v5: Few name changes to match cntr_id. Changed the function names to rdtgroup_assign_cntr resctr_arch_assign_cntr More comments on commit log. Added function summary. v4: Commit message update. User bitmap APIs where applicable. Changed the interfaces considering MPAM(arm). Added domain specific assignment. v3: Removed the static from the prototype of rdtgroup_assign_abmc. The function is not called directly from user anymore. These 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/monitor.c | 42 ++++++++++++++++++++++++++ 2 files changed, 45 insertions(+) diff --git a/arch/x86/kernel/cpu/resctrl/internal.h b/arch/x86/kernel/cpu/r= esctrl/internal.h index acac7972cea4..161d3feb567c 100644 --- a/arch/x86/kernel/cpu/resctrl/internal.h +++ b/arch/x86/kernel/cpu/resctrl/internal.h @@ -724,4 +724,7 @@ unsigned int mon_event_config_index_get(u32 evtid); void resctrl_arch_mon_event_config_set(void *info); u32 resctrl_arch_mon_event_config_get(struct rdt_mon_domain *d, enum resctrl_event_id eventid); +int resctrl_arch_config_cntr(struct rdt_resource *r, struct rdt_mon_domain= *d, + enum resctrl_event_id evtid, u32 rmid, u32 closid, + u32 cntr_id, bool assign); #endif /* _ASM_X86_RESCTRL_INTERNAL_H */ diff --git a/arch/x86/kernel/cpu/resctrl/monitor.c b/arch/x86/kernel/cpu/re= sctrl/monitor.c index f2bf5b13465d..ef836bb69b9b 100644 --- a/arch/x86/kernel/cpu/resctrl/monitor.c +++ b/arch/x86/kernel/cpu/resctrl/monitor.c @@ -1371,3 +1371,45 @@ void resctrl_arch_mon_event_config_set(void *info) break; } } + +static void resctrl_abmc_config_one_amd(void *info) +{ + union l3_qos_abmc_cfg *abmc_cfg =3D info; + + wrmsrl(MSR_IA32_L3_QOS_ABMC_CFG, abmc_cfg->full); +} + +/* + * Send an IPI to the domain to assign the counter to RMID, event pair. + */ +int resctrl_arch_config_cntr(struct rdt_resource *r, struct rdt_mon_domain= *d, + enum resctrl_event_id evtid, u32 rmid, u32 closid, + u32 cntr_id, bool assign) +{ + struct rdt_hw_mon_domain *hw_dom =3D resctrl_to_arch_mon_dom(d); + union l3_qos_abmc_cfg abmc_cfg =3D { 0 }; + struct arch_mbm_state *am; + + abmc_cfg.split.cfg_en =3D 1; + abmc_cfg.split.cntr_en =3D assign ? 1 : 0; + abmc_cfg.split.cntr_id =3D cntr_id; + abmc_cfg.split.bw_src =3D rmid; + + /* 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; + else + abmc_cfg.split.bw_type =3D hw_dom->mbm_local_cfg; + + smp_call_function_any(&d->hdr.cpu_mask, resctrl_abmc_config_one_amd, &abm= c_cfg, 1); + + /* + * Reset the architectural state so that reading of hardware + * counter is not considered as an overflow in next update. + */ + am =3D get_arch_mbm_state(hw_dom, rmid, evtid); + if (am) + memset(am, 0, sizeof(*am)); + + return 0; +} --=20 2.34.1 From nobody Wed Feb 11 05:40:54 2026 Received: from NAM10-MW2-obe.outbound.protection.outlook.com (mail-mw2nam10on2074.outbound.protection.outlook.com [40.107.94.74]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 298C721765F; Wed, 22 Jan 2025 20:22:53 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.94.74 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1737577375; cv=fail; b=YIVx5RO8r2Nq2wZ7WT2kJ++EM3+QQxPbq9X3j0W794IWUlcwfw3o1I1VEp7khxATkvAete4sZQnXUlsfQ/jhuOFxTewTEjgOQPEadMJCT2jlCOjKIIdLyit4pK5V6g/bBo4/8vBY1ewxrD+yeE3cJMpbgTCUF88GJg26laJDduo= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1737577375; c=relaxed/simple; bh=9R6Ekz2ZrAjjVlQNo5RNEP9K6XAt5BJ95esM7mMsxn4=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=lGlBHODx83kWRFVvWQ1fkGGlCH6rP9iKO37U5+TBoroaVPWrS02xrLzvjSBGBAyqRcsdYXH+Wtx5zfto4lhAaPtb5ztUBdot6Kk6mI7zcwMvPsxLJPB5HuyMqS8/DyMdWPIBABiJUEWgmthWGLCXun15Vqmi/5MnZ2BeR0sIpz8= 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=wsPJvLpr; arc=fail smtp.client-ip=40.107.94.74 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=amd.com Authentication-Results: smtp.subspace.kernel.org; spf=fail smtp.mailfrom=amd.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=amd.com header.i=@amd.com header.b="wsPJvLpr" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=O+e2c4JX8OQU3aUb408uYH0aQDgdM4cU20RLPoWYomXEv3f+eIx0td3SWPm0VCpTxHWc0ysePFPczAVcFKEdsu3Ck0Ceoe72MP3YhdBfj6myTk7mNZbWtOjUUScVEeWy4ZxdSXrvFShQThKbEi6tn/eu4v1IbnKdA6r0dkIBSt1f287mWJP9eYhwPoFnhKuLEljs1y6SstYENJXXAE10TyvNbio6/KbJwW0mDtBDivkoHRUBxiKnboYCJQkdXqqOPO6FL4tgQCpB3VswVoV8rMvBjBhU0D7SSC9q1wDU6IfsiW36kpob3fA/qgllCZHN53cUm6/RutB9SsLsSYao4Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=WiAPZcQJ8g2SCBdeGvdHCAE5ygxsvP303rLpVgDEQPo=; b=JyN5od1uH936ctvNyja/oJBa906kIKD2XCUjFS3uYes9rlS9PE+8sSU8OL208JnCmnEISy8AVi2H8XpTS8dvvvJiPGXTq7o6uPIEvY3/FOrWDKwkxryUkpH+Uzemh4JAIiAA1gkTA0bF/C7574AXJGilm5OmLCRj55zm82gfeUYsujgste8r3btbcL5IDPdWP7xWKoMqscKiyAOId04wXYZG4bijtngOSLn5t5h+M4rSrBlU9PrCQRTmSlf4MaXzHVrA4kGozaJPYM8NRfM6mhO4P+lPZby4ARoqObIiW/BM9vxILhR4wBfI/+dBVmTgHvozsYD2p7AgV3UnNp2y3w== 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=WiAPZcQJ8g2SCBdeGvdHCAE5ygxsvP303rLpVgDEQPo=; b=wsPJvLprEUPCwR7pfXhA4rvlX+ns7qxkF2eNOauYt7yvmtRg5VBts2SvjFWBUoFToUvaZQYbQoWVdRUBfoARI0kT4AnorUM46ViVCpFhEmCFbQ2xMVrb0WQ5DHLFZ8QzrGaXxkihax6ZvNb5dLVl9y/L+4OHWT6Zn6oTreZR5t8= Received: from CH5PR05CA0019.namprd05.prod.outlook.com (2603:10b6:610:1f0::27) by MW6PR12MB8661.namprd12.prod.outlook.com (2603:10b6:303:23f::5) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8356.14; Wed, 22 Jan 2025 20:22:51 +0000 Received: from CH1PEPF0000A346.namprd04.prod.outlook.com (2603:10b6:610:1f0:cafe::d2) by CH5PR05CA0019.outlook.office365.com (2603:10b6:610:1f0::27) with Microsoft SMTP Server (version=TLS1_3, cipher=TLS_AES_256_GCM_SHA384) id 15.20.8377.13 via Frontend Transport; Wed, 22 Jan 2025 20:22:50 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 165.204.84.17) smtp.mailfrom=amd.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=amd.com; Received-SPF: Pass (protection.outlook.com: domain of amd.com designates 165.204.84.17 as permitted sender) receiver=protection.outlook.com; client-ip=165.204.84.17; helo=SATLEXMB04.amd.com; pr=C Received: from SATLEXMB04.amd.com (165.204.84.17) by CH1PEPF0000A346.mail.protection.outlook.com (10.167.244.11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.8377.8 via Frontend Transport; Wed, 22 Jan 2025 20:22:50 +0000 Received: from bmoger-ubuntu.amd.com (10.180.168.240) by SATLEXMB04.amd.com (10.181.40.145) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.39; Wed, 22 Jan 2025 14:22:48 -0600 From: Babu Moger To: , , , , , , , CC: , , , , , , , , , , , , , , , , , , , , , , , , , , Subject: [PATCH v11 15/23] x86/resctrl: Add the functionality to assigm MBM events Date: Wed, 22 Jan 2025 14:20:23 -0600 Message-ID: X-Mailer: git-send-email 2.34.1 In-Reply-To: References: Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-ClientProxiedBy: SATLEXMB04.amd.com (10.181.40.145) To SATLEXMB04.amd.com (10.181.40.145) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CH1PEPF0000A346:EE_|MW6PR12MB8661:EE_ X-MS-Office365-Filtering-Correlation-Id: cec54b71-170d-4813-5289-08dd3b228b37 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|36860700013|1800799024|7416014|376014|82310400026; X-Microsoft-Antispam-Message-Info: =?us-ascii?Q?7KmvaVv9mUlevyoy6by3MIRR1qCizNsoDZBV0mtNcvjBlkYNiXJzpPknzTXe?= =?us-ascii?Q?4mldeKlmM21EiHU7KteHLIKZ/ghfL3MVdFbGwnmp5LTMqbpxQRRNE9AqZul2?= =?us-ascii?Q?fAZO8B0l9cZoRqh9pIcowWIcA3cCK3TOqXGTCZLINakmu9lCyBDnXmjOMSbP?= =?us-ascii?Q?kzqurFIBcjyfWzr5jOGlgpMtvoIcBYNNHt0TvWz5JmXLclXk7mVpApGAB6lw?= =?us-ascii?Q?NvhNyR1IOwsKD8Bocn/xY3wI1CfUIRGTlLlblK9ZsOJSYb8SNbCK9v1yIotb?= =?us-ascii?Q?um68aV8/XE52/8FoItIOV4af8FA+oVyAj0j3MRqUye38d9aLY6V0Eddi1oRB?= =?us-ascii?Q?4vm6ZGn8od+ENCJiXg2++FeWiteFQRYtHsKb/bM/X8OJ8IjFt+VolX7psXH7?= =?us-ascii?Q?mIQzT06avYWE/OpurA0R1sclmvssrdczh8GIWjPBaEtAjqtPuwRxfOqtf7Ek?= =?us-ascii?Q?W8oMO2CbWN6c26KZB+C8LaPv4OmbH4EY8B4IGZQHYb01cfdMV31/4c02Zfbn?= =?us-ascii?Q?Yb16e1oA24eIHgRA9LCRE130C4NhKLZYKi6o7gDUETJdHrOWW2UYfH/+RL9v?= =?us-ascii?Q?9cnzfx+wwa7cdBjCsP+AF87uIETM7EXAm2MGnyB+W16Wds9f0/MfmXlc4Q+i?= =?us-ascii?Q?oBwzedaRn1vogcpnoJ3AFLUp6AhNe4bL2gqxmo6MW7jrc04QNM8ZgUqjN7SE?= =?us-ascii?Q?qKo4KzTP7V/6F5ktFTBLaI2/4Bjf16UhL5Aj09YuUeERh4H7l08D1FHGXSR3?= =?us-ascii?Q?oQ7P2+Wa9UwClQHPJOiOyv8u5dTeIySR1rp2iL7K9XOMIMgoqR3Qzzx+qhjb?= =?us-ascii?Q?yFViMi7wMnQ07Fdkt8B6JyF3B6laniM21oN1hbS1rFh9WDD4twkmnY+x1IFz?= =?us-ascii?Q?CQmqp+wx1eetxq/vLqrKBg2CekPyu6rKpegG/W7DBO0ygsNbh+WKWlgRoe07?= =?us-ascii?Q?qG+96tNgFDrKIdyqA0sn8NUMIjPjYdEfOfk6p4+ulnqqV/Lm/rfSrJ3APBur?= =?us-ascii?Q?6gpA/WkQMxsZTH6oBqn3O9JjfKnDSuTQQ8zj++804qw8EcU8p/T5Q0nxOcqy?= =?us-ascii?Q?auMhGHSLaGxdyJ7829Uqkz9g1ga1/X8xYgPJh9lvyyGXygI/UYJWq2NGCUR+?= =?us-ascii?Q?49Vmv4DZvdX4EYAYUNC98Eklqyf8kR1HJZWWfNiAVR3Qcmn0vXUeCYg5HFb3?= =?us-ascii?Q?3GT9o2ZV1z6ajD3n87CF4uly9s9Bxx0fccfM1+3Xc1tmtowZd3QBJywu2T+G?= =?us-ascii?Q?nfN1AWqS/VqI1EgissWHhb7VoUnVCdAJdxMw6NGrvsMF8j5H8WoegrVajntB?= =?us-ascii?Q?4y02T3KO/Ckh394BGJX7EM+9TlLFaUJbamVWnq4DhlNDpAvFn2TZT2LlFDt4?= =?us-ascii?Q?3ImPIsszDJdxLA+crP7d3l0YblvSnsxpx/1SZfg9VV7xLTulXmfY2cINVKKR?= =?us-ascii?Q?4+iW0A5G6bY=3D?= X-Forefront-Antispam-Report: CIP:165.204.84.17;CTRY:US;LANG:en;SCL:1;SRV:;IPV:CAL;SFV:NSPM;H:SATLEXMB04.amd.com;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(13230040)(36860700013)(1800799024)(7416014)(376014)(82310400026);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 22 Jan 2025 20:22:50.6282 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: cec54b71-170d-4813-5289-08dd3b228b37 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: CH1PEPF0000A346.namprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: MW6PR12MB8661 Content-Type: text/plain; charset="utf-8" The mbm_cntr_assign mode offers several counters that can be assigned to an RMID, event pair and monitor the bandwidth as long as it is assigned. Add the functionality to allocate and assign the counters to RMID, event pair in the domain. If all counters are in use, the kernel will show an error message: "Out of MBM assignable counters" when a new assignment is requested. Exit on the first failure when assigning counters across all the domains. Report the error in /sys/fs/resctrl/info/last_cmd_status. Signed-off-by: Babu Moger --- v11: Patch changed again quite a bit. Moved the functions to monitor.c. Renamed rdtgroup_assign_cntr_event() to resctrl_assign_cntr_event(). Refactored the resctrl_assign_cntr_event(). Added functionality to exit on the first error during assignment. Simplified mbm_cntr_free(). Removed the function mbm_cntr_assigned(). Will be using mbm_cntr_get()= to figure out if the counter is assigned or not. Updated commit message and code comments. v10: Patch changed completely. Counters are managed at the domain based on the discussion. https://lore.kernel.org/lkml/CALPaoCj+zWq1vkHVbXYP0znJbe6Ke3PXPWjtri5A= FgD9cQDCUg@mail.gmail.com/ Reset non-architectural MBM state. Commit message update. v9: Introduced new function resctrl_config_cntr to assign the counter, upda= te the bitmap and reset the architectural state. Taken care of error handling(freeing the counter) when assignment fails. Moved mbm_cntr_assigned_to_domain here as it used in this patch. Minor text changes. v8: Renamed rdtgroup_assign_cntr() to rdtgroup_assign_cntr_event(). Added the code to return the error if rdtgroup_assign_cntr_event fails. Moved definition of MBM_EVENT_ARRAY_INDEX to resctrl/internal.h. Updated typo in the comments. v7: New patch. Moved all the FS code here. Merged rdtgroup_assign_cntr and rdtgroup_alloc_cntr. Adde new #define MBM_EVENT_ARRAY_INDEX. --- arch/x86/kernel/cpu/resctrl/internal.h | 2 + arch/x86/kernel/cpu/resctrl/monitor.c | 105 +++++++++++++++++++++++++ 2 files changed, 107 insertions(+) diff --git a/arch/x86/kernel/cpu/resctrl/internal.h b/arch/x86/kernel/cpu/r= esctrl/internal.h index 161d3feb567c..547d8a4c8aba 100644 --- a/arch/x86/kernel/cpu/resctrl/internal.h +++ b/arch/x86/kernel/cpu/resctrl/internal.h @@ -727,4 +727,6 @@ u32 resctrl_arch_mon_event_config_get(struct rdt_mon_do= main *d, int resctrl_arch_config_cntr(struct rdt_resource *r, struct rdt_mon_domain= *d, enum resctrl_event_id evtid, u32 rmid, u32 closid, u32 cntr_id, bool assign); +int resctrl_assign_cntr_event(struct rdt_resource *r, struct rdt_mon_domai= n *d, + struct rdtgroup *rdtgrp, enum resctrl_event_id evtid); #endif /* _ASM_X86_RESCTRL_INTERNAL_H */ diff --git a/arch/x86/kernel/cpu/resctrl/monitor.c b/arch/x86/kernel/cpu/re= sctrl/monitor.c index ef836bb69b9b..127c4000a81a 100644 --- a/arch/x86/kernel/cpu/resctrl/monitor.c +++ b/arch/x86/kernel/cpu/resctrl/monitor.c @@ -1413,3 +1413,108 @@ int resctrl_arch_config_cntr(struct rdt_resource *r= , struct rdt_mon_domain *d, =20 return 0; } + +/* + * Configure the counter for the event, RMID pair for the domain. Reset the + * non-architectural state to clear all the event counters. + */ +static int resctrl_config_cntr(struct rdt_resource *r, struct rdt_mon_doma= in *d, + enum resctrl_event_id evtid, u32 rmid, u32 closid, + u32 cntr_id, bool assign) +{ + struct mbm_state *m; + int ret; + + ret =3D resctrl_arch_config_cntr(r, d, evtid, rmid, closid, cntr_id, assi= gn); + if (ret) + return ret; + + m =3D get_mbm_state(d, closid, rmid, evtid); + if (m) + memset(m, 0, sizeof(struct mbm_state)); + + return ret; +} + +static int mbm_cntr_get(struct rdt_resource *r, struct rdt_mon_domain *d, + struct rdtgroup *rdtgrp, enum resctrl_event_id evtid) +{ + int cntr_id; + + for (cntr_id =3D 0; cntr_id < r->mon.num_mbm_cntrs; cntr_id++) { + if (d->cntr_cfg[cntr_id].rdtgrp =3D=3D rdtgrp && + d->cntr_cfg[cntr_id].evtid =3D=3D evtid) + return cntr_id; + } + + return -ENOENT; +} + +static int mbm_cntr_alloc(struct rdt_resource *r, struct rdt_mon_domain *d, + struct rdtgroup *rdtgrp, enum resctrl_event_id evtid) +{ + int cntr_id; + + for (cntr_id =3D 0; cntr_id < r->mon.num_mbm_cntrs; cntr_id++) { + if (!d->cntr_cfg[cntr_id].rdtgrp) { + d->cntr_cfg[cntr_id].rdtgrp =3D rdtgrp; + d->cntr_cfg[cntr_id].evtid =3D evtid; + return cntr_id; + } + } + + return -ENOSPC; +} + +static void mbm_cntr_free(struct rdt_mon_domain *d, int cntr_id) +{ + memset(&d->cntr_cfg[cntr_id], 0, sizeof(struct mbm_cntr_cfg)); +} + +/* + * Allocate a fresh counter and configure the event if not assigned already + * else return success. + */ +static int resctrl_alloc_config_cntr(struct rdt_resource *r, struct rdt_mo= n_domain *d, + struct rdtgroup *rdtgrp, enum resctrl_event_id evtid) +{ + int cntr_id, ret =3D 0; + + if (mbm_cntr_get(r, d, rdtgrp, evtid) =3D=3D -ENOENT) { + cntr_id =3D mbm_cntr_alloc(r, d, rdtgrp, evtid); + if (cntr_id < 0) { + rdt_last_cmd_printf("Domain %d is Out of MBM assignable counter\n", + d->hdr.id); + return -ENOSPC; + } + + ret =3D resctrl_config_cntr(r, d, evtid, rdtgrp->mon.rmid, rdtgrp->closi= d, + cntr_id, true); + if (ret) { + rdt_last_cmd_printf("Assignment failed on domain %d\n", d->hdr.id); + mbm_cntr_free(d, cntr_id); + } + } + + return ret; +} + +/* + * Assign a hardware counter to event @evtid of group @rdtgrp. + * Counter will be assigned to all the domains if @d is NULL else + * the counter will be assigned to @d. + */ +int resctrl_assign_cntr_event(struct rdt_resource *r, struct rdt_mon_domai= n *d, + struct rdtgroup *rdtgrp, enum resctrl_event_id evtid) +{ + int ret =3D 0; + + if (!d) { + list_for_each_entry(d, &r->mon_domains, hdr.list) + ret =3D resctrl_alloc_config_cntr(r, d, rdtgrp, evtid); + } else { + ret =3D resctrl_alloc_config_cntr(r, d, rdtgrp, evtid); + } + + return ret; +} --=20 2.34.1 From nobody Wed Feb 11 05:40:54 2026 Received: from NAM02-BN1-obe.outbound.protection.outlook.com (mail-bn1nam02on2045.outbound.protection.outlook.com [40.107.212.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 C7276217727; Wed, 22 Jan 2025 20:23:04 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.212.45 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1737577389; cv=fail; b=Q8CbtgRj/AmHmqYcCjRYf+twHV3gcEZc7WGp+roH45HY9UrXFauI6Bo2u6+zRxFboiZJsCHEb9SvdYzFXm5FMTjSOFDoou4bzVCRwpuRAS60TXF5DMmW1h8FqkZCri1ipvwII9qRdhBIrCG/R50cMr+vwzlLB/k+9WaMLtfH288= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1737577389; c=relaxed/simple; bh=MJxlBahNn2vM3v4D1DGDck1K3HTDV0yhnHKOiw1pltM=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=jqvaN3piZhjjpE/HO14X+2v+PUoqi6NqjemvQLWVBmr5QVQOWFx8HuOJH++k3sZDC4fTs34DXmFf0BfLOaOs8f3R5gHUq+qF3ShACRUo/JiYOL8Mg5rtszZS4/tajMC5J3naAd45gKNF5gzCK0Mjq/31tQeDAY78uhrki2PnTig= 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=NLhM2rKO; arc=fail smtp.client-ip=40.107.212.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="NLhM2rKO" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=EV4gHOG3jhl2u3EZmW9ZQF7UkBDondrfUCgw5M9oJqdCEntUPuS3jLsX0OntUdSm1cMv9SchJODEhAdpUpKqTSJ4CeTXWsQPuKjmuCYVlBxziHZWuAhOKV5/aF6oeoCl5VP3EBSOtx/QnAKzMX8aAvFnq0a+pWPOO5FSV2j8dmQoqzFKT4j0S1pEjSjO2R3PwPyPQC9vGLlwVNE1LXP0hAF9ftQ1/M7OLX2D5yMBGFCLSpZ5aUH9SArd6Ea2PMJHiY2xfK6NDIGiL5KQDmDbugKNlnYZG1C9Op0fYxN3Nm8mY/qS8cF571t3rUEfGfbec+OE7O/mp2ZrvMRipzmJKA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=Qq8pDWkleqlwmfJqRtiEOnHYflH26TbxvDwKjimXhUA=; b=fvjzJfdc3Jw5WBFm/N3WYCRVq3Ez9p8a56Bo/ar2txzKiiVM0OTAzfv5zheJV8fM60gzUKS1XNj6GgL/fhLZx8XG0nsHjPknIm+clHP+WlQzxA+MNOGLiHfUuV+Yq/SaJC3Av5WXmxUTWn/XfKkMdIgibzKUYdqS/3O/t75pLqyJnh2h84r9GqC7YeCaFRUuj7x814cbNcds4GuiUTNgdysNOdtacBANLweO3vVdCGH4dE0erZe9ZRIKiZIh+VRiCKzQSAfnBf9QleTZ4ubrNJV5C8hHWhQMnrTPJVSsOOpDx80bEXq99eMMSKrvXx4tSVIUEXQZdDqTxdPUAWslCA== 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=Qq8pDWkleqlwmfJqRtiEOnHYflH26TbxvDwKjimXhUA=; b=NLhM2rKO4lN/Ohd2ZF/DjZT6K/hSa/RCRYVhI5WVqNoCqykE7qylWIpNsuLUOvQInAWeMkdzNnIjk6JY9VdpFnR0KHJ0qXmAUTcDQuxVL/54c0Fz79Df1BjK9HX95AY45pW+vkBbHa6nAbxYOCJQyOw3iRRESE1HsiBGbpnoz58= Received: from CH0PR03CA0427.namprd03.prod.outlook.com (2603:10b6:610:10e::30) by DM4PR12MB6064.namprd12.prod.outlook.com (2603:10b6:8:af::12) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8356.21; Wed, 22 Jan 2025 20:22:59 +0000 Received: from CH1PEPF0000A345.namprd04.prod.outlook.com (2603:10b6:610:10e:cafe::fe) by CH0PR03CA0427.outlook.office365.com (2603:10b6:610:10e::30) with Microsoft SMTP Server (version=TLS1_3, cipher=TLS_AES_256_GCM_SHA384) id 15.20.8356.22 via Frontend Transport; Wed, 22 Jan 2025 20:22: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 CH1PEPF0000A345.mail.protection.outlook.com (10.167.244.8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.8377.8 via Frontend Transport; Wed, 22 Jan 2025 20:22:58 +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, 22 Jan 2025 14:22:56 -0600 From: Babu Moger To: , , , , , , , CC: , , , , , , , , , , , , , , , , , , , , , , , , , , Subject: [PATCH v11 16/23] x86/resctrl: Add the functionality to unassigm MBM events Date: Wed, 22 Jan 2025 14:20:24 -0600 Message-ID: <36262057667c27acad777836cc1497b19cb7c06d.1737577229.git.babu.moger@amd.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: References: Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-ClientProxiedBy: SATLEXMB04.amd.com (10.181.40.145) To SATLEXMB04.amd.com (10.181.40.145) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CH1PEPF0000A345:EE_|DM4PR12MB6064:EE_ X-MS-Office365-Filtering-Correlation-Id: b420810e-be71-47e2-1046-08dd3b229029 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|1800799024|36860700013|376014|7416014|82310400026; X-Microsoft-Antispam-Message-Info: =?us-ascii?Q?0rja95xLL82JDeQ0fPaYgStFJNB54UGqB8uweW1uoW7ehhUOMr4jU8SJJ3se?= =?us-ascii?Q?zwlvbXGe5FddUisXX0VXQwpsXJY4ByGaY2W12EMdhE2oMMKb++JASupNz+fU?= =?us-ascii?Q?f859MqsoJR4ay78M315/0FIYBMj4goZFAafUSn9I8C/QD5u6UyIK+UFggFG3?= =?us-ascii?Q?kvIoPCL0sockV/NQIyEpei1PWpxowoY6MpPk4G4YZhnY6lyzUwp17IbOOBk3?= =?us-ascii?Q?lYYZlS88cRHiJzud662oTn0pLQ8B/rPvHJVaQ/aQEI2JYt+bcCdlp1zRDYLs?= =?us-ascii?Q?yZ8BaMoK9OvTw6KhcTkvlHa01cOB/N8e8wWHJZUXeVwh7hsy6rf5pek7jI91?= =?us-ascii?Q?jylwfTeu6vNrDi5+r1BOmXYXC7QlVchjZiufcQQrjHCgpmWX3bjrxTKpZFLd?= =?us-ascii?Q?t26LHoJ4lbTQtlRXLKWTfSIMxCpIJhl5evktDVGDEv9n4q2X1U/XvQ9GjudH?= =?us-ascii?Q?3kYd/SFkOcic+rOS02ZKuIzw5YhH2smYm44vDfNgL06klTi5QX+Z7HfAJpZO?= =?us-ascii?Q?CHDAqn5oJo6SZuw4722kbSwZItF9pYzYOy4E2rWGfEDIaDqB2co9jrZPJ8BG?= =?us-ascii?Q?H7DW7HD6UjSoAb8jEn8YbqoHPwXIKTOIx9Y2IvEh+vGHvG7Xi1OtxwHb3Ye3?= =?us-ascii?Q?BHwIxy+sBjhtqKECrzjnUThAZ2vLru4kvTABEnFJgkWJvXO0O9dFaUoouoUo?= =?us-ascii?Q?aQYx63/FQwh671EjFDoU8Bh+z01fSNqhLfMgCoHr98xTZ/svQ2jNYp3xnBzw?= =?us-ascii?Q?Huk955m0aiEdL/xB3yIfjTimSbl7aNVo4yBtrtfGKXTRdEVPNHZQx/nCO9sv?= =?us-ascii?Q?3ScAzp0dqpzZH1k971RnVcJIJJc12MI/5n+ck66XC6rTVRI5y/BdfisdT+0w?= =?us-ascii?Q?phNnyRs++0FFyDxbRcZH8FHJEFjOSQiryE6n8ytAMxZPefFrZ2H/0q9qVjSG?= =?us-ascii?Q?auEwCIKt6sp3ZZGhoVy4bLETq5wT9IBvt+XJ+XTC+oE+58qfEMBIAqRNE6Ta?= =?us-ascii?Q?+ULcYLAMnUo4QpzK+JatsC7frCKpAndrTiLXPaSDtUvZRBpjAC9jcvxRQg1f?= =?us-ascii?Q?TOLojvjYcPh1if91fTXFDfb1Q9BDR0wN7qsMogTUzeNgPUNbd+hatOZLuOaq?= =?us-ascii?Q?5I+wTblHzEmOY1k4Fsc7JNyHyvJust24vM6tXMcyUe3KH1uDxEbRm3LzIrX1?= =?us-ascii?Q?8SgNCRioS+6r5kKiJH6PrA1YLkQeIiDsRME1nr5b3HBim5ppiWROxQR3gJJO?= =?us-ascii?Q?iX7rAXD6e7XqLiWQ+sPc/EGg82gzgnXuU0rUJ7fkKsxnIapp3Xd6af5nVfor?= =?us-ascii?Q?SeOL/xiIL7uUrl9we9OW0/Bfb1BFUZGo7bkCJOR7qLYTyRYId4JhD7lR9grb?= =?us-ascii?Q?KjXYDmdGAsK6qqfRLZDNWWuutMRs53I7a/+qu2HsqWWjbFF9Jqq6XsIUYVgH?= =?us-ascii?Q?IvXmArUovrXfpF+XjJUYlk0ZZu2WtLh/?= X-Forefront-Antispam-Report: CIP:165.204.84.17;CTRY:US;LANG:en;SCL:1;SRV:;IPV:CAL;SFV:NSPM;H:SATLEXMB04.amd.com;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(13230040)(1800799024)(36860700013)(376014)(7416014)(82310400026);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 22 Jan 2025 20:22:58.9235 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: b420810e-be71-47e2-1046-08dd3b229029 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: CH1PEPF0000A345.namprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM4PR12MB6064 Content-Type: text/plain; charset="utf-8" The mbm_cntr_assign mode provides a limited number of hardware counters that can be assigned to an RMID, event pair to monitor bandwidth while assigned. If all counters are in use, the kernel will show an error message: "Out of MBM assignable counters" when a new assignment is requested. To make space for a new assignment, users must unassign an already assigned counter and retry the assignment again.. Add the functionality to unassign and free the counters in the domain. Signed-off-by: Babu Moger --- v11: Moved the functions to monitor.c. Renamed rdtgroup_unassign_cntr_event() to resctrl_unassign_cntr_event(= ). Refactored the resctrl_unassign_cntr_event(). Updated commit message and code comments. v10: Patch changed again. Counters are managed at the domain based on the discussion. https://lore.kernel.org/lkml/CALPaoCj+zWq1vkHVbXYP0znJbe6Ke3PXPWjtri5A= FgD9cQDCUg@mail.gmail.com/ commit message update. v9: Changes related to addition of new function resctrl_config_cntr(). The removed rdtgroup_mbm_cntr_is_assigned() as it was introduced already. Text changes to take care comments. v8: Renamed rdtgroup_mbm_cntr_is_assigned to mbm_cntr_assigned_to_domain Added return error handling in resctrl_arch_config_cntr(). v7: Merged rdtgroup_unassign_cntr and rdtgroup_free_cntr functions. Renamed rdtgroup_mbm_cntr_test() to rdtgroup_mbm_cntr_is_assigned(). Reworded the commit log little bit. v6: Removed mbm_cntr_free from this patch. Added counter test in all the domains and free if it is not assigned to any domains. v5: Few name changes to match cntr_id. Changed the function names to rdtgroup_unassign_cntr More comments on commit log. v4: Added domain specific unassign feature. Few name changes. v3: Removed the static from the prototype of rdtgroup_unassign_abmc. The function is not called directly from user anymore. These changes are related to global assignment interface. v2: No changes. --- arch/x86/kernel/cpu/resctrl/internal.h | 2 ++ arch/x86/kernel/cpu/resctrl/monitor.c | 39 ++++++++++++++++++++++++++ 2 files changed, 41 insertions(+) diff --git a/arch/x86/kernel/cpu/resctrl/internal.h b/arch/x86/kernel/cpu/r= esctrl/internal.h index 547d8a4c8aba..a5b8eadc7f5c 100644 --- a/arch/x86/kernel/cpu/resctrl/internal.h +++ b/arch/x86/kernel/cpu/resctrl/internal.h @@ -729,4 +729,6 @@ int resctrl_arch_config_cntr(struct rdt_resource *r, st= ruct rdt_mon_domain *d, u32 cntr_id, bool assign); int resctrl_assign_cntr_event(struct rdt_resource *r, struct rdt_mon_domai= n *d, struct rdtgroup *rdtgrp, enum resctrl_event_id evtid); +int resctrl_unassign_cntr_event(struct rdt_resource *r, struct rdt_mon_dom= ain *d, + struct rdtgroup *rdtgrp, enum resctrl_event_id evtid); #endif /* _ASM_X86_RESCTRL_INTERNAL_H */ diff --git a/arch/x86/kernel/cpu/resctrl/monitor.c b/arch/x86/kernel/cpu/re= sctrl/monitor.c index 127c4000a81a..b6d188d0f9b7 100644 --- a/arch/x86/kernel/cpu/resctrl/monitor.c +++ b/arch/x86/kernel/cpu/resctrl/monitor.c @@ -1518,3 +1518,42 @@ int resctrl_assign_cntr_event(struct rdt_resource *r= , struct rdt_mon_domain *d, =20 return ret; } + +/* + * Unassign and free the counter if assigned else return success. + */ +static int resctrl_free_config_cntr(struct rdt_resource *r, struct rdt_mon= _domain *d, + struct rdtgroup *rdtgrp, enum resctrl_event_id evtid) +{ + int cntr_id, ret =3D 0; + + cntr_id =3D mbm_cntr_get(r, d, rdtgrp, evtid); + if (cntr_id !=3D -ENOENT) { + ret =3D resctrl_config_cntr(r, d, evtid, rdtgrp->mon.rmid, + rdtgrp->closid, cntr_id, false); + if (!ret) + mbm_cntr_free(d, cntr_id); + } + + return ret; +} + +/* + * Unassign a hardware counter associated with @evtid from the domain and + * the group. Unassign the counters from all the domains if @d is NULL else + * unassign from @d. + */ +int resctrl_unassign_cntr_event(struct rdt_resource *r, struct rdt_mon_dom= ain *d, + struct rdtgroup *rdtgrp, enum resctrl_event_id evtid) +{ + int ret =3D 0; + + if (!d) { + list_for_each_entry(d, &r->mon_domains, hdr.list) + ret =3D resctrl_free_config_cntr(r, d, rdtgrp, evtid); + } else { + ret =3D resctrl_free_config_cntr(r, d, rdtgrp, evtid); + } + + return ret; +} --=20 2.34.1 From nobody Wed Feb 11 05:40:54 2026 Received: from NAM04-DM6-obe.outbound.protection.outlook.com (mail-dm6nam04on2066.outbound.protection.outlook.com [40.107.102.66]) (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 95A7921772F; Wed, 22 Jan 2025 20:23:12 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.102.66 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1737577394; cv=fail; b=EqeFVY65RnPUTsCTSxPsDcz0T1BrRqeBNH+Ny95quZJ5bkC2bOmjFtzUVNqANHRxUV9vDdgU9TOwYx4UnmG/8zNEwLSSe5s6k76YCRCXxIKUXWtuhg7UY4sa0pCGwzyUyfkAvdFKK7iAK8aq68TukDOvllaDc055HJp1vVpywrg= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1737577394; c=relaxed/simple; bh=POYrs28rFVCWKlTPH0O/ZRWb6AbbZnImZv8hAXu2uzQ=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=r40iM+oBJa/eZTSaitdX0sOfg20kKSmPYvf3gBSzTGgTKIn+lo0tfYZkPXwtm7WBnfci+cSgGjo4pJdyj+LZpbBllI5vrUIax7dMHqVh+SLRAcE/T6UoG4bkLose2aIwCnAxRx2ml+l4ec9szC3jsXnlDmBLqaoWpNc6vRogMwQ= 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=FqgMw6aj; arc=fail smtp.client-ip=40.107.102.66 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="FqgMw6aj" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=LxmZMNfTFjLt0OSlGo/dLccfWST9c2mMBeo1rd1gHzjFi7iRYE5SMFEh099TptBIcLcryKsyrigV8keW1DX6PbDwJ+ScRN4IRhoIjz93OKeDBcA4fxJIC9356bL6FlY3r72Ss32ZPN4vNfEC5WkcDu69Ptm7pfw+VtL1jJW4mcSMuoYn59a79h6aJPI+wJ04yjTEA2onwGUWG/gAaMl37xpKSUnmfF+ibvM83LV6AeV+zBnC3fLBDdi9eOTeGx2OEy19Fn1M+lgnHyXhJCddL/vK8BSJTVracygjMbZBmh1FwkGsnqzYclWWFJzKdXlgoF8Ixv4GBcX9ykSv/pFfwA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=sS8ZpQdC+Xm62bHOkFdGffsgccGq15V9zKuRtXXI0LE=; b=DPT4xRdctFaAGWbFvfOxtKGuWcwOpMkgeOA/hTh565ym3ohKOlZ1SLNxtTDOPKK2g2QCdyJcpSp2WRqCCNWvBGzVxrTjVjijI6MGcaurx0Oho+K5HrIVpIuAnwbxdeoPr1Uczisr2VfzpGjMyCLUDha8tT52L8eB9BOqsI9hr0OdDX8ANql28EBFjXGCRpD8PhW3tFtM4LcOQFiKh9+oHjYTrXmY1pueOjXaQZUzp10WerRHeMNsJ640XvV6NzeBbAzndSSVdQVKYwEHElnajmEuoBouOYUGq8oYrZwoN6D9BDHYK8MF8A9oA1ynbD2GhIVTuJnQBIyau+OajoiOlw== 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=sS8ZpQdC+Xm62bHOkFdGffsgccGq15V9zKuRtXXI0LE=; b=FqgMw6ajBNM2+Qf5S83JBHW1PT+Ofp7tIP0DDeGDPmB1/dfdlUOnY+44+LbCoaMRXZCGUeJ0cPKf3k7BIoO76KiqH5UtrXkNWlZUCwSCO6kkqCFb8cb1+6yRBvGsm0aCc6d6rSyoFpo8+kdZS0NdgNrnxF4pmrH7X4qfFc0yF3I= Received: from CH0PR03CA0301.namprd03.prod.outlook.com (2603:10b6:610:118::11) by CY5PR12MB6132.namprd12.prod.outlook.com (2603:10b6:930:24::8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8356.18; Wed, 22 Jan 2025 20:23:07 +0000 Received: from CH1PEPF0000A34B.namprd04.prod.outlook.com (2603:10b6:610:118:cafe::ca) by CH0PR03CA0301.outlook.office365.com (2603:10b6:610:118::11) with Microsoft SMTP Server (version=TLS1_3, cipher=TLS_AES_256_GCM_SHA384) id 15.20.8356.21 via Frontend Transport; Wed, 22 Jan 2025 20:23: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 CH1PEPF0000A34B.mail.protection.outlook.com (10.167.244.10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.8377.8 via Frontend Transport; Wed, 22 Jan 2025 20:23:07 +0000 Received: from bmoger-ubuntu.amd.com (10.180.168.240) by SATLEXMB04.amd.com (10.181.40.145) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.39; Wed, 22 Jan 2025 14:23:05 -0600 From: Babu Moger To: , , , , , , , CC: , , , , , , , , , , , , , , , , , , , , , , , , , , Subject: [PATCH v11 17/23] x86/resctrl: Auto assign/unassign counters when mbm_cntr_assign is enabled Date: Wed, 22 Jan 2025 14:20:25 -0600 Message-ID: <2119b76ef8be21b1d8b2deedfab23e8e33ba724c.1737577229.git.babu.moger@amd.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: References: Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-ClientProxiedBy: SATLEXMB04.amd.com (10.181.40.145) To SATLEXMB04.amd.com (10.181.40.145) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CH1PEPF0000A34B:EE_|CY5PR12MB6132:EE_ X-MS-Office365-Filtering-Correlation-Id: 4cd1ba2e-8cb1-4e48-79ac-08dd3b229506 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|1800799024|376014|36860700013|82310400026|7416014; X-Microsoft-Antispam-Message-Info: =?us-ascii?Q?v7rRudAvMw/HkzHeeEkHbEhEHXZVW6CmRFto9uPm92TYiWZDsv4OjV9OGyQM?= =?us-ascii?Q?voSobCIyFx7Ml1UjAYiK0K3WYtmiLg1Ts5WohleAJli2zHfqy8ITAipZVAc5?= =?us-ascii?Q?KtGIKJIVWIxS5xI6qmQhmJjxQfYoqyFrpC75IkfMZk1ti/pAPJea9FIQpw0O?= =?us-ascii?Q?UnZWGLthV6ztFKc+HEJwWL9RKNQddGx6+CZnjSGEnnJxdvOzML4r8VmiGncs?= =?us-ascii?Q?OAQik48TlGrvaA+G2S2O27FQTw6zj9UILIs13QLhTb5L3DsuGbBTvSMbQCch?= =?us-ascii?Q?bIQnfWtM3uWx0o15MKR23NPqJpY08Nbn87nVvXlXpuAgxdqCd+UfHoOiShy/?= =?us-ascii?Q?bAHcAikvej0iroyV2DgWPw4tDTHgPR2p/RYNpg+XYf89pP2iXvfSQZreZFSy?= =?us-ascii?Q?QffJfShg4Eu13ndSxR8lP0lp55ANKLQwA2aEfl+8l8uXoXR+UUln3J2dRQ2m?= =?us-ascii?Q?JCnAlP2j0dL0ws2UfJjzcBZL3KeBFk8+3pDK5AiHctQLopbc/iXYu97tYSPf?= =?us-ascii?Q?JvZ5OFEZYs4U0j843Yq6SfVJ+o1vu9g7JqnUfVHP8HLmT6aZXI/Mmb3ocr+l?= =?us-ascii?Q?iO62PYYGcqI7Kq8GZzZJJNUTxP0JxATd3YjVEMAVxWCbmGfvlcbJqe1UiYRs?= =?us-ascii?Q?vvNRmjnyOFzSRh0BnTr2d+9XQNvlVNr4VYzGFEGNvd7n+JeWCA5S62gtoYHo?= =?us-ascii?Q?zhPQxIG5ESKrx+Lg+3MnFsQ2+b7IyMVjZPpuXGgsp/zaMywkSxgc29LU4zev?= =?us-ascii?Q?AIxMoj2mPbGD72QBcFazA/W31IYZ1lJ3J4aiwGHZJudkxabkYpmGS/Kb8uC2?= =?us-ascii?Q?J79tfVarApkLZQKqiHAxm489e0OvtsvfH0VLGFMgl62RYj2UdzRSNRugCnuA?= =?us-ascii?Q?teTIPfQ1yxgJFw+t+fzydogkXCXTsHDTEcacIkKwfrhL5+M3sPRLbGQIawEE?= =?us-ascii?Q?QmOR7PwjnmX2Xkecdh3HH+cMRBsZM9o0v3TNGn7BlY5WoCyCLqn8wU101oqU?= =?us-ascii?Q?HaoZ2OOzejHSn9/g/s5bv88tKJbNht7V5/yCmiPMgnaS0vj+AFzfFKrSRyiH?= =?us-ascii?Q?8eiJuZoB3DeaVDBWOdDjVc0pA0bu/M62FBHV2574gaPIR2x3ddAu8nVcKUc5?= =?us-ascii?Q?Jg8+0gjcL+i8uR/gs1kumoodpbUqzsb1GJeh3u15ftojZNtiRhSBuUi+7mXx?= =?us-ascii?Q?Myw86k1e45BnZAIL+kNxMzPjSydz0KITJzSONALLBBAjNoXiHM1INOSo+yZB?= =?us-ascii?Q?OQ+w02wN3fiMtPw9xuY7RqaA15sMYAa4abhU7HD/JdML9Lg0+8p6K1/aa8uf?= =?us-ascii?Q?gP6uiT7ToJdM881UWUfto8WZIMxN+itoJCQ/Fd3l1EwrxC5xzU4UD5pWSDCI?= =?us-ascii?Q?sA+HDUvG6j+xOyYo0Jd6HpAJotV1uKIcXAYC8KfBznDnyNVJ5CPVwMrWDRw0?= =?us-ascii?Q?sFJLsw1wyrAcA1x6Ftqip5jici/nYPPtDZ23uULTYjZqRyrIgnWN1ZyiXMYO?= =?us-ascii?Q?QBMcSVCpkLG1Byo=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)(82310400026)(7416014);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 22 Jan 2025 20:23:07.0697 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 4cd1ba2e-8cb1-4e48-79ac-08dd3b229506 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: CH1PEPF0000A34B.namprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: CY5PR12MB6132 Content-Type: text/plain; charset="utf-8" Assign/unassign counters on resctrl group creation/deletion. Two counters are required per group, one for MBM total event and one for MBM local event. There are a limited number of counters available for assignment. If these counters are exhausted, the kernel will display the error message: "Out of MBM assignable counters". However, it is not necessary to fail the creation of a group due to assignment failures. Users have the flexibility to modify the assignments at a later time. Signed-off-by: Babu Moger --- v11: Moved mbm_cntr_reset() to monitor.c. Added code reset non-architectural state in mbm_cntr_reset(). Added missing rdtgroup_unassign_cntrs() calls on failure path. v10: Assigned the counter before exposing the event files. Moved the call rdtgroup_assign_cntrs() inside mkdir_rdt_prepare_rmid_al= loc(). This is called both CNTR_MON and MON group creation. Call mbm_cntr_reset() when unmounted to clear all the assignments. Taken care of few other feedback comments. v9: Changed rdtgroup_assign_cntrs() and rdtgroup_unassign_cntrs() to return= void. Updated couple of rdtgroup_unassign_cntrs() calls properly. Updated function comments. v8: Renamed rdtgroup_assign_grp to rdtgroup_assign_cntrs. Renamed rdtgroup_unassign_grp to rdtgroup_unassign_cntrs. Fixed the problem with unassigning the child MON groups of CTRL_MON gro= up. v7: Reworded the commit message. Removed the reference of ABMC with mbm_cntr_assign. Renamed the function rdtgroup_assign_cntrs to rdtgroup_assign_grp. v6: Removed the redundant comments on all the calls of rdtgroup_assign_cntrs. Updated the commit message. Dropped printing error message on every call of rdtgroup_assign_cntrs. v5: Removed the code to enable/disable ABMC during the mount. That will be another patch. Added arch callers to get the arch specific data. Renamed fuctions to match the other abmc function. Added code comments for assignment failures. v4: Few name changes based on the upstream discussion. Commit message update. v3: This is a new patch. Patch addresses the upstream comment to enable ABMC feature by default if the feature is available. --- arch/x86/kernel/cpu/resctrl/internal.h | 1 + arch/x86/kernel/cpu/resctrl/monitor.c | 27 +++++++++++ arch/x86/kernel/cpu/resctrl/rdtgroup.c | 63 +++++++++++++++++++++++++- 3 files changed, 89 insertions(+), 2 deletions(-) diff --git a/arch/x86/kernel/cpu/resctrl/internal.h b/arch/x86/kernel/cpu/r= esctrl/internal.h index a5b8eadc7f5c..c979abb3d3b0 100644 --- a/arch/x86/kernel/cpu/resctrl/internal.h +++ b/arch/x86/kernel/cpu/resctrl/internal.h @@ -731,4 +731,5 @@ int resctrl_assign_cntr_event(struct rdt_resource *r, s= truct rdt_mon_domain *d, struct rdtgroup *rdtgrp, enum resctrl_event_id evtid); int resctrl_unassign_cntr_event(struct rdt_resource *r, struct rdt_mon_dom= ain *d, struct rdtgroup *rdtgrp, enum resctrl_event_id evtid); +void mbm_cntr_reset(struct rdt_resource *r); #endif /* _ASM_X86_RESCTRL_INTERNAL_H */ diff --git a/arch/x86/kernel/cpu/resctrl/monitor.c b/arch/x86/kernel/cpu/re= sctrl/monitor.c index b6d188d0f9b7..118b39fbb01e 100644 --- a/arch/x86/kernel/cpu/resctrl/monitor.c +++ b/arch/x86/kernel/cpu/resctrl/monitor.c @@ -1557,3 +1557,30 @@ int resctrl_unassign_cntr_event(struct rdt_resource = *r, struct rdt_mon_domain *d =20 return ret; } + +void mbm_cntr_reset(struct rdt_resource *r) +{ + u32 idx_limit =3D resctrl_arch_system_num_rmid_idx(); + struct rdt_mon_domain *dom; + + /* + * Reset the domain counter configuration. Hardware counters + * will reset after switching the monitor mode. So, reset the + * architectural amd non-architectural state so that reading + * of hardware counter is not considered as an overflow in the + * next update. + */ + if (is_mbm_enabled() && r->mon.mbm_cntr_assignable) { + list_for_each_entry(dom, &r->mon_domains, hdr.list) { + memset(dom->cntr_cfg, 0, + sizeof(*dom->cntr_cfg) * r->mon.num_mbm_cntrs); + if (is_mbm_total_enabled()) + memset(dom->mbm_total, 0, + sizeof(struct mbm_state) * idx_limit); + if (is_mbm_local_enabled()) + memset(dom->mbm_local, 0, + sizeof(struct mbm_state) * idx_limit); + resctrl_arch_reset_rmid_all(r, dom); + } + } +} diff --git a/arch/x86/kernel/cpu/resctrl/rdtgroup.c b/arch/x86/kernel/cpu/r= esctrl/rdtgroup.c index 2b86124c336b..f61f0cd032ef 100644 --- a/arch/x86/kernel/cpu/resctrl/rdtgroup.c +++ b/arch/x86/kernel/cpu/resctrl/rdtgroup.c @@ -2687,6 +2687,46 @@ static void schemata_list_destroy(void) } } =20 +/* + * Called when a new group is created. If "mbm_cntr_assign" mode is enable= d, + * counters are automatically assigned. Each group can accommodate two cou= nters: + * one for the total event and one for the local event. Assignments may fa= il + * due to the limited number of counters. However, it is not necessary to = fail + * the group creation and thus no failure is returned. Users have the opti= on + * to modify the counter assignments after the group has been created. + */ +static void rdtgroup_assign_cntrs(struct rdtgroup *rdtgrp) +{ + struct rdt_resource *r =3D &rdt_resources_all[RDT_RESOURCE_L3].r_resctrl; + + if (!resctrl_arch_mbm_cntr_assign_enabled(r)) + return; + + if (is_mbm_total_enabled()) + resctrl_assign_cntr_event(r, NULL, rdtgrp, QOS_L3_MBM_TOTAL_EVENT_ID); + + if (is_mbm_local_enabled()) + resctrl_assign_cntr_event(r, NULL, rdtgrp, QOS_L3_MBM_LOCAL_EVENT_ID); +} + +/* + * Called when a group is deleted. Counters are unassigned if it was in + * assigned state. + */ +static void rdtgroup_unassign_cntrs(struct rdtgroup *rdtgrp) +{ + struct rdt_resource *r =3D &rdt_resources_all[RDT_RESOURCE_L3].r_resctrl; + + if (!resctrl_arch_mbm_cntr_assign_enabled(r)) + return; + + if (is_mbm_total_enabled()) + resctrl_unassign_cntr_event(r, NULL, rdtgrp, QOS_L3_MBM_TOTAL_EVENT_ID); + + if (is_mbm_local_enabled()) + resctrl_unassign_cntr_event(r, NULL, rdtgrp, QOS_L3_MBM_LOCAL_EVENT_ID); +} + static int rdt_get_tree(struct fs_context *fc) { struct rdt_fs_context *ctx =3D rdt_fc2context(fc); @@ -2741,6 +2781,8 @@ static int rdt_get_tree(struct fs_context *fc) if (ret < 0) goto out_info; =20 + rdtgroup_assign_cntrs(&rdtgroup_default); + ret =3D mkdir_mondata_all(rdtgroup_default.kn, &rdtgroup_default, &kn_mondata); if (ret < 0) @@ -2779,8 +2821,10 @@ static int rdt_get_tree(struct fs_context *fc) if (resctrl_arch_mon_capable()) kernfs_remove(kn_mondata); out_mongrp: - if (resctrl_arch_mon_capable()) + if (resctrl_arch_mon_capable()) { + rdtgroup_unassign_cntrs(&rdtgroup_default); kernfs_remove(kn_mongrp); + } out_info: kernfs_remove(kn_info); out_schemata_free: @@ -2956,6 +3000,7 @@ static void free_all_child_rdtgrp(struct rdtgroup *rd= tgrp) =20 head =3D &rdtgrp->mon.crdtgrp_list; list_for_each_entry_safe(sentry, stmp, head, mon.crdtgrp_list) { + rdtgroup_unassign_cntrs(sentry); free_rmid(sentry->closid, sentry->mon.rmid); list_del(&sentry->mon.crdtgrp_list); =20 @@ -2996,6 +3041,8 @@ static void rmdir_all_sub(void) cpumask_or(&rdtgroup_default.cpu_mask, &rdtgroup_default.cpu_mask, &rdtgrp->cpu_mask); =20 + rdtgroup_unassign_cntrs(rdtgrp); + free_rmid(rdtgrp->closid, rdtgrp->mon.rmid); =20 kernfs_remove(rdtgrp->kn); @@ -3027,6 +3074,8 @@ static void rdt_kill_sb(struct super_block *sb) for_each_alloc_capable_rdt_resource(r) reset_all_ctrls(r); rmdir_all_sub(); + rdtgroup_unassign_cntrs(&rdtgroup_default); + mbm_cntr_reset(&rdt_resources_all[RDT_RESOURCE_L3].r_resctrl); rdt_pseudo_lock_release(); rdtgroup_default.mode =3D RDT_MODE_SHAREABLE; schemata_list_destroy(); @@ -3490,9 +3539,12 @@ static int mkdir_rdt_prepare_rmid_alloc(struct rdtgr= oup *rdtgrp) } rdtgrp->mon.rmid =3D ret; =20 + rdtgroup_assign_cntrs(rdtgrp); + ret =3D mkdir_mondata_all(rdtgrp->kn, rdtgrp, &rdtgrp->mon.mon_data_kn); if (ret) { rdt_last_cmd_puts("kernfs subdir error\n"); + rdtgroup_unassign_cntrs(rdtgrp); free_rmid(rdtgrp->closid, rdtgrp->mon.rmid); return ret; } @@ -3502,8 +3554,10 @@ static int mkdir_rdt_prepare_rmid_alloc(struct rdtgr= oup *rdtgrp) =20 static void mkdir_rdt_prepare_rmid_free(struct rdtgroup *rgrp) { - if (resctrl_arch_mon_capable()) + if (resctrl_arch_mon_capable()) { + rdtgroup_unassign_cntrs(rgrp); free_rmid(rgrp->closid, rgrp->mon.rmid); + } } =20 static int mkdir_rdt_prepare(struct kernfs_node *parent_kn, @@ -3764,6 +3818,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 /* @@ -3810,6 +3867,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 Wed Feb 11 05:40:54 2026 Received: from NAM12-DM6-obe.outbound.protection.outlook.com (mail-dm6nam12on2084.outbound.protection.outlook.com [40.107.243.84]) (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 E5461218589; Wed, 22 Jan 2025 20:23:19 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.243.84 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1737577402; cv=fail; b=EcWc553o2wHidBnyj80QrImX6sDNjBGb8jCYsr0FzghvV+t1KdaqYPL2jVXrtFqJGI07vFCUIfkguMN8c6qUFCcUk8Sic2/y6zkRDk+hQmTa+H5JdbOXgGp2tfA+/KswBecaUCTyeUBhIBBanqPqaggATtgkQA6XaO7aJ/nGkps= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1737577402; c=relaxed/simple; bh=QmLe1+4piIRdrYLVZbFXj38m0zIjCBMF+pKkZ3/aBMQ=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=HxXaK/q91ObSe3fRy/EN5MG17slDuca5lxVfBHmTUZIAkzAXvLlRuka16YpJeEE+h6IvH/62IwyeZsPL4IVaQ4k3wS2Gl5zU9a958O5usB8w8x6VvF0a3s/ksnhVMhlWLru5kFwgvkY48+U7vADmCLGLJxoOLAtu0uonA8VybcI= 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=bM++9uuT; arc=fail smtp.client-ip=40.107.243.84 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="bM++9uuT" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=LQCjqwSvs63lFzWTIWmCrPkcvfMMndbwBiDzLUHKVKnNi0gWNA1OtDhCN4yrUCbGDbCnGmFigDbRoyiGdm2kqj1sqnKIrjhtQrSCtO7empmaFL9qGTZw/uz2sv5g0YPj9BfwEsOBNCYlnJ4tFsGCcUYULtiWTXkT/XiDn1N2sF0S3qO+J5I/OXtp66/7elsVxVOKCOj3yk9gO20edIcbTNagohaLoLM8hgCmFO1TQKck0vAfWlm5ExHNgUVP6n8WooEkyrmYCXDSPOeubey/hiejmA4OFNvZCj3jnFWC/WAavvK5kWouO/vhXznXf6c9rGDpe/T3M+4KltW1fb+0lQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=KlEOkR1OSotvkCGt0xT1cQqUmI6uKhsD1QKydw+aoj4=; b=Du2kX2KFSypZHprRtrC/gQULHTudcqE15nIvDfr63ngOFdhxmMXZSGHL22DheBRbM0wwbfCkAxIjf0H/jLa48NjDut0F/IAtEGQvhRKbK0RYZYmlla8gdx6/8p4EU5xm88M+GvW1FmiISze2eU2crNLeRhmwfJwV6KFw8K+ePdABMNSHA2RoSCbPI3c9nTFOsIVCtIezzOhgIZS3/8wZUf3SueV4yvmhoaEtj0oOwjtBDrV87bFMzO1ox6uJFRWjzDDg0i4ciu2EVhsr+tZzbyVmbonydVTT75/5Lt5IZA+WL25gh0+iVVKEYxc71SnwkO/7RQYVIk5+VD3hTYoLPw== 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=KlEOkR1OSotvkCGt0xT1cQqUmI6uKhsD1QKydw+aoj4=; b=bM++9uuTc35TReNSjTv2HH8xgaSuCZBjr62yobNY8/gaVxP6dFbfYsvWyn1c8s8ERGOFz4eM9QHi0ZG6vVuLTL5xQEhpunjQL5CnEq6GgZ8BjU2/s2pFMI7+iO0H7GOpDFFHvaXcFSmjuPfG2HtMacr+kXZ8RUTKVuTe61r75PI= Received: from CH2PR15CA0002.namprd15.prod.outlook.com (2603:10b6:610:51::12) by PH7PR12MB5808.namprd12.prod.outlook.com (2603:10b6:510:1d4::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8356.22; Wed, 22 Jan 2025 20:23:15 +0000 Received: from CH1PEPF0000A349.namprd04.prod.outlook.com (2603:10b6:610:51:cafe::6c) by CH2PR15CA0002.outlook.office365.com (2603:10b6:610:51::12) with Microsoft SMTP Server (version=TLS1_3, cipher=TLS_AES_256_GCM_SHA384) id 15.20.8356.21 via Frontend Transport; Wed, 22 Jan 2025 20:23: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 CH1PEPF0000A349.mail.protection.outlook.com (10.167.244.9) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.8377.8 via Frontend Transport; Wed, 22 Jan 2025 20:23: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, 22 Jan 2025 14:23:13 -0600 From: Babu Moger To: , , , , , , , CC: , , , , , , , , , , , , , , , , , , , , , , , , , , Subject: [PATCH v11 18/23] x86/resctrl: Report "Unassigned" for MBM events in mbm_cntr_assign mode Date: Wed, 22 Jan 2025 14:20:26 -0600 Message-ID: <22cdafb381295c3802388613686d7b89a5e313c6.1737577229.git.babu.moger@amd.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: References: Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-ClientProxiedBy: SATLEXMB04.amd.com (10.181.40.145) To SATLEXMB04.amd.com (10.181.40.145) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CH1PEPF0000A349:EE_|PH7PR12MB5808:EE_ X-MS-Office365-Filtering-Correlation-Id: fe834b0a-df29-4e47-2795-08dd3b2299d1 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|7416014|36860700013|376014|82310400026|1800799024; X-Microsoft-Antispam-Message-Info: =?us-ascii?Q?HlITD0FYUuBfcfWSkd9ig/XDjmixVOGk5qTrI8ZariMrS3S77jH2pK38p5WT?= =?us-ascii?Q?h9bC2hK448Zgin4xAlq0FLZk2s2+t9LNA9lCNNjx8AdENzMuIf/7eINpIV77?= =?us-ascii?Q?/eDFrgNktLTYU3jaJwTeivdb8g7Sl2jeWl8TrbmxHphT1zxEyr1kTLQLXRaQ?= =?us-ascii?Q?yz3RorXu7smVa97E/sfM0R9qJptCuT1HqUQKcfRy1g5uFAGfcEvm5Kpx3QJP?= =?us-ascii?Q?Lxf7z5412BoRorgFkx2qOo5+Imj9cNPw3h87Al2r6zVqpEDKJ405Nfx2fm4N?= =?us-ascii?Q?mZ62UdQkPQw4NF5/ELTdgrvW0mEyRVK1PqdakxRPHMwcRqrldKS4b6VjLBnN?= =?us-ascii?Q?IGaV3C/eb2Q0QUjm7DMY9sAAtYZ3x3ySQPvydw+OPGKQDXeKGigfmjpC8hAM?= =?us-ascii?Q?rWU78hnFGOjoGWVUZadw2Yg802dQxJZBOO2ZDbvy+n4fTfoqefExnkL386Le?= =?us-ascii?Q?9um6rnrOaBIEW2yJzACjJuJw0avgMjAg+QlrSNhmsMMOMBqdLah4PM9r10jH?= =?us-ascii?Q?S25KQcwYoCh0gnugl6sY85SS69k1/kjw8nLaKGLWmMJU6OGpumFnCwg4xOAA?= =?us-ascii?Q?Y8LLr6Kdz/2IWPBBdZe/i2LbXJWH+thE1tXfGvarZypk4pICLYf2RWKVsQhc?= =?us-ascii?Q?37vquu4i1xJ+WisfOYgy0rNF5JAGXXG1AVaXoC86F0suSi4Mqt3YqqF3NQ50?= =?us-ascii?Q?XfWrp/XAGqFce9+u0WXEpX92yMlvriA0zmQlHrhorQqmnZWp6UEkEfLZ8AZU?= =?us-ascii?Q?Mdhpel683CxXdMkbfF5rJ2c8mLY8xNlwBwGNnaA/NU2VMVUujCq5j/duBPZK?= =?us-ascii?Q?Lu85wxY3K7fgRuouLo2su2Lw26wGOmO/zuSTLFuOBelbA5KLUiJsfa8vl02G?= =?us-ascii?Q?YlTANXvcQpRBmcPf95sOTL/jNiBSWvEphDoopisVa7YPPjYZUJ4XF7StP8or?= =?us-ascii?Q?HsVoHaPus605Mt7DfT7fI/62ZUcVf8T4zH/k3Jv2v2Zo6qPzKHmjC79sWhYk?= =?us-ascii?Q?v5mvPCxpn33vaQnDuhDd8Qv6R+L7SCo4S72YeApofFJjjUoh+fxCj4chgrSn?= =?us-ascii?Q?CSENpcS+xeMOoqqTLmEasyXLSerSxhVG36sgzrcTrf6ywaUDCP/XPaV5J4b5?= =?us-ascii?Q?vlwd0iD315qVfGwRLVroj+WgtkU1Zs3QqdWso4h+6RpEEmUgHHDn3TLaHvO9?= =?us-ascii?Q?o1Pcz/95L8uDZ59nUWSV60fV4fljh5DIn0Q0bs5ENndCJMT0JULBzepj7J09?= =?us-ascii?Q?SEZ2aut9eNTRSkKSzyezQBD63mPgXsVLN4/tUxkwaRJXCbdLRkMvRF5lcUFA?= =?us-ascii?Q?YdDNPehlBVIWlXoCQyAUGy6QCxUYs5yzXkMki2RC2DtS03pQEocy+2rH0pDW?= =?us-ascii?Q?BJTnzx5Hg/0r79aBmYjcYPmI6NHFnPGzyJB2Bie6bAVf1UEOWUYO9l8rzUVq?= =?us-ascii?Q?dyiDIXQrEl/H7vzDyls+6BmA5YtpSvYc3dpbzpn/goqZfgfE2lHAMKGIsWjO?= =?us-ascii?Q?O1zK/7qgiOfFlrs=3D?= X-Forefront-Antispam-Report: CIP:165.204.84.17;CTRY:US;LANG:en;SCL:1;SRV:;IPV:CAL;SFV:NSPM;H:SATLEXMB04.amd.com;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(13230040)(7416014)(36860700013)(376014)(82310400026)(1800799024);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 22 Jan 2025 20:23:15.1245 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: fe834b0a-df29-4e47-2795-08dd3b2299d1 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: CH1PEPF0000A349.namprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH7PR12MB5808 Content-Type: text/plain; charset="utf-8" In mbm_cntr_assign mode, the hardware counter should be assigned to read the MBM events. Report 'Unassigned' in case the user attempts to read the events without assigning the counter. Signed-off-by: Babu Moger --- v11: Domain can be NULL with SNC support so moved the unassign check in rdtgroup_mondata_show(). v10: Moved the code to check the assign state inside mon_event_read(). Fixed few text comments. v9: Used is_mbm_event() to check the event type. Minor user documentation update. v8: Used MBM_EVENT_ARRAY_INDEX to get the index for the MBM event. Documentation update to make the text generic. v7: Moved the documentation under "mon_data". Updated the text little bit. v6: Added more explaination in the resctrl.rst Added checks to detect "Unassigned" before reading RMID. v5: New patch. --- Documentation/arch/x86/resctrl.rst | 10 ++++++++++ arch/x86/kernel/cpu/resctrl/ctrlmondata.c | 13 +++++++++++++ arch/x86/kernel/cpu/resctrl/internal.h | 2 ++ arch/x86/kernel/cpu/resctrl/monitor.c | 4 ++-- 4 files changed, 27 insertions(+), 2 deletions(-) diff --git a/Documentation/arch/x86/resctrl.rst b/Documentation/arch/x86/re= sctrl.rst index 99cae75559b0..072b15550ff7 100644 --- a/Documentation/arch/x86/resctrl.rst +++ b/Documentation/arch/x86/resctrl.rst @@ -431,6 +431,16 @@ When monitoring is enabled all MON groups will also co= ntain: for the L3 cache they occupy). These are named "mon_sub_L3_YY" where "YY" is the node number. =20 + When supported the mbm_cntr_assign mode allows users to assign a + counter to mon_hw_id, event pair enabling bandwidth monitoring for + as long as the counter remains assigned. The hardware will continue + tracking the assigned mon_hw_id until the user manually unassigns + it, ensuring that counters are not reset during this period. With + a limited number of counters, the system may run out of assignable + counters. In that case, MBM event counters will return 'Unassigned' + when the event is read. Users must manually assign a counter to read + the events. + "mon_hw_id": Available only with debug option. The identifier used by hardware for the monitor group. On x86 this is the RMID. diff --git a/arch/x86/kernel/cpu/resctrl/ctrlmondata.c b/arch/x86/kernel/cp= u/resctrl/ctrlmondata.c index 536351159cc2..d00e77d08ef4 100644 --- a/arch/x86/kernel/cpu/resctrl/ctrlmondata.c +++ b/arch/x86/kernel/cpu/resctrl/ctrlmondata.c @@ -679,6 +679,17 @@ int rdtgroup_mondata_show(struct seq_file *m, void *ar= g) goto out; } d =3D container_of(hdr, struct rdt_mon_domain, hdr); + + /* + * Report 'Unassigned' if the mbm_cntr_assign mode is enabled and + * counter is unassigned + */ + if (resctrl_arch_mbm_cntr_assign_enabled(r) && is_mbm_event(evtid) && + (mbm_cntr_get(r, d, rdtgrp, evtid) =3D=3D -ENOENT)) { + rr.err =3D -ENOENT; + goto checkresult; + } + mon_event_read(&rr, r, d, rdtgrp, &d->hdr.cpu_mask, evtid, false); } =20 @@ -688,6 +699,8 @@ int rdtgroup_mondata_show(struct seq_file *m, void *arg) seq_puts(m, "Error\n"); else if (rr.err =3D=3D -EINVAL) seq_puts(m, "Unavailable\n"); + else if (rr.err =3D=3D -ENOENT) + seq_puts(m, "Unassigned\n"); else seq_printf(m, "%llu\n", rr.val); =20 diff --git a/arch/x86/kernel/cpu/resctrl/internal.h b/arch/x86/kernel/cpu/r= esctrl/internal.h index c979abb3d3b0..c006c4d8d6ff 100644 --- a/arch/x86/kernel/cpu/resctrl/internal.h +++ b/arch/x86/kernel/cpu/resctrl/internal.h @@ -732,4 +732,6 @@ int resctrl_assign_cntr_event(struct rdt_resource *r, s= truct rdt_mon_domain *d, int resctrl_unassign_cntr_event(struct rdt_resource *r, struct rdt_mon_dom= ain *d, struct rdtgroup *rdtgrp, enum resctrl_event_id evtid); void mbm_cntr_reset(struct rdt_resource *r); +int mbm_cntr_get(struct rdt_resource *r, struct rdt_mon_domain *d, + struct rdtgroup *rdtgrp, enum resctrl_event_id evtid); #endif /* _ASM_X86_RESCTRL_INTERNAL_H */ diff --git a/arch/x86/kernel/cpu/resctrl/monitor.c b/arch/x86/kernel/cpu/re= sctrl/monitor.c index 118b39fbb01e..3d748fdbcb5f 100644 --- a/arch/x86/kernel/cpu/resctrl/monitor.c +++ b/arch/x86/kernel/cpu/resctrl/monitor.c @@ -1436,8 +1436,8 @@ static int resctrl_config_cntr(struct rdt_resource *r= , struct rdt_mon_domain *d, return ret; } =20 -static int mbm_cntr_get(struct rdt_resource *r, struct rdt_mon_domain *d, - struct rdtgroup *rdtgrp, enum resctrl_event_id evtid) +int mbm_cntr_get(struct rdt_resource *r, struct rdt_mon_domain *d, + struct rdtgroup *rdtgrp, enum resctrl_event_id evtid) { int cntr_id; =20 --=20 2.34.1 From nobody Wed Feb 11 05:40:54 2026 Received: from NAM12-BN8-obe.outbound.protection.outlook.com (mail-bn8nam12on2045.outbound.protection.outlook.com [40.107.237.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 374B5215F4E; Wed, 22 Jan 2025 20:23:30 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.237.45 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1737577412; cv=fail; b=QkaQKp/Mc16+MdRC91lgOdxNMrBNJIx5eDo7lAL12ouUBtrGUxK1ekOK1QdFgxQbNWUwVwhwTDoZWlNDh9ctqnr313jXrZSd95ZRVuGG9FbkLvKEk/jla9bPiZ1JkbTJAhPgjKDwpNtJaftr0RxZJMyBYHdvfQyU15qFZOy1Rxs= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1737577412; c=relaxed/simple; bh=8PamxcBouoN2RXFvevdCqDLlSkYxQrWxmalH3i4vUR8=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=QRRYxxbTr3K/JLHq4OXyyyzCasR538yc4hHzI/twpToG+9m8JNbkkyZopKKE2fVhpNPM2+zHTPjoYguV8qs/en0O/bedGgiVAsXJfGtES1bMB1KfIsXkY+8Z9BFYWNvbIL8jE7tFjibTpzeJAZKBxwjxJhsklKPK5PyKIjM4YhM= 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=r21EC9IB; arc=fail smtp.client-ip=40.107.237.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="r21EC9IB" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=G/VbB1vorfE32NuJKAeSQ0cWkpBvN2cnseoX8XZ+Z0N/BKU9ixrEU889HytfWsHdIG0IgezPqy26JVhaFVtHvlhn1VsfSEeg98ey6IqwqCY6HCoU8iLqJTHmiTa6zP7mtaPKcTdnlwBA4TEuXf+vnz1LU4di7HHjjWxIMHJbcJYyQ+kgcykJ3+79v8MuZHZK+tBauKiaJ7U8KOvPwI8KbWkU3SjIVUMD1O1pHIBDbb1NmqGSRdHriPqcwVSsaDM1XpooQLV9yWDaVLdrlts7DR3pO9ctqXKdsDcRtBccWNMq09WdqCqdg4mWeZ4CoMSxkIvoBBHWR9y+QbZgL6llog== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=IYH+00nkTdxZwXrCJPMGj/NBQ921m8op2z/3pznTrPo=; b=pszwZAj/j2m0kw3/GKxT0CxIIUScCm2snBguktBPrVdHMqqDR72zSNqs3kNvE0P9fBetQTWWbiRyBO7zSSFLxTAKo/bctqwzG/SdTiFPWox0F+ry39G1WQEOl18eU7mZAbl5lo5we7PIHONjeufEl7uucVrcy2wmTBiCKb5iM3CEJII+I+Sa/N2p8dNK3/llb6UyFfs0VdF4rHQfhRlbhgV8geWNy43LoURM95cSo87S04ENLYrqXPzNoeotKIGfUTf490Uyps0Ah0RqK+Ek2Ejmzt11CRJkNHzKggT0qk2PmbQ3uJjU31+qTRg959Cbkx6qBhfZSbgwf2hbCLZCRw== 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=IYH+00nkTdxZwXrCJPMGj/NBQ921m8op2z/3pznTrPo=; b=r21EC9IBAi+ZQqnNkMcu3Lj7N0CUMJvGACtjzWyOjsiGOGF8NjzQGi8oKkTed5GhpBDv5a9+p76ADN6Ii7lQ+D1ISYoENpT5IZVbn8cKETAIslarV1XIoZOBMphs7+gOyVojNKV5lZobV+DBLIOFwBW8NmYqDoLfuViUGc4kxq0= Received: from CH2PR07CA0023.namprd07.prod.outlook.com (2603:10b6:610:20::36) by IA1PR12MB8287.namprd12.prod.outlook.com (2603:10b6:208:3f5::14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8377.16; Wed, 22 Jan 2025 20:23:24 +0000 Received: from CH1PEPF0000A34A.namprd04.prod.outlook.com (2603:10b6:610:20:cafe::5f) by CH2PR07CA0023.outlook.office365.com (2603:10b6:610:20::36) with Microsoft SMTP Server (version=TLS1_3, cipher=TLS_AES_256_GCM_SHA384) id 15.20.8377.14 via Frontend Transport; Wed, 22 Jan 2025 20:23: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 CH1PEPF0000A34A.mail.protection.outlook.com (10.167.244.5) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.8377.8 via Frontend Transport; Wed, 22 Jan 2025 20:23: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, 22 Jan 2025 14:23:21 -0600 From: Babu Moger To: , , , , , , , CC: , , , , , , , , , , , , , , , , , , , , , , , , , , Subject: [PATCH v11 19/23] x86/resctrl: Introduce the interface to switch between monitor modes Date: Wed, 22 Jan 2025 14:20:27 -0600 Message-ID: X-Mailer: git-send-email 2.34.1 In-Reply-To: References: Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-ClientProxiedBy: SATLEXMB04.amd.com (10.181.40.145) To SATLEXMB04.amd.com (10.181.40.145) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CH1PEPF0000A34A:EE_|IA1PR12MB8287:EE_ X-MS-Office365-Filtering-Correlation-Id: ceeaf484-df0a-416e-3f21-08dd3b229f88 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|36860700013|1800799024|82310400026|7416014|376014; X-Microsoft-Antispam-Message-Info: =?us-ascii?Q?irLpORexEzkat8oWfHmtdQrrU4uZ2w44jOJ6U7UG32lzcKcolIxGVHW0sXn9?= =?us-ascii?Q?8G5i/MQhUV/CMFADwFal27ScHkXS36hvgkWJsUcq0WdhVwSELapLZhXEBPbr?= =?us-ascii?Q?gHSNf0Smc7bE8sP9psGN5LcKwu4vl2Jvkle4S/t+p5aRGcZ1M9akFLf6zWq1?= =?us-ascii?Q?6qobPCcWFxB6T5tWg6nsEtV/MrWio83/rOYVJiUT3CNYlm1m3jo4aHhNA55H?= =?us-ascii?Q?VUI18MG9lW/pJ05zlUEAbJ/lVInqbv/dDWCDNSunFZKDoh9e04keYuL5zxYI?= =?us-ascii?Q?IN8F0kPldEZG/2VcVf6CpUz5+4HnFDDahbiCQ9tx4J4KKMwJ3XDFtlpbBDlH?= =?us-ascii?Q?9Q7yEVD0PITr7FdWpCKVGhIVIubQTWu+vsWZ/Poj8Yq4skJppT2j21LholTE?= =?us-ascii?Q?DrCrXvQYZ/AlnqymRSqGgkqfWd06l54ytieNl9qKkXOaX/J3EKwZ5AhR7oLa?= =?us-ascii?Q?CRdR29FsXJT+fvHGKT12L1LGObtiuqxNaG28+/EvWIxUO2gDDHgjGrwS4PKP?= =?us-ascii?Q?GRS5vwPYi8JVlkyIMPtPY7Gr7vnQBE/1sCMNE8e24swUhcgKijc0TQW7la+y?= =?us-ascii?Q?N8zrlnJsE5n4PCFOL9njIUnJ/2If3jFrzmIAY7t/ETsYmjJlj5K7PhZTaadl?= =?us-ascii?Q?qLEgBygDoiRpZ2dHOSuaA/RwY2H3PlaVUKq5OU1T1oz3X0TDLIrqTgyuhezG?= =?us-ascii?Q?LiCTY7ykGjw+kgvdzu23B5vpvKJs2qXBxYOV+jRyfBdxVzQCqqDks/J0lS0I?= =?us-ascii?Q?IN/bKvB4kWEYVYHcpNGRscP3f+qGQkuYx2NBP0Pt8M19UfQYYhTZvoXF85WT?= =?us-ascii?Q?gWGY+jKF7H4/wAC6oyQMjMG3cM6iXPvGJwwjviFPJFvndh8FOMbQpneAEGEf?= =?us-ascii?Q?iQQHc0HhkkOonh/2MfC4QPa20Aj5pBYr6Z05IbKPZ+jMlRIELglUYdlIkasF?= =?us-ascii?Q?zhYIrl2ZV6fxVvo06McOaGIYaATbx+47HUFDTIxeHPeJ1gE0ZLTKM977ptP2?= =?us-ascii?Q?3I4JHoRJWox4yhKnVr6jDm0DoexQ1s0GYZOxKKYz/AjMm8agY4m9tDwH13Fb?= =?us-ascii?Q?OoGkAs1tQBYi94g2/OnG5QDH1s/XntbsGrYR31MK8e3cP6P/5Llu40ME/8Db?= =?us-ascii?Q?SGuLSzu2ZvPJEfXjt/B7ZTBkkBS7HHOgosiBTuxYPQvNPuU3Al6eDtWH1Xfu?= =?us-ascii?Q?V8WwB7CKAgCdulZ6KHuppMITRNSzwHo6n/3UqGtzMwo17WyQUWi91xCUvB0H?= =?us-ascii?Q?GadQgQ8i6KJXu8krFfnkaDKXBtkF+yt0OiRVhX2XdI0vvDMvEFded/pDR9BY?= =?us-ascii?Q?WQa/0VgxRmtgn9o63594O5W+SQ7eVkrW5zjy5VwCSuINxVMKoxNevz/X2W4f?= =?us-ascii?Q?zrRgxtyN1uF3hzYg/Iocyo6YWd9ctJCXhNXHVyQBx8v1blLaSl6bXwqC6Faf?= =?us-ascii?Q?bTcVJAIo8iYGkauy4+3AQQu+NxASZvziqZvHrZxH8IZPFffxCpz5nI5IefTP?= =?us-ascii?Q?tvmFHnds3kJ8i5I=3D?= X-Forefront-Antispam-Report: CIP:165.204.84.17;CTRY:US;LANG:en;SCL:1;SRV:;IPV:CAL;SFV:NSPM;H:SATLEXMB04.amd.com;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(13230040)(36860700013)(1800799024)(82310400026)(7416014)(376014);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 22 Jan 2025 20:23:24.6974 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: ceeaf484-df0a-416e-3f21-08dd3b229f88 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: CH1PEPF0000A34A.namprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: IA1PR12MB8287 Content-Type: text/plain; charset="utf-8" Resctrl subsystem can support two monitoring modes, 'mbm_cntr_assign' or 'default'. In mbm_cntr_assign, monitoring event can only accumulate data while it is backed by a hardware counter. In 'default' mode, resctrl assumes there is a hardware counter for each event within every CTRL_MON and MON group. Introduce interface to switch between mbm_cntr_assign and default modes. $ cat /sys/fs/resctrl/info/L3_MON/mbm_assign_mode [mbm_cntr_assign] default To enable the "mbm_cntr_assign" mode: $ echo "mbm_cntr_assign" > /sys/fs/resctrl/info/L3_MON/mbm_assign_mode To enable the default monitoring mode: $ echo "default" > /sys/fs/resctrl/info/L3_MON/mbm_assign_mode MBM event counters are automatically reset as part of changing the mode. Clear both architectural and non-architectural event states to prevent overflow conditions during the next event read. Signed-off-by: Babu Moger --- v11: Changed the name of the function rdtgroup_mbm_assign_mode_write() to resctrl_mbm_assign_mode_write(). Rewrote the commit message with context. Added few more details in resctrl.rst about mbm_cntr_assign mode. Re-arranged the text in resctrl.rst file. v10: The call mbm_cntr_reset() has been moved to earlier patch. Minor documentation update. v9: Fixed extra spaces in user documentation. Fixed problem changing the mode to mbm_cntr_assign mode when it is not supported. Added extra checks to detect if systems supports it. Used the rdtgroup_cntr_id_init to initialize cntr_id. v8: Reset the internal counters after mbm_cntr_assign mode is changed. Renamed rdtgroup_mbm_cntr_reset() to mbm_cntr_reset() Updated the documentation to make text generic. v7: Changed the interface name to mbm_assign_mode. Removed the references of ABMC. Added the changes to reset global and domain bitmaps. Added the changes to reset rmid. v6: Changed the mode name to mbm_cntr_assign. Moved all the FS related code here. Added changes to reset mbm_cntr_map and resctrl group counters. v5: Change log and mode description text correction. v4: Minor commit text changes. Keep the default to ABMC when supported. Fixed comments to reflect changed interface "mbm_mode". v3: New patch to address the review comments from upstream. --- Documentation/arch/x86/resctrl.rst | 25 ++++++++++++- arch/x86/kernel/cpu/resctrl/rdtgroup.c | 50 +++++++++++++++++++++++++- 2 files changed, 73 insertions(+), 2 deletions(-) diff --git a/Documentation/arch/x86/resctrl.rst b/Documentation/arch/x86/re= sctrl.rst index 072b15550ff7..5d18c4c8bc48 100644 --- a/Documentation/arch/x86/resctrl.rst +++ b/Documentation/arch/x86/resctrl.rst @@ -259,7 +259,10 @@ with the following files: =20 "mbm_assign_mode": Reports the list of monitoring modes supported. The enclosed brackets - indicate which mode is enabled. + indicate which mode is enabled. The MBM events (mbm_total_bytes and/or + mbm_local_bytes) associated with counters may reset when "mbm_assign_mode" + is changed. + :: =20 # cat /sys/fs/resctrl/info/L3_MON/mbm_assign_mode @@ -275,6 +278,16 @@ with the following files: available is described in the "num_mbm_cntrs" file. Changing the mode may cause all counters on a resource to reset. =20 + Moving to mbm_cntr_assign mode require users to assign the counters to + the events. Otherwise, the MBM event counters will return "Unassigned" + when read. + + The mode is beneficial for AMD platforms that support more CTRL_MON + and MON groups than available hardware counters. By default, this + feature is enabled on AMD platforms with the ABMC (Assignable Bandwidth + Monitoring Counters) capability, ensuring counters remain assigned even + when the corresponding RMID is not actively used by any processor. + "default": =20 In default mode, resctrl assumes there is a hardware counter for each @@ -283,6 +296,16 @@ with the following files: "mbm_total_bytes" or "mbm_local_bytes" will report 'Unavailable' if there is no counter associated with that event. =20 + * To enable "mbm_cntr_assign" mode: + :: + + # echo "mbm_cntr_assign" > /sys/fs/resctrl/info/L3_MON/mbm_assign_mode + + * To enable default monitoring mode: + :: + + # echo "default" > /sys/fs/resctrl/info/L3_MON/mbm_assign_mode + "num_mbm_cntrs": The number of monitoring counters available for assignment when the system supports mbm_cntr_assign mode. diff --git a/arch/x86/kernel/cpu/resctrl/rdtgroup.c b/arch/x86/kernel/cpu/r= esctrl/rdtgroup.c index f61f0cd032ef..6922173c4f8f 100644 --- a/arch/x86/kernel/cpu/resctrl/rdtgroup.c +++ b/arch/x86/kernel/cpu/resctrl/rdtgroup.c @@ -928,6 +928,53 @@ static int resctrl_available_mbm_cntrs_show(struct ker= nfs_open_file *of, return ret; } =20 +static ssize_t resctrl_mbm_assign_mode_write(struct kernfs_open_file *of, + char *buf, size_t nbytes, loff_t off) +{ + struct rdt_resource *r =3D of->kn->parent->priv; + int ret =3D 0; + bool enable; + + /* Valid input requires a trailing newline */ + if (nbytes =3D=3D 0 || buf[nbytes - 1] !=3D '\n') + return -EINVAL; + + buf[nbytes - 1] =3D '\0'; + + cpus_read_lock(); + mutex_lock(&rdtgroup_mutex); + + rdt_last_cmd_clear(); + + if (!strcmp(buf, "default")) { + enable =3D 0; + } else if (!strcmp(buf, "mbm_cntr_assign")) { + if (r->mon.mbm_cntr_assignable) { + enable =3D 1; + } else { + ret =3D -EINVAL; + rdt_last_cmd_puts("mbm_cntr_assign mode is not supported\n"); + goto write_exit; + } + } else { + ret =3D -EINVAL; + rdt_last_cmd_puts("Unsupported assign mode\n"); + goto write_exit; + } + + if (enable !=3D resctrl_arch_mbm_cntr_assign_enabled(r)) { + ret =3D resctrl_arch_mbm_cntr_assign_set(r, enable); + if (!ret) + mbm_cntr_reset(r); + } + +write_exit: + mutex_unlock(&rdtgroup_mutex); + cpus_read_unlock(); + + return ret ?: nbytes; +} + #ifdef CONFIG_PROC_CPU_RESCTRL =20 /* @@ -1945,9 +1992,10 @@ static struct rftype res_common_files[] =3D { }, { .name =3D "mbm_assign_mode", - .mode =3D 0444, + .mode =3D 0644, .kf_ops =3D &rdtgroup_kf_single_ops, .seq_show =3D resctrl_mbm_assign_mode_show, + .write =3D resctrl_mbm_assign_mode_write, .fflags =3D RFTYPE_MON_INFO, }, { --=20 2.34.1 From nobody Wed Feb 11 05:40:54 2026 Received: from NAM12-BN8-obe.outbound.protection.outlook.com (mail-bn8nam12on2065.outbound.protection.outlook.com [40.107.237.65]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 516DF216E33; Wed, 22 Jan 2025 20:23:37 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.237.65 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1737577420; cv=fail; b=SNPanDKG+EpFASCLRxQArYJztb0qdpkgy0NshwdQp0p8qo0DtBtdHEKPfHotSkvOIN8oS1/vxjYl8KXcUYymGLpkAQGU4WEdf8T8qa9sQsZAPTgySn9aXqL3LOXMCKQDJN4foWJ0RHCMMPMBdpzzbn8cECsJOZo+JcORfwQLzRo= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1737577420; c=relaxed/simple; bh=YcwhqMYNzYtEtP16PsV+dPGp5rX88KSfMbzehLiZQAY=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=aMQQJ1JUmGk2RfJX6N6WMPZEB0qbZdhy79ppu4aTD8c30H/hkvkIwJthpJ586tZZ7FJFSqEfjfrwls5j+8jGAzBPY0Ov47jBgCDrMCZGsaRlTtCN4aJREZYfa0TjsohWisZGe1SZfZqKl6AcbQHj7K0YvfXE/yxPkOQ1UHhZx5Y= 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=uEUsArUF; arc=fail smtp.client-ip=40.107.237.65 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=amd.com Authentication-Results: smtp.subspace.kernel.org; spf=fail smtp.mailfrom=amd.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=amd.com header.i=@amd.com header.b="uEUsArUF" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=qBNRyVyhcSp1rjqfjqgRRZZHO9VyF++v1+4jO+xM8K5ccg+IxnTtdAAPOInJ6/Rmkv8NAjUdPvhpal1cgDCndS1Ub7Pj/9HMh4sill+xiUa5CI+J6/+hA4bzHcAFTDEQP8XkkN/BXCiVfh3R0Rn2HRrb0gQXQ7MXE91k5Hs4Fh+xwcIkSHdSKsqlhTdp92qNTCtfG1vlHxTX+R2DD264PhSMtAWMmQnnTFgzRnleCsvp1baRMpeJdR0mWYpnWMo6m9IgxfYiZCMy2Qlo20MhWf0Ceod3TP2Ndce0CiUQrmkUgMETM52HhdT+H8+nCVs3J7Tx5KUjAfg4L8AmyDs1rQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=HIjRqfzUuP6ECFL7hnA22Eu2QQcpdSck2GcM2+nfWBQ=; b=c8oLMaG3zMWRLJrl2b3OjTLnZJuJY2oAKime7Pv4gKBQGhqsv4vVJYuVBI1lm0QHu16S/1BsJixBpotJb/xziIWhwdz8T5PSVKclthK9ulcN+HmxNGyk4vYd5NLbh43ihu2KI8gTMgeuBsuduHvi6Zu5YkolQIYjtiMkrIrFCqwxk0uFyn/+GSgRYp5Cer5UP59DBIv6VVUzVkmd8hPSyDdhBt507SXLpFUyTlWM6mZHKSafkxM+9CMHaMSuDPvfzJ3yz3GUUyPoSoCy5p7Juz1KT9Ab77Ch50AWbjqwS+BMAQ1tHhwSqwPdx7AIk8fXPOJ4aL4vJzBUFz87z1ZY2w== 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=HIjRqfzUuP6ECFL7hnA22Eu2QQcpdSck2GcM2+nfWBQ=; b=uEUsArUFequ430vqAI0DBgrZoaJ8P7fk3WNu7IZWNNA+6tpk/O78MkGWABOrPQZ3HZrtvUtRMmeqTfrQJEUea8TtpYdYuEDaVpo6TYhQS8u77lENZIUZCtBe6mf6aMe9hU96iGpY72pbrEXnN8P+EvbdWdbPxfFhyK11ks5FJSM= Received: from CH2PR07CA0019.namprd07.prod.outlook.com (2603:10b6:610:20::32) by SA0PR12MB4415.namprd12.prod.outlook.com (2603:10b6:806:70::17) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8377.17; Wed, 22 Jan 2025 20:23:32 +0000 Received: from CH1PEPF0000A34A.namprd04.prod.outlook.com (2603:10b6:610:20:cafe::34) by CH2PR07CA0019.outlook.office365.com (2603:10b6:610:20::32) with Microsoft SMTP Server (version=TLS1_3, cipher=TLS_AES_256_GCM_SHA384) id 15.20.8356.21 via Frontend Transport; Wed, 22 Jan 2025 20:23:31 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 165.204.84.17) smtp.mailfrom=amd.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=amd.com; Received-SPF: Pass (protection.outlook.com: domain of amd.com designates 165.204.84.17 as permitted sender) receiver=protection.outlook.com; client-ip=165.204.84.17; helo=SATLEXMB04.amd.com; pr=C Received: from SATLEXMB04.amd.com (165.204.84.17) by CH1PEPF0000A34A.mail.protection.outlook.com (10.167.244.5) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.8377.8 via Frontend Transport; Wed, 22 Jan 2025 20:23:31 +0000 Received: from bmoger-ubuntu.amd.com (10.180.168.240) by SATLEXMB04.amd.com (10.181.40.145) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.39; Wed, 22 Jan 2025 14:23:29 -0600 From: Babu Moger To: , , , , , , , CC: , , , , , , , , , , , , , , , , , , , , , , , , , , Subject: [PATCH v11 20/23] x86/resctrl: Configure mbm_cntr_assign mode if supported Date: Wed, 22 Jan 2025 14:20:28 -0600 Message-ID: <4a48aabf502897bec1e015305d7b0b826bb20841.1737577229.git.babu.moger@amd.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: References: Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-ClientProxiedBy: SATLEXMB04.amd.com (10.181.40.145) To SATLEXMB04.amd.com (10.181.40.145) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CH1PEPF0000A34A:EE_|SA0PR12MB4415:EE_ X-MS-Office365-Filtering-Correlation-Id: d757944b-b97e-4be6-d1c7-08dd3b22a3c9 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|7416014|36860700013|376014|82310400026|1800799024; X-Microsoft-Antispam-Message-Info: =?us-ascii?Q?Zgtm82mK81HLX4WpHR8BvgsbA3Q4pD8tTOgli1l8V7h50dvu3lYBzwipMI2u?= =?us-ascii?Q?MTmtVbpfJzChT6Z7MmiBGSc7NdB5XadVc12VWVK88Fu7+qY4sTq14zqs8Tm+?= =?us-ascii?Q?Sgc9IYXl7z1l1fgQwOi2u0yhE8Z6q5SF0B/mTPc67JS/YG28TcyrSzxFVI+Z?= =?us-ascii?Q?OKvo9/cdCkCF5+IkPafIYj0+0Un/AehYfxiv1oEGMYBMdPWh8T++VJtqZVZA?= =?us-ascii?Q?w80JmcJTjewwrlXx9MQpkF8DWp3NfQ5o1L8MPHbg4MbmwXNbNyngqFT8bEBL?= =?us-ascii?Q?4U7v+igEGU5bt7zCo7imv93HZvebLXDayv+ur0Oo2aoOsRKtilaAmTqliPJ9?= =?us-ascii?Q?USGnoSL5aAmUtQu8sWXUSq7x3u4F/SHq1Fz+Ax+kHC61qvRljcTKLTEkzDh6?= =?us-ascii?Q?gjkOQcxpZ/qRHaiaR3LOffOJ/+RrMeTVuBc4JG4AHnTzsZJPiNjy1+Nxo/UJ?= =?us-ascii?Q?yd9wsMU8agasQjaIinzwZv7K5lP54ppIiZARUWeB/e3KpTHm7a5bXyIfQxfU?= =?us-ascii?Q?7R+Mcp3kJ+4NClvUCeID3PGEhouJ3qmX00GfACLXsV1kIVQBrc2heH+6PW4l?= =?us-ascii?Q?BXjHSPFziiT5hc8KTYzx4G8OJ8WY+QqUUK7bU9M+r5oabWSqCF8skl4XZF1E?= =?us-ascii?Q?qm1CxpkI04rSss22trU5w/cnz3ZT/pGFonTowAY6SaWybnJ1pyulDvaIXzI4?= =?us-ascii?Q?tp8DfQ1aXcyhejxCG4T2oQLFUgouBO8M+g3r8ny/cJ1oCCSAI2vsWu3QiN2l?= =?us-ascii?Q?vjptC0u6SbMU3RoDEiaCu6jvdgRtHSY/aZJciMvEq+Gj6EBkQzF56S/3oerC?= =?us-ascii?Q?HRGpezTMteR3nfN7EsAQIwEtSaBDyEmtQWtQ6LcYXXQqWamJSQk6omarcBAT?= =?us-ascii?Q?rU+BrYfBLZkD70bURQM+r6pl1lCM8NUM0+PkVPw3TwODbs4uHspJeoVH7QdP?= =?us-ascii?Q?xSQvFreewGM6tys4/Wklw7f1KLcU0gDEq+k0Wk1qrcQSXyQ2OYGmSdY9DVDQ?= =?us-ascii?Q?cUDSej+rr89s/YT+tuLS1btVwiVnnR4hxoSsBFwRWTQJEcJ8qrD32fy3vcXb?= =?us-ascii?Q?pPNg2NMJlzKRH26yw2yCrkXGLcouRgBXkAipjV3+ld0tQobxSn1zxsGHwR5M?= =?us-ascii?Q?pbbqHbR+i3kCvBWCnIeN0ixhHYhQUpEVdyVc+ZNMbD8WfWlc8uNUY+2bRUXX?= =?us-ascii?Q?pDnri/icaIHLvQTPKcdbxQbg6LeWeFrKqLnvzsa8iRDLVaxOW/B/pFgGhyZt?= =?us-ascii?Q?83BFn65eQdl0tsLtZJMnOKD8Efl+1MQKuov5ZwlnTbINuK7UmFNH2aCINDr/?= =?us-ascii?Q?ktSL8VpYDzPjo2L0abyNs/AOSTf0WlTLJB3NqApSEBcjVS7tlucZ/23bzujn?= =?us-ascii?Q?VZhsnrOY5LldimZcPbyc3jAvirkfGWQ80D9gBAjArdFZZw0W+ldI86J8IsTh?= =?us-ascii?Q?Zr6HLp0KD+zPZ/b0lef73tnrp/573Po/HobFCdDv+MnUCkYTFQmI0U5Gw86s?= =?us-ascii?Q?fa3CqA2KQMjdEB8=3D?= X-Forefront-Antispam-Report: CIP:165.204.84.17;CTRY:US;LANG:en;SCL:1;SRV:;IPV:CAL;SFV:NSPM;H:SATLEXMB04.amd.com;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(13230040)(7416014)(36860700013)(376014)(82310400026)(1800799024);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 22 Jan 2025 20:23:31.8380 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: d757944b-b97e-4be6-d1c7-08dd3b22a3c9 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: CH1PEPF0000A34A.namprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: SA0PR12MB4415 Content-Type: text/plain; charset="utf-8" Configure mbm_cntr_assign mode on AMD platforms. On AMD platforms, it is recommended to use mbm_cntr_assign mode if supported, because reading "mbm_total_bytes" or "mbm_local_bytes" will report 'Unavailable' if there is no counter associated with that event. The mbm_cntr_assign mode, referred to as ABMC (Assignable Bandwidth Monitoring Counters) on AMD, is enabled by default when supported by the system. Update ABMC across all logical processors within the resctrl domain to ensure proper functionality. Signed-off-by: Babu Moger --- v11: Commit text in imperative tone. Added few more details. Moved resctrl_arch_mbm_cntr_assign_set_one() to monitor.c. v10: Commit text in imperative tone. v9: Minor code change due to merge. Actual code did not change. v8: Renamed resctrl_arch_mbm_cntr_assign_configure to resctrl_arch_mbm_cntr_assign_set_one. Adde r->mon_capable check. Commit message update. v7: Introduced resctrl_arch_mbm_cntr_assign_configure() to configure. Moved the default settings to rdt_get_mon_l3_config(). It should be done before the hotplug handler is called. It cannot be done at rdtgroup_init(). v6: Keeping the default enablement in arch init code for now. This may need some discussion. Renamed resctrl_arch_configure_abmc to resctrl_arch_mbm_cntr_assign_co= nfigure. v5: New patch to enable ABMC by default. --- arch/x86/kernel/cpu/resctrl/internal.h | 1 + arch/x86/kernel/cpu/resctrl/monitor.c | 8 ++++++++ arch/x86/kernel/cpu/resctrl/rdtgroup.c | 4 ++++ 3 files changed, 13 insertions(+) diff --git a/arch/x86/kernel/cpu/resctrl/internal.h b/arch/x86/kernel/cpu/r= esctrl/internal.h index c006c4d8d6ff..2480698b643d 100644 --- a/arch/x86/kernel/cpu/resctrl/internal.h +++ b/arch/x86/kernel/cpu/resctrl/internal.h @@ -734,4 +734,5 @@ int resctrl_unassign_cntr_event(struct rdt_resource *r,= struct rdt_mon_domain *d void mbm_cntr_reset(struct rdt_resource *r); int mbm_cntr_get(struct rdt_resource *r, struct rdt_mon_domain *d, struct rdtgroup *rdtgrp, enum resctrl_event_id evtid); +void resctrl_arch_mbm_cntr_assign_set_one(struct rdt_resource *r); #endif /* _ASM_X86_RESCTRL_INTERNAL_H */ diff --git a/arch/x86/kernel/cpu/resctrl/monitor.c b/arch/x86/kernel/cpu/re= sctrl/monitor.c index 3d748fdbcb5f..a9a5dc626a1e 100644 --- a/arch/x86/kernel/cpu/resctrl/monitor.c +++ b/arch/x86/kernel/cpu/resctrl/monitor.c @@ -1233,6 +1233,7 @@ int __init rdt_get_mon_l3_config(struct rdt_resource = *r) r->mon.mbm_cntr_assignable =3D true; cpuid_count(0x80000020, 5, &eax, &ebx, &ecx, &edx); r->mon.num_mbm_cntrs =3D (ebx & GENMASK(15, 0)) + 1; + hw_res->mbm_cntr_assign_enabled =3D true; resctrl_file_fflags_init("num_mbm_cntrs", RFTYPE_MON_INFO); resctrl_file_fflags_init("available_mbm_cntrs", RFTYPE_MON_INFO); } @@ -1313,6 +1314,13 @@ static void _resctrl_abmc_enable(struct rdt_resource= *r, bool enable) resctrl_abmc_set_one_amd, &enable, 1); } =20 +void resctrl_arch_mbm_cntr_assign_set_one(struct rdt_resource *r) +{ + struct rdt_hw_resource *hw_res =3D resctrl_to_arch_res(r); + + resctrl_abmc_set_one_amd(&hw_res->mbm_cntr_assign_enabled); +} + int resctrl_arch_mbm_cntr_assign_set(struct rdt_resource *r, bool enable) { struct rdt_hw_resource *hw_res =3D resctrl_to_arch_res(r); diff --git a/arch/x86/kernel/cpu/resctrl/rdtgroup.c b/arch/x86/kernel/cpu/r= esctrl/rdtgroup.c index 6922173c4f8f..515969c5f64f 100644 --- a/arch/x86/kernel/cpu/resctrl/rdtgroup.c +++ b/arch/x86/kernel/cpu/resctrl/rdtgroup.c @@ -4302,9 +4302,13 @@ int resctrl_online_mon_domain(struct rdt_resource *r= , struct rdt_mon_domain *d) =20 void resctrl_online_cpu(unsigned int cpu) { + struct rdt_resource *r =3D &rdt_resources_all[RDT_RESOURCE_L3].r_resctrl; + mutex_lock(&rdtgroup_mutex); /* The CPU is set in default rdtgroup after online. */ cpumask_set_cpu(cpu, &rdtgroup_default.cpu_mask); + if (r->mon_capable && r->mon.mbm_cntr_assignable) + resctrl_arch_mbm_cntr_assign_set_one(r); mutex_unlock(&rdtgroup_mutex); } =20 --=20 2.34.1 From nobody Wed Feb 11 05:40:54 2026 Received: from NAM11-DM6-obe.outbound.protection.outlook.com (mail-dm6nam11on2055.outbound.protection.outlook.com [40.107.223.55]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 0A993216616; Wed, 22 Jan 2025 20:23:47 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.223.55 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1737577429; cv=fail; b=ITfUNnEdSOQd+/8K24WZps0qKbmBmufgg4eZlNm0j5kgWDNznJlrGL6gAk2KFZ1n64xPtcBLiPn2/OO4P5CgU7vVsZFetDSQJc2vvTiCdJT7pMnlsrPQP2fj5SgSlu1YFSFRgyZaabN56rTM/h5z9WipTzAR/EerVQ1fJvcaOJg= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1737577429; c=relaxed/simple; bh=keDPBKNst0F23XKBEzDIfKMDXMzXaQoOEXHRTSG2sSQ=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=Hk5hH9uLpChus4z9J5SdSlE9PhVGavGRC6fnfWgQC383eQDJSV+54qxB2X6JNtwNi/ELJNvEwc9SgZLJF6ZG6AwI6hMHLTmP3GObIMKWW9iPrx1zNg/Or5Ey1O+Ppu4+7f/PYpHpbiJF9jucYnfc9o6p62SOciLKBdAX8B6Ceak= 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=jT+3kEon; arc=fail smtp.client-ip=40.107.223.55 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=amd.com Authentication-Results: smtp.subspace.kernel.org; spf=fail smtp.mailfrom=amd.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=amd.com header.i=@amd.com header.b="jT+3kEon" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=rC57iajExzZm2sgspkhk/yKNOx8Gkhw3WOsKllu63ZDrko5ws77bLDdcpncIopbkWUQKXk81YJtOnZhRNTsNxmXSPjLiLr21XDDl8ETrNwsoAO81CFRORPkShP8VIjyBQOvdzOuk7J+FUTo+XvvxgwPF63zaKjeyEwVsPNQS7adHZRrkkrNnVi3iJF5+Il/zWCcbu6xJVqAZvXuBqQAKZSWf1pV9JUtfpPio5Xyj8qVq4SINXDHW7QQug9iyhP/3or7GE6FJvIhPsGjf9z/Pu73eXCprDaBVN+/JTTB8dhZuiybjuaIbnhajxFNjG+rOYEUU3o/+3H9MkDdgFZDViw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=Qz9kYfrUCZvSIiUDxuhgdCq78Ufjp2mIBWDWMlVk0x8=; b=PuI+1zu2mAQi98DggxgEL72CGbYwLyefFPBpq8XeIKQD6tY8HneJ3r5i892BlDl58q6Ys//GH90fuznhUw+c2gV2IgIUZqreZ0qxQlIkaAt2dC81ADLF2yPC31kgANNqLWt2aEvPoSwRALiIRtq/3UaDSwdIVbIovCWrsSGgia17cqWy89fbAsyHY/fKv1/aBBCbJwusntbPtivFlhmJQwHrUEcTd/kfpyJe/jk/LMc4AcOnZHdoZq2loJyHXMBQNWGWeUr+h9gmVazE3C3w5olHofrXZxZPCa/rPJNPHVGPfDW4RpTD+dIEAlT9fpVAYiUnmYLXYAt/N8k96LKyUg== 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=Qz9kYfrUCZvSIiUDxuhgdCq78Ufjp2mIBWDWMlVk0x8=; b=jT+3kEonAooJtTsJAtI+SQEPSSep7Lw8kGUqaF2rd3RP8QVkGs9MubImbH2uqLADgMv6e2fhLqtxz9ze9511k3gHN2v58z14qtI9KAw0YOrnnsA7Dqobsx6IYjVbl9iAHa4LnHdFa6HxzU3FIqJpkBT+LpVQ166O2EASFc1AaIs= Received: from CH0PR03CA0409.namprd03.prod.outlook.com (2603:10b6:610:11b::17) by PH7PR12MB6561.namprd12.prod.outlook.com (2603:10b6:510:213::12) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8356.20; Wed, 22 Jan 2025 20:23:40 +0000 Received: from CH1PEPF0000A348.namprd04.prod.outlook.com (2603:10b6:610:11b:cafe::16) by CH0PR03CA0409.outlook.office365.com (2603:10b6:610:11b::17) with Microsoft SMTP Server (version=TLS1_3, cipher=TLS_AES_256_GCM_SHA384) id 15.20.8377.14 via Frontend Transport; Wed, 22 Jan 2025 20:23:39 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 165.204.84.17) smtp.mailfrom=amd.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=amd.com; Received-SPF: Pass (protection.outlook.com: domain of amd.com designates 165.204.84.17 as permitted sender) receiver=protection.outlook.com; client-ip=165.204.84.17; helo=SATLEXMB04.amd.com; pr=C Received: from SATLEXMB04.amd.com (165.204.84.17) by CH1PEPF0000A348.mail.protection.outlook.com (10.167.244.4) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.8377.8 via Frontend Transport; Wed, 22 Jan 2025 20:23:39 +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, 22 Jan 2025 14:23:38 -0600 From: Babu Moger To: , , , , , , , CC: , , , , , , , , , , , , , , , , , , , , , , , , , , Subject: [PATCH v11 21/23] x86/resctrl: Update assignments on event configuration changes Date: Wed, 22 Jan 2025 14:20:29 -0600 Message-ID: X-Mailer: git-send-email 2.34.1 In-Reply-To: References: Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-ClientProxiedBy: SATLEXMB04.amd.com (10.181.40.145) To SATLEXMB04.amd.com (10.181.40.145) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CH1PEPF0000A348:EE_|PH7PR12MB6561:EE_ X-MS-Office365-Filtering-Correlation-Id: 916cd659-c3e3-4828-b663-08dd3b22a885 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|36860700013|1800799024|82310400026|376014|7416014|13003099007; X-Microsoft-Antispam-Message-Info: =?us-ascii?Q?7n+tm6Ayy2GwIRogrWhTp8Hodcq5vVC7mmgs/Xdn3xj90Au0LKmIMWBgGl8K?= =?us-ascii?Q?D7VC93QIA7YhVdJ9mOa3cDXz0//lBXcI8/l4rxESjpUSpxefbFpZ67PwpQrU?= =?us-ascii?Q?ZtxigIksjbnTlARZgq7JvCoZ/ThErjfALrxB3AAulP3DbxG3uYYgREkNw69j?= =?us-ascii?Q?6/QP6QbBEGF9TQOkluDNLuubKPpseKyBZCifOmsruYFh0U5tQ22slh5wAKfp?= =?us-ascii?Q?cYB6qq+VMtMiO3u3WRG//fPze3r8rIlQxTgeHYmM2fvEyS5tpKcdmwpS3k3u?= =?us-ascii?Q?GSDzf1f5F0//6FMkWgdLKo8SILp9qG+xjSpjMxqWhgGuzFIwYF2qozxFa81J?= =?us-ascii?Q?xaF8n+qgqwuL8Vnud3WI4JKQaetQacof2dv6bkjj3tjaxil0i+YTyRee77Qn?= =?us-ascii?Q?RD3J8MgqCRd1HupfbCBV3nsW/QbsiNH+WUYYD12zCxWifJoZDduo7lAbaiRJ?= =?us-ascii?Q?lTfGY3joiemq333bSX+B76warYeb/Q5ZGCNDU2eyCDqZPLxlOjhTRJdBEZsH?= =?us-ascii?Q?Q8/CBI01VjFRT1KQr8mS8w2ZOSwvt9F3Zi+on1VsiYyDuvO/xYV8gG5kUm7N?= =?us-ascii?Q?ZauVanddljyrcnvHP0tY+qCkgd4FsGodc9Fsq9cCsKu8yjFlZo6iHY10wJRK?= =?us-ascii?Q?lHBwroMlC0Q0mC2/o4AZYTg94Y5+kJPlNbCXKiOZ0UbP+rOl7QliXA8IMqsF?= =?us-ascii?Q?kQY+Rq6we2rvP5X02KLGq0AGY4kwpubP0kx/JMRS+fZFm90+R/zdlrIVnP/C?= =?us-ascii?Q?X/hzztNkGkGijv7ZRvqZB5dA2uGV+DS1cHnY2GFI+GxMNqGbqZx6/eeWu8gw?= =?us-ascii?Q?DAZ6kBl1/2v6x1WRIIxqpeHVFflOXhdWlg8W8lqWoNiaD85ZatLIEaRdu4wx?= =?us-ascii?Q?mXCmZ6r8lExEDQ6lN21GbRSMwmW2kFp+JfomwociaWk6WGB/9TnvXLH+vVtX?= =?us-ascii?Q?vyxMSgmd3UzLZpoCinvpW8+Ff55sJO2eWeyS67D2e5SAJRJ5XTTKY7pDpjUY?= =?us-ascii?Q?GY//yXEtAslPE8AVNyEs96PGfweRzVlz+RUUw50BLtV3oCg5gF+zrsGHPY6Q?= =?us-ascii?Q?h5MkFIZs2aD8cXjm96MwL/MqIfDpGkaQFYbIqLy992V3Nj5fnsANBB/36q2+?= =?us-ascii?Q?fC8T4W1NCF0fEpbpEgMinfXjycUvTaPrxYvIYmDXbqQxFnt8N7rusg5/JU1q?= =?us-ascii?Q?CA9agW1DaUhVmeCFtnzws+4Er9Nz/6V1E4mep4Z9jhr8O9vOelQDc0F/JyqT?= =?us-ascii?Q?E7GW+bxzcmW3EZw4OlwWFCkSwzfvB1cn87cXDE4eICPidWKSVJ1c2BBSWCIR?= =?us-ascii?Q?JBL13LYCnh0/R5FWTaP8rDm2otnUBY1U+VX4EJf8gkNFnYZlm3dpnsgfib49?= =?us-ascii?Q?zmuP1zWU3Iowwf3LhpZYEtEDrts5oOxnsj/i+gEQtRnCQvMF2qR0GkJE98Jh?= =?us-ascii?Q?+fhftA4qql0Iae1CTFZ5MpOuwciSJdhndtKhIUqm5faF09BH22GUSeceJSUj?= =?us-ascii?Q?7SXUORbESC13EDcR/YaKACRLB5DZF2XKYesW?= X-Forefront-Antispam-Report: CIP:165.204.84.17;CTRY:US;LANG:en;SCL:1;SRV:;IPV:CAL;SFV:NSPM;H:SATLEXMB04.amd.com;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(13230040)(36860700013)(1800799024)(82310400026)(376014)(7416014)(13003099007);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 22 Jan 2025 20:23:39.7959 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 916cd659-c3e3-4828-b663-08dd3b22a885 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: CH1PEPF0000A348.namprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH7PR12MB6561 Content-Type: text/plain; charset="utf-8" When BMEC (Bandwidth Monitoring Event Configuration) is supported, resctrl provides option to configure events by writing to the interfaces /sys/fs/resctrl/info/L3_MON/mbm_total_bytes_config or /sys/fs/resctrl/info/L3_MON/mbm_local_bytes_config. Update MBM event assignments for all monitor groups in the affected domains whenever the event configuration is changed. Signed-off-by: Babu Moger --- v11: Added non-arch RMID reset code in mbm_config_write_domain() which was mi= ssing. Removed resctrl_arch_reset_rmid() call in resctrl_abmc_config_one_amd(). Not required as reset of arch and non-arch rmid counters done from the c= allers. It simplies the IPI code. Updated the code comments with Reinette's feedback. Updated the commit message in imperative mode. v10: Code changed completely with domain specific counter assignment. Rewrite the commit message. Added few more code comments. v9: Again patch changed completely based on the comment. https://lore.kernel.org/lkml/03b278b5-6c15-4d09-9ab7-3317e84a409e@intel= .com/ Introduced resctrl_mon_event_config_set to handle IPI. But sending another IPI inside IPI causes problem. Kernel reports SMP warning. So, introduced resctrl_arch_update_cntr() to send the command = directly. v8: Patch changed completely. Updated the assignment on same IPI as the event is updated. Could not do the way we discussed in the thread. https://lore.kernel.org/lkml/f77737ac-d3f6-3e4b-3565-564f79c86ca8@amd.c= om/ Needed to figure out event type to update the configuration. v7: New patch to update the assignments. Missed it earlier. --- arch/x86/kernel/cpu/resctrl/internal.h | 4 +- arch/x86/kernel/cpu/resctrl/monitor.c | 58 ++++++++++++++++++++++---- arch/x86/kernel/cpu/resctrl/rdtgroup.c | 10 ++++- 3 files changed, 61 insertions(+), 11 deletions(-) diff --git a/arch/x86/kernel/cpu/resctrl/internal.h b/arch/x86/kernel/cpu/r= esctrl/internal.h index 2480698b643d..aec564fa2833 100644 --- a/arch/x86/kernel/cpu/resctrl/internal.h +++ b/arch/x86/kernel/cpu/resctrl/internal.h @@ -607,11 +607,13 @@ union cpuid_0x10_x_edx { =20 /** * struct mon_config_info - Monitoring event configuratiin details + * @r: Resource for monitoring * @d: Domain for the event * @evtid: Event type * @mon_config: Event configuration value */ struct mon_config_info { + struct rdt_resource *r; struct rdt_mon_domain *d; enum resctrl_event_id evtid; u32 mon_config; @@ -721,12 +723,12 @@ int resctrl_arch_mbm_cntr_assign_set(struct rdt_resou= rce *r, bool enable); bool resctrl_arch_mbm_cntr_assign_enabled(struct rdt_resource *r); void arch_mbm_evt_config_init(struct rdt_hw_mon_domain *hw_dom); unsigned int mon_event_config_index_get(u32 evtid); -void resctrl_arch_mon_event_config_set(void *info); u32 resctrl_arch_mon_event_config_get(struct rdt_mon_domain *d, enum resctrl_event_id eventid); int resctrl_arch_config_cntr(struct rdt_resource *r, struct rdt_mon_domain= *d, enum resctrl_event_id evtid, u32 rmid, u32 closid, u32 cntr_id, bool assign); +void resctrl_mon_event_config_set(void *info); int resctrl_assign_cntr_event(struct rdt_resource *r, struct rdt_mon_domai= n *d, struct rdtgroup *rdtgrp, enum resctrl_event_id evtid); int resctrl_unassign_cntr_event(struct rdt_resource *r, struct rdt_mon_dom= ain *d, diff --git a/arch/x86/kernel/cpu/resctrl/monitor.c b/arch/x86/kernel/cpu/re= sctrl/monitor.c index a9a5dc626a1e..024aabbecbb5 100644 --- a/arch/x86/kernel/cpu/resctrl/monitor.c +++ b/arch/x86/kernel/cpu/resctrl/monitor.c @@ -1354,26 +1354,26 @@ u32 resctrl_arch_mon_event_config_get(struct rdt_mo= n_domain *d, return INVALID_CONFIG_VALUE; } =20 -void resctrl_arch_mon_event_config_set(void *info) +static void resctrl_arch_mon_event_config_set(struct rdt_mon_domain *d, + enum resctrl_event_id eventid, u32 val) { - struct mon_config_info *mon_info =3D info; struct rdt_hw_mon_domain *hw_dom; unsigned int index; =20 - index =3D mon_event_config_index_get(mon_info->evtid); + index =3D mon_event_config_index_get(eventid); if (index =3D=3D INVALID_CONFIG_INDEX) return; =20 - wrmsr(MSR_IA32_EVT_CFG_BASE + index, mon_info->mon_config, 0); + wrmsr(MSR_IA32_EVT_CFG_BASE + index, val, 0); =20 - hw_dom =3D resctrl_to_arch_mon_dom(mon_info->d); + hw_dom =3D resctrl_to_arch_mon_dom(d); =20 - switch (mon_info->evtid) { + switch (eventid) { case QOS_L3_MBM_TOTAL_EVENT_ID: - hw_dom->mbm_total_cfg =3D mon_info->mon_config; + hw_dom->mbm_total_cfg =3D val; break; case QOS_L3_MBM_LOCAL_EVENT_ID: - hw_dom->mbm_local_cfg =3D mon_info->mon_config; + hw_dom->mbm_local_cfg =3D val; break; default: break; @@ -1592,3 +1592,45 @@ void mbm_cntr_reset(struct rdt_resource *r) } } } + +/* + * Update hardware counter configuration after event configuration change. + * Walk the hardware counters of domain @d to reconfigure all assigned + * counters that are monitoring @evtid with the event's new configuration + * value. + * This is run on a CPU belonging to domain @d so call + * resctrl_abmc_config_one_amd() directly. + */ +static void resctrl_arch_update_cntr(struct rdt_resource *r, struct rdt_mo= n_domain *d, + enum resctrl_event_id evtid, u32 val) +{ + union l3_qos_abmc_cfg abmc_cfg =3D { 0 }; + struct rdtgroup *rdtgrp; + u32 cntr_id; + + for (cntr_id =3D 0; cntr_id < r->mon.num_mbm_cntrs; cntr_id++) { + rdtgrp =3D d->cntr_cfg[cntr_id].rdtgrp; + if (rdtgrp && d->cntr_cfg[cntr_id].evtid =3D=3D evtid) { + abmc_cfg.split.cfg_en =3D 1; + abmc_cfg.split.cntr_en =3D 1; + abmc_cfg.split.cntr_id =3D cntr_id; + abmc_cfg.split.bw_src =3D rdtgrp->mon.rmid; + abmc_cfg.split.bw_type =3D val; + resctrl_abmc_config_one_amd(&abmc_cfg); + } + } +} + +void resctrl_mon_event_config_set(void *info) +{ + struct mon_config_info *mon_info =3D info; + struct rdt_mon_domain *d =3D mon_info->d; + struct rdt_resource *r =3D mon_info->r; + + resctrl_arch_mon_event_config_set(d, mon_info->evtid, mon_info->mon_confi= g); + + /* Check if assignments needs to be updated */ + if (resctrl_arch_mbm_cntr_assign_enabled(r)) + resctrl_arch_update_cntr(r, d, mon_info->evtid, + mon_info->mon_config); +} diff --git a/arch/x86/kernel/cpu/resctrl/rdtgroup.c b/arch/x86/kernel/cpu/r= esctrl/rdtgroup.c index 515969c5f64f..5d305d0ac053 100644 --- a/arch/x86/kernel/cpu/resctrl/rdtgroup.c +++ b/arch/x86/kernel/cpu/resctrl/rdtgroup.c @@ -1740,10 +1740,10 @@ static int mbm_local_bytes_config_show(struct kernf= s_open_file *of, return 0; } =20 - static void mbm_config_write_domain(struct rdt_resource *r, struct rdt_mon_domain *d, u32 evtid, u32 val) { + u32 idx_limit =3D resctrl_arch_system_num_rmid_idx(); struct mon_config_info mon_info =3D {0}; u32 config_val; =20 @@ -1755,6 +1755,7 @@ static void mbm_config_write_domain(struct rdt_resour= ce *r, if (config_val =3D=3D INVALID_CONFIG_VALUE || config_val =3D=3D val) return; =20 + mon_info.r =3D r; mon_info.d =3D d; mon_info.evtid =3D evtid; mon_info.mon_config =3D val; @@ -1766,7 +1767,7 @@ static void mbm_config_write_domain(struct rdt_resour= ce *r, * on one CPU is observed by all the CPUs in the domain. */ smp_call_function_any(&d->hdr.cpu_mask, - resctrl_arch_mon_event_config_set, + resctrl_mon_event_config_set, &mon_info, 1); =20 /* @@ -1779,6 +1780,11 @@ static void mbm_config_write_domain(struct rdt_resou= rce *r, * mbm_local and mbm_total counts for all the RMIDs. */ resctrl_arch_reset_rmid_all(r, d); + + if (is_mbm_total_enabled()) + memset(d->mbm_total, 0, sizeof(struct mbm_state) * idx_limit); + if (is_mbm_local_enabled()) + memset(d->mbm_local, 0, sizeof(struct mbm_state) * idx_limit); } =20 static int mon_config_write(struct rdt_resource *r, char *tok, u32 evtid) --=20 2.34.1 From nobody Wed Feb 11 05:40:54 2026 Received: from NAM10-BN7-obe.outbound.protection.outlook.com (mail-bn7nam10on2044.outbound.protection.outlook.com [40.107.92.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 A703821884A; Wed, 22 Jan 2025 20:23:52 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.92.44 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1737577434; cv=fail; b=c3I/DHRL3XCxEmD6qYE6+mOpNzrSHSLGfshaV2TsTqISGJ9nH+LRK+Y0c+4y5CnEzi4qL0IMHTlj0EVb02kfIcF3wee60MbIJVZJhApx4uo0mwJsGkAxMky5YP7dSCdXa9IGWD77gI2o3KYcrZktvTuoKTN5zmkMDtbwEew2yWs= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1737577434; c=relaxed/simple; bh=2DaioZnhf89Fl5sdiNrRxLf/6JHH2TZI2vKD2aKgpQo=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=MswiRVgENa1KKHKjJqbHCHr3fKkT02ffgUEWwlNeshTD43vQ4niRfuYbgzSc1yNx2BaogxSlhAi+1M1Q4tBztvtLtvs0lF+a2AP1mkk1m3JEFZtuBak5FNJrI/ea4HjxM+MH38gMl6rE5IY1RaJ3+Z9wu3tQwfRCygRPaa595BY= 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=DQM6npg5; arc=fail smtp.client-ip=40.107.92.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="DQM6npg5" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=GOy1quq+53ZD2qcjIY1BHRrHXy2sOwXpDtzRi6sGr/ZWa5qw2PJ8oANymt0VNYy/4QWXBWfigFhQRVPDgqeDA+iUJGBQNlee0JPAtlFtj7CAoQtgp1smYPtI49igpk314F/KXiQUIcxdKSe8fsCqN5IaMFltEIPk0R1q3QDfKqPROciGDTFIFedGXfjYRvQJ1j14RhZEHbGF+zVAYo4Xfn7ffpCRd4gYibGLM18kR1a5q1tla75757hfBqa+bMIF3/PQSnL2IcGT+MpbPmf6WqIDXlHw/bgCLTpRe+B6QsWpgL4lprF3mZS88OgCJLOXvA3L+znk6YPh6l1FkGg3ig== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=194ma8It+LR6yWBFaJDPOIQUTFoFmLgXqlmahW5RnT8=; b=ZdiY0fxtE3OAFVn/HvZXKBaptTnAWPHqSoY6e3ER6ojVW9PFABVX5wft1hofg2fK4v3P4N7G7QbPikeMREA27fYvwS5A7ObnmfDePnMp5odNmrIgZ961XI8QVaAfM1G8Z+f3F+MgLN9TLPQ9YKcNzZ5iaS9z897vhe8nF14QgvVSyWXlT/8Yp3SjvhpjmaHSc5MZxnDBdXQAtgaSaVKo1UXU9U4Y/h0JLCJ3RTQl7D52U/zQ4SN2iHz7dJmrE3zygyve5xJ27mAtLFvTVLr0kEHCWMHt3Lo0JYU+7h39fH6i7JPlrT9g0pD+M4ZgiO3B41EL+dXV20auG1h2vCeX7w== 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=194ma8It+LR6yWBFaJDPOIQUTFoFmLgXqlmahW5RnT8=; b=DQM6npg5DFbfSc98L+u/tpjGUsuO4DlPdSoGwc4duYKpDCWqDzop/RLIVpktIhWlJ5r1inbTC1EJPisr9BnNPLTVeWY0goGNIg8Akrlre7sdeY1o+PMLtdQUe8H9ND7TVTsKgnuCvoRvhsS0hwA+JtDFcpnJF0WrrMQzIWVZ/pk= Received: from CH0PR03CA0303.namprd03.prod.outlook.com (2603:10b6:610:118::16) by IA0PR12MB7604.namprd12.prod.outlook.com (2603:10b6:208:438::9) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8356.21; Wed, 22 Jan 2025 20:23:48 +0000 Received: from CH1PEPF0000A347.namprd04.prod.outlook.com (2603:10b6:610:118:cafe::5) by CH0PR03CA0303.outlook.office365.com (2603:10b6:610:118::16) with Microsoft SMTP Server (version=TLS1_3, cipher=TLS_AES_256_GCM_SHA384) id 15.20.8377.14 via Frontend Transport; Wed, 22 Jan 2025 20:23: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 CH1PEPF0000A347.mail.protection.outlook.com (10.167.244.7) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.8377.8 via Frontend Transport; Wed, 22 Jan 2025 20:23: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, 22 Jan 2025 14:23:46 -0600 From: Babu Moger To: , , , , , , , CC: , , , , , , , , , , , , , , , , , , , , , , , , , , Subject: [PATCH v11 22/23] x86/resctrl: Introduce interface to list assignment states of all the groups Date: Wed, 22 Jan 2025 14:20:30 -0600 Message-ID: <52c66bf98480c0ab6bb0f0762497e328fcbdeaac.1737577229.git.babu.moger@amd.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: References: Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-ClientProxiedBy: SATLEXMB04.amd.com (10.181.40.145) To SATLEXMB04.amd.com (10.181.40.145) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CH1PEPF0000A347:EE_|IA0PR12MB7604:EE_ X-MS-Office365-Filtering-Correlation-Id: 6aaa66a7-898c-4f56-2a86-08dd3b22ad5c X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|7416014|376014|1800799024|36860700013|82310400026|13003099007; X-Microsoft-Antispam-Message-Info: =?us-ascii?Q?Yn2YUttPqh5IFax0ZV1ZuE8uwXzDTESICIsKkDxXAFP8mzPJCO3JpniDmnLw?= =?us-ascii?Q?YNE9eb+iK8/g/nNX0uvoeX9snfWm86tnCZak7NYEb6h0AnMJJ2cvcNsZEfMy?= =?us-ascii?Q?1jBFZ/JQ77QZWMMm4PZcJT/G5e4o/MUD7Ii8RQ4gesznADLX3vpblcRtg6/J?= =?us-ascii?Q?Se6XqsCPaBfkgvDcIiSXjJv6Irh94IPFkUUAWWDnD5Z2jcPbkOmdPHGjHrZ+?= =?us-ascii?Q?nAhPSjFh1GTd2hvgCl4Law/5IA/SqSzxfUL7PDzIx9CfzBg9yK6O+wED34u6?= =?us-ascii?Q?IbmeZV3RrsPrEWDlNj8a5fRnCveyMjY+PQWdZg8EGIpqHQTUwNlhhFuc6vWH?= =?us-ascii?Q?/IAFETNVakkOX/7/Uf/jw/LW1NB3sJd+fyqM0MkumFRC15OviRgUGCemraem?= =?us-ascii?Q?9SvhJbrG5ue+93ZU+Jt59u5lzC4Fmmf9B3r0ECpp9dKe9fFJzQVynNVZy9GT?= =?us-ascii?Q?SRUVhf4kOegLtL9Na96WRU5fZ0dYMfFXLz55Apfei1d60cYEExF8bycGCK2x?= =?us-ascii?Q?qj/EVkHpWdbJfz0yYv9bS3Pk2TFRRYnRSsNot60K12eUPC+Ho+F+BGO0tEWg?= =?us-ascii?Q?FUan2Tg19wl5vgRY2pJ0Kx6tJB2E4JZG3iDYjlx4i7iupleAz0MDIWM7uIUU?= =?us-ascii?Q?uuV2hAkvjGYahAA79bUHExqB3EbXPhIcEJ3NFsGnCU/tlPxQ2qQh/rzFP/i/?= =?us-ascii?Q?77Kr2wy3lAmqKuNjRVam4EmOvht9C2ygiaVCTdHkllQrVvyxmIsQQtQCIQF8?= =?us-ascii?Q?L9Ijd8MxRt7BtQUKTiBWpvioayuqmHciksi13j6yIVRvAlUTLAIau7fCTpUH?= =?us-ascii?Q?Tc0wuHfgJQRXLoSTzbKxZh8ncYOdRKDOcVXD6K/SPfMiP2jHUYkhAxGAe8En?= =?us-ascii?Q?HVIiPxotM4v7Alcx57W+EVcAiyzcekyBkNHXDuhlKb7qgKln3r+qYC+kIsKO?= =?us-ascii?Q?N2ZM96ySGq2sNYzaOMr95BsMOBieu5wbwCoviGyFu8MoxDCoYtAN6XFkx7RV?= =?us-ascii?Q?F0J4kKHbTTCSfvhVq9cQhd0Wv0+pQXXxjORAB61eO1A9lOGkGnOdVv+d8Up/?= =?us-ascii?Q?UndAHZfH8NbQcWMK5NSdRBz9z9VhYovk70xZVFM3a2nEp7PcqmqiRNQejdsw?= =?us-ascii?Q?QIahyg0/W+zkFx/0BhgGU1sbGAbEoFnFIYLiKbi0wduyXX+5dgA6sK4c3l24?= =?us-ascii?Q?Vv6yyzY6ls4/3dVtqQO6ub6Crxzj+DcWwww9ONhxaoD4zu/mCIkgMsovxeRv?= =?us-ascii?Q?lRdbiD2r/SiscSoyOhKaj6fhTGbq8jrZrBUk40TRSlkFKs0A5O+MYRBbuWRo?= =?us-ascii?Q?Izs2ZVdm7g9n2QeLLGBCCdDjXPhJt8yXlXQqHzthYhEVxuFW/0UXbUxRsD4R?= =?us-ascii?Q?mosUjMyyILcK8cBlhquAA5cnxdO60ocRjLmra7pP9rCIJ56GVrVCjkvecJK3?= =?us-ascii?Q?vgyNQ0fbwqP/V64+yGhpWkJEq2lYZgnDxmIpLGH665lbaDdyCFu3P63fhdHU?= =?us-ascii?Q?UN/1UR/HVjxS+yo=3D?= X-Forefront-Antispam-Report: CIP:165.204.84.17;CTRY:US;LANG:en;SCL:1;SRV:;IPV:CAL;SFV:NSPM;H:SATLEXMB04.amd.com;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(13230040)(7416014)(376014)(1800799024)(36860700013)(82310400026)(13003099007);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 22 Jan 2025 20:23:47.9122 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 6aaa66a7-898c-4f56-2a86-08dd3b22ad5c 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: CH1PEPF0000A347.namprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: IA0PR12MB7604 Content-Type: text/plain; charset="utf-8" Provide the interface to list the assignment states of all the resctrl groups in mbm_cntr_assign mode. Example: $ mount -t resctrl resctrl /sys/fs/resctrl/ $ cat /sys/fs/resctrl/info/L3_MON/mbm_assign_control //0=3Dtl;1=3Dtl 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 assigned l MBM local event is assigned tl Both total and local MBM events are assigned _ None of the MBM events are assigned Signed-off-by: Babu Moger --- v11: Fixed printing the separator after each domain while listing the group= assignments. Renamed rdtgroup_mbm_assign_control_show to resctrl_mbm_assign_control= _show(). v10: Changes mostly due to domain specific counter assignment. v9: Minor parameter update in resctrl_mbm_event_assigned(). v8: Moved resctrl_mbm_event_assigned() in here as it is first used here. Moved rdt_last_cmd_clear() before making any call. Updated the commit log. Corrected the doc format. v7: Renamed the interface name from 'mbm_control' to 'mbm_assign_control' to match 'mbm_assign_mode'. Removed Arch references from FS code. Added rdt_last_cmd_clear() before the command processing. Added rdtgroup_mutex before all the calls. Removed references of ABMC from FS code. v6: The domain specific assignment can be determined looking at mbm_cntr_ma= p. Removed rdtgroup_abmc_dom_cfg() and rdtgroup_abmc_dom_state(). Removed the switch statement for the domain_state detection. Determined the flags incremently. Removed special handling of default group while printing.. v5: Replaced "assignment flags" with "flags". Changes related to mon structure. Changes related renaming the interface from mbm_assign_control to mbm_control. v4: Added functionality to query domain specific assigment in. rdtgroup_abmc_dom_state(). v3: New patch. Addresses the feedback to provide the global assignment interface. https://lore.kernel.org/lkml/c73f444b-83a1-4e9a-95d3-54c5165ee782@intel= .com/ --- Documentation/arch/x86/resctrl.rst | 44 ++++++++++++++ arch/x86/kernel/cpu/resctrl/monitor.c | 1 + arch/x86/kernel/cpu/resctrl/rdtgroup.c | 81 ++++++++++++++++++++++++++ 3 files changed, 126 insertions(+) diff --git a/Documentation/arch/x86/resctrl.rst b/Documentation/arch/x86/re= sctrl.rst index 5d18c4c8bc48..3040e5c4cd76 100644 --- a/Documentation/arch/x86/resctrl.rst +++ b/Documentation/arch/x86/resctrl.rst @@ -330,6 +330,50 @@ with the following files: # cat /sys/fs/resctrl/info/L3_MON/available_mbm_cntrs 0=3D30;1=3D30 =20 +"mbm_assign_control": + Reports the resctrl group and monitor status of each group. + + List follows the following format: + "//=3D" + + Format for specific type of groups: + + * Default CTRL_MON group: + "//=3D" + + * Non-default CTRL_MON group: + "//=3D" + + * Child MON group of default CTRL_MON group: + "//=3D" + + * Child MON group of non-default CTRL_MON group: + "//=3D" + + Flags can be one of the following: + :: + + t MBM total event is assigned. + l MBM local event is assigned. + tl Both MBM total and local events are assigned. + _ None of the MBM events are assigned. + + 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_assign_control + non_default_ctrl_mon_grp//0=3Dtl;1=3Dtl + non_default_ctrl_mon_grp/child_non_default_mon_grp/0=3Dtl;1=3Dtl + //0=3Dtl;1=3Dtl + /child_default_mon_grp/0=3Dtl;1=3Dtl + + There are four resctrl groups. All the groups have total and local MBM ev= ents + assigned on domain 0 and 1. + "max_threshold_occupancy": Read/write file provides the largest value (in bytes) at which a previously used LLC_occupancy diff --git a/arch/x86/kernel/cpu/resctrl/monitor.c b/arch/x86/kernel/cpu/re= sctrl/monitor.c index 024aabbecbb5..2dd6c47c9276 100644 --- a/arch/x86/kernel/cpu/resctrl/monitor.c +++ b/arch/x86/kernel/cpu/resctrl/monitor.c @@ -1236,6 +1236,7 @@ int __init rdt_get_mon_l3_config(struct rdt_resource = *r) hw_res->mbm_cntr_assign_enabled =3D true; resctrl_file_fflags_init("num_mbm_cntrs", RFTYPE_MON_INFO); resctrl_file_fflags_init("available_mbm_cntrs", RFTYPE_MON_INFO); + resctrl_file_fflags_init("mbm_assign_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 5d305d0ac053..6e29827239e0 100644 --- a/arch/x86/kernel/cpu/resctrl/rdtgroup.c +++ b/arch/x86/kernel/cpu/resctrl/rdtgroup.c @@ -975,6 +975,81 @@ static ssize_t resctrl_mbm_assign_mode_write(struct ke= rnfs_open_file *of, return ret ?: nbytes; } =20 +static char *rdtgroup_mon_state_to_str(struct rdt_resource *r, + struct rdt_mon_domain *d, + struct rdtgroup *rdtgrp, char *str) +{ + char *tmp =3D str; + + /* Query the total and local event flags for the domain */ + if (mbm_cntr_get(r, d, rdtgrp, QOS_L3_MBM_TOTAL_EVENT_ID) !=3D -ENOENT) + *tmp++ =3D 't'; + + if (mbm_cntr_get(r, d, rdtgrp, QOS_L3_MBM_LOCAL_EVENT_ID) !=3D -ENOENT) + *tmp++ =3D 'l'; + + if (tmp =3D=3D str) + *tmp++ =3D '_'; + + *tmp =3D '\0'; + return str; +} + +static int resctrl_mbm_assign_control_show(struct kernfs_open_file *of, + struct seq_file *s, void *v) +{ + struct rdt_resource *r =3D of->kn->parent->priv; + struct rdtgroup *rdtg, *crg; + struct rdt_mon_domain *dom; + char str[10]; + bool sep; + + cpus_read_lock(); + mutex_lock(&rdtgroup_mutex); + rdt_last_cmd_clear(); + + if (!resctrl_arch_mbm_cntr_assign_enabled(r)) { + rdt_last_cmd_puts("mbm_cntr_assign mode is not enabled\n"); + mutex_unlock(&rdtgroup_mutex); + cpus_read_unlock(); + return -EINVAL; + } + + list_for_each_entry(rdtg, &rdt_all_groups, rdtgroup_list) { + seq_printf(s, "%s//", rdtg->kn->name); + + sep =3D false; + list_for_each_entry(dom, &r->mon_domains, hdr.list) { + if (sep) + seq_puts(s, ";"); + + seq_printf(s, "%d=3D%s", dom->hdr.id, + rdtgroup_mon_state_to_str(r, dom, rdtg, str)); + + sep =3D true; + } + seq_putc(s, '\n'); + + list_for_each_entry(crg, &rdtg->mon.crdtgrp_list, mon.crdtgrp_list) { + seq_printf(s, "%s/%s/", rdtg->kn->name, crg->kn->name); + + sep =3D false; + list_for_each_entry(dom, &r->mon_domains, hdr.list) { + if (sep) + seq_puts(s, ";"); + seq_printf(s, "%d=3D%s", dom->hdr.id, + rdtgroup_mon_state_to_str(r, dom, crg, str)); + sep =3D true; + } + seq_putc(s, '\n'); + } + } + + mutex_unlock(&rdtgroup_mutex); + cpus_read_unlock(); + return 0; +} + #ifdef CONFIG_PROC_CPU_RESCTRL =20 /* @@ -1996,6 +2071,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_assign_control", + .mode =3D 0444, + .kf_ops =3D &rdtgroup_kf_single_ops, + .seq_show =3D resctrl_mbm_assign_control_show, + }, { .name =3D "mbm_assign_mode", .mode =3D 0644, --=20 2.34.1 From nobody Wed Feb 11 05:40:54 2026 Received: from NAM12-MW2-obe.outbound.protection.outlook.com (mail-mw2nam12on2072.outbound.protection.outlook.com [40.107.244.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 044D9217655; Wed, 22 Jan 2025 20:24:01 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.244.72 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1737577444; cv=fail; b=igL8IcnOI//ODs+9RGaCA1ucKtI0olvm6vXiyVK5Hnj28uwPVH6V75o3uLeZzYQLocHCP14+rylxcHYEFz60khfyT0rVx89zssepbUS5FlmVOEfB7laFununrqD8oC2ooCVZtjRKDnnwcsg9f5NvLWdWpgZDfolHxTzSbp/n3o0= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1737577444; c=relaxed/simple; bh=wZJIdvfQhT2zB1jsJeb7wSQBw8wCfN0hjqlMAT8GE2E=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=IWSJ1pY8Bcv0i6A8NWnZGiJlI1+gzKU7GxYTrIlHPg10LKJP0/pisNYVXjqSAHVnOhwjIq9Qa0ToLyMykNk8V3N2mMA7mWh0BM6l2j5cJ3r9C8ojTwwvQhvLBtr0u5IKCADok+zzObNkf9gJtK+ikl2Cj/ETwLw1D7R7QbMoT9o= 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=A87veTWw; arc=fail smtp.client-ip=40.107.244.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="A87veTWw" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=sIF0HKYx6hmIUz8uKM8leQxaL9+c5luXd1sF7e0Ykml3b12UvtnU0KIsWLGc2ykRUh3YsLfv9CUEdoxZTwIl9pSiqAm6f3sITqkC2JoCvd+S3N+E8UlKli905k8V717INnaJ2IEohp6LYxGbhtW0L2vuymAkFIGNv0m1r8JkWyJj+9rILZpwPXL9WocHTq6vUzJEEdqrd6nxXnaXF93/epHyeqTi+C/YPrhYkhO+Y+ZivAywbmShD4411XP/IN456om8wQxuX7nzCD/D0dxxpEOofhCchVuVLtjJv/tI8HeTh6JFcYs/CXF+qkRhWUXIWLmx/Mq+mHrDVo95cjDs8w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=Ra1VRAElPMsU0pELvWluObkjlIr38D9Z82Ls1r/EjBM=; b=DN8NjXpJFTzVjfB0g7lDRxAw2BSZAZg+SRtVAogXScTUd9yi+wgFqJkk81h7cgv3aWbRVIgJpuv8ZIj64m4Cbbhfbsups+m+IrZ6uN1LrSPRsTkrI/SlD+l96f+FsjBiFdg84NANmfCabsUfo3IxFFMo53BTNc7JZfeRzSf682Dd2v/JLWSmeBmmbLz0DaXx1G+J5F7xAZmIzMCUklbsfW1HlxwKKTpznTtFbHTWos+e51029dlNJiqcfYcG17CeI7F7QosRT/XT8i/b6vLyqZg1SAs97CmVx+g7YRHzD7/U+VvjV6N8SRbMAm4qomySMA4U708IF8vCkI/Vk4/JHw== 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=Ra1VRAElPMsU0pELvWluObkjlIr38D9Z82Ls1r/EjBM=; b=A87veTWwQcLHzoyYteRZwaRQcTzY8UOodFZw+QxefykHmdj8iNIlkW2iAWwgu105ZFEzQVAgrfbzwG9nktDw+fndC4pdCtfIBSwcMrboJjUUjvb/D68MiGD1yhhaIo9833/OFT7JzmOxmdcIAz5ffDxXrkUH4JaPeKSQtXhjEu8= Received: from CH0PR03CA0393.namprd03.prod.outlook.com (2603:10b6:610:11b::21) by MN0PR12MB6319.namprd12.prod.outlook.com (2603:10b6:208:3c0::11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8377.17; Wed, 22 Jan 2025 20:23:56 +0000 Received: from CH1PEPF0000A348.namprd04.prod.outlook.com (2603:10b6:610:11b:cafe::87) by CH0PR03CA0393.outlook.office365.com (2603:10b6:610:11b::21) with Microsoft SMTP Server (version=TLS1_3, cipher=TLS_AES_256_GCM_SHA384) id 15.20.8377.14 via Frontend Transport; Wed, 22 Jan 2025 20:23: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 CH1PEPF0000A348.mail.protection.outlook.com (10.167.244.4) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.8377.8 via Frontend Transport; Wed, 22 Jan 2025 20:23: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, 22 Jan 2025 14:23:54 -0600 From: Babu Moger To: , , , , , , , CC: , , , , , , , , , , , , , , , , , , , , , , , , , , Subject: [PATCH v11 23/23] x86/resctrl: Introduce interface to modify assignment states of the groups Date: Wed, 22 Jan 2025 14:20:31 -0600 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-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-ClientProxiedBy: SATLEXMB04.amd.com (10.181.40.145) To SATLEXMB04.amd.com (10.181.40.145) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CH1PEPF0000A348:EE_|MN0PR12MB6319:EE_ X-MS-Office365-Filtering-Correlation-Id: 5a77854f-f8b0-4239-a8b0-08dd3b22b218 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|7416014|376014|1800799024|36860700013|82310400026; X-Microsoft-Antispam-Message-Info: =?utf-8?B?QmNVYjhBMWhkVU5XRk1nVkNMZGljZlBOTTZnYk81THlzYVdTVEtreVBlVi9R?= =?utf-8?B?Y2ZjdUxwVHZqd2w0ZzZkU0wwT3Zqb09mS01hanQ1Y2kvdGZjb1l4cVpnRlVz?= =?utf-8?B?VCtNaFg2WlJVdTUxTUhFNjVOb0lHNTZYWkdLMmRSYmRqVy94dWNoZjBpV3Rm?= =?utf-8?B?L2xmZEFJb1M4M2hKN01WZCtvdDhSa25tUzBLVDYyZnJyR1JYTXRWYjJoTml0?= =?utf-8?B?NVd2a012TDlCU2poYTVyWFRPai9DUndzK1Z6ekFpdG1jNlVicUlVV1orSUpq?= =?utf-8?B?d2xYMnFxdlArRWxKbE1CY3kySnFFYUQrenN3SmhnOVRvZUVGZEFXbUdERThZ?= =?utf-8?B?ejlFYmhJYUVCK2FxQTRrN1dVenRJWnpQeHNiKzhoZ1hSV01iYk5ZaG5SR1Zt?= =?utf-8?B?dm9TcVNmbGZTbWVvWUMzYlQwY3lmWHQ5TDEwbU16b2hKYU1tYWpuSGRXNC8x?= =?utf-8?B?SFJ3L1dlSlYrRmlxL3Q5VnZwRkpMLy9RVlc4aFIzM29HNW9rM1dYd3JRVXlB?= =?utf-8?B?L0JmMTRoazR4VkFqYkJ5dHNnY1pTZ1djSDJVU01nNUswOHdLbldwaUIrWGRO?= =?utf-8?B?c1lZalVNeXRpOGpZZ3UxeGJMVEVucUxSUXk1SW5jbjNJNklRQW9IeUtYUGd6?= =?utf-8?B?b1ZSM3lMbStFaWZVSURXbllGblNQUHpUNUdLUnV6K2I4VWp4M3NQYW8xZTZH?= =?utf-8?B?VnlzaXFGMitRUFlRME1Qa3pkc2QwZG11Nlg5TEg0cGlnbVpuV0NaM0U0a0Qw?= =?utf-8?B?akNmblFHZTZhVUxRcFJ5MktiRkgzMTF0c1NYUVhkcjM0QzdJQkR0aXJJYkx3?= =?utf-8?B?Mm1kaWpDOXNQOC9RUG51Z1NBOEtZNnBQVDRSQ05rdkt1aEVqNmV6ZXBwUEIw?= =?utf-8?B?aDd3VGYwbUxVNi80amlVajYvL3FFTmR1Wm1YWTFidFBhWWNrcjRHS2dDWDRi?= =?utf-8?B?bk1paHVseUgxaEFGOGF5S0xFcE45N3hGVHdUVWM2SDRzc1g3VWVQbU1GZHdR?= =?utf-8?B?Z0xudnNQdllmWFd2NjVZMzBYdDdRRVZaZFhTNWNDM09LTmhoRGZhSmdvMjk1?= =?utf-8?B?d3NTekh1N3g1MlFaTWNoaFMwWEEzRHNMT25HZ1duZmpJcDhSTVB3dXRXczU3?= =?utf-8?B?eHJnSTlObVZ2aGo0WVRqanBHWTk5ZFVYb1BvTHZaU0N2RWR0N3Fjb3MrZkVx?= =?utf-8?B?bFBKanBpNjkrbEU3TlF5WkpmeWtZZm8wT3M4Zmx0M3VWSk9GRE9uNjFXZGVy?= =?utf-8?B?MFJoNE5CdTVaci9qUmNiekptVGl2S0NucXZNMmdTa1AxVzJLWERkYWZHSEV4?= =?utf-8?B?VyszNDFqLzhnSnJqU25ZOHg5MjNSMGtpRzl6T1NjYWJ5Y0tTRGZqR1hOMVQ1?= =?utf-8?B?b2lyb0xwSFZady9HSCtycTZEUCtmU1QzaGY1R0lMK0hxWmNjN2hDck1hdFhu?= =?utf-8?B?TndsS3JVbnp3bFJKS2h6aHRyUWxZQngxQkZqL1l2dndyc0Q3ZndMNHlGcE9O?= =?utf-8?B?ZzgrbXF1MmgvYkszckpFRm53RmQ3VlhHZk0zdFJ4STZVdEZhaUlpUlNYMTFa?= =?utf-8?B?RTNhVGl0OW5Za2hHVWpXZUd5N1lndGkrVU9lWHJuM29UUlpYL1dXOUt3VnQx?= =?utf-8?B?R1F6VFBjcTBmOGxzalY4UVkwUDFYNXl0bXl2V2lEN1MxUVhheDl0MFYvcHFo?= =?utf-8?B?REJuQ2RhRFI1OVZ2Mkp1MDIrdTE0RGFoQkFQL3ZoMUpxWkdrQUdudS9aODBr?= =?utf-8?B?R1BXemt3b1lvcVEwRUVITy92UWFZVitseFB6WWs3ZW5VUHdSbDRnOTlPY0Rq?= =?utf-8?B?Uy90cXJaWFRFWHkyNWt0Rkc5a0FQRENCMm9EcjB6Sjk2ME9tb29qUVZZcTVw?= =?utf-8?B?UmE5S2xqeW9UUUF2Z2ZrSzlQQS9sdHBHZXVNei9PY0NFZDJyMnBSUEs2YXJa?= =?utf-8?B?WEFtT0tYbExXdnA3alkzOXdmYUJ6by9KOUpHcSthYnd6bjlzQ1NML0U0NXFq?= =?utf-8?Q?G5OkrWmUG+VjLyO5L2lyUwDv6DTdUk=3D?= X-Forefront-Antispam-Report: CIP:165.204.84.17;CTRY:US;LANG:en;SCL:1;SRV:;IPV:CAL;SFV:NSPM;H:SATLEXMB04.amd.com;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(13230040)(7416014)(376014)(1800799024)(36860700013)(82310400026);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 22 Jan 2025 20:23:55.8428 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 5a77854f-f8b0-4239-a8b0-08dd3b22b218 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: CH1PEPF0000A348.namprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: MN0PR12MB6319 When mbm_cntr_assign mode is enabled, users can designate which of the MBM events in the CTRL_MON or MON groups should have counters assigned. Provide an interface for assigning MBM events by writing to the file: /sys/fs/resctrl/info/L3_MON/mbm_assign_control. Using this interface, events can be assigned or unassigned as needed. Format is similar to the list format with addition of opcode for the assignment operation. "//" Format for specific type of groups: * Default CTRL_MON group: "//" * Non-default CTRL_MON group: "//" * Child MON group of default CTRL_MON group: "//" * Child MON group of non-default CTRL_MON group: "//" Domain_id '*' will apply the flags on all the domains. Opcode can be one of the following: =3D Update the assignment to match the flags + Assign a new MBM event without impacting existing assignments. - Unassign a MBM event from currently assigned events. Assignment flags can be one of the following: t MBM total event l MBM local event tl Both total and local MBM events _ None of the MBM events. Valid only with '=3D' opcode. This flag cannot be combined with other flags. Signed-off-by: Babu Moger --- v11: Fixed the static check warning with initializing dom_id in resctrl_pro= cess_flags(). v10: Fixed the issue with finding the domain in multiple iterations. Printed error message with domain information when assign fails. Changed the variables to unsigned for processing assign state. Taken care of few format corrections. v9: Fixed handling special case '//0=3D' and '//". Removed extra strstr() call. Added generic failure text when assignment operation fails. Corrected user documentation format texts. v8: Moved unassign as the first action during the assign modification. Assign none "_" takes priority. Cannot be mixed with other flags. Updated the documentation and .rst file format. htmldoc looks ok. v7: Simplified the parsing (strsep(&token, "//") in rdtgroup_mbm_assign_con= trol_write(). Added mutex lock in rdtgroup_mbm_assign_control_write() while processin= g. Renamed rdtgroup_find_grp to rdtgroup_find_grp_by_name. Fixed rdtgroup_str_to_mon_state to return error for invalid flags. Simplified the calls rdtgroup_assign_cntr by merging few functions earl= ier. Removed ABMC reference in FS code. Reinette commented about handling the combination of flags like 'lt_' a= nd '_lt'. Not sure if we need to change the behaviour here. Processed them sequen= cially right now. Users have the liberty to pass the flags. Restricting it might be a pro= blem later. v6: Added support assign all if domain id is '*' Fixed the allocation of counter id if it not assigned already. v5: Interface name changed from mbm_assign_control to mbm_control. Fixed opcode and flags combination. '=3D_" is valid. "-_" amd "+_" is not valid. Minor message update. Renamed the function with prefix - rdtgroup_. Corrected few documentation mistakes. Rebase related changes after SNC support. v4: Added domain specific assignments. Fixed the opcode parsing. v3: New patch. Addresses the feedback to provide the global assignment interface. --- Documentation/arch/x86/resctrl.rst | 116 +++++++++++- arch/x86/kernel/cpu/resctrl/internal.h | 10 + arch/x86/kernel/cpu/resctrl/rdtgroup.c | 241 ++++++++++++++++++++++++- 3 files changed, 365 insertions(+), 2 deletions(-) diff --git a/Documentation/arch/x86/resctrl.rst b/Documentation/arch/x86/re= sctrl.rst index 3040e5c4cd76..47e15b48d951 100644 --- a/Documentation/arch/x86/resctrl.rst +++ b/Documentation/arch/x86/resctrl.rst @@ -356,7 +356,8 @@ with the following files: t MBM total event is assigned. l MBM local event is assigned. tl Both MBM total and local events are assigned. - _ None of the MBM events are assigned. + _ None of the MBM events are assigned. Only works with opcode '=3D' for= write + and cannot be combined with other flags. =20 Examples: :: @@ -374,6 +375,119 @@ with the following files: There are four resctrl groups. All the groups have total and local MBM ev= ents assigned on domain 0 and 1. =20 + Assignment state can be updated by writing to "mbm_assign_control". + + Format is similar to the list format with addition of opcode for the + assignment operation. + + "//" + + Format for each type of group: + + * Default CTRL_MON group: + "//" + + * Non-default CTRL_MON group: + "//" + + * Child MON group of default CTRL_MON group: + "//" + + * Child MON group of non-default CTRL_MON group: + "//" + + Domain_id '*' will apply the flags to all the domains. + + Opcode can be one of the following: + :: + + =3D Update the assignment to match the MBM event. + + Assign a new MBM event without impacting existing assignments. + - Unassign a MBM event from currently assigned events. + + Examples: + Initial group status: + :: + + # cat /sys/fs/resctrl/info/L3_MON/mbm_assign_control + non_default_ctrl_mon_grp//0=3Dtl;1=3Dtl + non_default_ctrl_mon_grp/child_non_default_mon_grp/0=3Dtl;1=3Dtl + //0=3Dtl;1=3Dtl + /child_default_mon_grp/0=3Dtl;1=3Dtl + + To update the default group to assign only total MBM event on domain 0: + :: + + # echo "//0=3Dt" > /sys/fs/resctrl/info/L3_MON/mbm_assign_control + + Assignment status after the update: + :: + + # cat /sys/fs/resctrl/info/L3_MON/mbm_assign_control + non_default_ctrl_mon_grp//0=3Dtl;1=3Dtl + non_default_ctrl_mon_grp/child_non_default_mon_grp/0=3Dtl;1=3Dtl + //0=3Dt;1=3Dtl + /child_default_mon_grp/0=3Dtl;1=3Dtl + + To update the MON group child_default_mon_grp to remove total MBM event o= n domain 1: + :: + + # echo "/child_default_mon_grp/1-t" > /sys/fs/resctrl/info/L3_MON/mbm_a= ssign_control + + Assignment status after the update: + :: + + # cat /sys/fs/resctrl/info/L3_MON/mbm_assign_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_gr= p to unassign + both local and total MBM events on domain 1: + :: + + # echo "non_default_ctrl_mon_grp/child_non_default_mon_grp/1=3D_" > + /sys/fs/resctrl/info/L3_MON/mbm_assign_control + + Assignment status after the update: + :: + + # cat /sys/fs/resctrl/info/L3_MON/mbm_assign_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=3Dt;1=3Dtl + /child_default_mon_grp/0=3Dtl;1=3Dl + + To update the default group to add a local MBM event domain 0: + :: + + # echo "//0+l" > /sys/fs/resctrl/info/L3_MON/mbm_assign_control + + Assignment status after the update: + :: + + # cat /sys/fs/resctrl/info/L3_MON/mbm_assign_control + non_default_ctrl_mon_grp//0=3Dtl;1=3Dtl + non_default_ctrl_mon_grp/child_non_default_mon_grp/0=3Dtl;1=3D_ + //0=3Dtl;1=3Dtl + /child_default_mon_grp/0=3Dtl;1=3Dl + + To update the non default CTRL_MON group non_default_ctrl_mon_grp to unas= sign all the + MBM events on all the domains: + :: + + # echo "non_default_ctrl_mon_grp//*=3D_" > /sys/fs/resctrl/info/L3_MON/= mbm_assign_control + + Assignment status after the update: + :: + + # cat /sys/fs/resctrl/info/L3_MON/mbm_assign_control + non_default_ctrl_mon_grp//0=3D_;1=3D_ + non_default_ctrl_mon_grp/child_non_default_mon_grp/0=3Dtl;1=3D_ + //0=3Dtl;1=3Dtl + /child_default_mon_grp/0=3Dtl;1=3Dl + "max_threshold_occupancy": Read/write file provides the largest value (in bytes) at which a previously used LLC_occupancy diff --git a/arch/x86/kernel/cpu/resctrl/internal.h b/arch/x86/kernel/cpu/r= esctrl/internal.h index aec564fa2833..377b5db66793 100644 --- a/arch/x86/kernel/cpu/resctrl/internal.h +++ b/arch/x86/kernel/cpu/resctrl/internal.h @@ -62,6 +62,16 @@ /* Setting bit 0 in L3_QOS_EXT_CFG enables the ABMC feature. */ #define ABMC_ENABLE_BIT 0 =20 +/* + * Assignment flags for mbm_cntr_assign mode + */ +enum { + ASSIGN_NONE =3D 0, + ASSIGN_TOTAL =3D BIT(QOS_L3_MBM_TOTAL_EVENT_ID), + ASSIGN_LOCAL =3D BIT(QOS_L3_MBM_LOCAL_EVENT_ID), + ASSIGN_INVALID, +}; + /** * cpumask_any_housekeeping() - Choose any CPU in @mask, preferring those = that * aren't marked nohz_full diff --git a/arch/x86/kernel/cpu/resctrl/rdtgroup.c b/arch/x86/kernel/cpu/r= esctrl/rdtgroup.c index 6e29827239e0..299839bcf23f 100644 --- a/arch/x86/kernel/cpu/resctrl/rdtgroup.c +++ b/arch/x86/kernel/cpu/resctrl/rdtgroup.c @@ -1050,6 +1050,244 @@ static int resctrl_mbm_assign_control_show(struct k= ernfs_open_file *of, return 0; } =20 +static unsigned int resctrl_str_to_mon_state(char *flag) +{ + unsigned int i, mon_state =3D ASSIGN_NONE; + + if (!strlen(flag)) + return ASSIGN_INVALID; + + 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 '_': + return ASSIGN_NONE; + default: + return ASSIGN_INVALID; + } + } + + return mon_state; +} + +static struct rdtgroup *rdtgroup_find_grp_by_name(enum rdt_group_type rtyp= e, + 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 resctrl_process_flags(struct rdt_resource *r, + enum rdt_group_type rtype, + char *p_grp, char *c_grp, char *tok) +{ + unsigned int op, mon_state, assign_state, unassign_state; + char *dom_str, *id_str, *op_str; + struct rdt_mon_domain *d; + unsigned long dom_id =3D 0; + struct rdtgroup *rdtgrp; + char domain[10]; + bool found; + int ret; + + rdtgrp =3D rdtgroup_find_grp_by_name(rtype, p_grp, c_grp); + + if (!rdtgrp) { + rdt_last_cmd_puts("Not a valid resctrl group\n"); + return -EINVAL; + } + +next: + if (!tok || tok[0] =3D=3D '\0') + return 0; + + /* Start processing the strings for each domain */ + dom_str =3D strim(strsep(&tok, ";")); + + op_str =3D strpbrk(dom_str, "=3D+-"); + + if (op_str) { + op =3D *op_str; + } else { + rdt_last_cmd_puts("Missing operation =3D, +, - character\n"); + return -EINVAL; + } + + id_str =3D strsep(&dom_str, "=3D+-"); + + /* Check for domain id '*' which means all domains */ + if (id_str && *id_str =3D=3D '*') { + d =3D NULL; + goto check_state; + } else if (!id_str || kstrtoul(id_str, 10, &dom_id)) { + rdt_last_cmd_puts("Missing domain id\n"); + return -EINVAL; + } + + /* Verify if the dom_id is valid */ + found =3D false; + list_for_each_entry(d, &r->mon_domains, hdr.list) { + if (d->hdr.id =3D=3D dom_id) { + found =3D true; + break; + } + } + + if (!found) { + rdt_last_cmd_printf("Invalid domain id %ld\n", dom_id); + return -EINVAL; + } + +check_state: + mon_state =3D resctrl_str_to_mon_state(dom_str); + + if (mon_state =3D=3D ASSIGN_INVALID) { + rdt_last_cmd_puts("Invalid assign flag\n"); + goto out_fail; + } + + 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 (unassign_state & ASSIGN_TOTAL) { + ret =3D resctrl_unassign_cntr_event(r, d, rdtgrp, QOS_L3_MBM_TOTAL_EVENT= _ID); + if (ret) + goto out_fail; + } + + if (unassign_state & ASSIGN_LOCAL) { + ret =3D resctrl_unassign_cntr_event(r, d, rdtgrp, QOS_L3_MBM_LOCAL_EVENT= _ID); + if (ret) + goto out_fail; + } + + if (assign_state & ASSIGN_TOTAL) { + ret =3D resctrl_assign_cntr_event(r, d, rdtgrp, QOS_L3_MBM_TOTAL_EVENT_I= D); + if (ret) + goto out_fail; + } + + if (assign_state & ASSIGN_LOCAL) { + ret =3D resctrl_assign_cntr_event(r, d, rdtgrp, QOS_L3_MBM_LOCAL_EVENT_I= D); + if (ret) + goto out_fail; + } + + goto next; + +out_fail: + sprintf(domain, d ? "%ld" : "*", dom_id); + + rdt_last_cmd_printf("Assign operation '%s%c%s' failed on the group %s/%s/= \n", + domain, op, dom_str, p_grp, c_grp); + + return -EINVAL; +} + +static ssize_t resctrl_mbm_assign_control_write(struct kernfs_open_file *o= f, + char *buf, size_t nbytes, loff_t off) +{ + struct rdt_resource *r =3D of->kn->parent->priv; + char *token, *cmon_grp, *mon_grp; + enum rdt_group_type rtype; + int ret; + + /* Valid input requires a trailing newline */ + if (nbytes =3D=3D 0 || buf[nbytes - 1] !=3D '\n') + return -EINVAL; + + buf[nbytes - 1] =3D '\0'; + + cpus_read_lock(); + mutex_lock(&rdtgroup_mutex); + + rdt_last_cmd_clear(); + + if (!resctrl_arch_mbm_cntr_assign_enabled(r)) { + rdt_last_cmd_puts("mbm_cntr_assign mode is not enabled\n"); + mutex_unlock(&rdtgroup_mutex); + cpus_read_unlock(); + return -EINVAL; + } + + while ((token =3D strsep(&buf, "\n")) !=3D NULL) { + /* + * The write command follows the following format: + * =E2=80=9C//=E2= =80=9D + * Extract the CTRL_MON group. + */ + cmon_grp =3D strsep(&token, "/"); + + /* + * Extract the MON_GROUP. + * strsep returns empty string for contiguous delimiters. + * Empty mon_grp here means it is a RDTCTRL_GROUP. + */ + mon_grp =3D strsep(&token, "/"); + + if (*mon_grp =3D=3D '\0') + rtype =3D RDTCTRL_GROUP; + else + rtype =3D RDTMON_GROUP; + + ret =3D resctrl_process_flags(r, rtype, cmon_grp, mon_grp, token); + if (ret) + break; + } + + mutex_unlock(&rdtgroup_mutex); + cpus_read_unlock(); + + return ret ?: nbytes; +} + #ifdef CONFIG_PROC_CPU_RESCTRL =20 /* @@ -2073,9 +2311,10 @@ static struct rftype res_common_files[] =3D { }, { .name =3D "mbm_assign_control", - .mode =3D 0444, + .mode =3D 0644, .kf_ops =3D &rdtgroup_kf_single_ops, .seq_show =3D resctrl_mbm_assign_control_show, + .write =3D resctrl_mbm_assign_control_write, }, { .name =3D "mbm_assign_mode", --=20 2.34.1