Re: [PATCH v2 07/14] fs/resctrl: Use accurate type for rdt_resource::rid
From: Ben Horgan
Date: Mon Mar 23 2026 - 06:54:48 EST
Hi Reinette,
On 3/20/26 22:03, Reinette Chatre wrote:
> Every resctrl resource has a unique ID described by enum resctrl_res_level.
> enum resctrl_res_level is used in all resource ID initializations and all
> resource ID comparisons. All functions consuming the resource ID expects an
> enum resctrl_res_level. Of the four structures that contain a resource ID
> (struct mon_data, struct mon_evt, struct rdt_domain_hdr, and struct
> rdt_resource) only struct rdt_resource does not use enum resctrl_res_level.
>
> Switch the type of rdt_resource::rid to be enum resctrl_res_level to make
> it obvious what values are valid, match the type everywhere this member is
> used, and obtain benefits from tools that can flag any enum misuse.
>
> Move define of RDT_NUM_RESOURCES outside the enum to enable tools to catch
> when a switch() on the resource ID does not handle all the resources and
> thus help flag which switch statements need an update when a new resource
> is added.
LGTM
Reviewed-by: Ben Horgan <ben.horgan@xxxxxxx>
Thanks,
Ben