Skip to content

Commit 0118427

Browse files
James Morsebp3tk0v
authored andcommitted
x86/resctrl: Move monitor exit work to a resctrl exit call
rdt_put_mon_l3_config() is called via the architecture's resctrl_arch_exit() call, and appears to free the rmid_ptrs[] and closid_num_dirty_rmid[] arrays. In reality this code is marked __exit, and is removed by the linker as resctrl can't be built as a module. To separate the filesystem and architecture parts of resctrl, this free()ing work needs to be triggered by the filesystem, as these structures belong to the filesystem code. Rename rdt_put_mon_l3_config() to resctrl_mon_resource_exit() and call it from resctrl_exit(). The kfree() is currently dependent on r->mon_capable. Signed-off-by: James Morse <[email protected]> Signed-off-by: Borislav Petkov (AMD) <[email protected]> Reviewed-by: Shaopeng Tan <[email protected]> Reviewed-by: Tony Luck <[email protected]> Reviewed-by: Reinette Chatre <[email protected]> Reviewed-by: Fenghua Yu <[email protected]> Reviewed-by: Babu Moger <[email protected]> Tested-by: Carl Worth <[email protected]> # arm64 Tested-by: Shaopeng Tan <[email protected]> Tested-by: Peter Newman <[email protected]> Tested-by: Amit Singh Tomar <[email protected]> # arm64 Tested-by: Shanker Donthineni <[email protected]> # arm64 Tested-by: Babu Moger <[email protected]> Link: https://lore.kernel.org/r/[email protected]
1 parent 9be68b1 commit 0118427

File tree

4 files changed

+12
-9
lines changed

4 files changed

+12
-9
lines changed

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

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1074,14 +1074,9 @@ late_initcall(resctrl_arch_late_init);
10741074

10751075
static void __exit resctrl_arch_exit(void)
10761076
{
1077-
struct rdt_resource *r = &rdt_resources_all[RDT_RESOURCE_L3].r_resctrl;
1078-
10791077
cpuhp_remove_state(rdt_online);
10801078

10811079
resctrl_exit();
1082-
1083-
if (r->mon_capable)
1084-
rdt_put_mon_l3_config();
10851080
}
10861081

10871082
__exitcall(resctrl_arch_exit);

arch/x86/kernel/cpu/resctrl/internal.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -586,7 +586,7 @@ void closid_free(int closid);
586586
int alloc_rmid(u32 closid);
587587
void free_rmid(u32 closid, u32 rmid);
588588
int rdt_get_mon_l3_config(struct rdt_resource *r);
589-
void __exit rdt_put_mon_l3_config(void);
589+
void __exit resctrl_mon_resource_exit(void);
590590
bool __init rdt_cpu_has(int flag);
591591
void mon_event_count(void *info);
592592
int rdtgroup_mondata_show(struct seq_file *m, void *arg);

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

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1040,10 +1040,13 @@ static int dom_data_init(struct rdt_resource *r)
10401040
return err;
10411041
}
10421042

1043-
static void __exit dom_data_exit(void)
1043+
static void __exit dom_data_exit(struct rdt_resource *r)
10441044
{
10451045
mutex_lock(&rdtgroup_mutex);
10461046

1047+
if (!r->mon_capable)
1048+
goto out_unlock;
1049+
10471050
if (IS_ENABLED(CONFIG_RESCTRL_RMID_DEPENDS_ON_CLOSID)) {
10481051
kfree(closid_num_dirty_rmid);
10491052
closid_num_dirty_rmid = NULL;
@@ -1052,6 +1055,7 @@ static void __exit dom_data_exit(void)
10521055
kfree(rmid_ptrs);
10531056
rmid_ptrs = NULL;
10541057

1058+
out_unlock:
10551059
mutex_unlock(&rdtgroup_mutex);
10561060
}
10571061

@@ -1237,9 +1241,11 @@ int __init rdt_get_mon_l3_config(struct rdt_resource *r)
12371241
return 0;
12381242
}
12391243

1240-
void __exit rdt_put_mon_l3_config(void)
1244+
void __exit resctrl_mon_resource_exit(void)
12411245
{
1242-
dom_data_exit();
1246+
struct rdt_resource *r = resctrl_arch_get_resource(RDT_RESOURCE_L3);
1247+
1248+
dom_data_exit(r);
12431249
}
12441250

12451251
void __init intel_rdt_mbm_apply_quirk(void)

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4296,4 +4296,6 @@ void __exit resctrl_exit(void)
42964296
debugfs_remove_recursive(debugfs_resctrl);
42974297
unregister_filesystem(&rdt_fs_type);
42984298
sysfs_remove_mount_point(fs_kobj, "resctrl");
4299+
4300+
resctrl_mon_resource_exit();
42994301
}

0 commit comments

Comments
 (0)