From nobody Sun Dec 14 08:06:23 2025 Received: from NAM12-MW2-obe.outbound.protection.outlook.com (mail-mw2nam12on2049.outbound.protection.outlook.com [40.107.244.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 821B928D845; Thu, 15 May 2025 22:55:47 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.244.49 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1747349749; cv=fail; b=GrlmxqYE0y2rrecLO+8ggcyM/eb1lGyvJ36RrXkqin5wVz6LKeLlJdShLM7y2kSxN31K/mWhkqKiZk+IoFrSbSE6XZ3VgNJIGt4K2d+jjCBqtW00FforXrTs+ly217q3VhV4iUbbz1R9jzlOak9VFXrOzHInL/KJZzKNViyIkyc= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1747349749; c=relaxed/simple; bh=u3Mq6F3+q0KbJzGbo6+aFa1c4uAay3aVYHq/yx7p2V4=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=IslnkSRIxiumLuuD2+4Q4hi6FMHCiOlkJJRx5SgT5ZjN8aj24JgBPOn5MkXrYurYAuNAP0uVPn1hcoFFQCtf5RM0qPLBq3cNbb/hMQDFuClBwbmax16x7BFwS4EvVHkBuzergzHpSwMUxYtlMdnHP2Jbd+Uyu34Bz6aiFYJc6oY= 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=pOcZjWIm; arc=fail smtp.client-ip=40.107.244.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="pOcZjWIm" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=gfjHwNmItByj1zx8UcuenEJU/gXLQ4GILBVzLm76XHGtYHj6Yn4gN4sYOW7B0snWS4LS0508j2/SyvndHHTzfhuRYe1kN9IZ+tUNdyGiqnIFMeSmT/5Bvlf4BgOwwGvhtcb7DnKlNXuEQz8dh3kXAJW8l4bBITqHm4wzpOB3nOZ8Gs1YO7dGHx/+C8xnAPxKzeNvU1m487I2LQNlTJvLbTXQ0599Jm3NEjz0sIIotHQFbOYeKZ/UsLYaVIOOWTstF2K5XTxmQoXiqRViQvPYudvUo1C8DW4BFv6m22F+5fBRKEZXVrIgKRDXuOI5tkijjzpOqABel6kJ7D+e3xWuew== 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=xfD3lLeta8Ng3P+KvCVlxOsYWLD+rSQbCdzWwxDrGTQ=; b=dG57gMzSP/Feef5R3G6U2tP4yUdJBrQ+CvMyDtb0wTaPQ+tD6vt3H++2QjBectbS28XL21tjJ7+k4laV5fXMOgbOhatdgwXeLFdr/Rt656BPFZg57h1+3uPZy5G6bHYeUWg3VFbb3V4Iqjez+C7jjDkBCh+5Y8pnjEDN42eujKgbk/o5UByTo8YqtXMdoUIJzpgpzaU/bSnCMecB69PxTMA6RLVgi6OJHkGvhLDa1z6e/9HK658Lo9ehHjbanFt5arSUKvs7sncZ3ybHqOp5lHNLn4u4qcHNWL2+bNzG1tD5NXRmHAu6xGB/ilFqZ24ZCeZCPOJdgs7r1OKiWOuBoQ== 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=xfD3lLeta8Ng3P+KvCVlxOsYWLD+rSQbCdzWwxDrGTQ=; b=pOcZjWImchlp+EklUUqpsMbxXpHDJMXE2alptjfJDFfRjWurnU7x52v9Vr0HtddctsX2I43vOEAZYtVRNM8SA4D+dqJh79GggUO7uk42epwB68scsTB7F33G5MeK/nfgPn90DVqUmi4KrWaiJwIxWwl1qj3eHt2hn9C1c/fCdeQ= Received: from BN9PR03CA0173.namprd03.prod.outlook.com (2603:10b6:408:f4::28) by CH3PR12MB8658.namprd12.prod.outlook.com (2603:10b6:610:175::8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8722.32; Thu, 15 May 2025 22:55:43 +0000 Received: from BN2PEPF000044A1.namprd02.prod.outlook.com (2603:10b6:408:f4:cafe::70) by BN9PR03CA0173.outlook.office365.com (2603:10b6:408:f4::28) with Microsoft SMTP Server (version=TLS1_3, cipher=TLS_AES_256_GCM_SHA384) id 15.20.8722.25 via Frontend Transport; Thu, 15 May 2025 22:55:43 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 165.204.84.17) smtp.mailfrom=amd.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=amd.com; Received-SPF: Pass (protection.outlook.com: domain of amd.com designates 165.204.84.17 as permitted sender) receiver=protection.outlook.com; client-ip=165.204.84.17; helo=SATLEXMB04.amd.com; pr=C Received: from SATLEXMB04.amd.com (165.204.84.17) by BN2PEPF000044A1.mail.protection.outlook.com (10.167.243.152) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.8722.18 via Frontend Transport; Thu, 15 May 2025 22:55:42 +0000 Received: from bmoger-ubuntu.amd.com (10.180.168.240) by SATLEXMB04.amd.com (10.181.40.145) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.39; Thu, 15 May 2025 17:55:40 -0500 From: Babu Moger To: , , , , , , CC: , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , Subject: [PATCH v13 21/27] x86/resctrl: Introduce mbm_assign_on_mkdir to configure assignments Date: Thu, 15 May 2025 17:52:06 -0500 Message-ID: X-Mailer: git-send-email 2.34.1 In-Reply-To: References: Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-ClientProxiedBy: SATLEXMB04.amd.com (10.181.40.145) To SATLEXMB04.amd.com (10.181.40.145) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: BN2PEPF000044A1:EE_|CH3PR12MB8658:EE_ X-MS-Office365-Filtering-Correlation-Id: a9349f4b-7038-4c0c-53fe-08dd94039f06 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|376014|7416014|1800799024|82310400026|36860700013|13003099007; X-Microsoft-Antispam-Message-Info: =?us-ascii?Q?KKj2zz/PhgMKIJ2JKNWV1oOPSR0p7/rpOT/HwFI/ix3DuaGyxc/7epGgYpW7?= =?us-ascii?Q?kGhAhfNUHOC+lBdDj0ntAFAe+EaLh8Gk/uRj4up8RomZZ6KrwDOSp6jB3EkZ?= =?us-ascii?Q?RqT5WxkuqWnRJy9OKddegsxmBUnMfZAd8kQxkObRuBvwerTpWwpn3P2yBEm+?= =?us-ascii?Q?lAadIBkobm3METYBfU5t6BhW2YjGa1syPg6I/0sSHc59Pk+e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D6uibU06fJiw3tVMxbnR1kOwQvaB?= =?us-ascii?Q?UUqZAwqv3Fg3VuKdSUYJ57pmsWxNvCH//MHrtTNeYerRguIsvzChdqvDWrcj?= =?us-ascii?Q?iiddWKpY/0cmtC7xZ600KH2jMsK9YHEuT4zjWp3PJonymQk3XQkXLJFac7kC?= =?us-ascii?Q?b7Jo6FM3O+NEE4BQwaJpDYa4sV2/4RKe/c4clZvfSZ59YgX+TX5IdNt4GQPS?= =?us-ascii?Q?gQMW0NyMdCDo8t5JmTilEROQpkn401brMbhwSmNfsyegKrss/WHzVl1BcuVb?= =?us-ascii?Q?AWAga3J+ejAek6OQkicdLCCCbwGCTY9T6wwBDEcgoPnzARdvCUnIbv0Oujl5?= =?us-ascii?Q?p8Y92zDIfB+VVOULYb8sZJ9QLBiAy8G7iSzAaJ1T3fJQQBxWSg1DcNNdHP9W?= =?us-ascii?Q?NNUIPn+uJzuhF/PzU+RBQff3Ymv7CvMRmo9x20NxRRsqbvtKhAQlKfBn2Q?= =?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)(1800799024)(82310400026)(36860700013)(13003099007);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 15 May 2025 22:55:42.9852 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: a9349f4b-7038-4c0c-53fe-08dd94039f06 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: BN2PEPF000044A1.namprd02.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: CH3PR12MB8658 Content-Type: text/plain; charset="utf-8" The mbm_cntr_assign mode provides an option to the user to assign a counter to an RMID, event pair and monitor the bandwidth as long as the counter is assigned. Introduce a configuration option to automatically assign counter IDs when a resctrl group is created, provided the counters are available. By default, this option is enabled at boot. Suggested-by: Peter Newman Signed-off-by: Babu Moger --- 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 | 10 ++++++ fs/resctrl/monitor.c | 2 ++ fs/resctrl/rdtgroup.c | 44 +++++++++++++++++++++++++-- include/linux/resctrl.h | 2 ++ 4 files changed, 56 insertions(+), 2 deletions(-) diff --git a/Documentation/filesystems/resctrl.rst b/Documentation/filesyst= ems/resctrl.rst index 9923276826db..356f1f918a86 100644 --- a/Documentation/filesystems/resctrl.rst +++ b/Documentation/filesystems/resctrl.rst @@ -348,6 +348,16 @@ with the following files: # cat /sys/fs/resctrl/info/L3_MON/counter_configs/mbm_total_bytes/event= _filter local_reads, local_non_temporal_writes =20 +"mbm_assign_on_mkdir": + Automatically assign the monitoring counters on resctrl group creation + if the counters are available. It is enabled by default on boot and users + can disable by writing to the interface. + :: + + # 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 1f72249a5c93..5f6c4b662f3b 100644 --- a/fs/resctrl/monitor.c +++ b/fs/resctrl/monitor.c @@ -933,6 +933,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 8c498b41be5d..0093b323d858 100644 --- a/fs/resctrl/rdtgroup.c +++ b/fs/resctrl/rdtgroup.c @@ -2035,8 +2035,8 @@ static ssize_t event_filter_write(struct kernfs_open_= file *of, char *buf, } =20 ret =3D resctrl_process_configs(buf, &evt_cfg); - if (!ret && mevt->evt_val !=3D evt_cfg) { - mevt->evt_val =3D evt_cfg; + if (!ret && mevt->evt_cfg !=3D evt_cfg) { + mevt->evt_cfg =3D evt_cfg; resctrl_update_assign(r, mevt->evtid, evt_cfg); } =20 @@ -2047,6 +2047,39 @@ static ssize_t event_filter_write(struct kernfs_open= _file *of, char *buf, return ret ?: nbytes; } =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); + + seq_printf(s, "%u\n", r->mon.mbm_assign_on_mkdir); + + 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; + + cpus_read_lock(); + mutex_lock(&rdtgroup_mutex); + rdt_last_cmd_clear(); + + r->mon.mbm_assign_on_mkdir =3D value; + + mutex_unlock(&rdtgroup_mutex); + cpus_read_unlock(); + + return ret ?: nbytes; +} + /* rdtgroup information files for one cache resource. */ static struct rftype res_common_files[] =3D { { @@ -2056,6 +2089,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 cd24d1577e0a..d6435abdde7b 100644 --- a/include/linux/resctrl.h +++ b/include/linux/resctrl.h @@ -278,6 +278,7 @@ enum resctrl_schema_fmt { * monitoring events can be configured. * @num_mbm_cntrs: Number of assignable monitoring counters * @mbm_cntr_assignable:Is system capable of supporting monitor assignment? + * @mbm_assign_on_mkdir:Auto enable monitor assignment on mkdir? * @evt_list: List of monitoring events */ struct resctrl_mon { @@ -285,6 +286,7 @@ struct resctrl_mon { unsigned int mbm_cfg_mask; int num_mbm_cntrs; bool mbm_cntr_assignable; + bool mbm_assign_on_mkdir; struct list_head evt_list; }; =20 --=20 2.34.1