From nobody Mon Dec 1 23:02:28 2025 Received: from CWXP265CU009.outbound.protection.outlook.com (mail-ukwestazon11021077.outbound.protection.outlook.com [52.101.100.77]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 89BA127815E for ; Wed, 26 Nov 2025 17:17:10 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=52.101.100.77 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1764177432; cv=fail; b=uoE0rvlbfq9cD2F+iOIXBBiXm8QaFVe6zCyEkyHlJ+YPCoHm1rmHP/79yqtoIQPoGq5D8uIO/d7CfPksGk+PSIue/8JwoW6jm7wENlOY35yrr1x0AqqB+y5MVqEMdxQXzjSNJ3xeoy1R4C/6xhDIax32Nv9hBvgd8014EBV+HFg= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1764177432; c=relaxed/simple; bh=RKSuCCsFSAfKNfuJ9ek8HYfZbAZLWLiLabGr77nn3sE=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: Content-Type:MIME-Version; b=PeQk6aGRjFqLvfzpXR1u3agLK0zqOUQ9GsSwEI8VeV7UZTBb0k5Xr3GjrK1LlfmfOtJwabgpJ2SeVZHXo3OAYVOq7/yuVZyzLQq9kTHxjuKX1F+jlA/bz3t0BDdp9mFgijZOsW5qvUSgcxIyGIc1Rrtyh4lg9N7+bwMRtaCo/M8= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=atomlin.com; spf=pass smtp.mailfrom=atomlin.com; arc=fail smtp.client-ip=52.101.100.77 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=atomlin.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=atomlin.com ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=hKIu+uUZUxzOzIVfhJbzCazU3n6haAtHg/zq9t/HCaw7dXL2UNqZ/HRQPKfGhNdTpu06bFUszSbwn/oV2l98dtzLGY/PowClwEJtPxw2Od6N2t/b4FkfLy3dZ2vMviETFJ68Y/cA+9spxvpsFxh362fkT5z4/JtuzKLsaVPLol/J9JCZ+373vrQxpjhbHHLvz0LpycDIaBi7a6hKLcEAzpTcGXnwpFiVhPQlGBJwlb9dPHMxX3SE1X8xdy+jrfW8rKftpCIzpaiX5jr7Kpi+ZEvwuiY6UDSfM+v+yaUXBkPI4T6WN63/bb9a2JXm213ttn/dJssP0ArfI0MjxwNeHw== 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=90zHLNZi69qgzyPnAiAOJv5tQn7afZeTOdK1FTG6sL4=; b=mG+YxpCaJxr0r9eQ1aeOY26upVU2KnLrDSRselHMJq4BYFmh76YM/1WIwshRZa09MAXmJcTOStOTTV/BJuaawRncJv0Wq9cx1i0nbsY8U/JHEQ3zGtqFxR5kZDbQrchQhWkt180CAuOcgYmucnXVEsOEvp+0YeGL//VeQStID2+kp9ip5tYwye0vPaLe66wbcwG40JWUSEIDcgqfB1AF2q8sO/Si9URciD/yKR/pwx2ty3LhnF1oQMWKjuZ4G/G1dVyA+mB2gyIL6gINQKf0SVe8xRap2C2bYF0K/ZzVanq33n0QoLQTTXzMHp0J9snd9d8aMhXtKOfT8a9JL4QNRg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=atomlin.com; dmarc=pass action=none header.from=atomlin.com; dkim=pass header.d=atomlin.com; arc=none Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=atomlin.com; Received: from CWLP123MB3523.GBRP123.PROD.OUTLOOK.COM (2603:10a6:400:70::10) by CWLP123MB6960.GBRP123.PROD.OUTLOOK.COM (2603:10a6:400:1e0::11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.9366.13; Wed, 26 Nov 2025 17:17:07 +0000 Received: from CWLP123MB3523.GBRP123.PROD.OUTLOOK.COM ([fe80::de8e:2e4f:6c6:f3bf]) by CWLP123MB3523.GBRP123.PROD.OUTLOOK.COM ([fe80::de8e:2e4f:6c6:f3bf%5]) with mapi id 15.20.9366.009; Wed, 26 Nov 2025 17:17:07 +0000 From: Aaron Tomlin To: tony.luck@intel.com, reinette.chatre@intel.com, Dave.Martin@arm.com, james.morse@arm.com, babu.moger@amd.com, tglx@linutronix.de, mingo@redhat.com, bp@alien8.de, dave.hansen@linux.intel.com Cc: dave.martin@arm.com, atomlin@atomlin.com, sean@ashe.io, linux-kernel@vger.kernel.org Subject: [PATCH 3/3] x86/resctrl: Add "*" shorthand to set minimum io_alloc CBM for all domains Date: Wed, 26 Nov 2025 12:16:52 -0500 Message-ID: <20251126171653.1004321-4-atomlin@atomlin.com> X-Mailer: git-send-email 2.51.0 In-Reply-To: <20251126171653.1004321-1-atomlin@atomlin.com> References: <20251126171653.1004321-1-atomlin@atomlin.com> Content-Transfer-Encoding: quoted-printable X-ClientProxiedBy: BLAPR03CA0022.namprd03.prod.outlook.com (2603:10b6:208:32b::27) To CWLP123MB3523.GBRP123.PROD.OUTLOOK.COM (2603:10a6:400:70::10) Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CWLP123MB3523:EE_|CWLP123MB6960:EE_ X-MS-Office365-Filtering-Correlation-Id: fee17615-4723-4724-9f8e-08de2d0fa0b0 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|376014|7416014|1800799024|366016; X-Microsoft-Antispam-Message-Info: =?us-ascii?Q?js7qvbpPHz3jJBJT1oFT/9vv5LqFhpPya81JF6glwlSQu613elsitz41SJ/3?= =?us-ascii?Q?duvaXdj9hb30soILkudY977crb1wxKaTZd/NkfIk+UobltMQ7/pMhzQ9b27o?= =?us-ascii?Q?VRn13b8kerV9KGxPK0FceDOIj/uzGEsPreOSVVLR4ikl9nvnDQIYDcafoWN5?= =?us-ascii?Q?K4uLAxuznscCFncotP+KNgQli3kltwLIgY01fbpfnF3Q/SeLwsKqILSje5i5?= =?us-ascii?Q?+T5xK7CAfNy16bXlKKMK6LQ1gJnWMJPmrH4SzGr23dZxh2AtJipVzYH7Xnc8?= =?us-ascii?Q?C28NI66Q0URJTyb6XfjSPecRNXZjkhNLQmny2NSb6qNA8QqVuY0s53l6sQn8?= =?us-ascii?Q?DU2nPnO1oMhmrEgNjL0ilnG8EQI0iD5HHmiDLmxImuDycW7lfeTZWW497eci?= =?us-ascii?Q?kFLyP65ki7Q5pJJRhMv0g3Er/MEPP5TEALzWWuLykhOp82x9gi3E44HypoLI?= =?us-ascii?Q?R+KgJYuEiVzbIXI5xzc/S6hn8nJx/z4FZ95vMiVtjS8SCvEKnOChQc2K3cLM?= =?us-ascii?Q?WsYTqqDEFqLpHlelwqJe+A7JHlyGOEoc6+UQGCvuQWqWfCKNDYHpSobhmfur?= =?us-ascii?Q?xMvhiT5WCJbJSezDbVoxC11Z3C6kcFMn0uTTPc+NsOYVzqW31PbdVIbsCpn2?= =?us-ascii?Q?ZRzz7I5Mv8XnBUgaE+ealK0ag35PdbYJb1KEe9j442ISM3J0cBDVl1nv+6lD?= =?us-ascii?Q?96+ICpnK6xbFeiC/BeDMZGRyhoLuy9eIy25HT/81yRUNFUYqhloy963d0ZfL?= =?us-ascii?Q?W0726r2txt6zknz991IdsWruer32Gug5ZwDWZao8WjMSBfgRqrlg5JSNO+mf?= =?us-ascii?Q?SORXyNX34xGB4ShGf/o6B9Uy9u1dTg5iNSbmMfjHUm3wtHHoe43YPC0rblJx?= =?us-ascii?Q?RRY1LY0n2dnfAK4fMj7XKmsRjCzNKL0toulj99qFEx0I2LNblLp614aLjV2o?= =?us-ascii?Q?MBMOmidhqW8sI6c49vNhdFtKepnVY8MrlguJGAPwfLvPKWBhSzgEkwLrJLmm?= =?us-ascii?Q?h+3wnbDJrn1JFlJUCEVBfEdafTaToP79sfukHxNqSUEu4OwYCfry3Sm14uLf?= =?us-ascii?Q?SGNjdrBt2j8Bo9wG7azj3Kr9qpLB5yJdkZHc2B8OkwkIyHawPCWA4dXv8vST?= =?us-ascii?Q?wIF6TXbsmdZ2+rRWMLXaJwltjTbr6Y9rAbJzCNb84AB+i1zVZEM8/HU24ZIi?= =?us-ascii?Q?Lk5z0ffwAUkBqLJXGIrk2EXdsY34+iVsYoUByJWwfIckQvC0K+HXu+rLPdGQ?= =?us-ascii?Q?2EwmGl3ArQK3k5++ndQojEZ06rDRwQ18AepAemXqz70vetwJkP8WCk/kuCtY?= =?us-ascii?Q?6flCmFG81Ei9dG4+1lc9+ntxgmQ3q8OQUdrAB972zQqUiwVLXM7HpC06B/z1?= =?us-ascii?Q?u0tPjugBT4EhQ6jPpc2r32hw3YZ0wXRzol8CHi3nQ6HNSAAAIJCSj44sOa+D?= =?us-ascii?Q?JWS8fraAEfJ8WQYFtNXzWV/crPcEgu+O?= X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:CWLP123MB3523.GBRP123.PROD.OUTLOOK.COM;PTR:;CAT:NONE;SFS:(13230040)(376014)(7416014)(1800799024)(366016);DIR:OUT;SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?us-ascii?Q?pVEmUqZRSmZxPHhfU1muAC8m1mSlFvtoZQnTyfBGH5l/nbjQXLwVleBwXU27?= =?us-ascii?Q?IVAb7vTdyhY+Jq8S2c/UMKUJ5FHWNgv91FTfeaPrXteUgM3EzDGFBWxeHWgd?= =?us-ascii?Q?kqp0Onw82Lo8Dhv32vZFQDtNXvilPyVnvHxjz0lSmnOXqpKu7N6/eWf05fqx?= =?us-ascii?Q?qDknu49XcfAtawFj3CNnir/Lgin8ke82he7X5cDMIetYaSIdDKSwR5FiDzWj?= =?us-ascii?Q?TJU6AiZddwfYYBYqkjGYpK+8z6GXbK033TM5qvLTyHnUk+L/f49/RcnzGABl?= =?us-ascii?Q?r9ctHWOQQjlJ05mmHEi06EFjMol7C2JHnoc8x2XVO39eA1QZeCuq+cAYGMZX?= =?us-ascii?Q?9RAGviPfVjY0wx7ADjxStKztk5screIp/hfnKARKhZ5qrQLTjcZx7zXL6JUl?= =?us-ascii?Q?3W+0nz9abWhbO7zmGuzULdtnjgrVBttlFtDdYEbbF/vLpdh1Mc4bWD24U5iX?= =?us-ascii?Q?WzwSaLr2J7/MXQHxdq9RJSXWp1mIag+f5fhzUEIP8rHCYxy6WsNwxL6S8LUg?= =?us-ascii?Q?kcEOPgAslasvSBbuelX9rxeW1rNaOZBPbcTWvPmTTA2o7QN1JycEndrnCdho?= =?us-ascii?Q?pIboFLhQRf2AyExILGaK97YkGliyyCBimV/egem4FezfupEjyEqoQrlQADgC?= =?us-ascii?Q?t5D0RJI0/oMHofcWCOz/r7Na/xnNivOhabDLj/vWfzr2U4w8aAZQfi89mCLh?= =?us-ascii?Q?Y6FM0Tqx1kfuD0gcYUPCVpW5+1zS5AYna9cEuGDgj4omskCPIG071sWG8YCn?= =?us-ascii?Q?+UvUG4xDvwwO4BXj4M6AGFgarcxxaOTqJsTAs+pzzbwKtD1x/i5X5AI/8cKt?= =?us-ascii?Q?I/huLFXh/b4qBhr2UeTgjpSLIZLqf9H3MXV6hP2fyuj29ESmzzwo6b+WdL85?= =?us-ascii?Q?mljQSbM57vD2QzDmYDrHKYahIQaikLiIzmF63n4sDTgLhjqtzZz0cSfICzsf?= =?us-ascii?Q?JiHdhAm6xbIZTmlrk1OGbF03O1xmZkDmkHZzf6b81ATLR2hkdqxPN+p7cpCr?= =?us-ascii?Q?dsNIMG0Lm3mKi6lonKzhTIzu0svJfl+Si6ltBt2Q1lY5R10MMwc1z2mSDlE5?= =?us-ascii?Q?TpPPWv5OvOsm935lNa/rUj8hJDHlJmHob3wHA1aDxgVIZn7XrGeJtT0SByuA?= =?us-ascii?Q?YqV9JBwxl/SLVmP/D6zpWkJhrDyYTxRarq7bFyYCrGvV2SWtyopar8G+iO9d?= =?us-ascii?Q?ovSlPOuTXwGa4zuVvQvPaC4FWiwH8BI870C4KVDbQpkZoe5xDYtAKBSdDItY?= =?us-ascii?Q?Pgw4mmI6dKMVft30V5CeNzeh1kckxA5R2Lz2i3ORhOTdTa/HM3yn9o6SXC28?= =?us-ascii?Q?+F9ogUri4j2e5GbRTVDDOhhE8AvueCeGI1Bi/0MVBlpLmw6ZxlpUYKs3fOZl?= =?us-ascii?Q?4DoFh4TDDyoSxBQhwg/JJX2/dOKrcKqwhU9Zz6P0cFQbwJDTJ/+e98yRgJOP?= =?us-ascii?Q?u2bATy+cxSQnhBwQkWH8h8nLkDIXy00L2mCbLFVcpJyQyIJ3I7Bj57AVjfcd?= =?us-ascii?Q?71jg7LU+HQAitbJ4U8K8ZfFM4gcpclbQxrQLyJHpxoh6rdyt2IAO7fETiJPY?= =?us-ascii?Q?nAJX1z2wfhXw3eccao02Ir6SwaPxLwP+oU3NJC88?= X-OriginatorOrg: atomlin.com X-MS-Exchange-CrossTenant-Network-Message-Id: fee17615-4723-4724-9f8e-08de2d0fa0b0 X-MS-Exchange-CrossTenant-AuthSource: CWLP123MB3523.GBRP123.PROD.OUTLOOK.COM X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 26 Nov 2025 17:17:07.7965 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: e6a32402-7d7b-4830-9a2b-76945bbbcb57 X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: bvVYS0P5Yp/v1sV0rdhp+AyJfiYMiBU5pQjdbLFD7LbM0Gecbj/PVE+squOMR8O76TcT1b00+qhErJwLpTnmTQ== X-MS-Exchange-Transport-CrossTenantHeadersStamped: CWLP123MB6960 Content-Type: text/plain; charset="utf-8" This patch introduces a special domain ID selector "*" for io_alloc_cbm that allows setting the CBM of each cache domain to its minimum number of consecutive bits in a single operation. For example, writing "*=3D0" to /sys/fs/resctrl/info/L3/io_alloc_cbm programs each domain's CBM to the hardware-defined minimum, greatly simplifying automation and management tasks. The user is required to specify the correct minimum stored in /sys/fs/resctrl/info/L3/min_cbm_bits. Signed-off-by: Aaron Tomlin --- Documentation/filesystems/resctrl.rst | 10 ++ arch/x86/kernel/cpu/resctrl/core.c | 2 +- arch/x86/kernel/cpu/resctrl/ctrlmondata.c | 23 +++-- fs/resctrl/ctrlmondata.c | 108 +++++++++++++++++----- fs/resctrl/internal.h | 13 +++ fs/resctrl/rdtgroup.c | 2 +- include/linux/resctrl.h | 30 +++++- 7 files changed, 155 insertions(+), 33 deletions(-) diff --git a/Documentation/filesystems/resctrl.rst b/Documentation/filesyst= ems/resctrl.rst index 8c8ce678148a..9c128c8fba86 100644 --- a/Documentation/filesystems/resctrl.rst +++ b/Documentation/filesystems/resctrl.rst @@ -215,6 +215,16 @@ related to allocation: # cat /sys/fs/resctrl/info/L3/io_alloc_cbm 0=3D00ff;1=3D000f =20 + Set each CBM to their minimum number of consecutive bits. + + A special value "*" is required to represent all cache IDs. + The user should specify the correct minimum stored in + /sys/fs/resctrl/info/L3/min_cbm_bits. + + Example:: + + # echo "*=3D0" > /sys/fs/resctrl/info/L3/io_alloc_cbm + When CDP is enabled "io_alloc_cbm" associated with the CDP_DATA and CDP_= CODE resources may reflect the same values. For example, values read from and written to /sys/fs/resctrl/info/L3DATA/io_alloc_cbm may be reflected by diff --git a/arch/x86/kernel/cpu/resctrl/core.c b/arch/x86/kernel/cpu/resct= rl/core.c index 3792ab4819dc..44aea6b534e0 100644 --- a/arch/x86/kernel/cpu/resctrl/core.c +++ b/arch/x86/kernel/cpu/resctrl/core.c @@ -276,7 +276,7 @@ static void rdt_get_cdp_config(int level) =20 static void rdt_set_io_alloc_capable(struct rdt_resource *r) { - r->cache.io_alloc_capable =3D true; + r->cache.io_alloc.io_alloc_capable =3D true; } =20 static void rdt_get_cdp_l3_config(void) diff --git a/arch/x86/kernel/cpu/resctrl/ctrlmondata.c b/arch/x86/kernel/cp= u/resctrl/ctrlmondata.c index b20e705606b8..0f051d848422 100644 --- a/arch/x86/kernel/cpu/resctrl/ctrlmondata.c +++ b/arch/x86/kernel/cpu/resctrl/ctrlmondata.c @@ -57,14 +57,19 @@ int resctrl_arch_update_domains(struct rdt_resource *r,= u32 closid) hw_dom =3D resctrl_to_arch_ctrl_dom(d); msr_param.res =3D NULL; for (t =3D 0; t < CDP_NUM_TYPES; t++) { - cfg =3D &hw_dom->d_resctrl.staged_config[t]; - if (!cfg->have_new_ctrl) - continue; - - idx =3D resctrl_get_config_index(closid, t); - if (cfg->new_ctrl =3D=3D hw_dom->ctrl_val[idx]) - continue; - hw_dom->ctrl_val[idx] =3D cfg->new_ctrl; + if (resctrl_should_io_alloc_min_cbm(r)) { + idx =3D resctrl_get_config_index(closid, t); + hw_dom->ctrl_val[idx] =3D apply_io_alloc_min_cbm(r); + } else { + cfg =3D &hw_dom->d_resctrl.staged_config[t]; + if (!cfg->have_new_ctrl) + continue; + + idx =3D resctrl_get_config_index(closid, t); + if (cfg->new_ctrl =3D=3D hw_dom->ctrl_val[idx]) + continue; + hw_dom->ctrl_val[idx] =3D cfg->new_ctrl; + } =20 if (!msr_param.res) { msr_param.low =3D idx; @@ -123,7 +128,7 @@ int resctrl_arch_io_alloc_enable(struct rdt_resource *r= , bool enable) { struct rdt_hw_resource *hw_res =3D resctrl_to_arch_res(r); =20 - if (hw_res->r_resctrl.cache.io_alloc_capable && + if (hw_res->r_resctrl.cache.io_alloc.io_alloc_capable && hw_res->sdciae_enabled !=3D enable) { _resctrl_sdciae_enable(r, enable); hw_res->sdciae_enabled =3D enable; diff --git a/fs/resctrl/ctrlmondata.c b/fs/resctrl/ctrlmondata.c index 5f6f96d70e4a..b3abd781899f 100644 --- a/fs/resctrl/ctrlmondata.c +++ b/fs/resctrl/ctrlmondata.c @@ -688,7 +688,7 @@ int resctrl_io_alloc_show(struct kernfs_open_file *of, = struct seq_file *seq, voi =20 mutex_lock(&rdtgroup_mutex); =20 - if (r->cache.io_alloc_capable) { + if (r->cache.io_alloc.io_alloc_capable) { if (resctrl_arch_get_io_alloc_enabled(r)) seq_puts(seq, "enabled\n"); else @@ -712,13 +712,31 @@ static bool resctrl_io_alloc_closid_supported(u32 io_= alloc_closid) return io_alloc_closid < closids_supported(); } =20 +/** + * resctrl_sync_cdp_peer - Mirror staged configuration to the CDP peer type + * + * @s: resctrl schema + * @d: resctrl control domain + * + * The caller must ensure CDP is enabled for the resource and must be + * called under the cpu hotplug lock and rdtgroup mutex + */ +static void resctrl_sync_cdp_peer(struct resctrl_schema *s, struct rdt_ctr= l_domain *d) +{ + enum resctrl_conf_type peer_type; + + peer_type =3D resctrl_peer_type(s->conf_type); + memcpy(&d->staged_config[peer_type], + &d->staged_config[s->conf_type], + sizeof(d->staged_config[0])); +} + /* * Initialize io_alloc CLOSID cache resource CBM with all usable (shared * and unused) cache portions. */ static int resctrl_io_alloc_init_cbm(struct resctrl_schema *s, u32 closid) { - enum resctrl_conf_type peer_type; struct rdt_resource *r =3D s->res; struct rdt_ctrl_domain *d; int ret; @@ -731,11 +749,8 @@ static int resctrl_io_alloc_init_cbm(struct resctrl_sc= hema *s, u32 closid) =20 /* Keep CDP_CODE and CDP_DATA of io_alloc CLOSID's CBM in sync. */ if (resctrl_arch_get_cdp_enabled(r->rid)) { - peer_type =3D resctrl_peer_type(s->conf_type); list_for_each_entry(d, &s->res->ctrl_domains, hdr.list) - memcpy(&d->staged_config[peer_type], - &d->staged_config[s->conf_type], - sizeof(d->staged_config[0])); + resctrl_sync_cdp_peer(s, d); } =20 ret =3D resctrl_arch_update_domains(r, closid); @@ -903,29 +918,82 @@ int resctrl_io_alloc_cbm_show(struct kernfs_open_file= *of, struct seq_file *seq, return ret; } =20 +/** + * parse_domain_cbm - Parse "domain=3Dcbm" and return either side + * + * @line_ptr: Pointer to the input string + * @out_val: Output from parsed value (either domain ID or CDM) + * @which: Selector for which side to parse + * + * It is assumed that *line_ptr and *out_val are valid. + * + * Return: 0 on success and advance *line_ptr to point past the + * delimiter, EINVAL on parsing error + */ +static int parse_domain_cbm(char **line_ptr, unsigned long *out_val, + enum resctrl_kv_sel which) +{ + char *rhs, *lhs, *tok; + unsigned int base; + + rhs =3D *line_ptr; + + lhs =3D strsep(&rhs, "=3D"); + if (!lhs || !rhs) + goto err; + + if (which =3D=3D RDT_PARSE_DOMAIN) { + tok =3D lhs; + base =3D 10; + } else { + tok =3D rhs; + base =3D 16; + } + tok =3D strim(tok); + + if (kstrtoul(tok, base, out_val)) + goto err; + + *line_ptr =3D rhs; + return 0; +err: + rdt_last_cmd_puts("Invalid domain=3Dcbm: missing '=3D' or non-numeric val= ue\n"); + return -EINVAL; +} + static int resctrl_io_alloc_parse_line(char *line, struct rdt_resource *r, struct resctrl_schema *s, u32 closid) { - enum resctrl_conf_type peer_type; struct rdt_parse_data data; struct rdt_ctrl_domain *d; - char *dom =3D NULL, *id; - unsigned long dom_id; + char *dom =3D NULL; + unsigned long out_val; + int ret; + + if (line[0] =3D=3D '*') { + ret =3D parse_domain_cbm(&line, &out_val, RDT_PARSE_CBM); + if (ret) + return ret; =20 + if (out_val =3D=3D r->cache.min_cbm_bits) { + r->cache.io_alloc.io_alloc_min_cbm =3D true; + return 0; + } + rdt_last_cmd_puts("Invalid io_alloc min CBM\n"); + return -EINVAL; + } next: if (!line || line[0] =3D=3D '\0') return 0; =20 dom =3D strsep(&line, ";"); - id =3D strsep(&dom, "=3D"); - if (!dom || kstrtoul(id, 10, &dom_id)) { - rdt_last_cmd_puts("Missing '=3D' or non-numeric domain\n"); - return -EINVAL; - } + ret =3D parse_domain_cbm(&line, &out_val, RDT_PARSE_DOMAIN); + if (ret) + return ret; =20 dom =3D strim(dom); list_for_each_entry(d, &r->ctrl_domains, hdr.list) { - if (d->hdr.id =3D=3D dom_id) { + if (d->hdr.id =3D=3D out_val) { data.buf =3D dom; data.mode =3D RDT_MODE_SHAREABLE; data.closid =3D closid; @@ -935,12 +1003,8 @@ static int resctrl_io_alloc_parse_line(char *line, s= truct rdt_resource *r, * Keep io_alloc CLOSID's CBM of CDP_CODE and CDP_DATA * in sync. */ - if (resctrl_arch_get_cdp_enabled(r->rid)) { - peer_type =3D resctrl_peer_type(s->conf_type); - memcpy(&d->staged_config[peer_type], - &d->staged_config[s->conf_type], - sizeof(d->staged_config[0])); - } + if (resctrl_arch_get_cdp_enabled(r->rid)) + resctrl_sync_cdp_peer(s, d); goto next; } } @@ -982,6 +1046,8 @@ ssize_t resctrl_io_alloc_cbm_write(struct kernfs_open_= file *of, char *buf, goto out_clear_configs; =20 ret =3D resctrl_arch_update_domains(r, io_alloc_closid); + if (resctrl_should_io_alloc_min_cbm(r)) + r->cache.io_alloc.io_alloc_min_cbm =3D false; =20 out_clear_configs: rdt_staged_configs_clear(); diff --git a/fs/resctrl/internal.h b/fs/resctrl/internal.h index bff4a54ae333..3846737992bb 100644 --- a/fs/resctrl/internal.h +++ b/fs/resctrl/internal.h @@ -143,6 +143,19 @@ enum rdt_group_type { RDT_NUM_GROUP, }; =20 +/** + * enum resctrl_kv_sel - Selector for "domain=3Dcbm" key/value parsing + * @RDT_PARSE_DOMAIN: Parse the left-hand side (domain ID) + * @RDT_PARSE_CBM: Parse the right-hand side (CBM value) + * + * Used by parsers of key/value pairs formatted as "domain=3Dcbm" to indic= ate + * which token should be extracted and converted. + */ +enum resctrl_kv_sel { + RDT_PARSE_DOMAIN, + RDT_PARSE_CBM, +}; + /** * enum rdtgrp_mode - Mode of a RDT resource group * @RDT_MODE_SHAREABLE: This resource group allows sharing of its allocati= ons diff --git a/fs/resctrl/rdtgroup.c b/fs/resctrl/rdtgroup.c index e1dc63b2218f..83ce3bafa5cb 100644 --- a/fs/resctrl/rdtgroup.c +++ b/fs/resctrl/rdtgroup.c @@ -2196,7 +2196,7 @@ static void io_alloc_init(void) { struct rdt_resource *r =3D resctrl_arch_get_resource(RDT_RESOURCE_L3); =20 - if (r->cache.io_alloc_capable) { + if (r->cache.io_alloc.io_alloc_capable) { resctrl_file_fflags_init("io_alloc", RFTYPE_CTRL_INFO | RFTYPE_RES_CACHE); resctrl_file_fflags_init("io_alloc_cbm", diff --git a/include/linux/resctrl.h b/include/linux/resctrl.h index 54701668b3df..9e75959565dc 100644 --- a/include/linux/resctrl.h +++ b/include/linux/resctrl.h @@ -215,7 +215,10 @@ struct resctrl_cache { unsigned int shareable_bits; bool arch_has_sparse_bitmasks; bool arch_has_per_cpu_cfg; - bool io_alloc_capable; + struct { + bool io_alloc_capable; + bool io_alloc_min_cbm; + } io_alloc; }; =20 /** @@ -415,6 +418,31 @@ static inline bool resctrl_is_mbm_event(enum resctrl_e= vent_id eventid) eventid <=3D QOS_L3_MBM_LOCAL_EVENT_ID); } =20 +/** + * apply_io_alloc_min_cbm() - Apply minimum io_alloc CBM + * + * @r: resctrl resource + * + * Return: Minimum number of consecutive io_alloc CBM bits to be set. + */ +static inline u32 apply_io_alloc_min_cbm(struct rdt_resource *r) +{ + return r->cache.min_cbm_bits; +} + +/** + * resctrl_should_io_alloc_min_cbm() - Should the minimum io_alloc + * CBM be applied + * @r: resctrl resource + * + * Return: True if the minimum number of consecutive + * bits to be set in the io_alloc CBM should be applied. + */ +static inline bool resctrl_should_io_alloc_min_cbm(struct rdt_resource *r) +{ + return r->cache.io_alloc.io_alloc_min_cbm; +} + u32 resctrl_get_mon_evt_cfg(enum resctrl_event_id eventid); =20 /* Iterate over all memory bandwidth events */ --=20 2.51.0