From nobody Thu Dec 18 06:16:21 2025 Received: from CWXP265CU010.outbound.protection.outlook.com (mail-ukwestazon11022129.outbound.protection.outlook.com [52.101.101.129]) (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 D8E19324B33 for ; Mon, 15 Dec 2025 23:03:20 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=52.101.101.129 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1765839803; cv=fail; b=Q7kzchGuvtcrQJ6x70RDGzawo68iRMw9pKEADdunaOIHO5D//P8be/tmomoSS/pdYgqa6kHTc4wCE2Bl8la5Y1IYQYDpJkj7OhFCkH/xgoiUNWol2VKiqwzL0N2woFG1UGpwNbT90iv+vQ2nvPHni+2Nl1y0X2bSxey5Gq4yHHE= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1765839803; c=relaxed/simple; bh=vJW5C4TVbx16enXhLAiDp7ChtgmQm9zXavnRzxUvSsQ=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: Content-Type:MIME-Version; b=SXm8MiSwqr8zRy4x4BaRM+sOb19+7JaiuxheqmGouEckaJEeGsPzwp/ddAeemTOqKvIJowIJLI7aVESs1d8+qsg8l6hE+ialg9Wxw2M4b8re3hmPeeNqDpzJnuE9Cdcme+792kf4mumlbPgIFrZnOE6/9XP29NMzzci79gKNbU0= 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.101.129 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=GOQ4tG5VzajXE9TZZ15uYn66NOdvOaT2UhWTV5p1zuS9kjHIN7H+DXeR+IDWE8CfYndRlT44YW/Vw6qxZ3A4oAmcCM4Vdze45JhnmdkY+2GmTxqROup9AbHn7A3f3WwDLs4SGY0WSt3HnC0HAjsbC/qihUgYrUPctgFX2fwCujHXh+9Jc7q5JaqTQBMExO4q6PUG1UoHTg1GonmOdI67IZmXwlvDTKCQNxhYfANIqT9H0ccMe81LYMDoSndvo1GDx+5H0LXU7x5dpmMQafxQIkzcn/Vtcx2EQvEYPZMy9Mw45zC6PcZKSt9jlrCCkcHC4W1j6XopJSccGp51DQnXOQ== 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=cwI5xpfxw549GHf7Kz5+52hvmHiF0/F0tfeZPdv0DYg=; b=EFogj0wFUDSe2o0bTU8pyIhMevVbnvDB/GiKJra5X9Fv6gpiNGEOPRxMkrEliz4yjJ9AMd7iNtrV1jJjLmqtqsq386NIPU79irgNiYvlrThP0B+/AXegIYh3uuet97kKJI+aCpQutAXqzWpWgr+DvIz9RD7vs1o6tHkCfjn6fqaE/FfuwJdj7y+YfBaqMmD75f30oeW3mPRK+s9KCMhgn8nFWL3i8Qa1gmv+B6EzTGBCXc7RBTr+/Ai+AshWBy2fUrbCPCqBDmm2agqODk6QJPwvX+rd53a7AlzdcgbTcCJ3nbrc7wsQJjPQE72RVyuhAOv6bUmfrp/bi7E/t4sRHA== 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 LO0P123MB6333.GBRP123.PROD.OUTLOOK.COM (2603:10a6:600:288::7) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.9412.13; Mon, 15 Dec 2025 23:03:17 +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.9412.011; Mon, 15 Dec 2025 23:03:17 +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 v2 3/3] x86/resctrl: Add "*" shorthand to set minimum io_alloc CBM for all domains Date: Mon, 15 Dec 2025 18:02:57 -0500 Message-ID: <20251215230257.1798865-4-atomlin@atomlin.com> X-Mailer: git-send-email 2.51.0 In-Reply-To: <20251215230257.1798865-1-atomlin@atomlin.com> References: <20251215230257.1798865-1-atomlin@atomlin.com> Content-Transfer-Encoding: quoted-printable X-ClientProxiedBy: BN9PR03CA0102.namprd03.prod.outlook.com (2603:10b6:408:fd::17) 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_|LO0P123MB6333:EE_ X-MS-Office365-Filtering-Correlation-Id: ae82fa46-9dbf-4667-67b9-08de3c2e21b6 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|366016|7416014|376014|1800799024; X-Microsoft-Antispam-Message-Info: =?us-ascii?Q?q+sVnaigiVoBoPe2jkGEb0jXJkhnCTw79mkOHflypiOVY5RTUYAHfpElTdnc?= =?us-ascii?Q?+5HiR7FWZqQCcw/5w4Xcea8ds7oL9t0ehu07DmNXQqSGMS7mTa0365vKXlwZ?= =?us-ascii?Q?KL38O87rHPbLtmMAdmEuaFqfpzMg+mi3bsK3F2gd8Y8Il1HCwLQVLOjHpROQ?= =?us-ascii?Q?ydb29b8LzEg4qzGfRaTmq/aDuw1suJbBzJur8DZuY7lYgxxGb2BeXJo31rql?= =?us-ascii?Q?9AGcf2Hkiw0u8sgnznT7JyuAL35wBhX5G3kEznpGViMH1lHKdRCYIqkuxxoN?= =?us-ascii?Q?6+2d0L0B5EvohrWMRSekcHEH0O3ahRmulXOVhy7CSElIfYRyNRhR4odzDWGL?= =?us-ascii?Q?erKs12clptp51knLkm+z0pCEfvuLFb5P7EMDrrOVyzsAt6vAw0LTynYHbbMu?= =?us-ascii?Q?4QyrtD1Jb8FH+ui8vHKuTc9Uja66Qo+Yj7ta1RvWmq5x+nNC1pi8psSiT2TB?= =?us-ascii?Q?XoYU/qPp2hvOwsPZ3u3P4LC20P6NIcfWKidnTYwRrOY+nzv6JtiS26OjckaJ?= =?us-ascii?Q?YqYVozEFUpDptZZOT+vKCHqWrfnNLJ8UBJEpMfK5X9z8uvotOGlemtHnNi0d?= =?us-ascii?Q?BEKwV0pxtZw1VkUwS/cZgWDjIDatqLwBSSZtCVDXpAssHSxT1sq95d9g9UnX?= =?us-ascii?Q?sjQK0HQESMF66sbWX7NBnhFNZIgGrO+Hjr5ur2VSCV+UF4rCmFj1RDqALFm7?= =?us-ascii?Q?laRuzvIHWeNZRgbd4P/TdOGI00S52HTwu/n/SApCsmo0M7u3pZ7SsJImDa7s?= =?us-ascii?Q?JZzbpXPsimY/k9yFY7azrLFnt20gNQPbIFvvH11Zb7JuWrL+YUNJ9svd+ha7?= =?us-ascii?Q?hEXF9PtpwnYaM0F7h27WNpQOm4IBwdhdMjIBYNep9iKf0zSX4EbpA5F0MTiB?= =?us-ascii?Q?0wMFn3AkXEc7IW1PVxudchA9/tvlmrlYQsdTpcCaIE0TLkgdlSS1iMWpx+hu?= =?us-ascii?Q?EOOgIw1lu4J74VisUM6jkfK6S5atP01Gh72gUFJq0fJGDi9JGBSQm2Q/fKvT?= =?us-ascii?Q?N1qPsU0OOKlk8DXazNmhgzRXTGnw9pjp4RCZu+3DmxJ/aj/RB0eaCp49Ryep?= =?us-ascii?Q?+OkCWjKhVL9WveuretiFyRZNFriEoUBKhOgNvrJl16n7XS+gU5uoyuk0TK/a?= =?us-ascii?Q?Ei7mxQmXZwSRO4vepUcv6nGcxkKKuc438FHpiQqnisT/7RODjwwA0I008Ep0?= =?us-ascii?Q?kyKAEt6rghdnU3o41+VOzjF1xSoRzi4hgxLjoRwt0KDNh4MSbCTkkkUbOCKn?= =?us-ascii?Q?BE7uh3hg4CDsUGqEd73jupr4xq7LdqTkYrPUg+33+AW7G2/6lt7XbLofA1MX?= =?us-ascii?Q?jaCsNXtnJbL2/aARz+k3fOkbG0gCeCe/EjEi0VtdNL2CkHg6tO+jhIIlGf16?= =?us-ascii?Q?bOc5p3GFqNyMBwpOux/0oRUmg4P6evdjqn8QQLW063rRTBb0EwleoVAAaq+B?= =?us-ascii?Q?A1Qdx9fzdq+gbCOYQl5XPuAXOwGCBHpq?= 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)(366016)(7416014)(376014)(1800799024);DIR:OUT;SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?us-ascii?Q?wUeyZuq4W06lMpeV0hplC/d2vKuuXyWzDk6041umPLFP+/820+/giUL/Um3D?= =?us-ascii?Q?bCw4Bs3Eyw0mYGy2hgRf5tk7HnK8MRVfoPcodIMDtQaUT4a6QXZvfupdnvkg?= =?us-ascii?Q?F55bwrm7/DpdwjLAwkVcFqJEvu3wErKoDpN0YhCIGNVCM4jSDR92kgsk/Fyj?= =?us-ascii?Q?yJL/6fw0+NaG3vo1NyFLdNIfP0NjLHm9Hrt5mPSK43HBo3VkHd3DiP7S8ZjL?= =?us-ascii?Q?LZ6g85gvq6Zp6F4hC+myUjM26hIafNpId0YKDlSen4FFG+9OXrrVxvaYmN/k?= =?us-ascii?Q?S645ZcGhPI122e4lovKibC/2hYNhs2qNv1XVa1j2OVR0qvtIRlgEsjYgZX3b?= =?us-ascii?Q?DRLGZbKHAOk0DeR/U0qgYImOCGaIuYcFOaPolRRs2HbsCspdVXJa6OSTAh+t?= =?us-ascii?Q?VnBqiNu1R0ICA1BN2IHCDNN1n7kCwCaegrAOXb5qjmejieOdJnSFwdC1Sgcy?= =?us-ascii?Q?sRZpKHq9NDIbxhI4nURUXy99qvx1aK2bq0Fa9XT09T6xJ/FfLxLcHYcEM3gg?= =?us-ascii?Q?yGLxG7EqVJcbJ1ta/ZRb5GIf9/cygmBh6VSDKMzYmMqt5uHVwJdoPvx8uKt4?= =?us-ascii?Q?zdZ/GES5l3Z8NvXgxQTGlaRW4yJX6CSf05nztcwvo5T+BDmXPcpsAOwrYGF6?= =?us-ascii?Q?8w8xKVat8UQDptyDSXEYpnneaWVXsRVJC05DEiSfAaDZJ9iAVx6orkKTu4qK?= =?us-ascii?Q?AvVEoWhdoWz4nB2OxMvjKsCqfvsLXLyQof0CMGpWO97ngGMhRz/mUaztzAa2?= =?us-ascii?Q?MZWZphkxNqp1AyaGctC/K/uQRb2e0H01SyEEbeNk4HUF13GHNOzHmCuJihXj?= =?us-ascii?Q?UA3aow231szq1tv0Ro8UDocGXIoY0IjiLyPBWEgdXu8Q/NfFRAtX1/W4zrUT?= =?us-ascii?Q?FqmZ9u3tu/x47dexndQ6mNiyc61OYcXlImKTsrr5F0nLqYTXTLMJscGSm3d3?= =?us-ascii?Q?KRgzXPmtKoOosVCfYNUzkHalUFwFBVcQkV9v/lH7apaeA4EyqQp+xIaUNcrp?= =?us-ascii?Q?ont8afooSDGcJJg6IKhX1vSBaDxPSULZyAZY2klvpJbWFdmdVe2WoVWYYKWN?= =?us-ascii?Q?Qy/iIT1G14Y80Cdr0W86nWDzyg0c/24YeyOEtGtTnwb7A4TBxhvevpWVQCrm?= =?us-ascii?Q?9wUR3oMTkgPba2qsnkeqxp5KdlgyQ4yOBUSaRY2T0WYJoQzRF7OpJS0IaQqq?= =?us-ascii?Q?Vt8PnCp8nK6vs8uwp+Y30hkUft4yCfWBD7bf6GbJ/JhmgUvY6a1bByQXRCZF?= =?us-ascii?Q?8ez5Prt3vHUvOcHzrpKr1Z/Jxu0EUt7H0wVumorIsYlAvAZ03PWNaTh72UJw?= =?us-ascii?Q?lcBDx6sL8epInAaC7SawiJI4XVWAwvvvFDKF69I2RK9RzbRFHK80dEz7UG/0?= =?us-ascii?Q?aAbFPkuCKYEiePAyw4BLk1YBK6IHkedmWVAedKFnTJXTXs6V8Fio/OK79K5R?= =?us-ascii?Q?hUySgmWfqult0T4oejymH4PMJLB4yD5sMUYS7XoAImp24Y3BP/bdMElmNu4B?= =?us-ascii?Q?L4e10xWaLttbdq1spOPagujBqLVL61GtTAoAeFv2fV89OqsvnMAQYKBFXLkU?= =?us-ascii?Q?JF2mfAzX2/LFi3KzYd2V+T/7/Uwf3o9POEMTb+9n?= X-OriginatorOrg: atomlin.com X-MS-Exchange-CrossTenant-Network-Message-Id: ae82fa46-9dbf-4667-67b9-08de3c2e21b6 X-MS-Exchange-CrossTenant-AuthSource: CWLP123MB3523.GBRP123.PROD.OUTLOOK.COM X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 15 Dec 2025 23:03:17.0735 (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: CJdtTtgd7TDTIESHYsCTyQYPcD2/7MNTn2kgDb5g4DSS7SCkqw4kAPvBfJS7qsTdpzTRTC3PvEkhzrUknwXc+A== X-MS-Exchange-Transport-CrossTenantHeadersStamped: LO0P123MB6333 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 | 141 ++++++++++++++++------ fs/resctrl/internal.h | 13 ++ fs/resctrl/rdtgroup.c | 2 +- include/linux/resctrl.h | 30 ++++- 7 files changed, 174 insertions(+), 47 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 d2f9a4f2d887..a36b9055a1be 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,49 +918,103 @@ int resctrl_io_alloc_cbm_show(struct kernfs_open_fil= e *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 inline 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 *cbm =3D NULL; + unsigned long out_val; + int ret; =20 -next: - if (!line || line[0] =3D=3D '\0') - return 0; + if (line[0] =3D=3D '*') { + ret =3D parse_domain_cbm(&line, &out_val, RDT_PARSE_CBM); + if (ret) + return ret; =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"); + 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; } =20 - dom =3D strim(dom); - list_for_each_entry(d, &r->ctrl_domains, hdr.list) { - if (d->hdr.id =3D=3D dom_id) { - data.buf =3D dom; - data.mode =3D RDT_MODE_SHAREABLE; - data.closid =3D closid; - if (parse_cbm(&data, s, d)) - return -EINVAL; - /* - * 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])); + while (line && line[0] !=3D '\0') { + bool found =3D false; + + cbm =3D strsep(&line, ";"); + ret =3D parse_domain_cbm(&cbm, &out_val, RDT_PARSE_DOMAIN); + if (ret) + return ret; + + cbm =3D strim(cbm); + list_for_each_entry(d, &r->ctrl_domains, hdr.list) { + if (d->hdr.id =3D=3D out_val) { + data.buf =3D cbm; + data.mode =3D RDT_MODE_SHAREABLE; + data.closid =3D closid; + if (parse_cbm(&data, s, d)) + return -EINVAL; + /* + * Keep io_alloc CLOSID's CBM of CDP_CODE and CDP_DATA + * in sync. + */ + if (resctrl_arch_get_cdp_enabled(r->rid)) + resctrl_sync_cdp_peer(s, d); + found =3D true; + break; } - goto next; } + + if (!found) + return -EINVAL; } =20 - return -EINVAL; + return 0; } =20 ssize_t resctrl_io_alloc_cbm_write(struct kernfs_open_file *of, char *buf, @@ -982,6 +1051,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