Re: [PATCH v23 14/19] x86/resctrl: Handle removing directories in Sub-NUMA Cluster (SNC) mode

From: Tony Luck
Date: Tue Jul 02 2024 - 13:17:08 EST


On Tue, Jul 02, 2024 at 10:53:37AM +0200, Borislav Petkov wrote:
> On Fri, Jun 28, 2024 at 02:56:14PM -0700, Tony Luck wrote:
...
> ... and this are almost identical hunks.
>
> Why isn't there a helper which gets called here?

A helper will avoid this duplication. Draft below. Is this
what you want? Is the function name OK. I wasn't sure if the
"mon" looked better at the beginning. Or as rmdir_one_mon_subdir()

I've also fixed up part 17 to use msr_clear_bit()

Are you still digging through the patches?

-Tony

static void mon_rmdir_one_subdir(struct kernfs_node *pkn, char *name, char *subname)
{
struct kernfs_node *kn;

kn = kernfs_find_and_get(pkn, name);
if (!kn)
return;
kernfs_put(kn);

if (kn->dir.subdirs <= 1)
kernfs_remove(kn);
else
kernfs_remove_by_name(kn, subname);
}

/*
* Remove all subdirectories of mon_data of ctrl_mon groups
* and monitor groups for the given domain.
* Remove files and directories containing "sum" of domain data
* when last domain being summed is removed.
*/
static void rmdir_mondata_subdir_allrdtgrp(struct rdt_resource *r,
struct rdt_mon_domain *d)
{
struct rdtgroup *prgrp, *crgrp;
char subname[32];
bool snc_mode;
char name[32];

snc_mode = r->mon_scope == RESCTRL_L3_NODE;
sprintf(name, "mon_%s_%02d", r->name, snc_mode ? d->ci->id : d->hdr.id);
if (snc_mode)
sprintf(subname, "mon_sub_%s_%02d", r->name, d->hdr.id);

list_for_each_entry(prgrp, &rdt_all_groups, rdtgroup_list) {
mon_rmdir_one_subdir(prgrp->mon.mon_data_kn, name, subname);

list_for_each_entry(crgrp, &prgrp->mon.crdtgrp_list, mon.crdtgrp_list)
mon_rmdir_one_subdir(crgrp->mon.mon_data_kn, name, subname);
}
}