Re: [PATCH v11 20/31] fs/resctrl: Refactor Sub-NUMA Cluster (SNC) in mkdir/rmdir code flow

From: Reinette Chatre
Date: Thu Oct 09 2025 - 20:16:15 EST


Hi Tony,

On 10/9/25 3:08 PM, Luck, Tony wrote:
>> I did not mean to imply that this can be supported without refactoring. It does
>> seem as though you agree that mon_data::sum may be used for something
>> other than SNC and thus that using mon_data::sum as a check for SNC is not ideal.
>
> Reinette,
>
> Yes, we are in agreement about non-SNC future usage.
>
> Is it sufficient that I plant some WARN_ON_ONCE() in places where the
> code assumes that mon_data::sum is only used by RDT_RESOURCE_L3
> or for SNC?

>From what I understand this series does this already? I think this only applies to
rdtgroup_mondata_show() that does below ("L3 specific" comments added by me just for this example)
in this series:

rdtgroup_mondata_show()
{
...
if (md->sum) {
struct rdt_l3_mon_domain *d;

if (WARN_ON_ONCE(resid != RDT_RESOURCE_L3)) {
...
}

list_for_each_entry(d, &r->mon_domains, hdr.list) {
if (d->ci_id == domid) { /* L3 specific field */
...
/* L3 specific */
ci = get_cpu_cacheinfo_level(cpu, RESCTRL_L3_CACHE);
}
}
...
}

This seems reasonable since the flow is different from the typical "check resource"
followed by a domain_header_is_valid() that a refactor to support another resource
would probably do as you state below.

>
> Such code can be fixed by future patches that want to use mon_data::sum
> for other things.

This discussion digressed a bit. The discussion started with a request to add a check
for the L3 resource before calling rmdir_mondata_subdir_allrdtgrp_snc().
I see this as something like:
if (r->rid == RDT_RESOURCE_L3 && r->mon_scope == RESCTRL_L3_NODE) {
rmdir_mondata_subdir_allrdtgrp_snc(r, hdr);
...
}

I understand that rmdir_mondata_subdir_allrdtgrp_snc() may look something like below
but I still find the flow easier to follow if a resource check is done before calling
rmdir_mondata_subdir_allrdtgrp_snc().

rmdir_mondata_subdir_allrdtgrp_snc(r, hdr)
{
if (!domain_header_is_valid(hdr, RESCTRL_MON_DOMAIN, RDT_RESOURCE_L3))
return -EINVAL;

d = container_of(hdr, struct rdt_l3_mon_domain, hdr);
...

}

Reinette