From nobody Wed Sep 10 11:44:45 2025 Received: from NAM10-MW2-obe.outbound.protection.outlook.com (mail-mw2nam10on2040.outbound.protection.outlook.com [40.107.94.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 D00532F3C01; Fri, 5 Sep 2025 21:35:04 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.94.40 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1757108106; cv=fail; b=UWYnFkUVTPsmM7o0VkX16v5r66b9Zuy086eMqT/zMivjQOYHrgNVKhOCwnyFBfidkySUYReBBIINeFzmrflslsfHuAI1dDuW+MeaRltCR+slunxMTttD2ibdWi7eXY4Ku5xi8Rdrdx8bu7UgzxqNcq+RqKDWJm6bYuCmcXRTlwk= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1757108106; c=relaxed/simple; bh=7Xk8xLdxQm/HRPgwArUDZz6wyft4hK3WPgUcy+9pLK0=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=leFuGS1ZTnRhiJQxpbxsTuS8t3aoKJPrur4bvNCmpMCxzwfd4hNK5ZEcvYnPQuAEztibn7PGqTeLZSTzqHwTYdDQgHSVintUG9IWwmNFjEzzihzmh34yO3UjpBR2zYkgJS0hNygdScbLv5AXHxZZPd+4BVvHW3cI9e6pnHxMRzU= 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=fKeFKWUd; arc=fail smtp.client-ip=40.107.94.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="fKeFKWUd" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=JpSKIYtn8+7BxWs7ZJDjQFu2n+FSxIYpBR3KhxJHyjn2lCMpUiLeSA8fNjwv6Z5rlV0aRGeP+ztiOy4mozihZyHS4BBLzVhuADyDu/8+0fseB3fxsoq78vKi7QyuScrx2KPeeD7MXpo1/mCbLjFTHmmk82QQumrKlYXLBfCgmyA3D48AnXonlwMgQQKiWHiciyar+bwzJNmTCTNReLVNcmogr7oaqrbdmjv21ASi3DDN+cJ+cXdObOLbVnPLNjTmcGrgZqmHTTB3oMJYIfRpMKePFCpQ0DPiUvySkTawoCHyFKH1S23GM31uzPWsPEHseq3Qo0/5dzYGHvG2LjyUCA== 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=4sjXprsrNHtuOGkFqqgqeqObmmP2E4yuAZqoY1egrNQ=; b=Qj8quYYLpo8Q3AVMd7Tpwg7f2MCTO4nEillgbJ7DeF/HqARsqo0r+6c07t/AZR5/kj4urs1aN8f4J0qeoAD6lgevvxbkX3DZu27pbYTuLd02Efu0M2RVXaOdK+82Rwchlc79IaqjxhsKDdgX4Kmf8lu/Y+avwUOmpZ37SNrIUx89D8AZB9hWdwBt+Hgr+6EH2FnOE/5AUbTX1aGjMiq1xHLl5ncG1HBLIHYxEXfAkmbvYOC0P7YXj0UsBtBtG6OcOBi/5yXL2zPn4Uq1Xg3FjElN3b/c0co/j2q9Q5uHwOvU0WSLKxYcyXqIPR6Dc1Dvu2YsnbUcdKPiXUuQbLcKAA== 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=4sjXprsrNHtuOGkFqqgqeqObmmP2E4yuAZqoY1egrNQ=; b=fKeFKWUdWryxYRjfYM2Hk55WTdneXMuI7DnI8bNsuSlpoxv5KxQvTX1acXxXbbEMX1GPdig9s3B4LHgeXaZi5b8X5w+DGXsvyjV4ky7da1UbLskxrroftzyuLxhY4BJCTk2VVxWvakEJwN+95kA1omQ4QSUPPuCl63+okZk/wrE= Received: from MW4PR03CA0107.namprd03.prod.outlook.com (2603:10b6:303:b7::22) by IA0PR12MB8693.namprd12.prod.outlook.com (2603:10b6:208:48e::10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.9094.19; Fri, 5 Sep 2025 21:34:58 +0000 Received: from SJ5PEPF000001F4.namprd05.prod.outlook.com (2603:10b6:303:b7:cafe::b0) by MW4PR03CA0107.outlook.office365.com (2603:10b6:303:b7::22) with Microsoft SMTP Server (version=TLS1_3, cipher=TLS_AES_256_GCM_SHA384) id 15.20.9094.17 via Frontend Transport; Fri, 5 Sep 2025 21:34:57 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 165.204.84.17) smtp.mailfrom=amd.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=amd.com; Received-SPF: Pass (protection.outlook.com: domain of amd.com designates 165.204.84.17 as permitted sender) receiver=protection.outlook.com; client-ip=165.204.84.17; helo=SATLEXMB04.amd.com; pr=C Received: from SATLEXMB04.amd.com (165.204.84.17) by SJ5PEPF000001F4.mail.protection.outlook.com (10.167.242.72) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.9094.14 via Frontend Transport; Fri, 5 Sep 2025 21:34:57 +0000 Received: from satlexmb07.amd.com (10.181.42.216) 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, 5 Sep 2025 16:34:55 -0500 Received: from bmoger-ubuntu.amd.com (10.180.168.240) by satlexmb07.amd.com (10.181.42.216) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.2.1748.10; Fri, 5 Sep 2025 14:34:53 -0700 From: Babu Moger To: , , , , , , , , CC: , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , Subject: [PATCH v18 01/33] x86,fs/resctrl: Consolidate monitor event descriptions Date: Fri, 5 Sep 2025 16:34:00 -0500 Message-ID: <633fa2733eeeb3017db567fac3466fb64530bc47.1757108044.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 satlexmb07.amd.com (10.181.42.216) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: SJ5PEPF000001F4:EE_|IA0PR12MB8693:EE_ X-MS-Office365-Filtering-Correlation-Id: 9d55a136-263a-4606-00ca-08ddecc40fc3 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|36860700013|1800799024|7416014|376014|82310400026|13003099007; X-Microsoft-Antispam-Message-Info: =?us-ascii?Q?GSEgW66yTS91z9CkHKPF23FAmzqH/rxKLTOSfc0523po1/w0tr0gf+N5R9UX?= =?us-ascii?Q?+EFw1P4OwHV6O3U9rOrQ7egxf07I+5R4/EN2im0WsaGcmicJYzEMFHErJksx?= =?us-ascii?Q?k3KaxdFDO7n2IdvGwSsiKmFaIoVzWCV0KavMd8Eqd7Mx/szv0RzEpWGTIKJ5?= =?us-ascii?Q?cF+B8OqNhsE/+LzEfqmF+gEaP9ZUkdpE2frB76g/VaFAxqGqMTNLmac6SpWq?= =?us-ascii?Q?cr/F+PRVZGZMK9iHuhsZqxL1wDnAOGJTuuqWaFQS+ZRSJvmd/+bcsHcHBNqG?= =?us-ascii?Q?/B7HrjN7BhSz6J0AfFUiqh9L1Klivel2i8q2UmjHsYVTEi9Hd7gFaUrM1BLU?= =?us-ascii?Q?c9Ny7jpFKGNBLz5ClTz2/PD2F7sv7ZKxZj7e8/eWSGrfaH8jzA7kEqkscWvY?= =?us-ascii?Q?I2W4+1HKKz+7Rj1gazIbiKKF5QnbPWcn01x9hENvcDihDJmzHQsCXvxWizVJ?= =?us-ascii?Q?Uz4wG088yg6xfUqYHGeItwaAXMCdxxyxq3OTZncrdXDMwRHgQ9WjCN5/Xcxr?= =?us-ascii?Q?JQF8J/1JNai+R9+lPjzRxlw6zY6aEnAV3W+3vIlmLlPGWV++NLk9qqyYVGlk?= =?us-ascii?Q?4QvRMsMGexWevQ8qEtvjeopMLskPV+9OTj6YEgnxQvfSSHkVEsozttY8E6IS?= =?us-ascii?Q?GwBrOHSmritjb84tPF3i+uhdLpgF6ub5ujdzusAp9lDp74oAP0mps7Tstl6B?= =?us-ascii?Q?FCuxQUv2MzvO358OaFEYZZCsFk6JFeZcTYUHZzQqhCFxvGMzeZ/8IztEdX4Y?= =?us-ascii?Q?Ay6S6LERxsXXAA7F1+UJ92VgxUcvrE4K2galEIDlK7lqhz99J6cx1ixDVZe/?= =?us-ascii?Q?iq9H7StWitM4hJETnOIklmayAeqY1ZguLZgyw4e0RQB3IPa8qVvX48nHrIal?= =?us-ascii?Q?3S56KcPqH2mFceMsf9TdtQsUT1bNYMZAvJBrc592cnrh5LFtijLazTpRLyfl?= =?us-ascii?Q?bozeG2fYZ3b6I1z/Fky1tsD/5nsmE3kMkr3hTFKRRMnRzuYqjd8PWlbyBwRi?= =?us-ascii?Q?cwev90MQV8vwweHJzZ0MuMLHgTtz44ZU4IvP5XV5y98n9WCOfDNx+gtipbAw?= =?us-ascii?Q?0FIWW9cefVUGMGzaFYoBDRU9znkPlV4TJyFBT+UYxAKRG+3R7xYSju7C641U?= =?us-ascii?Q?1cNUdTCBL5Cwsx/TyUmkcFncTt1VRMXQql4ETmvKNoepzAEF8x0W8vJZNTLL?= =?us-ascii?Q?SYsdF/VRfroaiawCIrzylvL4VmrCv5Yez5hIcVYnGUW4aHYxFmOHvBH+Qx2p?= =?us-ascii?Q?tKpuxURSyU2BfvcREQe/YLhEjjBxKw+0RBgDx+rPPFBlIrfOgzlu/HW/ZFy/?= =?us-ascii?Q?zdQbWwmiss43Zeo3SoiuDdULN3cooslkfY6ynjpff8xgvMAPQl4YcYIF67vU?= =?us-ascii?Q?UqwXApZEq1/RRPGK1aw9nUU90TQTULGR1N2wxs0ODwE70iV9hOCWSUn8udI5?= =?us-ascii?Q?S8QSAV3hCadz12a93UXXs5/SXCv7IoL3NFuB0BPbjjoiL9BJbxKKndPvsD2U?= =?us-ascii?Q?PSJ9mHxjTrNDXUrA0aEk1grRfpmauwRNEuXKwBgeBbhsW7WUPY2ZiGgJlQ?= =?us-ascii?Q?=3D=3D?= X-Forefront-Antispam-Report: CIP:165.204.84.17;CTRY:US;LANG:en;SCL:1;SRV:;IPV:CAL;SFV:NSPM;H:SATLEXMB04.amd.com;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(13230040)(36860700013)(1800799024)(7416014)(376014)(82310400026)(13003099007);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 05 Sep 2025 21:34:57.7292 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 9d55a136-263a-4606-00ca-08ddecc40fc3 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: SJ5PEPF000001F4.namprd05.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: IA0PR12MB8693 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 Signed-off-by: Babu Moger Reviewed-by: Fenghua Yu Reviewed-by: Reinette Chatre --- v18: No changes. v17: Added Signed-off-by tag. 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 5f0b7cfa1cc2..ab943a5907c5 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); @@ -3054,10 +3056,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