Skip to content

Commit 6b48b80

Browse files
aeglbp3tk0v
authored andcommitted
x86/resctrl: Handle removing directories in Sub-NUMA Cluster (SNC) mode
In SNC mode, there are multiple subdirectories in each L3 level monitor directory (one for each SNC node). If all the CPUs in an SNC node are taken offline, just remove the SNC directory for that node. In non-SNC mode, or when the last SNC node directory is removed, remove the L3 monitor directory. Add a helper function to avoid duplicated code. Signed-off-by: Tony Luck <[email protected]> Signed-off-by: Borislav Petkov (AMD) <[email protected]> Reviewed-by: Reinette Chatre <[email protected]> Link: https://lore.kernel.org/r/[email protected]
1 parent 0158ed6 commit 6b48b80

File tree

1 file changed

+29
-6
lines changed

1 file changed

+29
-6
lines changed

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

Lines changed: 29 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3006,22 +3006,45 @@ static int mon_addfile(struct kernfs_node *parent_kn, const char *name,
30063006
return ret;
30073007
}
30083008

3009+
static void mon_rmdir_one_subdir(struct kernfs_node *pkn, char *name, char *subname)
3010+
{
3011+
struct kernfs_node *kn;
3012+
3013+
kn = kernfs_find_and_get(pkn, name);
3014+
if (!kn)
3015+
return;
3016+
kernfs_put(kn);
3017+
3018+
if (kn->dir.subdirs <= 1)
3019+
kernfs_remove(kn);
3020+
else
3021+
kernfs_remove_by_name(kn, subname);
3022+
}
3023+
30093024
/*
30103025
* Remove all subdirectories of mon_data of ctrl_mon groups
3011-
* and monitor groups with given domain id.
3026+
* and monitor groups for the given domain.
3027+
* Remove files and directories containing "sum" of domain data
3028+
* when last domain being summed is removed.
30123029
*/
30133030
static void rmdir_mondata_subdir_allrdtgrp(struct rdt_resource *r,
3014-
unsigned int dom_id)
3031+
struct rdt_mon_domain *d)
30153032
{
30163033
struct rdtgroup *prgrp, *crgrp;
3034+
char subname[32];
3035+
bool snc_mode;
30173036
char name[32];
30183037

3038+
snc_mode = r->mon_scope == RESCTRL_L3_NODE;
3039+
sprintf(name, "mon_%s_%02d", r->name, snc_mode ? d->ci->id : d->hdr.id);
3040+
if (snc_mode)
3041+
sprintf(subname, "mon_sub_%s_%02d", r->name, d->hdr.id);
3042+
30193043
list_for_each_entry(prgrp, &rdt_all_groups, rdtgroup_list) {
3020-
sprintf(name, "mon_%s_%02d", r->name, dom_id);
3021-
kernfs_remove_by_name(prgrp->mon.mon_data_kn, name);
3044+
mon_rmdir_one_subdir(prgrp->mon.mon_data_kn, name, subname);
30223045

30233046
list_for_each_entry(crgrp, &prgrp->mon.crdtgrp_list, mon.crdtgrp_list)
3024-
kernfs_remove_by_name(crgrp->mon.mon_data_kn, name);
3047+
mon_rmdir_one_subdir(crgrp->mon.mon_data_kn, name, subname);
30253048
}
30263049
}
30273050

@@ -3991,7 +4014,7 @@ void resctrl_offline_mon_domain(struct rdt_resource *r, struct rdt_mon_domain *d
39914014
* per domain monitor data directories.
39924015
*/
39934016
if (resctrl_mounted && resctrl_arch_mon_capable())
3994-
rmdir_mondata_subdir_allrdtgrp(r, d->hdr.id);
4017+
rmdir_mondata_subdir_allrdtgrp(r, d);
39954018

39964019
if (is_mbm_enabled())
39974020
cancel_delayed_work(&d->mbm_over);

0 commit comments

Comments
 (0)