Skip to content

Commit 93d9fd8

Browse files
aeglbp3tk0v
authored andcommitted
fs/resctrl: Refactor rmdir_mondata_subdir_allrdtgrp()
Clearing a monitor group's mon_data directory is complicated because of the support for Sub-NUMA Cluster (SNC) mode. Refactor the SNC case into a helper function to make it easier to add support for a new telemetry resource. Suggested-by: Reinette Chatre <reinette.chatre@intel.com> Signed-off-by: Tony Luck <tony.luck@intel.com> Signed-off-by: Borislav Petkov (AMD) <bp@alien8.de> Reviewed-by: Reinette Chatre <reinette.chatre@intel.com> Link: https://lore.kernel.org/20251217172121.12030-1-tony.luck@intel.com
1 parent 0ec1db4 commit 93d9fd8

1 file changed

Lines changed: 31 additions & 11 deletions

File tree

fs/resctrl/rdtgroup.c

Lines changed: 31 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -3229,28 +3229,24 @@ static void mon_rmdir_one_subdir(struct kernfs_node *pkn, char *name, char *subn
32293229
}
32303230

32313231
/*
3232-
* Remove all subdirectories of mon_data of ctrl_mon groups
3233-
* and monitor groups for the given domain.
3234-
* Remove files and directories containing "sum" of domain data
3235-
* when last domain being summed is removed.
3232+
* Remove files and directories for one SNC node. If it is the last node
3233+
* sharing an L3 cache, then remove the upper level directory containing
3234+
* the "sum" files too.
32363235
*/
3237-
static void rmdir_mondata_subdir_allrdtgrp(struct rdt_resource *r,
3238-
struct rdt_domain_hdr *hdr)
3236+
static void rmdir_mondata_subdir_allrdtgrp_snc(struct rdt_resource *r,
3237+
struct rdt_domain_hdr *hdr)
32393238
{
32403239
struct rdtgroup *prgrp, *crgrp;
32413240
struct rdt_l3_mon_domain *d;
32423241
char subname[32];
3243-
bool snc_mode;
32443242
char name[32];
32453243

32463244
if (!domain_header_is_valid(hdr, RESCTRL_MON_DOMAIN, RDT_RESOURCE_L3))
32473245
return;
32483246

32493247
d = container_of(hdr, struct rdt_l3_mon_domain, hdr);
3250-
snc_mode = r->mon_scope == RESCTRL_L3_NODE;
3251-
sprintf(name, "mon_%s_%02d", r->name, snc_mode ? d->ci_id : hdr->id);
3252-
if (snc_mode)
3253-
sprintf(subname, "mon_sub_%s_%02d", r->name, hdr->id);
3248+
sprintf(name, "mon_%s_%02d", r->name, d->ci_id);
3249+
sprintf(subname, "mon_sub_%s_%02d", r->name, hdr->id);
32543250

32553251
list_for_each_entry(prgrp, &rdt_all_groups, rdtgroup_list) {
32563252
mon_rmdir_one_subdir(prgrp->mon.mon_data_kn, name, subname);
@@ -3260,6 +3256,30 @@ static void rmdir_mondata_subdir_allrdtgrp(struct rdt_resource *r,
32603256
}
32613257
}
32623258

3259+
/*
3260+
* Remove all subdirectories of mon_data of ctrl_mon groups
3261+
* and monitor groups for the given domain.
3262+
*/
3263+
static void rmdir_mondata_subdir_allrdtgrp(struct rdt_resource *r,
3264+
struct rdt_domain_hdr *hdr)
3265+
{
3266+
struct rdtgroup *prgrp, *crgrp;
3267+
char name[32];
3268+
3269+
if (r->rid == RDT_RESOURCE_L3 && r->mon_scope == RESCTRL_L3_NODE) {
3270+
rmdir_mondata_subdir_allrdtgrp_snc(r, hdr);
3271+
return;
3272+
}
3273+
3274+
sprintf(name, "mon_%s_%02d", r->name, hdr->id);
3275+
list_for_each_entry(prgrp, &rdt_all_groups, rdtgroup_list) {
3276+
kernfs_remove_by_name(prgrp->mon.mon_data_kn, name);
3277+
3278+
list_for_each_entry(crgrp, &prgrp->mon.crdtgrp_list, mon.crdtgrp_list)
3279+
kernfs_remove_by_name(crgrp->mon.mon_data_kn, name);
3280+
}
3281+
}
3282+
32633283
/*
32643284
* Create a directory for a domain and populate it with monitor files. Create
32653285
* summing monitors when @hdr is NULL. No need to initialize summing monitors.

0 commit comments

Comments
 (0)