Skip to content

Commit 8eb7ad6

Browse files
James Morsebp3tk0v
authored andcommitted
x86/resctrl: Check all domains are offline in resctrl_exit()
resctrl_exit() removes things like the resctrl mount point directory and unregisters the filesystem prior to freeing data structures that were allocated during resctrl_init(). This assumes that there are no online domains when resctrl_exit() is called. If any domain were online, the limbo or overflow handler could be scheduled to run. Add a check for any online control or monitor domains, and document that the architecture code is required to offline all monitor and control domains before calling resctrl_exit(). Suggested-by: Reinette Chatre <reinette.chatre@intel.com> Signed-off-by: James Morse <james.morse@arm.com> Signed-off-by: Borislav Petkov (AMD) <bp@alien8.de> Reviewed-by: Reinette Chatre <reinette.chatre@intel.com> Reviewed-by: Fenghua Yu <fenghuay@nvidia.com> Tested-by: Fenghua Yu <fenghuay@nvidia.com> Tested-by: Babu Moger <babu.moger@amd.com> Tested-by: Shaopeng Tan <tan.shaopeng@jp.fujitsu.com> Tested-by: Tony Luck <tony.luck@intel.com> Link: https://lore.kernel.org/20250515165855.31452-8-james.morse@arm.com
1 parent 7704fb8 commit 8eb7ad6

File tree

1 file changed

+33
-0
lines changed

1 file changed

+33
-0
lines changed

arch/x86/kernel/cpu/resctrl/rdtgroup.c

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4420,8 +4420,41 @@ int __init resctrl_init(void)
44204420
return ret;
44214421
}
44224422

4423+
static bool __exit resctrl_online_domains_exist(void)
4424+
{
4425+
struct rdt_resource *r;
4426+
4427+
/*
4428+
* Only walk capable resources to allow resctrl_arch_get_resource()
4429+
* to return dummy 'not capable' resources.
4430+
*/
4431+
for_each_alloc_capable_rdt_resource(r) {
4432+
if (!list_empty(&r->ctrl_domains))
4433+
return true;
4434+
}
4435+
4436+
for_each_mon_capable_rdt_resource(r) {
4437+
if (!list_empty(&r->mon_domains))
4438+
return true;
4439+
}
4440+
4441+
return false;
4442+
}
4443+
4444+
/*
4445+
* resctrl_exit() - Remove the resctrl filesystem and free resources.
4446+
*
4447+
* When called by the architecture code, all CPUs and resctrl domains must be
4448+
* offline. This ensures the limbo and overflow handlers are not scheduled to
4449+
* run, meaning the data structures they access can be freed by
4450+
* resctrl_mon_resource_exit().
4451+
*/
44234452
void __exit resctrl_exit(void)
44244453
{
4454+
cpus_read_lock();
4455+
WARN_ON_ONCE(resctrl_online_domains_exist());
4456+
cpus_read_unlock();
4457+
44254458
debugfs_remove_recursive(debugfs_resctrl);
44264459
unregister_filesystem(&rdt_fs_type);
44274460
sysfs_remove_mount_point(fs_kobj, "resctrl");

0 commit comments

Comments
 (0)