From nobody Mon Oct 6 01:21:10 2025 Received: from NAM02-SN1-obe.outbound.protection.outlook.com (mail-sn1nam02on2070.outbound.protection.outlook.com [40.107.96.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 B3392248869; Fri, 25 Jul 2025 18:30:27 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.96.70 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1753468229; cv=fail; b=E+dNO3NC8C9i+RK2vkzGvkwc3TgEAkBxfW/algmTbBwjgpXLX0d9co6yMsZjxuCbERphnwZJmHV9KgJTfJNr5xe+KjVXCfO9UsBk8oPL9vI/PL5G4DHLKI/RPToBzG9JxUIaGLymXiiYg0aRg5Bz+X0KCmINx/v0KrJVE1pUMd8= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1753468229; c=relaxed/simple; bh=PQtYcn0iyZ16Gg0giG6SH4tsoC5AVPlBzZab273Jupg=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=OliwhN6FUAg6CGJFNBCJQ4BkGOD82/j09wj7uyzBFCchqfyn62C9yBtqfG85leT2+nKDol8yXlCK/4wa8pb+Y/IytD6fmrtJ8CrJAQ3lXNCSfSIPXaXkAOCp56PwgcSXqzsSQ0jNlFoj1I/JPUjDqQuB+Sh2M/jsLDFnGkwPof4= 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=wGkA1UDs; arc=fail smtp.client-ip=40.107.96.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="wGkA1UDs" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=B77T417PWR5bcLygPEmL2pU7/5IWdmoq0d7Ns4XIwEMv95w6OnY8eZinerW/EklelymOTTv4Q/p6aoEic23rwHYuM6EzIroGFBF7ANg++izh6mdSfAMo/QPGjZb00mqGzoneZQq9L0wkSjeEamua6RibHhG64+lEFfSM6XizBFhNsm6U1d9hy9YzRyfmjDZnQgQwoUnpjwFJgsXuxIZyEPvlXhWt0Ldpl/gi4LcEq+l2X0S/lHAAIDyig532rG9Q9NhspM+QDOwLVG+1ul52faAP3hvn1ISc6VunHWOokbyA0m13M3JMKYmxqvBdOHvlU5vuyxde/oX35fqzq3XheA== 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=V73REeLkcPpC4b6iBiWhbphtCeB8hbGCKHOLhwaoiMU=; b=DZaJER5n63EraY0z1kuScHM17YWvpl4pSzqyiTq++c6cRfV2C8V2VXyrPLjarp2BibxU+m3osRtFnbt2Ni3xdOFN0SOoC8aqwdqk0So68lkjNU3CWd4osW0HZdppL5zg72ULGAljiKF1Lae9czwzwniizxtPuezJ5upJ75O9Qo3lJCLoahhJ10DzmZ0PCOeWn0+IrAtlOAHru/SlsCxJbZd3jDbu4qF0VzhZPSh89mVHLYen4/EERf7XM69i4iAQDxj6gRWx1bMR7e4ILhJGf6a2PIJvj0tRgi6MK8tcyVyMq+gXeqFK0tEkGG5Z98vZR4sWQQySIg/af64Ej5gCTA== 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=V73REeLkcPpC4b6iBiWhbphtCeB8hbGCKHOLhwaoiMU=; b=wGkA1UDshEhgJjJJ2dhADxlA95Kisr66/EXJBKga3e6+BUG8O87me0rgDzl7Eo8gyXwO7DkLldtRWgm5pvNTrLTA1KVVec6xaaFolKwgkABVwb2VdDH7o+0TObUfRNYT/86ML0zD7m20xOI0H9OERjjzWgB1ddUfWBtLrts4kQc= Received: from SN6PR04CA0089.namprd04.prod.outlook.com (2603:10b6:805:f2::30) by PH0PR12MB5607.namprd12.prod.outlook.com (2603:10b6:510:142::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8964.21; Fri, 25 Jul 2025 18:30:23 +0000 Received: from SA2PEPF000015CC.namprd03.prod.outlook.com (2603:10b6:805:f2:cafe::7b) by SN6PR04CA0089.outlook.office365.com (2603:10b6:805:f2::30) with Microsoft SMTP Server (version=TLS1_3, cipher=TLS_AES_256_GCM_SHA384) id 15.20.8964.23 via Frontend Transport; Fri, 25 Jul 2025 18:30:23 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 165.204.84.17) smtp.mailfrom=amd.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=amd.com; Received-SPF: Pass (protection.outlook.com: domain of amd.com designates 165.204.84.17 as permitted sender) receiver=protection.outlook.com; client-ip=165.204.84.17; helo=SATLEXMB04.amd.com; pr=C Received: from SATLEXMB04.amd.com (165.204.84.17) by SA2PEPF000015CC.mail.protection.outlook.com (10.167.241.202) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.8964.20 via Frontend Transport; Fri, 25 Jul 2025 18:30:23 +0000 Received: from bmoger-ubuntu.amd.com (10.180.168.240) by SATLEXMB04.amd.com (10.181.40.145) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.39; Fri, 25 Jul 2025 13:30:20 -0500 From: Babu Moger To: , , , , , , , CC: , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , Subject: [PATCH v16 01/34] x86,fs/resctrl: Consolidate monitor event descriptions Date: Fri, 25 Jul 2025 13:29:20 -0500 Message-ID: <404b149d4e717fa7e7f93cbe85cd5abd990202ca.1753467772.git.babu.moger@amd.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: References: Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-ClientProxiedBy: SATLEXMB03.amd.com (10.181.40.144) To SATLEXMB04.amd.com (10.181.40.145) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: SA2PEPF000015CC:EE_|PH0PR12MB5607:EE_ X-MS-Office365-Filtering-Correlation-Id: 83686049-813e-4e32-6dcf-08ddcba9516f X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|376014|7416014|82310400026|36860700013|1800799024; X-Microsoft-Antispam-Message-Info: =?us-ascii?Q?d33hoe02CGcvUqnBMxl5dKgRLhK9B35isLnU7ZOi4+n3/HYtaPoeaKx/SV0E?= =?us-ascii?Q?5lv1HlNSS2qecrosIWNh5rTBCjPQRfqkZ2iW3DSbB3u+7rdA5LYR3jAXgex2?= =?us-ascii?Q?cBf1RTtagxPgkpxzCc6rwf1HOs4UbEiRdq2BE2ZgJWnet4ej+4hhK2Zh6r2a?= =?us-ascii?Q?9h8p4/a2+KtyShkKOq6N+e6Gc6ywLyXHw84Q9iB8gdJzJvZkmntb7o6SOuD1?= =?us-ascii?Q?8PKOiV2oMXdJ5SM8C8koSyRSfbYtVcyTPU2NvKf+401n8UZTI3NQhlNxe/8d?= =?us-ascii?Q?W13mT1i9ws0qDzDepp94IrrqQ1mRzRFUIudl07hDB67y3/TjgBZUQDRPlOX/?= =?us-ascii?Q?ResiqjpyOO2o0ybJeQNehHoBazYJUJOuFPXY+a3xYhWom2fkCxjLFhapBWnx?= =?us-ascii?Q?gEKrKWbxc9fCbWdfELoC0ZmlgINhluiLNcbeLZxdyBsAMoYyx4vaVyj3IFhn?= =?us-ascii?Q?ExDVD0iSx40YWQ3iCn4nYTE8sJbazmcclP1unEzocGMabc3TGRyrpY8N8Eri?= =?us-ascii?Q?b0yNBnTAOOQ9aZfp8NK4nV3gzUW6+MCo9MBU9nw8r8Bgkm3/O4qPcUSm2ie7?= =?us-ascii?Q?A5dpQo9Lz1ZCj0gS8iJgoC70pZFrKaOZE3tZoylQ8Lg1XnrhQvTWQ1cnoQyO?= =?us-ascii?Q?Mo/k4h0b6Ikq0gQOrxXoCHuC8cGuvFyL59uPvnKOA0y8bv19h5YpKQZbQVur?= =?us-ascii?Q?BokynDjqlAssUHjGu+EqLuzdT6Zaq5mB/6yOS+LA+4ueTe6K3gR/6+Xy3FMP?= =?us-ascii?Q?Ai4yp8FNxiEr8yGx4Hwd4Xl2onDld4t0xaK0grdaMXEhoa/nY+jt+/yDNuW/?= =?us-ascii?Q?HEI2zUVaOKEeGvIu9w+NkiNY6YfCa8ibVoNIQbh4lMTkTvD5omxWi5NjgsDy?= =?us-ascii?Q?Is8irR4iX+iCyeRdCGYZJcTgGdvKhaQ7SsIBRkEN5YefDVzeAWAi4KPcSxcA?= =?us-ascii?Q?qpu3ZUnMhrWdZC8GwWO75DKP5s1Ab2+WBK3wGPNplftQkn3XvEmmLN7vAzVF?= =?us-ascii?Q?Bkx7G2zWf6EIt2MOTC/qrOZfyhN4C0flGkh31+Z+nTcqO9D5iTTYGLHX6Y94?= =?us-ascii?Q?M6yl1RfacZfO+EA3tz9i2z3CPPioEqLHZuGfiaZurSRIi0wkzmkCyfalks/A?= =?us-ascii?Q?aNG//RxHhF/fKH13FuySsWY0SRhPKr7y8iMCwA89NirmW2S3tMw7ceB4jVZd?= =?us-ascii?Q?ceFrkZRib58vpbDVbvr35SQxNvFrY++vMPuRUkPDJnDRsEpvnNopv2NPxSP5?= =?us-ascii?Q?SaQd37MB6gUArOiDsFBqOKSxQmSLly0PDWNA3du4MHliPxZbkKL+KQSINzvY?= =?us-ascii?Q?tbL/xtO6jQBq89Q4ucBGaB0tRPoa+YbyzUVb79emvXyWOvNtJgOUIJo9kLaW?= =?us-ascii?Q?bWm7kMitLjaxJNRX6T1yS17hTRj/UoHeCIs4Qb/uwf2dUctNmEPHIxgOO26Q?= =?us-ascii?Q?j6FOAKxwvYI0f3fqRCnvtPh8kPFUdV8pxbJ6If/NmGYFF5z0SDikQtmY4oha?= =?us-ascii?Q?H7AbYM+2g6sJyuhYRry4WcF5pQNlYqSsjEdP1fAf7hVa3fpcQ70L96xEHw?= =?us-ascii?Q?=3D=3D?= X-Forefront-Antispam-Report: CIP:165.204.84.17;CTRY:US;LANG:en;SCL:1;SRV:;IPV:CAL;SFV:NSPM;H:SATLEXMB04.amd.com;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(13230040)(376014)(7416014)(82310400026)(36860700013)(1800799024);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 25 Jul 2025 18:30:23.1956 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 83686049-813e-4e32-6dcf-08ddcba9516f 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: SA2PEPF000015CC.namprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH0PR12MB5607 Content-Type: text/plain; charset="utf-8" From: Tony Luck There are currently only three monitor events, all associated with the RDT_RESOURCE_L3 resource. Growing support for additional events will be easier with some restructuring to have a single point in file system code where all attributes of all events are defined. Place all event descriptions into an array mon_event_all[]. Doing this has the beneficial side effect of removing the need for rdt_resource::evt_list. Add resctrl_event_id::QOS_FIRST_EVENT for a lower bound on range checks for event ids and as the starting index to scan mon_event_all[]. Drop the code that builds evt_list and change the two places where the list is scanned to scan mon_event_all[] instead using a new helper macro for_each_mon_event(). Architecture code now informs file system code which events are available with resctrl_enable_mon_event(). Signed-off-by: Tony Luck Reviewed-by: Fenghua Yu Reviewed-by: Reinette Chatre --- Picked up first four patches from: https://lore.kernel.org/lkml/20250711235341.113933-1-tony.luck@intel.com/ These patches have already been reviewed. --- arch/x86/kernel/cpu/resctrl/core.c | 12 ++++-- fs/resctrl/internal.h | 13 ++++-- fs/resctrl/monitor.c | 63 +++++++++++++++--------------- fs/resctrl/rdtgroup.c | 11 +++--- include/linux/resctrl.h | 4 +- include/linux/resctrl_types.h | 12 ++++-- 6 files changed, 66 insertions(+), 49 deletions(-) diff --git a/arch/x86/kernel/cpu/resctrl/core.c b/arch/x86/kernel/cpu/resct= rl/core.c index 187d527ef73b..7fcae25874fe 100644 --- a/arch/x86/kernel/cpu/resctrl/core.c +++ b/arch/x86/kernel/cpu/resctrl/core.c @@ -864,12 +864,18 @@ static __init bool get_rdt_mon_resources(void) { struct rdt_resource *r =3D &rdt_resources_all[RDT_RESOURCE_L3].r_resctrl; =20 - if (rdt_cpu_has(X86_FEATURE_CQM_OCCUP_LLC)) + if (rdt_cpu_has(X86_FEATURE_CQM_OCCUP_LLC)) { + resctrl_enable_mon_event(QOS_L3_OCCUP_EVENT_ID); rdt_mon_features |=3D (1 << QOS_L3_OCCUP_EVENT_ID); - if (rdt_cpu_has(X86_FEATURE_CQM_MBM_TOTAL)) + } + if (rdt_cpu_has(X86_FEATURE_CQM_MBM_TOTAL)) { + resctrl_enable_mon_event(QOS_L3_MBM_TOTAL_EVENT_ID); rdt_mon_features |=3D (1 << QOS_L3_MBM_TOTAL_EVENT_ID); - if (rdt_cpu_has(X86_FEATURE_CQM_MBM_LOCAL)) + } + if (rdt_cpu_has(X86_FEATURE_CQM_MBM_LOCAL)) { + resctrl_enable_mon_event(QOS_L3_MBM_LOCAL_EVENT_ID); rdt_mon_features |=3D (1 << QOS_L3_MBM_LOCAL_EVENT_ID); + } =20 if (!rdt_mon_features) return false; diff --git a/fs/resctrl/internal.h b/fs/resctrl/internal.h index 0a1eedba2b03..4f315b7e9ec0 100644 --- a/fs/resctrl/internal.h +++ b/fs/resctrl/internal.h @@ -52,19 +52,26 @@ static inline struct rdt_fs_context *rdt_fc2context(str= uct fs_context *fc) } =20 /** - * struct mon_evt - Entry in the event list of a resource + * struct mon_evt - Properties of a monitor event * @evtid: event id + * @rid: resource id for this event * @name: name of the event * @configurable: true if the event is configurable - * @list: entry in &rdt_resource->evt_list + * @enabled: true if the event is enabled */ struct mon_evt { enum resctrl_event_id evtid; + enum resctrl_res_level rid; char *name; bool configurable; - struct list_head list; + bool enabled; }; =20 +extern struct mon_evt mon_event_all[QOS_NUM_EVENTS]; + +#define for_each_mon_event(mevt) for (mevt =3D &mon_event_all[QOS_FIRST_EV= ENT]; \ + mevt < &mon_event_all[QOS_NUM_EVENTS]; mevt++) + /** * struct mon_data - Monitoring details for each event file. * @list: Member of the global @mon_data_kn_priv_list list. diff --git a/fs/resctrl/monitor.c b/fs/resctrl/monitor.c index f5637855c3ac..2313e48de55f 100644 --- a/fs/resctrl/monitor.c +++ b/fs/resctrl/monitor.c @@ -844,38 +844,39 @@ static void dom_data_exit(struct rdt_resource *r) mutex_unlock(&rdtgroup_mutex); } =20 -static struct mon_evt llc_occupancy_event =3D { - .name =3D "llc_occupancy", - .evtid =3D QOS_L3_OCCUP_EVENT_ID, -}; - -static struct mon_evt mbm_total_event =3D { - .name =3D "mbm_total_bytes", - .evtid =3D QOS_L3_MBM_TOTAL_EVENT_ID, -}; - -static struct mon_evt mbm_local_event =3D { - .name =3D "mbm_local_bytes", - .evtid =3D QOS_L3_MBM_LOCAL_EVENT_ID, -}; - /* - * Initialize the event list for the resource. - * - * Note that MBM events are also part of RDT_RESOURCE_L3 resource - * because as per the SDM the total and local memory bandwidth - * are enumerated as part of L3 monitoring. + * All available events. Architecture code marks the ones that + * are supported by a system using resctrl_enable_mon_event() + * to set .enabled. */ -static void l3_mon_evt_init(struct rdt_resource *r) +struct mon_evt mon_event_all[QOS_NUM_EVENTS] =3D { + [QOS_L3_OCCUP_EVENT_ID] =3D { + .name =3D "llc_occupancy", + .evtid =3D QOS_L3_OCCUP_EVENT_ID, + .rid =3D RDT_RESOURCE_L3, + }, + [QOS_L3_MBM_TOTAL_EVENT_ID] =3D { + .name =3D "mbm_total_bytes", + .evtid =3D QOS_L3_MBM_TOTAL_EVENT_ID, + .rid =3D RDT_RESOURCE_L3, + }, + [QOS_L3_MBM_LOCAL_EVENT_ID] =3D { + .name =3D "mbm_local_bytes", + .evtid =3D QOS_L3_MBM_LOCAL_EVENT_ID, + .rid =3D RDT_RESOURCE_L3, + }, +}; + +void resctrl_enable_mon_event(enum resctrl_event_id eventid) { - INIT_LIST_HEAD(&r->evt_list); + if (WARN_ON_ONCE(eventid < QOS_FIRST_EVENT || eventid >=3D QOS_NUM_EVENTS= )) + return; + if (mon_event_all[eventid].enabled) { + pr_warn("Duplicate enable for event %d\n", eventid); + return; + } =20 - if (resctrl_arch_is_llc_occupancy_enabled()) - list_add_tail(&llc_occupancy_event.list, &r->evt_list); - if (resctrl_arch_is_mbm_total_enabled()) - list_add_tail(&mbm_total_event.list, &r->evt_list); - if (resctrl_arch_is_mbm_local_enabled()) - list_add_tail(&mbm_local_event.list, &r->evt_list); + mon_event_all[eventid].enabled =3D true; } =20 /** @@ -902,15 +903,13 @@ int resctrl_mon_resource_init(void) if (ret) return ret; =20 - l3_mon_evt_init(r); - if (resctrl_arch_is_evt_configurable(QOS_L3_MBM_TOTAL_EVENT_ID)) { - mbm_total_event.configurable =3D true; + mon_event_all[QOS_L3_MBM_TOTAL_EVENT_ID].configurable =3D true; resctrl_file_fflags_init("mbm_total_bytes_config", RFTYPE_MON_INFO | RFTYPE_RES_CACHE); } if (resctrl_arch_is_evt_configurable(QOS_L3_MBM_LOCAL_EVENT_ID)) { - mbm_local_event.configurable =3D true; + mon_event_all[QOS_L3_MBM_LOCAL_EVENT_ID].configurable =3D true; resctrl_file_fflags_init("mbm_local_bytes_config", RFTYPE_MON_INFO | RFTYPE_RES_CACHE); } diff --git a/fs/resctrl/rdtgroup.c b/fs/resctrl/rdtgroup.c index 77d08229d855..b95501d4b5de 100644 --- a/fs/resctrl/rdtgroup.c +++ b/fs/resctrl/rdtgroup.c @@ -1152,7 +1152,9 @@ static int rdt_mon_features_show(struct kernfs_open_f= ile *of, struct rdt_resource *r =3D rdt_kn_parent_priv(of->kn); struct mon_evt *mevt; =20 - list_for_each_entry(mevt, &r->evt_list, list) { + for_each_mon_event(mevt) { + if (mevt->rid !=3D r->rid || !mevt->enabled) + continue; seq_printf(seq, "%s\n", mevt->name); if (mevt->configurable) seq_printf(seq, "%s_config\n", mevt->name); @@ -3057,10 +3059,9 @@ static int mon_add_all_files(struct kernfs_node *kn,= struct rdt_mon_domain *d, struct mon_evt *mevt; int ret, domid; =20 - if (WARN_ON(list_empty(&r->evt_list))) - return -EPERM; - - list_for_each_entry(mevt, &r->evt_list, list) { + for_each_mon_event(mevt) { + if (mevt->rid !=3D r->rid || !mevt->enabled) + continue; domid =3D do_sum ? d->ci_id : d->hdr.id; priv =3D mon_get_kn_priv(r->rid, domid, mevt, do_sum); if (WARN_ON_ONCE(!priv)) diff --git a/include/linux/resctrl.h b/include/linux/resctrl.h index 6fb4894b8cfd..2944042bd84c 100644 --- a/include/linux/resctrl.h +++ b/include/linux/resctrl.h @@ -269,7 +269,6 @@ enum resctrl_schema_fmt { * @mon_domains: RCU list of all monitor domains for this resource * @name: Name to use in "schemata" file. * @schema_fmt: Which format string and parser is used for this schema. - * @evt_list: List of monitoring events * @mbm_cfg_mask: Bandwidth sources that can be tracked when bandwidth * monitoring events can be configured. * @cdp_capable: Is the CDP feature available on this resource @@ -287,7 +286,6 @@ struct rdt_resource { struct list_head mon_domains; char *name; enum resctrl_schema_fmt schema_fmt; - struct list_head evt_list; unsigned int mbm_cfg_mask; bool cdp_capable; }; @@ -372,6 +370,8 @@ u32 resctrl_arch_get_num_closid(struct rdt_resource *r); u32 resctrl_arch_system_num_rmid_idx(void); int resctrl_arch_update_domains(struct rdt_resource *r, u32 closid); =20 +void resctrl_enable_mon_event(enum resctrl_event_id eventid); + bool resctrl_arch_is_evt_configurable(enum resctrl_event_id evt); =20 /** diff --git a/include/linux/resctrl_types.h b/include/linux/resctrl_types.h index a25fb9c4070d..2dadbc54e4b3 100644 --- a/include/linux/resctrl_types.h +++ b/include/linux/resctrl_types.h @@ -34,11 +34,15 @@ /* Max event bits supported */ #define MAX_EVT_CONFIG_BITS GENMASK(6, 0) =20 -/* - * Event IDs, the values match those used to program IA32_QM_EVTSEL before - * reading IA32_QM_CTR on RDT systems. - */ +/* Event IDs */ enum resctrl_event_id { + /* Must match value of first event below */ + QOS_FIRST_EVENT =3D 0x01, + + /* + * These values match those used to program IA32_QM_EVTSEL before + * reading IA32_QM_CTR on RDT systems. + */ QOS_L3_OCCUP_EVENT_ID =3D 0x01, QOS_L3_MBM_TOTAL_EVENT_ID =3D 0x02, QOS_L3_MBM_LOCAL_EVENT_ID =3D 0x03, --=20 2.34.1 From nobody Mon Oct 6 01:21:10 2025 Received: from NAM10-DM6-obe.outbound.protection.outlook.com (mail-dm6nam10on2072.outbound.protection.outlook.com [40.107.93.72]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 26DFD246784; Fri, 25 Jul 2025 18:30:39 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.93.72 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1753468241; cv=fail; b=FwXW9sRxe4Ii4SA3ogIulrlRIYqS4IVC9X2dkzL8r4Mql2Vf8ESviUMGexJpc/U0KbM9wPCgKgiw/W/th7GtGYX1lMlYafoUqH+dvaeLaJReaJwDkEdoXPp3tTUzvAS66iLWXF49cDH5wURCROg7yDWDI4XmZ0RR91VAr3ZNIng= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1753468241; c=relaxed/simple; bh=B017s1kmCpH2nuMtV8oOJ2ytpHkPlb15V45wW9qXXXU=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=tkqYPXiOlK/f6jKp1Q0/CZPX8qVx3QmMdsv7eZoSTZ8TjVSTGVh4pYoCOAJRFdSBqGUHWAsOVLLNwpsiCCCAOG5AMP1/xFGPrKe+z8VjFM4N3NQbDELMpLZ+c2eKTTFtE+A306XjPn8BBE9Sbom1cEoUVc3QLUX0R+mdVZnCL1k= 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=i5/Zjd+T; arc=fail smtp.client-ip=40.107.93.72 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=amd.com Authentication-Results: smtp.subspace.kernel.org; spf=fail smtp.mailfrom=amd.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=amd.com header.i=@amd.com header.b="i5/Zjd+T" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=sjVBwteAWCqI3pJ2OADGLGkiYH0AED0IMYlLCmmgzHiSmQk60JgjFvg0ASOHC3IR+dp/qxRcdVcduzzTmYIL9xxFuRUiapQlB47d05hbhgRCSreDvpSI0LD4jNzOZSxAkMZZbMpEoSXFLLNsySd9qtCCUSsWIoP9eNbnDZ/jnYWTZK0UkF6DrHN2FDs9QvQn4GCkjOz1sx4Bzr8QrLS4sHV+NT2Ds3R9DCY7I5U+wXh5KEkKNi7TGGidxlBhIdOonJ7psYEP0aUaTwABLySUVUiTqUNhsLscseBqCuI27kwMXTvMovFQPzxa1TTPG8PXAbCjq5pZB2UviioU0le0aQ== 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=8F293fVe2luY6MdLWMC1gszE7dc6yb3clPIn6Yded1I=; b=VW+IpWp/hUlHbazUwOnfzfeONlXSax1mNkcgISeMNMWOcbRoLUUNl9M2l9aMBb7Fm8FUq/HO1oy4RZVf6d16hjcLZBsagcodwdiBwF4N32oXyPEvCjUkd2P3Kjko6gYm+7wHabVu6D7pfSnSLDTZu6dsSGcl+i/hAswKC4PG054Iv51UC26gt0AT7/W+SCZ8jvKuD+ScfycYlTpqmI54qQmZzpj63U+bIiHNJpHUWNQPLZGzs4Di46c5GyVVe5vnKe7vNty88GfVwRDFVn14u1bH8O16PvoaCwH5ExZkUj1AL8tQrYLwWl/f4c7unR1L76n5fDAQASoReoYLaFHgOA== 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=8F293fVe2luY6MdLWMC1gszE7dc6yb3clPIn6Yded1I=; b=i5/Zjd+T3VaP5uE/wCQ1l9yQXOXEPUKDqXJTnJjkDgF21SBFP8jaZ2ewabKQ8EPxFiGDMaErD3QIxE1qfu2jYuB5M/vPEQM9kDrvI8RTsD6wdCRKaoWykmqExwcEYm3QhRBhovnb4z2Wp0sMEukSk2dkxZ9/0DrF54PPRFZuH9Y= Received: from PH7P220CA0113.NAMP220.PROD.OUTLOOK.COM (2603:10b6:510:32d::31) by SA3PR12MB7904.namprd12.prod.outlook.com (2603:10b6:806:320::17) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8964.22; Fri, 25 Jul 2025 18:30:37 +0000 Received: from SA2PEPF000015C6.namprd03.prod.outlook.com (2603:10b6:510:32d:cafe::34) by PH7P220CA0113.outlook.office365.com (2603:10b6:510:32d::31) with Microsoft SMTP Server (version=TLS1_3, cipher=TLS_AES_256_GCM_SHA384) id 15.20.8943.31 via Frontend Transport; Fri, 25 Jul 2025 18:30: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 SA2PEPF000015C6.mail.protection.outlook.com (10.167.241.196) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.8964.20 via Frontend Transport; Fri, 25 Jul 2025 18:30: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; Fri, 25 Jul 2025 13:30:34 -0500 From: Babu Moger To: , , , , , , , CC: , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , Subject: [PATCH v16 02/34] x86,fs/resctrl: Replace architecture event enabled checks Date: Fri, 25 Jul 2025 13:29:21 -0500 Message-ID: <63d54a44ab32a95d9a21b7bae9396f077653111e.1753467772.git.babu.moger@amd.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: References: Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-ClientProxiedBy: SATLEXMB03.amd.com (10.181.40.144) To SATLEXMB04.amd.com (10.181.40.145) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: SA2PEPF000015C6:EE_|SA3PR12MB7904:EE_ X-MS-Office365-Filtering-Correlation-Id: 28b8a234-9f65-45b8-6b67-08ddcba959ea 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?tnxXyYlfxqeYhhMan63AlGOTneeCT0zPgyLPhk8XjCZY7pHpNet/C+FgKwzO?= =?us-ascii?Q?W9O5anL46/7affBP49sKseio/62G2SVjyJ81v4hfa7qfBMylaC+4lho5nSYh?= =?us-ascii?Q?Ji23/zFBE86sYOBQuAHJ7ll89LVS4x8785CI6vyjyOYeLgocOvLTwNSfWbyV?= =?us-ascii?Q?Iv9nYDUEOr57iIkMmx/klq878D/tWS5CMh2KqGCHjW3dKZuMWKcy/K+zXYqu?= =?us-ascii?Q?snY/Qem4NiNfB2nLJ4t0sfgC/K0th0CbfDSe9uDGMQUJgYNMYMi3Fvc5Z01T?= =?us-ascii?Q?32aEI4g5yCHhSKUZKFmgnr9rujOuZkznUP7FlxGZYTVwAN2UA5rixWMw3tIx?= =?us-ascii?Q?ycQG3I0X/MsPcY4IraqXasKEXj/nE3/2bRhQNol2b9sPKcSwwRcIQW/a/odn?= =?us-ascii?Q?WZkpW43oet0ykYRxNBY7Cle89qywRE0o+xGDmmihH88fow1ZrGmv8KbiKwBx?= =?us-ascii?Q?oIUACI7KqclrbPs/cdmysXRj6qDZaJBdcc5pSQ1WnIsK0VDuLRfPu50OfHgd?= =?us-ascii?Q?emzzkZy7tIpqVoYl4Zd/a7Er+cv1M4eJ3+5m3vyXWz9QO2hASRZWRMtvGVxo?= =?us-ascii?Q?qdKLfSTMl1LI19A9CMe8TSilv2+rmFp2XH39PzSoV2jPezzGzxNOi60+4SWj?= =?us-ascii?Q?ePmw9/J01ZCD5/B7pbI6QWMi9HJABcqKCVhDjR4++EoYyfH4nExCFbprRGR+?= =?us-ascii?Q?bW9EggSgKbdUJgyWofteuoLDLNxnmq+c7iJhvthlQrvrSwAlQm+X+VTX2/2Z?= =?us-ascii?Q?iBGauuYYEgUGT+f1b5pgYeIihb4qa7LOs+1v+Q8RNkFT3jP4KRoLb+pzoPoz?= =?us-ascii?Q?BLPSwbg3rwtmNx6iSkHXwxQ+uRw9uCl8XfA1aUbDeLDlfxyJzxbkDfaUtpuA?= =?us-ascii?Q?NI7TG1NZAGAR8s9BHtC/6zUzuDEtR+8l0L3WPPavYiRt4V2GNCz2kdzll8xN?= =?us-ascii?Q?WNIkXm/tPwxVtaiIHk06S2EdN9CbDdg5idldoIabjy0UUT5vEcxndjAd1YHx?= =?us-ascii?Q?3EOh9cAycnb7jZQ3sPQ/MWVW0ABqHuyUJYyXRzfoTOVAsiWekw7Tx4B0pcMh?= =?us-ascii?Q?KM1cdaKVKPAwdOnJdWjZGA+53WVFgNgtA+WB+OijE/Cwu6ckzblYvePuI/a7?= =?us-ascii?Q?Fm/WUi/0zS7Dt/yjefbC4QPfzsxWSk1NfInUmT76WGzIn7jKA/HS9VFo/CLU?= =?us-ascii?Q?c4nW01bp5ug5yPydrx7MXRyINUxTIZt5rwmDQCvOeIBah8rLLx9YwSCQj1Wr?= =?us-ascii?Q?howgE4ccdLoFnXbpJiZsJuAuK4K4rpAsuCRpVYz1lzvJ5qgFns3eyz496C8+?= =?us-ascii?Q?rYsSr2S6ZImK1ZHvKAJo9JelPKDPPP9rhFZbzSfmLW1+ldEvi56Pyu55eHzU?= =?us-ascii?Q?n/fWRs5Omp09Vfu62yXVIn3bK+2eD/49Mmx2r7s+j2dNIlp1JU+3qRZ4Rt3g?= =?us-ascii?Q?sOyP1Db4VEHlBu1lMBYE2E938uAyLUqn8nYQRP0cVrya2bKJZ5gtDbYDg+hJ?= =?us-ascii?Q?6oHw9oA0oMenJtg/dEqMRkQJXivcYQD2BzEgHIeeP5Drdmp7DSi2yDCDRg?= =?us-ascii?Q?=3D=3D?= X-Forefront-Antispam-Report: CIP:165.204.84.17;CTRY:US;LANG:en;SCL:1;SRV:;IPV:CAL;SFV:NSPM;H:SATLEXMB04.amd.com;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(13230040)(1800799024)(36860700013)(7416014)(376014)(82310400026);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 25 Jul 2025 18:30:37.4266 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 28b8a234-9f65-45b8-6b67-08ddcba959ea 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: SA2PEPF000015C6.namprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: SA3PR12MB7904 Content-Type: text/plain; charset="utf-8" From: Tony Luck The resctrl file system now has complete knowledge of the status of every event. So there is no need for per-event function calls to check. Replace each of the resctrl_arch_is_{event}enabled() calls with resctrl_is_mon_event_enabled(QOS_{EVENT}). No functional change. Signed-off-by: Tony Luck Reviewed-by: Fenghua Yu Reviewed-by: Reinette Chatre --- Picked up first four patches from: https://lore.kernel.org/lkml/20250711235341.113933-1-tony.luck@intel.com/ These patches have already been reviewed. --- arch/x86/include/asm/resctrl.h | 15 --------------- arch/x86/kernel/cpu/resctrl/core.c | 4 ++-- arch/x86/kernel/cpu/resctrl/monitor.c | 4 ++-- fs/resctrl/ctrlmondata.c | 4 ++-- fs/resctrl/monitor.c | 16 +++++++++++----- fs/resctrl/rdtgroup.c | 18 +++++++++--------- include/linux/resctrl.h | 2 ++ 7 files changed, 28 insertions(+), 35 deletions(-) diff --git a/arch/x86/include/asm/resctrl.h b/arch/x86/include/asm/resctrl.h index feb93b50e990..b1dd5d6b87db 100644 --- a/arch/x86/include/asm/resctrl.h +++ b/arch/x86/include/asm/resctrl.h @@ -84,21 +84,6 @@ static inline void resctrl_arch_disable_mon(void) static_branch_dec_cpuslocked(&rdt_enable_key); } =20 -static inline bool resctrl_arch_is_llc_occupancy_enabled(void) -{ - return (rdt_mon_features & (1 << QOS_L3_OCCUP_EVENT_ID)); -} - -static inline bool resctrl_arch_is_mbm_total_enabled(void) -{ - return (rdt_mon_features & (1 << QOS_L3_MBM_TOTAL_EVENT_ID)); -} - -static inline bool resctrl_arch_is_mbm_local_enabled(void) -{ - return (rdt_mon_features & (1 << QOS_L3_MBM_LOCAL_EVENT_ID)); -} - /* * __resctrl_sched_in() - Writes the task's CLOSid/RMID to IA32_PQR_MSR * diff --git a/arch/x86/kernel/cpu/resctrl/core.c b/arch/x86/kernel/cpu/resct= rl/core.c index 7fcae25874fe..1a319ce9328c 100644 --- a/arch/x86/kernel/cpu/resctrl/core.c +++ b/arch/x86/kernel/cpu/resctrl/core.c @@ -402,13 +402,13 @@ static int arch_domain_mbm_alloc(u32 num_rmid, struct= rdt_hw_mon_domain *hw_dom) { size_t tsize; =20 - if (resctrl_arch_is_mbm_total_enabled()) { + if (resctrl_is_mon_event_enabled(QOS_L3_MBM_TOTAL_EVENT_ID)) { tsize =3D sizeof(*hw_dom->arch_mbm_total); hw_dom->arch_mbm_total =3D kcalloc(num_rmid, tsize, GFP_KERNEL); if (!hw_dom->arch_mbm_total) return -ENOMEM; } - if (resctrl_arch_is_mbm_local_enabled()) { + if (resctrl_is_mon_event_enabled(QOS_L3_MBM_LOCAL_EVENT_ID)) { tsize =3D sizeof(*hw_dom->arch_mbm_local); hw_dom->arch_mbm_local =3D kcalloc(num_rmid, tsize, GFP_KERNEL); if (!hw_dom->arch_mbm_local) { diff --git a/arch/x86/kernel/cpu/resctrl/monitor.c b/arch/x86/kernel/cpu/re= sctrl/monitor.c index c261558276cd..61d38517e2bf 100644 --- a/arch/x86/kernel/cpu/resctrl/monitor.c +++ b/arch/x86/kernel/cpu/resctrl/monitor.c @@ -207,11 +207,11 @@ void resctrl_arch_reset_rmid_all(struct rdt_resource = *r, struct rdt_mon_domain * { struct rdt_hw_mon_domain *hw_dom =3D resctrl_to_arch_mon_dom(d); =20 - if (resctrl_arch_is_mbm_total_enabled()) + if (resctrl_is_mon_event_enabled(QOS_L3_MBM_TOTAL_EVENT_ID)) memset(hw_dom->arch_mbm_total, 0, sizeof(*hw_dom->arch_mbm_total) * r->num_rmid); =20 - if (resctrl_arch_is_mbm_local_enabled()) + if (resctrl_is_mon_event_enabled(QOS_L3_MBM_LOCAL_EVENT_ID)) memset(hw_dom->arch_mbm_local, 0, sizeof(*hw_dom->arch_mbm_local) * r->num_rmid); } diff --git a/fs/resctrl/ctrlmondata.c b/fs/resctrl/ctrlmondata.c index d98e0d2de09f..ad7ffc6acf13 100644 --- a/fs/resctrl/ctrlmondata.c +++ b/fs/resctrl/ctrlmondata.c @@ -473,12 +473,12 @@ ssize_t rdtgroup_mba_mbps_event_write(struct kernfs_o= pen_file *of, rdt_last_cmd_clear(); =20 if (!strcmp(buf, "mbm_local_bytes")) { - if (resctrl_arch_is_mbm_local_enabled()) + if (resctrl_is_mon_event_enabled(QOS_L3_MBM_LOCAL_EVENT_ID)) rdtgrp->mba_mbps_event =3D QOS_L3_MBM_LOCAL_EVENT_ID; else ret =3D -EINVAL; } else if (!strcmp(buf, "mbm_total_bytes")) { - if (resctrl_arch_is_mbm_total_enabled()) + if (resctrl_is_mon_event_enabled(QOS_L3_MBM_TOTAL_EVENT_ID)) rdtgrp->mba_mbps_event =3D QOS_L3_MBM_TOTAL_EVENT_ID; else ret =3D -EINVAL; diff --git a/fs/resctrl/monitor.c b/fs/resctrl/monitor.c index 2313e48de55f..9e988b2c1a22 100644 --- a/fs/resctrl/monitor.c +++ b/fs/resctrl/monitor.c @@ -336,7 +336,7 @@ void free_rmid(u32 closid, u32 rmid) =20 entry =3D __rmid_entry(idx); =20 - if (resctrl_arch_is_llc_occupancy_enabled()) + if (resctrl_is_mon_event_enabled(QOS_L3_OCCUP_EVENT_ID)) add_rmid_to_limbo(entry); else list_add_tail(&entry->list, &rmid_free_lru); @@ -637,10 +637,10 @@ static void mbm_update(struct rdt_resource *r, struct= rdt_mon_domain *d, * This is protected from concurrent reads from user as both * the user and overflow handler hold the global mutex. */ - if (resctrl_arch_is_mbm_total_enabled()) + if (resctrl_is_mon_event_enabled(QOS_L3_MBM_TOTAL_EVENT_ID)) mbm_update_one_event(r, d, closid, rmid, QOS_L3_MBM_TOTAL_EVENT_ID); =20 - if (resctrl_arch_is_mbm_local_enabled()) + if (resctrl_is_mon_event_enabled(QOS_L3_MBM_LOCAL_EVENT_ID)) mbm_update_one_event(r, d, closid, rmid, QOS_L3_MBM_LOCAL_EVENT_ID); } =20 @@ -879,6 +879,12 @@ void resctrl_enable_mon_event(enum resctrl_event_id ev= entid) mon_event_all[eventid].enabled =3D true; } =20 +bool resctrl_is_mon_event_enabled(enum resctrl_event_id eventid) +{ + return eventid >=3D QOS_FIRST_EVENT && eventid < QOS_NUM_EVENTS && + mon_event_all[eventid].enabled; +} + /** * resctrl_mon_resource_init() - Initialise global monitoring structures. * @@ -914,9 +920,9 @@ int resctrl_mon_resource_init(void) RFTYPE_MON_INFO | RFTYPE_RES_CACHE); } =20 - if (resctrl_arch_is_mbm_local_enabled()) + if (resctrl_is_mon_event_enabled(QOS_L3_MBM_LOCAL_EVENT_ID)) mba_mbps_default_event =3D QOS_L3_MBM_LOCAL_EVENT_ID; - else if (resctrl_arch_is_mbm_total_enabled()) + else if (resctrl_is_mon_event_enabled(QOS_L3_MBM_TOTAL_EVENT_ID)) mba_mbps_default_event =3D QOS_L3_MBM_TOTAL_EVENT_ID; =20 return 0; diff --git a/fs/resctrl/rdtgroup.c b/fs/resctrl/rdtgroup.c index b95501d4b5de..a7eeb33501da 100644 --- a/fs/resctrl/rdtgroup.c +++ b/fs/resctrl/rdtgroup.c @@ -123,8 +123,8 @@ void rdt_staged_configs_clear(void) =20 static bool resctrl_is_mbm_enabled(void) { - return (resctrl_arch_is_mbm_total_enabled() || - resctrl_arch_is_mbm_local_enabled()); + return (resctrl_is_mon_event_enabled(QOS_L3_MBM_TOTAL_EVENT_ID) || + resctrl_is_mon_event_enabled(QOS_L3_MBM_LOCAL_EVENT_ID)); } =20 static bool resctrl_is_mbm_event(int e) @@ -196,7 +196,7 @@ static int closid_alloc(void) lockdep_assert_held(&rdtgroup_mutex); =20 if (IS_ENABLED(CONFIG_RESCTRL_RMID_DEPENDS_ON_CLOSID) && - resctrl_arch_is_llc_occupancy_enabled()) { + resctrl_is_mon_event_enabled(QOS_L3_OCCUP_EVENT_ID)) { cleanest_closid =3D resctrl_find_cleanest_closid(); if (cleanest_closid < 0) return cleanest_closid; @@ -4051,7 +4051,7 @@ void resctrl_offline_mon_domain(struct rdt_resource *= r, struct rdt_mon_domain *d =20 if (resctrl_is_mbm_enabled()) cancel_delayed_work(&d->mbm_over); - if (resctrl_arch_is_llc_occupancy_enabled() && has_busy_rmid(d)) { + if (resctrl_is_mon_event_enabled(QOS_L3_OCCUP_EVENT_ID) && has_busy_rmid(= d)) { /* * When a package is going down, forcefully * decrement rmid->ebusy. There is no way to know @@ -4087,12 +4087,12 @@ static int domain_setup_mon_state(struct rdt_resour= ce *r, struct rdt_mon_domain u32 idx_limit =3D resctrl_arch_system_num_rmid_idx(); size_t tsize; =20 - if (resctrl_arch_is_llc_occupancy_enabled()) { + if (resctrl_is_mon_event_enabled(QOS_L3_OCCUP_EVENT_ID)) { d->rmid_busy_llc =3D bitmap_zalloc(idx_limit, GFP_KERNEL); if (!d->rmid_busy_llc) return -ENOMEM; } - if (resctrl_arch_is_mbm_total_enabled()) { + if (resctrl_is_mon_event_enabled(QOS_L3_MBM_TOTAL_EVENT_ID)) { tsize =3D sizeof(*d->mbm_total); d->mbm_total =3D kcalloc(idx_limit, tsize, GFP_KERNEL); if (!d->mbm_total) { @@ -4100,7 +4100,7 @@ static int domain_setup_mon_state(struct rdt_resource= *r, struct rdt_mon_domain return -ENOMEM; } } - if (resctrl_arch_is_mbm_local_enabled()) { + if (resctrl_is_mon_event_enabled(QOS_L3_MBM_LOCAL_EVENT_ID)) { tsize =3D sizeof(*d->mbm_local); d->mbm_local =3D kcalloc(idx_limit, tsize, GFP_KERNEL); if (!d->mbm_local) { @@ -4145,7 +4145,7 @@ int resctrl_online_mon_domain(struct rdt_resource *r,= struct rdt_mon_domain *d) RESCTRL_PICK_ANY_CPU); } =20 - if (resctrl_arch_is_llc_occupancy_enabled()) + if (resctrl_is_mon_event_enabled(QOS_L3_OCCUP_EVENT_ID)) INIT_DELAYED_WORK(&d->cqm_limbo, cqm_handle_limbo); =20 /* @@ -4220,7 +4220,7 @@ void resctrl_offline_cpu(unsigned int cpu) cancel_delayed_work(&d->mbm_over); mbm_setup_overflow_handler(d, 0, cpu); } - if (resctrl_arch_is_llc_occupancy_enabled() && + if (resctrl_is_mon_event_enabled(QOS_L3_OCCUP_EVENT_ID) && cpu =3D=3D d->cqm_work_cpu && has_busy_rmid(d)) { cancel_delayed_work(&d->cqm_limbo); cqm_setup_limbo_handler(d, 0, cpu); diff --git a/include/linux/resctrl.h b/include/linux/resctrl.h index 2944042bd84c..40aba6b5d4f0 100644 --- a/include/linux/resctrl.h +++ b/include/linux/resctrl.h @@ -372,6 +372,8 @@ int resctrl_arch_update_domains(struct rdt_resource *r,= u32 closid); =20 void resctrl_enable_mon_event(enum resctrl_event_id eventid); =20 +bool resctrl_is_mon_event_enabled(enum resctrl_event_id eventid); + bool resctrl_arch_is_evt_configurable(enum resctrl_event_id evt); =20 /** --=20 2.34.1 From nobody Mon Oct 6 01:21:10 2025 Received: from NAM11-BN8-obe.outbound.protection.outlook.com (mail-bn8nam11on2072.outbound.protection.outlook.com [40.107.236.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 C758F2475C3; Fri, 25 Jul 2025 18:30:49 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.236.72 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1753468252; cv=fail; b=RIPyRzgxGd4zgSHo1ksLwNc6Xb2EEheX22o13BWb4tHNHYUgXkwJlBQepiJC7h7SKYEXqmmhSJHrMGaL5vfGgUSPRAfxqQZ2ItiQy3EmRwJ4aTzdtucl2Yy1JV0TKt2eKPldpkqJ50IgWoU6tqJiLQd5vsUDbCTTM7eOQFyhfZ0= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1753468252; c=relaxed/simple; bh=1Dlt2pjwv5WsT3iy447fj6RIgAQoJZRdm0aBdUQT6+A=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=t/A1f19hIq9Co34HK30j+y5UpnB/1kkg9S8bT08g+afX7vRTRoSLQ51Ypi/SIwtkOGE01X79Hz8GF9Nv9JzL/oXmfxWAU4sLOGUdUdoRhirQkdYhMcy2WxqRWs9XlDZcDfr/z2G6gukbB08Y56gNDecdczYZZwFX5wcyDMbBDQs= 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=I6c2LJc2; arc=fail smtp.client-ip=40.107.236.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="I6c2LJc2" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=jsiSJWC7A+NQLakhwGB85pBFWwLuetURdld8mHbecmHfX19ho0+ohK560z3mfDZW0wB4sss3pQFpKUM2QBaqO+hbIKvgEVEDUZC8Ac0Uu3hSnV2C2A7agDsjqXk+dv2Ct6ZR7WhI+D1BPQpGn9PYFfYoUd0Z5b4dJOep0hR3UbqzRagU59b72NVuCgVhANTWTFQ8NRyQSDGw9M5H9WePfc26pJYmNvRrbOo7EMuVEUxIA2s6QtCDJS+G3LygyOoS8dU81jhJ8RN8GcsMO7Ej1H+l63Wof9tp/wVU/yf4pobQWTQihkaFlrvqMCe/yIxLqgwc315DnQvZFuTMeSmnMA== 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=PeEL8F0c08m7nJP0X4MJwXUuWM9D8i1rH1SX1Hc7ceE=; b=FzPq8mKddLItWAKx4pWo+O6xg+5XxYt8VnQ+vLuOAaHGrIVwso7R3cHmeUBZxST8bxPbytfN8+dRWBnCpppXSowMTZ/r41pdhKUTitATodI3Ra7JfHZqSnN5QmZPadEDRJkAslw5purb+wOCnduLTc5busqc+f1tV2mdzZwrH2J6frWZ9FXeFa0TAOw6pxeeVN2fpn+ZotvT3ceVtMGEYaphqFVyuuFXGC+DKfr540Wd7fsQa7YbvDaSXbvE/6etgrKh6ydu3D2M2DpSkXDywECvSXkBED3VnU7s1S+0n1BgD1j2oG9lQkV48W6VZX0L4fvrddzMq79INvmpA8VTZQ== 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=PeEL8F0c08m7nJP0X4MJwXUuWM9D8i1rH1SX1Hc7ceE=; b=I6c2LJc2XZ4d2zExaew9NcTGWfUQmDoHCQ1/6LA7nipWLPKxrIjVJcWQhK7FsrgYyWQhgr7486kL566xy8UiEfB4b19vxsCUnh6RW//TyPf8LIl0YjwWNihfiIT72mS8raTxvZ0Wjvlj2FKOC/pMe09BF3s88LN+VYNSzwGgvpQ= Received: from SA0PR11CA0036.namprd11.prod.outlook.com (2603:10b6:806:d0::11) by DM6PR12MB4172.namprd12.prod.outlook.com (2603:10b6:5:212::9) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8943.30; Fri, 25 Jul 2025 18:30:46 +0000 Received: from SA2PEPF000015CD.namprd03.prod.outlook.com (2603:10b6:806:d0:cafe::5d) by SA0PR11CA0036.outlook.office365.com (2603:10b6:806:d0::11) with Microsoft SMTP Server (version=TLS1_3, cipher=TLS_AES_256_GCM_SHA384) id 15.20.8964.21 via Frontend Transport; Fri, 25 Jul 2025 18:30:46 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 165.204.84.17) smtp.mailfrom=amd.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=amd.com; Received-SPF: Pass (protection.outlook.com: domain of amd.com designates 165.204.84.17 as permitted sender) receiver=protection.outlook.com; client-ip=165.204.84.17; helo=SATLEXMB04.amd.com; pr=C Received: from SATLEXMB04.amd.com (165.204.84.17) by SA2PEPF000015CD.mail.protection.outlook.com (10.167.241.203) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.8964.20 via Frontend Transport; Fri, 25 Jul 2025 18:30:46 +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; Fri, 25 Jul 2025 13:30:43 -0500 From: Babu Moger To: , , , , , , , CC: , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , Subject: [PATCH v16 03/34] x86/resctrl: Remove 'rdt_mon_features' global variable Date: Fri, 25 Jul 2025 13:29:22 -0500 Message-ID: X-Mailer: git-send-email 2.34.1 In-Reply-To: References: Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-ClientProxiedBy: SATLEXMB03.amd.com (10.181.40.144) To SATLEXMB04.amd.com (10.181.40.145) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: SA2PEPF000015CD:EE_|DM6PR12MB4172:EE_ X-MS-Office365-Filtering-Correlation-Id: 47fb31f9-5db7-4c15-c55d-08ddcba95f20 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|376014|36860700013|7416014|1800799024|82310400026; X-Microsoft-Antispam-Message-Info: =?us-ascii?Q?i5HQTn1ghcsz0msR8lRHEPrDNw9pYdFm35oSmUEYDrvcDTC7zbjVowGqzVdC?= =?us-ascii?Q?2ehZPvU0z33qbD1r241fUWi8/mXQeM1FZblJfhuSNib6ftPqRfnM4B5t/D+l?= =?us-ascii?Q?CM2xbytF9RcTpUOKPCiZ7ljGGFvtXqhUxM9NUMS5hB5QeBdA99mC3m2owXZA?= =?us-ascii?Q?mqTvRUrQOyalbvt6Cu2PAkyj/IvJRWBP3Jsjo2nxX+F2Duubc/ZTOpFkABzR?= =?us-ascii?Q?oNABmrrxopWt7NQlVxa0+frw12gKTRQkDDmcCMaqYhrDr1Vt0aKKu0uj08QN?= =?us-ascii?Q?w6P7sKi1XvSw0eujggjXoQar0n8rqCcWVa2NJimvUPT75K49CZJLbTF8pNRm?= =?us-ascii?Q?Kahkyvpeuf+HoIq/isyyhyYm1hHMdwnsQN8Ik760ZlHZeOU7pjSV5JEtGxcc?= =?us-ascii?Q?I5ka+iH3MfDd5qKwRaD8bSxa0HjvpoqcbMY1dFYmqkZzMgI9Ptz7ZnKvZnKy?= =?us-ascii?Q?yfhYIe9RjiWedF/J5jRdwsLbbLMXiBsekAzWGea26CvyEiYDMew+JWZhJPDE?= =?us-ascii?Q?jaccm1XjlDLWpFpzzjnGuPcfzRE1fHLHjyiP4KqVLG4bw8MAOnwBpuf/jKFL?= =?us-ascii?Q?wnQpFkP6VGjn80yVUU4rCKDBMkYy/x/+xJ5e97/+C0+V+CW9moeEhBIbHT0y?= =?us-ascii?Q?im5W7AvWdSqJznYZ0652neERcsgRiYOpSt3nV08OTEvFTshesutInTtvH22Q?= =?us-ascii?Q?Vp5uiCNh25avfSp85bII9hpKEsoASVfWt9ges/3AV/F6Pha01dNDCrYyvNIV?= =?us-ascii?Q?whmKt3FguuML/YwtxCgNGXAtzFgzH9jtXRiKlpop/84ka+sLGodiDEeRJxK1?= =?us-ascii?Q?4REyUugc+yKyi7GFK2CCcxrE6dWdegs0UzHtWqMqemtk4Mqn01iJ20CRzq/5?= =?us-ascii?Q?8cuNACU0o68ElsKB2qYf6/FtiiUToiGG4nkOKsXTi3hlvhSOAeSGg972O92F?= =?us-ascii?Q?+5HAuYZrJEaWucQjpLE37c5cg22fWpU+wtdfeP5cUpp94tCMbnnKONDuv5l5?= =?us-ascii?Q?ATdEJt/637eK0O40AUft/mmDxedXKQrQ3jnn4+f5ZfAdiIGdS1g1m1PfukQJ?= =?us-ascii?Q?l9xX/sg9QYfy+aX8K6Rk5P+H4CnU1nJfMLh/VHk9IuAg0OoeBh40ZYK3jMnq?= =?us-ascii?Q?Cry/V7j3s7Vf00B8Jgtj/C41p56Ldv3AANYKq8fwVc+jjoyiK4rea63KGMlD?= =?us-ascii?Q?O2XbnFittGGCFF9sBMZ5PIi6D8VUboo6RJHw3yRFpObuIfb8El7oL8n1mEIa?= =?us-ascii?Q?mhMRR6xHUTKwvCoxaljoBLb/fO2kaBhGKCfyRRnqMJwcwvnAstews8YQGyJj?= =?us-ascii?Q?VZ3pjAtBo3Ay/O2WdxBJcsNbIs2U8ZjZ7VsGwGGB3PX9xAw6eDBUdxu9b3mX?= =?us-ascii?Q?RCItXwbJv56jDY6/LNEIJ/zZq++Vav7LAc7GsNCenGfVIHJS2hHye/jmgfgG?= =?us-ascii?Q?wJLaKTMitdIMZrmw5HqUs2r/d/rFSqk1ZjULlffbc1suEbH3mWaVHnGW8Twh?= =?us-ascii?Q?IY5p5sXjMUPjxN0U1SJHuWZ4ibtMSJPH0m1dB4wBHfv+tAMu5DrmxgaSnw?= =?us-ascii?Q?=3D=3D?= X-Forefront-Antispam-Report: CIP:165.204.84.17;CTRY:US;LANG:en;SCL:1;SRV:;IPV:CAL;SFV:NSPM;H:SATLEXMB04.amd.com;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(13230040)(376014)(36860700013)(7416014)(1800799024)(82310400026);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 25 Jul 2025 18:30:46.1717 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 47fb31f9-5db7-4c15-c55d-08ddcba95f20 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: SA2PEPF000015CD.namprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM6PR12MB4172 Content-Type: text/plain; charset="utf-8" From: Tony Luck rdt_mon_features is used as a bitmask of enabled monitor events. A monitor event's status is now maintained in mon_evt::enabled with all monitor events' mon_evt structures found in the filesystem's mon_event_all[] array. Remove the remaining uses of rdt_mon_features. Signed-off-by: Tony Luck Reviewed-by: Reinette Chatre --- Picked up first four patches from: https://lore.kernel.org/lkml/20250711235341.113933-1-tony.luck@intel.com/ These patches have already been reviewed. --- arch/x86/include/asm/resctrl.h | 1 - arch/x86/kernel/cpu/resctrl/core.c | 9 +++++---- arch/x86/kernel/cpu/resctrl/monitor.c | 5 ----- 3 files changed, 5 insertions(+), 10 deletions(-) diff --git a/arch/x86/include/asm/resctrl.h b/arch/x86/include/asm/resctrl.h index b1dd5d6b87db..575f8408a9e7 100644 --- a/arch/x86/include/asm/resctrl.h +++ b/arch/x86/include/asm/resctrl.h @@ -44,7 +44,6 @@ DECLARE_PER_CPU(struct resctrl_pqr_state, pqr_state); =20 extern bool rdt_alloc_capable; extern bool rdt_mon_capable; -extern unsigned int rdt_mon_features; =20 DECLARE_STATIC_KEY_FALSE(rdt_enable_key); DECLARE_STATIC_KEY_FALSE(rdt_alloc_enable_key); diff --git a/arch/x86/kernel/cpu/resctrl/core.c b/arch/x86/kernel/cpu/resct= rl/core.c index 1a319ce9328c..5d14f9a14eda 100644 --- a/arch/x86/kernel/cpu/resctrl/core.c +++ b/arch/x86/kernel/cpu/resctrl/core.c @@ -863,21 +863,22 @@ static __init bool get_rdt_alloc_resources(void) static __init bool get_rdt_mon_resources(void) { struct rdt_resource *r =3D &rdt_resources_all[RDT_RESOURCE_L3].r_resctrl; + bool ret =3D false; =20 if (rdt_cpu_has(X86_FEATURE_CQM_OCCUP_LLC)) { resctrl_enable_mon_event(QOS_L3_OCCUP_EVENT_ID); - rdt_mon_features |=3D (1 << QOS_L3_OCCUP_EVENT_ID); + ret =3D true; } if (rdt_cpu_has(X86_FEATURE_CQM_MBM_TOTAL)) { resctrl_enable_mon_event(QOS_L3_MBM_TOTAL_EVENT_ID); - rdt_mon_features |=3D (1 << QOS_L3_MBM_TOTAL_EVENT_ID); + ret =3D true; } if (rdt_cpu_has(X86_FEATURE_CQM_MBM_LOCAL)) { resctrl_enable_mon_event(QOS_L3_MBM_LOCAL_EVENT_ID); - rdt_mon_features |=3D (1 << QOS_L3_MBM_LOCAL_EVENT_ID); + ret =3D true; } =20 - if (!rdt_mon_features) + if (!ret) return false; =20 return !rdt_get_mon_l3_config(r); diff --git a/arch/x86/kernel/cpu/resctrl/monitor.c b/arch/x86/kernel/cpu/re= sctrl/monitor.c index 61d38517e2bf..07f8ab097cbe 100644 --- a/arch/x86/kernel/cpu/resctrl/monitor.c +++ b/arch/x86/kernel/cpu/resctrl/monitor.c @@ -31,11 +31,6 @@ */ bool rdt_mon_capable; =20 -/* - * Global to indicate which monitoring events are enabled. - */ -unsigned int rdt_mon_features; - #define CF(cf) ((unsigned long)(1048576 * (cf) + 0.5)) =20 static int snc_nodes_per_l3_cache =3D 1; --=20 2.34.1 From nobody Mon Oct 6 01:21:10 2025 Received: from NAM12-DM6-obe.outbound.protection.outlook.com (mail-dm6nam12on2040.outbound.protection.outlook.com [40.107.243.40]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 209BC3D994; Fri, 25 Jul 2025 18:31:02 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.243.40 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1753468265; cv=fail; b=rjlWyb6ZPPrC5APy/n55fMTvtdCtXOGVc4dXifUjTrM+pZ6dEVad2Mn+pY+8OT0gNv0ssQZqY+XjFA5DDnV9JLtWi4PlTPKZMvFjMxJgF2ddtDGuUnLzpS+PLcEvP2Upi5ZNN+6OD+QKNvOxSsrw/tKeICv0RoqDaNkIa8ayGfY= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1753468265; c=relaxed/simple; bh=5ig51/lvJ0yjcluNiFI6RFcXpJ0fvAsH2GwKuCFBRCw=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=mQeDdDockWESUiMo+YE9E4KXPCl68sjn2Fz/kvgGlZ+nG9yqymyb28Xx+/grD7opQkFwkuvD8bWW5nrLZpS9q0cT4Mu2em4jTw6gVQIvET66HDcbUSCLHGkbKhcFBTh6u1Nv/mgAqq221FfEjXBYaCm0ZJeAuoz1OQYL5Dna2oI= 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=GWve+zop; arc=fail smtp.client-ip=40.107.243.40 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=amd.com Authentication-Results: smtp.subspace.kernel.org; spf=fail smtp.mailfrom=amd.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=amd.com header.i=@amd.com header.b="GWve+zop" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=PX0yhMVXfVFOdPJWHpRKMHUVFE8zlBldRX/6ZU4NkKpCL0xKBTMUF4BJNfYNHRcfqB6gCl3SRExngJibsrbQ/dhgzTz0t/a5v/Re1VKO4aQB+JMyQE0H2ZwD7lRlWFqHqV0B7SALKgQGJ4I64/9+ZhS0L+znPbtlEU9LHsBuuuFkauaeGT3cl2HJ94agIKXLq/gXgriyHRTFZh7Z7JoOIuhpPc2inygabUm7jlDh4Oz2YTeazNmuoTOg2xbAYNewgk5iE+sf9f3PyURcGEOJPIefwIFuEMugYvivKCq8aVk+3Ah95AEpRXPkV5EHAOaJVW5kwWGj8WPtl0i7muv9rw== 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=OJ1zoW1AhP/Agi+mGB2kUHhMNlmMJ9aHb9waDPoRetI=; b=AEhLRjhb5leTyGncd5THJAZbnnE24ZY2H9CUCJT1uOvQYnD87g9MwuhGhyIMDo6hxOV/5Ciu11C/ppavjIwt1lpy3Z5QQ4JiLLB8Lt+eLGvmRbMAL77yj3qzUoN8E/Af6KIgDwwzYA4FENT+KF4P8izMxc6CBxiTG+sDbHB5E6zogd4cZUV3hIkoMoTa1lGvta1eVhxKLGDI93ESZzCvbrVIDs+PeJWFDp/X45JUDgSF7Ae+mU5zjR7rGmrIZKdoHW4JdMLvbc9T01rp1hvaK1fBW0R0yP+drPHIrKnOHw7897aMJx/B18IaM7qB4dmVqMYUbgfE7nrUEKFrgsRGkQ== 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=OJ1zoW1AhP/Agi+mGB2kUHhMNlmMJ9aHb9waDPoRetI=; b=GWve+zopjIkZzdoWUBZu5u+vJuM6EpFYRNryeRtqsBbjiLWxa+1reBTM4sE7Y+5XMJOqkf6V8t2MZi4/4HXpfj6XAK2lbyvwX5kHq8P14Z3/IdEvs28Fv02XMN7pG4ksRb9W/P2ocyYhz4JUQLTjzND5VrzcBqZG2F/RqX9z7+Q= Received: from SA9P223CA0017.NAMP223.PROD.OUTLOOK.COM (2603:10b6:806:26::22) by IA1PR12MB6041.namprd12.prod.outlook.com (2603:10b6:208:3d7::16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8964.22; Fri, 25 Jul 2025 18:30:57 +0000 Received: from SA2PEPF000015C7.namprd03.prod.outlook.com (2603:10b6:806:26:cafe::db) by SA9P223CA0017.outlook.office365.com (2603:10b6:806:26::22) with Microsoft SMTP Server (version=TLS1_3, cipher=TLS_AES_256_GCM_SHA384) id 15.20.8964.23 via Frontend Transport; Fri, 25 Jul 2025 18:30:56 +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 SA2PEPF000015C7.mail.protection.outlook.com (10.167.241.197) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.8964.20 via Frontend Transport; Fri, 25 Jul 2025 18:30:56 +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; Fri, 25 Jul 2025 13:30:52 -0500 From: Babu Moger To: , , , , , , , CC: , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , Subject: [PATCH v16 04/34] x86,fs/resctrl: Prepare for more monitor events Date: Fri, 25 Jul 2025 13:29:23 -0500 Message-ID: <6e622e088020ca78446019cbbabb3d95fc9185ee.1753467772.git.babu.moger@amd.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: References: Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-ClientProxiedBy: SATLEXMB03.amd.com (10.181.40.144) To SATLEXMB04.amd.com (10.181.40.145) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: SA2PEPF000015C7:EE_|IA1PR12MB6041:EE_ X-MS-Office365-Filtering-Correlation-Id: 65c72983-2d53-4514-c6ad-08ddcba9653c X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|7416014|376014|82310400026|36860700013|1800799024; X-Microsoft-Antispam-Message-Info: =?us-ascii?Q?9PZbwT6bwKltOtunK+acqH3Rbpt+go/OFjoruKX/Ekypml5xF+0toUW9jbRk?= =?us-ascii?Q?GBz1ndTNHgpBAUXYM4q3TZH86JGJhErncpDOeZ1zJ7A1HqdDIZ5512GkBVQK?= =?us-ascii?Q?rxQUsLGrSqfLRLXOIG6Yr6ylielnVfTMmAm3hTKWEBZkaMVSFvPoHQ1sfb9L?= =?us-ascii?Q?WA6/YM7+Tr4b1CGR6QhQ/6FuyUnFqnC5JrsV+BMZrvxEWQz3m18jLeopOXm2?= =?us-ascii?Q?q9glnVpkxQKwQ2BUqZ1vzou3Egw/nQ/aOS3kC4Mi/ZMoSDlfbIR8sDEv0bHW?= =?us-ascii?Q?D2f78+GFR3Cfnnf6uglpBP8D28bfine61iz72x7LzZSX2IcDfkgKhp33MvRd?= =?us-ascii?Q?BVqR6v7fTo1u4y1iTERed3a3nr52vfyCSjHJka0S2ollcFvnINjMsvZyH4Ju?= =?us-ascii?Q?2fYD5TPgW2ABeOjG08kJffMVzMnIUtNGYZwUdv/bU4aWudrXm/NW7sNnpC9V?= =?us-ascii?Q?DONhReOJV1W4UAlV8E0pqMf3YncYnVBxz6ll/qTGC0tPJ5XUp3wku6NYgKB1?= =?us-ascii?Q?Q0NoxGnWOO4GdvDLngJfouEH2sZK4bfaQrzgv15cNCXQJNsDTxlOZ7VaNKfJ?= =?us-ascii?Q?yFgCmJ5gxKHorjuK1IlcY7BoBSTbXWp6JlxZZaIYT4/u8vER2/S48ZEdS2du?= =?us-ascii?Q?FcNR2oVJmDcoafOKtzH5IafQVjl41AD0Wo9g1ShNK8Dfrz6yi4Y1Ttiwt6Ao?= =?us-ascii?Q?0BLLoBgCvb9DmoGeoFCtgf2T9MVDUCMFPnpCC/Gb82NEEaWwRISM7mDyN5bi?= =?us-ascii?Q?8hif4fGlHJ8CPZW2Ep9aAfa9ikVSb1o7xas3hATV9J4z8MpXVy7BfGIwdTuw?= =?us-ascii?Q?FxZZRafUL9nAwKU7CTTfdqiNqnHvNI6gn+JTOZjbUq8phbcsGVpptKu//VqZ?= =?us-ascii?Q?U2RGXeOUi00SGEtqMQ5M1PuX9Ce+9d+7t3J4Xvs+7oOocHUz2GESjzwQfguf?= =?us-ascii?Q?lYXG/ArtR/WlTnc5nb+17p2MqUwxshMPekWkSZljA/Ud8VzWGPgGGRu/9FL1?= =?us-ascii?Q?aU/N9id/rjw2d+5xiPaUxZG6D7yievVfWnt/rcPgfQzhN/obFIj2b7jcuEpA?= =?us-ascii?Q?nPqsEknVp5WibpcR0/s8RjisFTsBwS760sTHiBj9UypOOXCAD5Hk3MUTTWAY?= =?us-ascii?Q?C5Ii0VEiH/BZDxvg/ZhOAPQLyZC4JUsLQZR7VS6HGVeMnudI1s2jR22sTlWO?= =?us-ascii?Q?rLWuCkBKKRNJAEb/nPe2dxm9TTZAGFZumXvO2oCEI7Ue52zSHlv695HwU99s?= =?us-ascii?Q?gksuYUjc7QHduqGA/5gqacn3G9ai+pZuKE7mwQsCyaLx6d3GIHb/omw90fgl?= =?us-ascii?Q?Yoltv//Q68oMMKnRhzZshR+vsnR+EKfCYLWN7YNNglUNuggWLQBH92ztrxc+?= =?us-ascii?Q?zmj5jqQadVgKJT631kDfyOp7rqzXNH1xpYxiF8TpFAPJs30q73yQuafPK/iw?= =?us-ascii?Q?RTnohSK+bCrvKxPBYQYd1boK4TMdy7hDcIUe9BWyTVLO6/YIWjtCJkSbVrtD?= =?us-ascii?Q?pukq6PIzZtsXIEKHNKirvlRyz+R5MtgSh/qcCPiR/vl4KEEpMN+jEtRcIg?= =?us-ascii?Q?=3D=3D?= X-Forefront-Antispam-Report: CIP:165.204.84.17;CTRY:US;LANG:en;SCL:1;SRV:;IPV:CAL;SFV:NSPM;H:SATLEXMB04.amd.com;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(13230040)(7416014)(376014)(82310400026)(36860700013)(1800799024);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 25 Jul 2025 18:30:56.4207 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 65c72983-2d53-4514-c6ad-08ddcba9653c 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: SA2PEPF000015C7.namprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: IA1PR12MB6041 Content-Type: text/plain; charset="utf-8" From: Tony Luck There's a rule in computer programming that objects appear zero, once, or many times. So code accordingly. There are two MBM events and resctrl is coded with a lot of if (local) do one thing if (total) do a different thing Change the rdt_mon_domain and rdt_hw_mon_domain structures to hold arrays of pointers to per event data instead of explicit fields for total and local bandwidth. Simplify by coding for many events using loops on which are enabled. Move resctrl_is_mbm_event() to so it can be used more widely. Also provide a for_each_mbm_event_id() helper macro. Cleanup variable names in functions touched to consistently use "eventid" for those with type enum resctrl_event_id. Signed-off-by: Tony Luck Reviewed-by: Reinette Chatre --- Picked up first four patches from: https://lore.kernel.org/lkml/20250711235341.113933-1-tony.luck@intel.com/ These patches have already been reviewed. --- arch/x86/kernel/cpu/resctrl/core.c | 40 +++++++++++---------- arch/x86/kernel/cpu/resctrl/internal.h | 8 ++--- arch/x86/kernel/cpu/resctrl/monitor.c | 36 +++++++++---------- fs/resctrl/monitor.c | 13 ++++--- fs/resctrl/rdtgroup.c | 50 +++++++++++++------------- include/linux/resctrl.h | 23 +++++++++--- include/linux/resctrl_types.h | 3 ++ 7 files changed, 96 insertions(+), 77 deletions(-) diff --git a/arch/x86/kernel/cpu/resctrl/core.c b/arch/x86/kernel/cpu/resct= rl/core.c index 5d14f9a14eda..fbf019c1ff11 100644 --- a/arch/x86/kernel/cpu/resctrl/core.c +++ b/arch/x86/kernel/cpu/resctrl/core.c @@ -365,8 +365,10 @@ static void ctrl_domain_free(struct rdt_hw_ctrl_domain= *hw_dom) =20 static void mon_domain_free(struct rdt_hw_mon_domain *hw_dom) { - kfree(hw_dom->arch_mbm_total); - kfree(hw_dom->arch_mbm_local); + int idx; + + for_each_mbm_idx(idx) + kfree(hw_dom->arch_mbm_states[idx]); kfree(hw_dom); } =20 @@ -400,25 +402,27 @@ static int domain_setup_ctrlval(struct rdt_resource *= r, struct rdt_ctrl_domain * */ static int arch_domain_mbm_alloc(u32 num_rmid, struct rdt_hw_mon_domain *h= w_dom) { - size_t tsize; - - if (resctrl_is_mon_event_enabled(QOS_L3_MBM_TOTAL_EVENT_ID)) { - tsize =3D sizeof(*hw_dom->arch_mbm_total); - hw_dom->arch_mbm_total =3D kcalloc(num_rmid, tsize, GFP_KERNEL); - if (!hw_dom->arch_mbm_total) - return -ENOMEM; - } - if (resctrl_is_mon_event_enabled(QOS_L3_MBM_LOCAL_EVENT_ID)) { - tsize =3D sizeof(*hw_dom->arch_mbm_local); - hw_dom->arch_mbm_local =3D kcalloc(num_rmid, tsize, GFP_KERNEL); - if (!hw_dom->arch_mbm_local) { - kfree(hw_dom->arch_mbm_total); - hw_dom->arch_mbm_total =3D NULL; - return -ENOMEM; - } + size_t tsize =3D sizeof(*hw_dom->arch_mbm_states[0]); + enum resctrl_event_id eventid; + int idx; + + for_each_mbm_event_id(eventid) { + if (!resctrl_is_mon_event_enabled(eventid)) + continue; + idx =3D MBM_STATE_IDX(eventid); + hw_dom->arch_mbm_states[idx] =3D kcalloc(num_rmid, tsize, GFP_KERNEL); + if (!hw_dom->arch_mbm_states[idx]) + goto cleanup; } =20 return 0; +cleanup: + for_each_mbm_idx(idx) { + kfree(hw_dom->arch_mbm_states[idx]); + hw_dom->arch_mbm_states[idx] =3D NULL; + } + + return -ENOMEM; } =20 static int get_domain_id_from_scope(int cpu, enum resctrl_scope scope) diff --git a/arch/x86/kernel/cpu/resctrl/internal.h b/arch/x86/kernel/cpu/r= esctrl/internal.h index 5e3c41b36437..58dca892a5df 100644 --- a/arch/x86/kernel/cpu/resctrl/internal.h +++ b/arch/x86/kernel/cpu/resctrl/internal.h @@ -54,15 +54,15 @@ struct rdt_hw_ctrl_domain { * struct rdt_hw_mon_domain - Arch private attributes of a set of CPUs tha= t share * a resource for a monitor function * @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 + * @arch_mbm_states: Per-event pointer to the MBM event's saved state. + * An MBM event's state is an array of struct arch_mbm_state + * indexed by RMID on x86. * * Members of this structure are accessed via helpers that provide abstrac= tion. */ 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; + struct arch_mbm_state *arch_mbm_states[QOS_NUM_L3_MBM_EVENTS]; }; =20 static inline struct rdt_hw_ctrl_domain *resctrl_to_arch_ctrl_dom(struct r= dt_ctrl_domain *r) diff --git a/arch/x86/kernel/cpu/resctrl/monitor.c b/arch/x86/kernel/cpu/re= sctrl/monitor.c index 07f8ab097cbe..f01db2034d08 100644 --- a/arch/x86/kernel/cpu/resctrl/monitor.c +++ b/arch/x86/kernel/cpu/resctrl/monitor.c @@ -161,18 +161,14 @@ static struct arch_mbm_state *get_arch_mbm_state(stru= ct rdt_hw_mon_domain *hw_do u32 rmid, enum resctrl_event_id eventid) { - switch (eventid) { - case QOS_L3_OCCUP_EVENT_ID: - return NULL; - case QOS_L3_MBM_TOTAL_EVENT_ID: - return &hw_dom->arch_mbm_total[rmid]; - case QOS_L3_MBM_LOCAL_EVENT_ID: - return &hw_dom->arch_mbm_local[rmid]; - default: - /* Never expect to get here */ - WARN_ON_ONCE(1); + struct arch_mbm_state *state; + + if (!resctrl_is_mbm_event(eventid)) return NULL; - } + + state =3D hw_dom->arch_mbm_states[MBM_STATE_IDX(eventid)]; + + return state ? &state[rmid] : NULL; } =20 void resctrl_arch_reset_rmid(struct rdt_resource *r, struct rdt_mon_domain= *d, @@ -201,14 +197,16 @@ void resctrl_arch_reset_rmid(struct rdt_resource *r, = struct rdt_mon_domain *d, void resctrl_arch_reset_rmid_all(struct rdt_resource *r, struct rdt_mon_do= main *d) { struct rdt_hw_mon_domain *hw_dom =3D resctrl_to_arch_mon_dom(d); - - if (resctrl_is_mon_event_enabled(QOS_L3_MBM_TOTAL_EVENT_ID)) - memset(hw_dom->arch_mbm_total, 0, - sizeof(*hw_dom->arch_mbm_total) * r->num_rmid); - - if (resctrl_is_mon_event_enabled(QOS_L3_MBM_LOCAL_EVENT_ID)) - memset(hw_dom->arch_mbm_local, 0, - sizeof(*hw_dom->arch_mbm_local) * r->num_rmid); + enum resctrl_event_id eventid; + int idx; + + for_each_mbm_event_id(eventid) { + if (!resctrl_is_mon_event_enabled(eventid)) + continue; + idx =3D MBM_STATE_IDX(eventid); + memset(hw_dom->arch_mbm_states[idx], 0, + sizeof(*hw_dom->arch_mbm_states[0]) * r->num_rmid); + } } =20 static u64 mbm_overflow_count(u64 prev_msr, u64 cur_msr, unsigned int widt= h) diff --git a/fs/resctrl/monitor.c b/fs/resctrl/monitor.c index 9e988b2c1a22..dcc6c00eb362 100644 --- a/fs/resctrl/monitor.c +++ b/fs/resctrl/monitor.c @@ -346,15 +346,14 @@ static struct mbm_state *get_mbm_state(struct rdt_mon= _domain *d, u32 closid, u32 rmid, enum resctrl_event_id evtid) { u32 idx =3D resctrl_arch_rmid_idx_encode(closid, rmid); + struct mbm_state *state; =20 - switch (evtid) { - case QOS_L3_MBM_TOTAL_EVENT_ID: - return &d->mbm_total[idx]; - case QOS_L3_MBM_LOCAL_EVENT_ID: - return &d->mbm_local[idx]; - default: + if (!resctrl_is_mbm_event(evtid)) return NULL; - } + + state =3D d->mbm_states[MBM_STATE_IDX(evtid)]; + + return state ? &state[idx] : NULL; } =20 static int __mon_event_count(u32 closid, u32 rmid, struct rmid_read *rr) diff --git a/fs/resctrl/rdtgroup.c b/fs/resctrl/rdtgroup.c index a7eeb33501da..77336d5e4915 100644 --- a/fs/resctrl/rdtgroup.c +++ b/fs/resctrl/rdtgroup.c @@ -127,12 +127,6 @@ static bool resctrl_is_mbm_enabled(void) resctrl_is_mon_event_enabled(QOS_L3_MBM_LOCAL_EVENT_ID)); } =20 -static bool resctrl_is_mbm_event(int e) -{ - return (e >=3D QOS_L3_MBM_TOTAL_EVENT_ID && - e <=3D QOS_L3_MBM_LOCAL_EVENT_ID); -} - /* * Trivial allocator for CLOSIDs. Use BITMAP APIs to manipulate a bitmap * of free CLOSIDs. @@ -4023,9 +4017,13 @@ static void rdtgroup_setup_default(void) =20 static void domain_destroy_mon_state(struct rdt_mon_domain *d) { + int idx; + bitmap_free(d->rmid_busy_llc); - kfree(d->mbm_total); - kfree(d->mbm_local); + for_each_mbm_idx(idx) { + kfree(d->mbm_states[idx]); + d->mbm_states[idx] =3D NULL; + } } =20 void resctrl_offline_ctrl_domain(struct rdt_resource *r, struct rdt_ctrl_d= omain *d) @@ -4085,32 +4083,34 @@ void resctrl_offline_mon_domain(struct rdt_resource= *r, struct rdt_mon_domain *d static int domain_setup_mon_state(struct rdt_resource *r, struct rdt_mon_d= omain *d) { u32 idx_limit =3D resctrl_arch_system_num_rmid_idx(); - size_t tsize; + size_t tsize =3D sizeof(*d->mbm_states[0]); + enum resctrl_event_id eventid; + int idx; =20 if (resctrl_is_mon_event_enabled(QOS_L3_OCCUP_EVENT_ID)) { d->rmid_busy_llc =3D bitmap_zalloc(idx_limit, GFP_KERNEL); if (!d->rmid_busy_llc) return -ENOMEM; } - if (resctrl_is_mon_event_enabled(QOS_L3_MBM_TOTAL_EVENT_ID)) { - tsize =3D sizeof(*d->mbm_total); - d->mbm_total =3D kcalloc(idx_limit, tsize, GFP_KERNEL); - if (!d->mbm_total) { - bitmap_free(d->rmid_busy_llc); - return -ENOMEM; - } - } - if (resctrl_is_mon_event_enabled(QOS_L3_MBM_LOCAL_EVENT_ID)) { - tsize =3D sizeof(*d->mbm_local); - d->mbm_local =3D kcalloc(idx_limit, tsize, GFP_KERNEL); - if (!d->mbm_local) { - bitmap_free(d->rmid_busy_llc); - kfree(d->mbm_total); - return -ENOMEM; - } + + for_each_mbm_event_id(eventid) { + if (!resctrl_is_mon_event_enabled(eventid)) + continue; + idx =3D MBM_STATE_IDX(eventid); + d->mbm_states[idx] =3D kcalloc(idx_limit, tsize, GFP_KERNEL); + if (!d->mbm_states[idx]) + goto cleanup; } =20 return 0; +cleanup: + bitmap_free(d->rmid_busy_llc); + for_each_mbm_idx(idx) { + kfree(d->mbm_states[idx]); + d->mbm_states[idx] =3D NULL; + } + + return -ENOMEM; } =20 int resctrl_online_ctrl_domain(struct rdt_resource *r, struct rdt_ctrl_dom= ain *d) diff --git a/include/linux/resctrl.h b/include/linux/resctrl.h index 40aba6b5d4f0..478d7a935ca3 100644 --- a/include/linux/resctrl.h +++ b/include/linux/resctrl.h @@ -161,8 +161,9 @@ struct rdt_ctrl_domain { * @hdr: common header for different domain types * @ci_id: cache info id for this domain * @rmid_busy_llc: bitmap of which limbo RMIDs are above threshold - * @mbm_total: saved state for MBM total bandwidth - * @mbm_local: saved state for MBM local bandwidth + * @mbm_states: Per-event pointer to the MBM event's saved state. + * An MBM event's state is an array of struct mbm_state + * indexed by RMID on x86 or combined CLOSID, RMID on Arm. * @mbm_over: worker to periodically read MBM h/w counters * @cqm_limbo: worker to periodically read CQM h/w counters * @mbm_work_cpu: worker CPU for MBM h/w counters @@ -172,8 +173,7 @@ struct rdt_mon_domain { struct rdt_domain_hdr hdr; unsigned int ci_id; unsigned long *rmid_busy_llc; - struct mbm_state *mbm_total; - struct mbm_state *mbm_local; + struct mbm_state *mbm_states[QOS_NUM_L3_MBM_EVENTS]; struct delayed_work mbm_over; struct delayed_work cqm_limbo; int mbm_work_cpu; @@ -376,6 +376,21 @@ bool resctrl_is_mon_event_enabled(enum resctrl_event_i= d eventid); =20 bool resctrl_arch_is_evt_configurable(enum resctrl_event_id evt); =20 +static inline bool resctrl_is_mbm_event(enum resctrl_event_id eventid) +{ + return (eventid >=3D QOS_L3_MBM_TOTAL_EVENT_ID && + eventid <=3D QOS_L3_MBM_LOCAL_EVENT_ID); +} + +/* Iterate over all memory bandwidth events */ +#define for_each_mbm_event_id(eventid) \ + for (eventid =3D QOS_L3_MBM_TOTAL_EVENT_ID; \ + eventid <=3D QOS_L3_MBM_LOCAL_EVENT_ID; eventid++) + +/* Iterate over memory bandwidth arrays in domain structures */ +#define for_each_mbm_idx(idx) \ + for (idx =3D 0; idx < QOS_NUM_L3_MBM_EVENTS; idx++) + /** * resctrl_arch_mon_event_config_write() - Write the config for an event. * @config_info: struct resctrl_mon_config_info describing the resource, d= omain diff --git a/include/linux/resctrl_types.h b/include/linux/resctrl_types.h index 2dadbc54e4b3..d98351663c2c 100644 --- a/include/linux/resctrl_types.h +++ b/include/linux/resctrl_types.h @@ -51,4 +51,7 @@ enum resctrl_event_id { QOS_NUM_EVENTS, }; =20 +#define QOS_NUM_L3_MBM_EVENTS (QOS_L3_MBM_LOCAL_EVENT_ID - QOS_L3_MBM_TOTA= L_EVENT_ID + 1) +#define MBM_STATE_IDX(evt) ((evt) - QOS_L3_MBM_TOTAL_EVENT_ID) + #endif /* __LINUX_RESCTRL_TYPES_H */ --=20 2.34.1 From nobody Mon Oct 6 01:21:10 2025 Received: from NAM11-BN8-obe.outbound.protection.outlook.com (mail-bn8nam11on2064.outbound.protection.outlook.com [40.107.236.64]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id EA312248869; Fri, 25 Jul 2025 18:31:12 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.236.64 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1753468274; cv=fail; b=n99MdnP/uK0Os3OrwysPtnx7hbivFEOoCLm0u/Uj8tzcncY+mzhP/VFB7sFzU2zh8yjdZYV+PlNiUR+a1HKewe8k+EGbUC6TPkaJzQOFbejdfjsGwABLavnXGcgEpeY9Gpgt1c3UjyRn03QcnRfn0ahL10JeKWRERBNDmNXZ9KY= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1753468274; c=relaxed/simple; bh=puIvZkNshZ8LHnu22QTcaE274k2xEvSwF5laNls5Qug=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=SDNN4k1nSAYXYxyi9SbiwmyIozifiAtbxDcVp3tKteWeUPoq5msHZ6pP183t2us2QObwvmsEUej9PEYGEi4y+11ytVgNwXToSUG1xdjOSi92kgVtdvH6nIljCYfkZWZa5nv1hAzVWCJyYlGyCw45wBDFXwn1U3Aog6jMNkYcsXI= 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=L3AU+1G5; arc=fail smtp.client-ip=40.107.236.64 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=amd.com Authentication-Results: smtp.subspace.kernel.org; spf=fail smtp.mailfrom=amd.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=amd.com header.i=@amd.com header.b="L3AU+1G5" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=d6wKkLrdxPhRNdCECt0IbMJah4olISAfOvVBC4O1iSTNPPWq2V60ZBVPhydVp5nxaWa/5p2XSeo2B0jkHk7r//kAfVJu/C8Ft/PG9by0vMZQNYwXF2qnCwre1fItz/OtFBxeAydK3CZCGUIa8Ye2lF1Y6rtd91GZrtJ+V0eByu9bv6D/vAKIkbqT3AdnuTGofrlNeLNbYlFjKjnpWxkxgoV4utOHxxzFmmhQrY50NnpbvtHm++IZkEj6SlEJnsLXBstDUGZdkCgr+ZVjdILQsC2Go2uUaazXIWS4MmeP20ZhcMsEQLrWMEzbTuBAsxPV9B+78CDluGOD70Cgi0h4ww== 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=XS1uTyS9FKUKhZA23c5i8Kl937iuC0noN5nbUAuMKD0=; b=vhB6BKv9DP0skWoUKpT8FVslTmNik4zPxacjvLVsfDXAf7/T1LZyCBWKFLPpcnSHegNm8J1XAyIj4bFQtNBiGf4OX/eohdwa3nVd3ixEYuxdgzanBgKkkYyTUIWC+Jb2m+iI9sCBNAHOvgPT1TMTIdWqNS7ermzpHATrcTpaX5w6o68t3oct7yTPlOg8TQ54pnBj90WtF858nsny9AKEpTffkOuxA2VyakX3VIdRBPc4LADpjf4QNesVAgi3Y46WJrjYTal/bzU60o9umcXqoB0IHkDNG5Ximm5l27bSKqNdh+O+deQnfrCsnhIRw1Zyl5Np0Lyzd/dWbrXr/O317g== 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=XS1uTyS9FKUKhZA23c5i8Kl937iuC0noN5nbUAuMKD0=; b=L3AU+1G5QoFEbGq7YTFvg9NG/rxSyZc1a9kKCBZrROgswkvH17okrfWijKaZ0qsi9eqw4njc5cCesEpIhu5s/EWic0aKv1g23k7DvDxQOIYcWZGgZksCBn+mKrvdFIdbinnGyA7w36WdRnpIrPcNCknJqoISDSrKIC4VvnnMNjY= Received: from BY3PR05CA0011.namprd05.prod.outlook.com (2603:10b6:a03:254::16) by LV2PR12MB5919.namprd12.prod.outlook.com (2603:10b6:408:173::17) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8964.21; Fri, 25 Jul 2025 18:31:08 +0000 Received: from SA2PEPF000015CA.namprd03.prod.outlook.com (2603:10b6:a03:254:cafe::1c) by BY3PR05CA0011.outlook.office365.com (2603:10b6:a03:254::16) with Microsoft SMTP Server (version=TLS1_3, cipher=TLS_AES_256_GCM_SHA384) id 15.20.8989.6 via Frontend Transport; Fri, 25 Jul 2025 18:31:08 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 165.204.84.17) smtp.mailfrom=amd.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=amd.com; Received-SPF: Pass (protection.outlook.com: domain of amd.com designates 165.204.84.17 as permitted sender) receiver=protection.outlook.com; client-ip=165.204.84.17; helo=SATLEXMB04.amd.com; pr=C Received: from SATLEXMB04.amd.com (165.204.84.17) by SA2PEPF000015CA.mail.protection.outlook.com (10.167.241.200) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.8964.20 via Frontend Transport; Fri, 25 Jul 2025 18:31:08 +0000 Received: from bmoger-ubuntu.amd.com (10.180.168.240) by SATLEXMB04.amd.com (10.181.40.145) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.39; Fri, 25 Jul 2025 13:31:01 -0500 From: Babu Moger To: , , , , , , , CC: , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , Subject: [PATCH v16 05/34] x86/cpufeatures: Add support for Assignable Bandwidth Monitoring Counters (ABMC) Date: Fri, 25 Jul 2025 13:29:24 -0500 Message-ID: X-Mailer: git-send-email 2.34.1 In-Reply-To: References: Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-ClientProxiedBy: SATLEXMB03.amd.com (10.181.40.144) To SATLEXMB04.amd.com (10.181.40.145) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: SA2PEPF000015CA:EE_|LV2PR12MB5919:EE_ X-MS-Office365-Filtering-Correlation-Id: 6703e705-98f8-451e-8a87-08ddcba96c3a X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|1800799024|82310400026|376014|7416014|36860700013; X-Microsoft-Antispam-Message-Info: =?us-ascii?Q?yct+HcxPwryLz2SCWPwl19WLawxB4YcT1z6SL/DQf0bpB9vya/SgcBRvacuc?= =?us-ascii?Q?JrsyNIFc/zGWguT6reH2fyJPYuPi6HDrg56DvFWUmKemImc8WfbGJl/t14+S?= =?us-ascii?Q?34+ohwiqHtBhkSbDafERPEKS8+SXmzpxeIhbvcD+db8Z8KDqO0qo9Uo/nxMT?= =?us-ascii?Q?iUlPNYj0ywg6oA+ayhNL2rGIAJ1ai/AqEpT7Hpj6c+loXaOB7PNHJTHBWhCT?= =?us-ascii?Q?60zP+DJL2QK5xGUA9ZywGrIY7orUYuwAjPspfNuTrebn1dpI3oZyyNV+3fY/?= =?us-ascii?Q?SJkN+PSqkVzesOw44VZKoS4GUfVAXtcacGae2rXEowc78DtZHDQ5Hhe0n75P?= =?us-ascii?Q?Q3Lz//G0ktR4teB5VX7I21h5eRndJYBqzCPhTqRiKEpDCT5BG7SWlXN4YlK+?= =?us-ascii?Q?IKFNPw1DROIAhyKaNfL5z6eBKis5d5RyvUl5uTLA0Q9CykQd4KtNlNNpQNVN?= =?us-ascii?Q?UrqVjjVS6L7Q0KYVW3w1QJjHEv155kFe5a0PabQMR3In6BDRqx6xKVWFrmLH?= =?us-ascii?Q?uQWvU05j7uxdAaz2qHycjP2W7RO0nAQnpod9vZdN9S7jbFK5Wzz8ICVsNxFe?= =?us-ascii?Q?93lCv+cAmUeMxKRUMhlKLV8G4d+waNVAE1+aK3nAtRLa9KZw5xjViIwVx/Yr?= =?us-ascii?Q?C9WzmC3hYVLf7DGbxH94YYKOSUUTGiSHMpNJFOvhFLWfnI4baJyrIqw5XcdY?= =?us-ascii?Q?TqxVRA710VzYt4hMXR35XtWlMLlgh4xbMbf/LJgAnJkhxQaTrwW8YwwEiliD?= =?us-ascii?Q?KGR7YaE47CQImvzpwzbcZONOKlu8Abm8qvj0WAtj8wch+2WcR0JZktWfInmT?= =?us-ascii?Q?TM66dVfzQteayHvz0I5b0a+8PjO05yYbhQ/eN7I1wUVLUjRjpPIsgXVffCro?= =?us-ascii?Q?rO4kxDC9A+qw+sUDmcHb+jSO8A8Gi0fnQvpNTNlmcNljWwKS2GZelcIt8F1C?= =?us-ascii?Q?lViVhMO4zahoiewLoOVaFFey3oAG0IC6LNh+ijnJO+TIJF8/z/ySjqwCOu18?= =?us-ascii?Q?arSU8qLtTlFc7pvKh+RXnlvoWxQf82CdVE2Y3uziqjG8T7cNgwQMQtPMEWz7?= =?us-ascii?Q?3Yz2AepdFAbCd5hcnG86VsvlRCbzGdLhjx0PurLrdhAx7Nvu0NLrywo6tpQi?= =?us-ascii?Q?UN8aazzEGx6ifAiZk6Ve3xwHn/ow+j3PRUsSFnGTnFeo1OtMmXlxQjKQHPA9?= =?us-ascii?Q?pzZix74QB/B0jVRV7c8liVtI1tSySPCdqG0WuI7F/P9WwJ9AzTjj6IzQkO5/?= =?us-ascii?Q?nUqYWqfCqPGade7BEtaIkZ4C1NNm5VwB4EkC+xvcOavep3wtPg6xRHt4rZAP?= =?us-ascii?Q?T0Ngbd/pD5QbGZgYmyuetu75a9ApuKsrP8C2SPAuhcAY7GbRoEp9RQYUIiZN?= =?us-ascii?Q?6PBp/5SU/4wtDqi5SQyqhDMrz/URLSs52y3lONKXRqYNyulwHi/HtPE9IjAG?= =?us-ascii?Q?BzQLNK2Mg/SFIFEwo60pZ5510NIG0OFyto0vCPzE9FFW7wnHYRDIb+M5Yzyn?= =?us-ascii?Q?mvSrV+REZmovZqGkrVa7sVnp84B86Lp/sYOJr1qdsh8eU/OvPzkNWxqpSg?= =?us-ascii?Q?=3D=3D?= X-Forefront-Antispam-Report: CIP:165.204.84.17;CTRY:US;LANG:en;SCL:1;SRV:;IPV:CAL;SFV:NSPM;H:SATLEXMB04.amd.com;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(13230040)(1800799024)(82310400026)(376014)(7416014)(36860700013);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 25 Jul 2025 18:31:08.1520 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 6703e705-98f8-451e-8a87-08ddcba96c3a 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: SA2PEPF000015CA.namprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: LV2PR12MB5919 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 during a particular time. Users do not have the option to monitor a group or set of groups for a certain period of time without worrying about RMID being reset in between. The ABMC feature allows users to assign a hardware counter to an RMID, event pair and monitor bandwidth usage as long as it is assigned. The hardware continues to track the assigned counter until it is explicitly unassigned by the user. There is no need to worry about counters being reset during this period. Additionally, the user can specify the type of memory transactions (e.g., reads, writes) for the counter to track. Without ABMC enabled, monitoring will work in current mode without assignment option. The Linux resctrl subsystem provides an interface that allows monitoring of up to two memory bandwidth events per group, selected from a combination of available total and local events. When ABMC is enabled, two events will be assigned to each group by default, in line with the current interface design. Users will also have the option to configure which types of memory transactions are counted by these events. Due to the limited number of available counters (32), users may quickly exhaust the available counters. If the system runs out of assignable ABMC counters, the kernel will report an error. In such cases, users will need to unassign one or more active counters to free up counters for new assignments. resctrl will provide options to assign or unassign events through the group-specific interface file. The feature is 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. v16: Fixed the conflicts with latest cpufeatures.h and scattered.c files. v15: Minor changelog update. v14: Removed the dependancy on X86_FEATURE_CQM_MBM_TOTAL and X86_FEATURE_CQ= M_MBM_LOCAL. as discussed in https://lore.kernel.org/lkml/5f8b21c6-5166-46a6-be14-0= c7c9bfb7cde@intel.com/ Need to re-work on ABMC enumeration during the init. Updated changelog with few text update. v13: Updated the commit log with Linux interface details. v12: Removed the dependancy on X86_FEATURE_BMEC. Removed the Reviewed-by tag as patch has changed. v11: No changes. v10: No changes. v9: Took care of couple of minor merge conflicts. No other changes. v8: No changes. v7: Removed "" from feature flags. Not required anymore. https://lore.kernel.org/lkml/20240817145058.GCZsC40neU4wkPXeVR@fat_crat= e.local/ v6: Added Reinette's Reviewed-by. Moved the Checkpatch note below ---. v5: Minor rebase change and subject line update. v4: Changes because of rebase. Feature word 21 has few more additions now. Changed the text to "tracked by hardware" instead of active. v3: Change because of rebase. Actual patch did not change. v2: Added dependency on X86_FEATURE_BMEC. --- arch/x86/include/asm/cpufeatures.h | 1 + arch/x86/kernel/cpu/scattered.c | 1 + 2 files changed, 2 insertions(+) diff --git a/arch/x86/include/asm/cpufeatures.h b/arch/x86/include/asm/cpuf= eatures.h index 602957dd2609..43cba78a50e5 100644 --- a/arch/x86/include/asm/cpufeatures.h +++ b/arch/x86/include/asm/cpufeatures.h @@ -494,6 +494,7 @@ #define X86_FEATURE_TSA_SQ_NO (21*32+11) /* AMD CPU not vulnerable to TSA= -SQ */ #define X86_FEATURE_TSA_L1_NO (21*32+12) /* AMD CPU not vulnerable to TSA= -L1 */ #define X86_FEATURE_CLEAR_CPU_BUF_VM (21*32+13) /* Clear CPU buffers using= VERW before VMRUN */ +#define X86_FEATURE_ABMC (21*32+14) /* Assignable Bandwidth Monitoring Co= unters */ =20 /* * BUG word(s) diff --git a/arch/x86/kernel/cpu/scattered.c b/arch/x86/kernel/cpu/scattere= d.c index b4a1f6732a3a..cdd3c3e2d4c6 100644 --- a/arch/x86/kernel/cpu/scattered.c +++ b/arch/x86/kernel/cpu/scattered.c @@ -50,6 +50,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_TSA_SQ_NO, CPUID_ECX, 1, 0x80000021, 0 }, { X86_FEATURE_TSA_L1_NO, CPUID_ECX, 2, 0x80000021, 0 }, { X86_FEATURE_AMD_WORKLOAD_CLASS, CPUID_EAX, 22, 0x80000021, 0 }, --=20 2.34.1 From nobody Mon Oct 6 01:21:10 2025 Received: from NAM02-BN1-obe.outbound.protection.outlook.com (mail-bn1nam02on2044.outbound.protection.outlook.com [40.107.212.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 E7142155C97; Fri, 25 Jul 2025 18:31:22 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.212.44 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1753468284; cv=fail; b=l8spdTLt1xZOTcIsOFIPLWWQ9jYERvGQFmoyIAiTP9rhSQiu/WzhV1e/v7DfelvdJ8EN3QXvtDLNXAEtjtnFE4EHfequyTQfSxu+gukt7TF6angvB3NG4oT/wUVg9OYf3TLBUda0FSfToNfDVWagKpdZSfpp7VJoBlEdbqnDGcA= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1753468284; c=relaxed/simple; bh=GrGKoAmjvBjE8nF8o3XT5GyfMLvPkWBk8cA3dCUX97A=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=Pela/OBR2wCDbOx0jJq2tHj76x3OOhLbJCONXXDD9U9IYLvLCoy3rrvhDoYyxiOOkT+bcPZ9VXfV9t+Xtcxyub42O7Qg5q/7BjXKxmVsU0zibnms+Wu9e7q5K0wO6T+swZN/9neU1nLuup4VR7br/CHmm9nqRMvGc3HiLwHVI5c= 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=R7+FpQNz; arc=fail smtp.client-ip=40.107.212.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="R7+FpQNz" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=VK95fCjb/9P+H5UjKmDO2spimIQ395rTKfONpOpHnh7/GOuB1URYw4DFDx0inoJrkZY7CJum7SsylT1yrXvIQG4644n4QPkFY92cYeV5uHwoeB/Gif31L1xbDYGgpHAuREAwXZp87nd1KdkxjHmM2hsFkCbmwuppXB/92wvWGRKcudQ9HI7S3pFHXJcAhWuLzfTQ5q0WaZnbNoqrCoowX+CN/TNANA510faVqC1qoSyYC36Wo9QrGWg+4XhVylnuW52960gVxhAgOxFPYkpDXlPlvaokZwRk2CSIIp3OR7hSUryQJEjWmkGWxdAqRJSHWkvZIw7XmJ+04EZN8b460A== 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=GuruLJu7M26304ztQ3GErW2Ibraq4OGv4mtKSU2wC10=; b=SW08qBXDUcM5hsGcEEj/EnZbvibmhrMhunqpVDyHxO55KT/UnA9UCYKhwvQZ0AcDrn37HaIhHzWjpoRMFahI/kVAy9ZpL7qylXDPMoJQqbxyWJLoe4xRP7JQ/b+YvgOZZ24Qtrg7CuQlTxkizLCkUOgT1gw6YTwStwFOL7jI1HoD5oEiqUmRsPpuVT43Ar2HK43T5v4k0mI1hZIFR45WpoyCtprZtWxr2FHFWIladVhm40j2dTpuNDeco3mhpiXWV/eI1lmcZkuvDoAbSuls2dA1fnJyo/E00a1mz0EIeYLWfOd3OxV/AXnSoEjLkKcCJAL5su45jKeabjpFB7plhw== 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=GuruLJu7M26304ztQ3GErW2Ibraq4OGv4mtKSU2wC10=; b=R7+FpQNzeUVI1LQLzk2fYIkRQ83CCGSiSvYHLDHG1Vo0Smeg3Mq5hLyZTL29doycXGwbeuEqDHJW1ZZ6S45f/dVqxqa58E43PXmGFVpeEthOA7TyGFtrZBzXzAWfqZhMl0eBC1oDyW3kZfbFDpD51KX1ESNjjC97n7AvqcQe8HY= Received: from BY3PR05CA0008.namprd05.prod.outlook.com (2603:10b6:a03:254::13) by SA1PR12MB8857.namprd12.prod.outlook.com (2603:10b6:806:38d::6) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8964.22; Fri, 25 Jul 2025 18:31:18 +0000 Received: from SA2PEPF000015CA.namprd03.prod.outlook.com (2603:10b6:a03:254:cafe::89) by BY3PR05CA0008.outlook.office365.com (2603:10b6:a03:254::13) with Microsoft SMTP Server (version=TLS1_3, cipher=TLS_AES_256_GCM_SHA384) id 15.20.8989.6 via Frontend Transport; Fri, 25 Jul 2025 18:31: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 SA2PEPF000015CA.mail.protection.outlook.com (10.167.241.200) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.8964.20 via Frontend Transport; Fri, 25 Jul 2025 18:31: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; Fri, 25 Jul 2025 13:31:15 -0500 From: Babu Moger To: , , , , , , , CC: , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , Subject: [PATCH v16 06/34] x86/resctrl: Add ABMC feature in the command line options Date: Fri, 25 Jul 2025 13:29:25 -0500 Message-ID: <333d6f5ddf02d772ab6ad5cc26e65804f444fa0e.1753467772.git.babu.moger@amd.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: References: Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-ClientProxiedBy: SATLEXMB03.amd.com (10.181.40.144) To SATLEXMB04.amd.com (10.181.40.145) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: SA2PEPF000015CA:EE_|SA1PR12MB8857:EE_ X-MS-Office365-Filtering-Correlation-Id: 1c094708-7931-4dce-df14-08ddcba971e1 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?X1S836AfzABIbHDk5aKjHb+8hhNCts84I5NT0o2ra3kj9aTqxu4Yvmw30ANy?= =?us-ascii?Q?eoDBG94s+PgFT8vgReWqyJHIY1fjHG5xSFGNbFuUvK5SFxdJOGg3dVGQxi0z?= =?us-ascii?Q?cdgKCWIIxfWYpuqRwhk3gpR+5Z6S0kIVeMKpSTogcjwRx2t/4ZpdOvOKYoWq?= =?us-ascii?Q?6IaI/2whP9J18ru7Z8szfKKLuUyWBxwqCZkwbVsKXRpgAHkiWTuAFoQ3RamY?= =?us-ascii?Q?lEprldPl/GRnmzGF7bWAOIg9RnePbBJpkc7FmmsfNhu4vD8ytVhjIHoOaNiq?= =?us-ascii?Q?vKu269hpQCJSd9Mi4CzU2/SsCaj2tOlcTxSM/ODm5EFmodcPB86KYC72ShV+?= =?us-ascii?Q?sLuf9LfTtWOi96PdItg27zHm+HxZp6mu731EsuLQKnRzs38mO184Rzydc+0G?= =?us-ascii?Q?FSVHW+08+jTIQWV5d1gOo1KEpzB81aYfKayIl0gQhj294NJYno4SooYpK+c6?= =?us-ascii?Q?BUd2dcm7eWdRRYb3FXF8dDMmu/5lEDeD0/xd1kG3bGvF/O1rLc2tnIAoxmfn?= =?us-ascii?Q?psFd2c/crxsrsPQIaiw11hKyYCgL+yYTgh2mgfBm92kbNJh5fWz6Pn4x4Xtv?= =?us-ascii?Q?yphoGcBYollu2A741b2uis+y/88XcTF/f7blw7sos6dAiObOInOLGO5ndTDu?= =?us-ascii?Q?U5WZg5TasfGa8buiP8WDQ0th+zQjrAjWUYifV6ddVF6GDwcBrDlZuW/Ye2T5?= =?us-ascii?Q?vtJkM04dtLJ3lkoeCSo+J4p+Qbo3OGYBqunEpb4j7hbVXDcbyBqyf+CpUsBT?= =?us-ascii?Q?1GefG7D8WkDSMjEl9S4IvIHfTcoNE1RPZtD37FnjRz2N/b1xHyubKjZO19JR?= =?us-ascii?Q?psFvFENafkn0XW1r9FdYpwngb6pfRZXQM/eykpVFW/YXnmd2yyLaFhpH3HFQ?= =?us-ascii?Q?culthnOo7qe79cMz2SS5acvRHXiA/UHQUS/BfFaQZCw/Ik0L9rP4T1ST6f4l?= =?us-ascii?Q?my1t0aiQINkvfBL7BzTRZ0zQa5lOJnJzVNTavHNL7ldXGo8sLsyh9mTPFg95?= =?us-ascii?Q?/vM4W1aTL3SIrHNraGqpZmeOwd7J5lX14FwZGoxt8X2hNm+IPCPGbCFEQ2Jf?= =?us-ascii?Q?XsZHOnJEvhceikAylcUbEFU/YsekbZH1WqSiIdACXSwJqmrU9n1LerC4qC4F?= =?us-ascii?Q?7/E9uBAqENl3fDtyojwb29Ykn0tI0odfWZbqJmYnLPwsna3RjYPKSUafgpnE?= =?us-ascii?Q?QPBMiOfLO2IRqctr5MpIS1VKItH/FUDiwteQQQXYJJr8s4C2JkZRZIGfd8i4?= =?us-ascii?Q?7hbjN60+bNqOEIsYJhidhKOLu+qsyvjDwP+BMAhNJ7Ne/5p9e7+aNxYk3qkX?= =?us-ascii?Q?Uw6RGn2YnuS9iz+Vp0mnVYRG2CON61oArLcwboDoamjdqfA0f/GZ+vMeimX/?= =?us-ascii?Q?tOUGl21XsHOIx40syBxvJQKL1Dq/OcNFZr8oms3hGdTIF7dTWzmTvggHsy6X?= =?us-ascii?Q?sg2qqodXXe+BWHoQ1KIyHZtgR8Ku2aj+NIdyzik1GtOqIqEQNhuyGduHFqcy?= =?us-ascii?Q?cx/AU+PfjvwUHOeFjk+W7Ycmh+YXE5z34rF5?= 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: 25 Jul 2025 18:31:17.6349 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 1c094708-7931-4dce-df14-08ddcba971e1 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: SA2PEPF000015CA.namprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: SA1PR12MB8857 Content-Type: text/plain; charset="utf-8" Add a kernel command-line parameter to enable or disable the exposure of the ABMC (Assignable Bandwidth Monitoring Counters) hardware feature to resctrl. Signed-off-by: Babu Moger Reviewed-by: Reinette Chatre --- v16: Added Reviewed-by tag. v15: No changes. v14: Slight changelog modification. v13: Removed the Reviewed-by as the file resctrl.rst is moved to Documentation/filesystems/resctrl.rst. In that sense patch has changed. v12: No changes. v11: No changes. v10: No changes. v9: No code changes. Added Reviewed-by. v8: Commit message update. v7: No changes v6: No changes v5: No changes v4: No changes v3: No changes v2: No changes --- Documentation/admin-guide/kernel-parameters.txt | 2 +- Documentation/filesystems/resctrl.rst | 1 + arch/x86/kernel/cpu/resctrl/core.c | 2 ++ 3 files changed, 4 insertions(+), 1 deletion(-) diff --git a/Documentation/admin-guide/kernel-parameters.txt b/Documentatio= n/admin-guide/kernel-parameters.txt index b29c7a8dc7e6..6a74a32c9416 100644 --- a/Documentation/admin-guide/kernel-parameters.txt +++ b/Documentation/admin-guide/kernel-parameters.txt @@ -6077,7 +6077,7 @@ rdt=3D [HW,X86,RDT] Turn on/off individual RDT features. List is: cmt, mbmtotal, mbmlocal, l3cat, l3cdp, l2cat, l2cdp, - mba, smba, bmec. + mba, smba, bmec, abmc. E.g. to turn on cmt and turn off mba use: rdt=3Dcmt,!mba =20 diff --git a/Documentation/filesystems/resctrl.rst b/Documentation/filesyst= ems/resctrl.rst index c7949dd44f2f..c97fd77a107d 100644 --- a/Documentation/filesystems/resctrl.rst +++ b/Documentation/filesystems/resctrl.rst @@ -26,6 +26,7 @@ MBM (Memory Bandwidth Monitoring) "cqm_mbm_total", "cqm_= mbm_local" MBA (Memory Bandwidth Allocation) "mba" SMBA (Slow Memory Bandwidth Allocation) "" BMEC (Bandwidth Monitoring Event Configuration) "" +ABMC (Assignable Bandwidth Monitoring Counters) "" =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D =3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D =20 Historically, new features were made visible by default in /proc/cpuinfo. = This diff --git a/arch/x86/kernel/cpu/resctrl/core.c b/arch/x86/kernel/cpu/resct= rl/core.c index fbf019c1ff11..b07b12a05886 100644 --- a/arch/x86/kernel/cpu/resctrl/core.c +++ b/arch/x86/kernel/cpu/resctrl/core.c @@ -711,6 +711,7 @@ enum { RDT_FLAG_MBA, RDT_FLAG_SMBA, RDT_FLAG_BMEC, + RDT_FLAG_ABMC, }; =20 #define RDT_OPT(idx, n, f) \ @@ -736,6 +737,7 @@ static struct rdt_options rdt_options[] __ro_after_ini= t =3D { RDT_OPT(RDT_FLAG_MBA, "mba", X86_FEATURE_MBA), RDT_OPT(RDT_FLAG_SMBA, "smba", X86_FEATURE_SMBA), RDT_OPT(RDT_FLAG_BMEC, "bmec", X86_FEATURE_BMEC), + RDT_OPT(RDT_FLAG_ABMC, "abmc", X86_FEATURE_ABMC), }; #define NUM_RDT_OPTIONS ARRAY_SIZE(rdt_options) =20 --=20 2.34.1 From nobody Mon Oct 6 01:21:10 2025 Received: from NAM11-DM6-obe.outbound.protection.outlook.com (mail-dm6nam11on2070.outbound.protection.outlook.com [40.107.223.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 B961224A079; Fri, 25 Jul 2025 18:31:34 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.223.70 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1753468296; cv=fail; b=sO552eisZZPPAULtw+NMeduvB7CFZ4/CtA5NCVy1BzTqKGw4dFx/eIsDsEtGcHSg1bSD0W4yzCJIbF0e1J7ze2SvfIC7iTqksRIac0kQrQLNU0yR4YtSLYIXaH/OgIHt2lnvfrvW2Rv3cYe6B5euqBr6DHlsQBCyNJrTSArUS94= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1753468296; c=relaxed/simple; bh=qDgBlQ8PkeQysYdW7tHHCt9KF2Y85t9r77ZIFwwdw9A=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=WkNSME2ft6AwXj3FHXdr8s0jRTgm+sXZ4wsWRG1Ix1HFmFrMyxnocMWK3QmjUDDlxBAtAbKvXxwki70j46T5MeLclJSo25/j19Nsq8Bgm33SvZ4AO8GLqKEqUCn31DuHoR2HLotKcal8Qxfl1ZyHUivlKn3BXOIcHPB7Ml9Ebis= 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=a8D+AumY; arc=fail smtp.client-ip=40.107.223.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="a8D+AumY" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=J3xFevYjURHU4vjcl7PV+xGKiFJ6GOXDa4oBSLIyM8Koxt5SxikYiD1jvcjCKf3zeYbWNL8Nvrl/5mkTY9vRYTbZh6LXYFHOWghet81N/9VccRQVOi2WFc+zZKmfLBMzzRhhAP8ZUmpOaVxJo3T9uND9SJsQt6eaApasujdVLnCuQn22jkTtAOQ1XI4GP3cY88jhW33YFpvZpotFTXdI/BK5W2ihs+xa5vUOW3sN8QWMQQht7c8CsAHKXlA0PMFYYjR9qlCIlWShfetS2wQM41vNsl4KFcgwxbscgXvN/Et1x248XkTsZ14dgvzx31d/f7a5loVzGmcNvgWmREGMig== 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=ku71Tai/ECAGbOId8A/xg4U6M3+urC+pOgHI5734cqk=; b=m8Z/AieIOMYlJhaBzVCRFHmxIDsvczi3duqT7VqJUSG7U++AM+l59dFztQsdL7C8Mnw1zXHTafLVkzjzVpJZQ48DMTpQG4czHXsNtVOE0pzTPsT/BSvO8XA4jh39UFqYlOTcshyBp80NB7HEfarlCwUgPNYdrvJwgyp1u0LinRqBaZERMd3f/k4Cwr24tjBfzW1U6ejDw/OLifeHEqChyXXFPPqi0FJJu+nI4a3zuHjFxzaJ6cAIuAFTCu6Vq7F5IqQIfWPfTOAx5PbGI2dzC9hiXgH88TzXbhwOyALco144YOot0XV6K2U8ENIFKLqWxPA6HGVt5046DKt4jzK81A== 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=ku71Tai/ECAGbOId8A/xg4U6M3+urC+pOgHI5734cqk=; b=a8D+AumYwahBxaZifgPl7IBFrtpavBpfW+uel4XzMd9h7qNK8sjP3lWWPvbT56rczPL+n1kiqjJIB9Zcln7cTgk8UHaP/C+ADkV5CNVDdCd90au7b2CFrLwRpBGR4DKHhF0Fv/QjYWr/BpDXXzTQqCVSGpGvhR1u9vDQ4vl/jmU= Received: from MW4PR03CA0129.namprd03.prod.outlook.com (2603:10b6:303:8c::14) by DM3PR12MB9285.namprd12.prod.outlook.com (2603:10b6:0:49::7) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8964.22; Fri, 25 Jul 2025 18:31:32 +0000 Received: from SA2PEPF000015C6.namprd03.prod.outlook.com (2603:10b6:303:8c:cafe::6c) by MW4PR03CA0129.outlook.office365.com (2603:10b6:303:8c::14) with Microsoft SMTP Server (version=TLS1_3, cipher=TLS_AES_256_GCM_SHA384) id 15.20.8964.22 via Frontend Transport; Fri, 25 Jul 2025 18:31: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 SA2PEPF000015C6.mail.protection.outlook.com (10.167.241.196) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.8964.20 via Frontend Transport; Fri, 25 Jul 2025 18:31: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; Fri, 25 Jul 2025 13:31:29 -0500 From: Babu Moger To: , , , , , , , CC: , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , Subject: [PATCH v16 07/34] x86,fs/resctrl: Consolidate monitoring related data from rdt_resource Date: Fri, 25 Jul 2025 13:29:26 -0500 Message-ID: X-Mailer: git-send-email 2.34.1 In-Reply-To: References: Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-ClientProxiedBy: SATLEXMB03.amd.com (10.181.40.144) To SATLEXMB04.amd.com (10.181.40.145) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: SA2PEPF000015C6:EE_|DM3PR12MB9285:EE_ X-MS-Office365-Filtering-Correlation-Id: dffc3eb1-2bbf-48d0-8d81-08ddcba97a2d X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|376014|7416014|36860700013|82310400026|1800799024; X-Microsoft-Antispam-Message-Info: =?us-ascii?Q?QcagSVEHK/RYWoBmlfyllBCr9UO3WOJ8COQU7i1zn/vx+mUutJ23qLzFmTpU?= =?us-ascii?Q?BYh5s+xTYNogckA4oaG1dxiBSKcAJln6GWonsy8F9gMQ1EyQYiEVMBqlaPZO?= =?us-ascii?Q?wpQYqbmXl7JOooH00J7WdHOhe+5WD+W1iNES9G74G3NxeY6UyEC0k1vSRY3R?= =?us-ascii?Q?e3wWkzGpv0DUgOYiLgD2QsJa7+z3EVaWN3vavgF3hi+7RxVz0v3YVhbt1FA0?= =?us-ascii?Q?9Yp2utpBXmQeiiIgX/c8RdpVyysaTE8o8ZtYsXfcOnZZ13ABamjfhltZ6pGp?= =?us-ascii?Q?atSo48PSw2M9Y3bnuGN3/hY6RCVkA3eyAod0bU9v5Yj6XpmKr6GlQRfrjwDj?= =?us-ascii?Q?EtGUp2g4dbVEBfz34N1Kp32IvOJ8FiZeobosVmOqBflSt8VNm76Hnv3sbIu3?= =?us-ascii?Q?9DdPJS66XMfAgNxTmEhRnQtvGVvS2IPuEDNmqBwy4FBa8qGTaBMmtDeFZ16H?= =?us-ascii?Q?sS+wB5nqopW9c3TDt6o/8p8WLmrVlsEbt7+YEWQCrylmfDNPzLaL290Hbx9v?= =?us-ascii?Q?YV25UnZ93xvfcUVzwEohlEQJGCXJrDQoBSJEd8a+JdpPa/etxUipLlfNB74u?= =?us-ascii?Q?MMk7O7S9rQ2nYrAKzNkpiecRpvyYKT+D+vVOpqpPYVydGmRKL7zpb599G8kd?= =?us-ascii?Q?kBe1NgVH2vBRjJIIg3RM56Drd9MhOSuguPxlcYiqP60Zst1/C4UKxRg5lY0t?= =?us-ascii?Q?pfG1ZckXyDFItx1PMGIACz2TxMg4vLXtxdUpuJcYppBtB3JQE32dL/EbwfWW?= =?us-ascii?Q?igbG2XwK7ENwW651tmclvlbFtu7+1LdGP675xV5Wqd8+ig4bmi2ozd4Bfsr1?= =?us-ascii?Q?rfofX3IiYEoGNo0CeOhj7TIb95UvG5PAT4SgH2a2xnams83VcI0HpRi9Sk1A?= =?us-ascii?Q?f0tp8ikiGLvTmd8HEnAJusW6nPXbSC4UIUEBLeidqdC3NDmf6wqRXZ0Tm/Yc?= =?us-ascii?Q?cjviydHIDioDkmdbNvB4Oh9F/YNZqNdTvv5Ugkt3IBLPKVdEgqbq0vjq087T?= =?us-ascii?Q?XYhxXcjMi6ZFhPuG1FvZxa2yeqWo3AVY5dBNliqeGbS8GPu7eeysOtXGx1oZ?= =?us-ascii?Q?pSRWVfLi2YlVZtp66tFhTPxNXiH/EN6WbuMfrrPbX+uWd9Q+7+h6M+oKg/Ai?= =?us-ascii?Q?Wb+3p4UMHRs0uHl3uwPV9U5hVC+SB5jXcYDuDnxDukZnuLyLwuUir1v4KkG5?= =?us-ascii?Q?uRbXrTkTachuCGAcvNFBPj2nuw7/I8W6FIKvQAlobQxAiXqiS6f621BiITNV?= =?us-ascii?Q?pG4PSiG+IswPPS+OFZD69yAlxxUToF09G8IjYmAokjduGpUzQPKu0PYXDbtX?= =?us-ascii?Q?ItdyxS+DVpAanBWt/tPZklxrmPp7CUHiecgpYv4sRCuA5L4FU1zpPNxXui+T?= =?us-ascii?Q?IPrYBcm5hUeSu4MkJL5oesXyLhrK7tZS7IQDwjRFiUQsZDQXJO1/XlJGmYqo?= =?us-ascii?Q?Ibfe6n8RRm1fMYeB2B+HlEnzBCzfdZgzzweM/9TXT3KoHrMNizwJ0rZUz2GQ?= =?us-ascii?Q?wBBg+zK3Fyan61C9NhLVOdWrZKQWjyppBULX?= X-Forefront-Antispam-Report: CIP:165.204.84.17;CTRY:US;LANG:en;SCL:1;SRV:;IPV:CAL;SFV:NSPM;H:SATLEXMB04.amd.com;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(13230040)(376014)(7416014)(36860700013)(82310400026)(1800799024);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 25 Jul 2025 18:31:31.5544 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: dffc3eb1-2bbf-48d0-8d81-08ddcba97a2d 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: SA2PEPF000015C6.namprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM3PR12MB9285 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. Also switch "bandwidth sources" term to "memory transactions" to use consistent term within resctrl for related monitoring features. Suggested-by: Reinette Chatre Signed-off-by: Babu Moger Reviewed-by: Reinette Chatre --- v16: Added the Reviewed-by tag. v15: Updated changelog. Minor update in code comment in resctrl.h. v14: Updated the code comment in resctrl.h. v13: Changes due to FS/ARCH restructure. v12: Fixed the conflicts due to recent changes in rdt_resource data structu= re. Added new mbm_cfg_mask field to resctrl_mon. Removed Reviewed-by tag as patch has changed. v11: No changes. v10: No changes. v9: No changes. v8: Added Reviewed-by from Reinette. No other changes. v7: Added kernel doc for data structure. Minor text update. v6: Update commit message and update kernel doc for rdt_resource. v5: Commit message update. Also changes related to data structure updates does to SNC support. v4: New patch. --- arch/x86/kernel/cpu/resctrl/core.c | 4 ++-- arch/x86/kernel/cpu/resctrl/monitor.c | 10 +++++----- fs/resctrl/rdtgroup.c | 6 +++--- include/linux/resctrl.h | 18 +++++++++++++----- 4 files changed, 23 insertions(+), 15 deletions(-) diff --git a/arch/x86/kernel/cpu/resctrl/core.c b/arch/x86/kernel/cpu/resct= rl/core.c index b07b12a05886..267e9206a999 100644 --- a/arch/x86/kernel/cpu/resctrl/core.c +++ b/arch/x86/kernel/cpu/resctrl/core.c @@ -107,7 +107,7 @@ u32 resctrl_arch_system_num_rmid_idx(void) struct rdt_resource *r =3D &rdt_resources_all[RDT_RESOURCE_L3].r_resctrl; =20 /* RMID are independent numbers for x86. num_rmid_idx =3D=3D num_rmid */ - return r->num_rmid; + return r->mon.num_rmid; } =20 struct rdt_resource *resctrl_arch_get_resource(enum resctrl_res_level l) @@ -541,7 +541,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 f01db2034d08..2558b1bdef8b 100644 --- a/arch/x86/kernel/cpu/resctrl/monitor.c +++ b/arch/x86/kernel/cpu/resctrl/monitor.c @@ -130,7 +130,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) @@ -205,7 +205,7 @@ void resctrl_arch_reset_rmid_all(struct rdt_resource *r= , struct rdt_mon_domain * continue; idx =3D MBM_STATE_IDX(eventid); memset(hw_dom->arch_mbm_states[idx], 0, - sizeof(*hw_dom->arch_mbm_states[0]) * r->num_rmid); + sizeof(*hw_dom->arch_mbm_states[0]) * r->mon.num_rmid); } } =20 @@ -344,7 +344,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) @@ -359,7 +359,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 @@ -373,7 +373,7 @@ int __init rdt_get_mon_l3_config(struct rdt_resource *r) =20 /* Detect list of bandwidth sources that can be tracked */ cpuid_count(0x80000020, 3, &eax, &ebx, &ecx, &edx); - r->mbm_cfg_mask =3D ecx & MAX_EVT_CONFIG_BITS; + r->mon.mbm_cfg_mask =3D ecx & MAX_EVT_CONFIG_BITS; } =20 r->mon_capable =3D true; diff --git a/fs/resctrl/rdtgroup.c b/fs/resctrl/rdtgroup.c index 77336d5e4915..ca0475b75390 100644 --- a/fs/resctrl/rdtgroup.c +++ b/fs/resctrl/rdtgroup.c @@ -1135,7 +1135,7 @@ static int rdt_num_rmids_show(struct kernfs_open_file= *of, { struct rdt_resource *r =3D rdt_kn_parent_priv(of->kn); =20 - seq_printf(seq, "%d\n", r->num_rmid); + seq_printf(seq, "%d\n", r->mon.num_rmid); =20 return 0; } @@ -1731,9 +1731,9 @@ static int mon_config_write(struct rdt_resource *r, c= har *tok, u32 evtid) } =20 /* Value from user cannot be more than the supported set of events */ - if ((val & r->mbm_cfg_mask) !=3D val) { + if ((val & r->mon.mbm_cfg_mask) !=3D val) { rdt_last_cmd_printf("Invalid event configuration: max valid mask is 0x%0= 2x\n", - r->mbm_cfg_mask); + r->mon.mbm_cfg_mask); return -EINVAL; } =20 diff --git a/include/linux/resctrl.h b/include/linux/resctrl.h index 478d7a935ca3..fe2af6cb96d4 100644 --- a/include/linux/resctrl.h +++ b/include/linux/resctrl.h @@ -255,38 +255,46 @@ enum resctrl_schema_fmt { RESCTRL_SCHEMA_RANGE, }; =20 +/** + * struct resctrl_mon - Monitoring related data of a resctrl resource. + * @num_rmid: Number of RMIDs available. + * @mbm_cfg_mask: Memory transactions that can be tracked when bandwidth + * monitoring events can be configured. + */ +struct resctrl_mon { + int num_rmid; + unsigned int mbm_cfg_mask; +}; + /** * struct rdt_resource - attributes of a resctrl resource * @rid: The index of the resource * @alloc_capable: Is allocation available on this machine * @mon_capable: Is monitor feature available on this machine - * @num_rmid: Number of RMIDs available * @ctrl_scope: Scope of this resource for control functions * @mon_scope: Scope of this resource for monitor functions * @cache: Cache allocation related data * @membw: If the component has bandwidth controls, their properties. + * @mon: Monitoring related data. * @ctrl_domains: RCU list of all control domains for this resource * @mon_domains: RCU list of all monitor domains for this resource * @name: Name to use in "schemata" file. * @schema_fmt: Which format string and parser is used for this schema. - * @mbm_cfg_mask: Bandwidth sources that can be tracked when bandwidth - * monitoring events can be configured. * @cdp_capable: Is the CDP feature available on this resource */ struct rdt_resource { int rid; bool alloc_capable; bool mon_capable; - int num_rmid; enum resctrl_scope ctrl_scope; enum resctrl_scope mon_scope; struct resctrl_cache cache; struct resctrl_membw membw; + struct resctrl_mon mon; struct list_head ctrl_domains; struct list_head mon_domains; char *name; enum resctrl_schema_fmt schema_fmt; - unsigned int mbm_cfg_mask; bool cdp_capable; }; =20 --=20 2.34.1 From nobody Mon Oct 6 01:21:10 2025 Received: from NAM04-BN8-obe.outbound.protection.outlook.com (mail-bn8nam04on2069.outbound.protection.outlook.com [40.107.100.69]) (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 A63D02472AB; Fri, 25 Jul 2025 18:31:47 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.100.69 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1753468309; cv=fail; b=of6zvKJltqliXTf/kUyNdMa94bffbCxjRhnjNLxz/FU/4QYHYgFHJBs9l2o4PCUM7oZ3KzvAwV62F/VPXAtV+2/FtEQ4RrAWvzWpSMdCXPPu8RKf7cEsD0XRw4wqtsc3pOWcdg/LgSFJPSPsHWrjaStgh1PQ6CMsIsMeBCfJYfk= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1753468309; c=relaxed/simple; bh=PbdwAgX8mp9MNPfAVoKtfp3CnuvpShQkolYloOKqvjk=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=XPXd0khpjspVetN3zZHpkdfSU0ivbXP0cxrSpG8O3E2P3xlLrHHlAXGXz4zi4wISXauDLl+73pDC44XFrMyil+UHV6q6qtQJR6ttIgC9cY6s0Vbq/N7SQLMet1NFGkCUf1HWfyYkq9tNn58lLF3eL4kYMJeATNk5Od8Rw+WsYsc= 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=FDYMz6iZ; arc=fail smtp.client-ip=40.107.100.69 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="FDYMz6iZ" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=VygXwkSj8jxmb36qNjtUl1vHXgGZLpL4UtUwS43d+tjPqaBOaCZz+kvpNGKizBo5WiK0vXf7iZ7nYXKytRFQWMnB0WEzMtJGUhWuffC8XK6l76XcvvCstYldC6hXkhi91XvK3+32p1ifpaXEPmMxyYgWYmDkJHixxxs7yNwi/IscSiM0x8alNCih5bwPN+aBI2UpB3vr2GhcJjgR/4Q5SqQrVw3F5rf6+c8sydHd/EQ5QLqpzVoWUqoO5IJ4AlAc5/QNhplDR5bGgrCaZYWA+XZFLnLSEb9CSosPYR0aBg6xmHKS56SQVbVIruGLtJvAwpTbFnmjJzUjLMpkTqtMng== 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=Dg7zMAksRbS76WEHcxxsYZ+XN6eU5DjoVhFlBlFagOM=; b=y5NaBE9yJfGfUaRlx2nd4LvFuD+fIrg3y7oNBowptk/ZdsOYbKszCdhauXLjHxJ+O7j6T83fr+NqhYTD0BbXuRBhhf0tgsoeaYKSjEUQ7IxDOSb7KJJYC6wjFDcgTK2Q2JHoOOGGnnG5v/TAOYG7TXTQLt45fPlyFnXbMfbLLE4eygIE5Ngz6Ll7ze66fwQyBM0iJhyFDAfjhY7CpfQMxxFc19nPdG+5eVC1In47mnXiCfdWMhKEjZIxJBXrwj9Xvd80B8v/YpDb5NehyP0pxII3oZO5tZYq+mYGYwhs16bABljUYzwR5/Fa3IdDddCq1HIClap2mNs9UT+IiuBNyg== 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=Dg7zMAksRbS76WEHcxxsYZ+XN6eU5DjoVhFlBlFagOM=; b=FDYMz6iZkUSj6VbFf8v4qLUFNwjB2hiLOdMjiCkORZEDwktt819kXxgDL+WCUvZzafsPzz6gACI4V+IWDq6UWhNdXwebBsq0fk9erF7U0TFSlZXi1M1H7yMjO4FteTKEcJS5joKqJKx87wJZ5/UvLvitaVCoxBR5OubFrqlKPtg= Received: from BY3PR05CA0018.namprd05.prod.outlook.com (2603:10b6:a03:254::23) by PH0PR12MB7816.namprd12.prod.outlook.com (2603:10b6:510:28c::16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8943.28; Fri, 25 Jul 2025 18:31:40 +0000 Received: from SA2PEPF000015CA.namprd03.prod.outlook.com (2603:10b6:a03:254:cafe::8f) by BY3PR05CA0018.outlook.office365.com (2603:10b6:a03:254::23) with Microsoft SMTP Server (version=TLS1_3, cipher=TLS_AES_256_GCM_SHA384) id 15.20.8989.7 via Frontend Transport; Fri, 25 Jul 2025 18:31:40 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 165.204.84.17) smtp.mailfrom=amd.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=amd.com; Received-SPF: Pass (protection.outlook.com: domain of amd.com designates 165.204.84.17 as permitted sender) receiver=protection.outlook.com; client-ip=165.204.84.17; helo=SATLEXMB04.amd.com; pr=C Received: from SATLEXMB04.amd.com (165.204.84.17) by SA2PEPF000015CA.mail.protection.outlook.com (10.167.241.200) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.8964.20 via Frontend Transport; Fri, 25 Jul 2025 18:31:40 +0000 Received: from bmoger-ubuntu.amd.com (10.180.168.240) by SATLEXMB04.amd.com (10.181.40.145) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.39; Fri, 25 Jul 2025 13:31:38 -0500 From: Babu Moger To: , , , , , , , CC: , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , Subject: [PATCH v16 08/34] x86,fs/resctrl: Detect Assignable Bandwidth Monitoring feature details Date: Fri, 25 Jul 2025 13:29:27 -0500 Message-ID: X-Mailer: git-send-email 2.34.1 In-Reply-To: References: Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-ClientProxiedBy: SATLEXMB03.amd.com (10.181.40.144) To SATLEXMB04.amd.com (10.181.40.145) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: SA2PEPF000015CA:EE_|PH0PR12MB7816:EE_ X-MS-Office365-Filtering-Correlation-Id: 365e1640-24ae-44d3-074d-08ddcba97f76 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|7416014|376014|1800799024|82310400026|36860700013; X-Microsoft-Antispam-Message-Info: =?us-ascii?Q?XtwMyT6Tj831Ura5aXHHNFQ7Veul5cCG4yaUuEXqVl0mtWdA07HzLyX1byi+?= =?us-ascii?Q?upTxcg6a+cXHjFH8zSbRlhVpvVUbsW/5DDNKu+Tv1VTVsa11obWq9viq+5or?= =?us-ascii?Q?uCBdfCxDXOJMri3doq5zvAOL2OMAVATGVoe2C69fYx7WBeXS6y7vAXQKJ82D?= =?us-ascii?Q?lcODUFvG8t3phoerQbGxkcgCQ4I8KXLi7f0hM6ZebJ9eAMSrtJZwjSW3kodR?= =?us-ascii?Q?OvINmm8DDXZ+7Aqhx1kJALYvAeTMI0NKN+Ke4lSwTFbkKqPYWos5uHSwj6ci?= =?us-ascii?Q?cTJpQ1hkp48rLNM0FxfAeTrdgAHoMYCsFAcH9m5yzlc1eI5K+fO3nEM9rmYP?= =?us-ascii?Q?ybb2ug0V9LjTVrrIvSNHB9fXMhPChrcnMHAedHPagaH5UpNdpSM2GI/7dPhZ?= =?us-ascii?Q?ImjnN0xNl0xEqsav1WiXXghgh1soA+nzRseGlbyvAlHszfVN9Y8EZpvScwRC?= =?us-ascii?Q?dsDkPEHMh99ZibCNk0O4OhEhwga2dnuU0md1raJ/DIXiQ+MaHt80+koHu30t?= =?us-ascii?Q?/WFtL07ruwJZamh79C9uo/PwjdFpTaLpYihCbrTAFRGnmZUqL9ogjTLDvX+s?= =?us-ascii?Q?SiunYa86Q/6EJ+RsvA7hTvLUb4WkKl8a2Jj9VFe5ixYNHcs1GjSN0tlhQ0oS?= =?us-ascii?Q?NavuIUYb0+31MS6/OuWV2OlJ14S6yJFmnchPjPubhAcQNZjKmecdked85AEl?= =?us-ascii?Q?nut/s+2Y+GFvGXGyhCgvFtZ/KLcVBZ3RvNLkVePSGdYsu/s8q+rzg0TCFeXy?= =?us-ascii?Q?xstJZ557stykYzE2eHZDxhhKvR3O7Wyf1zBMCnpX4YgCAo9U9oGXS4ixOeFp?= =?us-ascii?Q?r209aHq285OqdkGBZ6GlnaKqLPd8dxIXTqU84zcVGbn2U/opArtFBrs2gjtP?= =?us-ascii?Q?N0ll6MOe+SK5L2CA0eG0jPhDjKJLal+dQ1o7s9EbKTU5stPLBBI/uts/5UWY?= =?us-ascii?Q?hsvklJvEsjxODfj9HvR2lzsWeO6GAOeP6bcsFikDC6v0+aDWLlLtCYYDeT0j?= =?us-ascii?Q?mNHZyMbHtaj8dy393PXZIO9Yvs0IqGwHIDkGGUh1HYwFtCWEokGjTIlf963i?= =?us-ascii?Q?Fv2SN64Jl+z1wGVZ3qdLDhXcQEpDPHF2mzxcjv2X4/3O9LaA5kTkOq2qemUT?= =?us-ascii?Q?n0fkddl/XjJiFPz6rX2Pkd6Xj6A+jncmzTZN2sxxIA4kJkC5bnUsr+OQY5e6?= =?us-ascii?Q?diSmh1PX+993HGXY2RoQLjLwZtEosZF4AdlzFpBggbocTOBfA2evYG0x+8/7?= =?us-ascii?Q?t72CNeXYZlTAawl7dRh3c+FDJHvlQ3ZHgb4acU5xqCgmdfSEE77eN4Lsz1bZ?= =?us-ascii?Q?dCIeOUlFF20bNFbl6z2E1baGSKCHwQazO2b0cdqixYoRsyYvLVfhqErRk3sg?= =?us-ascii?Q?b35JhAKHiotda9ijteYtSAkflkR1hkZX2AAuQMzpfKv07Srd+xgNFoY4pQsm?= =?us-ascii?Q?IGrk0yY+4wMwLPwROKzoWjgpM9dO7dr8j4pYPAoTiq8e5Ty0FPf5eEgIO2mi?= =?us-ascii?Q?Sx09T26fck84HTDVKq2nS8iVhwVH36HvPglavqN27FXXt0k62SIWXOwbDQ?= =?us-ascii?Q?=3D=3D?= X-Forefront-Antispam-Report: CIP:165.204.84.17;CTRY:US;LANG:en;SCL:1;SRV:;IPV:CAL;SFV:NSPM;H:SATLEXMB04.amd.com;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(13230040)(7416014)(376014)(1800799024)(82310400026)(36860700013);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 25 Jul 2025 18:31:40.4167 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 365e1640-24ae-44d3-074d-08ddcba97f76 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: SA2PEPF000015CA.namprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH0PR12MB7816 Content-Type: text/plain; charset="utf-8" ABMC feature details are reported via CPUID Fn8000_0020_EBX_x5. Bits Description 15:0 MAX_ABMC Maximum Supported Assignable Bandwidth Monitoring Counter ID + 1 The feature details are documented in APM listed below [1]. [1] AMD64 Architecture Programmer's Manual Volume 2: System Programming Publication # 24593 Revision 3.41 section 19.3.3.3 Assignable Bandwidth Monitoring (ABMC). Detect the feature and number of assignable counters supported. For backward compatibility, upon detecting the assignable counter feature, enable the mbm_total_bytes and mbm_local_bytes events that users are familiar with as part of original L3 MBM support. Link: https://bugzilla.kernel.org/show_bug.cgi?id=3D206537 Signed-off-by: Babu Moger --- v16: Added a new check in get_rdt_mon_resources(). Added a check resctrl_is_mon_event_enabled() before enabling. v15: Minor update to changelog. Added check in resctrl_cpu_detect(). Moved the resctrl_enable_mon_event() to resctrl_mon_resource_init(). v14: Updated enumeration to support ABMC regardless of MBM total and local = support. Updated the changelog accordingly. v13: No changes. v12: Resolved conflicts because of latest merge. Removed Reviewed-by as the patch has changed. v11: No changes. v10: No changes. v9: Added Reviewed-by tag. No code changes v8: Used GENMASK for the mask. v7: Removed WARN_ON for num_mbm_cntrs. Decided to dynamically allocate the bitmap. WARN_ON is not required anymore. Removed redundant comments. v6: Commit message update. Renamed abmc_capable to mbm_cntr_assignable. v5: Name change num_cntrs to num_mbm_cntrs. Moved abmc_capable to resctrl_mon. v4: Removed resctrl_arch_has_abmc(). Added all the code inline. We dont need to separate this as arch code. v3: Removed changes related to mon_features. Moved rdt_cpu_has to core.c and added new function resctrl_arch_has_abm= c. Also moved the fields mbm_assign_capable and mbm_assign_cntrs to rdt_resource. (James) v2: Changed the field name to mbm_assign_capable from abmc_capable. --- arch/x86/kernel/cpu/resctrl/core.c | 5 ++++- arch/x86/kernel/cpu/resctrl/monitor.c | 11 ++++++++--- fs/resctrl/monitor.c | 7 +++++++ include/linux/resctrl.h | 4 ++++ 4 files changed, 23 insertions(+), 4 deletions(-) diff --git a/arch/x86/kernel/cpu/resctrl/core.c b/arch/x86/kernel/cpu/resct= rl/core.c index 267e9206a999..09cb5a70b1cb 100644 --- a/arch/x86/kernel/cpu/resctrl/core.c +++ b/arch/x86/kernel/cpu/resctrl/core.c @@ -883,6 +883,8 @@ static __init bool get_rdt_mon_resources(void) resctrl_enable_mon_event(QOS_L3_MBM_LOCAL_EVENT_ID); ret =3D true; } + if (rdt_cpu_has(X86_FEATURE_ABMC)) + ret =3D true; =20 if (!ret) return false; @@ -990,7 +992,8 @@ void resctrl_cpu_detect(struct cpuinfo_x86 *c) =20 if (cpu_has(c, X86_FEATURE_CQM_OCCUP_LLC) || cpu_has(c, X86_FEATURE_CQM_MBM_TOTAL) || - cpu_has(c, X86_FEATURE_CQM_MBM_LOCAL)) { + cpu_has(c, X86_FEATURE_CQM_MBM_LOCAL) || + cpu_has(c, X86_FEATURE_ABMC)) { u32 eax, ebx, ecx, edx; =20 /* QoS sub-leaf, EAX=3D0Fh, ECX=3D1 */ diff --git a/arch/x86/kernel/cpu/resctrl/monitor.c b/arch/x86/kernel/cpu/re= sctrl/monitor.c index 2558b1bdef8b..0a695ce68f46 100644 --- a/arch/x86/kernel/cpu/resctrl/monitor.c +++ b/arch/x86/kernel/cpu/resctrl/monitor.c @@ -339,6 +339,7 @@ int __init rdt_get_mon_l3_config(struct rdt_resource *r) unsigned int mbm_offset =3D boot_cpu_data.x86_cache_mbm_width_offset; struct rdt_hw_resource *hw_res =3D resctrl_to_arch_res(r); unsigned int threshold; + u32 eax, ebx, ecx, edx; =20 snc_nodes_per_l3_cache =3D snc_get_config(); =20 @@ -368,14 +369,18 @@ int __init rdt_get_mon_l3_config(struct rdt_resource = *r) */ resctrl_rmid_realloc_threshold =3D resctrl_arch_round_mon_val(threshold); =20 - if (rdt_cpu_has(X86_FEATURE_BMEC)) { - u32 eax, ebx, ecx, edx; - + if (rdt_cpu_has(X86_FEATURE_BMEC) || rdt_cpu_has(X86_FEATURE_ABMC)) { /* Detect list of bandwidth sources that can be tracked */ cpuid_count(0x80000020, 3, &eax, &ebx, &ecx, &edx); r->mon.mbm_cfg_mask =3D ecx & MAX_EVT_CONFIG_BITS; } =20 + if (rdt_cpu_has(X86_FEATURE_ABMC)) { + r->mon.mbm_cntr_assignable =3D true; + cpuid_count(0x80000020, 5, &eax, &ebx, &ecx, &edx); + r->mon.num_mbm_cntrs =3D (ebx & GENMASK(15, 0)) + 1; + } + r->mon_capable =3D true; =20 return 0; diff --git a/fs/resctrl/monitor.c b/fs/resctrl/monitor.c index dcc6c00eb362..66c8c635f4b3 100644 --- a/fs/resctrl/monitor.c +++ b/fs/resctrl/monitor.c @@ -924,6 +924,13 @@ int resctrl_mon_resource_init(void) else if (resctrl_is_mon_event_enabled(QOS_L3_MBM_TOTAL_EVENT_ID)) mba_mbps_default_event =3D QOS_L3_MBM_TOTAL_EVENT_ID; =20 + if (r->mon.mbm_cntr_assignable) { + if (!resctrl_is_mon_event_enabled(QOS_L3_MBM_TOTAL_EVENT_ID)) + resctrl_enable_mon_event(QOS_L3_MBM_TOTAL_EVENT_ID); + if (!resctrl_is_mon_event_enabled(QOS_L3_MBM_LOCAL_EVENT_ID)) + resctrl_enable_mon_event(QOS_L3_MBM_LOCAL_EVENT_ID); + } + return 0; } =20 diff --git a/include/linux/resctrl.h b/include/linux/resctrl.h index fe2af6cb96d4..eb80cc233be4 100644 --- a/include/linux/resctrl.h +++ b/include/linux/resctrl.h @@ -260,10 +260,14 @@ enum resctrl_schema_fmt { * @num_rmid: Number of RMIDs available. * @mbm_cfg_mask: Memory transactions that can be tracked when bandwidth * monitoring events can be configured. + * @num_mbm_cntrs: Number of assignable counters. + * @mbm_cntr_assignable:Is system capable of supporting counter assignment? */ struct resctrl_mon { int num_rmid; unsigned int mbm_cfg_mask; + int num_mbm_cntrs; + bool mbm_cntr_assignable; }; =20 /** --=20 2.34.1 From nobody Mon Oct 6 01:21:11 2025 Received: from NAM10-BN7-obe.outbound.protection.outlook.com (mail-bn7nam10on2046.outbound.protection.outlook.com [40.107.92.46]) (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 9DDE824A07C; Fri, 25 Jul 2025 18:31:55 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.92.46 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1753468317; cv=fail; b=puPq6yBgAXb2annKYPZf7HXbp7PSV2FiPgry+9FwfPHknVcQFEM7rRyI9fImMlCF6UymYqTrYvLCk0SH7lrJIU5AOdGWL4plxq6deLCVxlRbKGWhhiyAuzq+ATAAq7JFp2znPSn4EgIFB2WwQBwKvSRJsPxw++CUvVL/aaZzyo8= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1753468317; c=relaxed/simple; bh=YOrVjL7APdbfJCezabMPX8AA1wQ/eNTRE5lSZ7BqMI8=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=t7CVuSTT73fo10pcdeucyGK2+22SXg/fj5JfAXWm6inWGuyFqZXzoIi8cmjQ55Y75HcZbv+La1bD4bg5GuUH8hjpi4JnVHRQFT3LAsDKxjlD5Rm89Ve8m78fxpEIO0luBQsH/+gWRBqUor6Pg5wSuTTaOEN/DBXvhOIOLuP59lY= 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=SEHDyiLZ; arc=fail smtp.client-ip=40.107.92.46 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="SEHDyiLZ" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=m19QW152UNcqOYeQK8CRKiOaZJlu7KCrhrFunmYRgUeaReJXdEnx/t3ffpT4pgUO88kSp6l47cO1Q+SGV5voPJKPXIasExq/dNlBhcOzuY3PXLdViUBuDPg/8zzvZK+gFOGtIXTJWR3geqJMQjngbO8ic8KjCFVGoI6EgrmrkrFgiftttn+Q5muhXOYwv7FvYanMF70i//OQHXwrh3k0PEASMVb/1dX2+8DyebGBewrbhMIzoQBcgsl4VdDZILUe1chYAloNbKM75QnXAekFJrc0mPyCU3M/qAAfu/49MjgYjgqhpQeIMzsFG6VImvCcjTERxOBV9NuBQHUJcV8Rmw== 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=7ShULnPgzSwOdOR3JWXQdn/VGd+EEHB5ztuon49d8p4=; b=Qj5yDdHT+5ZDcSv98Y4uSlWg1AFMNTBGSVv4bgq4Nt82YW0MksWRLDPu5K9MpRD7/Pd6IsKdQqIlJddwTOV7RcnEQFS7qydfm3pYPuxS6oWKL51kwTkB+JpPzCTjdmwMmEwNydUN+bpaMrbFHXVaSS42pACNied4LN48P1MvrC1tfMy6wueLtCVRnWutoiJzwfpbMD/JooI4gi+iiKCQpFhnA1pUjjLWjGKTqOXIiLe/8Ja2flOqw7B/nNR3SqI70uUR1DHfD5RSdJcioxtcADSPYTsLLAlE2xSD66FLcbKbjPNMsBgakANpQRmVDWUH4hBKPbA1Mnpounqa0XTtag== 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=7ShULnPgzSwOdOR3JWXQdn/VGd+EEHB5ztuon49d8p4=; b=SEHDyiLZb3EzA8siUi4QoOzDRj9J7yohg3HGRJhuV2x4J71eaOTPC4e+AHPi6IE+7KLzaWAbmpR1Cx0GhlwG39kAIi9QQBe06b905zSZmgSok1/i+G1iBlFdNm9HEm8b05s/4hAzqtyukrbOheh0iMV0cQAyYWJdB5MSrFzDa5I= Received: from SA0PR11CA0036.namprd11.prod.outlook.com (2603:10b6:806:d0::11) by MN0PR12MB5857.namprd12.prod.outlook.com (2603:10b6:208:378::10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8964.22; Fri, 25 Jul 2025 18:31:49 +0000 Received: from SA2PEPF000015CD.namprd03.prod.outlook.com (2603:10b6:806:d0:cafe::7c) by SA0PR11CA0036.outlook.office365.com (2603:10b6:806:d0::11) with Microsoft SMTP Server (version=TLS1_3, cipher=TLS_AES_256_GCM_SHA384) id 15.20.8964.21 via Frontend Transport; Fri, 25 Jul 2025 18:31:49 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 165.204.84.17) smtp.mailfrom=amd.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=amd.com; Received-SPF: Pass (protection.outlook.com: domain of amd.com designates 165.204.84.17 as permitted sender) receiver=protection.outlook.com; client-ip=165.204.84.17; helo=SATLEXMB04.amd.com; pr=C Received: from SATLEXMB04.amd.com (165.204.84.17) by SA2PEPF000015CD.mail.protection.outlook.com (10.167.241.203) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.8964.20 via Frontend Transport; Fri, 25 Jul 2025 18:31:49 +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; Fri, 25 Jul 2025 13:31:46 -0500 From: Babu Moger To: , , , , , , , CC: , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , Subject: [PATCH v16 09/34] x86/resctrl: Add support to enable/disable AMD ABMC feature Date: Fri, 25 Jul 2025 13:29:28 -0500 Message-ID: <0903bec452b28d99adf68ce168c64073fb9ef3de.1753467772.git.babu.moger@amd.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: References: Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-ClientProxiedBy: SATLEXMB03.amd.com (10.181.40.144) To SATLEXMB04.amd.com (10.181.40.145) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: SA2PEPF000015CD:EE_|MN0PR12MB5857:EE_ X-MS-Office365-Filtering-Correlation-Id: c945ceef-3029-4aa9-65dd-08ddcba984a1 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|376014|7416014|36860700013|82310400026|1800799024; X-Microsoft-Antispam-Message-Info: =?us-ascii?Q?mKR7xUCwt7KD9ek9sUmOyk6XhYjRaMd5oR6Ks6gaFyH9V+HYdMoPlYgY0n2O?= =?us-ascii?Q?Vn4BJd8Pt0jnF7eX463LlKNgV76XPuysxZTpnZQktOZAWyDimmaSIgNUdy8c?= =?us-ascii?Q?dleEOx3J8/ru2dYagKNgWbWKYxMR7LbkFJVdiJzODXYqP7B1Fok2gO7pS1QY?= =?us-ascii?Q?3hQ/ATUjKCsRkxQT0D7AByaHvEFEXqfxApgjDOBDSkDSSCfMEvya5qWNZ7j/?= =?us-ascii?Q?RXWThWnW1KNt6GAdDYHMPgkEhe+31nC5pij3+11q/5VIy7PgKYoVaVj222ZD?= =?us-ascii?Q?VB5KzDn9NUcKa1vXwTz2rpcw/geHbME40txNUx+zqmQLyh1QB2LU8bP862A1?= =?us-ascii?Q?JEQA61e74cnpeyM0EXyzdMOZMZZLtkB6U4OIJRMQBu+9MjUM+MKwtXnHT1wz?= =?us-ascii?Q?zQdHagsIsl4M7dlbIgVT2z8mNyMJSu5jGWAUhvMfuf7SuhvCF6moj06yJeha?= =?us-ascii?Q?QjhOvCFJpYudoUGZueMV6yjKTrbqAN0aQfQ+9nnfGlm9r5pq3WfQLqxvdQyM?= =?us-ascii?Q?aVFTQRtLMkbRDgEPf5CWy3hjoYPxUPTyEtXei3NUDYGsUgsYrfNDmAP7GtsN?= =?us-ascii?Q?zwQnPGio1U1Aju/oqacOyNqg7F5bJUffsEhGbx6J0+8jE/a0DimzOtxebHGQ?= =?us-ascii?Q?WK/UEARsRRnaNHie9oBEtudnfZRLZv7My/aA2CSGjHJoHn3VlQ/tFipQveZc?= =?us-ascii?Q?7dVp36RtCEXx/gjXSQrE3wNb499k83b8iD7Uggf/nnZnXqbqD3f1tGu2jtIt?= =?us-ascii?Q?G3ShlTyISGy9SY+mavUAmJrUWaMTrjnB4Voa579QMZ1HF1OKeiihhtygR+/y?= =?us-ascii?Q?0o0TundhSEX6G18760axebEXmRSHTMVqLTFxZ3DRsW4JQDQ67S+dNieRo76w?= =?us-ascii?Q?uxgNKQaB3Me8b+VtN9nKpo+AnTPvX8q4I7VOPWpsDp7HUwRlGVTE7Q7yR2B4?= =?us-ascii?Q?hWnIbVUC74N2DghH+ExKXlKXS4SJCSDgbdQWEx3TJmNKvesrA/WxUaz9S4ZP?= =?us-ascii?Q?Xcn0QwtUgFm2U3ycCVsawZLGV2YSYgVfIqzjU7/+c/COApx4EG/bCj2ElSar?= =?us-ascii?Q?zOqUU3g9anAOGaRrVKpEYTKzmOYE5BdJaRU9gY1xvjfz5ifTPQqTUpLSb+II?= =?us-ascii?Q?37c0Osf3bJ31RiNFItz/PckGaAoCzTDo993V5ZUyY0y8fI0J7GJtK9jVQVOh?= =?us-ascii?Q?1iz5Om5EGdsvSYUSgw0u7vqneOGu28lXNKpoZGF5fgEzT7jvP1f5VGlMOeBW?= =?us-ascii?Q?5j91VkXQj3Uw01Zwv1lSGumKZ+0DSvAZ06leVAGivz4xmoAp8UbSGltkxKG+?= =?us-ascii?Q?bNfkQSIdmWY6zEbTGa7cvCuLMREUkHJKZipqJAMBvmQf7rBQCwmMoaIST9do?= =?us-ascii?Q?9pc6Jk26/oNMXKcc/pMYe8aQhGbHjzpEBjxYXUzLotup4YDSq+ruiWHrxdDI?= =?us-ascii?Q?s7Nz7WsaThgy64b8LWy2wcrcV9dLmkBAPecM6I+tkzmVDnXlkw9evamqKd1n?= =?us-ascii?Q?9Ect7/IV2MC2GrnCIzlAgZrTwzAEwkEsmVsH6iTyAmP1LtfNCGFiyZVGow?= =?us-ascii?Q?=3D=3D?= X-Forefront-Antispam-Report: CIP:165.204.84.17;CTRY:US;LANG:en;SCL:1;SRV:;IPV:CAL;SFV:NSPM;H:SATLEXMB04.amd.com;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(13230040)(376014)(7416014)(36860700013)(82310400026)(1800799024);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 25 Jul 2025 18:31:49.0892 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: c945ceef-3029-4aa9-65dd-08ddcba984a1 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: SA2PEPF000015CD.namprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: MN0PR12MB5857 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 Reviewed-by: Reinette Chatre --- v16: Added Reviewed-by tag. v15: Minor comment change in resctrl.h. v14: Added lockdep_assert_cpus_held() in _resctrl_abmc_enable(). Removed inline for resctrl_arch_mbm_cntr_assign_enabled(). Added prototype descriptions for resctrl_arch_mbm_cntr_assign_enabled() and resctrl_arch_mbm_cntr_assign_set() in include/linux/resctrl.h. v13: Resolved minor conflicts with recent FS/ARCH restructure. v12: Clarified the comment on _resctrl_abmc_enable(). Added the code to reset arch state in _resctrl_abmc_enable(). Resolved the conflicts with latest merge. v11: Moved the monitoring related calls to monitor.c file. Moved the changes from include/linux/resctrl.h to arch/x86/kernel/cpu/resctrl/internal.h. Removed the Reviewed-by tag as patch changed. Actual code did not change. v10: No changes. v9: Re-ordered the MSR and added Reviewed-by tag. v8: Commit message update and moved around the comments about L3_QOS_EXT_CFG to _resctrl_abmc_enable. v7: Renamed the function resctrl_arch_get_abmc_enabled() to resctrl_arch_mbm_cntr_assign_enabled= (). Merged resctrl_arch_mbm_cntr_assign_disable, resctrl_arch_mbm_cntr_assi= gn_disable and renamed to resctrl_arch_mbm_cntr_assign_set(). Moved the function definition to linux/resctrl.h. Passed the struct rdt_resource to these functions. Removed resctrl_arch_reset_rmid_all() from arch code. This will be done from the caller. v6: Renamed abmc_enabled to mbm_cntr_assign_enabled. Used msr_set_bit and msr_clear_bit for msr updates. Renamed resctrl_arch_abmc_enable() to resctrl_arch_mbm_cntr_assign_enab= le(). Renamed resctrl_arch_abmc_disable() to resctrl_arch_mbm_cntr_assign_dis= able(). Made _resctrl_abmc_enable to return void. v5: Renamed resctrl_abmc_enable to resctrl_arch_abmc_enable. Renamed resctrl_abmc_disable to resctrl_arch_abmc_disable. Introduced resctrl_arch_get_abmc_enabled to get abmc state from non-arch code. Renamed resctrl_abmc_set_all to _resctrl_abmc_enable(). Modified commit log to make it clear about AMD ABMC feature. v3: No changes. v2: Few text changes in commit message. --- arch/x86/include/asm/msr-index.h | 1 + arch/x86/kernel/cpu/resctrl/internal.h | 5 +++ arch/x86/kernel/cpu/resctrl/monitor.c | 45 ++++++++++++++++++++++++++ include/linux/resctrl.h | 20 ++++++++++++ 4 files changed, 71 insertions(+) diff --git a/arch/x86/include/asm/msr-index.h b/arch/x86/include/asm/msr-in= dex.h index 7490bb5c0776..c998cf0e1375 100644 --- a/arch/x86/include/asm/msr-index.h +++ b/arch/x86/include/asm/msr-index.h @@ -1222,6 +1222,7 @@ /* - AMD: */ #define MSR_IA32_MBA_BW_BASE 0xc0000200 #define MSR_IA32_SMBA_BW_BASE 0xc0000280 +#define MSR_IA32_L3_QOS_EXT_CFG 0xc00003ff #define MSR_IA32_EVT_CFG_BASE 0xc0000400 =20 /* AMD-V MSRs */ diff --git a/arch/x86/kernel/cpu/resctrl/internal.h b/arch/x86/kernel/cpu/r= esctrl/internal.h index 58dca892a5df..a79a487e639c 100644 --- a/arch/x86/kernel/cpu/resctrl/internal.h +++ b/arch/x86/kernel/cpu/resctrl/internal.h @@ -37,6 +37,9 @@ struct arch_mbm_state { u64 prev_msr; }; =20 +/* Setting bit 0 in L3_QOS_EXT_CFG enables the ABMC feature. */ +#define ABMC_ENABLE_BIT 0 + /** * struct rdt_hw_ctrl_domain - Arch private attributes of a set of CPUs th= at share * a resource for a control function @@ -102,6 +105,7 @@ struct msr_param { * @mon_scale: cqm counter * mon_scale =3D occupancy in bytes * @mbm_width: Monitor width, to detect and correct for overflow. * @cdp_enabled: CDP state of this resource + * @mbm_cntr_assign_enabled: ABMC feature is enabled * * Members of this structure are either private to the architecture * e.g. mbm_width, or accessed via helpers that provide abstraction. e.g. @@ -115,6 +119,7 @@ struct rdt_hw_resource { unsigned int mon_scale; unsigned int mbm_width; bool cdp_enabled; + bool mbm_cntr_assign_enabled; }; =20 static inline struct rdt_hw_resource *resctrl_to_arch_res(struct rdt_resou= rce *r) diff --git a/arch/x86/kernel/cpu/resctrl/monitor.c b/arch/x86/kernel/cpu/re= sctrl/monitor.c index 0a695ce68f46..cce35a0ad455 100644 --- a/arch/x86/kernel/cpu/resctrl/monitor.c +++ b/arch/x86/kernel/cpu/resctrl/monitor.c @@ -399,3 +399,48 @@ void __init intel_rdt_mbm_apply_quirk(void) mbm_cf_rmidthreshold =3D mbm_cf_table[cf_index].rmidthreshold; mbm_cf =3D mbm_cf_table[cf_index].cf; } + +static void resctrl_abmc_set_one_amd(void *arg) +{ + bool *enable =3D arg; + + if (*enable) + msr_set_bit(MSR_IA32_L3_QOS_EXT_CFG, ABMC_ENABLE_BIT); + else + msr_clear_bit(MSR_IA32_L3_QOS_EXT_CFG, ABMC_ENABLE_BIT); +} + +/* + * ABMC enable/disable requires update of L3_QOS_EXT_CFG MSR on all the CP= Us + * associated with all monitor domains. + */ +static void _resctrl_abmc_enable(struct rdt_resource *r, bool enable) +{ + struct rdt_mon_domain *d; + + lockdep_assert_cpus_held(); + + list_for_each_entry(d, &r->mon_domains, hdr.list) { + on_each_cpu_mask(&d->hdr.cpu_mask, resctrl_abmc_set_one_amd, + &enable, 1); + resctrl_arch_reset_rmid_all(r, d); + } +} + +int resctrl_arch_mbm_cntr_assign_set(struct rdt_resource *r, bool enable) +{ + struct rdt_hw_resource *hw_res =3D resctrl_to_arch_res(r); + + if (r->mon.mbm_cntr_assignable && + hw_res->mbm_cntr_assign_enabled !=3D enable) { + _resctrl_abmc_enable(r, enable); + hw_res->mbm_cntr_assign_enabled =3D enable; + } + + return 0; +} + +bool resctrl_arch_mbm_cntr_assign_enabled(struct rdt_resource *r) +{ + return resctrl_to_arch_res(r)->mbm_cntr_assign_enabled; +} diff --git a/include/linux/resctrl.h b/include/linux/resctrl.h index eb80cc233be4..919806122c50 100644 --- a/include/linux/resctrl.h +++ b/include/linux/resctrl.h @@ -445,6 +445,26 @@ static inline u32 resctrl_get_config_index(u32 closid, bool resctrl_arch_get_cdp_enabled(enum resctrl_res_level l); int resctrl_arch_set_cdp_enabled(enum resctrl_res_level l, bool enable); =20 +/** + * resctrl_arch_mbm_cntr_assign_enabled() - Check if MBM counter assignment + * mode is enabled. + * @r: Pointer to the resource structure. + * + * Return: + * true if the assignment mode is enabled, false otherwise. + */ +bool resctrl_arch_mbm_cntr_assign_enabled(struct rdt_resource *r); + +/** + * resctrl_arch_mbm_cntr_assign_set() - Configure the MBM counter assignme= nt mode. + * @r: Pointer to the resource structure. + * @enable: Set to true to enable, false to disable the assignment mode. + * + * Return: + * 0 on success, < 0 on error. + */ +int resctrl_arch_mbm_cntr_assign_set(struct rdt_resource *r, bool enable); + /* * Update the ctrl_val and apply this config right now. * Must be called on one of the domain's CPUs. --=20 2.34.1 From nobody Mon Oct 6 01:21:11 2025 Received: from NAM12-MW2-obe.outbound.protection.outlook.com (mail-mw2nam12on2082.outbound.protection.outlook.com [40.107.244.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 073EE24A07C; Fri, 25 Jul 2025 18:32:03 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.244.82 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1753468325; cv=fail; b=DgPrBxlQthbyWQBLFCPNcKmC7Lx4eQt/fMGrRLL3//N0DCiUhdkp+90Jt1xy0OXrSFX39vcYMSTgW1KCTjsRwjMZ2pqhzV9vaTsEioKX9o3qjAL/lMhqRTZI+lLoOjY3emS28lqHviRD51t6/5r/JaVP0B0+5Wz3pTXWRVjeOB0= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1753468325; c=relaxed/simple; bh=9YHSUEduIwImw+qDWC83mHKXtrpEE3Wez9P6AvR7ZCY=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=k6lZ3SWUPXzK5yncR5HoR5kkXOJOCCpq3+WkDuRQe6klP4TMiGx7fCGs6+OnOvTJaABsU9Tw4INz/htDQTJMHneDUaW4tI9tq2KX1biYwMpjhnrJB+5DrdeyH0ydgXtCFfxLIhqSc6VNbAm1k9MX8xwxK1AG+TQhlXIXexub0Vo= 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=tfuXClpH; arc=fail smtp.client-ip=40.107.244.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="tfuXClpH" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=qlmIjAzVbK+ZDz0nC7qG6MvK60HpzwL+OYSjlUSeYW/E1ZXfURSu2APfNfnq3/onQbIjby108j1LSkyWwWi0f9czGwWGOj8lgxoivHvVnxYmb7qt1t9g6DBpUp6mBrVo5mwaFfdu9J4RSWLpYSuG295aq7hfj0lxW571sDOihRv5rIic8QWfCiStXMRlaqy4k+dLqBtsnCWXQKA4MXzr65r26yZVRGedSJTrf70REwEZcngMG/n0p12wk4Ua/7CffI/izjIbSMyML39Dpn8LnLceNkEF5nZ127KlH5drSjFTvANxqRdCqXvcIQzwcKw9mlMhgE7THH4iiiLLU9uPLw== 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=dSU4nIE6NyXnbk0oJSyiiisBN6Onx4mPsvHle4eYynU=; b=ZSIzGk/5rbyZML9C/VmSZU4KG3UnGPnQSPkefcKgf++qmTF51q+gbVVPVOzHIS3BTB6J1iJVmvuLBbfH55HEyGaLhgzXwlYMqkxPohSyelN/j+ZYMZG8s6g/GJQZi/T0+vwJP++zPFzh+zzsql891usWKiBeV33m8cosA8DpavsYs1eG/X0+LFamfEda5C+wVe4ngvG1fdOxx2/P26QT8uxb2Xmr01XW/jvrC6Uitj+laGSDtdl1cAIkyLFwZy5+fXAUDumUG/PjHezISOx/97bOwZ7G/TbvWTgPeA3okFJqpq6cuQnFkhkIQJbQC193E2vix933MmmokxI24nO1Qg== 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=dSU4nIE6NyXnbk0oJSyiiisBN6Onx4mPsvHle4eYynU=; b=tfuXClpHhF7wQC0B1ji0DErcj3tJUKVRHfwLiVfEtHEl+erBeOthW3FIhh1hYTczMDCeT48bYs1+Gu6pT+3N/H00u+FQzORA1EbFRaSTXEPRh8MWwVJGAD2KAViCtNsjUuOL6tJg7C8uhqHQ3gDVjO6UTi4y63aAUyaipCCQOTU= Received: from SA1P222CA0168.NAMP222.PROD.OUTLOOK.COM (2603:10b6:806:3c3::14) by IA0PR12MB8715.namprd12.prod.outlook.com (2603:10b6:208:487::16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8964.23; Fri, 25 Jul 2025 18:32:00 +0000 Received: from SA2PEPF000015C8.namprd03.prod.outlook.com (2603:10b6:806:3c3:cafe::50) by SA1P222CA0168.outlook.office365.com (2603:10b6:806:3c3::14) with Microsoft SMTP Server (version=TLS1_3, cipher=TLS_AES_256_GCM_SHA384) id 15.20.8964.24 via Frontend Transport; Fri, 25 Jul 2025 18:32:00 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 165.204.84.17) smtp.mailfrom=amd.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=amd.com; Received-SPF: Pass (protection.outlook.com: domain of amd.com designates 165.204.84.17 as permitted sender) receiver=protection.outlook.com; client-ip=165.204.84.17; helo=SATLEXMB04.amd.com; pr=C Received: from SATLEXMB04.amd.com (165.204.84.17) by SA2PEPF000015C8.mail.protection.outlook.com (10.167.241.198) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.8964.20 via Frontend Transport; Fri, 25 Jul 2025 18:32:00 +0000 Received: from bmoger-ubuntu.amd.com (10.180.168.240) by SATLEXMB04.amd.com (10.181.40.145) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.39; Fri, 25 Jul 2025 13:31:55 -0500 From: Babu Moger To: , , , , , , , CC: , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , Subject: [PATCH v16 10/34] fs/resctrl: Introduce the interface to display monitoring modes Date: Fri, 25 Jul 2025 13:29:29 -0500 Message-ID: X-Mailer: git-send-email 2.34.1 In-Reply-To: References: Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-ClientProxiedBy: SATLEXMB03.amd.com (10.181.40.144) To SATLEXMB04.amd.com (10.181.40.145) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: SA2PEPF000015C8:EE_|IA0PR12MB8715:EE_ X-MS-Office365-Filtering-Correlation-Id: ac155b99-9dae-4989-6fdf-08ddcba98b70 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?TwEpSECy+m90W3QbG5i84DC5VSwS/BZQ3M1rkg0iA0yHR5Yq4lolIEs/4jey?= =?us-ascii?Q?Y3HBK1YjgH5a+o04JhwmE2mqoIYARW4Z//yI5FYPj4mXGEjRlJ4b+9iyT2sR?= =?us-ascii?Q?I/DtLEFD1NUFzu+97RDr1m8cwkxzxQhvoQb+oLWTkY6fOqxDXkDfTOKOoM4x?= =?us-ascii?Q?zyRoJJXNU0iZVPNSnFnVMe+r6A+qn3YWCks3r9LsdpX9AjKG0kTGtf+VFutJ?= =?us-ascii?Q?8XyDLJO8b6iKsW9QOaUBDhOw3+WMI3hNy2CW/ggmqyGSqbbo+XOXPjXSFHpq?= =?us-ascii?Q?D3HeSITIYIy709Ah0xboWn87dG6zVe7cpVwBZEKZQ///BUhPRQLdFjZ6nfe7?= =?us-ascii?Q?IO9t2J6gsd+cpHeq+5wxVJKuyQbhL/xQLdpegWLqKKQq1xbqXp532PrzNbVF?= =?us-ascii?Q?IlSiyUEJm1NCSIVhXJGP4Ffvtt3Mrj66Q5cF7EluFcwGzzB5Voxv7PqyAYXb?= =?us-ascii?Q?DFxz72DwioELzVLe+ZydAnquHo6hkD8NVNbxcUHhgL7NblG82p8cP8qZF6ns?= =?us-ascii?Q?yH14+FQeywzRT8nhXIGRuEyKyyOqUU36wS1YFByrKletjJlyQM4HR4iNkqHv?= =?us-ascii?Q?1tG+2eux0ETq/Ik5eU4at0QNwgJ6+OwVkLaWa1+dAweP3Y71o0twMU2y7ZIu?= =?us-ascii?Q?kbeEa+Urabos8hGmcaSivJKE2J1tnmCDr9e02LW1Rb7UTf5Rpd7/nHM3CShS?= =?us-ascii?Q?jB25zu3cGOH4LQFV4LFGNcjR7lZKnrERopymOrMcvkmWt1sXdKX9jpv6+ZKd?= =?us-ascii?Q?054TZE/dY5e+bicItzhbKvZwN6NgeJACHP78NqLAreyp0UgxHCyigJHJVGoc?= =?us-ascii?Q?iLrXGhWIu2cwvG7GVV82JSDcUeKiVG0ECSiOvSV2CKGLNKwpT7C1hx9fWHCv?= =?us-ascii?Q?U+ytJDngpDrnY3uHLf1Qu2+FjnqN0NEDkHAQIjUOcH/Mc59Jz+Kg9/3rGPi6?= =?us-ascii?Q?w3bv1wAEntQwzrULqXkE+J3KcvONwevaT1ODsJG4BKL3Bd1i09x5pEFZfrjM?= =?us-ascii?Q?7/fEHnRCJFp3uKSbDGBikDZ0MF8PQmzJgHSzjRYgrgoY4lgf8r2Al8dZXflI?= =?us-ascii?Q?0kN81LtG7tqptUTgerscG4PYtiTuIoeXubjAy8rrXak2/2BRCegnV8eBkp23?= =?us-ascii?Q?Bb+B+8REC/dtTxMABPWpMmfAm/oxP2Y3bStFrHySYZj65SgLGm1H3n1grMqe?= =?us-ascii?Q?i03Z42P4GrAkHvkuhVvwc86G/LoVt1gO7V6GYEA6DZ8DVZgtaayiEvWJ/yAH?= =?us-ascii?Q?CBBcJ1NeamYosLz3Mahw5suFeiVb6PXL+8/9l+h+7K+qH0WEQNBIeh+rEI4Q?= =?us-ascii?Q?EKG42R7s76LVAN9AIP9puVp0GcifzcSiI/Gv221jUiWHM3Fl9JYy8JwR6oyC?= =?us-ascii?Q?txlJOAoX2kxLuXPQDHrdk+TXfYcQ+Edq3ynlhoBWyxm0uvX09Q59JISPboeJ?= =?us-ascii?Q?GZYOZ+t0LjMoA0/kMFPc3LsXj1xGLh4nq4R2pNDwAtgm0dMr98xsmRUbGRuH?= =?us-ascii?Q?zjEMQlqklvTDVyhIxb+0N7WkoC0rBxSOFEczgl1w3z3ZTEi7SgtGWXOC7w?= =?us-ascii?Q?=3D=3D?= X-Forefront-Antispam-Report: CIP:165.204.84.17;CTRY:US;LANG:en;SCL:1;SRV:;IPV:CAL;SFV:NSPM;H:SATLEXMB04.amd.com;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(13230040)(1800799024)(36860700013)(376014)(7416014)(82310400026);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 25 Jul 2025 18:32:00.5137 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: ac155b99-9dae-4989-6fdf-08ddcba98b70 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: SA2PEPF000015C8.namprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: IA0PR12MB8715 Content-Type: text/plain; charset="utf-8" Introduce the resctrl file "mbm_assign_mode" to list the supported counter assignment modes. The "mbm_event" counter assignment mode allows users to assign a hardware counter to an RMID, event pair and monitor bandwidth usage as long as it is assigned. The hardware continues to track the assigned counter until it is explicitly unassigned by the user. Each event within a resctrl group can be assigned independently in this mode. On AMD systems "mbm_event" mode is backed by the ABMC (Assignable Bandwidth Monitoring Counters) hardware feature and is enabled by default. The "default" mode is the existing 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 modes on the system. $ cat /sys/fs/resctrl/info/L3_MON/mbm_assign_mode [mbm_event] default Add IS_ENABLED(CONFIG_RESCTRL_ASSIGN_FIXED) check to support Arm64. On x86, CONFIG_RESCTRL_ASSIGN_FIXED is not defined. On Arm64, it will be defined when the "mbm_event" mode is supported. Add IS_ENABLED(CONFIG_RESCTRL_ASSIGN_FIXED) check early to ensure the user interface remains compatible with upcoming Arm64 support. IS_ENABLED() safely evaluates to 0 when the configuration is not defined. As a result, for MPAM, the display would be either: [default] or [mbm_event] Signed-off-by: Babu Moger Reviewed-by: Reinette Chatre --- v16: Update with Reviewed-by tag. v15: Minor text changes in changelog and resctrl.rst. v14: Changed the name of the monitor mode to mbm_cntr_evt_assign based on t= he discussion. https://lore.kernel.org/lkml/7628cec8-5914-4895-8289-027e7821777e@amd.= com/ Changed the name of the mbm_assign_mode's. Updated resctrl.rst for mbm_event mode. Changed subject line to fs/resctrl. v13: Updated the commit log with motivation for adding CONFIG_RESCTRL_ASSIG= N_FIXED. Added fflag RFTYPE_RES_CACHE for mbm_assign_mode file. Updated user doc. Removed the references to "mbm_assign_control". Resolved the conflicts with latest FS/ARCH code restructure. v12: Minor text update in change log and user documentation. Added the check CONFIG_RESCTRL_ASSIGN_FIXED to take care of arm platfo= rms. This will be defined only in arm and not in x86. v11: Renamed rdtgroup_mbm_assign_mode_show() to resctrl_mbm_assign_mode_sho= w(). Removed few texts in resctrl.rst about AMD specific information. Updated few texts. v10: Added few more text to user documentation clarify on the default mode. v9: Updated user documentation based on comments. v8: Commit message update. v7: Updated the descriptions/commit log in resctrl.rst to generic text. Thanks to James and Reinette. Rename mbm_mode to mbm_assign_mode. Introduced mutex lock in rdtgroup_mbm_mode_show(). v6: Added documentation for mbm_cntr_assign and legacy mode. Moved mbm_mode fflags initialization to static initialization. v5: Changed interface name to mbm_mode. It will be always available even if ABMC feature is not supported. Added description in resctrl.rst about ABMC mode. Fixed display abmc and legacy consistantly. v4: Fixed the checks for legacy and abmc mode. Default it ABMC. v3: New patch to display ABMC capability. --- Documentation/filesystems/resctrl.rst | 31 ++++++++++++++++++++++ fs/resctrl/rdtgroup.c | 37 +++++++++++++++++++++++++++ 2 files changed, 68 insertions(+) diff --git a/Documentation/filesystems/resctrl.rst b/Documentation/filesyst= ems/resctrl.rst index c97fd77a107d..b692829fec5f 100644 --- a/Documentation/filesystems/resctrl.rst +++ b/Documentation/filesystems/resctrl.rst @@ -257,6 +257,37 @@ 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": + The supported counter assignment modes. The enclosed brackets indicate wh= ich mode + is enabled. + :: + + # cat /sys/fs/resctrl/info/L3_MON/mbm_assign_mode + [mbm_event] + default + + "mbm_event": + + mbm_event mode allows users to assign a hardware counter to an RMID, event + pair and monitor the bandwidth usage as long as it is assigned. The hardw= are + continues to track the assigned counter until it is explicitly unassigned= by + the user. Each event within a resctrl group can be assigned independently. + + In this mode, a monitoring event can only accumulate data while it is bac= ked + by a hardware counter. Use "mbm_L3_assignments" found in each CTRL_MON an= d MON + group to specify which of the events should have a counter assigned. The = number + of counters available is described in the "num_mbm_cntrs" file. Changing = the + mode may cause all counters on the resource to reset. + + "default": + + In default mode, resctrl assumes there is a hardware counter for each + event within every CTRL_MON and MON group. On AMD platforms, it is + recommended to use the mbm_event mode, if supported, to prevent reset of = MBM + events between reads resulting from hardware re-allocating counters. This= can + result in misleading values or display "Unavailable" if no counter is ass= igned + to the event. + "max_threshold_occupancy": Read/write file provides the largest value (in bytes) at which a previously used LLC_occupancy diff --git a/fs/resctrl/rdtgroup.c b/fs/resctrl/rdtgroup.c index ca0475b75390..c7ca9113a12a 100644 --- a/fs/resctrl/rdtgroup.c +++ b/fs/resctrl/rdtgroup.c @@ -1799,6 +1799,36 @@ static ssize_t mbm_local_bytes_config_write(struct k= ernfs_open_file *of, return ret ?: nbytes; } =20 +static int resctrl_mbm_assign_mode_show(struct kernfs_open_file *of, + struct seq_file *s, void *v) +{ + struct rdt_resource *r =3D rdt_kn_parent_priv(of->kn); + bool enabled; + + mutex_lock(&rdtgroup_mutex); + enabled =3D resctrl_arch_mbm_cntr_assign_enabled(r); + + if (r->mon.mbm_cntr_assignable) { + if (enabled) + seq_puts(s, "[mbm_event]\n"); + else + seq_puts(s, "[default]\n"); + + if (!IS_ENABLED(CONFIG_RESCTRL_ASSIGN_FIXED)) { + if (enabled) + seq_puts(s, "default\n"); + else + seq_puts(s, "mbm_event\n"); + } + } else { + seq_puts(s, "[default]\n"); + } + + mutex_unlock(&rdtgroup_mutex); + + return 0; +} + /* rdtgroup information files for one cache resource. */ static struct rftype res_common_files[] =3D { { @@ -1911,6 +1941,13 @@ static struct rftype res_common_files[] =3D { .seq_show =3D mbm_local_bytes_config_show, .write =3D mbm_local_bytes_config_write, }, + { + .name =3D "mbm_assign_mode", + .mode =3D 0444, + .kf_ops =3D &rdtgroup_kf_single_ops, + .seq_show =3D resctrl_mbm_assign_mode_show, + .fflags =3D RFTYPE_MON_INFO | RFTYPE_RES_CACHE, + }, { .name =3D "cpus", .mode =3D 0644, --=20 2.34.1 From nobody Mon Oct 6 01:21:11 2025 Received: from NAM11-CO1-obe.outbound.protection.outlook.com (mail-co1nam11on2086.outbound.protection.outlook.com [40.107.220.86]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id BE49824A07C; Fri, 25 Jul 2025 18:32:12 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.220.86 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1753468334; cv=fail; b=ESnOodWMaHIP+FaeFMYO2GtcK2bcHB0Z1/pp9hTT23mVQaZ8TkXNspdOQYAakEzyueKYqO7/nZku25aU/fNENRQMMP3a6Wdob/flotEb8kPobQAIFU4tlha15UgnSsDQqfYScK1ECUgXE3e2eP9Bw377h0gNK+W1C6AMa8gIlak= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1753468334; c=relaxed/simple; bh=fzzC/NEf3swrC1CGBjn5epmhlUCmEux49UloIKmPnM0=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=PgfmvDMyk09w5NZ727nnicF2ALWWPzp/FKd5eylSzQ2WyQN0IH3d02jt3BdtH6kO0jDOpdQXVjcybb7Aea+WXPD5uKwXIIXrbkdbOFReTII2gsgAE+q/6A33te2ADc8ND7Hnff2+fkv98BVbltIKRNSquXFK3WqMZ1FnciCA6K4= 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=YbuoaD+X; arc=fail smtp.client-ip=40.107.220.86 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=amd.com Authentication-Results: smtp.subspace.kernel.org; spf=fail smtp.mailfrom=amd.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=amd.com header.i=@amd.com header.b="YbuoaD+X" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=L8/BJF/E27Xsfj/MEPpE7i21jNrjsqBGziobkMGEmCrtiL9JObnNnUkloMCbu+looUItLM4kFlXrjrJRCZqi35dx3l8CYuli5bG93mXnRB/r12sJA2Zm+AUY5sHki1xDw3+srUKoWC9aUQ8udd1WV9D1hG8omVDPHSndL9eR7WuKvdEju0tEF7ny1OwYX37UeijmH2lRyPb7r5i4iJcAa6Es4Qa39Bt8Is5JzOa8025tL2lanS+wvlSQIUfUtFtGwQFNzzhZ/ksDaRSBHCatAjgWqn645Guo5eZ6lmEJUb5aVkLPh8kkVOg3W0fXfE5xIP+kQmIzaVNy9uQF3wwscQ== 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=wrGXLFenwx8KsMTHO1AZBAzxA2JWkVPR4NJaJnmZylo=; b=okC/Pd8owIBfukMsjFdKqypmWxI3X+k+KkfmrMvrvqvGv4pQtaJkbDegMRbUFgB3z+UVLO022gw0DeCxJmSDbMu2Zy7C+qGxP2oKWJqcWO3Rd33tjkuuZGbgfJwP9eB3/ywGMzkhYDV23rTH7FKjcKNWoQT1m1qkFK2Ugkg29Z+KQYHRaDmgDYw8IFTDcHNnenAMNcH8/HSvGroXMqRcE7wrj3SwAo2eb7pC8zj24Jtm2thtkjWNeMEMFzvUEktC1MCoQrjzMO1KAi5mBEh6nhF+j78B1vEj3ykeyLNMULFKxKLcbEm/3C1b4nfDbaAb9N+HfryFNC419JZ8UKcxuA== 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=wrGXLFenwx8KsMTHO1AZBAzxA2JWkVPR4NJaJnmZylo=; b=YbuoaD+X/7tyE//2R4CzTP6Hbq6RgkYde/jZTJuZVU1206HNEPLfAgyhrnvjguQxa8n25jrPsQ6WpyyFYKPdWDc8rknXk/poMKkQDp10Pyr48t/HDhhEwUKto97fud9WIlrXqMeCsZXkwv6bd331HhA4xA2o2Crx2fvMggZl0n8= Received: from SA1P222CA0160.NAMP222.PROD.OUTLOOK.COM (2603:10b6:806:3c3::6) by LV2PR12MB5918.namprd12.prod.outlook.com (2603:10b6:408:174::21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8964.21; Fri, 25 Jul 2025 18:32:09 +0000 Received: from SA2PEPF000015C8.namprd03.prod.outlook.com (2603:10b6:806:3c3:cafe::e0) by SA1P222CA0160.outlook.office365.com (2603:10b6:806:3c3::6) with Microsoft SMTP Server (version=TLS1_3, cipher=TLS_AES_256_GCM_SHA384) id 15.20.8964.24 via Frontend Transport; Fri, 25 Jul 2025 18:32:09 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 165.204.84.17) smtp.mailfrom=amd.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=amd.com; Received-SPF: Pass (protection.outlook.com: domain of amd.com designates 165.204.84.17 as permitted sender) receiver=protection.outlook.com; client-ip=165.204.84.17; helo=SATLEXMB04.amd.com; pr=C Received: from SATLEXMB04.amd.com (165.204.84.17) by SA2PEPF000015C8.mail.protection.outlook.com (10.167.241.198) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.8964.20 via Frontend Transport; Fri, 25 Jul 2025 18:32:09 +0000 Received: from bmoger-ubuntu.amd.com (10.180.168.240) by SATLEXMB04.amd.com (10.181.40.145) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.39; Fri, 25 Jul 2025 13:32:04 -0500 From: Babu Moger To: , , , , , , , CC: , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , Subject: [PATCH v16 11/34] fs/resctrl: Add resctrl file to display number of assignable counters Date: Fri, 25 Jul 2025 13:29:30 -0500 Message-ID: X-Mailer: git-send-email 2.34.1 In-Reply-To: References: Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-ClientProxiedBy: SATLEXMB03.amd.com (10.181.40.144) To SATLEXMB04.amd.com (10.181.40.145) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: SA2PEPF000015C8:EE_|LV2PR12MB5918:EE_ X-MS-Office365-Filtering-Correlation-Id: 3c1bfaca-db1d-49d4-5331-08ddcba99099 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|36860700013|7416014|1800799024|376014|82310400026; X-Microsoft-Antispam-Message-Info: =?us-ascii?Q?pGrbJGHRjROc/XYXqm0J22JAcpI7IFS5KAuNi7nqPxuLuniAmoOTg/Y4ajMR?= =?us-ascii?Q?vwr8TEbDaL8nb8eFJukhUVZNNVj/DbFU+NcXoZwK48e4Ds9Ry35l0l6ZgKHv?= =?us-ascii?Q?3smqDEm+1MoF5aVH0lCW8ZT/3rLRvBA4GVlv9AT/FGpX45GxJxzpufj6+Jxa?= =?us-ascii?Q?HRxWKocK4Tyht++hLZzBM+quS/t/Oj5uVP2Eup0qZXS/I30cezbbEmTTl3iQ?= =?us-ascii?Q?6JskfKxxQFCXHSCfJZc5Uz+q6DAJr7nirzCgmch6KNqT6YInuSmkGq0xYqWk?= =?us-ascii?Q?3psuUHtJ8pVJ0asgkNzlAbqmdGMtFNs60NfK3XMp/5UKXJj3NEygVHfIC528?= =?us-ascii?Q?ACQoq5x5K1V1IuHL4zdQTGIGCBPF8bEPX9zNXMypsxzZOGbh//jMXQO7oCxj?= =?us-ascii?Q?FFXDkTY6J9dZ6bW0czq4nqB2YyB+R1tTVEFCjLDsPXX8JvPX2uPHswehKeaD?= =?us-ascii?Q?kin33dxkIb8F2NM8lI9weI8td7zklSkyUmHOdQlAQip4HwYEDM26JNf80OIJ?= =?us-ascii?Q?8z/9DfFo3pToVzce/h2kWd2UrLsLH2MX8MZW077pGOINWFdQ2ZAdWo9Qkb26?= =?us-ascii?Q?KCX+36YgVejCgkfKNK0lGAT/IrbZyowYp6lpYZY5AKoFhHTziZSgcv6ANXJw?= =?us-ascii?Q?L7WFT4PCNI9Xe/2i3JdM9WEco8zVavVY0PNcX/cOFVBJpkfwNf8w4B/CE9X+?= =?us-ascii?Q?DP6Mxsqk3Ogl5+RsVbJIR0qtzyWEXqb+v3Z0OYgXfWnE7nagp9k/Mk/732qu?= =?us-ascii?Q?8YnfDNs5VZC0plV2J4bHMAsXiXEHxPNXG5yFB0H47iIY7vXn8C4EfvE0E89A?= =?us-ascii?Q?KiqIhmZ6EY2GqRrsbRu3sw6wcEKVE2AajsXe1ZQWCgqQKeGLhhl7VOl2z3nB?= =?us-ascii?Q?1I2uT5U1aSCKBnp/RWJS/0FkVGe+07Wr7P57bzeYIEjvBb2CIsc++EjQonoY?= =?us-ascii?Q?l0Jn2xNuSNTAbEruz7Rr/EXXi9zhOkpirJo8rep8hHfwVfD+xDmz0vQ02G87?= =?us-ascii?Q?1FjVrSA7tbvZcTwYZ0/SAhGvFdaz8LD2JQS3xsAgA312D27bisxjiGkTQxh3?= =?us-ascii?Q?Ubw7NX2gCEGpMjlm3URxjogawkvkfLEmGrsRACgaOfPxzWOSOC6aUSOJfAcZ?= =?us-ascii?Q?u+8guMsfOC4+fFdgPQqbOvw3e99VyLbPDSCmNbVdDsDfGtZxyPZAAZWrFPrs?= =?us-ascii?Q?boN8dbHuvYAajZ7VQjLGLIHOmkJC+oiApRbKp2XHXjOLxEXu7qhtWXw25eLf?= =?us-ascii?Q?ass9nCSXb9ZV0yYN7Qbho0H/YxmPtwaTgzH0FE+gYSckkqBeeY+RSAdP83A3?= =?us-ascii?Q?GFYIqNoMVumLBC1oA1S7QNdrbG9HPWh/qgE9z3+3rbh1gLAn1TXzHjmMtY0U?= =?us-ascii?Q?+aDqA1wYrqd80toXtn2xnct+G+VbUJF4Wg0JbLlH3j3IzedPnlBK1w3+Cq5v?= =?us-ascii?Q?zGrVEEF8/drZzNOG+G3e1KT/i7vtVIVDR7g2NiAeb0uDwMRbBDKj7l/9oUnw?= =?us-ascii?Q?pUqhHVPHuoURxkFdD2/JLbosYcd7peCgLKsP?= 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)(7416014)(1800799024)(376014)(82310400026);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 25 Jul 2025 18:32:09.1683 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 3c1bfaca-db1d-49d4-5331-08ddcba99099 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: SA2PEPF000015C8.namprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: LV2PR12MB5918 Content-Type: text/plain; charset="utf-8" The "mbm_event" counter assignment mode allows users to assign a hardware counter to an RMID, event pair and monitor bandwidth usage as long as it is assigned. The hardware continues to track the assigned counter until it is explicitly unassigned by the user. Create 'num_mbm_cntrs' resctrl file that displays the number of counters supported in each domain. 'num_mbm_cntrs' is only visible to user space when the system supports "mbm_event" mode. Signed-off-by: Babu Moger Reviewed-by: Reinette Chatre --- v16: Added Reviewed-by tag. v15: Changed "assign a hardware counter ID" to "assign a hardware counter" in couple of places. v14: Minor update to changelog and user doc (resctrl.rst). Changed subject line to fs/resctrl. v13: Updated the changelog. Added fflags RFTYPE_RES_CACHE to the file num_mbm_cntrs. Replaced seq_puts from seq_putc where applicable. Resolved conflicts caused by the recent FS/ARCH code restructure. The files monitor.c/rdtgroup.c have been split between FS and ARCH dir= ectories. v12: Changed the code to display the max supported monitoring counters in each domain. Also updated the documentation. Resolved the conflict with the latest code. v11: Renamed rdtgroup_num_mbm_cntrs_show() to resctrl_num_mbm_cntrs_show(). Few monor text updates. v10: No changes. v9: Updated user document based on the comments. Will add a new file available_mbm_cntrs later in the series. v8: Commit message update and documentation update. v7: Minor commit log text changes. v6: No changes. v5: Changed the display name from num_cntrs to num_mbm_cntrs. Updated the commit message. Moved the patch after mbm_mode is introduced. v4: Changed the counter name to num_cntrs. And few text changes. v3: Changed the field name to mbm_assign_cntrs. v2: Changed the field name to mbm_assignable_counters from abmc_counter. --- Documentation/filesystems/resctrl.rst | 11 ++++++++++ fs/resctrl/monitor.c | 2 ++ fs/resctrl/rdtgroup.c | 30 +++++++++++++++++++++++++++ 3 files changed, 43 insertions(+) diff --git a/Documentation/filesystems/resctrl.rst b/Documentation/filesyst= ems/resctrl.rst index b692829fec5f..4eb27530be6f 100644 --- a/Documentation/filesystems/resctrl.rst +++ b/Documentation/filesystems/resctrl.rst @@ -288,6 +288,17 @@ with the following files: result in misleading values or display "Unavailable" if no counter is ass= igned to the event. =20 +"num_mbm_cntrs": + The maximum number of counters (total of available and assigned counters)= in + each domain when the system supports mbm_event mode. + + For example, on a system with maximum of 32 memory bandwidth monitoring + counters in each of its L3 domains: + :: + + # cat /sys/fs/resctrl/info/L3_MON/num_mbm_cntrs + 0=3D32;1=3D32 + "max_threshold_occupancy": Read/write file provides the largest value (in bytes) at which a previously used LLC_occupancy diff --git a/fs/resctrl/monitor.c b/fs/resctrl/monitor.c index 66c8c635f4b3..4539b08db7b9 100644 --- a/fs/resctrl/monitor.c +++ b/fs/resctrl/monitor.c @@ -929,6 +929,8 @@ int resctrl_mon_resource_init(void) resctrl_enable_mon_event(QOS_L3_MBM_TOTAL_EVENT_ID); if (!resctrl_is_mon_event_enabled(QOS_L3_MBM_LOCAL_EVENT_ID)) resctrl_enable_mon_event(QOS_L3_MBM_LOCAL_EVENT_ID); + resctrl_file_fflags_init("num_mbm_cntrs", + RFTYPE_MON_INFO | RFTYPE_RES_CACHE); } =20 return 0; diff --git a/fs/resctrl/rdtgroup.c b/fs/resctrl/rdtgroup.c index c7ca9113a12a..acbda73a9b9d 100644 --- a/fs/resctrl/rdtgroup.c +++ b/fs/resctrl/rdtgroup.c @@ -1829,6 +1829,30 @@ static int resctrl_mbm_assign_mode_show(struct kernf= s_open_file *of, return 0; } =20 +static int resctrl_num_mbm_cntrs_show(struct kernfs_open_file *of, + struct seq_file *s, void *v) +{ + struct rdt_resource *r =3D rdt_kn_parent_priv(of->kn); + struct rdt_mon_domain *dom; + bool sep =3D false; + + cpus_read_lock(); + mutex_lock(&rdtgroup_mutex); + + list_for_each_entry(dom, &r->mon_domains, hdr.list) { + if (sep) + seq_putc(s, ';'); + + seq_printf(s, "%d=3D%d", dom->hdr.id, r->mon.num_mbm_cntrs); + sep =3D true; + } + seq_putc(s, '\n'); + + mutex_unlock(&rdtgroup_mutex); + cpus_read_unlock(); + return 0; +} + /* rdtgroup information files for one cache resource. */ static struct rftype res_common_files[] =3D { { @@ -1866,6 +1890,12 @@ static struct rftype res_common_files[] =3D { .seq_show =3D rdt_default_ctrl_show, .fflags =3D RFTYPE_CTRL_INFO | RFTYPE_RES_CACHE, }, + { + .name =3D "num_mbm_cntrs", + .mode =3D 0444, + .kf_ops =3D &rdtgroup_kf_single_ops, + .seq_show =3D resctrl_num_mbm_cntrs_show, + }, { .name =3D "min_cbm_bits", .mode =3D 0444, --=20 2.34.1 From nobody Mon Oct 6 01:21:11 2025 Received: from NAM02-SN1-obe.outbound.protection.outlook.com (mail-sn1nam02on2051.outbound.protection.outlook.com [40.107.96.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 E2E9224729D; Fri, 25 Jul 2025 18:32:24 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.96.51 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1753468346; cv=fail; b=K5Wd4grwlvosF66S58+Ta+BM/DflCq2mfpXvZmihZrj7/3qJSx+PzOOieJtk51MTIog8nqzTmfrV1wsm7OjMn8hR72FLuFMlo2UoFGnx3tPvunsWZ0zAXI23XIZcqy8fHYDlYmwIzO6yp676YQuqUs98w4Lb5Pz7OK+WVfdpS0g= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1753468346; c=relaxed/simple; bh=2hAPdB0sgzxeEx0KkYUOydRyZzOzW6oUKTgn00mirGY=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=tpoYB26/uYhlVLWeI27y2OR8w2LxYJt/W7eSuLcd9PCEc/hzac7Dv8cuWVMNfsM5Z1w7LVMTBFw2RvHAyhgGFPRK7lrK0quF4U0uiRoat5inB3mSpL+yK/WjzgdAiItc3Zku6TUD0TQWj6Wl+ssbvjPjHJrf/iO3VvW3KJYb2Eo= 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=RPcpQ1RM; arc=fail smtp.client-ip=40.107.96.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="RPcpQ1RM" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=spbWFdqIzOWWnRg+ZJ9/jxVkyee/Q8mT3nJLMjAPyy9Rmv+zSWNzvlYzNPeyET10vZmznZiwo6Q1quGU9L9gkMlIH9wf9fyxxZZcux40cX+36e7t/+HHVbxAdZBbs0xNyeRSF3YgAWXDmJ8HBKCE/OVGP6ZwgVCg6qwVhy8/yRbkDiTyPaicxZSzrXW9E3JzOvMWGAPKpxRN083dPCQIBqTfp1dorwzSUvs259aj5BOnWsnYUl+8HBZfn7lGcAVf2WUWnAlh4vACCytusSLRp4SYJ7TJUhQQk/GenS87UfOjujawIHxbips3id8vt9Rsa7LsT1kxo4V3T3GGs+g67w== 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=AQIlrq4JU/vwNUqBC13EkTRkEIbIsEUWd+H7bkxLP4o=; b=Kz2fZoZg/+72Fa1RWBAyF9I57n8Tjcvux1pDGo/0hPeOrxVfkzovzPlGulU/ddJuM4+G2uo7j1X4V5CU3aDzwRdnSkvx1aEjz+ylvcq+RWvF1XTnxlkHPD5cUw4jXN5mqhkTj8nfCtb3QkAJbp6Dqi+EzXd6oLQlW5CaLv9qoOql91qlatKpfHMgt2VIQFNE0LsiKkn8GMTwV8HX0t1vqJAMJcg3OYmFrNfLCYDMfTpfhDwozBfcJMUVV0hVZ1GVkDZpiUdPPze5xGWy9Ja+X1rgaDowdKbzoyAzvHj/nsa5I1lrpgswUxSibzgf0vRKlC8aMVBP3+IfW7Igharlng== 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=AQIlrq4JU/vwNUqBC13EkTRkEIbIsEUWd+H7bkxLP4o=; b=RPcpQ1RM96mfygFJLBSUwWQNl+5k/9Yhwc7BLrpQAPKhAyWXOjriyCjXjO0YF1h8ue8luhCFDoUEZlRWZcAxhGNiZDz54rlWwN7bnGJxHrZBdnn0bT7hycHqKMAa9cvZsYqLdO2ukUBJBVW80NGs4Wq/CCpd7zxgVfOORSu7sq0= Received: from DM6PR08CA0019.namprd08.prod.outlook.com (2603:10b6:5:80::32) by DM4PR12MB5722.namprd12.prod.outlook.com (2603:10b6:8:5d::11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8964.21; Fri, 25 Jul 2025 18:32:21 +0000 Received: from CY4PEPF0000EE3A.namprd03.prod.outlook.com (2603:10b6:5:80:cafe::d9) by DM6PR08CA0019.outlook.office365.com (2603:10b6:5:80::32) with Microsoft SMTP Server (version=TLS1_3, cipher=TLS_AES_256_GCM_SHA384) id 15.20.8964.23 via Frontend Transport; Fri, 25 Jul 2025 18:32: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 CY4PEPF0000EE3A.mail.protection.outlook.com (10.167.242.12) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.8964.20 via Frontend Transport; Fri, 25 Jul 2025 18:32:20 +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; Fri, 25 Jul 2025 13:32:18 -0500 From: Babu Moger To: , , , , , , , CC: , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , Subject: [PATCH v16 12/34] fs/resctrl: Introduce mbm_cntr_cfg to track assignable counters per domain Date: Fri, 25 Jul 2025 13:29:31 -0500 Message-ID: X-Mailer: git-send-email 2.34.1 In-Reply-To: References: Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-ClientProxiedBy: SATLEXMB03.amd.com (10.181.40.144) To SATLEXMB04.amd.com (10.181.40.145) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CY4PEPF0000EE3A:EE_|DM4PR12MB5722:EE_ X-MS-Office365-Filtering-Correlation-Id: c375febd-2305-4d40-182c-08ddcba9979e 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?xSkY0UVOK9XjN5eJVLtdIVU/arUwJ7qXYzxJ84bSVA/o7Jd7LZc5ZUemsg+5?= =?us-ascii?Q?ijA4257FdBdn2SH97bCphT8XGVF+l9dW0IgNfJ277j/7PF73IC22MnkbAbK+?= =?us-ascii?Q?WNzxzGJXMsK8Hr/msOLa09dugmx2jyU/YtvS8xJnnz9XIXX3MbbXVWgHdcAl?= =?us-ascii?Q?alhtt5EQ4cF5zu1jctm9VNhdtlG91fDZwVLDicDYcXEX+KUumVNaNtVkZBS9?= =?us-ascii?Q?nbxb6OlVHJ7LBY0vmRrTYM7DMlF0TwaoUcUecs68k6uHgWw+27IfUO3vzNPo?= =?us-ascii?Q?OW6hFLM+XGDJs8d4AKnRP53gXJgidbXrdV28ZS6E5X7oDUuPmJN4lwGyNOJF?= =?us-ascii?Q?pHAYUxgKFZhCdFfvFjcboK+Uew8U5m2t8s/5ZAOqax9IFTgDmx8cldmQ7clz?= =?us-ascii?Q?sTCjIhikZyfY98CAtmdjiNM4ju2gxd6o0G3U98zBDJcy32WguKOW0LqoKa7C?= =?us-ascii?Q?CRzMSvIz5C5myRfrpprH8zA7BwiMzs76Y2NDdqKk+xcr99C85tQKbMyOqIXo?= =?us-ascii?Q?dX8KHGDPj62mQLXZtiGP7OvBm7Ns/vPBsJ1xFLJAghgWYvqpeSz4hWcbN16a?= =?us-ascii?Q?yrsvUdKWJNl2fMmlDMnn3wSeR6SDoKRwMWn3vZu5eaiFVi2iz3cwA0gS+rwN?= =?us-ascii?Q?H+hvOJmlWSaPK2R3jqxtDVe4y8/3qtmZifmMwH4umzisHm7SRlAbA6E8KiPb?= =?us-ascii?Q?JXewBF8lvl0XT8rfhyRhkhsDLoF0JNetRADbTwtTw+PocAtWLsoaQY9tb+fv?= =?us-ascii?Q?b575NNVP2mICpKRiBE0F5bmcJ6fP24SSBQ3f2ECy/41LSHmjIKcKFBh2EsC8?= =?us-ascii?Q?GSApiXfy6vBQxA5GpkyopwsVlsybrb0zxXV9DOIu2Ag536ZMI/70Kxflvl6l?= =?us-ascii?Q?ffEn+2qijDQ187hy5E/0os/aAsHV6/iyBG+/V+xEvsUbBqo8DXGyE1f5s5pn?= =?us-ascii?Q?F+RlNWF1bOms/XmatKPvWiWLF0db/jyxHMvNOxzMj7OqJAwwhvNeFNQHB+3h?= =?us-ascii?Q?jqXfh66UUJQNcT/F8CDrEB+xgdHxxNgOsUA1dhZYS1eTY5D400AGFhuJN9NL?= =?us-ascii?Q?zMDimrww+NlIEZ6Tn+xuPb2JoGo9m8TiRQIxpoNdEZEwcR7OVuyddIy4Ng5q?= =?us-ascii?Q?n9P4m7JvUGnh6h4T/H27bT0b3Nh4iZVgYd2vOYxhEPoUL5kFA43EzxRGlplP?= =?us-ascii?Q?uAM5euod9NdVNN9FfhbtgdPFapbjln+U1RwPsOQ589AkIANqbJ4E0NFa8tSP?= =?us-ascii?Q?3kem95B19dih7KxfZ35a8UDkL9zsUYk6qnuqsx72AKtsI1Hpy035WM9houRL?= =?us-ascii?Q?ftmRKfPu9sr3jnDSydRRVoVQbpyQgjlK6+xvgczrTEKm9GEX7TYXi7f1qcEm?= =?us-ascii?Q?73/vHyYORvz/ZeOmbf/v29IFdIXQcf+VJo1v36hP9ywjWdE0zbQemlcqW2fZ?= =?us-ascii?Q?Oqr1coLwXQx9o50DSfSdILlXwyXWSS7E5UAr+KhvlHAdZGvRFmhcV/nLUfJf?= =?us-ascii?Q?prb8a4KdTXUruizVxYrzWNmgDEVAQbt6dJ+TfzBQvP6gq259AvgZ/0GmHw?= =?us-ascii?Q?=3D=3D?= X-Forefront-Antispam-Report: CIP:165.204.84.17;CTRY:US;LANG:en;SCL:1;SRV:;IPV:CAL;SFV:NSPM;H:SATLEXMB04.amd.com;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(13230040)(1800799024)(36860700013)(376014)(7416014)(82310400026);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 25 Jul 2025 18:32:20.9225 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: c375febd-2305-4d40-182c-08ddcba9979e 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: CY4PEPF0000EE3A.namprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM4PR12MB5722 Content-Type: text/plain; charset="utf-8" The "mbm_event" counter assignment mode allows users to assign a hardware counter to an RMID, event pair and monitor bandwidth usage as long as it is assigned. The hardware continues to track the assigned counter until it is explicitly unassigned by the user. Counters are assigned/unassigned at monitoring domain level. Manage a monitoring domain's hardware counters using a per monitoring domain array of struct mbm_cntr_cfg that is indexed by the hardware counter ID. A hardware counter's configuration contains the MBM event ID and points to the monitoring group that it is assigned to, with a NULL pointer meaning that the hardware counter is available for assignment. There is no direct way to determine which hardware counters are assigned to a particular monitoring group. Check every entry of every hardware counter configuration array in every monitoring domain to query which MBM events of a monitoring group is tracked by hardware. Such queries are acceptable because of a very small number of assignable counters (32 to 64). Suggested-by: Peter Newman Signed-off-by: Babu Moger Reviewed-by: Reinette Chatre --- v16: Added Reviewed-by tag. v15: Minor changelog update. Removed evt_cfg from struct mbm_cntr_cfg based on the discussion. https://lore.kernel.org/lkml/887bad33-7f4a-4b6d-95a7-fdfe0451f42b@inte= l.com/ v14: Updated code documentation and changelog. Fixed up the indentation in resctrl.h. Changed subject line to fs/resctrl. v13: Resolved conflicts caused by the recent FS/ARCH code restructure. The files monitor.c/rdtgroup.c have been split between FS and ARCH dir= ectories. v12: Fixed the struct mbm_cntr_cfg code documentation. Removed few strange charactors in changelog. Added the counter range for better understanding. Moved the struct mbm_cntr_cfg definition to resctrl/internal.h as suggested by James. v11: Refined the change log based on Reinette's feedback. Fixed few style issues. v10: Patch changed completely to handle the counters at domain level. https://lore.kernel.org/lkml/CALPaoCj+zWq1vkHVbXYP0znJbe6Ke3PXPWjtri5A= FgD9cQDCUg@mail.gmail.com/ Removed Reviewed-by tag. Did not see the need to add cntr_id in mbm_state structure. Not used i= n the code. v9: Added Reviewed-by tag. No other changes. v8: Minor commit message changes. v7: Added check mbm_cntr_assignable for allocating bitmap mbm_cntr_map v6: New patch to add domain level assignment. --- fs/resctrl/rdtgroup.c | 8 ++++++++ include/linux/resctrl.h | 15 +++++++++++++++ 2 files changed, 23 insertions(+) diff --git a/fs/resctrl/rdtgroup.c b/fs/resctrl/rdtgroup.c index acbda73a9b9d..a09566720d4f 100644 --- a/fs/resctrl/rdtgroup.c +++ b/fs/resctrl/rdtgroup.c @@ -4086,6 +4086,7 @@ static void domain_destroy_mon_state(struct rdt_mon_d= omain *d) { int idx; =20 + kfree(d->cntr_cfg); bitmap_free(d->rmid_busy_llc); for_each_mbm_idx(idx) { kfree(d->mbm_states[idx]); @@ -4169,6 +4170,13 @@ static int domain_setup_mon_state(struct rdt_resourc= e *r, struct rdt_mon_domain goto cleanup; } =20 + if (resctrl_is_mbm_enabled() && r->mon.mbm_cntr_assignable) { + tsize =3D sizeof(*d->cntr_cfg); + d->cntr_cfg =3D kcalloc(r->mon.num_mbm_cntrs, tsize, GFP_KERNEL); + if (!d->cntr_cfg) + goto cleanup; + } + return 0; cleanup: bitmap_free(d->rmid_busy_llc); diff --git a/include/linux/resctrl.h b/include/linux/resctrl.h index 919806122c50..e013caba6641 100644 --- a/include/linux/resctrl.h +++ b/include/linux/resctrl.h @@ -156,6 +156,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. + * @rdtgrp: 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 @@ -168,6 +180,8 @@ 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: array of assignable counters' configuration (indexed + * by counter ID) */ struct rdt_mon_domain { struct rdt_domain_hdr hdr; @@ -178,6 +192,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 Mon Oct 6 01:21:11 2025 Received: from NAM10-DM6-obe.outbound.protection.outlook.com (mail-dm6nam10on2043.outbound.protection.outlook.com [40.107.93.43]) (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 E7778155C97; Fri, 25 Jul 2025 18:32:34 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.93.43 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1753468356; cv=fail; b=Etg/00rJX7jOioYTytALYDFlpXxUbd4P+yx2AVHIB1KvAeCb8c9UNys1uMxfTHhxpuTpNABmyFOudeHkxpoVfnl8DJQqjUFBHjYXb3HLoSRsK274zzlNHrwCudeQAhKcLbgmvSqzZL1r/vC+TkeJHcomEsUF9Bbzozkdiw+j+4c= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1753468356; c=relaxed/simple; bh=d/ztbK69fmZQB4q/0TMJVwAH27XE+LebtZc2ftEG7LY=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=L/k0IrOjx3YVxKgfau6MMFavfF9GjrsEei7NkN2Iqzpcv27zbubk3exqDLHfW9hjuk7yEKwQOZumxaCl6ucH6PJ0zmcZsh2wNBR2XYA3BU/u9KfkIxJ3MrZh6SN9N/J76834JRHYwvzn/dZeO2oxniVFjlcGIamqCkUO2DfEC0E= 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=Vu4Xitkh; arc=fail smtp.client-ip=40.107.93.43 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="Vu4Xitkh" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=P11u+Cia1xx2669jSTsziirkKofOWo0vSj7tjpiJG68SKai2eVA9jVxLCfUOTVjl2hxKSDzlYeltI7FBK6Opj3PzmbvqN8yUgEfLcJKHZMDTSzkeZdOUApiQotGeAvhy1L6fQY5PHjefkBOm4Fj13Qtezl92huNmv1oG7PUy9Ogx+d4DCl/G32saqof/ajxN4CEzKbDJ3WePnAaMYqhcqY766Op1hZlu6e/oVXuwgoJBDMrz9wB+10apFkNVBB0SXnmCNlC+y3EU+8IDfuigvgBqj6anFGW7yBetm6+zjvg/2TOhbAkwNGz4fBrMXrXAlPwUlJPmI6qcsdSZD5XdbA== 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=4VXV9csTEwvTnJ3ZEbLwzaUTRbd3LartIn08Z8aP5ZE=; b=GbuZJuyVjRelm2yorTlAcBRkJYViJr2Y+iIkApfNuOF0CwddO+1/dF2YkYBCdmCPae0B+uRARPphFHZxogorTd/KK4+lbvIpnmzLNLw/8ovKpHleNUh72cnslr7hrjDM4MPgASQhwNli1Dgyhj/sebiDbfwDO8BdMWtkv1mkXLEBUrrq7PsGNNBI8oGgncnhi+mtfoJDWDABtH8Gpwt8/02i5uXrMH3r292sLkTK+obcBYF3ztp8IVNnuNS19Dmr1rri6EpkmNoocxqStW5scZSE0dpuG1z31rPHOJyvIzJNqLU5HcIHGqJiygeAt9fqFxEQvOb18WsTXWLa8sSpZg== 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=4VXV9csTEwvTnJ3ZEbLwzaUTRbd3LartIn08Z8aP5ZE=; b=Vu4XitkhBGuOzq2HBDVV+c7B4x5tTRapyEu6EuD/NiJ/7mvpzMngkcI9sm0N03nzx08GfJbTL1TEodT5JAm5WJ+ypJS7f6M9Zr31MDZSEMh5iKB1WA0kcD3RuKwdA/brWHwhNG//3x34lObqX5520cB+W4HuH/S3z/otDdyAaeU= Received: from DS7PR03CA0311.namprd03.prod.outlook.com (2603:10b6:8:2b::23) by DS7PR12MB9044.namprd12.prod.outlook.com (2603:10b6:8:e3::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8964.21; Fri, 25 Jul 2025 18:32:30 +0000 Received: from CY4PEPF0000EE3E.namprd03.prod.outlook.com (2603:10b6:8:2b:cafe::79) by DS7PR03CA0311.outlook.office365.com (2603:10b6:8:2b::23) with Microsoft SMTP Server (version=TLS1_3, cipher=TLS_AES_256_GCM_SHA384) id 15.20.8964.22 via Frontend Transport; Fri, 25 Jul 2025 18:32:30 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 165.204.84.17) smtp.mailfrom=amd.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=amd.com; Received-SPF: Pass (protection.outlook.com: domain of amd.com designates 165.204.84.17 as permitted sender) receiver=protection.outlook.com; client-ip=165.204.84.17; helo=SATLEXMB04.amd.com; pr=C Received: from SATLEXMB04.amd.com (165.204.84.17) by CY4PEPF0000EE3E.mail.protection.outlook.com (10.167.242.16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.8964.20 via Frontend Transport; Fri, 25 Jul 2025 18:32: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; Fri, 25 Jul 2025 13:32:27 -0500 From: Babu Moger To: , , , , , , , CC: , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , Subject: [PATCH v16 13/34] fs/resctrl: Introduce interface to display number of free MBM counters Date: Fri, 25 Jul 2025 13:29:32 -0500 Message-ID: <9e805169d3fbc889a89b283d074a5dff23cb0e94.1753467772.git.babu.moger@amd.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: References: Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-ClientProxiedBy: SATLEXMB03.amd.com (10.181.40.144) To SATLEXMB04.amd.com (10.181.40.145) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CY4PEPF0000EE3E:EE_|DS7PR12MB9044:EE_ X-MS-Office365-Filtering-Correlation-Id: f93fa4b3-4b60-4a6a-7bb7-08ddcba99cdf X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|82310400026|376014|7416014|36860700013|1800799024; X-Microsoft-Antispam-Message-Info: =?us-ascii?Q?GJJEyaMcyL8xxi9fLOvP8H5/aE+ACufUtJ6FNqdHVOf3Jq+duRb5ZtoXIM4C?= =?us-ascii?Q?7GpESsFZeRo5LlkPW+zWkStep2SwwrLFjbvCHWFAkQYNXDZzE4ZCvKUpiXFk?= =?us-ascii?Q?jjUTILMym2gE6olUIZ0gcB0hsyY5gJQTTX6Uk3jJNdgsjh+J/4Eib5v79lKx?= =?us-ascii?Q?fqsIIAcvtzsM9Jvc1RM90SZDEUSOmKElum83WpI8dyT+WJ+wzLQWk00TaFJ1?= =?us-ascii?Q?6Cg5VKUpBvmdiYtywJedkXDcU28hc0xXATimrpMmmouYCgBS4W39m8ty3le/?= =?us-ascii?Q?iARHc+InnBlm/KzEb64VQJIPLSZErUq/sG/cbMWdKFo68zRfmotjUdNYtBVp?= =?us-ascii?Q?m0jptbezifI5Ua8nGj1diAxaGs3PdQxmVLXVjj0cWbtZoTqJ8LGjW5k8QnX8?= =?us-ascii?Q?gPLXYeiLuVCAvN5ssUGlRFEUrxX5nXYsun86QmUZtgQC73BqrysB2rwtxfJ2?= =?us-ascii?Q?ZumSR6uSErbdrkFN4XP+HgalbhsldexVKmKlBtDXEqaMqZvTPxtkB3Jm2eIL?= =?us-ascii?Q?c2yY9qNZ2CSLKoqkckTZVQc1SA/S1RVlflyhb/76OI53FdJ+xqSfsANJ/c00?= =?us-ascii?Q?Yz/iaTX5LVPD8oBPsRsYb6oUr7hbMhGxW5+PWulxH0oWxjTFe6waUd82CIfY?= =?us-ascii?Q?P1kezKeLodzvT1Fv9MC8vHVvUS+GlMKrgg/FuWlokikIPMm0GGqGAhqQ+TuC?= =?us-ascii?Q?SD2tAm7+5B2d2qaPWS0Pm8yiNneApxWEXfxH9/m+dR0vAmh3pgMmCMHKEIQc?= =?us-ascii?Q?RGd1Z0KuwWqA+PWBao/l5D7xeK6Xr++2ffQm+DbGVlrECwHNcaMKQxNZHu0d?= =?us-ascii?Q?fVgwlaFcGCmG7VaNUnMLj1q/SypCwDJ1Co2uAE19XEbVrfp/cOe0i4etyYjG?= =?us-ascii?Q?QWO7u3vf5ORIPoScqJkFAWVEHnnf+kbsjgagpIF7ysTWTrooAksPUWM64vrd?= =?us-ascii?Q?yt0AX9lyFN1vi2wQzBr3H/jycDDJT7MqJSXNQm5NkFwbYV45CYupz50ZHZat?= =?us-ascii?Q?WyVLJ56xvowLlTXQBLJeEuEYrN+jTxroHeZaN6XJLgaKhBylWsld1TY/tUVN?= =?us-ascii?Q?bFXr360HmF/Vv6gDIh7jo0PtLQcPUzfXoN5Z1kbfXvXXPLfCHEK9p3XMK1TG?= =?us-ascii?Q?XV93qkzlQ1U0Bt7aVE8FYpGHzCazNuYIOcaIzMeAekZ/2ll9Nr23q0qYNuUj?= =?us-ascii?Q?53cNwMAyYK640omhYdkaOjUe2uxUol1TcxMV83WJi5+8PTkKJJrtxV/uaitS?= =?us-ascii?Q?1g/tVp5n2NwE6fZ5XN7vQtxDN9k2gKD2UuSWMqjg8yQ2wogpVpckxW10VDbE?= =?us-ascii?Q?D7PlEEmroxl5rzR5g0bCO/EaXUACnkrB8cZRZrkeRWZ0UcwitsC8Rz3dRkyj?= =?us-ascii?Q?IB+lAO7Re3HtFZkNCLm0kp6a9iTtntd6FnNKSC+pcjWRghDb/KmdJ3JmCLj3?= =?us-ascii?Q?PQTdNxKnv5cPywyPITeoSJUX5u9sr8npduAuFGDusjzhyOl7hJq+5LJVjIxL?= =?us-ascii?Q?D7hESkwDdQVKcxvhLp0PUIGUtDvGIb99Ro1k1WKTPOfo1nXwYnVXaGs39w?= =?us-ascii?Q?=3D=3D?= X-Forefront-Antispam-Report: CIP:165.204.84.17;CTRY:US;LANG:en;SCL:1;SRV:;IPV:CAL;SFV:NSPM;H:SATLEXMB04.amd.com;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(13230040)(82310400026)(376014)(7416014)(36860700013)(1800799024);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 25 Jul 2025 18:32:29.7375 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: f93fa4b3-4b60-4a6a-7bb7-08ddcba99cdf 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: CY4PEPF0000EE3E.namprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DS7PR12MB9044 Content-Type: text/plain; charset="utf-8" Introduce the "available_mbm_cntrs" resctrl file to display the number of counters available for assignment in each domain when "mbm_event" mode is enabled. Signed-off-by: Babu Moger Reviewed-by: Reinette Chatre --- v16: Added Reviewed-by tag. v15: Minor changelog text update. Minor resctrl.rst text update and corrected the error text in resctrl_available_mbm_cntrs_show(). Changed the goto label to out_unlock for consistency. v14: Minor changelog update. Changed subject line to fs/resctrl. v13: Resolved conflicts caused by the recent FS/ARCH code restructure. The files monitor.c and rdtgroup.c file has now been split between the FS and ARCH directories. v12: Minor change to change log. Updated the documentation text with an example. Replaced seq_puts(s, ";") with seq_putc(s, ';'); Added missing rdt_last_cmd_clear() in resctrl_available_mbm_cntrs_show= (). v11: Rename rdtgroup_available_mbm_cntrs_show() to resctrl_available_mbm_cn= trs_show(). Few minor text changes. v10: Patch changed to handle the counters at domain level. https://lore.kernel.org/lkml/CALPaoCj+zWq1vkHVbXYP0znJbe6Ke3PXPWjtri5A= FgD9cQDCUg@mail.gmail.com/ So, display logic also changed now. v9: New patch --- Documentation/filesystems/resctrl.rst | 11 ++++++ fs/resctrl/monitor.c | 2 ++ fs/resctrl/rdtgroup.c | 48 +++++++++++++++++++++++++++ 3 files changed, 61 insertions(+) diff --git a/Documentation/filesystems/resctrl.rst b/Documentation/filesyst= ems/resctrl.rst index 4eb27530be6f..446736dbd97f 100644 --- a/Documentation/filesystems/resctrl.rst +++ b/Documentation/filesystems/resctrl.rst @@ -299,6 +299,17 @@ with the following files: # cat /sys/fs/resctrl/info/L3_MON/num_mbm_cntrs 0=3D32;1=3D32 =20 +"available_mbm_cntrs": + The number of counters available for assignment in each domain when mbm_e= vent + mode is enabled on the system. + + For example, on a system with 30 available [hardware] assignable counters + in each of its L3 domains: + :: + + # cat /sys/fs/resctrl/info/L3_MON/available_mbm_cntrs + 0=3D30;1=3D30 + "max_threshold_occupancy": Read/write file provides the largest value (in bytes) at which a previously used LLC_occupancy diff --git a/fs/resctrl/monitor.c b/fs/resctrl/monitor.c index 4539b08db7b9..a0b0ea45c7b4 100644 --- a/fs/resctrl/monitor.c +++ b/fs/resctrl/monitor.c @@ -931,6 +931,8 @@ int resctrl_mon_resource_init(void) resctrl_enable_mon_event(QOS_L3_MBM_LOCAL_EVENT_ID); resctrl_file_fflags_init("num_mbm_cntrs", RFTYPE_MON_INFO | RFTYPE_RES_CACHE); + resctrl_file_fflags_init("available_mbm_cntrs", + RFTYPE_MON_INFO | RFTYPE_RES_CACHE); } =20 return 0; diff --git a/fs/resctrl/rdtgroup.c b/fs/resctrl/rdtgroup.c index a09566720d4f..15d10c346307 100644 --- a/fs/resctrl/rdtgroup.c +++ b/fs/resctrl/rdtgroup.c @@ -1853,6 +1853,48 @@ static int resctrl_num_mbm_cntrs_show(struct kernfs_= open_file *of, return 0; } =20 +static int resctrl_available_mbm_cntrs_show(struct kernfs_open_file *of, + struct seq_file *s, void *v) +{ + struct rdt_resource *r =3D rdt_kn_parent_priv(of->kn); + struct rdt_mon_domain *dom; + bool sep =3D false; + u32 cntrs, i; + int ret =3D 0; + + cpus_read_lock(); + mutex_lock(&rdtgroup_mutex); + + rdt_last_cmd_clear(); + + if (!resctrl_arch_mbm_cntr_assign_enabled(r)) { + rdt_last_cmd_puts("mbm_event mode is not enabled\n"); + ret =3D -EINVAL; + goto out_unlock; + } + + list_for_each_entry(dom, &r->mon_domains, hdr.list) { + if (sep) + seq_putc(s, ';'); + + cntrs =3D 0; + for (i =3D 0; i < r->mon.num_mbm_cntrs; i++) { + if (!dom->cntr_cfg[i].rdtgrp) + cntrs++; + } + + seq_printf(s, "%d=3D%u", dom->hdr.id, cntrs); + sep =3D true; + } + seq_putc(s, '\n'); + +out_unlock: + mutex_unlock(&rdtgroup_mutex); + cpus_read_unlock(); + + return ret; +} + /* rdtgroup information files for one cache resource. */ static struct rftype res_common_files[] =3D { { @@ -1876,6 +1918,12 @@ static struct rftype res_common_files[] =3D { .seq_show =3D rdt_mon_features_show, .fflags =3D RFTYPE_MON_INFO, }, + { + .name =3D "available_mbm_cntrs", + .mode =3D 0444, + .kf_ops =3D &rdtgroup_kf_single_ops, + .seq_show =3D resctrl_available_mbm_cntrs_show, + }, { .name =3D "num_rmids", .mode =3D 0444, --=20 2.34.1 From nobody Mon Oct 6 01:21:11 2025 Received: from NAM12-BN8-obe.outbound.protection.outlook.com (mail-bn8nam12on2049.outbound.protection.outlook.com [40.107.237.49]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id AE699254864; Fri, 25 Jul 2025 18:32:41 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.237.49 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1753468363; cv=fail; b=Hc+AG69kEfuHTGdxQUlV3P0IyyLWcH164DP+h+qWuNgK75pJUjYt+sVUdT84C53CP1+CbTEk4wBw6GymO6TwAmDE8OziivOLYDZHv+/VycGCFkJRirbTvp5tssy5jyotnp0EXCmxXK2QjuB/HjNiIiTnTnP0HjyIoX98HXDvXqM= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1753468363; c=relaxed/simple; bh=WJyYblKy+ddvhJQ0Qva/5p3LtXCkk3lnu/DCMQNuPhQ=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=juC4eLlS/fuR/gqPH3Y6oWixC41PQ42LcdNdcOZEVrNhloGtjYdDed9x79dmq077ThchIdcrkxwFfuqCdfITbv7iUBHnt+0iF0OjcKUDmiTcS3SsNCcQbeKJsumUZiagnQAV4vMutodpmHEePWTWht1H6P8YHc/fDXA7kE72o3E= 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=p+Cps2go; arc=fail smtp.client-ip=40.107.237.49 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=amd.com Authentication-Results: smtp.subspace.kernel.org; spf=fail smtp.mailfrom=amd.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=amd.com header.i=@amd.com header.b="p+Cps2go" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=B8nFaMr2mXMmmQ5m7CZTG9nAIA+RLJB7QabWCwdenAyMqY8DMVSK5NDnDunBysgFM2ND0FBLEQORjOIkW0FMxiBtGX/14IOgU3ohih1WGxZmTLnR92LNtd/uiNQ8YtSaAgRhG4JykryP+DEvNfRC8JIGUeBlw/XWUVjOoxHcWRS8LyB18WVyfzmYBS7p22Ez2O8cyiUf65WjJDZ7HUf59GrGWkxXitnzC7xJiA7QWs5yXBBacBrBsasibMKvMLMcAOrFA1By2jkcEM6Tfa+679LNNQahbgGPDvSSoXuwrwLoJ6RWdD9zZ+fckiTOxVIi/X0RnKr66p4Tg+XbktGD+A== 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=vxIlwY8lnMP8NxETCGCi2aCSKXQcbDe9K89Hky00SiM=; b=qP42xRtxqGbysRLAH2Bvnsvofo4d9KVUiMmpIB0Snlx1LC6UhucmsOvrkappVqmJtEe7GqUQBubiNcbnqfs09EzmiiiJtmDa8nWJDBfuFRWUE0yy1kPhhp6LrLv918SokcF3k03vugFlCJxjW8cHFlkbq5Plu+uyCH4caUocYCs6XIjCitDDmQZmBVSfcDDaLBYTC6IqJoSBbDTUlMXCBs1sqZ4kw7m4JudRCukBJMu5AJk5APkkuIpRz1yTG8ZpgvtZnToCiG5uZxxYbYLoBCiOCl2JS/Tjm3l6gw15YLFg9PdAKIF3LzOu4qhhqz95U69SJgh3rCxcHe1LpqYmPQ== 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=vxIlwY8lnMP8NxETCGCi2aCSKXQcbDe9K89Hky00SiM=; b=p+Cps2goDLVy2QIQWTQlv646erqwlcPmKNjI2D+dU1P5CfCMHBuKujiTV1D0rmoTvK5rEHKkSWxk/50MLbkjlMeyijQmLYmqw2HggEbUyeGyI5DTg0MIuLDRVp6dChD18OoxTs0c6pQNf4GjdJuqYS1b6Au3aQ/ks6BGY8i7nk4= Received: from DM6PR08CA0035.namprd08.prod.outlook.com (2603:10b6:5:80::48) by SA0PR12MB4400.namprd12.prod.outlook.com (2603:10b6:806:95::13) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8964.22; Fri, 25 Jul 2025 18:32:38 +0000 Received: from CY4PEPF0000EE3A.namprd03.prod.outlook.com (2603:10b6:5:80:cafe::d9) by DM6PR08CA0035.outlook.office365.com (2603:10b6:5:80::48) with Microsoft SMTP Server (version=TLS1_3, cipher=TLS_AES_256_GCM_SHA384) id 15.20.8964.23 via Frontend Transport; Fri, 25 Jul 2025 18:32:38 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 165.204.84.17) smtp.mailfrom=amd.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=amd.com; Received-SPF: Pass (protection.outlook.com: domain of amd.com designates 165.204.84.17 as permitted sender) receiver=protection.outlook.com; client-ip=165.204.84.17; helo=SATLEXMB04.amd.com; pr=C Received: from SATLEXMB04.amd.com (165.204.84.17) by CY4PEPF0000EE3A.mail.protection.outlook.com (10.167.242.12) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.8964.20 via Frontend Transport; Fri, 25 Jul 2025 18:32:38 +0000 Received: from bmoger-ubuntu.amd.com (10.180.168.240) by SATLEXMB04.amd.com (10.181.40.145) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.39; Fri, 25 Jul 2025 13:32:35 -0500 From: Babu Moger To: , , , , , , , CC: , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , Subject: [PATCH v16 14/34] x86/resctrl: Add data structures and definitions for ABMC assignment Date: Fri, 25 Jul 2025 13:29:33 -0500 Message-ID: <300b8b39e670546cce44ee4d079a0b1d6e6386ea.1753467772.git.babu.moger@amd.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: References: Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-ClientProxiedBy: SATLEXMB03.amd.com (10.181.40.144) To SATLEXMB04.amd.com (10.181.40.145) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CY4PEPF0000EE3A:EE_|SA0PR12MB4400:EE_ X-MS-Office365-Filtering-Correlation-Id: 52b7c5ca-8c5d-4050-8139-08ddcba9a213 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|82310400026|36860700013|7416014|376014|1800799024; X-Microsoft-Antispam-Message-Info: =?utf-8?B?a1ROZWFOWGxmQWZRQmJjS3hUYUEwVW5aQjR6a3JQNFBSa3d5WVVISWtmd0p2?= =?utf-8?B?QmJubkZpUzZlaWh1WVBCbisya2Y5VkJkZ2JNSWRPSklZdC90dnVLZjhyQm9v?= =?utf-8?B?VEpjTDl0cVZUTW8xSHdUYUNrcHBuY1RLanNaNXl0L3lZRW56cXVyOUk3dXdp?= =?utf-8?B?T0ZEMmthYkRJMjlQeGM0WXZiM0hzZ3IwM0J6RjRoa25WR2NHaEhiQmpZclB4?= =?utf-8?B?TE42dW8wWGtTVk9sajVqWEF6dHJWZnphVnlUNzQ0ZEpLQXlVb0psL00zd3Zz?= =?utf-8?B?RnFzZkt3VURyQ1JKWm0rdklPTlpnaGZHMmZXQWJ1aDNRdUZVVktIQ09rbnBv?= =?utf-8?B?bTVyVjMwdHp6ZHdyWnZ5OGlGRTVTQXdWbG41akZlMSt6TVVoM2tqemxUZWhY?= =?utf-8?B?UjA0UENZcWRsbVhFTGtyYjBXQ0dGSHcrOXJPdUtuSGhwb1BRRnhDUjI3Z1dj?= =?utf-8?B?aUtGcy9rSVlTQUpjQndEUEpTdXVCNmRTcEJkV2RUQ0tzMXNUUTFtZUZrZjRK?= =?utf-8?B?dUVQbU9ZRFVES2k4c2pyakdhSURvZFRWTUt2cHp1ZVlNVVo2dmVUbUx1NXRy?= =?utf-8?B?T3VIMDVFekFWL0JCQnNTbC84TTNYcENJdWNNeW1rTERZWGY1STdldStmVUZN?= =?utf-8?B?TE83STBpVzFZcStPZjNyYWlzNU5mT3AvUCtGeExmR25KZk1kNEFoRXZJYzdl?= =?utf-8?B?UldPVEVLOGE1YkR4WDBiWEhPZEdsUm9TL0dLNDhURHNKS1o5dWczdS9QZVRi?= =?utf-8?B?bnBnaHRIWGZYL3hKalN1WEluTldOY0N6M00rUENCVFhlUXA3Qi9WNHBnQjZB?= =?utf-8?B?TkozOGdVdml3ZmlmQ3VPMnR2TEE5MExJY2kxaWNMNmVxWmxnR0dEM2NMNlJN?= =?utf-8?B?NVNWQWlqOExsbFB1dnZGdGxxWjlmWDRhcW1sWFB0WHAvNktldFJCcC92dVI1?= =?utf-8?B?Z3B6Ny9mTWppUDduVTZmNGNzMzQwUzdxdGk4ZEJQS08zWEFZQnZJWHc2U2p3?= =?utf-8?B?RXFkKzFadEFCK29uYjhTQlJtcVJHWGloY3NZYTdTUmUvU2Q2bVZiWmMxZllp?= =?utf-8?B?QmpQbUdqQ3pnclFoQUpQc3RzRS9xeHl1SmUvbWxjWTZONDk0czVTQnJscyts?= =?utf-8?B?b240WktlRnp5STNDSld5UnNxcjNMcUwxbVhkZVJkR09NV2pacTkzcFF6a0NT?= =?utf-8?B?NXh6Nm5NalZPK3RHVlRQMFBtS3Z2L3R4V1JON1RZTWhXeXZSQytCelZhczQ3?= =?utf-8?B?MGV5eTBValdKSEREd0hLVmtleTJ6K2tDMHVndE5qdkxUUXdneTZra1p6Qmh2?= =?utf-8?B?VGc5eEhINmJMVENXV1RYQkkrRCtQamxZeXR5RTJmYnYwRGxIcXE4Y1RNUElN?= =?utf-8?B?UEZMOG5GU1UrVWJBYzdmdytlNVRQd1RzSE1EMzh3ZVFURVpmdUJsWks0aC9K?= =?utf-8?B?Zm9lUnVOSjdPQmM3ajJvZ2UxdU5TQ3hKenMyZHNwQTgzTGNOWEJtS1QxRWsv?= =?utf-8?B?N3JVS3VYWFJIU0RwenIxOU5hMnBLZEFXTSsybDVoSTl5dXlHV1hKYXVzTVJE?= =?utf-8?B?am9zelFoUlNZUTYvZGs1WVkvQnNDUVluZWVwOGtYclJ2WEM5dDJtNGRyOXNN?= =?utf-8?B?WkxESUNNd0crNTV0NXFsOXViTDh2eFRYdnR2NW1tYkRXT00zTnVkSk4wWWZX?= =?utf-8?B?bldyTHI2Ui9vdHdBQXpEcjdLSkZ1M1phOUl6ZmdNaURjRERmalVRc3FXR0lU?= =?utf-8?B?b2V3TjluckJNTENoRWxuUG4wekorSDJLRE1iZHVZSDRUU2ZkcFpxT3hya2lz?= =?utf-8?B?N2QyUFZsUG9aNm90VzFGNHRNY1hHZ1JKNWgvUFN1eVAwUnJRb09hNjRsVEcz?= =?utf-8?B?TmZZUDlxMVJnLzdkUnR0WTNiTXRJQktTZWdEZyt1N3lEMDhLNldIc1lBc0hQ?= =?utf-8?B?WmNqczd1VTI1bEtzREVmSmkxYS9WeVlJNWswL3E4amNicHIrdWtWTmtleExE?= =?utf-8?B?RnlwS1FtNzcwODhqNGR0TXhWSVpFbld5M2pSMThWcFZCUGVFaHp0NGxBLzZX?= =?utf-8?B?WlUrbTdQRFFCanNqc0xHWWc3Q3BxejRzSFU2dz09?= X-Forefront-Antispam-Report: CIP:165.204.84.17;CTRY:US;LANG:en;SCL:1;SRV:;IPV:CAL;SFV:NSPM;H:SATLEXMB04.amd.com;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(13230040)(82310400026)(36860700013)(7416014)(376014)(1800799024);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 25 Jul 2025 18:32:38.4690 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 52b7c5ca-8c5d-4050-8139-08ddcba9a213 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: CY4PEPF0000EE3A.namprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: SA0PR12MB4400 The ABMC feature allows users to assign a hardware counter to an RMID, event pair and monitor bandwidth usage as long as it is assigned. The hardware continues to track the assigned counter until it is explicitly unassigned by the user. The ABMC feature implements an MSR L3_QOS_ABMC_CFG (C000_03FDh). ABMC counter assignment is done by setting the counter id, bandwidth source (RMID) and bandwidth configuration. 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 tracked by the CtrID =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =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 --- v16: Added Reviewed-by tag. v15: Minor changelog update. v14: Removed BMEC reference internal.h. Updated the changelog and code documentation. v13: Removed the Reviewed-by tag as there is commit log change to remove BMEC reference. v12: No changes. v11: No changes. v10: No changes. v9: Removed the references of L3_QOS_ABMC_DSC. Text changes about configuration in kernel doc. v8: Update the configuration notes in kernel_doc. Few commit message update. v7: Removed the reference of L3_QOS_ABMC_DSC as it is not used anymore. Moved the configuration notes to kernel_doc. Adjusted the tabs for l3_qos_abmc_cfg and checkpatch seems happy. v6: Removed all the fs related changes. Added note on CfgEn,CtrEn. Removed the definitions which are not used. Removed cntr_id initialization. v5: Moved assignment flags here (path 10/19 of v4). Added MON_CNTR_UNSET definition to initialize cntr_id's. More details in commit log. Renamed few fields in l3_qos_abmc_cfg for readability. v4: Added more descriptions. Changed the name abmc_ctr_id to ctr_id. Added L3_QOS_ABMC_DSC. Used for reading the configuration. v3: No changes. v2: No changes. --- arch/x86/include/asm/msr-index.h | 1 + arch/x86/kernel/cpu/resctrl/internal.h | 36 ++++++++++++++++++++++++++ 2 files changed, 37 insertions(+) diff --git a/arch/x86/include/asm/msr-index.h b/arch/x86/include/asm/msr-in= dex.h index c998cf0e1375..3ad7f37b8ad8 100644 --- a/arch/x86/include/asm/msr-index.h +++ b/arch/x86/include/asm/msr-index.h @@ -1222,6 +1222,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 a79a487e639c..6bf6042f11b6 100644 --- a/arch/x86/kernel/cpu/resctrl/internal.h +++ b/arch/x86/kernel/cpu/resctrl/internal.h @@ -164,6 +164,42 @@ union cpuid_0x10_x_edx { unsigned int full; }; =20 +/* + * ABMC counters are configured by writing to L3_QOS_ABMC_CFG. + * + * @bw_type : Event configuration that represent the memory + * transactions being tracked by the @cntr_id. + * @bw_src : Bandwidth source (RMID or CLOSID). + * @reserved1 : Reserved. + * @is_clos : @bw_src field is a CLOSID (not an RMID). + * @cntr_id : Counter identifier. + * @reserved : Reserved. + * @cntr_en : Counting enable bit. + * @cfg_en : Configuration enable bit. + * + * Configuration and counting: + * Counter can be configured across multiple writes to MSR. Configuration + * is applied only when @cfg_en =3D 1. Counter @cntr_id is reset when the + * configuration is applied. + * @cfg_en =3D 1, @cntr_en =3D 0 : Apply @cntr_id configuration but do not + * count events. + * @cfg_en =3D 1, @cntr_en =3D 1 : Apply @cntr_id configuration and start + * counting events. + */ +union l3_qos_abmc_cfg { + struct { + unsigned long bw_type :32, + bw_src :12, + reserved1: 3, + is_clos : 1, + cntr_id : 5, + reserved : 9, + cntr_en : 1, + cfg_en : 1; + } split; + unsigned long full; +}; + void rdt_ctrl_update(void *arg); =20 int rdt_get_mon_l3_config(struct rdt_resource *r); --=20 2.34.1 From nobody Mon Oct 6 01:21:11 2025 Received: from NAM11-DM6-obe.outbound.protection.outlook.com (mail-dm6nam11on2044.outbound.protection.outlook.com [40.107.223.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 03B9A253925; Fri, 25 Jul 2025 18:32:50 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.223.44 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1753468372; cv=fail; b=L8rvmh8lGVHCfNdTuWfjFCqEK9Ivya+BGa14VepsYthWkhmDY4QKDk99h+tgk4zVCXq8bzXQXks9jWFWYmfO33aZqjA+aEVcDb6f15+ho81rLMdh7PITia+GXYvt0UaX+voj+Ek9nXfr7eeGKFqMzn8NYB3x+xKR3BiUsthkbyc= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1753468372; c=relaxed/simple; bh=gvEI57rMSAhNoHWDpjh9P/sYeVDnTHRT9TL10SmkQuU=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=G41TPG96j4XFxMNmsnCjo1YNf94t/b3PCBs8CzhiAr3c7+Wef9s+rjCFQTe+t4nCByn4zOxPC2xU9x38q4ykjr4TJgqvHsZRyfx5YQrjx6jaDdt2QHxgP/G2MrysFh92NfFAJldLThmHCeVtpetTgHAxFi7bNwWyX3ku9OS37ws= 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=lCBhfEVj; arc=fail smtp.client-ip=40.107.223.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="lCBhfEVj" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=e/S17FJ/XBdxZF4zggXplY42pJ0BZF4RGE6v5fvW8B0CO/B5+1RiFXXWhx81IfkoAYtW24FDIM82RBW+33tHoRiaGsI0dm98A0R1ck/gN1BooF2svmud0nKWTfTqhVtdImfjBFfCqtD/duG85PPIwuTpdkj/B0da5OxKlMQHT+JB3eEL4H7VRUt4Zqa+WG2U84KHZOEhlOUyKD4wF6zuebLM1d8eRQ1er6fHq4hPbaI+DOVgGp1AKgGtX5tKcvblV1DW+msz58jbFy28dbd3dLQk+JVZT7SsWAYAN5HtUMpvCvgEJxcdYBCpVqnyaUqvLsfyr2Zi/TvSA3cL80IqVg== 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=vEmcsdzWI/IaUa2TyNq/nrWfN8iDKh5FssD4n3+c4sY=; b=RW0aalTucpi1IQO/3QQ0Xa+9ClMHbPNKQ7iI76AsJieMgoMxoX5IFbdIVH3rAirmtYBF1SDxmh5k24t7ILt65sYFHTyBlRck1LH3t9ujZu/O0QnXrYfm82JUl9q9b/Cp4Vxf27vE1n8U5VIINDyq/18lQqTnGe470RQ8uX4eof2VbEbBGPHLj8JuPUp/gScfJQEpjpi2nUB0vYrSFLKuDvjLKW2C4pXHlPtp9hu1ueQw6uRmfXmP5YP2y/N823gId7cJfH6JdKNNwLn10oBN4UwSb72TEOCSDe17TvRfBq9ePILI4Vg7bTTJcKHFP733BH5NFBJBdzoBYuWuREEwog== 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=vEmcsdzWI/IaUa2TyNq/nrWfN8iDKh5FssD4n3+c4sY=; b=lCBhfEVj07r0XCar76LWhXNqxbQviLJRDYD0n+nwkIqPtV9j4IDq6vlt+q186hiGG+Ecs3mLouzaYK1uRiyG9fi9no46t9Wt50U9y7RwaFxMqdo/1AwPAxB0gSuAh3c62wFnfBR03rCiWwn/LTTz3A0LBc875bSiWQFFLsqdjK0= Received: from BYAPR11CA0079.namprd11.prod.outlook.com (2603:10b6:a03:f4::20) by DS0PR12MB6607.namprd12.prod.outlook.com (2603:10b6:8:d1::13) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8964.22; Fri, 25 Jul 2025 18:32:48 +0000 Received: from CY4PEPF0000EE3D.namprd03.prod.outlook.com (2603:10b6:a03:f4:cafe::b) by BYAPR11CA0079.outlook.office365.com (2603:10b6:a03:f4::20) with Microsoft SMTP Server (version=TLS1_3, cipher=TLS_AES_256_GCM_SHA384) id 15.20.8964.22 via Frontend Transport; Fri, 25 Jul 2025 18:32:47 +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 CY4PEPF0000EE3D.mail.protection.outlook.com (10.167.242.15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.8964.20 via Frontend Transport; Fri, 25 Jul 2025 18:32: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; Fri, 25 Jul 2025 13:32:44 -0500 From: Babu Moger To: , , , , , , , CC: , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , Subject: [PATCH v16 15/34] fs/resctrl: Introduce event configuration field in struct mon_evt Date: Fri, 25 Jul 2025 13:29:34 -0500 Message-ID: X-Mailer: git-send-email 2.34.1 In-Reply-To: References: Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-ClientProxiedBy: SATLEXMB03.amd.com (10.181.40.144) To SATLEXMB04.amd.com (10.181.40.145) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CY4PEPF0000EE3D:EE_|DS0PR12MB6607:EE_ X-MS-Office365-Filtering-Correlation-Id: 9e1aaa90-2ac5-418b-fb78-08ddcba9a758 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|376014|7416014|36860700013|82310400026|1800799024; X-Microsoft-Antispam-Message-Info: =?us-ascii?Q?bMpPeaqzdiPI9Z1lqDalOO+eDB0Biwf3MIdzMYioywuYfDd0gM59h2LWhtk3?= =?us-ascii?Q?op7mANdczl4voNuaPh2eS7uWiR9qSoG5wG/NYIO6svFMB6+QZQdXZCV3e4JE?= =?us-ascii?Q?fKmbhsCfH8lkA5kaJmYTSp27/qANfBCO880kFltgOnyAsrp8x0IUPGDVL72D?= =?us-ascii?Q?iqarXKbIlFYZKqWOhl4iyhut2inkPXeLYmyHhHOOjvSKihdTU432pXShp0RS?= =?us-ascii?Q?HoFtTEPHrOK9CVE8asRuej7ci/u8/hjZwut7QwRbXUVdyTN5lRqEZ3vXSzg0?= =?us-ascii?Q?Z1WF0zMKoMmlWinWZpZVzVJyBYLkNQxQfNQAQ3ZTlboDu1kh+QZXscPyRhNo?= =?us-ascii?Q?qcCJI/bUN+rGRO+47sgyb2+ceK/nHJLluiwIpqYLnxWQYz9Vc1dMseekk/xf?= =?us-ascii?Q?8O3kzTXdDCBv4q2Gw4AwacZqJ1NZVIyD5nEyxXlbvYes3TVtH1o7YVUGc7pa?= =?us-ascii?Q?1ctGeGUHWR0P7rzk2N/JkE0UEPscbUfq6ZiUGLz4ZmlZnMCEMGHlPMbj6Om4?= =?us-ascii?Q?EDYWVICCOCfmQR0mEYDt3iv7IW/mT86XgErM6z+7TYvx8MTnA6VrG5+Wdicl?= =?us-ascii?Q?KY9zdoj3OApaffSko9ncT71j8CHjXy5+tPjlcBCB/wduatYFdNPB+X8o8Wef?= =?us-ascii?Q?uKt0T9RE+U50xkH1V6VdzQEbQ4ZMVXZztzOa4F/1h/0NN5xIPZujBLqLOG7y?= =?us-ascii?Q?fYKZi/FYq2WJzRi+ykmP4aMkuVBzfAS1NWD8PIIkhzMja/lh78HTXhrb318S?= =?us-ascii?Q?lg0VHZrEgSZy2HHrq9e6UpacD7yfEfBvcDM0ZRTH6/Q9t/gsY8UYDxmS/G7+?= =?us-ascii?Q?qeJ95833Q7Vuc3itP5Of705zOf49VZ9ovDN89wkYevOTOBXFiAhOkLeYkJ94?= =?us-ascii?Q?m5hCy9LeROvy89JfnNZKZ5TkLlhKbnUJB5yk6qebpIJwaMm7dQDtYM7MO7bb?= =?us-ascii?Q?O3bo6GBocpLpoXAc2WLMeqTakiNEbyY7nDxo/elbYalennySTKdXa+Ri82zn?= =?us-ascii?Q?fxla3d9fwLdGBY5RrMazaScIxh3lUsib4vOa78lnvPaqxP1RltMdB7CsSKbX?= =?us-ascii?Q?qIf9Yu4dQBOGZ/SsZX0giZP7Zib+IaIVmNwcwPh4wCrKP/BJtea3OWSlJ/UV?= =?us-ascii?Q?67mAFZfXMxkSY4TtXf5LB4e6YVvOHpO1cTIGWRPG9/codj33IooDsOPkYI/u?= =?us-ascii?Q?B/mk93HiCO95DfNeKJSqMohnRSnRxuzix+adZI6bz5GZKOqSxmUixNkS5Ple?= =?us-ascii?Q?/yCLWjnz75K+Zy2PPknBwGME37PBMEuJZ8fxHSLYnHwqXdirTBcAR6WnG9bB?= =?us-ascii?Q?S8ynmlNdU/+z6tkSKYw521EJf45XesOCKn8TM1mj9+AbyNDP6z81bzxS4J34?= =?us-ascii?Q?HaUP8BNfScBFeGRPMvpvbyHzM/DpwqTLly2RWN1oKmuULdQOArlQg6+T/wHN?= =?us-ascii?Q?WxwAGwfItty58WqLHLJGV8OWNQ7DEUqhHtkoZMSTJwL92VEwgHbrM7dVucDC?= =?us-ascii?Q?w6IwaZ1Qm69ELbUlN7tE/b6Ub7DMuUBU+isOOKJdCEqjRmh/QSsZg3pN4Q?= =?us-ascii?Q?=3D=3D?= X-Forefront-Antispam-Report: CIP:165.204.84.17;CTRY:US;LANG:en;SCL:1;SRV:;IPV:CAL;SFV:NSPM;H:SATLEXMB04.amd.com;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(13230040)(376014)(7416014)(36860700013)(82310400026)(1800799024);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 25 Jul 2025 18:32:47.3057 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 9e1aaa90-2ac5-418b-fb78-08ddcba9a758 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: CY4PEPF0000EE3D.namprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DS0PR12MB6607 Content-Type: text/plain; charset="utf-8" When supported, mbm_event counter assignment mode allows the user to configure events to track specific types of memory transactions. Introduce the evt_cfg field in struct mon_evt to define the type of memory transactions tracked by a monitoring event. Also add a helper function to get the evt_cfg value. Signed-off-by: Babu Moger Reviewed-by: Reinette Chatre --- v16: Added Reviewed-by tag. v15: Updated the changelog. Removed resctrl_set_mon_evt_cfg(). Moved the event initialization to resctrl_mon_resource_init(). v14: This is updated patch from previous patch. https://lore.kernel.org/lkml/95b7f4e9d72773e8fda327fc80b429646efc3a8a.= 1747349530.git.babu.moger@amd.com/ Removed mbm_mode as it is not required anymore. Added resctrl_get_mon_evt_cfg() and resctrl_set_mon_evt_cfg(). v13: New patch to handle different event configuration types with mbm_cntr_assign mode. --- fs/resctrl/internal.h | 5 +++++ fs/resctrl/monitor.c | 9 +++++++++ include/linux/resctrl.h | 2 ++ 3 files changed, 16 insertions(+) diff --git a/fs/resctrl/internal.h b/fs/resctrl/internal.h index 4f315b7e9ec0..db3a0f12ad77 100644 --- a/fs/resctrl/internal.h +++ b/fs/resctrl/internal.h @@ -56,6 +56,10 @@ static inline struct rdt_fs_context *rdt_fc2context(stru= ct fs_context *fc) * @evtid: event id * @rid: resource id for this event * @name: name of the event + * @evt_cfg: Event configuration value that represents the + * memory transactions (e.g., READS_TO_LOCAL_MEM, + * READS_TO_REMOTE_MEM) being tracked by @evtid. + * Only valid if @evtid is an MBM event. * @configurable: true if the event is configurable * @enabled: true if the event is enabled */ @@ -63,6 +67,7 @@ struct mon_evt { enum resctrl_event_id evtid; enum resctrl_res_level rid; char *name; + u32 evt_cfg; bool configurable; bool enabled; }; diff --git a/fs/resctrl/monitor.c b/fs/resctrl/monitor.c index a0b0ea45c7b4..a089867262fa 100644 --- a/fs/resctrl/monitor.c +++ b/fs/resctrl/monitor.c @@ -884,6 +884,11 @@ bool resctrl_is_mon_event_enabled(enum resctrl_event_i= d eventid) mon_event_all[eventid].enabled; } =20 +u32 resctrl_get_mon_evt_cfg(enum resctrl_event_id evtid) +{ + return mon_event_all[evtid].evt_cfg; +} + /** * resctrl_mon_resource_init() - Initialise global monitoring structures. * @@ -929,6 +934,10 @@ int resctrl_mon_resource_init(void) resctrl_enable_mon_event(QOS_L3_MBM_TOTAL_EVENT_ID); if (!resctrl_is_mon_event_enabled(QOS_L3_MBM_LOCAL_EVENT_ID)) resctrl_enable_mon_event(QOS_L3_MBM_LOCAL_EVENT_ID); + mon_event_all[QOS_L3_MBM_TOTAL_EVENT_ID].evt_cfg =3D MAX_EVT_CONFIG_BITS; + mon_event_all[QOS_L3_MBM_LOCAL_EVENT_ID].evt_cfg =3D READS_TO_LOCAL_MEM | + READS_TO_LOCAL_S_MEM | + NON_TEMP_WRITE_TO_LOCAL_MEM; resctrl_file_fflags_init("num_mbm_cntrs", RFTYPE_MON_INFO | RFTYPE_RES_CACHE); resctrl_file_fflags_init("available_mbm_cntrs", diff --git a/include/linux/resctrl.h b/include/linux/resctrl.h index e013caba6641..87daa4ca312d 100644 --- a/include/linux/resctrl.h +++ b/include/linux/resctrl.h @@ -409,6 +409,8 @@ static inline bool resctrl_is_mbm_event(enum resctrl_ev= ent_id eventid) eventid <=3D QOS_L3_MBM_LOCAL_EVENT_ID); } =20 +u32 resctrl_get_mon_evt_cfg(enum resctrl_event_id eventid); + /* Iterate over all memory bandwidth events */ #define for_each_mbm_event_id(eventid) \ for (eventid =3D QOS_L3_MBM_TOTAL_EVENT_ID; \ --=20 2.34.1 From nobody Mon Oct 6 01:21:11 2025 Received: from NAM04-BN8-obe.outbound.protection.outlook.com (mail-bn8nam04on2084.outbound.protection.outlook.com [40.107.100.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 464C8250BEC; Fri, 25 Jul 2025 18:33:01 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.100.84 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1753468382; cv=fail; b=VnmxpnZOmtgmqW4ZUhILQdzRd5FRfKOmfOdHr68ssaEcWUFuSHQLPNw7Ptrr7ymjVYKM/PN7rexmu4rMIAlH6/zuTJYQ1T1gtgsKqnnXB7iPLxmXBv1K4UkjEfuJ32Q5YkfTt5c7GdK/6RcnXrVeDSg4AWCTOr+xoDkACeVvt3s= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1753468382; c=relaxed/simple; bh=Q6fGApYAdWysqgR5yUv0yW4IhHom5HxPObCIZjGX4/k=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=O0fy0nq9LPSDjJLzIkj67hYvqTlGGx9QZpmVh8ZMAPNiO6RI0sriLWw824PGyrA6pIytZ2T/h5ABtaULVWgm4Gr2iiRzEN0sbCas6H85KIQNve9bHm0xh5NAWC3SR2pPL4c21xLX7lTNO9DxvB2Xq6ZfygcTQ2MGqfN7hfIVCYA= 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=4Ib/mw4B; arc=fail smtp.client-ip=40.107.100.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="4Ib/mw4B" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=coxTv1b7QWbyy0xV16ffPl+vhMq6EP938WqCwPhukXw2pbBf/4nefLHuHQO0E4+fpbJQC0mB46xVJPIzrdIo96odc6DkoMtg5NvFIQDa+3etlfC2mq6GTTSVk9H1h1AxPQPAG5UUyWfKt4iYzF4kgZIOY45hOvAl+o9Ctly7O2WvziK0mNdnZ7UMzh08hjmyArQ3zmdgYQEFX09PvfuTN7MVud9E3vteRXdO3kr16E7RvgbQPQFAhAts8ydsyxTADHLykWzPQh8Egl2jcuw990Fl8Prbq89S0C8WKg5cYQ+8gOLpD23YHpC6noUGzf9QOACjgVqDVonblT+MlBxFew== 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=UzVG2Uj5kF2q+xGh/LoyU9EeWt8mIYnbDRX+Br0+fPc=; b=IQdEtw9lF4LCls4LJ6fx9P8ZBAlOZjTNDrL/+diDD/I1+vlmqikiv5lTL2Gd/zpizYLDdm7UBq4Y5XNTweCzHAVQDL/65DS2FR3JUkRy+UIngxoBZNmY2GR/YlsZk+1Yd9VArWVljK6wS8FUuW7EhrnUvMZFu+q8i8piRxn/4d6hOknr7zO363VKZ+MSWiIDYCV7zeVFBqtx9yB6Vi+sUkl4wgj9VTz1PPkPeKWT/aYn1LOqRUQ+e5Y4/vUu/S9c2+16sq/hIy9I0htU2f7p8XiLnj6gaUFS8fx/SkFABf1ykPWgM5YjcYslf2kDjuCbSNINWLvbHAYonFt86rqGxQ== 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=UzVG2Uj5kF2q+xGh/LoyU9EeWt8mIYnbDRX+Br0+fPc=; b=4Ib/mw4BDRF/C3cYxecW14K3tYFCKmkclEqw1wXaCRk8HMox0oyUyMwTr0JxfrCEo/aaOYz/yg377VzWp7CYErI4T3VnXE5SFkVlQ5HNYmAKav589bvMA2ZoUOVjK9ptBknmF3r0e8EDGGCtJM5vI5iQCiI5BFgThXOSfKHatfw= Received: from SJ0PR03CA0135.namprd03.prod.outlook.com (2603:10b6:a03:33c::20) by MN2PR12MB4237.namprd12.prod.outlook.com (2603:10b6:208:1d6::7) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8922.39; Fri, 25 Jul 2025 18:32:57 +0000 Received: from CY4PEPF0000EE3C.namprd03.prod.outlook.com (2603:10b6:a03:33c:cafe::2b) by SJ0PR03CA0135.outlook.office365.com (2603:10b6:a03:33c::20) with Microsoft SMTP Server (version=TLS1_3, cipher=TLS_AES_256_GCM_SHA384) id 15.20.8964.23 via Frontend Transport; Fri, 25 Jul 2025 18:32:56 +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 CY4PEPF0000EE3C.mail.protection.outlook.com (10.167.242.13) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.8964.20 via Frontend Transport; Fri, 25 Jul 2025 18:32:56 +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; Fri, 25 Jul 2025 13:32:53 -0500 From: Babu Moger To: , , , , , , , CC: , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , Subject: [PATCH v16 16/34] x86,fs/resctrl: Implement resctrl_arch_config_cntr() to assign a counter with ABMC Date: Fri, 25 Jul 2025 13:29:35 -0500 Message-ID: <5ce91d983fdb22648e13727866b0b5ebe1428b32.1753467772.git.babu.moger@amd.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: References: Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-ClientProxiedBy: SATLEXMB03.amd.com (10.181.40.144) To SATLEXMB04.amd.com (10.181.40.145) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CY4PEPF0000EE3C:EE_|MN2PR12MB4237:EE_ X-MS-Office365-Filtering-Correlation-Id: b2f40283-3480-430f-0927-08ddcba9ac90 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|376014|7416014|82310400026|1800799024|36860700013; X-Microsoft-Antispam-Message-Info: =?us-ascii?Q?DHnXpU1NPgxxBfxuFmkLYezIxlG7A9TTVOGJ8V1IFm10E5QeokpP/n7Ruugt?= =?us-ascii?Q?qQGzQ/dpT1yy3AXDuU4Ry95zRGbzStZhXWyiJ74wv4QHez9lS8dj7tmVnW/Y?= =?us-ascii?Q?u/Te4nCUdieKyNH01h0b5D6xPAumtaiCF1Z9BPscBIRGH2oVUnBJs6QC2LvS?= =?us-ascii?Q?3eTGVLdwCaZFHD0yxHoxL3ovhN9GMiCeOpv0CeZYZcKcr4DKlTa5e0kHArwv?= =?us-ascii?Q?xczti8ZTaCFTiN0QKwHxXZ/sI7V5oCkVDA3/XEZKKdZiKx5eh38LzOCkN0WF?= =?us-ascii?Q?32m8zqUtkxMri/sIvVD8XTsQjcwrB7abJdsU+0bWPvcyLvpOv2jVF3FmNUWq?= =?us-ascii?Q?fohoBcj+bV7/94scY4Ni5cvsB8ZgsdXuFj2Sz5vFkqUNUlupr2nH/fqoNrIM?= =?us-ascii?Q?2gQ8L4lH3Kj8ex7YeDxyshQuZD8XXMIo1F7UOQPKg9aynpWEU1IenX/hA7vB?= =?us-ascii?Q?04m33FF+Zy7VMaOFiDHu5j0HItxE7OL+Mllgx6M8LlZYRpSWRKOmaeJuXnnq?= =?us-ascii?Q?vLD0xbbmlNI3GFyl/mTZeUQtciIwrKmg8pzabtWlZFPgfQdLuq9huD/9mCw7?= =?us-ascii?Q?4o0+VEow3v25OJyZGKdFc5EEMT8jAmiLxBbW81lYFdFEBdBqGMAS+hr03Xb0?= =?us-ascii?Q?T7PjCfur7dQm7OGOx/96DgZ67wfK8tzWUvR2tHOUwtU/K2v5u037Tv155EcO?= =?us-ascii?Q?PFygFCdRnKqfc1hT0Y9C4OqZaaE6flYAQbFG46KmeMcdxUepJsEgeDaod7PY?= =?us-ascii?Q?mOP/cHJ7bPS9sLowFj//w8FwDVU9/9/dXrnHf0EKZRE6j8WlD2uhfmcUHcO7?= =?us-ascii?Q?7LkmIDHGUtlWyy0vKUzcdG53IF0d1zzt5Jct4qXorl6j7SPzAp0XMKfY2MX1?= =?us-ascii?Q?Km92RIUsfxMM072S0Uz7pFpmMBZHh0OZsGH8/woJmjdgTJmtmfG3chQ9txKx?= =?us-ascii?Q?2WHSzocc0q6LhfJfmjqFxnl8usbm4u1sCSD88g2Za5QN07+lU5s7Wc/HqzGG?= =?us-ascii?Q?j3dXM+aEMBpXVulYpXNfi7LfKgRDnb7KomUoVzvSzAte48AkbXNCrt1ppGpu?= =?us-ascii?Q?g5j9TNrwSUGo13YqNO9e5BLgZY6E0EFHNWvdPZP1q8bQNbslPxxUbzRQYRI1?= =?us-ascii?Q?67iqjGN32JYn+mcPHVQrOCnrnQo3UxMftFXY2FqME17IFAwqLDWt0/CKFK6M?= =?us-ascii?Q?Px5FPUIMpjLEx/oGhauClvnvOhzpVcYtXeMG49mib/7XEyaLBEa/H8zl3Jum?= =?us-ascii?Q?2e+tz1PKhfKbifVvEEb7n7J+T+DPXPDC8+EaKuMvzayB1gmUcsTMAcxBU+HX?= =?us-ascii?Q?FflPSaN5mJgVEk6M5ImfC0TA+eCDOCDHAnJtrH/cbmUSiYkVa5XhAdAu9oDB?= =?us-ascii?Q?JDHQcDCQOJreXsRwk4+neociCzJY7CuJ9BgIRnCLwFj7M51ZRuVQmvfuX8mO?= =?us-ascii?Q?ugcsHfHW+KCPt3pVLbsRFkvJpklS/XpknTgQk/kg4pX8xGWYdh9htJpttxji?= =?us-ascii?Q?1SGjrwKig2lSuGJEXuCo1rnKDZXZwGODDlLL7LyFBU9cK4suZucKIoBj2g?= =?us-ascii?Q?=3D=3D?= X-Forefront-Antispam-Report: CIP:165.204.84.17;CTRY:US;LANG:en;SCL:1;SRV:;IPV:CAL;SFV:NSPM;H:SATLEXMB04.amd.com;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(13230040)(376014)(7416014)(82310400026)(1800799024)(36860700013);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 25 Jul 2025 18:32:56.0615 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: b2f40283-3480-430f-0927-08ddcba9ac90 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: CY4PEPF0000EE3C.namprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: MN2PR12MB4237 Content-Type: text/plain; charset="utf-8" The ABMC feature allows users to assign a hardware counter to an RMID, event pair and monitor bandwidth usage as long as it is assigned. The hardware continues to track the assigned counter until it is explicitly unassigned by the user. Implement an x86 architecture-specific handler to configure a counter. This architecture specific handler is called by resctrl fs when a counter is assigned or unassigned as well as when an already assigned counter's configuration should be updated. 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 Reviewed-by: Reinette Chatre --- v16: Updated the changelog. Reset the architectural state in resctrl_arch_config_cntr() in both assign and unassign cases. v15: Minor changelog update. Added few code comments in include/linux/resctrl.h. v14: Removed evt_cfg parameter in resctrl_arch_config_cntr(). Get evt_cfg only when assign is required. Minor update to changelog. v13: Moved resctrl_arch_config_cntr() prototype to include/linux/resctrl.h. Changed resctrl_arch_config_cntr() to retun void from int. Updated the kernal doc for the prototype. Updated the code comment. 12: Added the check to reset the architecture-specific state only when assign is requested. Added evt_cfg as the parameter as the user will be passing the event configuration from /info/L3_MON/event_configs/. v11: Moved resctrl_arch_assign_cntr() and resctrl_abmc_config_one_amd() to monitor.c. Added the code to reset the arch state in resctrl_arch_assign_cntr(). Also removed resctrl_arch_reset_rmid() inside IPI as the counters are reset from the callers. Re-wrote commit message. v10: Added call resctrl_arch_reset_rmid() to reset the RMID in the domain inside IPI call. SMP and non-SMP call support is not required in resctrl_arch_config_cn= tr with new domain specific assign approach/data structure. Commit message update. v9: Removed the code to reset the architectural state. It will done in another patch. v8: Rename resctrl_arch_assign_cntr to resctrl_arch_config_cntr. v7: Separated arch and fs functions. This patch only has arch implementatio= n. Added struct rdt_resource to the interface resctrl_arch_assign_cntr. Rename rdtgroup_abmc_cfg() to resctrl_abmc_config_one_amd(). v6: Removed mbm_cntr_alloc() from this patch to keep fs and arch code separate. Added code to update the counter assignment at domain level. v5: Few name changes to match cntr_id. Changed the function names to rdtgroup_assign_cntr resctr_arch_assign_cntr More comments on commit log. Added function summary. v4: Commit message update. User bitmap APIs where applicable. Changed the interfaces considering MPAM(arm). Added domain specific assignment. v3: Removed the static from the prototype of rdtgroup_assign_abmc. The function is not called directly from user anymore. These changes are related to global assignment interface. v2: Minor text changes in commit message. --- arch/x86/kernel/cpu/resctrl/monitor.c | 36 +++++++++++++++++++++++++++ include/linux/resctrl.h | 19 ++++++++++++++ 2 files changed, 55 insertions(+) diff --git a/arch/x86/kernel/cpu/resctrl/monitor.c b/arch/x86/kernel/cpu/re= sctrl/monitor.c index cce35a0ad455..ed295a6c5e66 100644 --- a/arch/x86/kernel/cpu/resctrl/monitor.c +++ b/arch/x86/kernel/cpu/resctrl/monitor.c @@ -444,3 +444,39 @@ bool resctrl_arch_mbm_cntr_assign_enabled(struct rdt_r= esource *r) { return resctrl_to_arch_res(r)->mbm_cntr_assign_enabled; } + +static void resctrl_abmc_config_one_amd(void *info) +{ + union l3_qos_abmc_cfg *abmc_cfg =3D info; + + wrmsrl(MSR_IA32_L3_QOS_ABMC_CFG, abmc_cfg->full); +} + +/* + * Send an IPI to the domain to assign the counter to RMID, event pair. + */ +void resctrl_arch_config_cntr(struct rdt_resource *r, struct rdt_mon_domai= n *d, + enum resctrl_event_id evtid, u32 rmid, u32 closid, + u32 cntr_id, 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; + if (assign) + abmc_cfg.split.bw_type =3D resctrl_get_mon_evt_cfg(evtid); + + smp_call_function_any(&d->hdr.cpu_mask, resctrl_abmc_config_one_amd, &abm= c_cfg, 1); + + /* + * The hardware counter is reset (because cfg_en =3D=3D 1) so there is no + * need to record initial non-zero counts. + */ + am =3D get_arch_mbm_state(hw_dom, rmid, evtid); + if (am) + memset(am, 0, sizeof(*am)); +} diff --git a/include/linux/resctrl.h b/include/linux/resctrl.h index 87daa4ca312d..50e38445183a 100644 --- a/include/linux/resctrl.h +++ b/include/linux/resctrl.h @@ -594,6 +594,25 @@ void resctrl_arch_reset_rmid_all(struct rdt_resource *= r, struct rdt_mon_domain * */ void resctrl_arch_reset_all_ctrls(struct rdt_resource *r); =20 +/** + * resctrl_arch_config_cntr() - Configure the counter with its new RMID + * and event details. + * @r: Resource structure. + * @d: The domain in which counter with ID @cntr_id should be configured. + * @evtid: Monitoring event type (e.g., QOS_L3_MBM_TOTAL_EVENT_ID + * or QOS_L3_MBM_LOCAL_EVENT_ID). + * @rmid: RMID. + * @closid: CLOSID. + * @cntr_id: Counter ID to configure. + * @assign: True to assign the counter or update an existing assignment, + * false to unassign the counter. + * + * This can be called from any CPU. + */ +void resctrl_arch_config_cntr(struct rdt_resource *r, struct rdt_mon_domai= n *d, + enum resctrl_event_id evtid, u32 rmid, u32 closid, + u32 cntr_id, bool assign); + extern unsigned int resctrl_rmid_realloc_threshold; extern unsigned int resctrl_rmid_realloc_limit; =20 --=20 2.34.1 From nobody Mon Oct 6 01:21:11 2025 Received: from NAM11-DM6-obe.outbound.protection.outlook.com (mail-dm6nam11on2086.outbound.protection.outlook.com [40.107.223.86]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id D817C2475C3; Fri, 25 Jul 2025 18:33:13 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.223.86 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1753468395; cv=fail; b=EPdg/pRCPDHwcWChpIno6/RmYXOGFL/gomjdTbOKrgz4FJ5nN0eiFv8G41k2HSNNhBE7EfMJta1yy+bm/JXV43EAgZCid6HR3IiQiZahfxxGQdfhRGKdgoqTvjwKJkcpbxw7yinsYp3Ac9ySK559NaiZG0X887942/ClL4Dl5MQ= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1753468395; c=relaxed/simple; bh=HtY0Ooz3ieSXVwGH/4lQ908GlLlrBecYJ7+J34sbM0I=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=cAP4jAMcz4FbSeWUFgsKaMEgVtndi6tuF1herieBnhFZvuYbLMuDiClh0H2zQ5c7y1/rk14Q9GfW2WQmxTTSchXBVZRQ3xyNFXHaSQeX17Zes7ax9T8mmgnvwtSE5fqalMW/M6QY7xrXXbz6WBN6dsH2eGAa/l1PAIJUFFDVZHY= 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=zqaPcVh7; arc=fail smtp.client-ip=40.107.223.86 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=amd.com Authentication-Results: smtp.subspace.kernel.org; spf=fail smtp.mailfrom=amd.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=amd.com header.i=@amd.com header.b="zqaPcVh7" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=d6bQXhUVOEN0uSmbp6xClInW+8aJ5hFjfkj5pH2Ws6B9js6YFR85pu3AmaI1tL1YCWyl+upr5PE2nhrP6zcpXdRVgAa1MCiOBZF/b16QEtDcjZXXnBD3HotNXG/d+3BA5HoFaC9QFuBjM1cQQ372ChyyUAcbcbaJZy4HwW1wMWtwfmkGhZxD6sTZth7QinOXzR+oEQzhkYvPQ0LetZxHfzwHV/OE4I/NDPm/8jiBoFPn/eEJNn6nFpT2QZ9gGqo58lbn0yVra5RGhiZwJ65Z3MqdpAtEIXKcGOxyTQxClpEkeuNXGo9Ow3nnMMhKfiv+LdV4i/grwhIUz76TtSScjQ== 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=+EIDifkGJyHYf+AcNLOuaLmQjaVwHC9QCFc4b1T2yW0=; b=f575gze6xp86fz8N2YOnIHIo2kGXSzudZrq98VPSKAIbsk1MUWqpyCtM3OrxQuKfYszv17/g2KoyQr1URgRW0CsNasGHSDx0CprqDkHu7WF+qeHQR5QIdWaOh3vhZI3yEnxGNoW84ZRrbvJPg5XHOtc31Hm955OoAfrO70R95eXmzVdoYXrrPPHaRK7wUlvxleN7woMYcr35Ndg45KYwa8IKrgxmsr3alIf0G1psB/UKv+SMIxj5wSFU39dx+oojGEzNxIQF8NrM4q2h13rGsYI/N1TJAMcmIhAAV/3qU/o9Cj478bcCvhZemp/2VXtVIxjKqPWtN49nnrmNkfCXKw== 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=+EIDifkGJyHYf+AcNLOuaLmQjaVwHC9QCFc4b1T2yW0=; b=zqaPcVh7AFmSAeS4OHgU2/aD6mDq+yVJrPxS8XiUiBZVZgrHGrLowl39wh2Q4uHjcsBzZpH2dOyW5o83VnZvNx3Qw5RmG945QhnSX88RnlwkKDbJu3W8c8Mj7nSlAt02xCXzetNX/MCc0m8ORB9rL+3HxoseRhPigCjf/+5eohQ= Received: from CYXPR03CA0080.namprd03.prod.outlook.com (2603:10b6:930:d3::24) by DS7PR12MB6215.namprd12.prod.outlook.com (2603:10b6:8:95::7) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8964.21; Fri, 25 Jul 2025 18:33:09 +0000 Received: from CY4PEPF0000EE38.namprd03.prod.outlook.com (2603:10b6:930:d3:cafe::a8) by CYXPR03CA0080.outlook.office365.com (2603:10b6:930:d3::24) with Microsoft SMTP Server (version=TLS1_3, cipher=TLS_AES_256_GCM_SHA384) id 15.20.8964.23 via Frontend Transport; Fri, 25 Jul 2025 18:33: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 CY4PEPF0000EE38.mail.protection.outlook.com (10.167.242.10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.8964.20 via Frontend Transport; Fri, 25 Jul 2025 18:33: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; Fri, 25 Jul 2025 13:33:02 -0500 From: Babu Moger To: , , , , , , , CC: , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , Subject: [PATCH v16 17/34] fs/resctrl: Add the functionality to assign MBM events Date: Fri, 25 Jul 2025 13:29:36 -0500 Message-ID: <09e6eb24212047908127b8b9fbd1673d6892cad2.1753467772.git.babu.moger@amd.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: References: Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-ClientProxiedBy: SATLEXMB03.amd.com (10.181.40.144) To SATLEXMB04.amd.com (10.181.40.145) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CY4PEPF0000EE38:EE_|DS7PR12MB6215:EE_ X-MS-Office365-Filtering-Correlation-Id: e272add0-84b9-4069-1824-08ddcba9b2cf 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?OmlhZLIfcd7zJCUzc7Xwt+bjGyH47hjn1SYVOmTPz/jSIikvogJGWRiJ+dU8?= =?us-ascii?Q?BnVqwYvOYkHWcmYVNHbnts+Zgl6KJRs3Z9kYfPNR1v5hxmpnoVOS87bi44Vk?= =?us-ascii?Q?JFc0KFT2zCcWNLCcCFfKQmqwNJqg3DXGGBOCSnVNoQLKmsUQrSrkACaEi5OK?= =?us-ascii?Q?NzQlSylNcA6uRmMtCIIFRXilJCtAvwQXmkyuVTernrjBWRSrQJkmzt73LhWF?= =?us-ascii?Q?QaQdAzpenemrqBdcAdMN1K3cq12uebYEe9O1muiU0zOd/I8IQIXRuxpvyoyl?= =?us-ascii?Q?lW/fpK7yXM+5TEQiLx24vgkhOBHzK65OBfQufhw5VY/a5QbLgh6Xz8kP4Gzm?= =?us-ascii?Q?lNMehkrSN8O6gYw2LYmg+ULPn1pdUwdTBKsv2VzdTAWgJdn5pmBEDo5p7BrJ?= =?us-ascii?Q?WqwfNGpyVUebhjdI9gorU6HT66Ddktoes4CxeplIJjkrX4kiwQU0CFZkj/vR?= =?us-ascii?Q?+/36arLYfZc/s71JiL0ngKV3ALdJI8iCCFFSCSOFaRzDaMhWqFhY9CSuKLZf?= =?us-ascii?Q?YII98LMUt9p7Dasb0gfibgPtncmwfaKCPWSVCXt8jNmDHFpNH+W1bA8++Ene?= =?us-ascii?Q?Hofw4Gx8skNs1ctVK5TvVHC/eacZbTQWdGxEAHBf35I0EqpD4IWYGm2DHq30?= =?us-ascii?Q?cYufR2iVqhUsj+XlGe2YSJ+YFU8T7ohqoPvhggHHrepBHiqS2d0n8hwr1fF1?= =?us-ascii?Q?YKzEvTfPrDHRcKvdRg0XrgP/O4YIbCN+stZOQB3o2iaR48/6cB8R/L6sXRv6?= =?us-ascii?Q?QaZO5HMlAkDVeqzjIIFZuIBLLW//kQfv2yK/nqkUY1RbhUYXVY8yPxRM5pbQ?= =?us-ascii?Q?w53JQgMHMP1fRCs8Hl9mspJ7z9o0/GQqYaza6Mpb2lmaJWMeBMjvmTOJ7p9f?= =?us-ascii?Q?WNWxOOovAsLclz58YkYTb1gfhW819Fnvm//y4B4ItPdP4zSmjqt9sCh3M8Bm?= =?us-ascii?Q?9f6OtdvMBlpSXzyzFaTlGvk/U29b3N1Qr0rA/V3HpCywjSBll0GmOnsgv4XI?= =?us-ascii?Q?+0Y/Kr6MeBV2CbjFbEQtNbs+8p+ZzwML+9aPzdOmZ/SH2ZYyG+8bZ/kM6YTM?= =?us-ascii?Q?XzfgP1CF1CqLDrnAoFnuYb1XgFSYh+pyF9wJASnF0c9cd+iiGmorm+Vaxsi6?= =?us-ascii?Q?yZRHdepl72+wQ7zlVmN0yb0BkGX/zF3eodmkAkQvakUE9o0rWxwQxeIY7qf5?= =?us-ascii?Q?dXGXo/+KqYrrxvAK5BkyvDBIKnfCIyP08Vw9cSuJeHpsZotUX/YbTsIj7Wox?= =?us-ascii?Q?tGpxnTtSEark+8kLPQA4kf21xAh954cvQzNtIYLTAUzqjkoAS9Cqtc4e2QET?= =?us-ascii?Q?xDj1EymlFTNjKAbCYZR8we4ryG0p937vRMiNtirYiaEKtNerG0AjP3SlVFrf?= =?us-ascii?Q?x+K1os4M2++wwwvGWuuwK32vjbQ6oPqNtJB9raNX/0LyeQ2IAEUK7MIUw5lw?= =?us-ascii?Q?ClijdcaYdWBy3UBvUKzVmC9XhZFpfT7E+ldUhk/BZkvMcwL4efpnf8tYa9CQ?= =?us-ascii?Q?fBe3M51ftNb7C6pMJYzdPi2cGEYsEX77UCQl3R5DPR3UPBYotawXsFb6WQ?= =?us-ascii?Q?=3D=3D?= X-Forefront-Antispam-Report: CIP:165.204.84.17;CTRY:US;LANG:en;SCL:1;SRV:;IPV:CAL;SFV:NSPM;H:SATLEXMB04.amd.com;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(13230040)(1800799024)(376014)(7416014)(36860700013)(82310400026)(13003099007);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 25 Jul 2025 18:33:06.5414 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: e272add0-84b9-4069-1824-08ddcba9b2cf 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: CY4PEPF0000EE38.namprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DS7PR12MB6215 Content-Type: text/plain; charset="utf-8" When supported, "mbm_event" counter assignment mode offers "num_mbm_cntrs" number of counters that can be assigned to RMID, event pairs and monitor bandwidth usage as long as it is assigned. Add the functionality to allocate and assign a counter to an RMID, event pair in the domain. If all the counters are in use, kernel will log the error message "Failed to allocate counter for in domain " in /sys/fs/resctrl/info/last_cmd_status when a new assignment is requested. Exit on the first failure when assigning counters across all the domains. Signed-off-by: Babu Moger --- v16: Function renames: resctrl_config_cntr() -> rdtgroup_assign_cntr() rdtgroup_alloc_config_cntr() -> rdtgroup_alloc_assign_cntr() Passed struct mevt to rdtgroup_alloc_assign_cntr so it can print event= name on failure. Minor code comment update. v15: Updated the changelog. Added the check !r->mon.mbm_cntr_assignable in mbm_cntr_get() to retur= n error. Removed the check to verify evt_cfg in the domain as it is not require= d anymore. https://lore.kernel.org/lkml/887bad33-7f4a-4b6d-95a7-fdfe0451f42b@inte= l.com/ Return success if the counter is already assigned. Rename resctrl_assign_cntr_event() -> rdtgroup_assign_cntr_event(). Removed the parameter struct rdt_resource. It can be obtained from mev= t->rid. v14: Updated the changelog little bit. Updated the code documentation for mbm_cntr_alloc() and mbm_cntr_get(= ). Passed struct mon_evt to resctrl_assign_cntr_event() that way to avoid back and forth calls to get event details. Updated the code documentation about the failure when counters are exh= asted. Changed subject line to fs/resctrl. v13: Updated changelog. Changed resctrl_arch_config_cntr() to return void instead of int. Just passing evtid is to resctrl_alloc_config_cntr() and resctrl_assign_cntr_event(). Event configuration value can be easily obtained from mon_evt list. Introduced new function mbm_get_mon_event() to get event configuration= value. Added prototype descriptions to mbm_cntr_get() and mbm_cntr_alloc(). Resolved conflicts caused by the recent FS/ARCH code restructure. The files monitor.c/rdtgroup.c have been split between FS and ARCH dir= ectories. v12: Fixed typo in the subjest line. Replaced several counters with "num_mbm_cntrs" counters. Changed the check in resctrl_alloc_config_cntr() to reduce the indenta= tion. Fixed the handling error on first failure. Added domain id and event id on failure. Fixed the return error override. Added new parameter event configuration (evt_cfg) to get the event con= figuration from user space. v11: Patch changed again quite a bit. Moved the functions to monitor.c. Renamed rdtgroup_assign_cntr_event() to resctrl_assign_cntr_event(). Refactored the resctrl_assign_cntr_event(). Added functionality to exit on the first error during assignment. Simplified mbm_cntr_free(). Removed the function mbm_cntr_assigned(). Will be using mbm_cntr_get()= to figure out if the counter is assigned or not. Updated commit message and code comments. v10: Patch changed completely. Counters are managed at the domain based on the discussion. https://lore.kernel.org/lkml/CALPaoCj+zWq1vkHVbXYP0znJbe6Ke3PXPWjtri5A= FgD9cQDCUg@mail.gmail.com/ Reset non-architectural MBM state. Commit message update. v9: Introduced new function resctrl_config_cntr to assign the counter, upda= te the bitmap and reset the architectural state. Taken care of error handling(freeing the counter) when assignment fails. Moved mbm_cntr_assigned_to_domain here as it used in this patch. Minor text changes. v8: Renamed rdtgroup_assign_cntr() to rdtgroup_assign_cntr_event(). Added the code to return the error if rdtgroup_assign_cntr_event fails. Moved definition of MBM_EVENT_ARRAY_INDEX to resctrl/internal.h. Updated typo in the comments. v7: New patch. Moved all the FS code here. Merged rdtgroup_assign_cntr and rdtgroup_alloc_cntr. Adde new #define MBM_EVENT_ARRAY_INDEX. --- fs/resctrl/internal.h | 3 + fs/resctrl/monitor.c | 130 ++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 133 insertions(+) diff --git a/fs/resctrl/internal.h b/fs/resctrl/internal.h index db3a0f12ad77..419423bdabdc 100644 --- a/fs/resctrl/internal.h +++ b/fs/resctrl/internal.h @@ -387,6 +387,9 @@ bool closid_allocated(unsigned int closid); =20 int resctrl_find_cleanest_closid(void); =20 +int rdtgroup_assign_cntr_event(struct rdt_mon_domain *d, struct rdtgroup *= rdtgrp, + struct mon_evt *mevt); + #ifdef CONFIG_RESCTRL_FS_PSEUDO_LOCK int rdtgroup_locksetup_enter(struct rdtgroup *rdtgrp); =20 diff --git a/fs/resctrl/monitor.c b/fs/resctrl/monitor.c index a089867262fa..8b0aa2469643 100644 --- a/fs/resctrl/monitor.c +++ b/fs/resctrl/monitor.c @@ -953,3 +953,133 @@ void resctrl_mon_resource_exit(void) =20 dom_data_exit(r); } + +/* + * rdtgroup_assign_cntr() - Assign/unassign the counter ID for the event, = RMID + * pair in the domain. + * + * Assign the counter if @assign is true else unassign the counter. Reset = the + * associated non-architectural state. + */ +static void rdtgroup_assign_cntr(struct rdt_resource *r, struct rdt_mon_do= main *d, + enum resctrl_event_id evtid, u32 rmid, u32 closid, + u32 cntr_id, bool assign) +{ + struct mbm_state *m; + + resctrl_arch_config_cntr(r, d, evtid, rmid, closid, cntr_id, assign); + + m =3D get_mbm_state(d, closid, rmid, evtid); + if (m) + memset(m, 0, sizeof(*m)); +} + +/* + * mbm_cntr_get() - Return the counter ID for the matching @evtid and @rdt= grp. + * + * Return: + * Valid counter ID on success, or -ENOENT on failure. + */ +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; + + if (!r->mon.mbm_cntr_assignable) + return -ENOENT; + + if (!resctrl_is_mbm_event(evtid)) + return -ENOENT; + + for (cntr_id =3D 0; cntr_id < r->mon.num_mbm_cntrs; cntr_id++) { + if (d->cntr_cfg[cntr_id].rdtgrp =3D=3D rdtgrp && + d->cntr_cfg[cntr_id].evtid =3D=3D evtid) + return cntr_id; + } + + return -ENOENT; +} + +/* + * mbm_cntr_alloc() - Initialize and return a new counter ID in the domain= @d. + * Caller must ensure that the specified event is not assigned already. + * + * Return: + * Valid counter ID on success, or -ENOSPC on failure. + */ +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; +} + +/* + * rdtgroup_alloc_assign_cntr() - Allocate a counter ID and assign it to t= he event + * pointed to by @mevt and the resctrl group @rdtgrp within the domain @d. + * + * Return: + * 0 on success, < 0 on failure. + */ +static int rdtgroup_alloc_assign_cntr(struct rdt_resource *r, struct rdt_m= on_domain *d, + struct rdtgroup *rdtgrp, struct mon_evt *mevt) +{ + int cntr_id; + + /* No action required if the counter is assigned already. */ + cntr_id =3D mbm_cntr_get(r, d, rdtgrp, mevt->evtid); + if (cntr_id >=3D 0) + return 0; + + cntr_id =3D mbm_cntr_alloc(r, d, rdtgrp, mevt->evtid); + if (cntr_id < 0) { + rdt_last_cmd_printf("Failed to allocate counter for %s in domain %d\n", + mevt->name, d->hdr.id); + return cntr_id; + } + + rdtgroup_assign_cntr(r, d, mevt->evtid, rdtgrp->mon.rmid, rdtgrp->closid,= cntr_id, true); + + return 0; +} + +/* + * rdtgroup_assign_cntr_event() - Assign a hardware counter for the event = in + * @mevt to the resctrl group @rdtgrp. Assign counters to all domains if @= d is + * NULL; otherwise, assign the counter to the specified domain @d. + * + * If all counters in a domain are already in use, rdtgroup_alloc_assign_c= ntr() + * will fail. The assignment process will abort at the first failure encou= ntered + * during domain traversal, which may result in the event being only parti= ally + * assigned. + * + * Return: + * 0 on success, < 0 on failure. + */ +int rdtgroup_assign_cntr_event(struct rdt_mon_domain *d, struct rdtgroup *= rdtgrp, + struct mon_evt *mevt) +{ + struct rdt_resource *r =3D resctrl_arch_get_resource(mevt->rid); + int ret =3D 0; + + if (!d) { + list_for_each_entry(d, &r->mon_domains, hdr.list) { + ret =3D rdtgroup_alloc_assign_cntr(r, d, rdtgrp, mevt); + if (ret) + return ret; + } + } else { + ret =3D rdtgroup_alloc_assign_cntr(r, d, rdtgrp, mevt); + } + + return ret; +} --=20 2.34.1 From nobody Mon Oct 6 01:21:11 2025 Received: from NAM12-BN8-obe.outbound.protection.outlook.com (mail-bn8nam12on2080.outbound.protection.outlook.com [40.107.237.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 57A907483; Fri, 25 Jul 2025 18:33:24 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.237.80 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1753468407; cv=fail; b=e0lr0tZYrcNPzwvzt/dt0ig7hh1cVdzicKqIFAGx5ndf95irnTATWbqjJ89bscDEdS8/tI6tSVBb5JhQb9a4ZSK6UoFbDTPqJ/Wm+JhlTc9yaNiEyp8+E27yxmE9p8CF89k83X7I4LLV508APE1GUyMFo/HFsMdBJYXSCrlJ/XU= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1753468407; c=relaxed/simple; bh=ogUwuDTBxewhWQcl799F8Xmkp+m8Xuems0vUFEeNIbg=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=FOrxIjr70OCamgI4MchKSzEBfxOGvU9BuIX1MHIjjh62xtxq0RjsCtE9w4SAx5BaxP+fqiJL5jDIxcCgPcKorQSzTb4efIjPovwiLoyzCn9xfUHH5kglKnDQDw42sbbkeUghzCTgSOFWJrcCrkwhQG4k/7r5rFK37RNAfaPjo74= 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=G+cy104f; arc=fail smtp.client-ip=40.107.237.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="G+cy104f" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=I/5L3DP/0nJdfI0eiP59rgOf32FkfVN+C7huO5zWuC+UC9GgqPi5z98DBQhQUe76WLxempFq+IVOR2aQSMPOGk6xkq86hdO5jEyu5YAcjyWCOoO0sbjVi/VeTmZaWLrgl4Y3tbU/xbniEugEfRkWhHIxpDiRISlzIoTIklYpQqRP/ZGUR+BeR4n+bjScf4KsXw/v0Cg6LTaUfHN92lgoSArX5LVRCvVhEtWiYCMhKeDu7bXCG3SVEdPEyrwHmBltkBJTJy3fkC3j3eAUM85CBcJVOTRmHUpBN7tBOleCIifngqI7sFIm6o16YCKr6CTP0LkCtNqlC4FCttqewdgM3A== 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=Da+tXozeTS7zpp1Sp9+KiTi6LLYWZweAqnljNcy1Cno=; b=xTqRXoM1xCoBF2xBO78R8bSACwadm/pqPK7qZOjmPNg4oCVeSnFQmr4ajn6Y1skK60QIAnqYpHvDBKwimi0pNZXrmlNhZMpiq41aFK+07idZx9rndrMi1nc5IFPxARZ6C+tKSTNqvolXLrfoAYADfYQ9hh/1yv1JyN1EDf0rMbG/5frMriKbbr4oibXcgO5ZjdFgTsBS8bk8Y9gMqZRjbTeDklcN9e+QyAGgd/3Y790ioR844SMtHjXWOx+crjj7pv4Bc+8yrzqJVrCi5bpbKL3/0TlADho2EexTWsr/asoK68BU4lRuuQyBsX5aOkDJhsUOozRc7pjMFftFTDlWGQ== 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=Da+tXozeTS7zpp1Sp9+KiTi6LLYWZweAqnljNcy1Cno=; b=G+cy104fOG5OvfMTc/deod2GriPBU9ysoOkFUqDbuOy1zUPuiP2xrrFGwSLaS5+AvuvFSiX3S3oS+h+dc9Z8Ni9l9ttP1LPb62UMnGlVe6QXkXJ/UO4xiXncoTSfF+amKDinKAzatZZiZcBWBGZk9t2BG16WvEdjXzdqiH4F2z0= Received: from CYXPR03CA0094.namprd03.prod.outlook.com (2603:10b6:930:d3::16) by DM4PR12MB6375.namprd12.prod.outlook.com (2603:10b6:8:a2::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8964.21; Fri, 25 Jul 2025 18:33:21 +0000 Received: from CY4PEPF0000EE38.namprd03.prod.outlook.com (2603:10b6:930:d3:cafe::16) by CYXPR03CA0094.outlook.office365.com (2603:10b6:930:d3::16) with Microsoft SMTP Server (version=TLS1_3, cipher=TLS_AES_256_GCM_SHA384) id 15.20.8964.24 via Frontend Transport; Fri, 25 Jul 2025 18:33: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 CY4PEPF0000EE38.mail.protection.outlook.com (10.167.242.10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.8964.20 via Frontend Transport; Fri, 25 Jul 2025 18:33:19 +0000 Received: from bmoger-ubuntu.amd.com (10.180.168.240) by SATLEXMB04.amd.com (10.181.40.145) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.39; Fri, 25 Jul 2025 13:33:16 -0500 From: Babu Moger To: , , , , , , , CC: , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , Subject: [PATCH v16 18/34] fs/resctrl: Add the functionality to unassign MBM events Date: Fri, 25 Jul 2025 13:29:37 -0500 Message-ID: <8289b3fcfabe6d820620429646b18660e7cf9ffa.1753467772.git.babu.moger@amd.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: References: Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-ClientProxiedBy: SATLEXMB03.amd.com (10.181.40.144) To SATLEXMB04.amd.com (10.181.40.145) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CY4PEPF0000EE38:EE_|DM4PR12MB6375:EE_ X-MS-Office365-Filtering-Correlation-Id: 39a49e40-66d5-4ccb-af7f-08ddcba9baaa X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|1800799024|82310400026|36860700013|7416014|376014; X-Microsoft-Antispam-Message-Info: =?us-ascii?Q?IcKoeiDtwIB84N9G/Y5Pmkx+t4Otbr0I7F1I4d03r9RnZM8xInHoSFTp14tN?= =?us-ascii?Q?1GcT0Xq1/rZ6m851JFXirDn0QhPhQskQSQC+ThkcJYR0UIDkIGPublfiJRIn?= =?us-ascii?Q?IJANly0LtGSlswxT8LspGxF1PfAlP7BzYtJFdDYpGerGS6NopeqipPh6UKWs?= =?us-ascii?Q?MME78TA0aJnDQGD1TeJ/As93JTGik28K05JmRIdW7UBObfEebQ2Lh7R9Fsuv?= =?us-ascii?Q?+2imj9pWstU0T6aShPe1YCBh1zQchNLoZzwJtYJdoiN9krM2iCxyWkbjoaro?= =?us-ascii?Q?e+8CZeelwKQ3RDRb6IAmE+FHoKZdk+sZDpQ9GOmi2siV8P0BIu+S3PUyon4P?= =?us-ascii?Q?hpwrUYbMZHsIAV517kLVvV3gtS9HkqLawwysrGsTAUOLvrf2J7KeKUqqngxH?= =?us-ascii?Q?LkBWjUkrt8Ajsm9QrNndzS58RrgkT4eoYuN+WvDSHvwyEYMNEygqBvvJMGZl?= =?us-ascii?Q?dTWv3i6t8SYBIEKwIvvPMCucCRwxpzRrxwYHJ/Gi0Dc9fSsZRF/wzyhZ3m3A?= =?us-ascii?Q?jBjhEjpcJilA4MFNoi6xP8tf5UIHROxBXNOzXZDJDLYAXjFoBfQXI1vJyYNQ?= =?us-ascii?Q?1ZXa0LG7bt6HEUkHW3BOebs0vtDHvUF2I3pdbdfdpYRy9F/6DTz/MWLI01YJ?= =?us-ascii?Q?R+ululG2miswD3WafPwYgx4AnR2jRQyEggHC6GuAzoHqdeHdikQzrDS0KBZw?= =?us-ascii?Q?qrnHWr1GF0N6ANdBKwgXVEJ31w5oLcD+DXFq0aruD1/L6v8qxunGVGaRcbIx?= =?us-ascii?Q?5/ORS+vsT6jrNVlpoZW0n4xNXAGIms/rO2Ku01LPzJWKqVwelK/TvHhDs8Hk?= =?us-ascii?Q?dloQvojjoaMKq8Vz3qiJrYgtkTSFyu6yLA7sA5oyxHy450rEXkELnr5zy6m1?= =?us-ascii?Q?W1QFwTkuz0Op64sqmgUhmsoQHRIxkYD3u3GGJ1Vn0YlHhqwB6bFvX5Pm4w0k?= =?us-ascii?Q?K35tzjKZL9LnLCB4v6jz+c4gv8+mFKLIuFyOdlRlj3BJTDcqq9gjGS2LWgZW?= =?us-ascii?Q?EZFzm4qUZ7m7P0lzFHGGfqI1DsnjMDQICaMRaHD5crS7OtBNf5ABg8NMhp35?= =?us-ascii?Q?bh7cmSMwuTeKn3Xp2VhWIwbiIVzef1kVztnIsHWkwmupV0tb7hrGnYz7O2GB?= =?us-ascii?Q?tMKri9EfhjTTu0oRHYGW/V1tJFc8KbUUtM3bhhKkDqJVGoAHVQ4t91lKLo/p?= =?us-ascii?Q?XHTkIap/tiSfxi+4n9mQxZZmM9vj20PDhwJaZQC5gNfTfFJQg0qFcIyM+t6I?= =?us-ascii?Q?akJlgwxQRLMQPKg/Pksup9c/kPIn7VecFKU3pQSbowZriOWTtlUcftJmQin0?= =?us-ascii?Q?1SV715dpEzARH7e6ttch7ZXEVF0tJ4O9kGpRSEMqm18CrWzyXI2jNquboiea?= =?us-ascii?Q?fCdNNthVb+BYblONi5+f6UtaFz7BFZwGRuRAG5MDiSVskwajnnUTWd3ZiNG1?= =?us-ascii?Q?t9pCTPHJkiDCgPFjse3yEK6Yo7ni6J4QjNUBhc7xPNAaEeLZoLaLPo2X4LTK?= =?us-ascii?Q?mkKMqAdf2coNvh2nHCLG1TUId8sNvqZ26VmjOU1bExSWt2iV9K/M56U2PA?= =?us-ascii?Q?=3D=3D?= X-Forefront-Antispam-Report: CIP:165.204.84.17;CTRY:US;LANG:en;SCL:1;SRV:;IPV:CAL;SFV:NSPM;H:SATLEXMB04.amd.com;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(13230040)(1800799024)(82310400026)(36860700013)(7416014)(376014);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 25 Jul 2025 18:33:19.7244 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 39a49e40-66d5-4ccb-af7f-08ddcba9baaa 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: CY4PEPF0000EE38.namprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM4PR12MB6375 Content-Type: text/plain; charset="utf-8" The "mbm_event" counter assignment mode offers "num_mbm_cntrs" number of counters that can be assigned to RMID, event pairs and monitor bandwidth usage as long as it is assigned. If all the counters are in use, the kernel logs the error message "Unable to allocate counter in domain" in /sys/fs/resctrl/info/last_cmd_status when a new assignment is requested. To make space for a new assignment, users must unassign an already assigned counter and retry the assignment again. Add the functionality to unassign and free the counters in the domain. Signed-off-by: Babu Moger --- v16: Function rename rdtgroup_free_config_cntr() -> rdtgroup_free_unassign_= cntr(). Updated rdtgroup_free_unassign_cntr() to pass struct mon_evt to match rdtgroup_alloc_assign_cntr() prototype. v15: Updated the changelog. Changed code in mbm_cntr_free to use the sizeof(*d->cntr_cfg)). Removed unnecessary return in resctrl_free_config_cntr(). Rename resctrl_unassign_cntr_event() -> rdtgroup_unassign_cntr_event(). Removed the parameter struct rdt_resource. It can be obtained from mev= t->rid. v14: Passing the struct mon_evt to resctrl_free_config_cntr() and removed the need for mbm_get_mon_event() call. Corrected the code documentation for mbm_cntr_free(). Changed resctrl_free_config_cntr() and resctrl_unassign_cntr_event() to return void. Changed subject line to fs/resctrl. Updated the changelog. v13: Moved mbm_cntr_free() to this patch as it is used in here first. Not required to pass evt_cfg to resctrl_unassign_cntr_event(). It is available via mbm_get_mon_event(). Resolved conflicts caused by the recent FS/ARCH code restructure. The monitor.c file has now been split between the FS and ARCH director= ies. v12: Updated the commit text to make bit more clear. Replaced several counters with "num_mbm_cntrs" counters. Fixed typo in the subjest line. Fixed the handling error on first failure. Added domain id and event id on failure. Added new parameter event configuration (evt_cfg) to provide the event= from user space. v11: Moved the functions to monitor.c. Renamed rdtgroup_unassign_cntr_event() to resctrl_unassign_cntr_event(= ). Refactored the resctrl_unassign_cntr_event(). Updated commit message and code comments. v10: Patch changed again. Counters are managed at the domain based on the discussion. https://lore.kernel.org/lkml/CALPaoCj+zWq1vkHVbXYP0znJbe6Ke3PXPWjtri5A= FgD9cQDCUg@mail.gmail.com/ commit message update. v9: Changes related to addition of new function resctrl_config_cntr(). The removed rdtgroup_mbm_cntr_is_assigned() as it was introduced already. Text changes to take care comments. v8: Renamed rdtgroup_mbm_cntr_is_assigned to mbm_cntr_assigned_to_domain Added return error handling in resctrl_arch_config_cntr(). v7: Merged rdtgroup_unassign_cntr and rdtgroup_free_cntr functions. Renamed rdtgroup_mbm_cntr_test() to rdtgroup_mbm_cntr_is_assigned(). Reworded the commit log little bit. v6: Removed mbm_cntr_free from this patch. Added counter test in all the domains and free if it is not assigned to any domains. v5: Few name changes to match cntr_id. Changed the function names to rdtgroup_unassign_cntr More comments on commit log. v4: Added domain specific unassign feature. Few name changes. v3: Removed the static from the prototype of rdtgroup_unassign_abmc. The function is not called directly from user anymore. These changes are related to global assignment interface. v2: No changes. --- fs/resctrl/internal.h | 2 ++ fs/resctrl/monitor.c | 46 +++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 48 insertions(+) diff --git a/fs/resctrl/internal.h b/fs/resctrl/internal.h index 419423bdabdc..216588842444 100644 --- a/fs/resctrl/internal.h +++ b/fs/resctrl/internal.h @@ -389,6 +389,8 @@ int resctrl_find_cleanest_closid(void); =20 int rdtgroup_assign_cntr_event(struct rdt_mon_domain *d, struct rdtgroup *= rdtgrp, struct mon_evt *mevt); +void rdtgroup_unassign_cntr_event(struct rdt_mon_domain *d, struct rdtgrou= p *rdtgrp, + struct mon_evt *mevt); =20 #ifdef CONFIG_RESCTRL_FS_PSEUDO_LOCK int rdtgroup_locksetup_enter(struct rdtgroup *rdtgrp); diff --git a/fs/resctrl/monitor.c b/fs/resctrl/monitor.c index 8b0aa2469643..049a82729c0b 100644 --- a/fs/resctrl/monitor.c +++ b/fs/resctrl/monitor.c @@ -1023,6 +1023,14 @@ static int mbm_cntr_alloc(struct rdt_resource *r, st= ruct rdt_mon_domain *d, return -ENOSPC; } =20 +/* + * mbm_cntr_free() - Clear the counter ID configuration details in the dom= ain @d. + */ +static void mbm_cntr_free(struct rdt_mon_domain *d, int cntr_id) +{ + memset(&d->cntr_cfg[cntr_id], 0, sizeof(*d->cntr_cfg)); +} + /* * rdtgroup_alloc_assign_cntr() - Allocate a counter ID and assign it to t= he event * pointed to by @mevt and the resctrl group @rdtgrp within the domain @d. @@ -1083,3 +1091,41 @@ int rdtgroup_assign_cntr_event(struct rdt_mon_domain= *d, struct rdtgroup *rdtgrp =20 return ret; } + +/* + * rdtgroup_free_unassign_cntr() - Unassign and reset the counter ID confi= guration + * for the event pointed to by @mevt within the domain @d and resctrl grou= p @rdtgrp. + */ +static void rdtgroup_free_unassign_cntr(struct rdt_resource *r, struct rdt= _mon_domain *d, + struct rdtgroup *rdtgrp, struct mon_evt *mevt) +{ + int cntr_id; + + cntr_id =3D mbm_cntr_get(r, d, rdtgrp, mevt->evtid); + + /* If there is no cntr_id assigned, nothing to do */ + if (cntr_id < 0) + return; + + rdtgroup_assign_cntr(r, d, mevt->evtid, rdtgrp->mon.rmid, rdtgrp->closid,= cntr_id, false); + + mbm_cntr_free(d, cntr_id); +} + +/* + * rdtgroup_unassign_cntr_event() - Unassign a hardware counter associated= with + * the event structure @mevt from the domain @d and the group @rdtgrp. Una= ssign + * the counters from all the domains if @d is NULL else unassign from @d. + */ +void rdtgroup_unassign_cntr_event(struct rdt_mon_domain *d, struct rdtgrou= p *rdtgrp, + struct mon_evt *mevt) +{ + struct rdt_resource *r =3D resctrl_arch_get_resource(mevt->rid); + + if (!d) { + list_for_each_entry(d, &r->mon_domains, hdr.list) + rdtgroup_free_unassign_cntr(r, d, rdtgrp, mevt); + } else { + rdtgroup_free_unassign_cntr(r, d, rdtgrp, mevt); + } +} --=20 2.34.1 From nobody Mon Oct 6 01:21:11 2025 Received: from NAM12-DM6-obe.outbound.protection.outlook.com (mail-dm6nam12on2045.outbound.protection.outlook.com [40.107.243.45]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 3614B199EAD; Fri, 25 Jul 2025 18:33:35 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.243.45 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1753468418; cv=fail; b=Yo8e1W6LE8bAtK773rSUDtb8DuGBA5R0hSs5eUH1Bf0w3iNZdeK1fGhOK+slaILqmvjiUy1zYsXxvGEKxQD7n+QlL2xspomdsb501JyvMaE0NWWMGlxL57lsNo8uzvGA1L91vwioPhGfkMHdz3iNiZiFyyHBaMLG8+YvnQvhKzY= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1753468418; c=relaxed/simple; bh=HuWEcG4NICdpesohiR449qi1Sf9yhYxmoPIDp2xjX6s=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=peAsA+cjAzae22eofh4AdFjAhDlRrZRJdIFxJridS96c4YQORQ57ZtkcThxZuzDn4M6r6LIx45+OTwzrDWhLKe4OqlX0eaLrx10KI687pDkJJPrCdCgjIcYgz0zNIiioNbIALON9J2ObhYoHTTSjetB75Sr8jiyPBtrEpqGre9E= 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=aHr2X2eH; arc=fail smtp.client-ip=40.107.243.45 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=amd.com Authentication-Results: smtp.subspace.kernel.org; spf=fail smtp.mailfrom=amd.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=amd.com header.i=@amd.com header.b="aHr2X2eH" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=Fa/aD7EDTekUBFD2L0nUYMvVLJdJ7RJqxSrJqzNtgJ+RXHIiVW+97FtGDsX2xUXldVon1cU3nTcMMi8yjR1qTd9NCLqrCqUKPU/8ub1e83vO+27r2dKBqVEsuZL3pC1UnSECRded1Zye5XJRKIFA0A+QjNDMenMUHk5GQ9o/XbZ6ICl4+9M2hUHzD6P/kkV4CFpDXtxZrfJa6okCdWUqZ8pgqgIR68klBN0r8ay+V5/JJoEdz3yhAfmchF6cdqra8aD/zQrrNrse8nubMnUSgo8tGgafT+w7cVCraYpZ3c/fsteJlPNwDAHnfLeAqXNclKVK2rQM/J9LJVCGUXVtJA== 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=GmJpN5+1GR+I0peRdZXyDUFculqRydQ7F296FFgSmLI=; b=RI41nv94h7YwNnTwY1kgXn9uhkSYhXKIeWxfdj3nkGDZeuwpA3fHUZ8tlWlVDIvEVxF0pEc666MkvRVEXDffVGicHiEdoMqIp0zKwuqT/lfsxvx/W2moN3rSCYkjUKPejRQsQofZhr2A7xelJC7cbLJHrkBBkjSMAjAQ/+KSZHS51Ci1OBjBe5u2/4sXA5jEOJHW7bT7LSHkYEupU1AqsHfR4kEwDBva6wBq6o2hHtU+JxzI10XpDAHuAu6FnRlbeJMpofzxpxWBqbaxtXFnk0k4PnVdyeVS9769Qflwq/KeJ9WpFfYiIw2318fh4of/rCogktlrJhdv2JNId0R8gg== 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=GmJpN5+1GR+I0peRdZXyDUFculqRydQ7F296FFgSmLI=; b=aHr2X2eHVuxA4Fc8tXrF9bAVIu4/nUQ/5KTKtSc6L+OnMkF/ItVKOTKkA5ynYx4v4PeOEDz1Y86Iv9dGKUxnuz9E1Y2ri6TY8koygn3JNFbCEgPALBblh67hCVWGNxyOArN+uKpEx+eF8hLznXSmgqvFIWdZWfBDfnXxlU2s1VE= Received: from SJ0PR13CA0161.namprd13.prod.outlook.com (2603:10b6:a03:2c7::16) by LV2PR12MB5797.namprd12.prod.outlook.com (2603:10b6:408:17b::21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8943.28; Fri, 25 Jul 2025 18:33:33 +0000 Received: from CY4PEPF0000EE39.namprd03.prod.outlook.com (2603:10b6:a03:2c7:cafe::ea) by SJ0PR13CA0161.outlook.office365.com (2603:10b6:a03:2c7::16) with Microsoft SMTP Server (version=TLS1_3, cipher=TLS_AES_256_GCM_SHA384) id 15.20.8989.8 via Frontend Transport; Fri, 25 Jul 2025 18:33:32 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 165.204.84.17) smtp.mailfrom=amd.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=amd.com; Received-SPF: Pass (protection.outlook.com: domain of amd.com designates 165.204.84.17 as permitted sender) receiver=protection.outlook.com; client-ip=165.204.84.17; helo=SATLEXMB04.amd.com; pr=C Received: from SATLEXMB04.amd.com (165.204.84.17) by CY4PEPF0000EE39.mail.protection.outlook.com (10.167.242.11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.8964.20 via Frontend Transport; Fri, 25 Jul 2025 18:33:32 +0000 Received: from bmoger-ubuntu.amd.com (10.180.168.240) by SATLEXMB04.amd.com (10.181.40.145) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.39; Fri, 25 Jul 2025 13:33:29 -0500 From: Babu Moger To: , , , , , , , CC: , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , Subject: [PATCH v16 19/34] fs/resctrl: Pass struct rdtgroup instead of individual members Date: Fri, 25 Jul 2025 13:29:38 -0500 Message-ID: <69f3501ba0851befc47063b593c3d180a7f2fb87.1753467772.git.babu.moger@amd.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: References: Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-ClientProxiedBy: SATLEXMB03.amd.com (10.181.40.144) To SATLEXMB04.amd.com (10.181.40.145) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CY4PEPF0000EE39:EE_|LV2PR12MB5797:EE_ X-MS-Office365-Filtering-Correlation-Id: 58e22db4-2f81-4f8d-018e-08ddcba9c238 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?Zw6uTuGkFbruypNSQGwacr57pXM6sMJbm/JXiz4/m2a2WjPzJ6Mr+t6T4Sbf?= =?us-ascii?Q?mZFSExYTsWrOkKZldnmXmX1DZQyq3Z1big5lJ9de8wRDyOCLi+8qXZ3jElSH?= =?us-ascii?Q?AYdsX75yyOiyCLT67mSu2A+7TdgcGl/qFLWdgVKgj0Ew6cg0hoMRRdaSQU2g?= =?us-ascii?Q?cJNjij/9yFsJ22j4xgQ0TvIzSZaMqICzYt3+KsenNVarCrncg+mB61sdMg/m?= =?us-ascii?Q?hq7CFKakW+xh3WIjvX5mLb0oeR41z8EakshWFqHSqatjke6t3ItrJwmeMl83?= =?us-ascii?Q?EDXaHp0psxc4GWelLrptzjWKLY4/R5NrB7nKD7pNFsh5R2YQn1rOwYCumVk9?= =?us-ascii?Q?OKG6NFdViOcu01H/WoSGHJ1hC97l4cGoyCEE9LDO7O+F6jSBG748PpgdkOTP?= =?us-ascii?Q?2bAaPG0JtMYrruc2+pf5iRSxl5fwstE02I3UDCZ4nXaEpsGZbVFt526t0nY6?= =?us-ascii?Q?4/f2k1dhRGHbbptTH7Zw52xN8/2vSMstKR35lPQOpkguEZUVtFnB8UBoImf9?= =?us-ascii?Q?XC4wvHtSSN9Pl9oavi+hU4YyrdznVUL11zMRS8HaMuhrfbewzYwMQFglVxo5?= =?us-ascii?Q?lgQiy8EouciFcJbZgnSiF3ZrjjB+swhp9ECIo6O3Q00OWHJO6v0yfIC84XWm?= =?us-ascii?Q?QL0XmsIB5RnYf3zA5Ua+J/7A7pYY/jsOh3GBHmyhGlUd2g115hT7U3M4im36?= =?us-ascii?Q?nXkTaZfqjBvq7n9mT7SkCedI367Wp+dzBjG/kJmj51uODaDpzEA7JS0bsL7S?= =?us-ascii?Q?6KOVEnEqGWFn0dteLYbidDUsqspH3YjJNC/iDw2aDcTJjGgmlM9Le9A+2bHl?= =?us-ascii?Q?c2LEGYzW3v2ktSlp+nPZq/Yvx8W08whV1/WphrsAhfuEcuFhU8LaCkDvEi8I?= =?us-ascii?Q?El78tidlAxtdbqcaa8Ks2/UFg2+OWtrwIQP4f03/gmbvjzhCt8nTf824EmL5?= =?us-ascii?Q?LEFgieaif468MbCkq1xjthzGSZSsnuaqLcnjSKFvkjObrbaTILoJKcyIYWao?= =?us-ascii?Q?4W5uQTvaKsFYC9H7T2l4bMSvTklon0SzWSeT0Xa41q4sR9/uCfe8uq1eRi+Z?= =?us-ascii?Q?oCiF1y83vmW2SlXzPr+pB8yVc0F0vUnOCAbh1UtrO0PZAhvb23Zstggmp8tY?= =?us-ascii?Q?Z4dj1nFW/bvbe9YO4eXlU16q7DmG8jrhU3T3zR1S2Gqi7adfCNFTKzMvG63u?= =?us-ascii?Q?xnYLWQKV2VmWDuegqyeRjpSiRhpIxNwGg2U/BknbzLxy4urxg7pLqGdsesYy?= =?us-ascii?Q?Jin/By1+wHtCO+jFpvThv4nSI9CkJSr3v2rBTwm+gOPeMi+OnJxgEaphCvMd?= =?us-ascii?Q?Dj0Mgj3NyGtSy8xv7aH/gMedjTnUUkdpix3Eer+y2YDl8phLxMvmxvr0Cwjm?= =?us-ascii?Q?Pr/7usjDfEglAB/FbqAlVBuTihoeOIs6Iuzj55lwjVLu1Gu8dZwhIX6nlFii?= =?us-ascii?Q?pIJehKolKDi69p5XSu5sXI/eSpejHEms+hSRESwyBJMKKDlnIufIGQqTCzhT?= =?us-ascii?Q?qp03f/Bd0SSL6TGfY2E4rMN99OWGDBetXX6W?= 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: 25 Jul 2025 18:33:32.3934 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 58e22db4-2f81-4f8d-018e-08ddcba9c238 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: CY4PEPF0000EE39.namprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: LV2PR12MB5797 Content-Type: text/plain; charset="utf-8" Reading monitoring data for a monitoring group requires both the RMID and CLOSID. The RMID and CLOSID are members of struct rdtgroup but passed separately to several functions involved in retrieving event data. When "mbm_event" counter assignment mode is enabled, a counter ID is required to read event data. The counter ID is obtained through mbm_cntr_get(), which expects a struct rdtgroup pointer. Provide a pointer to the struct rdtgroup as parameter to functions involved in retrieving event data to simplify access to RMID, CLOSID, and counter ID. Suggested-by: Reinette Chatre Signed-off-by: Babu Moger Reviewed-by: Reinette Chatre --- v16: Minor code comment update. v15: Rephrased the changelog. Thanks to Reinette. v14: Few text update to commit log. v13: New patch to pass the entire struct rdtgroup to __mon_event_count(), mbm_update(), and related functions. --- fs/resctrl/monitor.c | 33 ++++++++++++++++++--------------- 1 file changed, 18 insertions(+), 15 deletions(-) diff --git a/fs/resctrl/monitor.c b/fs/resctrl/monitor.c index 049a82729c0b..070965d45770 100644 --- a/fs/resctrl/monitor.c +++ b/fs/resctrl/monitor.c @@ -356,9 +356,11 @@ static struct mbm_state *get_mbm_state(struct rdt_mon_= domain *d, u32 closid, return state ? &state[idx] : NULL; } =20 -static int __mon_event_count(u32 closid, u32 rmid, struct rmid_read *rr) +static int __mon_event_count(struct rdtgroup *rdtgrp, struct rmid_read *rr) { int cpu =3D smp_processor_id(); + u32 closid =3D rdtgrp->closid; + u32 rmid =3D rdtgrp->mon.rmid; struct rdt_mon_domain *d; struct cacheinfo *ci; struct mbm_state *m; @@ -420,8 +422,8 @@ static int __mon_event_count(u32 closid, u32 rmid, stru= ct rmid_read *rr) /* * mbm_bw_count() - Update bw count from values previously read by * __mon_event_count(). - * @closid: The closid used to identify the cached mbm_state. - * @rmid: The rmid used to identify the cached mbm_state. + * @rdtgrp: resctrl group associated with the CLOSID and RMID to identify + * the cached mbm_state. * @rr: The struct rmid_read populated by __mon_event_count(). * * Supporting function to calculate the memory bandwidth @@ -429,9 +431,11 @@ static int __mon_event_count(u32 closid, u32 rmid, str= uct rmid_read *rr) * __mon_event_count() is compared with the chunks value from the previous * invocation. This must be called once per second to maintain values in M= Bps. */ -static void mbm_bw_count(u32 closid, u32 rmid, struct rmid_read *rr) +static void mbm_bw_count(struct rdtgroup *rdtgrp, struct rmid_read *rr) { u64 cur_bw, bytes, cur_bytes; + u32 closid =3D rdtgrp->closid; + u32 rmid =3D rdtgrp->mon.rmid; struct mbm_state *m; =20 m =3D get_mbm_state(rr->d, closid, rmid, rr->evtid); @@ -460,7 +464,7 @@ void mon_event_count(void *info) =20 rdtgrp =3D rr->rgrp; =20 - ret =3D __mon_event_count(rdtgrp->closid, rdtgrp->mon.rmid, rr); + ret =3D __mon_event_count(rdtgrp, rr); =20 /* * For Ctrl groups read data from child monitor groups and @@ -471,8 +475,7 @@ void mon_event_count(void *info) =20 if (rdtgrp->type =3D=3D RDTCTRL_GROUP) { list_for_each_entry(entry, head, mon.crdtgrp_list) { - if (__mon_event_count(entry->closid, entry->mon.rmid, - rr) =3D=3D 0) + if (__mon_event_count(entry, rr) =3D=3D 0) ret =3D 0; } } @@ -603,7 +606,7 @@ static void update_mba_bw(struct rdtgroup *rgrp, struct= rdt_mon_domain *dom_mbm) } =20 static void mbm_update_one_event(struct rdt_resource *r, struct rdt_mon_do= main *d, - u32 closid, u32 rmid, enum resctrl_event_id evtid) + struct rdtgroup *rdtgrp, enum resctrl_event_id evtid) { struct rmid_read rr =3D {0}; =20 @@ -617,30 +620,30 @@ static void mbm_update_one_event(struct rdt_resource = *r, struct rdt_mon_domain * return; } =20 - __mon_event_count(closid, rmid, &rr); + __mon_event_count(rdtgrp, &rr); =20 /* * If the software controller is enabled, compute the * bandwidth for this event id. */ if (is_mba_sc(NULL)) - mbm_bw_count(closid, rmid, &rr); + mbm_bw_count(rdtgrp, &rr); =20 resctrl_arch_mon_ctx_free(rr.r, rr.evtid, rr.arch_mon_ctx); } =20 static void mbm_update(struct rdt_resource *r, struct rdt_mon_domain *d, - u32 closid, u32 rmid) + struct rdtgroup *rdtgrp) { /* * This is protected from concurrent reads from user as both * the user and overflow handler hold the global mutex. */ if (resctrl_is_mon_event_enabled(QOS_L3_MBM_TOTAL_EVENT_ID)) - mbm_update_one_event(r, d, closid, rmid, QOS_L3_MBM_TOTAL_EVENT_ID); + mbm_update_one_event(r, d, rdtgrp, QOS_L3_MBM_TOTAL_EVENT_ID); =20 if (resctrl_is_mon_event_enabled(QOS_L3_MBM_LOCAL_EVENT_ID)) - mbm_update_one_event(r, d, closid, rmid, QOS_L3_MBM_LOCAL_EVENT_ID); + mbm_update_one_event(r, d, rdtgrp, QOS_L3_MBM_LOCAL_EVENT_ID); } =20 /* @@ -713,11 +716,11 @@ void mbm_handle_overflow(struct work_struct *work) d =3D container_of(work, struct rdt_mon_domain, mbm_over.work); =20 list_for_each_entry(prgrp, &rdt_all_groups, rdtgroup_list) { - mbm_update(r, d, prgrp->closid, prgrp->mon.rmid); + mbm_update(r, d, prgrp); =20 head =3D &prgrp->mon.crdtgrp_list; list_for_each_entry(crgrp, head, mon.crdtgrp_list) - mbm_update(r, d, crgrp->closid, crgrp->mon.rmid); + mbm_update(r, d, crgrp); =20 if (is_mba_sc(NULL)) update_mba_bw(prgrp, d); --=20 2.34.1 From nobody Mon Oct 6 01:21:11 2025 Received: from NAM10-BN7-obe.outbound.protection.outlook.com (mail-bn7nam10on2052.outbound.protection.outlook.com [40.107.92.52]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 28CB024C66F; Fri, 25 Jul 2025 18:33:44 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.92.52 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1753468426; cv=fail; b=AHoLw0xO6f8uTm2/sU+QtR0txFc4CtJcbw1NJyLupAI6qlwqsGQSqUk0TGVa1iaAzoAPnuPXvcME3TZ4v6+o2Q2wO+xgBvWt8xriAHr1g33z+K1nThNpQYbJCMkXlx2w74akJL/Hhk/TRjvIGVD1jY0qzv7SemQY8YLuHy0hBgk= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1753468426; c=relaxed/simple; bh=kPuAWnadL2ztYRcSWyosPg+ssT34+hFBpgbt20qxhpI=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=sHq00fZljAgAf/Lnmz3v+j6nLUlkEwloIaRD1+FGV0/PRPGpCt4/umS2nYyBJSzp/tQnUJsWJMY8aZhBRih8J+UIF6+U0jyQX2rwJ6e+NcrCUdS2m3H/9Xo8/VGaBp0DOqB7abIqWFikDozjQKNH3dg5xBWDCT1PvGBH2/aqqtI= 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=ktdHbfRw; arc=fail smtp.client-ip=40.107.92.52 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=amd.com Authentication-Results: smtp.subspace.kernel.org; spf=fail smtp.mailfrom=amd.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=amd.com header.i=@amd.com header.b="ktdHbfRw" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=UTg8HbOmubWzPNo21L8/EFrUa+heXpS0rSTTj5GU8iVeTTEcxEHSDv32r/0n86QU/Y9Sl+LQOT8AfaOWqQpu1k4ZC9WyGKMx3+EFPA5N+5RuburyzMv1U7EDYd7Uo/kGE8+NogF/xeYC1m4mnffwTQm6pKMIWep0w4cVgBfD/2JRsGg+7ceJ7aCYf+AiGneqDnUWWmWkjRzgmhMqssomqJe7Rbm5j1u6wAEgpKB4IJZlfaSYaDYslVcXJlg0swLDr+E0x2+Io5N9SOpehYRQ4DpqEMEf18175z1/wsqjHYJXn2jmhG7xqnYH4xd5Oi/7oR6E146nBeHE9/imG8Hf3w== 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=7e/W5Ai75uYxciNIqix+0uhd70zevITYNySCFH+8myM=; b=XgNB0N8pAScD9sfTVZ7HTMk7NDZiWaISp1nrjGxZ6eqPsWkKKGcNbzWFp9TNYz8m5mAALCq9R8ysNXTr1P6lfoG5xh2YyKuLzO0hByHNgr/Rar7kBCuPri76Zow3wKybIQ2KhgDSexUZUjEGMgK7mhwUri6VwJKeHY6teH7E9bwLp7g8Ku8ek09LO2ebkmX6wqK4b6Y+QGt49OxaTzkLynjXjyj/30vl4/V9mYPD0flpbqU9F5QBhM6jzpnpAXdU0P5Lhdy2tOXXgtAdFcfyhqEMjWA4zHCmz+BqbN/WZNq0pFSqWoQqGR3EUJ6tjQZbFORUyymDxu7N+CDI+kNHyw== 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=7e/W5Ai75uYxciNIqix+0uhd70zevITYNySCFH+8myM=; b=ktdHbfRwBSFOMwSnd8uHcgpxst066tCLTUjhaDkTu7FTzAPQpFdHaPbq0SVaVwbUkEv1BNjYkvyFQ3MDLsu76QlE1FTygitCEcyMDhIFvQLGKAFgalUUSFsbLCFALQtA+cFjVIQMZAmWQupLD6gTjtGekEusPn8YF+ZJO4bpSoE= Received: from DS7PR03CA0319.namprd03.prod.outlook.com (2603:10b6:8:2b::27) by IA0PR12MB8840.namprd12.prod.outlook.com (2603:10b6:208:490::13) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8964.21; Fri, 25 Jul 2025 18:33:41 +0000 Received: from CY4PEPF0000EE3E.namprd03.prod.outlook.com (2603:10b6:8:2b:cafe::70) by DS7PR03CA0319.outlook.office365.com (2603:10b6:8:2b::27) with Microsoft SMTP Server (version=TLS1_3, cipher=TLS_AES_256_GCM_SHA384) id 15.20.8964.23 via Frontend Transport; Fri, 25 Jul 2025 18:33:41 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 165.204.84.17) smtp.mailfrom=amd.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=amd.com; Received-SPF: Pass (protection.outlook.com: domain of amd.com designates 165.204.84.17 as permitted sender) receiver=protection.outlook.com; client-ip=165.204.84.17; helo=SATLEXMB04.amd.com; pr=C Received: from SATLEXMB04.amd.com (165.204.84.17) by CY4PEPF0000EE3E.mail.protection.outlook.com (10.167.242.16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.8964.20 via Frontend Transport; Fri, 25 Jul 2025 18:33:41 +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; Fri, 25 Jul 2025 13:33:38 -0500 From: Babu Moger To: , , , , , , , CC: , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , Subject: [PATCH v16 20/34] fs/resctrl: Introduce counter ID read, reset calls in mbm_event mode Date: Fri, 25 Jul 2025 13:29:39 -0500 Message-ID: <518b133429018f8b2f51055cfc2342536df98b84.1753467772.git.babu.moger@amd.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: References: Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-ClientProxiedBy: SATLEXMB03.amd.com (10.181.40.144) To SATLEXMB04.amd.com (10.181.40.145) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CY4PEPF0000EE3E:EE_|IA0PR12MB8840:EE_ X-MS-Office365-Filtering-Correlation-Id: ddef93ba-f981-4dda-3eee-08ddcba9c779 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?vENrwaOX7OkBjyEzVyXNV3EBtdYCo1i8Atk8ATQYm1SXRv5EzoclgwLie/vv?= =?us-ascii?Q?x6vwsBLQZ5uUvrvzrJAnTKfY7j24iN92sLR/QDNDGyZnRB3SWP7cFMoDGLFu?= =?us-ascii?Q?HfNcF3Zeq9d/bdqCRHHs32kLSn+HX8Rp7zyozLYDYqPLKt5QQQLsAyYJAfJq?= =?us-ascii?Q?6cd5ptGuhfjBCl4iPWCn2FG3JsJSkKRp4rPBTLRh8Vs8H+OntYEBbrg15Ofs?= =?us-ascii?Q?cM7saVuIm7iuGSG7FLaXpEtAmsDEnK29sVZeBicMQn2uOp7pIW4+vvZGV+EW?= =?us-ascii?Q?X9zsp1/WPZsvSKg/TIyL9NLPhpYD81/rExb2B/g8WZ0c21f9lJsZ4OnHm2ft?= =?us-ascii?Q?plSTZNVICbB9OYTb4S4yqmI4zy5Ni16SWioj98dCfeMfN230H8OJbYj8tPag?= =?us-ascii?Q?W/ueiS9s2nANl4REbI7Cf9Kl8Yj+m2k+BEmtvaWuYlw+oT0vAph5hZFDhbvl?= =?us-ascii?Q?Gn/YBuAqoGmN+zU/qJyHBFCrfim2Q6Qetkeyr5zPOdb8DHENJgX4vpIQL3Te?= =?us-ascii?Q?eSFgLbxv4MfXDkkKjsoaKInfhVmMH+ickAuISAFjth+yZ0f/Dt3KpSvwJjw7?= =?us-ascii?Q?tgm91aUTzVPsOnO7PnS5n03oRKEa0X8OPy1Q/c9m08DM3YemXJo075lw2H47?= =?us-ascii?Q?E8QOJhkR5n9moK3Bbh5zJjFBXt4PzbypotKMTNPisQw2FdK8rrSP+XqfoeuZ?= =?us-ascii?Q?ko7YzJQoBMZvtAChuJV+CQBhVt49GIbhqIwsn3o0pb8tLLM8n5ZSgi5n7Q2J?= =?us-ascii?Q?91HFQ8KHmMk/W2YPc2kxeahjc+MGQK0/ozwdJj1UpG1xCXwi9cSEVYTDpN0P?= =?us-ascii?Q?+vO172zFgrSJfnWmighDgfXZildeHe37W7tVupq4sxktoS2y9Lc6Ot+7sE/j?= =?us-ascii?Q?/QV7o9toostgPno6y2DKAkf3vszN4hs2oKe2ZAmdkC64+3WmcL3blt80OfTe?= =?us-ascii?Q?HEl8xs/RbwN1sKO7kMof960Xf2mAL/5HTudOmQp31C5J+hJpPWUM8htr8QFX?= =?us-ascii?Q?RoVNj2ld+p2MHkMSrU1oS7X/AGA+paYIhcgbVf2jKdLsotDN0G7pVl38EdRo?= =?us-ascii?Q?3wU1S5DlGrVYO8pTElv/jOL7/tKqBBOydRDpN0FkkuPY2eKfE5kzZ7UsU1fh?= =?us-ascii?Q?dNCT9CCltmRUy9A4Vkvl8wYEXxn157iKL3vXkfxUqzMahLOmvsq4JHVd/B+c?= =?us-ascii?Q?kbaAU9Y58z8WsvmsjE2gWaGhqmvIktrAmArFrN94um7gA2riOGotnoqv7Spo?= =?us-ascii?Q?eqjBP1lfeQSA7exoHXwvX8Xcn2UzYs4H1FWZnCBRozU5+9Gyzc3fkgJS5fp8?= =?us-ascii?Q?OU3ZGBxrA1iM09fof6Y4OMEF+Vxa6Gdi4O2pWWy6igbSvm2orPaQQa/4Vv8T?= =?us-ascii?Q?BTLHReVvuPYwvQQwbSPwy8Ljq1pOwNQsFtWq4xOr1GkK56m8mIfmxbeW6FBu?= =?us-ascii?Q?qPvQ+8bOxyahbZucbuRRmHSqTzqUpRbC6kdUBd0aXOlBbLlj3DbibY6hS4Co?= =?us-ascii?Q?xNMmTRmlmlMyJulCi62ldiliKRZm7N6IGGaddveODzp+XEQeE1QgyfiaEg?= =?us-ascii?Q?=3D=3D?= X-Forefront-Antispam-Report: CIP:165.204.84.17;CTRY:US;LANG:en;SCL:1;SRV:;IPV:CAL;SFV:NSPM;H:SATLEXMB04.amd.com;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(13230040)(1800799024)(36860700013)(376014)(7416014)(82310400026);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 25 Jul 2025 18:33:41.2121 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: ddef93ba-f981-4dda-3eee-08ddcba9c779 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: CY4PEPF0000EE3E.namprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: IA0PR12MB8840 Content-Type: text/plain; charset="utf-8" When supported, "mbm_event" counter assignment mode allows users to assign a hardware counter to an RMID, event pair and monitor the bandwidth usage as long as it is assigned. The hardware continues to track the assigned counter until it is explicitly unassigned by the user. Introduce the architecture calls resctrl_arch_cntr_read() and resctrl_arch_reset_cntr() to read and reset event counters when "mbm_event" mode is supported. Function names are chosen to match existing resctrl_arch_rmid_read() and resctrl_arch_reset_rmid(). Suggested-by: Reinette Chatre Signed-off-by: Babu Moger --- v16: Updated the changelog. Removed lots of copied and unnecessary text from resctrl.h. Also removed references to LLC occupancy. Removed arch_mon_ctx from resctrl_arch_cntr_read(). v15: New patch to add arch calls resctrl_arch_cntr_read() and resctrl_arch_= reset_cntr() with mbm_event mode. https://lore.kernel.org/lkml/b4b14670-9cb0-4f65-abd5-39db996e8da9@inte= l.com/ --- include/linux/resctrl.h | 38 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) diff --git a/include/linux/resctrl.h b/include/linux/resctrl.h index 50e38445183a..4d37827121a6 100644 --- a/include/linux/resctrl.h +++ b/include/linux/resctrl.h @@ -613,6 +613,44 @@ void 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); =20 +/** + * resctrl_arch_cntr_read() - Read the event data corresponding to the cou= nter ID + * assigned to the RMID, event pair for this resource + * and domain. + * @r: Resource that the counter should be read from. + * @d: Domain that the counter should be read from. + * @closid: CLOSID that matches the RMID. + * @rmid: RMID used for counter ID assignment. + * @cntr_id: The counter ID whose event data should be read. Valid when + * "mbm_event" mode is enabled and @eventid is MBM event. + * @eventid: eventid used for counter ID assignment, such as + * QOS_L3_MBM_TOTAL_EVENT_ID or QOS_L3_MBM_LOCAL_EVENT_ID. + * @val: Result of the counter read in bytes. + * + * Return: + * 0 on success, or -EIO, -EINVAL etc on error. + */ +int resctrl_arch_cntr_read(struct rdt_resource *r, struct rdt_mon_domain *= d, + u32 closid, u32 rmid, int cntr_id, + enum resctrl_event_id eventid, u64 *val); + +/** + * resctrl_arch_reset_cntr() - Reset any private state associated with cou= nter ID. + * @r: The domain's resource. + * @d: The counter ID's domain. + * @closid: CLOSID that matches the RMID. + * @rmid: RMID used for counter ID assignment. + * @cntr_id: The counter ID whose event data should be reset. Valid when + * "mbm_event" mode is enabled and @eventid is MBM event. + * @eventid: eventid used for counter ID assignment, such as + * QOS_L3_MBM_TOTAL_EVENT_ID or QOS_L3_MBM_LOCAL_EVENT_ID. + * + * This can be called from any CPU. + */ +void resctrl_arch_reset_cntr(struct rdt_resource *r, struct rdt_mon_domain= *d, + u32 closid, u32 rmid, int cntr_id, + enum resctrl_event_id eventid); + extern unsigned int resctrl_rmid_realloc_threshold; extern unsigned int resctrl_rmid_realloc_limit; =20 --=20 2.34.1 From nobody Mon Oct 6 01:21:11 2025 Received: from NAM12-BN8-obe.outbound.protection.outlook.com (mail-bn8nam12on2073.outbound.protection.outlook.com [40.107.237.73]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id A4824248F63; Fri, 25 Jul 2025 18:33:54 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.237.73 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1753468436; cv=fail; b=D2yf7FrQrdVq4CXSMcrT6Q4Yh9LBPYipkDdbfJ2mtPSpMYpzpSgPU9lJ6y2ODHUKkozIxkdQSeYURMggQMw13CTFXAMXclzJqAoDf9xFQz7k0FecSxUtYcf+nYoaCAWLuqC79SOogGy1rF28Aw2wTjLMTKMTufJd/eRUn7Frsg8= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1753468436; c=relaxed/simple; bh=0risnTerhGp/LD/5z3gERoCt4qcWL46ROwYZLa2TFkQ=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=PZFhJqXeAkNUTodhJe4o6/s7/fin5DFugg+xdPBGglXg3NOCPQ7HNk+qTB3jaAcH/LCrZVctSVy2e8n8YWwsX0A+x1U+06ofindCEzsd+fl6zb4K4NTOnZR7iEJXcnK5Jcv8XyNPO+BsgeHx4GGQ5kQ7uHGbC1ksR+RBRpLZHXg= 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=kDMaj9kN; arc=fail smtp.client-ip=40.107.237.73 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=amd.com Authentication-Results: smtp.subspace.kernel.org; spf=fail smtp.mailfrom=amd.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=amd.com header.i=@amd.com header.b="kDMaj9kN" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=r4eXzG2LlVLtAdEPRxI2tRSflDJc7871vT21BMuK+cMdKo7CSBxH4aqPIr6CpP6YtsMBDFZFiaSbsIMfuFCfmlr/ELuEqVvsPoaAupOFRVHQlDCPQYrasHEtEdL4fNI1GBh5hmc8TvwCISw09BTgxDABxJH9zwmaELAKkcoo2Cu0mT/Ag4+1amT3x0QkdUEBkIEYR7JcwQnqmznIkGYku/ZG8QVvfC7BPqsaPt+1wFmQx9bOmAxwC+fA1Q+D9Y21iHLRXFjBrEhLErvOWl0ppa4Njo++YzdCGTtPlDML6Bkr6sh3fvvcn0DbTxg6EY77OsuVMPuRR5Up2kb5X1AGlQ== 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=S9gKkJjofAWqikVtSWW3pRfyB/deZmVkEAqjr1jpIZI=; b=C5ToDECbZmbXQHw+kSffTM28JdQSblqooo+hYQFuWukiUMnhoyXE69/khzN62flib2lnWiaWb2pvPV4W3ZEJASdnUMvwv9oiMjM52gd3O0ArPhQ5aX4wCaBIqFxW8p59Xdqfz4gu7bf9Rs00AM8raCwoCYrWZNmb252X3Fw14HGrVxq7otTAN1P6J3WDzQ0xaN/He4pm117TuQqXYE6FNjFQAbOmdr/i5Ul9qQyFc924zfmHc/8VJ8ZHleep2XnwBEmqPB4Ya2MX8mK9EoNfP0hOyQoq26Ew+/tS+gZeQ9MIfyA/VyQ/xEp7SaksThyvlOtEm/mK8fAkL8mKpxfYsw== 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=S9gKkJjofAWqikVtSWW3pRfyB/deZmVkEAqjr1jpIZI=; b=kDMaj9kNVeOVg+EqxgOhGtw71Be4pLvhRq/UDUVmnbE2QgeL5bufAhNL6MEWULNHIUF1mHwKFX1DKCl/nV85Z08cIj2OHEwZb/qL9z9o0tbVs4EHI58syJqzNflr5tfvrOjbU3S1swCTt1lTBZrmi6kj703JVw9qXWIpj6MC+7I= Received: from SJ0PR03CA0077.namprd03.prod.outlook.com (2603:10b6:a03:331::22) by LV8PR12MB9619.namprd12.prod.outlook.com (2603:10b6:408:2a1::15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8964.23; Fri, 25 Jul 2025 18:33:50 +0000 Received: from CY4PEPF0000EE3B.namprd03.prod.outlook.com (2603:10b6:a03:331:cafe::8b) by SJ0PR03CA0077.outlook.office365.com (2603:10b6:a03:331::22) with Microsoft SMTP Server (version=TLS1_3, cipher=TLS_AES_256_GCM_SHA384) id 15.20.8964.22 via Frontend Transport; Fri, 25 Jul 2025 18:33: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 CY4PEPF0000EE3B.mail.protection.outlook.com (10.167.242.14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.8964.20 via Frontend Transport; Fri, 25 Jul 2025 18:33:49 +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; Fri, 25 Jul 2025 13:33:47 -0500 From: Babu Moger To: , , , , , , , CC: , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , Subject: [PATCH v16 21/34] x86/resctrl: Refactor resctrl_arch_rmid_read() Date: Fri, 25 Jul 2025 13:29:40 -0500 Message-ID: <451c774e1865d53664f5eac612570f753679024d.1753467772.git.babu.moger@amd.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: References: Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-ClientProxiedBy: SATLEXMB03.amd.com (10.181.40.144) To SATLEXMB04.amd.com (10.181.40.145) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CY4PEPF0000EE3B:EE_|LV8PR12MB9619:EE_ X-MS-Office365-Filtering-Correlation-Id: 512b6abb-034e-41c1-23ab-08ddcba9ccab 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?70YEfJFD2g/DXjbVADV9w6OUtMj1xSFULgVzw+Xq0fvBvihNT4G0d42XyYK8?= =?us-ascii?Q?tQEYIhamCM5CUIMUtgpBXDxK0glxc/bQXQSJScYIID9Bewk8MvhcFDLxzEAr?= =?us-ascii?Q?HJLWznut9q22jqvk9T1pY80YTHLztdn32h4YRjoF1/vColtFH90HMRWHzaZX?= =?us-ascii?Q?yzz5TtU7MJGg5BfW24BgwoGOjmEn9wCpwv8iNPEJ22DlP7jr/TzgA0reiRi0?= =?us-ascii?Q?EZ7jkPgckDpYvmLHrw1MGCh502oO75hbQklqNhtlLuPBceeRkxqKv3dGv3tN?= =?us-ascii?Q?aeZ9SelV6koZnv1iGqKQoFui1ri01sBWu7lXgVXcVrhlXZHKu99T7s07RHXy?= =?us-ascii?Q?fmadCyx4PfSqdfQuuwgvEgLPiD8i7jG4+dvZpf4PGepk/QXNYBsH/w1kxAqp?= =?us-ascii?Q?rbJCYLH68+SubdMnYHk9OVXWNhCOv47Vjag4nFem2U8hx5hVnSzG3JdY+g80?= =?us-ascii?Q?mtPurEYe0b/H0VnT84fXCUllhqQuzHyxMUxIFdQCrr4+riXj2FphGMp6imvF?= =?us-ascii?Q?vfXUmftwzkHxlzZbna384avNUhXC1+rSMobUYlMVtOvWjLYD7ghx/yOI2yW5?= =?us-ascii?Q?wq16pDa0DJimleRoB/sMUOaIb/NdMaMcJKyjZ+PhHSG68uGdV7yGVkIbjgPg?= =?us-ascii?Q?/XgxCpvO8VPkq2wUecoxm3Vp6wwk2jgwHg6SKBR0cnSM6wXIvRKHqt1ITUqR?= =?us-ascii?Q?iovAPRGFmBAXXqqxOJZrSIMhUnYNphlKBhEqqxyRnm6l+wxMgyuy7LTyU7Ad?= =?us-ascii?Q?+WuNb4NQVCm2jumKgAWjxQJeNeOWNPiAFR6s754zOVAzdltunYXRNs2XqO4Q?= =?us-ascii?Q?IZAIed9a1NrqRXzTrO96iaBT6sRfqw7125Qo6PiQ8hwTBIkwfGeURjNxu+pU?= =?us-ascii?Q?hBbdZ6F8/3fIijVWpF5fJh2mkZmaE6DP0M3x6Qvw3g731U/GDYY5cqGX1aNj?= =?us-ascii?Q?YH2X/59rdEZ+TT1nla5L6hP/KveIOm+oXFbAF5st9eUxxe8zOhuFx5USx0yA?= =?us-ascii?Q?m+Js2trx/FbHJRTeNCrtxokylVI8+4jEvBssq5Yaqs/tOrXN8ZQdq+g7XimQ?= =?us-ascii?Q?2vu/ofl/Lgvqpryc65BaWx/UTHEJE4UnyM6yLEZhFwc7vfFN6q3x5XvKOa4Q?= =?us-ascii?Q?pljtGhguemLpfOEjLrllBWy82NKBeO4tSm3GdZWmYjqUgSNiwQ97ZjVFL021?= =?us-ascii?Q?OHNXfI6n7g/aSFSBl5m4RT6YbkS2KJRYtQE7hpVxHckqPTRW9wYZQnhuPcdq?= =?us-ascii?Q?zsFhU5WyvLkFpqvAoa+Isi5c/oo92U+cjdcoeOyVscWoYSEN6OVU149KJlh8?= =?us-ascii?Q?lakEWmTHxrgmUSXOGBV4sKXO+GzC/DLjdhzGxEEmB8JMd4paYKHF43BwV8AE?= =?us-ascii?Q?dQq3RXZesaOCecoYi0IRDQCyk4WEwzY13/y+3te0bkB8eVYlstS3DbPC32Hu?= =?us-ascii?Q?V7WTUcvaYpPJ0G22rikoegCKWycQjJ5rsZBi8yPiJXpLa08Fcc+lmV6/5mw6?= =?us-ascii?Q?lpXuE3zrEAvuN5YDvmjj3Pez8kWH/XnRo6nzLvGtvDeHEZNkWKFTjjhv/g?= =?us-ascii?Q?=3D=3D?= X-Forefront-Antispam-Report: CIP:165.204.84.17;CTRY:US;LANG:en;SCL:1;SRV:;IPV:CAL;SFV:NSPM;H:SATLEXMB04.amd.com;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(13230040)(82310400026)(36860700013)(376014)(7416014)(1800799024);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 25 Jul 2025 18:33:49.9268 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 512b6abb-034e-41c1-23ab-08ddcba9ccab 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: CY4PEPF0000EE3B.namprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: LV8PR12MB9619 Content-Type: text/plain; charset="utf-8" resctrl_arch_rmid_read() adjusts the value obtained from MSR_IA32_QM_CTR to account for the overflow for MBM events and apply counter scaling for all the events. This logic is common to both reading an RMID and reading a hardware counter directly. Refactor the hardware value adjustment logic into get_corrected_val() to prepare for support of reading a hardware counter. Signed-off-by: Babu Moger Reviewed-by: Reinette Chatre --- v16: Rephrased the changelog. Fixed allignment. Renamed mbm_corrected_val() -> get_corrected_val(). v15: New patch to add arch calls resctrl_arch_cntr_read() and resctrl_arch_= reset_cntr() with mbm_event mode. https://lore.kernel.org/lkml/b4b14670-9cb0-4f65-abd5-39db996e8da9@inte= l.com/ --- arch/x86/kernel/cpu/resctrl/monitor.c | 38 ++++++++++++++++----------- 1 file changed, 23 insertions(+), 15 deletions(-) diff --git a/arch/x86/kernel/cpu/resctrl/monitor.c b/arch/x86/kernel/cpu/re= sctrl/monitor.c index ed295a6c5e66..1f77fd58e707 100644 --- a/arch/x86/kernel/cpu/resctrl/monitor.c +++ b/arch/x86/kernel/cpu/resctrl/monitor.c @@ -217,24 +217,13 @@ static u64 mbm_overflow_count(u64 prev_msr, u64 cur_m= sr, unsigned int width) return chunks >> shift; } =20 -int resctrl_arch_rmid_read(struct rdt_resource *r, struct rdt_mon_domain *= d, - u32 unused, u32 rmid, enum resctrl_event_id eventid, - u64 *val, void *ignored) +static u64 get_corrected_val(struct rdt_resource *r, struct rdt_mon_domain= *d, + u32 rmid, enum resctrl_event_id eventid, u64 msr_val) { struct rdt_hw_mon_domain *hw_dom =3D resctrl_to_arch_mon_dom(d); struct rdt_hw_resource *hw_res =3D resctrl_to_arch_res(r); - int cpu =3D cpumask_any(&d->hdr.cpu_mask); struct arch_mbm_state *am; - u64 msr_val, chunks; - u32 prmid; - int ret; - - resctrl_arch_rmid_read_context_check(); - - prmid =3D logical_rmid_to_physical_rmid(cpu, rmid); - ret =3D __rmid_read_phys(prmid, eventid, &msr_val); - if (ret) - return ret; + u64 chunks; =20 am =3D get_arch_mbm_state(hw_dom, rmid, eventid); if (am) { @@ -246,7 +235,26 @@ int resctrl_arch_rmid_read(struct rdt_resource *r, str= uct rdt_mon_domain *d, chunks =3D msr_val; } =20 - *val =3D chunks * hw_res->mon_scale; + return chunks * hw_res->mon_scale; +} + +int resctrl_arch_rmid_read(struct rdt_resource *r, struct rdt_mon_domain *= d, + u32 unused, u32 rmid, enum resctrl_event_id eventid, + u64 *val, void *ignored) +{ + int cpu =3D cpumask_any(&d->hdr.cpu_mask); + u64 msr_val; + u32 prmid; + int ret; + + resctrl_arch_rmid_read_context_check(); + + prmid =3D logical_rmid_to_physical_rmid(cpu, rmid); + ret =3D __rmid_read_phys(prmid, eventid, &msr_val); + if (ret) + return ret; + + *val =3D get_corrected_val(r, d, rmid, eventid, msr_val); =20 return 0; } --=20 2.34.1 From nobody Mon Oct 6 01:21:11 2025 Received: from NAM10-DM6-obe.outbound.protection.outlook.com (mail-dm6nam10on2048.outbound.protection.outlook.com [40.107.93.48]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 17C2C248F63; Fri, 25 Jul 2025 18:34:02 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.93.48 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1753468444; cv=fail; b=sekmAw6Le5K8bRLsyVLsCyAQG8PE+MXTqZoZYKoPXWTjgTYk41SheM4qicaYShD0k4SgB+anMqbd1i40sodhy1BarFgTUWjk7cUIOdFjklmPYxrI6BhKEmh04fSuHSsxdL2rUutJlLFotseZkO95YgTrJi8J5ZbfXpymYWHqPKs= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1753468444; c=relaxed/simple; bh=S8oVp6bsB6adPGioc6Nje2I4ibyDx76f0SsFIRvIYsk=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=MwzYqH4KV4VoUVBPMwstZZfHPyrVd+k48iot0myPR52IcEL/0Za+Wduvzvl68r0w9W5R/xq/BClFDqpb60qu09aGoFxQhp+8p6Sg7OXDbb9Vo4w3/1oaD7FJHDWH+wiFS4ous79CfaScHN96uf8C1tqrxuCZ2Kwml7pbjlVzQqQ= 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=yLxfAdqi; arc=fail smtp.client-ip=40.107.93.48 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=amd.com Authentication-Results: smtp.subspace.kernel.org; spf=fail smtp.mailfrom=amd.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=amd.com header.i=@amd.com header.b="yLxfAdqi" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=uIeadYealoa5YZH8gjCAQmpW6ojvRmhKsxfVfh/e3K1NF2EoCiEGJs9aSgnNVHbTflQAwonlIKBH9UUsnRhQw40msZMl/i94L4GkDRve09M8hnRJli3ZbmhU0tHZV/2j8UQR4az9yvkVpHmKFaAxeAcBQ/LqY+C9dJNGAB4P1/T87VjKrBgEOg+3QIivs2dy4fh0x49Kxmxg8ddkoNjK8gV8grvFRS3sUAHux+781XmugbhGekFQxWtmPFmgW3aSfxZFFyjd76jRTdCmMwsJEiUhQhR2HeXEvSilN0fcu6pecM+0ulfGtg0J+h62q02J/xjnkHQRUff8EbRd3G8LLw== 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=Gtdt9CAuvDML89r8vaBVSDFriuH/zRrwPGrQr7FvW7M=; b=wYDa6CKXPN/wd0lXRljHNu7GQrnns6GIqIX1hOvI2q3ze4gKUVotxDLeFsXYcedraUQzZKPDIdn3uPKQbo4UoHOPRKsYEOENQlIKMIF5fzoRnMxVb3y4eArH47m8aIu/mOptXnOlOIn/UP/OipThMTyQ9eprUpPjwgjE53XPrUe1CFvu0fXwqrBphqIbbgOunf1ARjs+/9Ac7lJMcatBi8+pUyx6o1Srj+UfV8djPoEBI+9NZaoTZMp4/LAv4370HFJvze4LwfmfFwXwrYj12uPwCz5JKe9fLZp1VGPWfFdfAuiDccStrJ/aUUTNeLbzvDm/KE2S9cIxqOeaLKqw0w== 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=Gtdt9CAuvDML89r8vaBVSDFriuH/zRrwPGrQr7FvW7M=; b=yLxfAdqio4xs5OyQiS1UOtE+cvaNww4ImIaqcM1XiQtBjYA0pDeOxXsIluek5S23KhbQPCz0v/lpuNisc/XewXBkkQ7DdIOrOWD4IuDPcELLBGsoX+s6jcsDyIUhPAN9yP+9nEm2e5/0GJR/in6dzmqTgNteSBgb4EibiYXslIY= Received: from SJ0PR03CA0070.namprd03.prod.outlook.com (2603:10b6:a03:331::15) by DS7PR12MB6239.namprd12.prod.outlook.com (2603:10b6:8:95::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8964.22; Fri, 25 Jul 2025 18:33:59 +0000 Received: from CY4PEPF0000EE3B.namprd03.prod.outlook.com (2603:10b6:a03:331:cafe::f9) by SJ0PR03CA0070.outlook.office365.com (2603:10b6:a03:331::15) with Microsoft SMTP Server (version=TLS1_3, cipher=TLS_AES_256_GCM_SHA384) id 15.20.8964.24 via Frontend Transport; Fri, 25 Jul 2025 18:33:58 +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 CY4PEPF0000EE3B.mail.protection.outlook.com (10.167.242.14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.8964.20 via Frontend Transport; Fri, 25 Jul 2025 18:33: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; Fri, 25 Jul 2025 13:33:56 -0500 From: Babu Moger To: , , , , , , , CC: , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , Subject: [PATCH v16 22/34] x86/resctrl: Implement resctrl_arch_reset_cntr() and resctrl_arch_cntr_read() Date: Fri, 25 Jul 2025 13:29:41 -0500 Message-ID: X-Mailer: git-send-email 2.34.1 In-Reply-To: References: Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-ClientProxiedBy: SATLEXMB03.amd.com (10.181.40.144) To SATLEXMB04.amd.com (10.181.40.145) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CY4PEPF0000EE3B:EE_|DS7PR12MB6239:EE_ X-MS-Office365-Filtering-Correlation-Id: 180a1bb7-deeb-4e81-68cb-08ddcba9d1e5 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|7416014|376014|36860700013|82310400026|1800799024; X-Microsoft-Antispam-Message-Info: =?us-ascii?Q?hlCoypHamp7mpxeWCJPZVF60UXEAu/gEPvWegvscu/VrmsXP0KScTwixOux1?= =?us-ascii?Q?WiMkcWbsG/AEFvhbenp6XcsZCBCgf20PDNL0jYp/8xc6L2G421jUOfjhLM5b?= =?us-ascii?Q?SA7dHlSy3rpWgagxVf4ScJnoh570ZTp3mfWjB/+S9fH1r18xuWmavgM1AXTp?= =?us-ascii?Q?LjGSEjLyNpciCCeyGRQuofJRAljhk3pwadREXUohckqTCEkRC2Xhmhse745C?= =?us-ascii?Q?so945fYPpP+6Ifjj4eXdgmRDaX+T5ezpNUd0Gbq/HKqjkVYpczqXSI9nFiEj?= =?us-ascii?Q?HusEfivO8tQhXYhxVaOtL/tnpJdzSxLgPDo87x9Dl5Oj80LySLA4Dy+ujJyZ?= =?us-ascii?Q?tloRt5+LiJ6IJ+poQGbcXbeL8s0ngZbmgGsR70DP+bNPsvWXe0T8IjLOiw/L?= =?us-ascii?Q?nLL5R7dqk+MqEg0djXwKiWKsDDy7AopqSGgcFdlQhlunVkJNl1hzhbikZlko?= =?us-ascii?Q?xl54fp8axDRWQU3aUnwJHHr35gNcPW3P7WnolzSQePl/HnZhI4hUUGccCSHr?= =?us-ascii?Q?t3HrdUYHc6lKG7ke+R58cgCNHi82/TpZVtPTia44T/pRj/CNpbFDuhJhmSb9?= =?us-ascii?Q?XCXnefplr6i+xHo/n+AvVGu4VPuf+sutqKxtRPYg20VA9wqMaRJ09pWAv643?= =?us-ascii?Q?lKPun33Z+ja6abWKJzJjpdxMj6D6IYyVQN5RRWL9HEIaniI2OPZnO/T2nhmo?= =?us-ascii?Q?pi1nyYQklCPJ53va2SXOflWCXCuJE6ln9OJZr2aqov/FzGkhYeCAymIL3zut?= =?us-ascii?Q?22EzJGsb3sFItHqNEBj94jXAucAwMtkipQyZyYeyOMW5oQduCHHJO/6D//qa?= =?us-ascii?Q?032dmB63mWp5KfJc/NRbmUKR7ksMCZH+WixnR1kDIWkShtdwy5ahRVjECE9i?= =?us-ascii?Q?1c91n1ggvQQoy4howTwJPGcAHq+/GeDtrku8fiyfUC9VUum5zq3hKYVe59JX?= =?us-ascii?Q?xvLBsdSnNE9AeYFIFrdRFu79s6Yqnm11ZARRqhjb1W+QIAhRopXTbt+jdHa7?= =?us-ascii?Q?8li+HliMufPCNe/Ukt3+cCe5IOjVF6H1JnQipWcxGLLCsKEL18TkzIx/f19D?= =?us-ascii?Q?2ZFl5dfmtHHtmXO5uF6qxT6mwtKQokxn3yxPEcJJUfjDdAid6ixGjuycsHoo?= =?us-ascii?Q?4FamBkQeDIWmugbZh7HT9Tpr0RtCL+rsuMvsvD2vt9xpX8042XPJewsjlkEY?= =?us-ascii?Q?j1PqfUAMaBGYnrQfL1b7Ew81sIDurn9z7h6gOGzaI7WXkyZw/YHNwDWGxTIU?= =?us-ascii?Q?uSiI7rrAFH6vQsCRxf3/YymkxsehrzKhvQw7ZdOx8aXFki5/pUMy3V8HhmZ/?= =?us-ascii?Q?pT/Cnf7NLKw/PszX6U1MS6mmWK/6ynewcUoAmFQ96QTUvbP9M6+7k8p7K41c?= =?us-ascii?Q?ZIMQ3EV6iis3py3CZXOIIo52Zrq0ntRuUh26zOA50tgm4rI3k3QIPWQMGnOL?= =?us-ascii?Q?Fmyr8ejkixXVm635HcNUwBKiG4qzm0cXHiW80OII5LRWMVS4eJ+PIifMKOvb?= =?us-ascii?Q?ZEBPOlEJRyiEUHj3hAkqFn1+2JX307n6FuBk5+jJK0GGcMBI2oUXZsrf0g?= =?us-ascii?Q?=3D=3D?= X-Forefront-Antispam-Report: CIP:165.204.84.17;CTRY:US;LANG:en;SCL:1;SRV:;IPV:CAL;SFV:NSPM;H:SATLEXMB04.amd.com;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(13230040)(7416014)(376014)(36860700013)(82310400026)(1800799024);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 25 Jul 2025 18:33:58.6974 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 180a1bb7-deeb-4e81-68cb-08ddcba9d1e5 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: CY4PEPF0000EE3B.namprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DS7PR12MB6239 Content-Type: text/plain; charset="utf-8" System software can read resctrl event data for a particular resource by writing the RMID and Event Identifier (EvtID) to the QM_EVTSEL register and then reading the event data from the QM_CTR register. In ABMC mode, the event data of a specific counter ID can be read by setting the following fields: QM_EVTSEL.ExtendedEvtID =3D 1, QM_EVTSEL.EvtID =3D L3CacheABMC (=3D1) and setting [RMID] to the desired counter ID. Reading QM_CTR will then return the contents of the specified counter ID. The RMID_VAL_ERROR bit will be set if the counter configuration was invalid, or if an invalid counter ID was set in the QM_EVTSEL[RMID] field. If the counter data is currently unavailable, the RMID_VAL_UNAVAIL bit will be set. Introduce resctrl_arch_reset_cntr() and resctrl_arch_cntr_read() to reset and read event data for a specific counter. Signed-off-by: Babu Moger --- v16: Updated the changelog. Removed the call resctrl_arch_rmid_read_context_check(); Added the text about RMID_VAL_UNAVAIL error. v15: Updated patch to add arch calls resctrl_arch_cntr_read() and resctrl_a= rch_reset_cntr() with mbm_event mode. https://lore.kernel.org/lkml/b4b14670-9cb0-4f65-abd5-39db996e8da9@inte= l.com/ v14: Updated the context in changelog. Added text in imperative tone. Added WARN_ON_ONCE() when cntr_id < 0. Improved code documentation in include/linux/resctrl.h. Added the check in mbm_update() to skip overflow handler when counter = is unassigned. v13: Split the patch into 2. First one to handle the passing of rdtgroup st= ructure to few functions( __mon_event_count and mbm_update(). Second one to handle AB= MC counter reading. Added new function __cntr_id_read_phys() to handle ABMC event reading. Updated kernel doc for resctrl_arch_reset_rmid() and resctrl_arch_rmid= _read(). Resolved conflicts caused by the recent FS/ARCH code restructure. The monitor.c file has now been split between the FS and ARCH director= ies. v12: New patch to support extended event mode when ABMC is enabled. --- arch/x86/kernel/cpu/resctrl/internal.h | 6 +++ arch/x86/kernel/cpu/resctrl/monitor.c | 68 ++++++++++++++++++++++++++ 2 files changed, 74 insertions(+) diff --git a/arch/x86/kernel/cpu/resctrl/internal.h b/arch/x86/kernel/cpu/r= esctrl/internal.h index 6bf6042f11b6..ae4003d44df4 100644 --- a/arch/x86/kernel/cpu/resctrl/internal.h +++ b/arch/x86/kernel/cpu/resctrl/internal.h @@ -40,6 +40,12 @@ struct arch_mbm_state { /* Setting bit 0 in L3_QOS_EXT_CFG enables the ABMC feature. */ #define ABMC_ENABLE_BIT 0 =20 +/* + * Qos Event Identifiers. + */ +#define ABMC_EXTENDED_EVT_ID BIT(31) +#define ABMC_EVT_ID BIT(0) + /** * struct rdt_hw_ctrl_domain - Arch private attributes of a set of CPUs th= at share * a resource for a control function diff --git a/arch/x86/kernel/cpu/resctrl/monitor.c b/arch/x86/kernel/cpu/re= sctrl/monitor.c index 1f77fd58e707..57c8409a8247 100644 --- a/arch/x86/kernel/cpu/resctrl/monitor.c +++ b/arch/x86/kernel/cpu/resctrl/monitor.c @@ -259,6 +259,74 @@ int resctrl_arch_rmid_read(struct rdt_resource *r, str= uct rdt_mon_domain *d, return 0; } =20 +static int __cntr_id_read(u32 cntr_id, u64 *val) +{ + u64 msr_val; + + /* + * QM_EVTSEL Register definition: + * =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D + * Bits Mnemonic Description + * =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D + * 63:44 -- Reserved + * 43:32 RMID Resource Monitoring Identifier + * 31 ExtEvtID Extended Event Identifier + * 30:8 -- Reserved + * 7:0 EvtID Event Identifier + * =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D + * The contents of a specific counter can be read by setting the + * following fields in QM_EVTSEL.ExtendedEvtID(=3D1) and + * QM_EVTSEL.EvtID =3D L3CacheABMC (=3D1) and setting [RMID] to the + * desired counter ID. Reading QM_CTR will then return the + * contents of the specified counter. The RMID_VAL_ERROR bit will + * be set if the counter configuration was invalid, or if an invalid + * counter ID was set in the QM_EVTSEL[RMID] field. If the counter + * data is currently unavailable, the RMID_VAL_UNAVAIL bit will be set. + */ + wrmsr(MSR_IA32_QM_EVTSEL, ABMC_EXTENDED_EVT_ID | ABMC_EVT_ID, cntr_id); + rdmsrl(MSR_IA32_QM_CTR, msr_val); + + if (msr_val & RMID_VAL_ERROR) + return -EIO; + if (msr_val & RMID_VAL_UNAVAIL) + return -EINVAL; + + *val =3D msr_val; + return 0; +} + +void resctrl_arch_reset_cntr(struct rdt_resource *r, struct rdt_mon_domain= *d, + u32 unused, u32 rmid, int cntr_id, + enum resctrl_event_id eventid) +{ + struct rdt_hw_mon_domain *hw_dom =3D resctrl_to_arch_mon_dom(d); + struct arch_mbm_state *am; + + am =3D get_arch_mbm_state(hw_dom, rmid, eventid); + if (am) { + memset(am, 0, sizeof(*am)); + + /* Record any initial, non-zero count value. */ + __cntr_id_read(cntr_id, &am->prev_msr); + } +} + +int resctrl_arch_cntr_read(struct rdt_resource *r, struct rdt_mon_domain *= d, + u32 unused, u32 rmid, int cntr_id, + enum resctrl_event_id eventid, u64 *val) +{ + u64 msr_val; + int ret; + + ret =3D __cntr_id_read(cntr_id, &msr_val); + if (ret) + return ret; + + *val =3D get_corrected_val(r, d, rmid, eventid, msr_val); + + return 0; +} + /* * The power-on reset value of MSR_RMID_SNC_CONFIG is 0x1 * which indicates that RMIDs are configured in legacy mode. --=20 2.34.1 From nobody Mon Oct 6 01:21:11 2025 Received: from NAM10-DM6-obe.outbound.protection.outlook.com (mail-dm6nam10on2059.outbound.protection.outlook.com [40.107.93.59]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 476E724A079; Fri, 25 Jul 2025 18:34:10 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.93.59 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1753468453; cv=fail; b=EMlOIPHOzB52J/YHZJrUK8VIp09tQ5rF8Eo35ZSOQDxxoaXbpLSz7pFCsszy177eHWVWXTnAjZZAxr4BzRTWuOoIZ7hbF2MGkViFVvTdNyeFMJWvGRLOUhEt1xUtf9P0VNIS+k4xDqNGFH7SfBVjye+zEvCZh2wz1khlQzWNuG0= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1753468453; c=relaxed/simple; bh=sU1vvfzhAmGSsqlKumwHjntKx040a1oxdDh7YKJYbE8=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=ADpy23k4Lkll3qK7bODhbPxqfErQFUf2Ra4KZTr3mWHzpOUaBNbsfyxolJI8o+GG03SrtmvK1vwSJ0ZbmmQBpI7kX8SDUSi3zX5TGafb6+yIEdvDXvxQUorUKslzE6JcdwNlpAlWRO0nD6DM40AyH9XK6JOAJAMMpaqnI0mK1Fk= 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=iwl8TMe9; arc=fail smtp.client-ip=40.107.93.59 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=amd.com Authentication-Results: smtp.subspace.kernel.org; spf=fail smtp.mailfrom=amd.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=amd.com header.i=@amd.com header.b="iwl8TMe9" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=EZ6B5FUe8AYpxOhZMXbqCzcvX/6rG9BFiqJ0KPA9+2WeZQWFU18AdEq/o251x+HGuQKtTe5fD3M5jX0KN+vFJPth261bmVhQrGPaGzHY4/U43CsoCVBwcjJ8UlDQxYYzyUtTt+sPqQr1HsdnQvoh/8J137I0uOjcc3uJ7qnivBhKqFM/32l/00weYIFhvd1xZMOI/EQlwlHLh3vd8O/73rIY8LO7wyCbT4tk3/j8xDfq8Te9oEoU762np7TZdEqawtNKpv4yrhR3uQNv+WzzwwzDVEbSyOYfuIYwBUZGPnyWuJG7u3mwV25oNgFiaeAp0XeQjfOpTDpXZyXe04WtnA== 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=5t7GOKxTBKUiVLnIhSfR+k0MYlS4m7Y+jKTBXsaUAi4=; b=sqfqLPFEVOJ1T0XsnXyYntyTKRPx3wFGGr6Xy0h+NerS3UfLMMDlex1d6MU+wojn8dFVLoD5Jvva+MT+WTBPLUwknlgpRGVnbf0+Mbaphb/7XkTugqJ51+WLz71KJMqAB/f8/P1na5NsKY4LTTIjvKes7q5a1uiqCGwXeKXWvzFTWK9bIS4fPQjOAGegnDZkURM7LltdhQU6BAMUNdg28fYoK+gOeatuUHsvapk1letVD8i4v8WFjZq5lJIp8ILeQARFi3ptx1Hm8/l5v3PEtAQ0o/JHBYH5DXvZPJNglC+KYE1zir8gSxZ8AhkK0r1UXJdAE8JxWM69RKXndwyu7A== 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=5t7GOKxTBKUiVLnIhSfR+k0MYlS4m7Y+jKTBXsaUAi4=; b=iwl8TMe9HaAXyeHjqZ8RWVcNG0XoQoLBdQYPowRUVGQzf8ymxiQqcNREGgU9eeX9tSDtCQuKSq/19JR4ku+8Ccb60yh5iOT3k5F2Vk7bcaFzW35FikEBw+ox2lWeXiuT5e/+UwaH7MBh3ua74+qqwd8UBCfMyKqEaf2r14Tc5G8= Received: from BYAPR11CA0095.namprd11.prod.outlook.com (2603:10b6:a03:f4::36) by DS7PR12MB6333.namprd12.prod.outlook.com (2603:10b6:8:96::15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8964.21; Fri, 25 Jul 2025 18:34:08 +0000 Received: from CY4PEPF0000EE3D.namprd03.prod.outlook.com (2603:10b6:a03:f4:cafe::32) by BYAPR11CA0095.outlook.office365.com (2603:10b6:a03:f4::36) with Microsoft SMTP Server (version=TLS1_3, cipher=TLS_AES_256_GCM_SHA384) id 15.20.8964.22 via Frontend Transport; Fri, 25 Jul 2025 18:34: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 CY4PEPF0000EE3D.mail.protection.outlook.com (10.167.242.15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.8964.20 via Frontend Transport; Fri, 25 Jul 2025 18:34: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; Fri, 25 Jul 2025 13:34:04 -0500 From: Babu Moger To: , , , , , , , CC: , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , Subject: [PATCH v16 23/34] fs/resctrl: Support counter read/reset with mbm_event assignment mode Date: Fri, 25 Jul 2025 13:29:42 -0500 Message-ID: X-Mailer: git-send-email 2.34.1 In-Reply-To: References: Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-ClientProxiedBy: SATLEXMB03.amd.com (10.181.40.144) To SATLEXMB04.amd.com (10.181.40.145) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CY4PEPF0000EE3D:EE_|DS7PR12MB6333:EE_ X-MS-Office365-Filtering-Correlation-Id: 0fc21c01-c28e-4202-34d6-08ddcba9d71e 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?JVvC6vLYka9bpM5ws/zPwuwaCxwKXFnz/LLIe2uTmPFbFY/JCfLN05nuhRM3?= =?us-ascii?Q?9ZUYtk7RO2386FSEFlzcu0RGOHeprEP8vNvRwWPJM6i5FB+tEIJCjOB2YUPl?= =?us-ascii?Q?qX7B6y01DNrM91yZYAQ3YDh/RhLalH9Wm4KntNfnL3Tt8YQCGLpJkcQpyMIb?= =?us-ascii?Q?nxfo1E71QpzuuraywN888IXbI6lnKCn1dMu3wmv9sphnGFiKFNfvqX+6HW5u?= =?us-ascii?Q?/hn5kOLpLcHJ28hE0Mj22Kk76Cb4Y6IQYBukb7vT/QtC4rVgDzTUU3w6MJiO?= =?us-ascii?Q?jIeJIGxw9Mqx+8qLBSj+G0YPs6XZdkBAqNFZPCByrp+bOnHchcaKx5eyGQCh?= =?us-ascii?Q?4Cfq1Q+zupDZIUbcZFu1RqvjVQeePm57IOyus3qtWuzpAB84cQI45xfnfa1f?= =?us-ascii?Q?dd5f45athsQlZBsuNnTNY1mdK/t3yxcfjH0ug4bdX88/qX9n6iJqXdp1HplY?= =?us-ascii?Q?NcAYrJSjF0pJLMFHwIYr+1rujHRd3FzJUJsmXPVLkFnkePtF8jqV9EvHM57k?= =?us-ascii?Q?0JlbkNcp8+TVOwfh2jPnzth8Ki3qprkmfSfbyF07lHl2dt8nSDRUsN97fHhU?= =?us-ascii?Q?EMpByX6GOT28l1XiAJwfEUOaIZiKRc90MfQNGNYCop2wkzYZMuuamKgOEjI1?= =?us-ascii?Q?eZKbmlqfY4QrAQAt+G3nMP2zicnaFf+ny1zs7pObWsZmn07UIvrpiG5oacV4?= =?us-ascii?Q?A7q9JeQV0RIQdzqLaEoOJSmw/9bHh7QWktzw/ds7+fOrAbsqqtU9IqGS36Ni?= =?us-ascii?Q?0BXrWnMezcpNzgBw/sybP6NcDbtP1Ub0Lc/Q1fMp3RHCYMD297aEVO2thIX4?= =?us-ascii?Q?u/gM0x32mu7Vgh6zXcU1HBpyXiGIXc4WeaiW3kZmR7lyQ505HT0RTB7SV8M6?= =?us-ascii?Q?Ki1pxADvDBh/YWOwnzbOhCEcRJuy0h5y+YsXKCk0SUzeOBJ2v+OGy3q82zhD?= =?us-ascii?Q?sBcqdR0i2OoXkONXNCQ+yb+jNWzjTF4LXAk/n0ySFDdNODn68m0hRBh/XDQ2?= =?us-ascii?Q?Y3nE9Eyfm7604E7bos5MJym1Bm8BvFTn7ufGWMAMfHmEbP/8SQZeq2ISPMAQ?= =?us-ascii?Q?f8EbPlpXJlAhVf8jAR9IHwkCSuBjQ1trgWVOVmQmxH+jMeJpvVEvvSbZAISn?= =?us-ascii?Q?jOhI4EunIvDYAwPYCsjDmTTUNSX9F1VOHXx3ycDId8dS+vHHjCp59cpWLdqB?= =?us-ascii?Q?q3OhCbT3yaF3W8dnGTtPepS51wgqnpMxzX8v9kTw1UrKv2LPNMgTJTws93vw?= =?us-ascii?Q?HNpKgqXVTl1pe+yzbSxCBj2XLAMyAfP0bNT3i+TIXKO14kacoc7F3hq83U01?= =?us-ascii?Q?MYJHBC+oR27wgjVA4DPNhQEOIgri0WMzdZHI/l94nO4UnjurlFlN+pYmxvdh?= =?us-ascii?Q?6SSOe81mGnq9r8euTHoWSo4pv1xKy84E3SaogD9Thtbqi20VuXxsAtrC+lXj?= =?us-ascii?Q?E3Mkq8r60c6QfCzKpvbQmnfQmbFi4AHtlIyUISE4Xzoc/GSkdCUFBv1D/ANR?= =?us-ascii?Q?bQ7gDA9cr54dOU4ckXAOcngh/IE0Umq8ukaUeMklTLBaCSvx43fbVVOPBA?= =?us-ascii?Q?=3D=3D?= X-Forefront-Antispam-Report: CIP:165.204.84.17;CTRY:US;LANG:en;SCL:1;SRV:;IPV:CAL;SFV:NSPM;H:SATLEXMB04.amd.com;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(13230040)(82310400026)(36860700013)(1800799024)(376014)(7416014);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 25 Jul 2025 18:34:07.4574 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 0fc21c01-c28e-4202-34d6-08ddcba9d71e 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: CY4PEPF0000EE3D.namprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DS7PR12MB6333 Content-Type: text/plain; charset="utf-8" When "mbm_event" counter assignment mode is enabled, the architecture requires a counter ID to read the event data. Introduce an is_mbm_cntr field in struct rmid_read to indicate whether counter assignment mode is in use. Update the logic to call resctrl_arch_cntr_read() and resctrl_arch_reset_cntr() when the assignment mode is active. Report 'Unassigned' in case the user attempts to read the event without assigning a hardware counter. Declare mbm_cntr_get() in fs/resctrl/internal.h to make it accessible to other functions within fs/resctrl. Suggested-by: Reinette Chatre Signed-off-by: Babu Moger --- v16: Squashed two patches here. https://lore.kernel.org/lkml/df215f02db88cad714755cd5275f20cf0ee4ae26.= 1752013061.git.babu.moger@amd.com/ https://lore.kernel.org/lkml/296c435e9bf63fc5031114cced00fbb4837ad327.= 1752013061.git.babu.moger@amd.com/ Changed is_cntr field in struct rmid_read to is_mbm_cntr. Fixed the memory leak with arch_mon_ctx. Updated the resctrl.rst user doc. Updated the changelog. Report Unassigned only if none of the events in CTRL_MON and MON are a= ssigned. v15: New patch to add is_cntr in rmid_read as discussed in https://lore.kernel.org/lkml/b4b14670-9cb0-4f65-abd5-39db996e8da9@inte= l.com/ --- Documentation/filesystems/resctrl.rst | 6 ++++ fs/resctrl/ctrlmondata.c | 22 +++++++++--- fs/resctrl/internal.h | 5 +++ fs/resctrl/monitor.c | 52 ++++++++++++++++++++------- 4 files changed, 67 insertions(+), 18 deletions(-) diff --git a/Documentation/filesystems/resctrl.rst b/Documentation/filesyst= ems/resctrl.rst index 446736dbd97f..4c24c5f3f4c1 100644 --- a/Documentation/filesystems/resctrl.rst +++ b/Documentation/filesystems/resctrl.rst @@ -434,6 +434,12 @@ 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 the 'mbm_event' counter assignment mode is enabled, reading + an MBM event of a MON group returns 'Unassigned' if no hardware + counter is assigned to it. For CTRL_MON groups, 'Unassigned' is + returned if the MBM event does not have an assigned counter in the + CTRL_MON group nor in any of its associated MON groups. + "mon_hw_id": Available only with debug option. The identifier used by hardware for the monitor group. On x86 this is the RMID. diff --git a/fs/resctrl/ctrlmondata.c b/fs/resctrl/ctrlmondata.c index ad7ffc6acf13..31787ce6ec91 100644 --- a/fs/resctrl/ctrlmondata.c +++ b/fs/resctrl/ctrlmondata.c @@ -563,10 +563,15 @@ void mon_event_read(struct rmid_read *rr, struct rdt_= resource *r, rr->r =3D r; rr->d =3D d; rr->first =3D first; - rr->arch_mon_ctx =3D resctrl_arch_mon_ctx_alloc(r, evtid); - if (IS_ERR(rr->arch_mon_ctx)) { - rr->err =3D -EINVAL; - return; + if (resctrl_arch_mbm_cntr_assign_enabled(r) && + resctrl_is_mbm_event(evtid)) { + rr->is_mbm_cntr =3D true; + } else { + rr->arch_mon_ctx =3D resctrl_arch_mon_ctx_alloc(r, evtid); + if (IS_ERR(rr->arch_mon_ctx)) { + rr->err =3D -EINVAL; + return; + } } =20 cpu =3D cpumask_any_housekeeping(cpumask, RESCTRL_PICK_ANY_CPU); @@ -582,7 +587,8 @@ void mon_event_read(struct rmid_read *rr, struct rdt_re= source *r, else smp_call_on_cpu(cpu, smp_mon_event_count, rr, false); =20 - resctrl_arch_mon_ctx_free(r, evtid, rr->arch_mon_ctx); + if (rr->arch_mon_ctx) + resctrl_arch_mon_ctx_free(r, evtid, rr->arch_mon_ctx); } =20 int rdtgroup_mondata_show(struct seq_file *m, void *arg) @@ -653,10 +659,16 @@ int rdtgroup_mondata_show(struct seq_file *m, void *a= rg) =20 checkresult: =20 + /* + * -ENOENT is a special case, set only when "mbm_event" counter assignment + * mode is enabled and no counter has been assigned. + */ if (rr.err =3D=3D -EIO) seq_puts(m, "Error\n"); else if (rr.err =3D=3D -EINVAL) seq_puts(m, "Unavailable\n"); + else if (rr.err =3D=3D -ENOENT) + seq_puts(m, "Unassigned\n"); else seq_printf(m, "%llu\n", rr.val); =20 diff --git a/fs/resctrl/internal.h b/fs/resctrl/internal.h index 216588842444..eeee83a5067a 100644 --- a/fs/resctrl/internal.h +++ b/fs/resctrl/internal.h @@ -110,6 +110,8 @@ struct mon_data { * domains in @r sharing L3 @ci.id * @evtid: Which monitor event to read. * @first: Initialize MBM counter when true. + * @is_mbm_cntr: Is the counter valid? true if "mbm_event" counter assignm= ent mode is + * enabled and it is an MBM event. * @ci_id: Cacheinfo id for L3. Only set when @d is NULL. Used when summin= g domains. * @err: Error encountered when reading counter. * @val: Returned value of event counter. If @rgrp is a parent resource = group, @@ -124,6 +126,7 @@ struct rmid_read { struct rdt_mon_domain *d; enum resctrl_event_id evtid; bool first; + bool is_mbm_cntr; unsigned int ci_id; int err; u64 val; @@ -391,6 +394,8 @@ int rdtgroup_assign_cntr_event(struct rdt_mon_domain *d= , struct rdtgroup *rdtgrp struct mon_evt *mevt); void rdtgroup_unassign_cntr_event(struct rdt_mon_domain *d, struct rdtgrou= p *rdtgrp, struct mon_evt *mevt); +int mbm_cntr_get(struct rdt_resource *r, struct rdt_mon_domain *d, + struct rdtgroup *rdtgrp, enum resctrl_event_id evtid); =20 #ifdef CONFIG_RESCTRL_FS_PSEUDO_LOCK int rdtgroup_locksetup_enter(struct rdtgroup *rdtgrp); diff --git a/fs/resctrl/monitor.c b/fs/resctrl/monitor.c index 070965d45770..a8b53b0ad0b7 100644 --- a/fs/resctrl/monitor.c +++ b/fs/resctrl/monitor.c @@ -362,13 +362,25 @@ static int __mon_event_count(struct rdtgroup *rdtgrp,= struct rmid_read *rr) u32 closid =3D rdtgrp->closid; u32 rmid =3D rdtgrp->mon.rmid; struct rdt_mon_domain *d; + int cntr_id =3D -ENOENT; struct cacheinfo *ci; struct mbm_state *m; int err, ret; u64 tval =3D 0; =20 + if (rr->is_mbm_cntr) { + cntr_id =3D mbm_cntr_get(rr->r, rr->d, rdtgrp, rr->evtid); + if (cntr_id < 0) { + rr->err =3D -ENOENT; + return -EINVAL; + } + } + if (rr->first) { - resctrl_arch_reset_rmid(rr->r, rr->d, closid, rmid, rr->evtid); + if (rr->is_mbm_cntr) + resctrl_arch_reset_cntr(rr->r, rr->d, closid, rmid, cntr_id, rr->evtid); + else + resctrl_arch_reset_rmid(rr->r, rr->d, closid, rmid, rr->evtid); m =3D get_mbm_state(rr->d, closid, rmid, rr->evtid); if (m) memset(m, 0, sizeof(struct mbm_state)); @@ -379,8 +391,12 @@ static int __mon_event_count(struct rdtgroup *rdtgrp, = struct rmid_read *rr) /* Reading a single domain, must be on a CPU in that domain. */ if (!cpumask_test_cpu(cpu, &rr->d->hdr.cpu_mask)) return -EINVAL; - rr->err =3D resctrl_arch_rmid_read(rr->r, rr->d, closid, rmid, - rr->evtid, &tval, rr->arch_mon_ctx); + if (rr->is_mbm_cntr) + rr->err =3D resctrl_arch_cntr_read(rr->r, rr->d, closid, rmid, cntr_id, + rr->evtid, &tval); + else + rr->err =3D resctrl_arch_rmid_read(rr->r, rr->d, closid, rmid, + rr->evtid, &tval, rr->arch_mon_ctx); if (rr->err) return rr->err; =20 @@ -405,8 +421,12 @@ static int __mon_event_count(struct rdtgroup *rdtgrp, = struct rmid_read *rr) list_for_each_entry(d, &rr->r->mon_domains, hdr.list) { if (d->ci_id !=3D rr->ci_id) continue; - err =3D resctrl_arch_rmid_read(rr->r, d, closid, rmid, - rr->evtid, &tval, rr->arch_mon_ctx); + if (rr->is_mbm_cntr) + err =3D resctrl_arch_cntr_read(rr->r, d, closid, rmid, cntr_id, + rr->evtid, &tval); + else + err =3D resctrl_arch_rmid_read(rr->r, d, closid, rmid, + rr->evtid, &tval, rr->arch_mon_ctx); if (!err) { rr->val +=3D tval; ret =3D 0; @@ -613,11 +633,16 @@ static void mbm_update_one_event(struct rdt_resource = *r, struct rdt_mon_domain * rr.r =3D r; rr.d =3D d; rr.evtid =3D evtid; - rr.arch_mon_ctx =3D resctrl_arch_mon_ctx_alloc(rr.r, rr.evtid); - if (IS_ERR(rr.arch_mon_ctx)) { - pr_warn_ratelimited("Failed to allocate monitor context: %ld", - PTR_ERR(rr.arch_mon_ctx)); - return; + if (resctrl_arch_mbm_cntr_assign_enabled(r) && + resctrl_arch_mbm_cntr_assign_enabled(r)) { + rr.is_mbm_cntr =3D true; + } else { + rr.arch_mon_ctx =3D resctrl_arch_mon_ctx_alloc(rr.r, rr.evtid); + if (IS_ERR(rr.arch_mon_ctx)) { + pr_warn_ratelimited("Failed to allocate monitor context: %ld", + PTR_ERR(rr.arch_mon_ctx)); + return; + } } =20 __mon_event_count(rdtgrp, &rr); @@ -629,7 +654,8 @@ static void mbm_update_one_event(struct rdt_resource *r= , struct rdt_mon_domain * if (is_mba_sc(NULL)) mbm_bw_count(rdtgrp, &rr); =20 - resctrl_arch_mon_ctx_free(rr.r, rr.evtid, rr.arch_mon_ctx); + if (rr.arch_mon_ctx) + resctrl_arch_mon_ctx_free(rr.r, rr.evtid, rr.arch_mon_ctx); } =20 static void mbm_update(struct rdt_resource *r, struct rdt_mon_domain *d, @@ -983,8 +1009,8 @@ static void rdtgroup_assign_cntr(struct rdt_resource *= r, struct rdt_mon_domain * * Return: * Valid counter ID on success, or -ENOENT on failure. */ -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 Mon Oct 6 01:21:11 2025 Received: from NAM11-CO1-obe.outbound.protection.outlook.com (mail-co1nam11on2074.outbound.protection.outlook.com [40.107.220.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 057262475C3; Fri, 25 Jul 2025 18:34:24 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.220.74 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1753468466; cv=fail; b=CDxgf9NwKa5uh1BQZxmT+Wr32d1sQrGAH9Z73Q3TPHcVEDsQTrV3xIUz/qzVu4i1HgldkoPkDUujRBRWO/9ctHTmEFnPKjbByNaSXEYI4XXTZaIiFgh6t3fo8k0x//Z7lbNq63cnln7dwbm7Vlw5pQiHXeBSS1rbRHBHm6aY/TI= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1753468466; c=relaxed/simple; bh=4daUxC5prdWDTO85pRWeUgmcbkA3pj4kWFSrQtgbZQw=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=p4pgbreCRiJ5tyQi77EM8oPN+TNevvOuDp5l12IkisWZXR3h954OUUrHsL1oq+6i4EFZNZ1N5QIpGbDOeTGSuyQyq/9Yit/B1i87CZmTJ2G/TewJ7OlgXgOAikhgjrL5PVZZ+j/mWx8qFRTO3jw5BxM6VT/CDS6t1bSSOzO1seQ= 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=vQ0mgVQD; arc=fail smtp.client-ip=40.107.220.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="vQ0mgVQD" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=nPQHpn1hMrgPvoNwTgxnt73beh5VTc3GXdPj0TtI9RpjyKoPrHkt7EhhkacsaO2g22T6Jjsw62OsqGIb7Nxp4xoBOojPx0cN/7iyqeA0RWWJv4c0h2cjj1592C+tHTdtRrs15MZwh2W03GpqUJ5cAwd4FMMSlvK8eUs3QjO074T3VbmKdXnfP/Tbsxy9hTFbh/W0xaiGyRZPPONCo+HZSQTAawWARwoTNG98B/pDivEQZ4FFDkf7vLCvtVlz/Tkx5789/Y5C5sv7rtoAy6zPXzhL5OOm1OwmobDNa8LsNw7FSKOYpZnIqz203GlhKBFR2kXxzS8SVOx+KVisMC/Qgw== 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=4kLIJ3Dw4ZZIuO/62Z5YgZbbkFQ35KQhTrRj2Q6Bu04=; b=nqFyBM9QbgMCihoHAU1faXIFSjUH3LETKSu5UWIUXPIaafZnpEQuRuhJz9lCn7KiH08E39llprTuj6LDQnEUEBEbcwrVA0p2QqaGhLZe6k5a0IU5fMFw2VOJfg3OUu7HV7bx8++vMPYMp167TqwVKDuuqBcnP6vrj3C5aUUKDQcSHL2piKrEzaWlBKgdNr6DERrj3p7KheqdFMQQLyyglf7GdJE/q+YysDz51c/Tet8dY8pHHElMH9S/xEVvz/LCVK9Qlw3OaqpC1/jkBh/z9Jf7g7gtO29AJbE7aBgFYzqjyTyTfv8ok12b7TnYosAzTZmZCPu2s/AfTlZv5couaw== 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=4kLIJ3Dw4ZZIuO/62Z5YgZbbkFQ35KQhTrRj2Q6Bu04=; b=vQ0mgVQDaIQhz0+CKKlCXUoAdSyKot8DrOIZIH5JHfuAbU5Ns89UIlWUFdWIygxNadGscV1603eYNtgmcZE9rrQxrhYqteQ8v2wFHbbpTNDTDOX7HDDv4IizWNnUlcwdwSJFZRgtgwUj0F7HXIM7XyPqvKzb0fy+RreEu2/D9tQ= Received: from BYAPR11CA0098.namprd11.prod.outlook.com (2603:10b6:a03:f4::39) by BL3PR12MB6404.namprd12.prod.outlook.com (2603:10b6:208:3b4::5) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8964.21; Fri, 25 Jul 2025 18:34:21 +0000 Received: from CY4PEPF0000EE3D.namprd03.prod.outlook.com (2603:10b6:a03:f4:cafe::47) by BYAPR11CA0098.outlook.office365.com (2603:10b6:a03:f4::39) with Microsoft SMTP Server (version=TLS1_3, cipher=TLS_AES_256_GCM_SHA384) id 15.20.8964.23 via Frontend Transport; Fri, 25 Jul 2025 18:34: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 CY4PEPF0000EE3D.mail.protection.outlook.com (10.167.242.15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.8964.20 via Frontend Transport; Fri, 25 Jul 2025 18:34: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; Fri, 25 Jul 2025 13:34:18 -0500 From: Babu Moger To: , , , , , , , CC: , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , Subject: [PATCH v16 24/34] fs/resctrl: Add definitions for MBM event configuration Date: Fri, 25 Jul 2025 13:29:43 -0500 Message-ID: X-Mailer: git-send-email 2.34.1 In-Reply-To: References: Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-ClientProxiedBy: SATLEXMB03.amd.com (10.181.40.144) To SATLEXMB04.amd.com (10.181.40.145) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CY4PEPF0000EE3D:EE_|BL3PR12MB6404:EE_ X-MS-Office365-Filtering-Correlation-Id: faea36c7-d5b7-4710-b837-08ddcba9df6b X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|1800799024|82310400026|376014|36860700013|7416014; X-Microsoft-Antispam-Message-Info: =?us-ascii?Q?M2U/4Uu35MnUmjGgKIcPBK82mRSMzAydKN6GyGYOmjbHX1YAYKwAgtRn0u2k?= =?us-ascii?Q?cWKpuVpLz4hkcWf6NLB0AbK7+gJyCd/sSgpV9ryzK88uhsC5ewKrgvXpW4vy?= =?us-ascii?Q?zTmkA4Hc9fLnCAVTQQ1zdKSQzHtBpKS30a8rwpG50NC+5gArSqwOmojqtYEx?= =?us-ascii?Q?Fzhy8vFrqWjWiWKqhNVsX7zr56TPOuGdy0G02dZeERuBird3+CtZJFknnXiq?= =?us-ascii?Q?NN7xrmGONGvPwWAjsUbZv707PVdl4/K5ndIohhtqzNEfQLeP6wkboc0WagRg?= =?us-ascii?Q?fqda7AfDlz0S92oZjN4k13ofWSO5UaxH8ySTNT5ESXJK3B9vzk3qkOku0M2N?= =?us-ascii?Q?GJ0x7hyoo3BMG7pXd81amBWbQZuFcOgczaeITPCqjtdo+DfHjb23kG3gVFnI?= =?us-ascii?Q?Asvr9GG6RusR/w5JhzXadW3tItgBaUwi3wOQYcGaogNsPMdyJd3mQ8c66InN?= =?us-ascii?Q?FUblFP89AD2VR0jPpq89ZGAUEySte/PRO8rKf2VlEDyPxgiggx3Bv6DvCMZy?= =?us-ascii?Q?Kfo2AZzcOLizkmFVCbNCppbLRqPipbNPUi/krb3sUZWw6LutYB1b5dWMkKDQ?= =?us-ascii?Q?WpwvoL58bndJycfHWnT0r5oeeIchZSazQslvZBBWcPGWNKHEx5lTNRpWWnpd?= =?us-ascii?Q?Va76f1oaOjEi/fasftEIKWSLhdqpxRf1C/ZJWk7ntUfx3RFDSUisikxkWY1Z?= =?us-ascii?Q?WHNNhLjnCZP8R+rsfupGjKtbKDHud38q3s/KpaKHI4xzk7G0Kt6prlAbRkW0?= =?us-ascii?Q?Gq5+SuRWwYc1LPO87L3jAIbVEXuFaXkMz7oAUZAX3lWJ86CvnYFVUP14MEmm?= =?us-ascii?Q?Dccui0d1+iKu6lis1md8Kx0HsSYej2GJsZumQyo4neFvhYKZ0sAT7up8tKAh?= =?us-ascii?Q?ags7tZCuxsbG2LrwFrTotFIfL5KuxcHi8fIczwq5BWct9EBvjgQwwsrRLEMM?= =?us-ascii?Q?cozyf0Wd+DvBSmxekxpJxJkvMTKEtqfzOmTumo2+ZVKCl/wvIcqEhfq+cZES?= =?us-ascii?Q?ee6ssP5lm00nogZLZN47kVa25gAm1wkg9v/Dww5xLjVKAouz9jlVmBhNMqXQ?= =?us-ascii?Q?BnhWQcw7uxbIRQUBtPtw/Lu/nqP/mxkadpPS0MJxNfGa2EOxJDq3b2fOnoQj?= =?us-ascii?Q?ZkNKGH+NQbhwwas5dbuIq4Eq8R2UlQMOGmO0geq9HTLF++o+EdYqrxJWFOH2?= =?us-ascii?Q?f/ESjFv/rzIbe90XOZbZu+YMcSjZWJb9oeinSLrMBe7KTRULZMBVW1F/A37U?= =?us-ascii?Q?TnIGplYBukpH1P+JtzXXQy+n+yOstAJi/1psm1XphGREQgib0roooqPxQ5c8?= =?us-ascii?Q?0IK4LbRnHHdCeDr3C5oezF9R56oqHZyJ4977feqtmgX9uTuSK8Po8ntRJGcS?= =?us-ascii?Q?fwqES5MHDvPR3F/tsR+Q6c+GXzT6gcJwQAbrATHejcVdqMTdrowv7JSwm3GZ?= =?us-ascii?Q?wgNrgnHXZG4tBSB1EE2gm233EEEUECe6Sim+uGvOVDKlgQbH5H7P3LGM7eL2?= =?us-ascii?Q?nITAq/ygRH82iX67SarFa9Fq1vwO8EkG2pes?= X-Forefront-Antispam-Report: CIP:165.204.84.17;CTRY:US;LANG:en;SCL:1;SRV:;IPV:CAL;SFV:NSPM;H:SATLEXMB04.amd.com;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(13230040)(1800799024)(82310400026)(376014)(36860700013)(7416014);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 25 Jul 2025 18:34:21.3887 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: faea36c7-d5b7-4710-b837-08ddcba9df6b 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: CY4PEPF0000EE3D.namprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: BL3PR12MB6404 Content-Type: text/plain; charset="utf-8" The "mbm_event" counter assignment mode allows the user to assign a hardware counter to an RMID, event pair and monitor the bandwidth as long as it is assigned. The user can specify the memory transaction(s) for the counter to track. Add the definitions for supported memory transactions (e.g., read, write, etc.) the counter can be configured with. Signed-off-by: Babu Moger --- v16: Minor code comment update. v15: Updated the changelog. Moved NUM_MBM_TRANSACTIONS to include/linux/resctrl_types.h Changed struct mbm_config_value to struct mbm_transaction. v14: Changed the term memory events to memory transactions to be consistant. Changed the name of the structure to mbm_config_value(from mbm_evt_val= ue). Changed name to memory trasactions where applicable. Changes subject line to fs/resctrl. v13: Updated the changelog. Removed the definitions from resctrl_types.h and moved to internal.h. Removed mbm_assign_config definition. Configurations will be part of mon_evt list. Resolved conflicts caused by the recent FS/ARCH code restructure. The rdtgroup.c file has now been split between the FS and ARCH directo= ries. v12: New patch to support event configurations via new counter_configs method. --- fs/resctrl/internal.h | 11 +++++++++++ fs/resctrl/monitor.c | 11 +++++++++++ include/linux/resctrl_types.h | 3 +++ 3 files changed, 25 insertions(+) diff --git a/fs/resctrl/internal.h b/fs/resctrl/internal.h index eeee83a5067a..693268bcbad2 100644 --- a/fs/resctrl/internal.h +++ b/fs/resctrl/internal.h @@ -216,6 +216,17 @@ struct rdtgroup { struct pseudo_lock_region *plr; }; =20 +/** + * struct mbm_transaction - Memory transaction an MBM event can be configu= red with. + * @name: Name of memory transaction (read, write ...). + * @val: The bit (eg. READS_TO_LOCAL_MEM or READS_TO_REMOTE_MEM) used to + * represent the memory transaction within an event's configuration. + */ +struct mbm_transaction { + char name[32]; + u32 val; +}; + /* rdtgroup.flags */ #define RDT_DELETED 1 =20 diff --git a/fs/resctrl/monitor.c b/fs/resctrl/monitor.c index a8b53b0ad0b7..16bcfeeb89e6 100644 --- a/fs/resctrl/monitor.c +++ b/fs/resctrl/monitor.c @@ -918,6 +918,17 @@ u32 resctrl_get_mon_evt_cfg(enum resctrl_event_id evti= d) return mon_event_all[evtid].evt_cfg; } =20 +/* Decoded values for each type of memory transaction. */ +struct mbm_transaction mbm_transactions[NUM_MBM_TRANSACTIONS] =3D { + {"local_reads", READS_TO_LOCAL_MEM}, + {"remote_reads", READS_TO_REMOTE_MEM}, + {"local_non_temporal_writes", NON_TEMP_WRITE_TO_LOCAL_MEM}, + {"remote_non_temporal_writes", NON_TEMP_WRITE_TO_REMOTE_MEM}, + {"local_reads_slow_memory", READS_TO_LOCAL_S_MEM}, + {"remote_reads_slow_memory", READS_TO_REMOTE_S_MEM}, + {"dirty_victim_writes_all", DIRTY_VICTIMS_TO_ALL_MEM}, +}; + /** * resctrl_mon_resource_init() - Initialise global monitoring structures. * diff --git a/include/linux/resctrl_types.h b/include/linux/resctrl_types.h index d98351663c2c..acfe07860b34 100644 --- a/include/linux/resctrl_types.h +++ b/include/linux/resctrl_types.h @@ -34,6 +34,9 @@ /* Max event bits supported */ #define MAX_EVT_CONFIG_BITS GENMASK(6, 0) =20 +/* Number of memory transactions that an MBM event can be configured with = */ +#define NUM_MBM_TRANSACTIONS 7 + /* Event IDs */ enum resctrl_event_id { /* Must match value of first event below */ --=20 2.34.1 From nobody Mon Oct 6 01:21:11 2025 Received: from NAM10-BN7-obe.outbound.protection.outlook.com (mail-bn7nam10on2060.outbound.protection.outlook.com [40.107.92.60]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id E6FD624EF76; Fri, 25 Jul 2025 18:34:40 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.92.60 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1753468482; cv=fail; b=QIRWCwrdFVmzL/eO6wKh4l2XwOMBHgi1WXJRbTdG+TfzobHSiW7zZIwndi67pqHRuRvalWM1earwx19j4bTussP5GP/mO8u1ovx6oadWMUFFYUtH2DrYiJYji3IwXTSMQCEiomQYuzN7NCd1iOIPMv2oRk6U2UJ0ZxXT9Aurza4= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1753468482; c=relaxed/simple; bh=bJOj5WGAlOG+V/XGTBpQeDNvn3+HUiM/coBwJNHHk/k=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=rZ5rTRXp3TenoJ6PgwMwZdo/dhE/HKMdNtqYBQ46QSVDPvTXuV/NrBX08rfiMNRtLyxkIyC9t7eScSKsf0Ej11Lb6ghHUaf1kUSd0y+8vTw3V17d+XbnPOgShxwfov3tKZs4SCCltxiNW2EahHlZwNNZgoqQXavVJxQyuRoosd0= 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=vgCJi9WQ; arc=fail smtp.client-ip=40.107.92.60 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=amd.com Authentication-Results: smtp.subspace.kernel.org; spf=fail smtp.mailfrom=amd.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=amd.com header.i=@amd.com header.b="vgCJi9WQ" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=ITkEHFA08LV1+W4zefuBjunKN3zXmJHEzCiEzPi4fXGE0ECa01VU1dbxzMgI4DQ9EL1gvfsW002WoGZfhwlRpM9C1v+jydhETrnY0ChgmEM78PD7CMrf5aEyrCi4kBogZb9loMMfthuoinKjw80dhvMHkkgN0bAwo+D9vhz0ClCRQ4jkDp/5kCwwyxY66c1TqZty1T8pYG4WvGT0jjslOc8abhYdp3eXOeVCZpAIPbc13DuPH6NNo4nHUntBGjEm7Wu7AlkYdIgZRkhG9c+s3GtOweMeCh8Sy6wXoFXwkLHMhAu+OgzjTrdvNxyBnNWXnLkdA3itGZVfLSo9lOv4yA== 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=3PZcWdVXtD2GxMkJG/D7s5s1pcx7fGxjFqz1goO/cNE=; b=B3Cjy2gttffSHqHwv0lxBxV8NK761jQ1K3zSwOO42LL4UDnqrCCRoHulZ0orqDT8l61fn0te9nWMgTzyQnVHFovvK3Hh4yBrgcpCf8ST6/MQZvhLXg0za0L5RPVs8o8X1slsCifhAvrsH1aSjaRdveavW1V/n45vBA513xvzKSzON6Wo8Z3dPL3lbRpDi2rhB9C/gpuwl7Ik42YfUrshwwNxH3CNQ3yQaWdQEtNXwXwT7U51vDKkhYsOVegPanFZctFTVRFQqAw85NlBWzjEGAWRmG1vTsGDca6KHX8SfqCOqDOxXiY6juK09Zoob+WwvZflQrgvuiaF2USh4j1siw== 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=3PZcWdVXtD2GxMkJG/D7s5s1pcx7fGxjFqz1goO/cNE=; b=vgCJi9WQ+eAT/4mST5Cipi2bPXqsgLCMN/Pegw95atuyshqHvtA35O+Qi7i3swghcv2+27x+DCy96a3qeIoD4ZMscHxNqsoq3jsVlmEUHyJ1x+LGkIgaH3gDmv8rflKFjG+hKy9yV7tF38DugX4PXMwakVlLmeFrecaxBIclprg= Received: from SJ0PR03CA0066.namprd03.prod.outlook.com (2603:10b6:a03:331::11) by SJ1PR12MB6196.namprd12.prod.outlook.com (2603:10b6:a03:456::8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8964.22; Fri, 25 Jul 2025 18:34:35 +0000 Received: from CY4PEPF0000EE3B.namprd03.prod.outlook.com (2603:10b6:a03:331:cafe::c6) by SJ0PR03CA0066.outlook.office365.com (2603:10b6:a03:331::11) with Microsoft SMTP Server (version=TLS1_3, cipher=TLS_AES_256_GCM_SHA384) id 15.20.8964.21 via Frontend Transport; Fri, 25 Jul 2025 18:34:35 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 165.204.84.17) smtp.mailfrom=amd.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=amd.com; Received-SPF: Pass (protection.outlook.com: domain of amd.com designates 165.204.84.17 as permitted sender) receiver=protection.outlook.com; client-ip=165.204.84.17; helo=SATLEXMB04.amd.com; pr=C Received: from SATLEXMB04.amd.com (165.204.84.17) by CY4PEPF0000EE3B.mail.protection.outlook.com (10.167.242.14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.8964.20 via Frontend Transport; Fri, 25 Jul 2025 18:34: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; Fri, 25 Jul 2025 13:34:32 -0500 From: Babu Moger To: , , , , , , , CC: , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , Subject: [PATCH v16 25/34] fs/resctrl: Add event configuration directory under info/L3_MON/ Date: Fri, 25 Jul 2025 13:29:44 -0500 Message-ID: <13467b9a56bccf960974741741b4960a8f02e333.1753467772.git.babu.moger@amd.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: References: Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-ClientProxiedBy: SATLEXMB03.amd.com (10.181.40.144) To SATLEXMB04.amd.com (10.181.40.145) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CY4PEPF0000EE3B:EE_|SJ1PR12MB6196:EE_ X-MS-Office365-Filtering-Correlation-Id: a86835be-6658-47e8-3d4a-08ddcba9e792 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|1800799024|7416014|376014|82310400026|36860700013; X-Microsoft-Antispam-Message-Info: =?us-ascii?Q?fTHQ010B6CauGwEyB7aqfIP18Ym9yjlaep+/250eh4DnAm7+tRBeQql1GoTd?= =?us-ascii?Q?jNSsdggPwd/dZLS5/YzrCJ7EgqqUv1XsEIwf/LrRkBkjyfpl3FnidsLd3jS0?= =?us-ascii?Q?nuiWJG1PEOrp2dCZdWqXj9Xp3ZKfrPdFLq0dyqCBk91Eaj9z3I/AtkHuYUve?= =?us-ascii?Q?UDEBOZSjMgwsGd4FmgnPj6x+ATQ8T9nSfaWIAdSzFIeE1oE5onxSSl/5ZjbD?= =?us-ascii?Q?5Ueh97d1RCQSHDyfY0m+FGe6AvDZ3PC8x4OSV0iF58j0LQXmjSXm2n+bif5L?= =?us-ascii?Q?p1SgRu3MC/tV0UU70u3Pc0DS8BqNgMB0FjD1WK4WQ+H+PtGq9oux1fgrOCTs?= =?us-ascii?Q?ZuUyJOTBAaLNo57kmd/Ahh4xBChbn6o1Px7++hYP7KAN5jxH0RRvXIOva64x?= =?us-ascii?Q?8XRMlW943AlYtv4l0aqoYoVn17EGSCCwvXL4bhgy1Aj7QT1Z27SGxDz7TN8F?= =?us-ascii?Q?OzJzBUns2JgGnIQZy1ErLKDw7dOM8SZD6hZCi613rQj2/ieIYs8SDMmRy7Ud?= =?us-ascii?Q?3aJ9C4IZI01s4PLCpxI9hxjhGq6XL9bFwqzE9OiSIqfju2u3rp0yDj+LMSqm?= =?us-ascii?Q?Q/nCfy4Qm9Nl3SB6+ENk3taTjz4kPLxcd9SLZ9QJm2zfSZgnVuK1ckdaG6Yn?= =?us-ascii?Q?uFcRs6V7EHRs8qvCXoWXDrkBf/EQV7DpxxvH25P4mCHbcI8fpNqJSQjx87bn?= =?us-ascii?Q?FNbs6eyLYnOTwFKLdM820/yWG375VJNMFemOftko9LqUxPhZPWg7cVCbg+mG?= =?us-ascii?Q?g4Nd3lL7/6FGuXokUjWAFAfoEy2szlwSBnCh88lZdRVO/xpsWV7CR/LjzpK7?= =?us-ascii?Q?hfBsCxriVBQrvH+1exe89x6YdwihwpEzshZrDn2RsxJz7Tih2i3WzpqK4l9E?= =?us-ascii?Q?XTl3Jesla8G2dOaTW9pVdk+uER29oX77Tj8N1srCuvhEvxm3+fj4et71Kxgo?= =?us-ascii?Q?tU3/u6urtLHp0fsPHf3n+T42p1/E0Ap+pSkAltXkur5Q5wemCNRCMrXDsAGS?= =?us-ascii?Q?3pG1NBbjZdoRia6Ggobof+75ltbROHx1H1mnpFgfH/eIhVq2nCxIdby41aRN?= =?us-ascii?Q?32NPJJFDyTJNMMZclpHamSu7UindG69d9wcYKdjGYUGKzbpt+cdHY8VJQNGA?= =?us-ascii?Q?juQnxGyCK+RSra9sBOKpic6TFCPwKxIPzDBcmTIxoRP14DL8IjttH7+3k/5o?= =?us-ascii?Q?OL7ifqNuKG+K9qk4XluKK/oXnobfObIAIFOMW+V4Xy07WGgld+8EShZp3tiy?= =?us-ascii?Q?IHJXo85N6Qm/1iAUATBp8ZId6RbZy/yOAtS8cUOGPfnaJ1cFEIaI0lZrUDgA?= =?us-ascii?Q?FI2FFTzBDCoYPaPA1GalAVn3op1H6vVTW3VI9dsvk5e1KEjBEBtclfuA93sN?= =?us-ascii?Q?Vt66XN8kP8X8ohqngerpj26rpEOYHItqyEL4Gftiwk8efCnodreer/qLU0wc?= =?us-ascii?Q?ENJiiS1uVpy+cvzPfV+WDmaVQt8C9uOPwzLvw0VoO8J71+ynn/EpCWwbgrLN?= =?us-ascii?Q?fTuRrXuXVw5XjqIEUOirvC4U2OMXZiqaCtCx?= X-Forefront-Antispam-Report: CIP:165.204.84.17;CTRY:US;LANG:en;SCL:1;SRV:;IPV:CAL;SFV:NSPM;H:SATLEXMB04.amd.com;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(13230040)(1800799024)(7416014)(376014)(82310400026)(36860700013);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 25 Jul 2025 18:34:35.0636 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: a86835be-6658-47e8-3d4a-08ddcba9e792 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: CY4PEPF0000EE3B.namprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: SJ1PR12MB6196 Content-Type: text/plain; charset="utf-8" When "mbm_event" counter assignment mode is supported the /sys/fs/resctrl/info/L3_MON/event_configs directory contains a sub-directory for each MBM event that can be assigned to a counter. The MBM event sub-directory contains a file named "event_filter" that is used to view and modify which memory transactions the MBM event is configured with. Create /sys/fs/resctrl/info/L3_MON/event_configs directory on resctrl mount and pre-populate it with directories for the two existing MBM events: mbm_total_bytes and mbm_local_bytes. Create the "event_filter" file within each MBM event directory with the needed *show() that displays the memory transactions with which the MBM event is configured. Example: $ mount -t resctrl resctrl /sys/fs/resctrl $ cd /sys/fs/resctrl/ $ cat info/L3_MON/event_configs/mbm_total_bytes/event_filter local_reads,remote_reads,local_non_temporal_writes, remote_non_temporal_writes,local_reads_slow_memory, remote_reads_slow_memory,dirty_victim_writes_all $ cat info/L3_MON/event_configs/mbm_local_bytes/event_filter local_reads,local_non_temporal_writes,local_reads_slow_memory Signed-off-by: Babu Moger --- v16: Moved event_filter_show() to fs/resctrl/monitor.c Changed the goto label out_config to out. Added rdtgroup_mutex in event_filter_show(). Removed extern for mbm_transactions. Not required. 0025-fs-resctrl-Add-event-configuration-directory-under 0025-fs-resctrl-Add-event-configuration-directory-under 0025-fs-resctrl-Add-event-configuration-directory-under Added prototype rdt_kn_parent_priv() in so it can be called from monit= or.c v15: Fixed the event_filter display with proper spacing. Updated the changelog. Changed the function name resctrl_mkdir_counter_configs() to resctrl_mkdir_event_configs(). Called resctrl_mkdir_event_configs from rdtgroup_mkdir_info_resdir(). It avoids the call kernfs_find_and_get() to get the node for info dire= ctory. Used for_each_mon_event() where applicable. v14: Updated the changelog with context. Thanks to Reinette. Changed the name of directory to event_configs from counter_config. Updated user doc about the memory transactions supported by assignment. Removed mbm_mode from struct mon_evt. Not required anymore. v13: Updated user doc (resctrl.rst). Changed the name of the function resctrl_mkdir_info_configs to resctrl_mkdir_counter_configs(). Replaced seq_puts() with seq_putc() where applicable. Removed RFTYPE_MON_CONFIG definition. Not required. Changed the name of the flag RFTYPE_CONFIG to RFTYPE_ASSIGN_CONFIG. Reinette suggested RFTYPE_MBM_EVENT_CONFIG but RFTYPE_ASSIGN_CONFIG seemed shorter and pricise. The configuration is created using evt_list. Resolved conflicts caused by the recent FS/ARCH code restructure. The monitor.c/rdtgroup.c files have been split between the FS and ARCH= directories. v12: New patch to hold the MBM event configurations for mbm_cntr_assign mod= e. --- Documentation/filesystems/resctrl.rst | 32 +++++++++++++++ fs/resctrl/internal.h | 6 +++ fs/resctrl/monitor.c | 24 +++++++++++ fs/resctrl/rdtgroup.c | 58 ++++++++++++++++++++++++++- 4 files changed, 119 insertions(+), 1 deletion(-) diff --git a/Documentation/filesystems/resctrl.rst b/Documentation/filesyst= ems/resctrl.rst index 4c24c5f3f4c1..3dfc177f9792 100644 --- a/Documentation/filesystems/resctrl.rst +++ b/Documentation/filesystems/resctrl.rst @@ -310,6 +310,38 @@ with the following files: # cat /sys/fs/resctrl/info/L3_MON/available_mbm_cntrs 0=3D30;1=3D30 =20 +"event_configs": + Directory that exists when "mbm_event" counter assignment mode is support= ed. + Contains sub-directory for each MBM event that can be assigned to a count= er. + + Two MBM events are supported by default: mbm_local_bytes and mbm_total_by= tes. + Each MBM event's sub-directory contains a file named "event_filter" that = is + used to view and modify which memory transactions the MBM event is config= ured + with. + + List of memory transaction types supported: + + =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D + Name Description + =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D + dirty_victim_writes_all Dirty Victims from the QOS domain to all type= s of memory + remote_reads_slow_memory Reads to slow memory in the non-local NUMA do= main + local_reads_slow_memory Reads to slow memory in the local NUMA domain + remote_non_temporal_writes Non-temporal writes to non-local NUMA domain + local_non_temporal_writes Non-temporal writes to local NUMA domain + remote_reads Reads to memory in the non-local NUMA domain + local_reads Reads to memory in the local NUMA domain + =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D + + For example:: + + # cat /sys/fs/resctrl/info/L3_MON/event_configs/mbm_total_bytes/event_f= ilter + local_reads,remote_reads,local_non_temporal_writes,remote_non_temporal_= writes, + local_reads_slow_memory,remote_reads_slow_memory,dirty_victim_writes_all + + # cat /sys/fs/resctrl/info/L3_MON/event_configs/mbm_local_bytes/event_f= ilter + local_reads,local_non_temporal_writes,local_reads_slow_memory + "max_threshold_occupancy": Read/write file provides the largest value (in bytes) at which a previously used LLC_occupancy diff --git a/fs/resctrl/internal.h b/fs/resctrl/internal.h index 693268bcbad2..e082d8718199 100644 --- a/fs/resctrl/internal.h +++ b/fs/resctrl/internal.h @@ -252,6 +252,8 @@ struct mbm_transaction { =20 #define RFTYPE_DEBUG BIT(10) =20 +#define RFTYPE_ASSIGN_CONFIG BIT(11) + #define RFTYPE_CTRL_INFO (RFTYPE_INFO | RFTYPE_CTRL) =20 #define RFTYPE_MON_INFO (RFTYPE_INFO | RFTYPE_MON) @@ -408,6 +410,10 @@ void rdtgroup_unassign_cntr_event(struct rdt_mon_domai= n *d, struct rdtgroup *rdt int mbm_cntr_get(struct rdt_resource *r, struct rdt_mon_domain *d, struct rdtgroup *rdtgrp, enum resctrl_event_id evtid); =20 +void *rdt_kn_parent_priv(struct kernfs_node *kn); + +int event_filter_show(struct kernfs_open_file *of, struct seq_file *seq, v= oid *v); + #ifdef CONFIG_RESCTRL_FS_PSEUDO_LOCK int rdtgroup_locksetup_enter(struct rdtgroup *rdtgrp); =20 diff --git a/fs/resctrl/monitor.c b/fs/resctrl/monitor.c index 16bcfeeb89e6..fa5f63126682 100644 --- a/fs/resctrl/monitor.c +++ b/fs/resctrl/monitor.c @@ -929,6 +929,29 @@ struct mbm_transaction mbm_transactions[NUM_MBM_TRANSA= CTIONS] =3D { {"dirty_victim_writes_all", DIRTY_VICTIMS_TO_ALL_MEM}, }; =20 +int event_filter_show(struct kernfs_open_file *of, struct seq_file *seq, v= oid *v) +{ + struct mon_evt *mevt =3D rdt_kn_parent_priv(of->kn); + bool sep =3D false; + int i; + + mutex_lock(&rdtgroup_mutex); + + for (i =3D 0; i < NUM_MBM_TRANSACTIONS; i++) { + if (mevt->evt_cfg & mbm_transactions[i].val) { + if (sep) + seq_putc(seq, ','); + seq_printf(seq, "%s", mbm_transactions[i].name); + sep =3D true; + } + } + seq_putc(seq, '\n'); + + mutex_unlock(&rdtgroup_mutex); + + return 0; +} + /** * resctrl_mon_resource_init() - Initialise global monitoring structures. * @@ -982,6 +1005,7 @@ int resctrl_mon_resource_init(void) RFTYPE_MON_INFO | RFTYPE_RES_CACHE); resctrl_file_fflags_init("available_mbm_cntrs", RFTYPE_MON_INFO | RFTYPE_RES_CACHE); + resctrl_file_fflags_init("event_filter", RFTYPE_ASSIGN_CONFIG); } =20 return 0; diff --git a/fs/resctrl/rdtgroup.c b/fs/resctrl/rdtgroup.c index 15d10c346307..11fc8e362ead 100644 --- a/fs/resctrl/rdtgroup.c +++ b/fs/resctrl/rdtgroup.c @@ -975,7 +975,7 @@ static int rdt_last_cmd_status_show(struct kernfs_open_= file *of, return 0; } =20 -static void *rdt_kn_parent_priv(struct kernfs_node *kn) +void *rdt_kn_parent_priv(struct kernfs_node *kn) { /* * The parent pointer is only valid within RCU section since it can be @@ -2019,6 +2019,12 @@ static struct rftype res_common_files[] =3D { .seq_show =3D mbm_local_bytes_config_show, .write =3D mbm_local_bytes_config_write, }, + { + .name =3D "event_filter", + .mode =3D 0444, + .kf_ops =3D &rdtgroup_kf_single_ops, + .seq_show =3D event_filter_show, + }, { .name =3D "mbm_assign_mode", .mode =3D 0444, @@ -2279,10 +2285,48 @@ int rdtgroup_kn_mode_restore(struct rdtgroup *r, co= nst char *name, return ret; } =20 +static int resctrl_mkdir_event_configs(struct rdt_resource *r, struct kern= fs_node *l3_mon_kn) +{ + struct kernfs_node *kn_subdir, *kn_subdir2; + struct mon_evt *mevt; + int ret; + + kn_subdir =3D kernfs_create_dir(l3_mon_kn, "event_configs", l3_mon_kn->mo= de, NULL); + if (IS_ERR(kn_subdir)) + return PTR_ERR(kn_subdir); + + ret =3D rdtgroup_kn_set_ugid(kn_subdir); + if (ret) + return ret; + + for_each_mon_event(mevt) { + if (mevt->rid !=3D r->rid || !mevt->enabled || !resctrl_is_mbm_event(mev= t->evtid)) + continue; + + kn_subdir2 =3D kernfs_create_dir(kn_subdir, mevt->name, kn_subdir->mode,= mevt); + if (IS_ERR(kn_subdir2)) { + ret =3D PTR_ERR(kn_subdir2); + goto out; + } + + ret =3D rdtgroup_kn_set_ugid(kn_subdir2); + if (ret) + goto out; + + ret =3D rdtgroup_add_files(kn_subdir2, RFTYPE_ASSIGN_CONFIG); + if (ret) + break; + } + +out: + return ret; +} + static int rdtgroup_mkdir_info_resdir(void *priv, char *name, unsigned long fflags) { struct kernfs_node *kn_subdir; + struct rdt_resource *r; int ret; =20 kn_subdir =3D kernfs_create_dir(kn_info, name, @@ -2295,6 +2339,18 @@ static int rdtgroup_mkdir_info_resdir(void *priv, ch= ar *name, return ret; =20 ret =3D rdtgroup_add_files(kn_subdir, fflags); + if (ret) + return ret; + + if ((fflags & RFTYPE_MON_INFO) =3D=3D RFTYPE_MON_INFO) { + r =3D priv; + if (r->mon.mbm_cntr_assignable) { + ret =3D resctrl_mkdir_event_configs(r, kn_subdir); + if (ret) + return ret; + } + } + if (!ret) kernfs_activate(kn_subdir); =20 --=20 2.34.1 From nobody Mon Oct 6 01:21:11 2025 Received: from NAM12-MW2-obe.outbound.protection.outlook.com (mail-mw2nam12on2074.outbound.protection.outlook.com [40.107.244.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 A8976255F2F; Fri, 25 Jul 2025 18:34:46 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.244.74 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1753468489; cv=fail; b=TpdifdPTqlRheuX2Mk4iBScLa0WH7boUC5wyQW8Q2Z1R/G1lD16q4EyAjBLkNFvwKe3Ds2UDSwTYQmx1TF8IGJPAt/aGP++Ta63YwWJca7hxNRZ8rl/bKTwmyi7v55P7cikOghwwbe0kG/Lj0IWst4x2SxjAlERpCQKVrj4z6Og= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1753468489; c=relaxed/simple; bh=27tMKmK2t7rrxKQNLqDUqTI7fh6qj5ufwqrN7t9Dr4c=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=IQZT+be1MEGWiM9IF4oOlt6dL3/DnuNz009+JINjCjCg+jp3Ys4fnCcS69eJc70m+MNYMVszRdZDAep00ToPSI6ZwsKrFG8eCHfJEBWED6GSVp3H1JDytf0EN8QasspWd2gZTpUuuBLMGYLvSm0mURXo7JPpIG6VP1CVEnmHa90= 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=YMsaHyll; arc=fail smtp.client-ip=40.107.244.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="YMsaHyll" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=jj2ykW0lgHd7nYa4pw04M3lJgwwSczvaBGX1fhVu+71uE1luP6WXFCo74Rlgj/tJ+y+btLVLueXAxg0Aj4K5UgDVtpcOm+XNs5iJLgi+jgVol/vXZUJK+qaqPFZRsdlza23MDcGd4CDI61x4g2PEa74DS3vIipS6N+8wMtnKo3jQY8iKy+EZLaUPm3Ks0jiVoww85TXWOW9LQi4crRUqdqZ3mjGBf9pgCEUku1xWDCi+fAfzdmlQj2qvqoyeYdraqCFtH5qZoCnalZQFCQVFgEU23KHvupnUlQOVJI7UioNcWy/LuxuW8t6EBGZ7d416zyvIczraL98XaGt88rBMkg== 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=7fqcyS5KUHM1y4r1j4/bvXyp/+sBfji8dITO0CSjC5A=; b=IAKEZvrvXaBnKn/QUvwJ3iF48JhZ5fz5TmyQOsQkPh/nf2z1ALwKfh0ZCbo0PtUYc/maCrb8t3h1XrcuBFbH+UCMUnLQ1KGO0hH6MWFTOnydOsjVlxGkbZQ+IFE/DZH1g8G/rmVEzWsoiyutDM9lYEdbMPnQxLn4GKLFsAOLGeSv+DXc+Osk6IDJDSLViqYLqgzLdj3YTPe4JluSIpYPnxH6yMdxNi/l48rrKD6W7qoubHMx4ycgxvtJSFqrnxCVd/xQADqtwa+0vtB2PZhEEIxUsn7v3dl0hkRxYr83uxWnDPO5Zd6gRGaaGbpkg/oCjXXfWHQGfKyVejZG0MWDbQ== 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=7fqcyS5KUHM1y4r1j4/bvXyp/+sBfji8dITO0CSjC5A=; b=YMsaHyllEfdstq3rJXIcTtrOQxRfcAELIHtVcW4HWHfB4yiGDl2UNv4DP/lLW6crdzwzr0kOn6lL9ZC5dJulfXT4YR5w4O9rfjF6HqEldIxVKSR8j93SGcQUbKVdGji0WlJGu6NiWxLdq6UebRHaRva3cwsm0BJwRvV9XYxE0Tk= Received: from CY5PR19CA0026.namprd19.prod.outlook.com (2603:10b6:930:15::30) by DS4PR12MB9561.namprd12.prod.outlook.com (2603:10b6:8:282::9) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8964.23; Fri, 25 Jul 2025 18:34:44 +0000 Received: from CY4PEPF0000EE3F.namprd03.prod.outlook.com (2603:10b6:930:15:cafe::14) by CY5PR19CA0026.outlook.office365.com (2603:10b6:930:15::30) with Microsoft SMTP Server (version=TLS1_3, cipher=TLS_AES_256_GCM_SHA384) id 15.20.8964.23 via Frontend Transport; Fri, 25 Jul 2025 18:34:44 +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 CY4PEPF0000EE3F.mail.protection.outlook.com (10.167.242.17) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.8964.20 via Frontend Transport; Fri, 25 Jul 2025 18:34:43 +0000 Received: from bmoger-ubuntu.amd.com (10.180.168.240) by SATLEXMB04.amd.com (10.181.40.145) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.39; Fri, 25 Jul 2025 13:34:41 -0500 From: Babu Moger To: , , , , , , , CC: , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , Subject: [PATCH v16 26/34] fs/resctrl: Provide interface to update the event configurations Date: Fri, 25 Jul 2025 13:29:45 -0500 Message-ID: <15ecac1be290452ff119f67f640c26b8203a4c01.1753467772.git.babu.moger@amd.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: References: Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-ClientProxiedBy: SATLEXMB03.amd.com (10.181.40.144) To SATLEXMB04.amd.com (10.181.40.145) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CY4PEPF0000EE3F:EE_|DS4PR12MB9561:EE_ X-MS-Office365-Filtering-Correlation-Id: e05b94ed-eea6-4244-eaeb-08ddcba9ecc5 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|36860700013|7416014|82310400026|376014|1800799024; X-Microsoft-Antispam-Message-Info: =?us-ascii?Q?H3K3bSKckDtTYVrnd3sTyKADG0T4ckJFtizwLjfw2e1DrAAEwqxEML2oYYD6?= =?us-ascii?Q?NCiKz8zH2C+sV8a3jSzg5z6ENKAzSOEdjPridBNXvJ6noZ6x8GhiD5sr235h?= =?us-ascii?Q?uoItbFfhC6BUwcYWnBWqKHqdAJuRt6tIQOi25bh+cU9pPIPcRO5XBNGJ5f/9?= =?us-ascii?Q?jVRWBRsiNhpYrKl2DmRcWFTJqTpfWVxAbe0otnHneU5gcdSikyljsupqm7zs?= =?us-ascii?Q?XDSqT6+wEPU/DTu6/j+DnOuXca4T0KX9MuJtn3EegR9tsIJhw5eI+OxDKw7j?= =?us-ascii?Q?Pa6W2+cOekj2oxHuZqymkPs/k6PU6bz+hWS5XUuyDMUBbLHWPgi84x/gq6OX?= =?us-ascii?Q?S47G6btgJKXUQ1ZP2YrqfQZZaUZX4A4taXL6DTrRrccPV+xTgMdEh6gf707Q?= =?us-ascii?Q?AD3fX0q6zbV/QiYV1Su9KNw1RECxMbgQKDTCE1K4jDCejImAvg0toglmJSFo?= =?us-ascii?Q?UlWGyX7zhUqerIqYsx15HpP13JNg73UC+P7nYSarc3jNblnoq+wbd2k5Be/i?= =?us-ascii?Q?+LWkq5+wdrzp/n98zbk+uzd7g6DaJ05jcdcS3qT/qVNs0QIM90VWgw9N7qS/?= =?us-ascii?Q?zsw0lzz4d0W5Y+ls3BS5OKubnaBRCaoYlsrP4qI93VTOeuBXGue0TkUXeFxn?= =?us-ascii?Q?wbdj1ch//M9yI5p/xAvz9h7YoXODfL3x+8rdnuxC+K7sg5lJ9Kq1RFHmbCF4?= =?us-ascii?Q?hac9cHab+cSacXsrRTiActgQlbiFyrFRjsNNSe1ivcP+qk4u2D6e22zYr1O+?= =?us-ascii?Q?bwuapxkQBWln+zpxKhQjcWAOLEpjrb+fTlaWPCjXaitp/g2tvd36KEqbYJfP?= =?us-ascii?Q?4v6Rfg4cJF4eGxVA93XtAj3/CPnWfUtDG5feSpsBq4HK0eJ2mrixkdQTzNHl?= =?us-ascii?Q?IVjyItvu0+WAjUhrSeApf902ZO0LXu4GwzfJQ9GEOCquLN6ATZD2U4X9TZSS?= =?us-ascii?Q?Cgi9L1sSkS4flHPjfenasVWJG/Dh3MFJGWxH8gOiTY/qSn+UH+O10Xp+f1yT?= =?us-ascii?Q?gg8sq2y663LyhzcSdsRr/9CcM8hRr1760e8y22wY8QzTjWKp9VE1xwPyKZVT?= =?us-ascii?Q?Xd7phikO587sHBdjFy8N+xGS9oNOiap+sulP9q6O5W5j0KrbfvN/hFXIrIm1?= =?us-ascii?Q?Z5/lMVDpxv2j2rekKoA3thGqe5hEgv41Q52bJ0oXWVmlbVPxqLYOjYRrFHC2?= =?us-ascii?Q?wDABB8WSJYlsyUWqueJJH1o90NXEpVZg3IId9IcNgiz79tK+Y7FjU2G7tU0F?= =?us-ascii?Q?YD0ZEsYENv9vKGc1fevZIWX7Rh+P3GIUQh2u3jXA0wPZCYtKqQ2fHAIuTEPY?= =?us-ascii?Q?FYB8PkGNF1VgQKorgXyUL6wf+KrMkYrfG2zKjjrdhro/vVvQJwHGOGEzkq5u?= =?us-ascii?Q?0xCufjlmDsfzbelTCDNKYAdIzHkElZo5XKYYERkmQ/0KPDc+6ZbnNOdNUIHL?= =?us-ascii?Q?jq4zuC5EGu8T9AxHa280Rh8PgQ86+RiSbfMk+g0tgUZt30rvyP7DiMNKpKoQ?= =?us-ascii?Q?CC3b84gW5tHskOnGDtYEv25631zL1cd+mHxS?= 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)(7416014)(82310400026)(376014)(1800799024);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 25 Jul 2025 18:34:43.7902 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: e05b94ed-eea6-4244-eaeb-08ddcba9ecc5 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: CY4PEPF0000EE3F.namprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DS4PR12MB9561 Content-Type: text/plain; charset="utf-8" When "mbm_event" counter assignment mode is supported, users can modify the event configuration by writing to the 'event_filter' resctrl file. The event configurations for mbm_event mode are located in /sys/fs/resctrl/info/L3_MON/event_configs/. Update the assignments of all CTRL_MON and MON resource groups when the event configuration is modified. Example: $ mount -t resctrl resctrl /sys/fs/resctrl $ cd /sys/fs/resctrl/ $ cat info/L3_MON/event_configs/mbm_local_bytes/event_filter local_reads,local_non_temporal_writes,local_reads_slow_memory $ echo "local_reads,local_non_temporal_writes" > info/L3_MON/event_configs/mbm_total_bytes/event_filter $ cat info/L3_MON/event_configs/mbm_total_bytes/event_filter local_reads,local_non_temporal_writes Signed-off-by: Babu Moger --- v16: Moved resctrl_process_configs() and event_filter_write() to fs/resctrl/monitor.c. Renamed resctrl_process_configs() -> resctrl_parse_mem_transactions(). Few minor code commnet update. v15: Updated changelog. Updated spacing in resctrl.rst. Corrected the name counter_configs -> event_configs. Changed the name rdtgroup_assign_cntr() > rdtgroup_update_cntr_event(). Removed the code to check d->cntr_cfg[cntr_id].evt_cfg. Fixed the partial initialization of val in resctrl_process_configs(). Passed mon_evt where applicable. The struct rdt_resource can be obtain= ed from mon_evt::rid. v14: Passed struct mon_evt where applicable instead of just the event type. Fixed few text corrections about memory trasaction type. Renamed few functions resctrl_group_assign() -> rdtgroup_assign_cntr() resctrl_update_assign() -> resctrl_assign_cntr_allrdtgrp() Removed few extra bases. v13: Updated changelog for imperative mode. Added function description in the prototype. Updated the user doc resctrl.rst to address few feedback. Resolved conflicts caused by the recent FS/ARCH code restructure. The rdtgroup.c/monitor.c file has now been split between the FS and AR= CH directories. v12: New patch to modify event configurations. --- Documentation/filesystems/resctrl.rst | 12 +++ fs/resctrl/internal.h | 4 + fs/resctrl/monitor.c | 114 ++++++++++++++++++++++++++ fs/resctrl/rdtgroup.c | 3 +- 4 files changed, 132 insertions(+), 1 deletion(-) diff --git a/Documentation/filesystems/resctrl.rst b/Documentation/filesyst= ems/resctrl.rst index 3dfc177f9792..37dbad4d50f7 100644 --- a/Documentation/filesystems/resctrl.rst +++ b/Documentation/filesystems/resctrl.rst @@ -342,6 +342,18 @@ with the following files: # cat /sys/fs/resctrl/info/L3_MON/event_configs/mbm_local_bytes/event_f= ilter local_reads,local_non_temporal_writes,local_reads_slow_memory =20 + Modify the event configuration by writing to the "event_filter" file with= in + the "event_configs" directory. The read/write "event_filter" file contain= s the + configuration of the event that reflects which memory transactions are co= unted by it. + + For example:: + + # echo "local_reads, local_non_temporal_writes" > + /sys/fs/resctrl/info/L3_MON/event_configs/mbm_total_bytes/event_filter + + # cat /sys/fs/resctrl/info/L3_MON/event_configs/mbm_total_bytes/event_f= ilter + local_reads,local_non_temporal_writes + "max_threshold_occupancy": Read/write file provides the largest value (in bytes) at which a previously used LLC_occupancy diff --git a/fs/resctrl/internal.h b/fs/resctrl/internal.h index e082d8718199..e2e3fc0c5fab 100644 --- a/fs/resctrl/internal.h +++ b/fs/resctrl/internal.h @@ -409,11 +409,15 @@ void rdtgroup_unassign_cntr_event(struct rdt_mon_doma= in *d, struct rdtgroup *rdt struct mon_evt *mevt); int mbm_cntr_get(struct rdt_resource *r, struct rdt_mon_domain *d, struct rdtgroup *rdtgrp, enum resctrl_event_id evtid); +void resctrl_update_cntr_allrdtgrp(struct mon_evt *mevt); =20 void *rdt_kn_parent_priv(struct kernfs_node *kn); =20 int event_filter_show(struct kernfs_open_file *of, struct seq_file *seq, v= oid *v); =20 +ssize_t event_filter_write(struct kernfs_open_file *of, char *buf, size_t = nbytes, + loff_t off); + #ifdef CONFIG_RESCTRL_FS_PSEUDO_LOCK int rdtgroup_locksetup_enter(struct rdtgroup *rdtgrp); =20 diff --git a/fs/resctrl/monitor.c b/fs/resctrl/monitor.c index fa5f63126682..8efbeb910f77 100644 --- a/fs/resctrl/monitor.c +++ b/fs/resctrl/monitor.c @@ -952,6 +952,77 @@ int event_filter_show(struct kernfs_open_file *of, str= uct seq_file *seq, void *v return 0; } =20 +static int resctrl_parse_mem_transactions(char *tok, u32 *val) +{ + u32 temp_val =3D 0; + char *evt_str; + bool found; + int i; + +next_config: + if (!tok || tok[0] =3D=3D '\0') { + *val =3D temp_val; + return 0; + } + + /* Start processing the strings for each memory transaction type */ + evt_str =3D strim(strsep(&tok, ",")); + found =3D false; + for (i =3D 0; i < NUM_MBM_TRANSACTIONS; i++) { + if (!strcmp(mbm_transactions[i].name, evt_str)) { + temp_val |=3D mbm_transactions[i].val; + found =3D true; + break; + } + } + + if (!found) { + rdt_last_cmd_printf("Invalid memory transaction type %s\n", evt_str); + return -EINVAL; + } + + goto next_config; +} + +ssize_t event_filter_write(struct kernfs_open_file *of, char *buf, size_t = nbytes, + loff_t off) +{ + struct mon_evt *mevt =3D rdt_kn_parent_priv(of->kn); + struct rdt_resource *r; + u32 evt_cfg =3D 0; + int ret =3D 0; + + /* Valid input requires a trailing newline */ + if (nbytes =3D=3D 0 || buf[nbytes - 1] !=3D '\n') + return -EINVAL; + + buf[nbytes - 1] =3D '\0'; + + cpus_read_lock(); + mutex_lock(&rdtgroup_mutex); + + rdt_last_cmd_clear(); + + r =3D resctrl_arch_get_resource(mevt->rid); + if (!resctrl_arch_mbm_cntr_assign_enabled(r)) { + rdt_last_cmd_puts("mbm_event counter assignment mode is not enabled\n"); + ret =3D -EINVAL; + goto out_unlock; + } + + ret =3D resctrl_parse_mem_transactions(buf, &evt_cfg); + if (!ret && mevt->evt_cfg !=3D evt_cfg) { + mevt->evt_cfg =3D evt_cfg; + resctrl_update_cntr_allrdtgrp(mevt); + } + +out_unlock: + mutex_unlock(&rdtgroup_mutex); + cpus_read_unlock(); + + return ret ?: nbytes; +} + /** * resctrl_mon_resource_init() - Initialise global monitoring structures. * @@ -1193,3 +1264,46 @@ void rdtgroup_unassign_cntr_event(struct rdt_mon_dom= ain *d, struct rdtgroup *rdt rdtgroup_free_unassign_cntr(r, d, rdtgrp, mevt); } } + +/* + * rdtgroup_update_cntr_event - Update the counter assignments for the eve= nt + * in a group. + * @r: Resource to which update needs to be done. + * @rdtgrp: Resctrl group. + * @evtid: MBM monitor event. + */ +static void rdtgroup_update_cntr_event(struct rdt_resource *r, struct rdtg= roup *rdtgrp, + enum resctrl_event_id evtid) +{ + struct rdt_mon_domain *d; + int cntr_id; + + list_for_each_entry(d, &r->mon_domains, hdr.list) { + cntr_id =3D mbm_cntr_get(r, d, rdtgrp, evtid); + if (cntr_id >=3D 0) + resctrl_arch_config_cntr(r, d, evtid, rdtgrp->mon.rmid, + rdtgrp->closid, cntr_id, true); + } +} + +/* + * resctrl_update_cntr_allrdtgrp - Update the counter assignments for the = event + * for all the groups. + * @mevt MBM Monitor event. + */ +void resctrl_update_cntr_allrdtgrp(struct mon_evt *mevt) +{ + struct rdt_resource *r =3D resctrl_arch_get_resource(mevt->rid); + struct rdtgroup *prgrp, *crgrp; + + /* + * Find all the groups where the event is assigned and update the + * configuration of existing assignments. + */ + list_for_each_entry(prgrp, &rdt_all_groups, rdtgroup_list) { + rdtgroup_update_cntr_event(r, prgrp, mevt->evtid); + + list_for_each_entry(crgrp, &prgrp->mon.crdtgrp_list, mon.crdtgrp_list) + rdtgroup_update_cntr_event(r, crgrp, mevt->evtid); + } +} diff --git a/fs/resctrl/rdtgroup.c b/fs/resctrl/rdtgroup.c index 11fc8e362ead..c3d6540c3280 100644 --- a/fs/resctrl/rdtgroup.c +++ b/fs/resctrl/rdtgroup.c @@ -2021,9 +2021,10 @@ static struct rftype res_common_files[] =3D { }, { .name =3D "event_filter", - .mode =3D 0444, + .mode =3D 0644, .kf_ops =3D &rdtgroup_kf_single_ops, .seq_show =3D event_filter_show, + .write =3D event_filter_write, }, { .name =3D "mbm_assign_mode", --=20 2.34.1 From nobody Mon Oct 6 01:21:11 2025 Received: from NAM10-DM6-obe.outbound.protection.outlook.com (mail-dm6nam10on2061.outbound.protection.outlook.com [40.107.93.61]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 9B81B25179A; Fri, 25 Jul 2025 18:34:57 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.93.61 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1753468499; cv=fail; b=X2MDcYa2v5wZ3eOU8S5GlsUzfDXz0U+GKM3PysgdlU1fBgvJWFcfOqLBGOLXQP7B3+7dfWEo+mVevPndZQ0pvK3kIR7G8AgKKJkznkpancBdu3xmQT2tQLAHA4G1NBMj0MKrZxSyQTriO7Kq4kWDGJh555tuOfB+f3LfFAK3PQ4= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1753468499; c=relaxed/simple; bh=lQAV6E6a0QXwHOP10eGcUnkjT6wZ+Tcw8KN8WMwG5Is=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=ULeHZbt8c/XI637XBvgcrT0y8QCSQOGBKj5befC83vSTDD3khsZkMaxs9psJkix1X7b99YUaOI0OdDUs4ZHXCw1xR428Tlcx+U8c4ZeBj5FsVbh+oX9sBBUrS3n2U44lcHXtN1vU7LZf2J06ZpEv0asZmWwLt33nO+HnfikDZP8= 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=WJR0vq56; arc=fail smtp.client-ip=40.107.93.61 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=amd.com Authentication-Results: smtp.subspace.kernel.org; spf=fail smtp.mailfrom=amd.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=amd.com header.i=@amd.com header.b="WJR0vq56" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=Cz1DXMmEDqxgfm5kUjAEtieTWJeIObNpmOOxEEzdBeWDdM1AJo0CFTsnSzDkCWxwdxJTvHWHssUtAorZKP+GYmzJAU1o8sQXFK1/LKymMeXnE4JLEWI0w5B4d7X5/cwcxyzOKHJ+F8xO0ULaUpAZ431R6adynLv6LZYvRPO26ALAfgTA+1rgTqsEypgyeMm3wo81Wpp5HUEsHoAv88QTAgsSANoNzwz5rQL7HCZeMGrZhkJZybOm2uJTtpZZH8h9SOdkMLqRxz2wrJzqDqElNvdxq4iKXnyVB2585CCao5VBn6V8pnZrdbZhgsxMKSQqXOoTUMDIFx1+2YmZIOeigA== 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=Kdx9KfBEOc8eyORCXiD9/gaay6nKqUevzU17YxS3FrI=; b=zPyAmEqcGMWJHNVMEVNxqfc2G8iuVELyKJotgPCLeVrmTCticYN+Zs6TSgUlS/dRgl73v6eTl/Yyf0DXzM4jYoHcwHger1AiHJxTVmINLwRwC/j4k7hLhpXXXkOMUMt4+zhuWAHevGEBa+HZUjAVbjctPoiLNb8jDDFR1qcxU/UWa9XojYZpcixuvYvMwLUWEfVa97uKu9pWPcBCUKBMolO3t0vyV+BZaPUWJuax3HoxRM4Z9stGjAtRdsPlNqSYcCUx0cX0deny1rgiyndxy2DnTIqqK0t5CfV78eoliD/Ky9HDm+7JDxCl9NsKkhYuMjyxvjBmqMZoVbg0itj7GA== 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=Kdx9KfBEOc8eyORCXiD9/gaay6nKqUevzU17YxS3FrI=; b=WJR0vq56OF48vPpOl/oN6QR4FPNrHcKo2Xt148UUQ9vUbLMKEDirpqzpMrBmUebcj0XuRrKMOLMR5FwP7RRrJzOAfjg5N6xggkglD3ZMFxRX/IvLmYhkuICf5fX+tqf+ChN3R0cBwur6aYmWEKSDLKaeX4F+EW6/haBwkzEMmEo= Received: from DM6PR08CA0028.namprd08.prod.outlook.com (2603:10b6:5:80::41) by DM4PR12MB6135.namprd12.prod.outlook.com (2603:10b6:8:ac::5) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8901.35; Fri, 25 Jul 2025 18:34:53 +0000 Received: from CY4PEPF0000EE3A.namprd03.prod.outlook.com (2603:10b6:5:80:cafe::6c) by DM6PR08CA0028.outlook.office365.com (2603:10b6:5:80::41) with Microsoft SMTP Server (version=TLS1_3, cipher=TLS_AES_256_GCM_SHA384) id 15.20.8964.23 via Frontend Transport; Fri, 25 Jul 2025 18:34:52 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 165.204.84.17) smtp.mailfrom=amd.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=amd.com; Received-SPF: Pass (protection.outlook.com: domain of amd.com designates 165.204.84.17 as permitted sender) receiver=protection.outlook.com; client-ip=165.204.84.17; helo=SATLEXMB04.amd.com; pr=C Received: from SATLEXMB04.amd.com (165.204.84.17) by CY4PEPF0000EE3A.mail.protection.outlook.com (10.167.242.12) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.8964.20 via Frontend Transport; Fri, 25 Jul 2025 18:34:52 +0000 Received: from bmoger-ubuntu.amd.com (10.180.168.240) by SATLEXMB04.amd.com (10.181.40.145) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.39; Fri, 25 Jul 2025 13:34:50 -0500 From: Babu Moger To: , , , , , , , CC: , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , Subject: [PATCH v16 27/34] fs/resctrl: Introduce mbm_assign_on_mkdir to enable assignments on mkdir Date: Fri, 25 Jul 2025 13:29:46 -0500 Message-ID: X-Mailer: git-send-email 2.34.1 In-Reply-To: References: Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-ClientProxiedBy: SATLEXMB03.amd.com (10.181.40.144) To SATLEXMB04.amd.com (10.181.40.145) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CY4PEPF0000EE3A:EE_|DM4PR12MB6135:EE_ X-MS-Office365-Filtering-Correlation-Id: 97f12175-c080-4852-15e2-08ddcba9f1f0 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|1800799024|376014|36860700013|82310400026|7416014|13003099007; X-Microsoft-Antispam-Message-Info: =?us-ascii?Q?lWrJK5kFpR7Lw+Fheeh0go9Vb1TaXiDhl0W1oJr9ILCwWuK1XIn9m2dOt6NB?= =?us-ascii?Q?68VavJS3Vwcbv3KAJu2XjScz0P3B9TaSZhApkSgHkm2xgBYX7cesRHFJgk5j?= =?us-ascii?Q?ZNCEDytP1LLBd1iZqJEa+AMOeY4WSY3BPdgQnJZF5musD72RzTinx12UKxgb?= =?us-ascii?Q?pJYhTaKn6MVg1UW6XRgwI/3RWgIpf1g+Cqt/NI3Gp5uWwfJ6D+fRFu+q5ogH?= =?us-ascii?Q?c53FmJLsbmyQ1flBN0BUF5sCENEkjlV0j++SlQEQByCLPpNfAQStuIcssaTd?= =?us-ascii?Q?YmcAbIBwxHJlSNUsiu80fWWy1q8C4G3ahAlAw61CPIRFUbrt9Y1ZVBQcbhZ7?= =?us-ascii?Q?3ZKGHWnrV+WtQ5JUYTGODF9DnczZiPoPqr9CMru4gHNxM8nY5PSfubM8LW9X?= =?us-ascii?Q?eJWUhHpO+kUR4uZKzfidCfN1tRuRWDx1fsXkltULAkzyoAouX0bsEm9Q/jBo?= =?us-ascii?Q?0AlXNvgEfFHHBuAnVO0d8dTrKkZoh7Cu7Y+AkzTYUXdMveplOQbmMlITa3jj?= =?us-ascii?Q?j5TuZJtAC1UWh7XK7aa4j9i8qAd4tEe1kEIjGoiDn98bYIh+FC+j2cDZWK/+?= =?us-ascii?Q?nwOSsQ/SFlaYoO4b/hmFb8s6DwerCUsxP75A2AVcan8Rx+d87sW9fFUkxVIM?= =?us-ascii?Q?edwROm+kNItVWzENJwJ7s583JZJs3Bc7qbB+Jhs+ihXbFFgDP2hsC/zx6y7p?= =?us-ascii?Q?k+zHv6a0oElKeki9Voiudxb3Yajd2YW9UGL9X2OCF7fiKDRIeZWHG5pmw8fO?= =?us-ascii?Q?7P2xh9O2r2XkffkgYq0/Eu4gSvRtvmhxgGZFrx5bymYYco9wYF+x5NsH99A+?= =?us-ascii?Q?C7gJEC2DxoBycTYC8t+8YwaM68ZX8H9rmmoyv6ybbiOXhByiAHlYTYEBErc7?= =?us-ascii?Q?ymhvkEh03jjVn8pRMlUAOwstEhF9Me/AhM0HJN3VRLZYbcnviEjKbXg8rN3Q?= =?us-ascii?Q?kFpAgADaekb3YhXXfVIcH74wo7eX1rOHJgfYgzMO2T3i2rxWqNhwaAUr4LPs?= =?us-ascii?Q?Ep/51p8M1hhuLahYIkV/0lKZ4Mw+OYzOqO393TF6ZNBTwfymp+xN7zJK37F9?= =?us-ascii?Q?n4v0TLZRJV3j8DrJpRDPygn5xf6EAoAuqJBVEP/k6ynXcB4cJDInV3a6sMTP?= =?us-ascii?Q?O5Y5BQ0iZZq1PY9RRrfO2KKmzgff5VDhVEktVdXtZRqeXurlHWRSf3/yYwYw?= =?us-ascii?Q?pGlVODi1sTiLBUFq54hTeMJ1Xs4ChQMd+tJ8lwXI3gXArf4pEBP+uOATEkVA?= =?us-ascii?Q?2jCeQ6oB8uBwZOLzFc69pJMG3HYNpwlGcGA8sYRiI1EHdH3oVC82k+4HafQn?= =?us-ascii?Q?mUvJHIWvI11njAREb9rR9vidmRUI73u3bMDl8dAtNS2QOyDdZORezs+KgJsM?= =?us-ascii?Q?HyzS0yRvSIH53100T5VB6LeTEg/iMCtnFymmt0JDcijS7CWW1hW3XUt46YDn?= =?us-ascii?Q?EcGz3k35ieHm9WWcxeMn+aU2yjYI/TalXR616iJNULVUdCLlMuLGmUBXjSF5?= =?us-ascii?Q?hOG/Kv3kXufyq5wwoIuCLMidlEMOZ2VsNTDC2cilVULc0SlLUtutjlh24g?= =?us-ascii?Q?=3D=3D?= X-Forefront-Antispam-Report: CIP:165.204.84.17;CTRY:US;LANG:en;SCL:1;SRV:;IPV:CAL;SFV:NSPM;H:SATLEXMB04.amd.com;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(13230040)(1800799024)(376014)(36860700013)(82310400026)(7416014)(13003099007);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 25 Jul 2025 18:34:52.4550 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 97f12175-c080-4852-15e2-08ddcba9f1f0 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: CY4PEPF0000EE3A.namprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM4PR12MB6135 Content-Type: text/plain; charset="utf-8" The "mbm_event" counter assignment mode allows users to assign a hardware counter to an RMID, event pair and monitor the bandwidth as long as it is assigned. Introduce a user-configurable option that determines if a counter will automatically be assigned to an RMID, event pair when its associated monitor group is created via mkdir. Suggested-by: Peter Newman Signed-off-by: Babu Moger --- v16: Fixed the return in resctrl_mbm_assign_on_mkdir_write(). v15: Fixed the static checker warning in resctrl_mbm_assign_on_mkdir_write(= ) reported in https://lore.kernel.org/lkml/dd4a1021-b996-438e-941c-69dfcea5f22a@inte= l.com/ v14: Added rdtgroup_mutex in resctrl_mbm_assign_on_mkdir_show(). Updated resctrl.rst for clarity. Fixed squashing of few previous changes. Added more code documentation. v13: Added Suggested-by tag. Resolved conflicts caused by the recent FS/ARCH code restructure. The rdtgroup.c/monitor.c file has now been split between the FS and AR= CH directories. v12: New patch. Added after the discussion on the list. https://lore.kernel.org/lkml/CALPaoCh8siZKjL_3yvOYGL4cF_n_38KpUFgHVGbQ= 86nD+Q2_SA@mail.gmail.com/ --- Documentation/filesystems/resctrl.rst | 16 ++++++++++ fs/resctrl/monitor.c | 2 ++ fs/resctrl/rdtgroup.c | 43 +++++++++++++++++++++++++++ include/linux/resctrl.h | 3 ++ 4 files changed, 64 insertions(+) diff --git a/Documentation/filesystems/resctrl.rst b/Documentation/filesyst= ems/resctrl.rst index 37dbad4d50f7..165e0d315af7 100644 --- a/Documentation/filesystems/resctrl.rst +++ b/Documentation/filesystems/resctrl.rst @@ -354,6 +354,22 @@ with the following files: # cat /sys/fs/resctrl/info/L3_MON/event_configs/mbm_total_bytes/event_f= ilter local_reads,local_non_temporal_writes =20 +"mbm_assign_on_mkdir": + Determines if a counter will automatically be assigned to an RMID, event = pair + when its associated monitor group is created via mkdir. It is enabled by = default + on boot and users can disable by writing to the interface. + + "0": + Auto assignment is disabled. + "1": + Auto assignment is enabled. + + Example:: + + # echo 0 > /sys/fs/resctrl/info/L3_MON/mbm_assign_on_mkdir + # cat /sys/fs/resctrl/info/L3_MON/mbm_assign_on_mkdir + 0 + "max_threshold_occupancy": Read/write file provides the largest value (in bytes) at which a previously used LLC_occupancy diff --git a/fs/resctrl/monitor.c b/fs/resctrl/monitor.c index 8efbeb910f77..6205bbfe08fb 100644 --- a/fs/resctrl/monitor.c +++ b/fs/resctrl/monitor.c @@ -1077,6 +1077,8 @@ int resctrl_mon_resource_init(void) resctrl_file_fflags_init("available_mbm_cntrs", RFTYPE_MON_INFO | RFTYPE_RES_CACHE); resctrl_file_fflags_init("event_filter", RFTYPE_ASSIGN_CONFIG); + resctrl_file_fflags_init("mbm_assign_on_mkdir", RFTYPE_MON_INFO | + RFTYPE_RES_CACHE); } =20 return 0; diff --git a/fs/resctrl/rdtgroup.c b/fs/resctrl/rdtgroup.c index c3d6540c3280..bf04235d2603 100644 --- a/fs/resctrl/rdtgroup.c +++ b/fs/resctrl/rdtgroup.c @@ -1895,6 +1895,42 @@ static int resctrl_available_mbm_cntrs_show(struct k= ernfs_open_file *of, return ret; } =20 +static int resctrl_mbm_assign_on_mkdir_show(struct kernfs_open_file *of, + struct seq_file *s, void *v) +{ + struct rdt_resource *r =3D rdt_kn_parent_priv(of->kn); + + mutex_lock(&rdtgroup_mutex); + rdt_last_cmd_clear(); + + seq_printf(s, "%u\n", r->mon.mbm_assign_on_mkdir); + + mutex_unlock(&rdtgroup_mutex); + + return 0; +} + +static ssize_t resctrl_mbm_assign_on_mkdir_write(struct kernfs_open_file *= of, + char *buf, size_t nbytes, loff_t off) +{ + struct rdt_resource *r =3D rdt_kn_parent_priv(of->kn); + bool value; + int ret; + + ret =3D kstrtobool(buf, &value); + if (ret) + return ret; + + mutex_lock(&rdtgroup_mutex); + rdt_last_cmd_clear(); + + r->mon.mbm_assign_on_mkdir =3D value; + + mutex_unlock(&rdtgroup_mutex); + + return nbytes; +} + /* rdtgroup information files for one cache resource. */ static struct rftype res_common_files[] =3D { { @@ -1904,6 +1940,13 @@ static struct rftype res_common_files[] =3D { .seq_show =3D rdt_last_cmd_status_show, .fflags =3D RFTYPE_TOP_INFO, }, + { + .name =3D "mbm_assign_on_mkdir", + .mode =3D 0644, + .kf_ops =3D &rdtgroup_kf_single_ops, + .seq_show =3D resctrl_mbm_assign_on_mkdir_show, + .write =3D resctrl_mbm_assign_on_mkdir_write, + }, { .name =3D "num_closids", .mode =3D 0444, diff --git a/include/linux/resctrl.h b/include/linux/resctrl.h index 4d37827121a6..632b9ee5466a 100644 --- a/include/linux/resctrl.h +++ b/include/linux/resctrl.h @@ -277,12 +277,15 @@ enum resctrl_schema_fmt { * monitoring events can be configured. * @num_mbm_cntrs: Number of assignable counters. * @mbm_cntr_assignable:Is system capable of supporting counter assignment? + * @mbm_assign_on_mkdir:True if counters should automatically be assigned = to MBM + * events of monitor groups created via mkdir. */ struct resctrl_mon { int num_rmid; unsigned int mbm_cfg_mask; int num_mbm_cntrs; bool mbm_cntr_assignable; + bool mbm_assign_on_mkdir; }; =20 /** --=20 2.34.1 From nobody Mon Oct 6 01:21:11 2025 Received: from NAM10-DM6-obe.outbound.protection.outlook.com (mail-dm6nam10on2053.outbound.protection.outlook.com [40.107.93.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 A5A7D253B66; Fri, 25 Jul 2025 18:35:08 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.93.53 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1753468510; cv=fail; b=rrB9D6m1ciuqTZaV42X01g+k15gg8EfFYKp5xkes8gAjx1Ko+AJC9nRIBaM8x3aR/sB0xINaG5LGkz3vfWv3jEOpDWoAPn+pFlGu7HP4aiGNrSZFhaMFJ2Y6y5+2X9wUx8sSze1FTFzEL3YbEQ3LmkJaF3fFiyKgs7Iq3GmmVqs= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1753468510; c=relaxed/simple; bh=i8qwNf9/OEwOIUPMT2djHtEDt9s83mNADT753UcJwoI=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=fXfLHuEgoesFfbX/SlIv6zK9OPLdnvzp6R/4rXSljnT7KSllzpr9Y5nyo8syty04stZlpGk04rHrH0de62M0GnTwm20ywIOH6V9JAAr8EhUi9C0ZCMNuOemMIVj2NOeGJzMkW6R54vWHQFste9y1PxNog/8/aWM5u/vZFMtNvtE= 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=vaFqA0B3; arc=fail smtp.client-ip=40.107.93.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="vaFqA0B3" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=iUjRZUDu5+ZIgASD4SUftPaCcNs9w6qCyfXMMsf9ED3+21xZPkufSyuMqnrIJxZZ9Mi9jTcH11teIUOU+w0vIj2scg894J9+j713hcQhI21gD7YGAJElXup2dBy44Da5wJHXrrVPIPqVvi2MyXlkv5j4KJc+6hXf6ZtBeSKIZ9SSDIvBBtKEYj2PUR9tr/f3KmrTzc6iknAdoihWjInpDMUtuDEow5mOKIcN9vVs0o2e2JTwCyX5qG9f+UiKYLpJhP/CCDP8DrnMWuCbxGMqY4VtcKk/ikdGtZWgIb0xlo3G72jUFGQ7umn14lmikvam9oHHFTCnQN90Yy4zRf31Xw== 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=DYNnqeTq45TYW5l1HN9pTKADPMSEBtmnRa/fUcbebzw=; b=Oz5OTWLW/2ZgOpQnW7+/Hqx4RRWjeGcILp63TlFC4REs+dRL1xzLWKZ8qfW6uqNBtVBjaW/QWo8m/2W8O/H2Nw2pzi7S/hO3lNbrV97WKin1P9Rbp3it+lE4M9P4QrxuhtLF3m4Hvcbk6Y+qu6Vm3/mzxAaopthWwu/MKIb2HPlqnxolqlOtzHeVRQhcvRWsay0N25TKz35/9B16+g2ScoSbroiT5NXesDQMR9OwAOacKRT3xt6stghA4hyN8jzINjC4tY6+LGFgXxhUo2xsjsNStJKvSLpZn4PDY4adwEf6npzcmr8Yp89E+j3UWKUyR1fWKUpJRIeI6cdNatizGQ== 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=DYNnqeTq45TYW5l1HN9pTKADPMSEBtmnRa/fUcbebzw=; b=vaFqA0B3UplBxMRnEy2EFvki7ffPqRltGVP8kd8mVRbw1PLIEL4+5YlgfWLvtCZW4gcYuUn/au4ve9eUYNg4mYTA42V4jH7eXcWwzyNc2lGionf2JgCPgeHSRT0wLMwXPzAq+qHHjTWAQSvHbypWhuSbt5Wy84OXwfHj5/38NrA= Received: from CH0P220CA0011.NAMP220.PROD.OUTLOOK.COM (2603:10b6:610:ef::13) by DS5PPF482CFEB7D.namprd12.prod.outlook.com (2603:10b6:f:fc00::64a) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8943.29; Fri, 25 Jul 2025 18:35:01 +0000 Received: from CY4PEPF0000EE38.namprd03.prod.outlook.com (2603:10b6:610:ef:cafe::b) by CH0P220CA0011.outlook.office365.com (2603:10b6:610:ef::13) with Microsoft SMTP Server (version=TLS1_3, cipher=TLS_AES_256_GCM_SHA384) id 15.20.8943.31 via Frontend Transport; Fri, 25 Jul 2025 18:35: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 CY4PEPF0000EE38.mail.protection.outlook.com (10.167.242.10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.8964.20 via Frontend Transport; Fri, 25 Jul 2025 18:35: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; Fri, 25 Jul 2025 13:34:58 -0500 From: Babu Moger To: , , , , , , , CC: , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , Subject: [PATCH v16 28/34] fs/resctrl: Auto assign counters on mkdir and clean up on group removal Date: Fri, 25 Jul 2025 13:29:47 -0500 Message-ID: X-Mailer: git-send-email 2.34.1 In-Reply-To: References: Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-ClientProxiedBy: SATLEXMB03.amd.com (10.181.40.144) To SATLEXMB04.amd.com (10.181.40.145) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CY4PEPF0000EE38:EE_|DS5PPF482CFEB7D:EE_ X-MS-Office365-Filtering-Correlation-Id: 642e8b3c-3c1b-4aed-4a37-08ddcba9f737 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?/uWKM8k3fGSPuRBhYmBLUNBA2fc1nEGMguRJYP2rNzofO894A8dlyjtEt9RU?= =?us-ascii?Q?NBr+ajQk5Giwceqes6TbzB+qJ8qrfLbIvwz2xUe38+LVGsGgUmaXx/FgoXlx?= =?us-ascii?Q?eZjBMnbExiZ6nlLKDA66QhqKMBSij/7CBDy3bRTwCGzHWSRgU2Vwfiedh/AM?= =?us-ascii?Q?zBRl1zhhf1a1/cD3vcHEyGEyp2jNmCXvoUXha32Jnja1XCtdOMSae/vpqGwL?= =?us-ascii?Q?EqFARwuZe0/Tz2KnHCWhbHB5RtRn5fM/IBWb8N4VjHhvqUvx1KdckzfjdBP1?= =?us-ascii?Q?xie1KavCwW53fhf7Y8kBXgWwW3K2J9/Nhn7EY6sN2iKhWa5qMCcESvlgl/W2?= =?us-ascii?Q?JLACklIHAHpc2zD1kvh3KTENZ2tZsEcBUVQPYcARxbYjDN39nKue2OBVqtUe?= =?us-ascii?Q?ix+W3fYKI0eedcTj6iVWHJXbSo/heDlnskT49GKSCHs1WJwi9UeDGw4ACZAE?= =?us-ascii?Q?Qe+twH1cdsUPyUmigiZd54TqSV24gTTZVi9tu7WGZ0M7PVTPe/F0Bid0YCA4?= =?us-ascii?Q?ba89FcLlhVdF1+wnoV2k/vLHo0Co1i/fxtYoDUt9Ppr6qGNVwysoJnBHICGh?= =?us-ascii?Q?WecfRgMS1s4l1ga0RCSE+DSuOiiJogxl8/6CgeMWXWpODJHB6vfK4m3TkFth?= =?us-ascii?Q?A/5Nn8FR+pSBAmuOmZxC//Nmp2mwt08n5hAKyYmct4OUweAd7T1jb79EGn5j?= =?us-ascii?Q?WgRM3F39Gdsin1KQsAnVPYRgh53NQZmDaQumKjieaTgU5pONscwf+UTAgPaH?= =?us-ascii?Q?90bH9jDADpXIHK3kcfF4cejZ+V66wpd0ZNgZXbD9MooAq9nGCiQZRMcGs1ek?= =?us-ascii?Q?gVs+osrz+o+KLZgUsT1/3EvbOsGN2pbMvChHDtLiOgWPyqPPycyQeeKjQBpH?= =?us-ascii?Q?Ljrc3p3lfOPxEl1DA9xv+tiojgb3GveIlLN4ZNf3wYdycJtLu+ZGIb8Y+Si8?= =?us-ascii?Q?6+fVqw5OGFN5tl52xo5dGinwSUzm5FoFQwKUxbu8cnndam8OsPR4j1WhbFy+?= =?us-ascii?Q?jBLdCw7IINjD3xlzEzLobnFMU6rMtUaS86LtGYYhRfe8KBHlBF/4csq3BqIe?= =?us-ascii?Q?QrHmijbLb3Iw/OJLbs+3p23ttigoY6esjb4Q+CD9kuzJgkqDKjhv4LpY5+8s?= =?us-ascii?Q?4fFR+wBZhLnygnOHt6a9Nv2FQjQydMMMapSi5FewtineFUsiH38cXhqK4rkZ?= =?us-ascii?Q?gjk6MXXwOq+3B/rx+5BL5O7WIVjEbGP41AJUh8+k9TWAgWdt++OnJMjXNBAM?= =?us-ascii?Q?nRqFnSI7PFuZ3e28A3WUE61/px5M439a45Q6TZf2hzBzlD5Yeok09LRKeXXx?= =?us-ascii?Q?nKTtwJb1aZg7YHqKUMBxf9gyrT5pAwfDUNeytlcdnwo6N8dnbyl3kaygLG4B?= =?us-ascii?Q?crNYIqj5hm7JAgf/KT9eyJSPWXfbz/UXFrrl7ILZj9MJuQNCkNybV0XoHFmX?= =?us-ascii?Q?hwHBoE4HeYYgyww7PEgiits8N25lt17IwX36JaKxhlMk+XryY2tYEA3J5wvZ?= =?us-ascii?Q?ExuzqLySKNyJ2LqVoO/OcMBatQBpgpbJBYQ5?= 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: 25 Jul 2025 18:35:01.3093 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 642e8b3c-3c1b-4aed-4a37-08ddcba9f737 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: CY4PEPF0000EE38.namprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DS5PPF482CFEB7D Content-Type: text/plain; charset="utf-8" Resctrl provides a user-configurable option mbm_assign_on_mkdir that determines if a counter will automatically be assigned to an RMID, event pair when its associated monitor group is created via mkdir. Enable mbm_assign_on_mkdir by default to automatically assign counters to the two default events (MBM total and MBM local) of a new monitoring group created via mkdir. This maintains backward compatibility with original resctrl support for these two events. Unassign and free counters belonging to a monitoring group when the group is deleted. Monitor group creation does not fail if a counter cannot be assigned to one or both events. There may be limited counters and users have the flexibility to modify counter assignments at a later time. Log the error message "Failed to allocate counter for in domain " in /sys/fs/resctrl/info/last_cmd_status when a new monitoring group is created but counter assignment failed. Signed-off-by: Babu Moger --- v16: Updated the changelog. Thanks to Reinette. Moved r->mon.mbm_assign_on_mkdir initialization to resctrl_mon_resourc= e_init(). Minor code comment update. Updated the Subject line to fs/resctrl: v15: Updated the subject line. Updated changelog to add unassign part. Fixed the check in rdtgroup_assign_cntrs() to call assign correctly. Renamed resctrl_assign_cntr_event() -> rdtgroup_assign_cntr_event() resctrl_unassign_cntr_event() -> rdtgroup_unassign_cntr_event(= ). v14: Updated the changelog with changed name mbm_event. Update code comments with changed name mbm_event. Changed the code to reflect Tony's struct mon_evt changes. v13: Changes due to calling of resctrl_assign_cntr_event() and resctrl_unas= sign_cntr_event(). It only takes evtid. evt_cfg is not required anymore. Resolved conflicts caused by the recent FS/ARCH code restructure. The monitor.c/rdtgroup.c files have been split between the FS and ARCH= directories. v12: Removed mbm_cntr_reset() as it is not required while removing the grou= p. Update the commit text. Added r->mon_capable check in rdtgroup_assign_cntrs() and rdtgroup_un= assign_cntrs. v11: Moved mbm_cntr_reset() to monitor.c. Added code reset non-architectural state in mbm_cntr_reset(). Added missing rdtgroup_unassign_cntrs() calls on failure path. v10: Assigned the counter before exposing the event files. Moved the call rdtgroup_assign_cntrs() inside mkdir_rdt_prepare_rmid_al= loc(). This is called both CNTR_MON and MON group creation. Call mbm_cntr_reset() when unmounted to clear all the assignments. Taken care of few other feedback comments. v9: Changed rdtgroup_assign_cntrs() and rdtgroup_unassign_cntrs() to return= void. Updated couple of rdtgroup_unassign_cntrs() calls properly. Updated function comments. v8: Renamed rdtgroup_assign_grp to rdtgroup_assign_cntrs. Renamed rdtgroup_unassign_grp to rdtgroup_unassign_cntrs. Fixed the problem with unassigning the child MON groups of CTRL_MON gro= up. v7: Reworded the commit message. Removed the reference of ABMC with mbm_cntr_assign. Renamed the function rdtgroup_assign_cntrs to rdtgroup_assign_grp. v6: Removed the redundant comments on all the calls of rdtgroup_assign_cntrs. Updated the commit message. Dropped printing error message on every call of rdtgroup_assign_cntrs. v5: Removed the code to enable/disable ABMC during the mount. That will be another patch. Added arch callers to get the arch specific data. Renamed fuctions to match the other abmc function. Added code comments for assignment failures. v4: Few name changes based on the upstream discussion. Commit message update. v3: This is a new patch. Patch addresses the upstream comment to enable ABMC feature by default if the feature is available. --- fs/resctrl/monitor.c | 1 + fs/resctrl/rdtgroup.c | 70 +++++++++++++++++++++++++++++++++++++++++-- 2 files changed, 69 insertions(+), 2 deletions(-) diff --git a/fs/resctrl/monitor.c b/fs/resctrl/monitor.c index 6205bbfe08fb..5cf1b79c17f5 100644 --- a/fs/resctrl/monitor.c +++ b/fs/resctrl/monitor.c @@ -1072,6 +1072,7 @@ int resctrl_mon_resource_init(void) mon_event_all[QOS_L3_MBM_LOCAL_EVENT_ID].evt_cfg =3D READS_TO_LOCAL_MEM | READS_TO_LOCAL_S_MEM | NON_TEMP_WRITE_TO_LOCAL_MEM; + r->mon.mbm_assign_on_mkdir =3D true; resctrl_file_fflags_init("num_mbm_cntrs", RFTYPE_MON_INFO | RFTYPE_RES_CACHE); resctrl_file_fflags_init("available_mbm_cntrs", diff --git a/fs/resctrl/rdtgroup.c b/fs/resctrl/rdtgroup.c index bf04235d2603..d087ba990cd3 100644 --- a/fs/resctrl/rdtgroup.c +++ b/fs/resctrl/rdtgroup.c @@ -2792,6 +2792,54 @@ static void schemata_list_destroy(void) } } =20 +/* + * rdtgroup_assign_cntrs() - Assign counters to MBM events. Called when + * a new group is created. + * If "mbm_event" counter assignment mode is enabled, counters should be + * automatically assigned if the "mbm_assign_on_mkdir" is set. + * Each group can accommodate two counters per domain: one for the total + * event and one for the local event. Assignments may fail due to the limi= ted + * number of counters. However, it is not necessary to fail the group crea= tion + * and thus no failure is returned. Users have the option to modify the + * counter assignments after the group has been created. + */ +static void rdtgroup_assign_cntrs(struct rdtgroup *rdtgrp) +{ + struct rdt_resource *r =3D resctrl_arch_get_resource(RDT_RESOURCE_L3); + + if (!r->mon_capable || !resctrl_arch_mbm_cntr_assign_enabled(r) || + !r->mon.mbm_assign_on_mkdir) + return; + + if (resctrl_is_mon_event_enabled(QOS_L3_MBM_TOTAL_EVENT_ID)) + rdtgroup_assign_cntr_event(NULL, rdtgrp, + &mon_event_all[QOS_L3_MBM_TOTAL_EVENT_ID]); + + if (resctrl_is_mon_event_enabled(QOS_L3_MBM_LOCAL_EVENT_ID)) + rdtgroup_assign_cntr_event(NULL, rdtgrp, + &mon_event_all[QOS_L3_MBM_LOCAL_EVENT_ID]); +} + +/* + * rdtgroup_unassign_cntrs() - Unassign the counters associated with MBM e= vents. + * Called when a group is deleted. + */ +static void rdtgroup_unassign_cntrs(struct rdtgroup *rdtgrp) +{ + struct rdt_resource *r =3D resctrl_arch_get_resource(RDT_RESOURCE_L3); + + if (!r->mon_capable || !resctrl_arch_mbm_cntr_assign_enabled(r)) + return; + + if (resctrl_is_mon_event_enabled(QOS_L3_MBM_TOTAL_EVENT_ID)) + rdtgroup_unassign_cntr_event(NULL, rdtgrp, + &mon_event_all[QOS_L3_MBM_TOTAL_EVENT_ID]); + + if (resctrl_is_mon_event_enabled(QOS_L3_MBM_LOCAL_EVENT_ID)) + rdtgroup_unassign_cntr_event(NULL, rdtgrp, + &mon_event_all[QOS_L3_MBM_LOCAL_EVENT_ID]); +} + static int rdt_get_tree(struct fs_context *fc) { struct rdt_fs_context *ctx =3D rdt_fc2context(fc); @@ -2848,6 +2896,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) @@ -2886,8 +2936,10 @@ static int rdt_get_tree(struct fs_context *fc) if (resctrl_arch_mon_capable()) kernfs_remove(kn_mondata); out_mongrp: - if (resctrl_arch_mon_capable()) + if (resctrl_arch_mon_capable()) { + rdtgroup_unassign_cntrs(&rdtgroup_default); kernfs_remove(kn_mongrp); + } out_info: kernfs_remove(kn_info); out_closid_exit: @@ -3033,6 +3085,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 @@ -3073,6 +3126,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); @@ -3157,6 +3212,7 @@ static void resctrl_fs_teardown(void) return; =20 rmdir_all_sub(); + rdtgroup_unassign_cntrs(&rdtgroup_default); mon_put_kn_priv(); rdt_pseudo_lock_release(); rdtgroup_default.mode =3D RDT_MODE_SHAREABLE; @@ -3637,9 +3693,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; } @@ -3649,8 +3708,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 /* @@ -3926,6 +3987,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 /* @@ -3973,6 +4037,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 Mon Oct 6 01:21:11 2025 Received: from NAM12-BN8-obe.outbound.protection.outlook.com (mail-bn8nam12on2048.outbound.protection.outlook.com [40.107.237.48]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 513A4248F70; Fri, 25 Jul 2025 18:35:23 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.237.48 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1753468524; cv=fail; b=X99H3kRYv/Uk8yqyMtvZ0dDrVhCsI11W5rsvdBlooIQHuCVkU6Y+aS2gbgMdUoRYlOOhXvzn7l5TEiRbJwzG+qE1iUZNvsrTChWwZ/DUPNO7L2dzKRkUO1+qYMyNZAfkkTUg5Qxy0VROUyy0moKI5l87RY//o6hfpsqCVXMWqM0= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1753468524; c=relaxed/simple; bh=4Pc6eqc/kAOQlp4gg11Fwspb0KcGNBlzFgtKuFW2H8Q=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=LoSrODmlWZGiCv4gE/p7zrPVF5IacxOjohWj7W7p3RveBk7K7vHVV19FRpPP5O65k3lRGnEni+ziYXka0d1+amXOPPe/eHcRnBv8nl0YdB2M/aTLNzwJ5JYdPbzAXhXcDm7DyYIrk4yLOmeDtrUAtTA623z1J5/Q5DUhDT9qZ7E= 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=Go3mDAM6; arc=fail smtp.client-ip=40.107.237.48 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=amd.com Authentication-Results: smtp.subspace.kernel.org; spf=fail smtp.mailfrom=amd.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=amd.com header.i=@amd.com header.b="Go3mDAM6" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=nSX5un2ngP+63LIo8ju2aQJcTHjVPieEMUDa2iKYyLS7rq8gYxezn0OtffdjwcitvIWx4GYgktLvGMkz/pppnqN4MUNPZoUIZxycnGVVgbZaz+6X33Ti+1bDeTbQCgyYFoXMKdY+Jj1cG/Uvv5DHKC8H13u5/QJi8+F1rtZ/xQjYJwVQbBcrlMJCnAABqF5Wpw2fR+uhk1wowwB5Exb1EW8dmwtxfpBSz3uObzI8Tbga1VVhGkBJBesRTWL69ZlXU+gYjEZhV398FgYGaLIwSCRepUlpOmcrJTPNE+1UZ4WWU9b2q4RHu4JGYadMt7YIgM47yd0vBQI6GSbX/BZp3Q== 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=z9gtk/ndO42c0i2799BKWsy/EMqg6x3BBWGUruB3VD4=; b=I6WmmJRkM4l5PvErXhADwp52Q5UK/p2Mt9S30oeFKjRDlDLdzZ4supSWsL5vYAB/f9oHIosvNoVUD0XXrLnCZfeZhdfrC99wJfBVLn6IElwwgrP6Z4YGuyr3fPn2rnCrLb72wAE5ojC8UwwTY9GLTiRDE3a4Ytdv/SQdbFLNs0ur2YQcsQ06Wrcz4WVRwcgxoeDKxy9h9bFXj0fG8Cmryvn/aGCC8C/APATuv65SeTYLaShfiw0KJRJFi3pZyP4NuTGTt2C1OEhgzkQ/lc8pAz2/hnKosebScJZE68geElISwGMx7QD4AxksZ+YyEJ/1sSExYvK2y6oZaOfuy0/dyA== 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=z9gtk/ndO42c0i2799BKWsy/EMqg6x3BBWGUruB3VD4=; b=Go3mDAM6z6mhf9HVPGcm3TIq1pkLfDIbPvON0kISwtpkLtbOPQYyOFq5+ETlf4C9chOZ/FNKprYQhp4f4kG/iDFp7aDyJnazrp/jnRdfdv4jNMbNgTGO+dOgfFGEtu6ovQCrhFcQCuhYUVD31GI9GSq2cyHHC+yn5dNDBJu/BPo= Received: from CH2PR14CA0026.namprd14.prod.outlook.com (2603:10b6:610:60::36) by LV3PR12MB9213.namprd12.prod.outlook.com (2603:10b6:408:1a6::20) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8943.27; Fri, 25 Jul 2025 18:35:15 +0000 Received: from CH1PEPF0000AD83.namprd04.prod.outlook.com (2603:10b6:610:60:cafe::56) by CH2PR14CA0026.outlook.office365.com (2603:10b6:610:60::36) with Microsoft SMTP Server (version=TLS1_3, cipher=TLS_AES_256_GCM_SHA384) id 15.20.8964.24 via Frontend Transport; Fri, 25 Jul 2025 18:35: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 CH1PEPF0000AD83.mail.protection.outlook.com (10.167.244.85) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.8964.20 via Frontend Transport; Fri, 25 Jul 2025 18:35:14 +0000 Received: from bmoger-ubuntu.amd.com (10.180.168.240) by SATLEXMB04.amd.com (10.181.40.145) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.39; Fri, 25 Jul 2025 13:35:12 -0500 From: Babu Moger To: , , , , , , , CC: , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , Subject: [PATCH v16 29/34] fs/resctrl: Introduce mbm_L3_assignments to list assignments in a group Date: Fri, 25 Jul 2025 13:29:48 -0500 Message-ID: <1a031e141affd6dfb8693de5a0bda83f3cf4a330.1753467772.git.babu.moger@amd.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: References: Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-ClientProxiedBy: SATLEXMB03.amd.com (10.181.40.144) To SATLEXMB04.amd.com (10.181.40.145) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CH1PEPF0000AD83:EE_|LV3PR12MB9213:EE_ X-MS-Office365-Filtering-Correlation-Id: 4b45f4e4-306e-4563-9023-08ddcba9ff4c X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|82310400026|1800799024|7416014|36860700013|376014; X-Microsoft-Antispam-Message-Info: =?us-ascii?Q?hndIPmdrOZNV2vv2XRm3EuMz0W+9Sg1YeygBPtxP/51CW/PXFH7MGQLZoT4i?= =?us-ascii?Q?YKn/fgtIFsXkk6AhC7RakFe76/hox7j6i2ZiAZ+yJcXfYRN7BWBhqjcHfnHo?= =?us-ascii?Q?Jkm8zET2QokPxvjNA6PiXvHQ1nHywPMSyp3lrvnpaZON3xFaxAKQ/oT3w8tr?= =?us-ascii?Q?Gmat62vf2jFdARiushDAK+W4O5Hi90mg+4GV+yHs5LQKyAipMCgDMpE2igTv?= =?us-ascii?Q?GSXMn4pZygWk3TugRJyfls61z7J/JpHTBYA3KFjHqeAmDu1Y9U+Tw9Sj90uw?= =?us-ascii?Q?MDOU/UwHVlhaYmhCaeqkEq41wjb0/GzA0ybA14463GPfhOFJDJI0T7fPOZKC?= =?us-ascii?Q?XOzYs8A5uHxTcIdwXpbFWueGbtGxdPoe5jP74N84bg1WmoG0sSwXvLILwYgE?= =?us-ascii?Q?p9IfdwKaG8PnI6+QDGu9PNfFscqOzQo0ducZWxeKfBbDz9EZcxyqSDsDYzzX?= =?us-ascii?Q?xBwMaDJKkH9uWtp7I/xwrwgOD9mCyHfDDrQQUTNjKp+FZs0IvyVqQmQBNJoF?= =?us-ascii?Q?laERH6/nm//ny8ip5rwYaHqVxa2Lhud5hJBIbzuKNiwgIq2bFbpWbXVp2cYS?= =?us-ascii?Q?bxZuJn8LQvhH5lWgE+HNHcERdPOEYlfKQIJ1gw9W3aMXrH1R+aQqj51d+4eW?= =?us-ascii?Q?ocPrkGJvR905OQTYpLRRedwKr8tsyzxE/mrxYxyJefZ0cLMxG8CgUqd79Iss?= =?us-ascii?Q?r7TOD6ZOIFQNGtaVSHDR9g0B+RnLKH3JLCEq/q1/PPo2EmcJAiIPwNt7Wn8H?= =?us-ascii?Q?EiDaFHlenUfEG3B2hbXrG3Bsf5pbQoC8ZKaQazzXn/M3tVQlwJCROYh4Et7L?= =?us-ascii?Q?ZpiqHHlnOkxv4sNDh3ixDLl3kejV6ej7nJYbMNaReKWRlwtNMzaBZ019SzOe?= =?us-ascii?Q?eiLapWsLImKzg13L++B6+2UCj/kvqQcLewTLOaY5BQ9+5VhglGKE454K8d7b?= =?us-ascii?Q?89GME82JTLYbeNFiQrBNchvEXQZGUzDhttuYHl/miyr1nygoklcsdwWGUWww?= =?us-ascii?Q?u7hut2esAlWFNZ/vVprdLYAtrqSkOujvWLgVGqlngap7qpBl05mqhc9G93YP?= =?us-ascii?Q?izjw1+rwYS/eyAi1w6pCyE4bvykkwYUqR+CGPqu4TvdvwqOoICPSwNEbQXQs?= =?us-ascii?Q?BR/2R2RSfSEUl6iCUI4EcwQ46KBsYu70e5AA8kpDU8aWndlYzxgqk/JMZdX8?= =?us-ascii?Q?gNfMM99DlP3hkja4JlmbcRjga3ApyHZH6Z0JQi+Uv7BdbYf1fWSUEbeF/2ze?= =?us-ascii?Q?1CGz9vGWP5N8we4b2xF7KndSStwYAcK6w5jMomEMU4vdHjnCxYSiPNqO7GuH?= =?us-ascii?Q?q8kVaefrS9y4wgyXUFbHkY+J2Mg/zg6spwmP45z4Daro2Wr0ihiiHSee5AV9?= =?us-ascii?Q?Pq/pV/jK0vkBfPy745kjcOi9h9PhO5JzYfnq5BUjsQhG1Uqq+6VNAYsuWeV2?= =?us-ascii?Q?/C2UeqTrJrXefRFwXWk6WS0w5+hw35BTRRMuod0HEwEKWmT1KI7tfQ=3D=3D?= X-Forefront-Antispam-Report: CIP:165.204.84.17;CTRY:US;LANG:en;SCL:1;SRV:;IPV:CAL;SFV:NSPM;H:SATLEXMB04.amd.com;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(13230040)(82310400026)(1800799024)(7416014)(36860700013)(376014);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 25 Jul 2025 18:35:14.9062 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 4b45f4e4-306e-4563-9023-08ddcba9ff4c 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: CH1PEPF0000AD83.namprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: LV3PR12MB9213 Content-Type: text/plain; charset="utf-8" Introduce the mbm_L3_assignments resctrl file associated with CTRL_MON and MON resource groups to display the counter assignment states of the resource group when "mbm_event" counter assignment mode is enabled. The list is displayed in the following format: :=3D;=3D Event: A valid MBM event listed in /sys/fs/resctrl/info/L3_MON/event_configs directory. Domain ID: A valid domain ID. The assignment state can be one of the following: _ : No counter assigned. e : Counter assigned exclusively. Example: To list the assignment states for the default group $ cd /sys/fs/resctrl $ cat /sys/fs/resctrl/mbm_L3_assignments mbm_total_bytes:0=3De;1=3De mbm_local_bytes:0=3De;1=3De Signed-off-by: Babu Moger --- v16: Fixed minor merge conflicts with code displacement. Changed the check with mbm_cntr_get() to "< 0" from " >=3D". v15: Updated the changelog with Reinette's text. Updated the event format list to list multiple domains. Changed the goto out_assing to out_unlock. Updated to use new loop for_each_mon_event() instead of hardcoding. v14: Added missed rdtgroup_kn_lock_live on failure case. Updated the user doc resctrl.rst to clarify counter assignments. Updated the changelog. v13: Changelog update. Few changes in mbm_L3_assignments_show() after moving the event config= to evt_list. Resolved conflicts caused by the recent FS/ARCH code restructure. The rdtgroup.c/monitor.c files have been split between the FS and ARCH= directories. v12: New patch: Assignment interface moved inside the group based the discussion https://lore.kernel.org/lkml/CALPaoCiii0vXOF06mfV=3DkVLBzhfNo0SFqt4kQG= wGSGVUqvr2Dg@mail.gmail.com/#t --- Documentation/filesystems/resctrl.rst | 28 ++++++++++++++ fs/resctrl/monitor.c | 1 + fs/resctrl/rdtgroup.c | 54 +++++++++++++++++++++++++++ 3 files changed, 83 insertions(+) diff --git a/Documentation/filesystems/resctrl.rst b/Documentation/filesyst= ems/resctrl.rst index 165e0d315af7..0b8ce942f112 100644 --- a/Documentation/filesystems/resctrl.rst +++ b/Documentation/filesystems/resctrl.rst @@ -514,6 +514,34 @@ When the "mba_MBps" mount option is used all CTRL_MON = groups will also contain: /sys/fs/resctrl/info/L3_MON/mon_features changes the input event. =20 +"mbm_L3_assignments": + Exists when "mbm_event" counter assignment mode is supported and lists the + counter assignment states of the group. + + The assignment list is displayed in the following format: + + :=3D;=3D + + Event: A valid MBM event in the + /sys/fs/resctrl/info/L3_MON/event_configs directory. + + Domain ID: A valid domain ID. + + Assignment states: + + _ : No counter assigned. + + e : Counter assigned exclusively. + + Example: + To display the counter assignment states for the default group. + :: + + # cd /sys/fs/resctrl + # cat /sys/fs/resctrl/mbm_L3_assignments + mbm_total_bytes:0=3De;1=3De + mbm_local_bytes:0=3De;1=3De + Resource allocation rules ------------------------- =20 diff --git a/fs/resctrl/monitor.c b/fs/resctrl/monitor.c index 5cf1b79c17f5..ebc049105949 100644 --- a/fs/resctrl/monitor.c +++ b/fs/resctrl/monitor.c @@ -1080,6 +1080,7 @@ int resctrl_mon_resource_init(void) resctrl_file_fflags_init("event_filter", RFTYPE_ASSIGN_CONFIG); resctrl_file_fflags_init("mbm_assign_on_mkdir", RFTYPE_MON_INFO | RFTYPE_RES_CACHE); + resctrl_file_fflags_init("mbm_L3_assignments", RFTYPE_MON_BASE); } =20 return 0; diff --git a/fs/resctrl/rdtgroup.c b/fs/resctrl/rdtgroup.c index d087ba990cd3..47716e623a9c 100644 --- a/fs/resctrl/rdtgroup.c +++ b/fs/resctrl/rdtgroup.c @@ -1931,6 +1931,54 @@ static ssize_t resctrl_mbm_assign_on_mkdir_write(str= uct kernfs_open_file *of, return nbytes; } =20 +static int mbm_L3_assignments_show(struct kernfs_open_file *of, struct seq= _file *s, void *v) +{ + struct rdt_resource *r =3D resctrl_arch_get_resource(RDT_RESOURCE_L3); + struct rdt_mon_domain *d; + struct rdtgroup *rdtgrp; + struct mon_evt *mevt; + int ret =3D 0; + bool sep; + + rdtgrp =3D rdtgroup_kn_lock_live(of->kn); + if (!rdtgrp) { + ret =3D -ENOENT; + goto out_unlock; + } + + rdt_last_cmd_clear(); + if (!resctrl_arch_mbm_cntr_assign_enabled(r)) { + rdt_last_cmd_puts("mbm_event mode is not enabled\n"); + ret =3D -ENOENT; + goto out_unlock; + } + + for_each_mon_event(mevt) { + if (mevt->rid !=3D r->rid || !mevt->enabled || !resctrl_is_mbm_event(mev= t->evtid)) + continue; + + sep =3D false; + seq_printf(s, "%s:", mevt->name); + list_for_each_entry(d, &r->mon_domains, hdr.list) { + if (sep) + seq_putc(s, ';'); + + if (mbm_cntr_get(r, d, rdtgrp, mevt->evtid) < 0) + seq_printf(s, "%d=3D_", d->hdr.id); + else + seq_printf(s, "%d=3De", d->hdr.id); + + sep =3D true; + } + seq_putc(s, '\n'); + } + +out_unlock: + rdtgroup_kn_unlock(of->kn); + + return ret; +} + /* rdtgroup information files for one cache resource. */ static struct rftype res_common_files[] =3D { { @@ -2069,6 +2117,12 @@ static struct rftype res_common_files[] =3D { .seq_show =3D event_filter_show, .write =3D event_filter_write, }, + { + .name =3D "mbm_L3_assignments", + .mode =3D 0444, + .kf_ops =3D &rdtgroup_kf_single_ops, + .seq_show =3D mbm_L3_assignments_show, + }, { .name =3D "mbm_assign_mode", .mode =3D 0444, --=20 2.34.1 From nobody Mon Oct 6 01:21:11 2025 Received: from NAM11-CO1-obe.outbound.protection.outlook.com (mail-co1nam11on2067.outbound.protection.outlook.com [40.107.220.67]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id A9CE12500DF; Fri, 25 Jul 2025 18:35:32 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.220.67 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1753468535; cv=fail; b=HiNyQmmGfd7/wUE/dZd33HpvsXntoevV2TlpiFRP5V161wKYdgA52/X0CstOAeeITtSwML9AP8vxSBB8O5WqjflRvrn2oBq4/7qKFcWc+Rxw8Taw5GRtOPVJ7L403jY1gNU7aRGyxU0AfwSRFzMkFGfUcjgbP4dg37OGP9sO1Lw= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1753468535; c=relaxed/simple; bh=Wmu1Huv59vXPfDKENfEfYF1/DikvR00c0Wv4RoHgfrM=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=QapXtwofFTksMgJN98F48IaYOxl7icEc4hh5+d3BPTw2AfJ+4sqfQSFUJR//z4vo63PAFw71XNI9+WHq40vGxkMHSWdDO5WaLPp5f9exXvmZpbA4LN9JTaTblGdh8qOQZdLyvKGAEWY+3tE3v5BfiUHJ3VB3DlDyGT67GuFk5wM= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=amd.com; spf=fail smtp.mailfrom=amd.com; dkim=pass (1024-bit key) header.d=amd.com header.i=@amd.com header.b=k/Fmew4p; arc=fail smtp.client-ip=40.107.220.67 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=amd.com Authentication-Results: smtp.subspace.kernel.org; spf=fail smtp.mailfrom=amd.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=amd.com header.i=@amd.com header.b="k/Fmew4p" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=B4n+rU4FjKuzwvnngrUU04fkHbsUUmhMl209WNtoMkt96pj2vOsaM7Tzzek1B7d3X5F19RSkR4bC2apI3z6M2KRhJsOm1p30Y/F24ixHaL+1PC3obevyhlhtZyH+K+lDCHLTp3LXwDjdC4gXcnx8xhaqbp/ge1YcQNYah8tnM8qPgCQydl+Gx7ck6UmMqf3FLTrxKi+ZZ0/+Q9CkdYBgxXQlhHGHISmGyHDPxroJWbphwiqafv2xHvj93WYf93jT9A/xae8dY2cmibwSfckBS7e7d53nde67HMG+2xhqIX5ejuu+29g5peZ/cVHzVWZsWYz5Y8Rq3WVRmDSca09CcQ== 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=zLfvK51lnum1BbeQsvfoxwwOII9Qa/zeoyiD8/delmM=; b=sdnU7lTGpJDXgWCA8A+Js1z9HhkiB8BQ6/GGHj2HnrY5OwHYE16lxvqtL8nMV3h6MfRl6dD1rSf8sWIsuDuKrz5bYkG3XifoGL3qb0mgxGjtAfXi3lzRAKhhRhGQajtaOL0aBNkWsTIWJwH1Y4sUZ7IaQk4I5zEYpZsG9t+Guwm4fWxAKLf5u7jSSsP4IANJEpPnqLoPD3p2wPbOxwqgjbXkvL4p0MoSrQU5opIEcQIsL7RG8r43RPbNP+tUWOvdSUlNOMVwD5h6VeZUY/2QLDKVK4qSyMnr678EUiQ9rjJtLFgkofKu9QCoDCBeLntkKUHJSQIMM3tOaMNETfCs4g== 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=zLfvK51lnum1BbeQsvfoxwwOII9Qa/zeoyiD8/delmM=; b=k/Fmew4pP1P7nE2rZ7+IqtXpNnCXyJjUmKh5N5hUXnlZd/e2NtVt84At1bfj7N436tD7zAm8M7cSZ0usbOR6SBIZdO44NdWWa//ffLgv+eIkoJu13YgpbpGiqRgbFL1Bn+qEa3zIicmTpOO0afTOJ2cVRPXvgwZeXoyBFnPm8UI= Received: from SJ0PR05CA0142.namprd05.prod.outlook.com (2603:10b6:a03:33d::27) by CH3PR12MB7593.namprd12.prod.outlook.com (2603:10b6:610:141::20) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8964.23; Fri, 25 Jul 2025 18:35:26 +0000 Received: from CY4PEPF0000EE39.namprd03.prod.outlook.com (2603:10b6:a03:33d:cafe::37) by SJ0PR05CA0142.outlook.office365.com (2603:10b6:a03:33d::27) with Microsoft SMTP Server (version=TLS1_3, cipher=TLS_AES_256_GCM_SHA384) id 15.20.8989.7 via Frontend Transport; Fri, 25 Jul 2025 18:35: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 CY4PEPF0000EE39.mail.protection.outlook.com (10.167.242.11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.8964.20 via Frontend Transport; Fri, 25 Jul 2025 18:35: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; Fri, 25 Jul 2025 13:35:21 -0500 From: Babu Moger To: , , , , , , , CC: , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , Subject: [PATCH v16 30/34] fs/resctrl: Introduce the interface to modify assignments in a group Date: Fri, 25 Jul 2025 13:29:49 -0500 Message-ID: <5c589b07428d3bce95616b0f69fc58883eb86360.1753467772.git.babu.moger@amd.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: References: Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-ClientProxiedBy: SATLEXMB03.amd.com (10.181.40.144) To SATLEXMB04.amd.com (10.181.40.145) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CY4PEPF0000EE39:EE_|CH3PR12MB7593:EE_ X-MS-Office365-Filtering-Correlation-Id: c2f596bf-3a36-49d6-6b4b-08ddcbaa0503 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|1800799024|82310400026|36860700013|7416014|376014; X-Microsoft-Antispam-Message-Info: =?utf-8?B?S20vaEVnNXJVRkkzS0YxZ0h3blNsTXNhKytNT2ZzT3pYcWg2SXI1Z1hMUThZ?= =?utf-8?B?SVZZZFY0RGh0ODcvV2RvSmg5MWZYOU84bmQzaGw3a3hPS2hobUEwTVUwenpQ?= =?utf-8?B?bHhYUmowM25LWkk1dkhJSTdlYXNiQ3JuY1RnSGlQdHpKQnFhRjFWZGZrN3FD?= =?utf-8?B?RXlBdDFXNEJveVNQMmNadForSFU0OWxiUkszQXRnUmZ6eTl4b1JrUFp6M1BT?= =?utf-8?B?OE5lSjdXUEV5WGNwVWJCUko5SWVIRStSTGxKNWdxeVBKYm81VXBMNkl2Q2hY?= =?utf-8?B?RFpydk9tQzR3blZ3Rk9aVythV0N1Y3FaSVEyelZPa000R1BaRHVnOXl5V2VV?= =?utf-8?B?ZnZWWEZBdHFYejJLOGRCY1JYTnN0dWJ5aGtLcFJ6czhPeE92SUkvWmRYMk1u?= =?utf-8?B?MEY4Q3lsM0JPdENTWGJRZ2JVTmV1MmNYaU1mNHRsUlJDV0dmMjZmQlZqdFJC?= =?utf-8?B?UVM0ZzdnTFlUUlVYd0hrK1QvY3UxZll1dTJNY3g4V0t1cEoza3JMRHFiK2g5?= =?utf-8?B?MGc0UUFKMzhtNUpnNzdFaXFBZVNnS1N0YkhYdVBuM1I5WHRxaDJvL0hxTDUw?= =?utf-8?B?VmRXQnpuYWRkMTZXRUx5cGo1dzVGUWdxU01yajlxdlFvNWIyb01VTXdoMC96?= =?utf-8?B?OHk1ajdlaXhwSGpMYVdDR3c3NFdVK3RyV0syeHZhcld0Nmd1ajRmRllaZi8y?= =?utf-8?B?MERRaDhaVGtVbldnNDFERXk2anBtYiswL05xUnk4bHZzNVAyRnJ5SVdsb3Z0?= =?utf-8?B?bThqWEhPOVhYbTRsN014OWlUajVabGhlNytUUUV2TUg0ZnkwYjdaTEh0QktS?= =?utf-8?B?MWczZmpEU0JpZDY0VldGaTU4dmhvN0F3L3R6OXNtSEtwb1B4ZFJlN2tzdjUz?= =?utf-8?B?SXMxNlNsZ2dPcGNkSmxobDQ2MHAxOEFUaS9uM09scklPa0YwSHFLa1RlZk4w?= =?utf-8?B?OUEwNGhScTNWMGhpdkJWV29sVWZGRXBxelZjS1BZTHVLVkthbjBQVlVkUENl?= =?utf-8?B?MUY0bVhTTGJVWFplVUIwQU9FNHhPVnB1T1liYWdOY1hMM3JYbUhpRzNrNXd5?= =?utf-8?B?U0Yxb2NNTVIyc1BPUHcyOHRiOElPTGxJc21xdWVyY1ZjYWhEa1hkVUJMMm1n?= =?utf-8?B?R01aa3lRZGFjcmY4OGFSYkdHZE5BUGNwdkJJY1hUUWxJazViK0VKU0czUzdD?= =?utf-8?B?Z0hpTklDUWtPS1FXUXN2UHM2Q3pvQitOeTllTVdoL2huNk9wcmFpVVUyV2FG?= =?utf-8?B?a1BoZkM0QjRaMlg1Z2FVWmpoNDlEK1kvY1B3RGd2K05tVXZ1NUNVMEFLb1Ju?= =?utf-8?B?NmV5RUxwOUs0SkNlUDU0ZTdxSzE3MWlNZGZ5M2hHZ2VsRTIzOWFWQXdTcWVy?= =?utf-8?B?c29VN3FpaDQyQ3J2N3VLdnNqOEk0NExwU1J4b3laeURkRTdzTDZUWDNzMGRP?= =?utf-8?B?VVVEbUE0TDZqMDJySmVQVWRzSXVIMzMzWGp6ZXBpMFNuanBHTitPYmZ3dkh3?= =?utf-8?B?MVZid1R3SzUvaGFrb29neitHWDdXcUViczZpMnVFZ28yWjFjRHB0UTR1VnM3?= =?utf-8?B?eVlyNzZLTDRhT0F0MWNWd01QdVJXRW1NRFQ3UW5tdm9JcGpucmZqMW1DL25U?= =?utf-8?B?NHpWVktlNHFGalUwNGJvMGxNZEJOOFZZZTB6UmJyb2RXb0RwOFVGVnhTcmZW?= =?utf-8?B?ZEF2V1NneDM3ZzNXN3hRcCtMVEp2OEg1ZWhMajVCVTFhelJEb0huL1FPRDBV?= =?utf-8?B?L0hqbjExZGtUWWNkOFFvelpsbm54MHUvZEdoMElndWRpS3BuNzA2NFFQOGpL?= =?utf-8?B?Y1JxQlBVSGhGdW45ZkkrK3JXVFJFMWJITU5GOGpjam5SZmNNbmhRVmpic29Z?= =?utf-8?B?WVpITzA5VWE0VkxHRysreXQ1ZXpxbDA5TXpybmJ3NC9wSXVIWnAraXVQWC9y?= =?utf-8?B?ME1reTdibTl4dVAwcG5DOHF4dHNOVFRXZVVPSHc5VWUxUE1MZG5zUFZpdzZu?= =?utf-8?B?dlUzd1lyWWN3PT0=?= X-Forefront-Antispam-Report: CIP:165.204.84.17;CTRY:US;LANG:en;SCL:1;SRV:;IPV:CAL;SFV:NSPM;H:SATLEXMB04.amd.com;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(13230040)(1800799024)(82310400026)(36860700013)(7416014)(376014);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 25 Jul 2025 18:35:24.4588 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: c2f596bf-3a36-49d6-6b4b-08ddcbaa0503 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: CY4PEPF0000EE39.namprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: CH3PR12MB7593 Enable the mbm_l3_assignments resctrl file to be used to modify counter assignments of CTRL_MON and MON groups when the "mbm_event" counter assignment mode is enabled. The assignment modifications are done in the following format: :=3D Event: A valid MBM event in the /sys/fs/resctrl/info/L3_MON/event_configs directory. Domain ID: A valid domain ID. When writing, '*' applies the changes to all domains. Assignment states: _ : Unassign a counter. e : Assign a counter exclusively. Examples: $ cd /sys/fs/resctrl $ cat /sys/fs/resctrl/mbm_L3_assignments mbm_total_bytes:0=3De;1=3De mbm_local_bytes:0=3De;1=3De To unassign the counter associated with the mbm_total_bytes event on domain 0: $ echo "mbm_total_bytes:0=3D_" > mbm_L3_assignments $ cat /sys/fs/resctrl/mbm_L3_assignments mbm_total_bytes:0=3D_;1=3De mbm_local_bytes:0=3De;1=3De To unassign the counter associated with the mbm_total_bytes event on all the domains: $ echo "mbm_total_bytes:*=3D_" > mbm_L3_assignments $ cat /sys/fs/resctrl/mbm_L3_assignments mbm_total_bytes:0=3D_;1=3D_ mbm_local_bytes:0=3De;1=3De Signed-off-by: Babu Moger --- v16: Updated the changelog for minor corrections. Updated resctrl.rst few corrections and consistancy. Fixed few references of counter_configs to > event_configs. Renamed resctrl_process_assign() to resctrl_parse_mbm_assignment(). Moved resctrl_parse_mbm_assignment() and rdtgroup_modify_assign_state(= ) to monitor.c. v15: Updated the changelog little bit. Fixed the spacing in event_filter display. Removed the enum ASSIGN_NONE etc. Not required anymore. Moved mbm_get_mon_event_by_name() to fs/resctrl/monitor.c Used the new macro for_each_mon_event(). Renamed resctrl_get_assign_state() -> rdtgroup_modify_assign_state(). Quite a few changes in resctrl_process_assign(). Removed the found and domain variables. Called rdtgroup_modify_assign_state() directly where applicable. Removed couple of goto statements. v14: Fixed the problem reported by Peter. Updated the changelog. Updated the user doc resctrl.rst. Added example section on how to use resctrl with mbm_assign_mode. v13: Few changes in mbm_L3_assignments_write() after moving the event confi= g to evt_list. Resolved conflicts caused by the recent FS/ARCH code restructure. v12: New patch: Assignment interface moved inside the group based the discussion https://lore.kernel.org/lkml/CALPaoCiii0vXOF06mfV=3DkVLBzhfNo0SFqt4kQG= wGSGVUqvr2Dg@mail.gmail.com/#t --- Documentation/filesystems/resctrl.rst | 146 +++++++++++++++++++++++++- fs/resctrl/internal.h | 3 + fs/resctrl/monitor.c | 94 +++++++++++++++++ fs/resctrl/rdtgroup.c | 48 ++++++++- 4 files changed, 289 insertions(+), 2 deletions(-) diff --git a/Documentation/filesystems/resctrl.rst b/Documentation/filesyst= ems/resctrl.rst index 0b8ce942f112..0c8701103214 100644 --- a/Documentation/filesystems/resctrl.rst +++ b/Documentation/filesystems/resctrl.rst @@ -525,7 +525,8 @@ When the "mba_MBps" mount option is used all CTRL_MON g= roups will also contain: Event: A valid MBM event in the /sys/fs/resctrl/info/L3_MON/event_configs directory. =20 - Domain ID: A valid domain ID. + Domain ID: A valid domain ID. When writing, '*' applies the changes + to all the domains. =20 Assignment states: =20 @@ -542,6 +543,34 @@ When the "mba_MBps" mount option is used all CTRL_MON = groups will also contain: mbm_total_bytes:0=3De;1=3De mbm_local_bytes:0=3De;1=3De =20 + Assignments can be modified by writing to the interface. + + Example: + To unassign the counter associated with the mbm_total_bytes event on doma= in 0: + :: + + # echo "mbm_total_bytes:0=3D_" > /sys/fs/resctrl/mbm_L3_assignments + # cat /sys/fs/resctrl/mbm_L3_assignments + mbm_total_bytes:0=3D_;1=3De + mbm_local_bytes:0=3De;1=3De + + To unassign the counter associated with the mbm_total_bytes event on all = the domains: + :: + + # echo "mbm_total_bytes:*=3D_" > /sys/fs/resctrl/mbm_L3_assignments + # cat /sys/fs/resctrl/mbm_L3_assignments + mbm_total_bytes:0=3D_;1=3D_ + mbm_local_bytes:0=3De;1=3De + + To assign a counter associated with the mbm_total_bytes event on all doma= ins in + exclusive mode: + :: + + # echo "mbm_total_bytes:*=3De" > /sys/fs/resctrl/mbm_L3_assignments + # cat /sys/fs/resctrl/mbm_L3_assignments + mbm_total_bytes:0=3De;1=3De + mbm_local_bytes:0=3De;1=3De + Resource allocation rules ------------------------- =20 @@ -1577,6 +1606,121 @@ View the llc occupancy snapshot:: # cat /sys/fs/resctrl/p1/mon_data/mon_L3_00/llc_occupancy 11234000 =20 + +Examples on working with mbm_assign_mode +=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D + +a. Check if MBM counter assignment mode is supported. +:: + + # mount -t resctrl resctrl /sys/fs/resctrl/ + + # cat /sys/fs/resctrl/info/L3_MON/mbm_assign_mode + [mbm_event] + default + +The "mbm_event" mode is detected and enabled. + +b. Check how many assignable counters are supported. +:: + + # cat /sys/fs/resctrl/info/L3_MON/num_mbm_cntrs + 0=3D32;1=3D32 + +c. Check how many assignable counters are available for assignment in each= domain. +:: + + # cat /sys/fs/resctrl/info/L3_MON/available_mbm_cntrs + 0=3D30;1=3D30 + +d. To list the default group's assign states. +:: + + # cat /sys/fs/resctrl/mbm_L3_assignments + mbm_total_bytes:0=3De;1=3De + mbm_local_bytes:0=3De;1=3De + +e. To unassign the counter associated with the mbm_total_bytes event on d= omain 0. +:: + + # echo "mbm_total_bytes:0=3D_" > /sys/fs/resctrl/mbm_L3_assignments + # cat /sys/fs/resctrl/mbm_L3_assignments + mbm_total_bytes:0=3D_;1=3De + mbm_local_bytes:0=3De;1=3De + +f. To unassign the counter associated with the mbm_total_bytes event on al= l domains. +:: + + # echo "mbm_total_bytes:*=3D_" > /sys/fs/resctrl/mbm_L3_assignments + # cat /sys/fs/resctrl/mbm_L3_assignment + mbm_total_bytes:0=3D_;1=3D_ + mbm_local_bytes:0=3De;1=3De + +g. To assign a counter associated with the mbm_total_bytes event on all do= mains in +exclusive mode. +:: + + # echo "mbm_total_bytes:*=3De" > /sys/fs/resctrl/mbm_L3_assignments + # cat /sys/fs/resctrl/mbm_L3_assignments + mbm_total_bytes:0=3De;1=3De + mbm_local_bytes:0=3De;1=3De + +h. Read the events mbm_total_bytes and mbm_local_bytes of the default grou= p. There is +no change in reading the events with the assignment. If the event is unas= signed when +reading, then the read will come back as "Unassigned". +:: + + # cat /sys/fs/resctrl/mon_data/mon_L3_00/mbm_total_bytes + 779247936 + # cat /sys/fs/resctrl/mon_data/mon_L3_00/mbm_local_bytes + 765207488 + +i. Check the event configurations. +:: + + # cat /sys/fs/resctrl/info/L3_MON/event_configs/mbm_total_bytes/event_fi= lter + local_reads,remote_reads,local_non_temporal_writes,remote_non_temporal_w= rites, + local_reads_slow_memory,remote_reads_slow_memory,dirty_victim_writes_all + + # cat /sys/fs/resctrl/info/L3_MON/event_configs/mbm_local_bytes/event_fi= lter + local_reads,local_non_temporal_writes,local_reads_slow_memory + +j. Change the event configuration for mbm_local_bytes. +:: + + # echo "local_reads, local_non_temporal_writes, local_reads_slow_memory,= remote_reads" > + /sys/fs/resctrl/info/L3_MON/event_configs/mbm_local_bytes/event_filter + + # cat /sys/fs/resctrl/info/L3_MON/event_configs/mbm_local_bytes/event_fi= lter + local_reads,local_non_temporal_writes,local_reads_slow_memory,remote_rea= ds + +This will update all (across all domains of all monitor groups) counter as= signments +associated with the mbm_local_bytes event. + +k. Now read the local event again. The first read may come back with "Unav= ailable" +status. The subsequent read of mbm_local_bytes will display the current va= lue. +:: + + # cat /sys/fs/resctrl/mon_data/mon_L3_00/mbm_local_bytes + Unavailable + # cat /sys/fs/resctrl/mon_data/mon_L3_00/mbm_local_bytes + 314101 + +l. Users have the option to go back to 'default' mbm_assign_mode if requir= ed. This can be +done using the following command. Note that switching the mbm_assign_mode = may reset all +the MBM counters (and thus all MBM events) of all the resctrl groups. +:: + + # echo "default" > /sys/fs/resctrl/info/L3_MON/mbm_assign_mode + # cat /sys/fs/resctrl/info/L3_MON/mbm_assign_mode + mbm_event + [default] + +m. Unmount the resctrl filesystem. +:: + + # umount /sys/fs/resctrl/ + Intel RDT Errata =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D =20 diff --git a/fs/resctrl/internal.h b/fs/resctrl/internal.h index e2e3fc0c5fab..1350fc273258 100644 --- a/fs/resctrl/internal.h +++ b/fs/resctrl/internal.h @@ -418,6 +418,9 @@ int event_filter_show(struct kernfs_open_file *of, stru= ct seq_file *seq, void *v ssize_t event_filter_write(struct kernfs_open_file *of, char *buf, size_t = nbytes, loff_t off); =20 +int resctrl_parse_mbm_assignment(struct rdt_resource *r, struct rdtgroup *= rdtgrp, + char *event, char *tok); + #ifdef CONFIG_RESCTRL_FS_PSEUDO_LOCK int rdtgroup_locksetup_enter(struct rdtgroup *rdtgrp); =20 diff --git a/fs/resctrl/monitor.c b/fs/resctrl/monitor.c index ebc049105949..1e4f8e3bedc6 100644 --- a/fs/resctrl/monitor.c +++ b/fs/resctrl/monitor.c @@ -1311,3 +1311,97 @@ void resctrl_update_cntr_allrdtgrp(struct mon_evt *m= evt) rdtgroup_update_cntr_event(r, crgrp, mevt->evtid); } } + +/* + * mbm_get_mon_event_by_name() - Return the mon_evt entry for the matching + * event name. + */ +static struct mon_evt *mbm_get_mon_event_by_name(struct rdt_resource *r, c= har *name) +{ + struct mon_evt *mevt; + + for_each_mon_event(mevt) { + if (mevt->rid =3D=3D r->rid && mevt->enabled && + resctrl_is_mbm_event(mevt->evtid) && + !strcmp(mevt->name, name)) + return mevt; + } + + return NULL; +} + +static int rdtgroup_modify_assign_state(char *assign, struct rdt_mon_domai= n *d, + struct rdtgroup *rdtgrp, struct mon_evt *mevt) +{ + int ret =3D 0; + + if (!assign || strlen(assign) !=3D 1) + return -EINVAL; + + switch (*assign) { + case 'e': + ret =3D rdtgroup_assign_cntr_event(d, rdtgrp, mevt); + break; + case '_': + rdtgroup_unassign_cntr_event(d, rdtgrp, mevt); + break; + default: + ret =3D -EINVAL; + break; + } + + return ret; +} + +int resctrl_parse_mbm_assignment(struct rdt_resource *r, struct rdtgroup *= rdtgrp, + char *event, char *tok) +{ + struct rdt_mon_domain *d; + unsigned long dom_id =3D 0; + char *dom_str, *id_str; + struct mon_evt *mevt; + int ret; + + mevt =3D mbm_get_mon_event_by_name(r, event); + if (!mevt) { + rdt_last_cmd_printf("Invalid event %s\n", event); + return -ENOENT; + } + +next: + if (!tok || tok[0] =3D=3D '\0') + return 0; + + /* Start processing the strings for each domain */ + dom_str =3D strim(strsep(&tok, ";")); + + id_str =3D strsep(&dom_str, "=3D"); + + /* Check for domain id '*' which means all domains */ + if (id_str && *id_str =3D=3D '*') { + ret =3D rdtgroup_modify_assign_state(dom_str, NULL, rdtgrp, mevt); + if (ret) + rdt_last_cmd_printf("Assign operation '%s:*=3D%s' failed\n", + event, dom_str); + return ret; + } else if (!id_str || kstrtoul(id_str, 10, &dom_id)) { + rdt_last_cmd_puts("Missing domain id\n"); + return -EINVAL; + } + + /* Verify if the dom_id is valid */ + list_for_each_entry(d, &r->mon_domains, hdr.list) { + if (d->hdr.id =3D=3D dom_id) { + ret =3D rdtgroup_modify_assign_state(dom_str, d, rdtgrp, mevt); + if (ret) { + rdt_last_cmd_printf("Assign operation '%s:%ld=3D%s' failed\n", + event, dom_id, dom_str); + return ret; + } + goto next; + } + } + + rdt_last_cmd_printf("Invalid domain id %ld\n", dom_id); + return -EINVAL; +} diff --git a/fs/resctrl/rdtgroup.c b/fs/resctrl/rdtgroup.c index 47716e623a9c..2d2b91cd1f67 100644 --- a/fs/resctrl/rdtgroup.c +++ b/fs/resctrl/rdtgroup.c @@ -1979,6 +1979,51 @@ static int mbm_L3_assignments_show(struct kernfs_ope= n_file *of, struct seq_file return ret; } =20 +static ssize_t mbm_L3_assignments_write(struct kernfs_open_file *of, char = *buf, + size_t nbytes, loff_t off) +{ + struct rdt_resource *r =3D resctrl_arch_get_resource(RDT_RESOURCE_L3); + struct rdtgroup *rdtgrp; + char *token, *event; + int ret =3D 0; + + /* Valid input requires a trailing newline */ + if (nbytes =3D=3D 0 || buf[nbytes - 1] !=3D '\n') + return -EINVAL; + + buf[nbytes - 1] =3D '\0'; + + rdtgrp =3D rdtgroup_kn_lock_live(of->kn); + if (!rdtgrp) { + rdtgroup_kn_unlock(of->kn); + return -ENOENT; + } + rdt_last_cmd_clear(); + + if (!resctrl_arch_mbm_cntr_assign_enabled(r)) { + rdt_last_cmd_puts("mbm_event mode is not enabled\n"); + rdtgroup_kn_unlock(of->kn); + return -EINVAL; + } + + while ((token =3D strsep(&buf, "\n")) !=3D NULL) { + /* + * The write command follows the following format: + * =E2=80=9C:=3D=E2=80=9D + * Extract the event name first. + */ + event =3D strsep(&token, ":"); + + ret =3D resctrl_parse_mbm_assignment(r, rdtgrp, event, token); + if (ret) + break; + } + + rdtgroup_kn_unlock(of->kn); + + return ret ?: nbytes; +} + /* rdtgroup information files for one cache resource. */ static struct rftype res_common_files[] =3D { { @@ -2119,9 +2164,10 @@ static struct rftype res_common_files[] =3D { }, { .name =3D "mbm_L3_assignments", - .mode =3D 0444, + .mode =3D 0644, .kf_ops =3D &rdtgroup_kf_single_ops, .seq_show =3D mbm_L3_assignments_show, + .write =3D mbm_L3_assignments_write, }, { .name =3D "mbm_assign_mode", --=20 2.34.1 From nobody Mon Oct 6 01:21:11 2025 Received: from NAM02-DM3-obe.outbound.protection.outlook.com (mail-dm3nam02on2068.outbound.protection.outlook.com [40.107.95.68]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id A478F24886C; Fri, 25 Jul 2025 18:35:44 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.95.68 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1753468546; cv=fail; b=oJuGayPj1wx0YGIEAHWkxndcgHNuj4K0TROJ9rqQlosOD8hqslTFK+pZOx5wNmG2/63T+nJvCsekzeqZTkoB/KXf1euW35yxDt68ztj/PZJhR871YDVXP1FcSULVZhCI8ljhebq2O4fd2mgy7pJeV50csje98E3VxTp3wCI83nQ= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1753468546; c=relaxed/simple; bh=ztjT5IHH+3hpBhLIlID60K78MV/GmgVMRXLGtGo2iUM=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=YOtlQ8PbNq1YLO1IJrMzR0AY6NPqoxh8OF1T5zlIjJEeQF9ZbZsqiOGWtaNMAH70t/E6f/Vu5mVt2o7nuB10iIAhfaNs2qdJlK+a+kJDYW3ELa88Qofg3UMnwxY4BwQlNxYInJRWJMScsE0fz9qvi78Pgp3+/QgO2QUTpR8jHwU= 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=CGYH/BsS; arc=fail smtp.client-ip=40.107.95.68 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=amd.com Authentication-Results: smtp.subspace.kernel.org; spf=fail smtp.mailfrom=amd.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=amd.com header.i=@amd.com header.b="CGYH/BsS" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=Lt8Rva0wdZEFLPaQwEUZirEXauK1n2fWGBR/daG2CZj4bFRONvOzkllEWYA7eP4BMq2gccqq08/XvIT1naskHHwxV66aGzbKSpe1lXNagOWgZnZOsqTcSTPr9EQMCIhfdjEZ2ouwyKyAnxir7YKQU6XGdbKoejdEjfhUps40Wdnhilb8iTjD9FU5iQ1VOyBMD/ivJtPyLZrBrzxdrrwsmp4nUz8ljqW/o5uaZBRyryvs0qUlUUIikDapS+qOPvRdrDJkINFYrDyu6n5qMuYh3mwqFuoJWqO7MbPrtKgszZugCVePx2aInOFq1AcKhhixoz+YZjxUuKr83nHHWDKQJw== 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=+d+xGTA/oscjHZ2ge0bwl2gNA7vk1ivfQKwPJe4URPU=; b=M7MxT9Qtcf6A2+Ha29vMl6THAky4MnoWNbIQdeauDUA04KFLvVKn2bJ5ipMGAG9GxDZdWhW5A7vNWL4jaMeBRF7jFj2fG7pruhCLoQbX1aKLFu5o8T3NqXqfHQmN4/sYmK/vdCoIjwxR94P7IGpOfJvkuziCEl5XtYjdiD+R+TAtyhH7s4fsKok5x0T+X7SqkhjsO8Rn0Fs7ChLB2IX0wMF0Bd86vjCX7zYbqNqotXiI2tRotsiigOg9ne76X2fFf7csABzpH08w3yIXn/0x8WKB88U6pOxE7QBCwEJS2QAqJw1hBKydZP6gfenLqpB8gXHkO9Q9mtdC8mebwuiGeA== 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=+d+xGTA/oscjHZ2ge0bwl2gNA7vk1ivfQKwPJe4URPU=; b=CGYH/BsSLK7syPSXqKVO0blGHvOl8TPCpJYjLS91wtOTuw79jm62CrALs9Agm2Vy1fgcmBg4Yz9MyiL5IMb7Pke8F/Tf/75AhJSYBZgswrZWqn+rvZuiB1NwzQHX0CxvBPceStwdXAjlO0QjNUFE0cVTvTQ/KUTfgV6KdO1yN/w= Received: from SJ0PR03CA0145.namprd03.prod.outlook.com (2603:10b6:a03:33c::30) by PH0PR12MB5677.namprd12.prod.outlook.com (2603:10b6:510:14d::7) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8964.21; Fri, 25 Jul 2025 18:35:38 +0000 Received: from CY4PEPF0000EE3C.namprd03.prod.outlook.com (2603:10b6:a03:33c:cafe::3b) by SJ0PR03CA0145.outlook.office365.com (2603:10b6:a03:33c::30) with Microsoft SMTP Server (version=TLS1_3, cipher=TLS_AES_256_GCM_SHA384) id 15.20.8964.23 via Frontend Transport; Fri, 25 Jul 2025 18:35:38 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 165.204.84.17) smtp.mailfrom=amd.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=amd.com; Received-SPF: Pass (protection.outlook.com: domain of amd.com designates 165.204.84.17 as permitted sender) receiver=protection.outlook.com; client-ip=165.204.84.17; helo=SATLEXMB04.amd.com; pr=C Received: from SATLEXMB04.amd.com (165.204.84.17) by CY4PEPF0000EE3C.mail.protection.outlook.com (10.167.242.13) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.8964.20 via Frontend Transport; Fri, 25 Jul 2025 18:35: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; Fri, 25 Jul 2025 13:35:35 -0500 From: Babu Moger To: , , , , , , , CC: , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , Subject: [PATCH v16 31/34] fs/resctrl: Disable BMEC event configuration when mbm_event mode is enabled Date: Fri, 25 Jul 2025 13:29:50 -0500 Message-ID: X-Mailer: git-send-email 2.34.1 In-Reply-To: References: Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-ClientProxiedBy: SATLEXMB03.amd.com (10.181.40.144) To SATLEXMB04.amd.com (10.181.40.145) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CY4PEPF0000EE3C:EE_|PH0PR12MB5677:EE_ X-MS-Office365-Filtering-Correlation-Id: 92118b7c-1d7b-4845-553c-08ddcbaa0ccc X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|1800799024|376014|7416014|36860700013|82310400026; X-Microsoft-Antispam-Message-Info: =?utf-8?B?aUs0NmZPNkhjRjB1TlplMFJEZzMxMlhJV1lzQVhpVytRVGY5Z2RMZUg4Yno4?= =?utf-8?B?Q2lSaXkrMk9vcHVxM21qREx4cW9PNUZPRlo0NFB1SzlsU2w2S1pacmdzN2li?= =?utf-8?B?ZFNwTmQrbTdpVTFJWmZ6c0xsRzE3WTQxMlRCL3V0WXBDMDNOVlFFOHVaa2dr?= =?utf-8?B?emVJODNkWmZHZ2R6TUhtQmpQd2oyWjNzVDZPek9WTUVIUU5WK3p5cHQ5dm1r?= =?utf-8?B?K1lIYTZyWlNtZk9HY0VUTVJZT1d3Mjg4a3VzMm44a3FGSi90SmpFUzZIZFVL?= =?utf-8?B?VTI4aVNHTDI4VmNNTUVzd25wVzhwSjJ4QWVuM1VPTHVoRDdxbW9ocTdvbG9Y?= =?utf-8?B?S1IwYk55aS9IaEpKVCtnWHF0MzN4L3RRUmtyK09wRWx3WFhXd1FQSWxWMXhm?= =?utf-8?B?VnF4eWFUYVBWamZIMmJRaXRLc0xNWDFyK1lpVjNPTHZNWUFIZ0dMTFE3cTRB?= =?utf-8?B?SjRKcmt5d1RLNnEzSzUyZjlGMWYwOEhuUGhYVEVJdUx3Q21jaFVXWjNON04r?= =?utf-8?B?RU9TVnprbm54MUlneGJLaWZpMVRlL2xDSmtIVUtxaDhKRjIxYTRLMjFyU1VT?= =?utf-8?B?U0hZb0xOR1E2MUp3aDVSNytvMFBkcnFvTHlxZWJpSXRKTEpLTjFDQ0JFVWRh?= =?utf-8?B?eGg1NTNHOSszTzVZSkhmTllCeElXM05ITWZHbW4xd1J6WnBxcDc4bERZRWlV?= =?utf-8?B?UHU4N1crSFpTNHVXVHBXeFVYblZrd2dBY0Y1SmJSQ2c2cGZaNjhySC9GUTlT?= =?utf-8?B?ejRuU0pDZ3hLVTV6M0Q5RkZRcG9lZFNycHVzd2Rsc3dHNW9qbzErUHNRTDE0?= =?utf-8?B?ZnU2SmdRNEhxaHJoeG1HUmwzVGdRQVZrS2VJOWpyRUhKRUdpS1dDSVVwWkkr?= =?utf-8?B?V01mZ1pvbldRTC9rdUc5aXc4V2swQ3ZnOENPRW14U29yM3d6VUlUSml6ejY0?= =?utf-8?B?L3RDZEpJR2h0NmRlUW9GQVd6NkFTV2oyWVBYaTI1QTE3d2hmUVZycWlBZnRM?= =?utf-8?B?dnpYd3NyaE4wSzJBZnRRV0hFZ0QwQkdIZElPRll5N2NjSmQ3bjRvWUExcDJK?= =?utf-8?B?aldKeGZNU2RqZC8yTmRyRnplQWJvUTE2TllqVEVGc1liWjA0MWJJVkNSQVpV?= =?utf-8?B?cDhVOTFRWFFNTHkvenBtc2kwdk9NdDFXalNzZWdOQi94S2tNN2NuNG91bkdR?= =?utf-8?B?cWMySU5hMHRoVm52RVorWVpiMDdROS9uQ0NLTjZscitBTkRXN0hlcFJlN2wy?= =?utf-8?B?dHdwbEN6T0MydEJ2N2s2bjJWMjNjU2ZDQmJUd0lqQ3pKRGp1NldqRVBHN1Ni?= =?utf-8?B?dWlnRlZYWnIyeHZ4R2Q4ZnRIMkJ4dlhnWVpRYktybFJ3NnZ2Q0VSaUZkeFZ0?= =?utf-8?B?VVlvU3FlNVJjOGsxUHQ0ak1ST3VTdmZ0NENWRCtaTUM1dDFCMUtHbXdsUFFM?= =?utf-8?B?amVEdHhNeXZmd21DK2RaRWVrSWdRcGxhL2lzSHJzUW54bThGZldGOHkyZWh3?= =?utf-8?B?bTJaTncrNWpBd1hqSUIydm5CMVF3cTRFRGxrcjFRYXRSaXc1N2FzZXc0QmNE?= =?utf-8?B?S2h6bkxvOFBnUk1RUjJFeU8yaGphaWdVbG40NlB4Uk9GWk9uNEdUTXFpUjB5?= =?utf-8?B?WjJYV3FDQ1ZjUWJ2RXdjSnpKK3I5eTdHbGdxRnUyZW1lcURQSUdkSGhxMll0?= =?utf-8?B?N2FkY1RTSm5HSWxWc2U5SXhPVXJtRWpxSGJkWm5JQnh3MGJpK2hiTG5pRkFh?= =?utf-8?B?T08rWmtKV0hrZ0xXb2kxMDdINXJnbE1KS3VYcmtlcUE2Rkk1S1Nmb0tmV1BY?= =?utf-8?B?Tm1DOEM0RXhKWnRpTHZjbjRSOGRNQkZSc1ZlNjJadERDZGcwU3hZYVFFc1Rp?= =?utf-8?B?RU1hV3JTTy9Xc2s3dDBPeWZrdDQxTUtGcVBQSkdLRG9BWmJpSDl6akVIMVEz?= =?utf-8?B?RFRCMDhXQUZUWUVDaXV3bW5HNUZaV0FaZXhQU0xYd0JOK1V2eis0SXg5c3o0?= =?utf-8?B?ZFIwM3NwUnVORkNVYUFPL2ZWcnBySjNDWnpPWjJVY0FKZWlLdVh0ZlpjZHB1?= =?utf-8?Q?OpmZSg?= 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);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 25 Jul 2025 18:35:37.5202 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 92118b7c-1d7b-4845-553c-08ddcbaa0ccc 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: CY4PEPF0000EE3C.namprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH0PR12MB5677 The BMEC (Bandwidth Monitoring Event Configuration) feature enables per-domain event configuration. With BMEC the MBM events are configured using the mbm_total_bytes_config or mbm_local_bytes_config files in /sys/fs/resctrl/info/L3_MON/ and the per-domain event configuration affects all monitor resource groups. The mbm_event counter assignment mode enables counters to be assigned to RMID (i.e a monitor resource group), event pairs, with potentially unique event configurations associated with every counter. There may be systems that support both BMEC and mbm_event counter assignment mode, but resctrl supporting both concurrently will present a conflicting interface to the user with both per-domain and per RMID, event configurations active at the same time. The mbm_event counter assignment provides most flexibility to user space and aligns with Arm's counter support. On systems that support both, disable BMEC event configuration when mbm_event mode is enabled by hiding the mbm_total_bytes_config or mbm_local_bytes_config files when mbm_event mode is enabled. Ensure mon_features always displays accurate information about monitor features. Suggested-by: Reinette Chatre Signed-off-by: Babu Moger --- v16: Added new comment in resctrl_bmec_files_show() about kernfs_find_and_g= et failure. Added the parameter to resctrl_bmec_files_show() to pass the kernfs_no= de. v15: Updated the changelog. Moved resctrl_bmec_files_show() inside rdtgroup_mkdir_info_resdir(). Removed the unnecessary kernfs_get() call. v14: Updated the changelog for change in mbm_assign_modes. Added check in rdt_mon_features_show to hide bmec related feature. v13: New patch to hide BMEC related files. --- fs/resctrl/rdtgroup.c | 44 ++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 43 insertions(+), 1 deletion(-) diff --git a/fs/resctrl/rdtgroup.c b/fs/resctrl/rdtgroup.c index 2d2b91cd1f67..1aeac350774d 100644 --- a/fs/resctrl/rdtgroup.c +++ b/fs/resctrl/rdtgroup.c @@ -1150,7 +1150,8 @@ static int rdt_mon_features_show(struct kernfs_open_f= ile *of, if (mevt->rid !=3D r->rid || !mevt->enabled) continue; seq_printf(seq, "%s\n", mevt->name); - if (mevt->configurable) + if (mevt->configurable && + !resctrl_arch_mbm_cntr_assign_enabled(r)) seq_printf(seq, "%s_config\n", mevt->name); } =20 @@ -1799,6 +1800,41 @@ static ssize_t mbm_local_bytes_config_write(struct k= ernfs_open_file *of, return ret ?: nbytes; } =20 +/* + * resctrl_bmec_files_show() =E2=80=94 Controls the visibility of BMEC-rel= ated resctrl + * files. When @show is true, the files are displayed; when false, the fil= es + * are hidden. + * Don't treat kernfs_find_and_get failure as an error, since this functio= n may + * be called regardless of whether BMEC is supported or the event is enabl= ed. + */ +static void resctrl_bmec_files_show(struct rdt_resource *r, struct kernfs_= node *l3_mon_kn, + bool show) +{ + struct kernfs_node *kn_config; + char name[32]; + + if (!l3_mon_kn) { + sprintf(name, "%s_MON", r->name); + l3_mon_kn =3D kernfs_find_and_get(kn_info, name); + if (!l3_mon_kn) + return; + } + + kn_config =3D kernfs_find_and_get(l3_mon_kn, "mbm_total_bytes_config"); + if (kn_config) { + kernfs_show(kn_config, show); + kernfs_put(kn_config); + } + + kn_config =3D kernfs_find_and_get(l3_mon_kn, "mbm_local_bytes_config"); + if (kn_config) { + kernfs_show(kn_config, show); + kernfs_put(kn_config); + } + + kernfs_put(l3_mon_kn); +} + static int resctrl_mbm_assign_mode_show(struct kernfs_open_file *of, struct seq_file *s, void *v) { @@ -2492,6 +2528,12 @@ static int rdtgroup_mkdir_info_resdir(void *priv, ch= ar *name, ret =3D resctrl_mkdir_event_configs(r, kn_subdir); if (ret) return ret; + /* + * Hide BMEC related files if mbm_event mode + * is enabled. + */ + if (resctrl_arch_mbm_cntr_assign_enabled(r)) + resctrl_bmec_files_show(r, kn_subdir, false); } } =20 --=20 2.34.1 From nobody Mon Oct 6 01:21:11 2025 Received: from NAM12-MW2-obe.outbound.protection.outlook.com (mail-mw2nam12on2068.outbound.protection.outlook.com [40.107.244.68]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 5AA0F25B695; Fri, 25 Jul 2025 18:35:49 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.244.68 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1753468551; cv=fail; b=gtb/FM1whU4Q+VyZkSGtx32k0LU2bPSDQ3nYWOtnv4hqjO0rkYfOERQN/C/wef/vZPax3AvKkzxqqqECofQPd8RdnnhAwl1oAbTibiW4eKIEO+grxwkpV92+G1cmelYAQlqeqBF7kKBDmWqMBqUTz+TxOmEXzstxrAxf7Il8jPo= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1753468551; c=relaxed/simple; bh=nCXxbpAM9Fwy2PNK6LHBsh9tWHAueQQkb62qLnroLJM=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=dpPjIVav2FBz96/UnL1qY+AkAro7tshR65QzY89/p3615s8qOMubCMmFfm4MjGMlm1gU1++Xbu4GeS89k/6Gl1fgfnK76yy/R6+rJDjULIb4fbN/iXpWDYdRcHIZb6duSKoQ6XenaQBmCUF8ngR08fcYiYju86mkm/6mdwTB+hw= 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=geMK4ZGU; arc=fail smtp.client-ip=40.107.244.68 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=amd.com Authentication-Results: smtp.subspace.kernel.org; spf=fail smtp.mailfrom=amd.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=amd.com header.i=@amd.com header.b="geMK4ZGU" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=pXQ/EFKuS37YxXGI8QLRzaY1C4IA9E1Ob6KM2dG9YZmODkyVPUb8SpQRomAwbuAEeSXK+ZcH8+YVnobrQCEzGgKnUX6uQ5FRjpivAi0XVtYzAMdK3bjJjvRWYZeTIIvU+eEe2DuvZh4TqCldwT6d6BXrkLScI9URHlc341WdfBib0ksHxHKPpbGhIPAeTmhHJVVwM8AsTD3/PhaHHk8tiz00+o5UuEhfOgvp/EBKmChN44w/n+hO1bgZHt+2Tfn+WRCjGwrWd4Kk8fOkhausSMECXBHYL2SXra8BjGnWUBWGYgrFKBzmasJSgEfFbD6kCX7+QM763gbfo76Z0WUC+A== 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=2r/bfU+ekV9CeAEoZDJbmQPsYA6u+iMLuubTfAH9u/A=; b=gJ954vhyE63vvyNdgEySUD34lqoYRfF8SJNxo8fGydszbUwXfUn7LqVhRp12GrXe/GPUEWYnqBDVpL6nFiDL2vfqHVvJf/XpIlNZ083u3MTO/2l1yaQiMDIAvKMU+JBkOQkbolmNCdAAVuTJMog+BKs5Vq9Ms5LECd/ETVu2RpAWQO3OcSprYGj2Anu34r+ru+WYpDUFRgIXmC6oXnwwMDM/Z5Sx8ZrPAkacSJrYDXX71q8AC8ZFE4ieLhHsZZ2BKxnvBbdYs6/xR64v8MypHLtts59ubKj92lUqKt4mnMMFUh/sL7cYuiSR/x1LEHSRuzmm8zbq9wAmvkC7cAyKGg== 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=2r/bfU+ekV9CeAEoZDJbmQPsYA6u+iMLuubTfAH9u/A=; b=geMK4ZGUVFwPyUNXhsIieFWhXTgMGPQfr0q1esg3GamTpW1WUbeFACg2ikHhNV1fSk5HuPOfm9SPsP0g9tMOYNplcDvc2SBbJ4vPX8QML7IhRlxf/MIweFjStsTV9ROAIX6rC7Lrto8I0uza7OWnyFxoRHJ6FhNlxMs8buZDq48= Received: from CY5PR19CA0028.namprd19.prod.outlook.com (2603:10b6:930:15::24) by DM4PR12MB6160.namprd12.prod.outlook.com (2603:10b6:8:a7::13) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8964.21; Fri, 25 Jul 2025 18:35:46 +0000 Received: from CY4PEPF0000EE3F.namprd03.prod.outlook.com (2603:10b6:930:15:cafe::bc) by CY5PR19CA0028.outlook.office365.com (2603:10b6:930:15::24) with Microsoft SMTP Server (version=TLS1_3, cipher=TLS_AES_256_GCM_SHA384) id 15.20.8964.23 via Frontend Transport; Fri, 25 Jul 2025 18:35:46 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 165.204.84.17) smtp.mailfrom=amd.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=amd.com; Received-SPF: Pass (protection.outlook.com: domain of amd.com designates 165.204.84.17 as permitted sender) receiver=protection.outlook.com; client-ip=165.204.84.17; helo=SATLEXMB04.amd.com; pr=C Received: from SATLEXMB04.amd.com (165.204.84.17) by CY4PEPF0000EE3F.mail.protection.outlook.com (10.167.242.17) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.8964.20 via Frontend Transport; Fri, 25 Jul 2025 18:35:46 +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; Fri, 25 Jul 2025 13:35:43 -0500 From: Babu Moger To: , , , , , , , CC: , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , Subject: [PATCH v16 32/34] fs/resctrl: Introduce the interface to switch between monitor modes Date: Fri, 25 Jul 2025 13:29:51 -0500 Message-ID: <9f7816ff6cefbffa2a9a701d2fd3bffbd9777736.1753467772.git.babu.moger@amd.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: References: Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-ClientProxiedBy: SATLEXMB03.amd.com (10.181.40.144) To SATLEXMB04.amd.com (10.181.40.145) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CY4PEPF0000EE3F:EE_|DM4PR12MB6160:EE_ X-MS-Office365-Filtering-Correlation-Id: f12db577-8488-4497-ec85-08ddcbaa121f X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|36860700013|82310400026|7416014|376014|1800799024; X-Microsoft-Antispam-Message-Info: =?us-ascii?Q?usTCTFL+i5r/A//fPfODrBKwMbMfPl4TuG3qBAnXSgJYvJLAcANkgpTznyuj?= =?us-ascii?Q?gOSlhLeyUlma1PSsO6mPQ+KC89AfqxsN0MNwtbNAuyNrKebyfR4bEaSZh2lO?= =?us-ascii?Q?OpoquRQH7jdBkioONS12JX1mtsq8Q2Cs+GL5G0pRjZx8HFz+fbJOmzqvYeZm?= =?us-ascii?Q?TuOsy2F2P/YYjj7KZB9n5bXlDBezX7vQQQ1VEiSqS6wrnudElzei1RTUqtU0?= =?us-ascii?Q?+FB22wYjSTsdrvN7Km8qC7Kw8E07L6/R3kGINpnKm8pao0TIcDIow+NI/SBI?= =?us-ascii?Q?Neh7BGjWzFwFehrZC0a8cb8gTB0DSBoNZ4tmEPxC5ToDUNVHzaSyypUv1eDK?= =?us-ascii?Q?fiFfVkbBOO6O3H41lY6UHkRhJo9zu7a2mfURMBvyxbYLICigTxWAI9l8fjJZ?= =?us-ascii?Q?ac8RK1LnND6nGtlkb7KpiKgfDE2l2GgbhxxTi6wO6DwZ4ba02D/PIFj6kH8w?= =?us-ascii?Q?+yMsLwq3nB4urgNdws09fw080JXp/VmM2rpVb9FuxqBMCLuoqKqiwVZppePI?= =?us-ascii?Q?tMWrmPwQgntVlu8nGJaAN2yRex3jXo/njneZNiyLKyetyRxy/geiye+SwHH0?= =?us-ascii?Q?jrpfZcf0bJIsZ8pgOECBN83oqUTF9DwtLnt4X3GTQi2bZzCX0JNmgfspm/1o?= =?us-ascii?Q?K6zT87kPyuFhdUUM1KgF6Ohahi48hjzOrX7Z01VUgWbGLboh15APWB4HrXeL?= =?us-ascii?Q?c1DYsLrRdIw9yyUVdgFrflCYIbbBvD/BIJnJRJIUJP0Ka0OqyXicgSKBTmXz?= =?us-ascii?Q?ScMch8HVi+fizJ5kTpyX3XHdRSn+j1wepgiqRRoAQsCuzSnsrCVGaLoOGdIn?= =?us-ascii?Q?RNPnZzKt96MaL4c/aKeBncRumqWr0GhrXycDk/WxceZf4f63+ZPjUmbH0qQg?= =?us-ascii?Q?sAv2IhHFPCZMh8y32PAuvblzQH41I28wktNlt0WVESf9SkXt0ogp2O2M2uys?= =?us-ascii?Q?PgUgQ3SOvn12fLtBlN4ii+OoyEDRJkaKN7d4NrojxhICMi77IuOoq0kJXatK?= =?us-ascii?Q?enr2PcbrWsGyGcNQyGrpOsCdckL/+4O3e+n42hzzVi7X6qd7b53iV7BHM2R6?= =?us-ascii?Q?IDDdlIJz+oQ/B21qQl3CvdhQeoSzMVg5pmtrt4UF0oXbKcoPeFmor/jN8Yq9?= =?us-ascii?Q?CftrauxdT4LpdRD+r1E6MwlD/Vs8f6iiCehc3PeQURHCI16iRhb3mcB/TlLZ?= =?us-ascii?Q?4w6cPwwD/Yg+/RS5/xvX0R99aHkqcwVEBxdYwAh/1D7vLIX3vsQlnrQxvpAD?= =?us-ascii?Q?UX3O7Jr6dDKgu7LGeV4KGiskBvjqoR4+iPhKkd3nRV6p7hVvVjxE4fnWo/RF?= =?us-ascii?Q?m/bL7hqyIQM2U006PMWOKHyXJ7hva08ap6xIdHv/cbv0zqgJf9h9QHFOMfnQ?= =?us-ascii?Q?ei4kc/rIA0mbeaObPpsAdBJ65QqZIcfAzNqklLQ8KM3K6Aytl8tAZ6PwQiY+?= =?us-ascii?Q?iUR0b+bEvNHv8Dbw7INWRV+tp7gXK13kWCgIrnnbin/2KVCCTWswRMgKC8+1?= =?us-ascii?Q?CvPH6E4H5k7u2lfFeO3oy1hRTREEV4lQeeiwca4rAAZTTsyRWSiU7W+ahQ?= =?us-ascii?Q?=3D=3D?= X-Forefront-Antispam-Report: CIP:165.204.84.17;CTRY:US;LANG:en;SCL:1;SRV:;IPV:CAL;SFV:NSPM;H:SATLEXMB04.amd.com;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(13230040)(36860700013)(82310400026)(7416014)(376014)(1800799024);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 25 Jul 2025 18:35:46.4564 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: f12db577-8488-4497-ec85-08ddcbaa121f 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: CY4PEPF0000EE3F.namprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM4PR12MB6160 Content-Type: text/plain; charset="utf-8" Resctrl subsystem can support two monitoring modes, "mbm_event" or "default". In mbm_event mode, 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 mbm_assign_mode resctrl file to switch between mbm_event and default modes. Example: To list the MBM monitor modes supported: $ cat /sys/fs/resctrl/info/L3_MON/mbm_assign_mode [mbm_event] default To enable the "mbm_event" counter assignment mode: $ echo "mbm_event" > /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. Also clear assignable counter configuration on all the domains. Signed-off-by: Babu Moger --- v16: Minor changelog update. Minor update in resctrl.rst. Updated resctrl_bmec_files_show() to pass NULL for kn_fs_node. v15: Minor changelog update. Minir user do resctrl.rst update. Fixed stray hunks. v14: Updated the changelog to reflect the change in monitor mode naming. Added the call resctrl_bmec_files_show() to enable/disable files related to BMEC. Added resctrl_set_mon_evt_cfg() to reset event configuration values when mode is changes. v13: Resolved the conflicts due to FS/ARCH restructure. Introduced the new resctrl_init_evt_configuration() to initialize the event modes and configuration values. Added the call to resctrl_bmec_files_show() hide/show BMEC related files. v12: Fixed the documentation for a consistency. Introduced mbm_cntr_free_all() and resctrl_reset_rmid_all() to clear counters and non-architectural states when monitor mode is changed. https://lore.kernel.org/lkml/b60b4f72-6245-46db-a126-428fb13b6310@inte= l.com/ v11: Changed the name of the function rdtgroup_mbm_assign_mode_write() to resctrl_mbm_assign_mode_write(). Rewrote the commit message with context. Added few more details in resctrl.rst about mbm_cntr_assign mode. Re-arranged the text in resctrl.rst file. v10: The call mbm_cntr_reset() has been moved to earlier patch. Minor documentation update. v9: Fixed extra spaces in user documentation. Fixed problem changing the mode to mbm_cntr_assign mode when it is not supported. Added extra checks to detect if systems supports it. Used the rdtgroup_cntr_id_init to initialize cntr_id. v8: Reset the internal counters after mbm_cntr_assign mode is changed. Renamed rdtgroup_mbm_cntr_reset() to mbm_cntr_reset() Updated the documentation to make text generic. v7: Changed the interface name to mbm_assign_mode. Removed the references of ABMC. Added the changes to reset global and domain bitmaps. Added the changes to reset rmid. v6: Changed the mode name to mbm_cntr_assign. Moved all the FS related code here. Added changes to reset mbm_cntr_map and resctrl group counters. v5: Change log and mode description text correction. v4: Minor commit text changes. Keep the default to ABMC when supported. Fixed comments to reflect changed interface "mbm_mode". v3: New patch to address the review comments from upstream. --- Documentation/filesystems/resctrl.rst | 22 +++++++- fs/resctrl/internal.h | 2 + fs/resctrl/monitor.c | 27 ++++++++++ fs/resctrl/rdtgroup.c | 72 ++++++++++++++++++++++++++- 4 files changed, 121 insertions(+), 2 deletions(-) diff --git a/Documentation/filesystems/resctrl.rst b/Documentation/filesyst= ems/resctrl.rst index 0c8701103214..35bd58af5c61 100644 --- a/Documentation/filesystems/resctrl.rst +++ b/Documentation/filesystems/resctrl.rst @@ -259,7 +259,8 @@ with the following files: =20 "mbm_assign_mode": The supported counter assignment modes. The enclosed brackets indicate wh= ich mode - is enabled. + is enabled. The MBM events associated with counters may reset when "mbm_a= ssign_mode" + is changed. :: =20 # cat /sys/fs/resctrl/info/L3_MON/mbm_assign_mode @@ -279,6 +280,15 @@ with the following files: of counters available is described in the "num_mbm_cntrs" file. Changing = the mode may cause all counters on the resource to reset. =20 + Moving to mbm_event counter assignment mode requires 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 @@ -288,6 +298,16 @@ with the following files: result in misleading values or display "Unavailable" if no counter is ass= igned to the event. =20 + * To enable "mbm_event" counter assignment mode: + :: + + # echo "mbm_event" > /sys/fs/resctrl/info/L3_MON/mbm_assign_mode + + * To enable "default" monitoring mode: + :: + + # echo "default" > /sys/fs/resctrl/info/L3_MON/mbm_assign_mode + "num_mbm_cntrs": The maximum number of counters (total of available and assigned counters)= in each domain when the system supports mbm_event mode. diff --git a/fs/resctrl/internal.h b/fs/resctrl/internal.h index 1350fc273258..c666aaf7858f 100644 --- a/fs/resctrl/internal.h +++ b/fs/resctrl/internal.h @@ -410,6 +410,8 @@ void rdtgroup_unassign_cntr_event(struct rdt_mon_domain= *d, struct rdtgroup *rdt int mbm_cntr_get(struct rdt_resource *r, struct rdt_mon_domain *d, struct rdtgroup *rdtgrp, enum resctrl_event_id evtid); void resctrl_update_cntr_allrdtgrp(struct mon_evt *mevt); +void resctrl_reset_rmid_all(struct rdt_resource *r, struct rdt_mon_domain = *d); +void mbm_cntr_free_all(struct rdt_resource *r, struct rdt_mon_domain *d); =20 void *rdt_kn_parent_priv(struct kernfs_node *kn); =20 diff --git a/fs/resctrl/monitor.c b/fs/resctrl/monitor.c index 1e4f8e3bedc6..a4411a128431 100644 --- a/fs/resctrl/monitor.c +++ b/fs/resctrl/monitor.c @@ -1093,6 +1093,33 @@ void resctrl_mon_resource_exit(void) dom_data_exit(r); } =20 +/* + * mbm_cntr_free_all() - Clear all the counter ID configuration details in= the + * domain @d. Called when mbm_assign_mode is changed. + */ +void mbm_cntr_free_all(struct rdt_resource *r, struct rdt_mon_domain *d) +{ + memset(d->cntr_cfg, 0, sizeof(*d->cntr_cfg) * r->mon.num_mbm_cntrs); +} + +/* + * resctrl_reset_rmid_all() - Reset all non-architecture states for all the + * supported RMIDs. + */ +void resctrl_reset_rmid_all(struct rdt_resource *r, struct rdt_mon_domain = *d) +{ + u32 idx_limit =3D resctrl_arch_system_num_rmid_idx(); + enum resctrl_event_id evt; + int idx; + + for_each_mbm_event_id(evt) { + if (!resctrl_is_mon_event_enabled(evt)) + continue; + idx =3D MBM_STATE_IDX(evt); + memset(d->mbm_states[idx], 0, sizeof(*d->mbm_states[0]) * idx_limit); + } +} + /* * rdtgroup_assign_cntr() - Assign/unassign the counter ID for the event, = RMID * pair in the domain. diff --git a/fs/resctrl/rdtgroup.c b/fs/resctrl/rdtgroup.c index 1aeac350774d..68ba08e95a54 100644 --- a/fs/resctrl/rdtgroup.c +++ b/fs/resctrl/rdtgroup.c @@ -1865,6 +1865,75 @@ static int resctrl_mbm_assign_mode_show(struct kernf= s_open_file *of, return 0; } =20 +static ssize_t resctrl_mbm_assign_mode_write(struct kernfs_open_file *of, + char *buf, size_t nbytes, loff_t off) +{ + struct rdt_resource *r =3D rdt_kn_parent_priv(of->kn); + struct rdt_mon_domain *d; + int ret =3D 0; + bool enable; + + /* Valid input requires a trailing newline */ + if (nbytes =3D=3D 0 || buf[nbytes - 1] !=3D '\n') + return -EINVAL; + + buf[nbytes - 1] =3D '\0'; + + cpus_read_lock(); + mutex_lock(&rdtgroup_mutex); + + rdt_last_cmd_clear(); + + if (!strcmp(buf, "default")) { + enable =3D 0; + } else if (!strcmp(buf, "mbm_event")) { + if (r->mon.mbm_cntr_assignable) { + enable =3D 1; + } else { + ret =3D -EINVAL; + rdt_last_cmd_puts("mbm_event mode is not supported\n"); + goto out_unlock; + } + } else { + ret =3D -EINVAL; + rdt_last_cmd_puts("Unsupported assign mode\n"); + goto out_unlock; + } + + if (enable !=3D resctrl_arch_mbm_cntr_assign_enabled(r)) { + ret =3D resctrl_arch_mbm_cntr_assign_set(r, enable); + if (ret) + goto out_unlock; + + /* Update the visibility of BMEC related files */ + resctrl_bmec_files_show(r, NULL, !enable); + + /* + * Initialize the default memory transaction values for + * total and local events. + */ + if (resctrl_is_mon_event_enabled(QOS_L3_MBM_TOTAL_EVENT_ID)) + mon_event_all[QOS_L3_MBM_TOTAL_EVENT_ID].evt_cfg =3D MAX_EVT_CONFIG_BIT= S; + if (resctrl_is_mon_event_enabled(QOS_L3_MBM_LOCAL_EVENT_ID)) + mon_event_all[QOS_L3_MBM_LOCAL_EVENT_ID].evt_cfg =3D READS_TO_LOCAL_MEM= | + READS_TO_LOCAL_S_MEM | + NON_TEMP_WRITE_TO_LOCAL_MEM; + /* + * Reset all the non-achitectural RMID state and assignable counters. + */ + list_for_each_entry(d, &r->mon_domains, hdr.list) { + mbm_cntr_free_all(r, d); + resctrl_reset_rmid_all(r, d); + } + } + +out_unlock: + mutex_unlock(&rdtgroup_mutex); + cpus_read_unlock(); + + return ret ?: nbytes; +} + static int resctrl_num_mbm_cntrs_show(struct kernfs_open_file *of, struct seq_file *s, void *v) { @@ -2207,9 +2276,10 @@ static struct rftype res_common_files[] =3D { }, { .name =3D "mbm_assign_mode", - .mode =3D 0444, + .mode =3D 0644, .kf_ops =3D &rdtgroup_kf_single_ops, .seq_show =3D resctrl_mbm_assign_mode_show, + .write =3D resctrl_mbm_assign_mode_write, .fflags =3D RFTYPE_MON_INFO | RFTYPE_RES_CACHE, }, { --=20 2.34.1 From nobody Mon Oct 6 01:21:11 2025 Received: from NAM10-DM6-obe.outbound.protection.outlook.com (mail-dm6nam10on2065.outbound.protection.outlook.com [40.107.93.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 3777B252917; Fri, 25 Jul 2025 18:36:00 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.93.65 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1753468562; cv=fail; b=h398oFTKUXtQIqn5VgFZuCAtcwnqY66cUcVteAISNCOQFGcvJoZvNYj01O3a9vZ7kT2VA7r2uux4zuiACP6jCp5b4CuoztQcHoJnFodafeoL4o4ZJGr/JTc0VN5UzIISLfzSdYgfH6HioyOW9F2brvK4pk1g7L9zvnn3nIXFv6Y= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1753468562; c=relaxed/simple; bh=Lm74TRrGKd5Edx0ZcslLOv+8js6UqfTZZMSlNOPChFM=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=uMxrHSpN4mwhajYXLuGxIqXZAotuxjkd8l+sRtdG4AW1S7qKdQUuczHzOmTwMwnPOePYMBRMEBM1cPnT8uwqwzLF+wlqaV8qvWKdgzSu1lEZ/LRMskaH9pqQbV43pgRjryZzoZDciAmcf6z/dpzYJJtpmJkubQTTyTBGxIA0cao= 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=ElH5/3bq; arc=fail smtp.client-ip=40.107.93.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="ElH5/3bq" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=gR36x1lxzDWYWBwzc3KWG1S45dHofZ7DKSKSJAPhEwAAmMfJ0BTMiY57BtoBagxPCSyXp/sN69vE6r7MTenkkN8twpOH0HQYjrr8IJjg5lj8D/tFxs70yfbtGkzq189gXpLHKDmtg3wq8Q80RGma88NYVAfVUN+RCRQNfh7Ma1xTe8RtCcV1QSlV3m242Y9zMOV+UKdGigzPeVI1vRMr8X0Tbrpdx69Xhloj291qpABv5l/9roxYp4Ol8MrBo+nW1OtRzhzAXH2YypjeIyPW2P7dc48TRK1JoKVk+gg3omNNmZ3cpwOSCrfV52kBYdd6qR2nOZCLChpV3J4gMuSiuQ== 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=0RQuBbfcOm+gSk/9wiCAqs69NRBp3EJ3sPNGnqGvlJA=; b=gQw598yOOnS7sw5CBgK/xsCd8paFrG0Bcs3NpLb5TKzLlN4KbT+CgZo0HVodM4ma581Y13zXkXFl9muLactj1JQNvPfl7DpcxRD7PiicdhNBse9WKbam1FoTGv2Omg/M1AHc8gxbaIjEGDGBHJqKuaxCHxq/2skdyeYHq2E5Rs6N/Rbqvi/U9I+kF4sdrty/jKMn4QvveoNHIIpGnhbcME3WurVTU8k6yExGv3Km/vG7SYFu+NJalBPQxSfvdpqp+Fh9USJFF03zPjAMbebZzT2Co/1M1EGYJwJWMwt/f+OmTW5chviy15WRsJyGEXkY+fjDOioebSFACedIMGYnJQ== 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=0RQuBbfcOm+gSk/9wiCAqs69NRBp3EJ3sPNGnqGvlJA=; b=ElH5/3bqj85Wbi8jBEsKOHuhJVn83ociKK5PQua5Yan7O4aejc8cX1zzVKoyyrIg0hMxAt+0dVNJxxbMPtAvVRrJe8gpIgLU8qnO0r0IfzrBjDyd4wmUL4K6W65ammeA7SAb9HyZ1yjCk6GZtrZxdRwVqKHMo9O+k8VQIIxxliU= Received: from SJ0PR13CA0035.namprd13.prod.outlook.com (2603:10b6:a03:2c2::10) by LV9PR12MB9806.namprd12.prod.outlook.com (2603:10b6:408:2ea::7) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8964.21; Fri, 25 Jul 2025 18:35:57 +0000 Received: from CY4PEPF0000EE3E.namprd03.prod.outlook.com (2603:10b6:a03:2c2:cafe::70) by SJ0PR13CA0035.outlook.office365.com (2603:10b6:a03:2c2::10) with Microsoft SMTP Server (version=TLS1_3, cipher=TLS_AES_256_GCM_SHA384) id 15.20.8964.15 via Frontend Transport; Fri, 25 Jul 2025 18:35:56 +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 CY4PEPF0000EE3E.mail.protection.outlook.com (10.167.242.16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.8964.20 via Frontend Transport; Fri, 25 Jul 2025 18:35: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; Fri, 25 Jul 2025 13:35:52 -0500 From: Babu Moger To: , , , , , , , CC: , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , Subject: [PATCH v16 33/34] x86/resctrl: Configure mbm_event mode if supported Date: Fri, 25 Jul 2025 13:29:52 -0500 Message-ID: X-Mailer: git-send-email 2.34.1 In-Reply-To: References: Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-ClientProxiedBy: SATLEXMB03.amd.com (10.181.40.144) To SATLEXMB04.amd.com (10.181.40.145) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CY4PEPF0000EE3E:EE_|LV9PR12MB9806:EE_ X-MS-Office365-Filtering-Correlation-Id: e4c5eb72-070d-4104-d1a8-08ddcbaa175a X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|1800799024|376014|7416014|36860700013|82310400026; X-Microsoft-Antispam-Message-Info: =?us-ascii?Q?OFB38k5tHCoXL6UWZnQ+GJU6uWLZVGPYl2lGJRSkTUYFKcTmON0pDowtLpZ+?= =?us-ascii?Q?ZtcwgqAIewKDQHCFzWe0ElptHiEIrq8rQIMTg9DHQZeA15tsAjsiYLzdztAI?= =?us-ascii?Q?Q5S/R4uRr+a+A6eUHj8pWnP6texPlckGVrFIZWelIW+N245Vmcm1vJk7VUoM?= =?us-ascii?Q?aqHN1xf0X4SHukyNS0nD6UhUr8VrH3Y8TZBBE/ggFyEodQgNjXwPkqzuZtn4?= =?us-ascii?Q?mwOhSz2fmMDkwPsyIq++gxQUB0Oqx3H4v7mC27oiQ1r3RM5NTPmvFG5tt8Ff?= =?us-ascii?Q?8pI04TpjBbTM1N8Y6tOjZaaEt7zHrbzV0U5AIFRzi96QQzQFdKOZKmqva+gn?= =?us-ascii?Q?lqv0Go0ab5k5BkqK0yxQUQgXvWKhiZCRcPK2Bb76B3duQv7Gq/30xVvt2mB9?= =?us-ascii?Q?8AgEt60iGKAvl2tjBKjkd6ZI2eXaLnC0FzPCRN5jxGrwJ2r3Vj8hsmkICK6S?= =?us-ascii?Q?bLXjyvu7Hdb9ftj/sjoPNOeo7yrzvVnclPrYkLjKP0Y1PWYZ8pTuIYDzBqxp?= =?us-ascii?Q?Jp+F1EL0JRC/EnAyH/K4vKqr6sM//t3sxBOEQKVmLRJRto9qDARohpAz72qH?= =?us-ascii?Q?zqvuJQzMwuKmP9a4YUYpmPtRyiBVZu9/H297+kqy/tdxsZtx6u7XYjtpCtJO?= =?us-ascii?Q?AgHuasQaVG0+cZjl1ZPsDXHPKpAGOhkx1VJKU8Qq/Jt3MeVhd/KUuhYTZQCU?= =?us-ascii?Q?JXa3YXyNbLwyx+vcaEQuBRPrEGZqFOBKnve7FzhLRpH4PuJf83JluRGN7W4i?= =?us-ascii?Q?hRCF49BCrhCx/fUGpM6dwGwNMxSW5ee2VH63csJBVSltN8AFD3KpB5ci80Py?= =?us-ascii?Q?MehTgOII0ENbhuiGNSFGB+w0T4vLQjU+Y5exMotu2b9B34p0t5PlnA/LjECO?= =?us-ascii?Q?83f+Ffw7b0k6yKC95j2pHShbjECKLAtQHsS5kuafnk+GBCe5d1I6ihvwjQ+x?= =?us-ascii?Q?ztjZ12HmygWM/Mt9c2gkj68PvXNDlHzKUMit9Y4Lcj4mWNiWfP4O/1jm0R3e?= =?us-ascii?Q?bydl5+JwmBvlvgFB/eJ49sNcRz41u5IwJ40lP8nrNapBFcrPDBfcL+4Xhd0h?= =?us-ascii?Q?5EDplLrhAHQuaPQlXH/clfHNTO69En1171KGJVf2uESJyHLbwTowxJNhgo5I?= =?us-ascii?Q?s7Syd9AUv6PMM7kXmQH0SFQ+kJ9tCLzDQ4vbNOwRNZmoCmlBABZSBUQvxjuh?= =?us-ascii?Q?4s+zKPfiTVPfZ/0S7MZshJ1ZEHu45YkdST5nA4QGQq59bjyeIN31YA3fkF6U?= =?us-ascii?Q?D/xqZr1xB66pnR4EY2QXlocQC8QGaATnVfR6w35U8d0mZlOJwUtmDV94VDSc?= =?us-ascii?Q?c5DDyXV2U+Aup3QFtkY387XZop01tDuJrl0Ta80QVGimaezvNjvVC9IjTLt0?= =?us-ascii?Q?wQeTdQ07ruJ4bKJAngmIfN/TcfC/1Qm8hz5h0FVSBpF7a53SeTbgwnr4pM9j?= =?us-ascii?Q?gLtqf8JYEh96Mm9nIBt6IM+rnEyFPKGO9y9dUI3LbM6x79Hwjf11gZEsqfmF?= =?us-ascii?Q?OYdNY1ZLAyrMqTb2p7K/fBlXztIxAvIo2Stb?= 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);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 25 Jul 2025 18:35:55.2304 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: e4c5eb72-070d-4104-d1a8-08ddcbaa175a 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: CY4PEPF0000EE3E.namprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: LV9PR12MB9806 Content-Type: text/plain; charset="utf-8" Configure mbm_event mode on AMD platforms. On AMD platforms, it is recommended to use the mbm_event mode, if supported, to prevent the hardware from resetting counters between reads. This can result in misleading values or display "Unavailable" if no counter is assigned to the event. The mbm_event 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 --- v16: Fixed a minor conflict in arch/x86/kernel/cpu/resctrl/monitor.c. v15: Minor comment update. v14: Updated the changelog to reflect the change in name of the monitor mode to mbm_event. v13 : Added the call resctrl_init_evt_configuration() to setup the event configuration during init. Resolved conflicts caused by the recent FS/ARCH code restructure. v12: Moved the resctrl_arch_mbm_cntr_assign_set_one to domain_add_cpu_mon(). Updated the commit log. v11: Commit text in imperative tone. Added few more details. Moved resctrl_arch_mbm_cntr_assign_set_one() to monitor.c. v10: Commit text in imperative tone. v9: Minor code change due to merge. Actual code did not change. v8: Renamed resctrl_arch_mbm_cntr_assign_configure to resctrl_arch_mbm_cntr_assign_set_one. Adde r->mon_capable check. Commit message update. v7: Introduced resctrl_arch_mbm_cntr_assign_configure() to configure. Moved the default settings to rdt_get_mon_l3_config(). It should be done before the hotplug handler is called. It cannot be done at rdtgroup_init(). v6: Keeping the default enablement in arch init code for now. This may need some discussion. Renamed resctrl_arch_configure_abmc to resctrl_arch_mbm_cntr_assign_co= nfigure. v5: New patch to enable ABMC by default. --- arch/x86/kernel/cpu/resctrl/core.c | 7 +++++++ arch/x86/kernel/cpu/resctrl/internal.h | 1 + arch/x86/kernel/cpu/resctrl/monitor.c | 8 ++++++++ 3 files changed, 16 insertions(+) diff --git a/arch/x86/kernel/cpu/resctrl/core.c b/arch/x86/kernel/cpu/resct= rl/core.c index 09cb5a70b1cb..bb707a762c53 100644 --- a/arch/x86/kernel/cpu/resctrl/core.c +++ b/arch/x86/kernel/cpu/resctrl/core.c @@ -520,6 +520,9 @@ static void domain_add_cpu_mon(int cpu, struct rdt_reso= urce *r) d =3D container_of(hdr, struct rdt_mon_domain, hdr); =20 cpumask_set_cpu(cpu, &d->hdr.cpu_mask); + /* Update the mbm_assign_mode state for the CPU if supported */ + if (r->mon.mbm_cntr_assignable) + resctrl_arch_mbm_cntr_assign_set_one(r); return; } =20 @@ -539,6 +542,10 @@ static void domain_add_cpu_mon(int cpu, struct rdt_res= ource *r) d->ci_id =3D ci->id; cpumask_set_cpu(cpu, &d->hdr.cpu_mask); =20 + /* Update the mbm_assign_mode state for the CPU if supported */ + if (r->mon.mbm_cntr_assignable) + resctrl_arch_mbm_cntr_assign_set_one(r); + arch_mon_domain_online(r, d); =20 if (arch_domain_mbm_alloc(r->mon.num_rmid, hw_dom)) { diff --git a/arch/x86/kernel/cpu/resctrl/internal.h b/arch/x86/kernel/cpu/r= esctrl/internal.h index ae4003d44df4..ee81c2d3f058 100644 --- a/arch/x86/kernel/cpu/resctrl/internal.h +++ b/arch/x86/kernel/cpu/resctrl/internal.h @@ -215,5 +215,6 @@ bool rdt_cpu_has(int flag); void __init intel_rdt_mbm_apply_quirk(void); =20 void rdt_domain_reconfigure_cdp(struct rdt_resource *r); +void resctrl_arch_mbm_cntr_assign_set_one(struct rdt_resource *r); =20 #endif /* _ASM_X86_RESCTRL_INTERNAL_H */ diff --git a/arch/x86/kernel/cpu/resctrl/monitor.c b/arch/x86/kernel/cpu/re= sctrl/monitor.c index 57c8409a8247..61c0ac5f0be1 100644 --- a/arch/x86/kernel/cpu/resctrl/monitor.c +++ b/arch/x86/kernel/cpu/resctrl/monitor.c @@ -455,6 +455,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; } =20 r->mon_capable =3D true; @@ -556,3 +557,10 @@ void resctrl_arch_config_cntr(struct rdt_resource *r, = struct rdt_mon_domain *d, if (am) memset(am, 0, sizeof(*am)); } + +void resctrl_arch_mbm_cntr_assign_set_one(struct rdt_resource *r) +{ + struct rdt_hw_resource *hw_res =3D resctrl_to_arch_res(r); + + resctrl_abmc_set_one_amd(&hw_res->mbm_cntr_assign_enabled); +} --=20 2.34.1 From nobody Mon Oct 6 01:21:11 2025 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 2D50724DD1E; Fri, 25 Jul 2025 18:36:11 +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=1753468573; cv=fail; b=ZH/DAUPD6Ff4tRi+vtaIfSyVGaaZ1cYhu/Uvh7Dg3IJrcohaiM8L+3rFODTqFVpaIcR3Do1x8FH+0pdwEfNSiiRONUmv64biLvg3quH0DQiC5ELCgONcKCLo3Qq2dlYe16tafCSymBIHmsrxaJinmfzgpIWZOPbtFG2Or7nCEig= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1753468573; c=relaxed/simple; bh=f5Nqjzh6EXPYMbyi99k5bDo0f0P8EKuCgP79/ATlVW0=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=HloPZeiae4s+zoLPXQirb9Cls8+dkxCRPNPvhwx9KGSlsLxYHa2MmHp3XZ9a5/PZTClLL/vGRyGCpB6W39qHFaj0ZzoiDvdfXTeIBe65D8b0wt+Trac1F0gegGkhqiRMcgiJDBOVGHrIOWmzp1ffz9z9l5W39ME1oF8Voou1P9A= 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=EG5IAiSL; 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="EG5IAiSL" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=NSzg9HWmpEMrJjOYpCrO1jzOloCs1cZ3VQOQ/ekl0DCFF9hvCEy56n8cMrjtvVThT7jqN77MviXWCwVIKrCIPz7N5Sg8DFcbZCNtEt5vonA1paSo92/A2wX2Mw8Tj4Lpm6TP7pKiQp+RmqW8Yt1xCL8OlFL4GtY28+jYUb9zLwOeUW9w6gXmuGrrzP9j7s3FHgHJ/IIjEkaXjgi/nBOnZplvMCDjhK8KYYXRlNQGI9wQKW57gnNTZGQ7tWxSsrK5h002RzxtkagiXvKUvpF8Qhk6XyxA9SDi0zwMZhDPgM3sSFPckGCvRAUCnIouhM8Zx+5gYU03DbGgVe6BkKdplQ== 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=x8SDQFOZi2WfKn5FUvR7FwSxJZ+KH2t/WcZAZNXU0mY=; b=a+honeNOzMTOnCfFXMfH30c7B2N3ts1+yqRH6tL+oukwoPql1le8yjM+/Xm3PMU1InXDG2WGHiB95kgOPf2A1sg1gm+XOneO6K5fh93gYQRJDxaSG8epJrbuikEMcYX4FSQbebkYkcm6rM/ybO+oeV7iOCEFxXpfhcKT/SmAQMpyvJb1/MLbDcxYii+tYhab03Ouw2F1EduvbIyGSsqHB6wcfo0Nw8LYM7x/Ra7SHSPErZIdyUhKD1DCZHGeHBgpJ1qUHzvhqS01IB+QXgLVY67uLr7tqMk0K63EVa/ZcoIMjrATOnHSJ6224z38z2fPAlBZ8WApeQcAN+gLjvb/8Q== 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=x8SDQFOZi2WfKn5FUvR7FwSxJZ+KH2t/WcZAZNXU0mY=; b=EG5IAiSL13bSCMl5VkQ6UnNM/Hh9mif9qRVKXq8RAv0UswWGZBJBMuTLxeYvNrf8OjQUKlviutM2UHqecKYlk6etUasaQj2wneoj9E8TIy2N2oayw4j04rNZZ/IDBSz96OAo0KCdEgK47vb1YYVAKHF1AAKwBVPzJVV12VAI00M= Received: from BYAPR11CA0107.namprd11.prod.outlook.com (2603:10b6:a03:f4::48) by DM4PR12MB5723.namprd12.prod.outlook.com (2603:10b6:8:5e::9) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8964.21; Fri, 25 Jul 2025 18:36:06 +0000 Received: from CY4PEPF0000EE3D.namprd03.prod.outlook.com (2603:10b6:a03:f4:cafe::2c) by BYAPR11CA0107.outlook.office365.com (2603:10b6:a03:f4::48) with Microsoft SMTP Server (version=TLS1_3, cipher=TLS_AES_256_GCM_SHA384) id 15.20.8964.21 via Frontend Transport; Fri, 25 Jul 2025 18:36: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 CY4PEPF0000EE3D.mail.protection.outlook.com (10.167.242.15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.8964.20 via Frontend Transport; Fri, 25 Jul 2025 18:36: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; Fri, 25 Jul 2025 13:36:01 -0500 From: Babu Moger To: , , , , , , , CC: , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , Subject: [PATCH v16 34/34] MAINTAINERS: resctrl: add myself as reviewer Date: Fri, 25 Jul 2025 13:29:53 -0500 Message-ID: <716f7dd7550b7cce8d4a3b1b29904cdf7224a090.1753467772.git.babu.moger@amd.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: References: Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-ClientProxiedBy: SATLEXMB03.amd.com (10.181.40.144) To SATLEXMB04.amd.com (10.181.40.145) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CY4PEPF0000EE3D:EE_|DM4PR12MB5723:EE_ X-MS-Office365-Filtering-Correlation-Id: 66fd6956-bec7-4387-e1a4-08ddcbaa1e01 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?4f5g/lnjpFzGhV9HVpLhyXRx0aZF/nYoEEtwDyiqrYShd14ngsyGApY5D5Nx?= =?us-ascii?Q?AHH537U+PfAoEBi94WQ9xkqbf4uldOna/TbiKiaES087DdGnmnBuu2JgpCS9?= =?us-ascii?Q?OdijyuDrK+DShx4i6nd7utyqKEXIDJot6UTGSFXhK7hlsJuVq9pX9smNz+Ls?= =?us-ascii?Q?hQCLhVZTvnz4e0oKsffOMKvODPtgg9CYjTdEwL/mJDuxq2NfSkYonZ4hWowV?= =?us-ascii?Q?ODjwA9BwkwAdBUoz70E4Stcwu8jTIbDfKIlvLLcCh5lzBgpp+Ssr6TVYtv7g?= =?us-ascii?Q?Z/6XuUA/CdvfVccjaC1hPDMmVoAqHuVYUTNrI17pyFFxbj14EpmXAaH83GKh?= =?us-ascii?Q?UuAlv3bpBzGW3TndjeNIFxy3F/fuSpymHhCXcllBH40seunFKJUHAHRjysAl?= =?us-ascii?Q?hOlWgp3x0ePp3zaDBOxg1DWbHrhX17WKnmXcCbhskv1LeF9YR4tDKFJNmerv?= =?us-ascii?Q?yiNcXewQHh6/tcMfzUlihr5hJSJpOSkg7lCupKVUbJaFquCHDW+OiaEUl6tU?= =?us-ascii?Q?uolxvo70IV6F3vM+Q529/N9Q6XrIQBnmk+SUbqPLs1rBs5sdUNHJSOMFewj1?= =?us-ascii?Q?JxY3nDvZmfVDd6mTdWhpPlvffJ8e5XrjtMuSmWr+MU7qep1kgHh4eJ6AVTMK?= =?us-ascii?Q?vLT+mfOOeaamw+Ansbi2tO6KlmTbKTy8Dq/6YsqxZhZyz8loj0KgrbKz9jd+?= =?us-ascii?Q?NzYE7te0rpgNnOK8dAAdM++cxdORCcQEp4lmaMlNRdzyZUSmEYxD/RucKEAO?= =?us-ascii?Q?4yFjI72Fo0twuZYA9suwuU+GWeCIju98eaAij2dSh5Hyu4vzeAuTRpfcxkc0?= =?us-ascii?Q?zDTXFemROxZBSM6wQzT/2OXqlALm1s55Hhb2C3zUE5CqfNedAV8xQEiA8Dd8?= =?us-ascii?Q?XW2Pk5Qwz47nehOLOtFzW7oqGRt2So2UQ5wbKqLfclYCK2CjRmLNbsP1VFQq?= =?us-ascii?Q?oaXs/guiuOK+fqkf/ZbOgsdMA2Vzmjf+axyiTQ4zsgwCkAR4j77wGNmRJiK0?= =?us-ascii?Q?Svi2KvXMnymuGLFuNMVsPgUkmAEtzop0+Ra0NprekHkIAiLjljCkpO+bNnTN?= =?us-ascii?Q?DWYtbUu8A6iAvEN8fGZ1AOIRQfxrBp4ynNubb3O20GINJCFpHKDL7eWN0vTO?= =?us-ascii?Q?tY7MyobZDsbIQ2H6V96lolymPzE25F5nf8r2dG8tTKc+jCxKr/6dfeBvmKIX?= =?us-ascii?Q?I9G4U1KOZqQFqYosJwBo0yjqfNwGVS1z0zX7W4e+lnObbUSp7vTVHxSP2zwY?= =?us-ascii?Q?UhKYmXAZ3ZhM1+fmU7/v6P9vInG8uJylTfgDPXNbdAeNf5PZU861llwfIlzc?= =?us-ascii?Q?uH1JFfQD0fZsEKrm/7hycIQxOycm77MIDUCpQTIGxDsi3bt5f0+T7uzbT5ln?= =?us-ascii?Q?EMTgbV9zgOufJcnJyRJlkh+ZPtthhb+2v0gex3+FI1mPKL6apAYp2xbuReP+?= =?us-ascii?Q?UlNSpozO41hUPFIN96/UgjyoC2TgqSRuM+1t29YJxoPq8Ym83zkJgsrkqg2o?= =?us-ascii?Q?Yh7DCxpniws31OA4SvwU6caoMfGiwtTbzrEL?= 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: 25 Jul 2025 18:36:06.3863 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 66fd6956-bec7-4387-e1a4-08ddcbaa1e01 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: CY4PEPF0000EE3D.namprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM4PR12MB5723 Content-Type: text/plain; charset="utf-8" I have been contributing to resctrl for sometime now and I would like to help with code reviews as well. Signed-off-by: Babu Moger Acked-by: Reinette Chatre --- v16: Reinette suggested to add me as a reviewer. I am glad to help as a rev= iewer. --- MAINTAINERS | 1 + 1 file changed, 1 insertion(+) diff --git a/MAINTAINERS b/MAINTAINERS index f697a0c51721..70a2f83145db 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -20866,6 +20866,7 @@ M: Tony Luck M: Reinette Chatre R: Dave Martin R: James Morse +R: Babu Moger L: linux-kernel@vger.kernel.org S: Supported F: Documentation/filesystems/resctrl.rst --=20 2.34.1