Re: [PATCH v2 04/16] x86/resctrl: Change generic monitor functions to use struct rdt_domain_hdr

From: Luck, Tony
Date: Mon Mar 31 2025 - 17:14:59 EST


On Mon, Mar 31, 2025 at 09:15:36AM -0700, Reinette Chatre wrote:
> Hi Tony,
>
> On 3/21/25 4:15 PM, Tony Luck wrote:
> > Functions that don't need the internal details of the rdt_mon_domain
> > can operate on just the rdt_domain_hdr.
>
> This does not seem accurate. The functions are modified to take rdt_domain_hdr
> as parameter but then the functions are modified to extract rdt_mon_domain
> based on rdt_domain_hdr .... and proceeds to operate on internals of
> rdt_mon_domain in a way that contradicts the changelog.
>
> Considering what comes later this seems risky to me to rely on the
> code flow to interpret which structure rdt_domain_hdr forms part of. I think
> that it will be safer if rdt_domain_hdr gets an identifier that reflects which
> structure it forms part of so that the accessors could be made explicit and
> have error checking.

This needs some more thought and cleanup. I ended up with a mix of
places that really just wanted the header. E.g. adding second and subsequent
CPUs to a domain, or deleting any but the last CPU from a domain, only
need to update the cpu_mask. But other places end up clumsily using
container_of() to get to the surrounding mon_domain. With different
types of mon_domain a type field would help sanity checking.
>
> Reinette

-Tony