Re: [PATCH v6 12/42] x86/resctrl: Move rdt_find_domain() to be visible to arch and fs code

From: Catalin Marinas
Date: Thu Feb 20 2025 - 05:59:13 EST


On Wed, Feb 19, 2025 at 03:24:06PM -0800, Reinette Chatre wrote:
> On 2/7/25 10:17 AM, James Morse wrote:
> > rdt_find_domain() finds a domain given a resource and a cache-id.
> > This is used by both the architecture code and the filesystem code.
> >
> > After the filesystem code moves to live in /fs/, this helper will no
> > longer be visible.
> >
> > Move it to the global header file. As its now globally visible, and
> > has only a handful of callers, swap the 'rdt' for 'resctrl'.
[...]
> > --- a/include/linux/resctrl.h
> > +++ b/include/linux/resctrl.h
> > @@ -372,6 +372,40 @@ static inline void resctrl_arch_rmid_read_context_check(void)
> > might_sleep();
> > }
> >
> > +/**
> > + * resctrl_find_domain() - Search for a domain id in a resource domain list.
> > + * @h: The domain list to search.
> > + * @id: The domain id to search for.
> > + * @pos: A pointer to position in the list id should be inserted.
> > + *
> > + * Search the domain list to find the domain id. If the domain id is
> > + * found, return the domain. NULL otherwise. If the domain id is not
> > + * found (and NULL returned) then the first domain with id bigger than
> > + * the input id can be returned to the caller via @pos.
> > + */
> > +static inline struct rdt_domain_hdr *resctrl_find_domain(struct list_head *h,
> > + int id,
> > + struct list_head **pos)
>
> Could you please provide a motivation for why this needs to be inline now?

It's in a header now, to avoid the compiler complaining about unused
static functions wherever this file is included. The alternative is a
prototype declaration and the actual implementation in a .c file.

(drive-by comment, I don't really understand this subsystem to make a
meaningful contribution)

--
Catalin