[PATCH v2 06/14] fs/resctrl: Change pattern used to track number of entries in enum

Reinette Chatre posted 14 patches 2 weeks ago
[PATCH v2 06/14] fs/resctrl: Change pattern used to track number of entries in enum
Posted by Reinette Chatre 2 weeks ago
CDP_NUM_TYPES tracks the number of different configuration types that can
be applied to a resource. CDP_NUM_TYPES is required to iterate over the
different configurations but is not a member of enum resctrl_conf_type to
avoid the warning generated with -Wswitch when CDP_NUM_TYPES lacks a case.

Add a new CDP_LAST enum entry used in CDP_NUM_TYPES definition to simplify
adding a new enum entry. Do this to create a cleaner pattern for tracking
the number of enum entries in resctrl in preparation for other enums
needing to do so.

Suggested-by: Ben Horgan <ben.horgan@arm.com>
Signed-off-by: Reinette Chatre <reinette.chatre@intel.com>
---
 include/linux/resctrl.h | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/include/linux/resctrl.h b/include/linux/resctrl.h
index 006e57fd7ca5..0b28049378c8 100644
--- a/include/linux/resctrl.h
+++ b/include/linux/resctrl.h
@@ -69,9 +69,10 @@ enum resctrl_conf_type {
 	CDP_NONE,
 	CDP_CODE,
 	CDP_DATA,
+	CDP_LAST = CDP_DATA
 };
 
-#define CDP_NUM_TYPES	(CDP_DATA + 1)
+#define CDP_NUM_TYPES	(CDP_LAST + 1)
 
 /*
  * struct pseudo_lock_region - pseudo-lock region information
-- 
2.50.1
Re: [PATCH v2 06/14] fs/resctrl: Change pattern used to track number of entries in enum
Posted by Ben Horgan 1 week, 4 days ago
Hi Reinette,

On 3/20/26 22:03, Reinette Chatre wrote:
> CDP_NUM_TYPES tracks the number of different configuration types that can
> be applied to a resource. CDP_NUM_TYPES is required to iterate over the
> different configurations but is not a member of enum resctrl_conf_type to
> avoid the warning generated with -Wswitch when CDP_NUM_TYPES lacks a case.
> 
> Add a new CDP_LAST enum entry used in CDP_NUM_TYPES definition to simplify
> adding a new enum entry. Do this to create a cleaner pattern for tracking
> the number of enum entries in resctrl in preparation for other enums
> needing to do so.

LGTM

Reviewed-by: Ben Horgan <ben.horgan@arm.com>

> 
> Suggested-by: Ben Horgan <ben.horgan@arm.com>
> Signed-off-by: Reinette Chatre <reinette.chatre@intel.com>
> ---
>  include/linux/resctrl.h | 3 ++-
>  1 file changed, 2 insertions(+), 1 deletion(-)
> 
> diff --git a/include/linux/resctrl.h b/include/linux/resctrl.h
> index 006e57fd7ca5..0b28049378c8 100644
> --- a/include/linux/resctrl.h
> +++ b/include/linux/resctrl.h
> @@ -69,9 +69,10 @@ enum resctrl_conf_type {
>  	CDP_NONE,
>  	CDP_CODE,
>  	CDP_DATA,
> +	CDP_LAST = CDP_DATA
>  };
>  
> -#define CDP_NUM_TYPES	(CDP_DATA + 1)
> +#define CDP_NUM_TYPES	(CDP_LAST + 1)
>  
>  /*
>   * struct pseudo_lock_region - pseudo-lock region information