Re: [PATCH v11 01/31] x86,fs/resctrl: Improve domain type checking
From: Reinette Chatre
Date: Fri Oct 03 2025 - 11:29:04 EST
Hi Tony,
On 9/25/25 1:02 PM, Tony Luck wrote:
> Each resctrl resource has a list of domain structures. These all begin
> with a common rdt_domain_hdr.
>
> Improve type checking of these headers by adding the resource id. Add
> domain_header_is_valid() before each call to container_of() to ensure
> the domain is the expected type.
Apart from the "short and sweet" part of the guidance [1] followed in the
changelog above the same guidance concluded with summary (in bold)
that the *why* of the patch should be clear. This changelog is missing
the "why".
Here is an attempt to address that, please feel free to rewrite and improve:
Every resctrl resource has a list of domain structures. struct rdt_ctrl_domain
and struct rdt_mon_domain both begin with struct rdt_domain_hdr
with rdt_domain_hdr::type used in validity checks before accessing
the domain of a particular type.
Add the resource id to struct rdt_domain_hdr in preparation for a new
monitoring domain structure that will be associated with a new monitoring
resource. Improve existing domain validity checks with a new helper
domain_header_is_valid() that checks both domain type and resource id.
domain_header_is_valid() should be used before every call to container_of()
that accesses a domain structure.
[1] https://lore.kernel.org/all/20250923100956.GAaNJx9BYhXKkfNJ71@fat_crate.local/
>
> Signed-off-by: Tony Luck <tony.luck@xxxxxxxxx>
> ---
Patch looks good to me.
Reinette