Re: [PATCH v1 13/31] x86/resctrl: Stop using the for_each_*_rdt_resource() walkers

Dave Martin
2024-04-11T14:16:07Z

On Mon, Apr 08, 2024 at 08:19:40PM -0700, Reinette Chatre wrote:
> Hi James,
>
> On 3/21/2024 9:50 AM, James Morse wrote:
> > The for_each_*_rdt_resource() helpers walk the architectures array
>
> architecture's ?

Noted.

> > of structures, using the resctrl visible part as an iterator. These
> > became over-complex when the structures were split into a
> > filesystem and architecture-specific struct. This approach avoided
> > the need to touch every call site.
> >
> > Once the filesystem parts of resctrl are moved to /fs/, both the
> > architecture's resource array, and the definition of those structures
> > is no longer accessible. To support resctrl, each architecture would
> > have to provide equally complex macros.
> >
> > Change the resctrl code that uses these to walk through the resource_level
> > enum and check the mon/alloc capable flags instead. Instances in core.c,
> > and resctrl_arch_reset_resources() remain part of x86's architecture
> > specific code.
> >
> > Signed-off-by: James Morse <james.morse@arm.com>
> > ---
> > arch/x86/kernel/cpu/resctrl/pseudo_lock.c | 7 +++++-
> > arch/x86/kernel/cpu/resctrl/rdtgroup.c | 30 +++++++++++++++++++----
> > 2 files changed, 31 insertions(+), 6 deletions(-)

[...]

> > diff --git a/arch/x86/kernel/cpu/resctrl/rdtgroup.c b/arch/x86/kernel/cpu/resctrl/rdtgroup.c
> > index e736e4d20f63..3f16e7854411 100644
> > --- a/arch/x86/kernel/cpu/resctrl/rdtgroup.c
> > +++ b/arch/x86/kernel/cpu/resctrl/rdtgroup.c

[...]

> > @@ -2205,8 +2211,12 @@ static int rdtgroup_create_info_dir(struct kernfs_node *parent_kn)
> > goto out_destroy;
> > }
> >
> > - for_each_mon_capable_rdt_resource(r) {
> > - fflags = r->fflags | RFTYPE_MON_INFO;
> > + for (i = 0; i < RDT_NUM_RESOURCES; i++) {
> > + r = resctrl_arch_get_resource(i);
> > + if (!r->mon_capable)
> > + continue;
> > +
> > + fflags = r->fflags | RFTYPE_MON_INFO;
>
> Please check spacing.

[...]

> Reinette

Noted, thanks.

Cheers
---Dave