Re: [PATCH v12 20/31] fs/resctrl: Refactor mkdir_mondata_subdir()

From: Luck, Tony

Date: Tue Oct 28 2025 - 13:14:24 EST


On Tue, Oct 28, 2025 at 09:00:46AM -0700, Reinette Chatre wrote:
> Hi Tony,
>
> On 10/27/25 4:00 PM, Luck, Tony wrote:
> > On Thu, Oct 23, 2025 at 10:45:06AM -0700, Reinette Chatre wrote:
> >>> + sprintf(name, "mon_sub_%s_%02d", r->name, hdr->id);
> >>> + ckn = kernfs_create_dir(kn, name, parent_kn->mode, prgrp);
> >>
> >> Noting here that kn was created earlier with mode of parent_kn->mode. It thus looks to me like
> >> above can also be written as:
> >> ckn = kernfs_create_dir(kn, name, kn->mode, prgrp);
> >>
> >> The reason I mention this is that this patch adds a third copy of a very similar code snippet
> >> (kernfs_create_dir(), rdtgroup_kn_set_ugid(), mon_add_all_files()) that looks like a good
> >> candidate for a helper?
> >
> > I looked at this. But the helper needs a lot of arguments to cover these
> > three cases. Something like:
> >
> > static struct kernfs_node *make_and_fill_mondir(struct kernfs_node *parent_kn,
> > char *name, umode_t mode,
>
> I aimed to preempt a response like this in the text you quoted that notes that
> a "mode" argument does not seem necessary. Are you hinting that mode is indeed
> required? If not, without "mode" there are six arguments which is just one more
> than mon_add_all_files() that will be called by it.
> What is the threshold for there being too many arguments? This series does not seem
> to have trouble pushing an arch API call resctrl_arch_rmid_read() to eight arguments
> while there is a concern with the number of arguments of this static call that has
> fewer?

Ok. you have me convinced. Since this helper will be the only caller
of mon_add_all_files(), would it be good to just add the extra args
needed to this function and have it create the directory and add the
files? It would need a new name to describe the added functions it
performs. Maybe mon_add_domain_dir()? But better suggestions welcomed.

-Tony