[PATCH v2 03/45] arm_mpam: Use non-atomic bitops when modifying feature bitmap

Ben Horgan posted 45 patches 1 month, 3 weeks ago
There is a newer version of this series
[PATCH v2 03/45] arm_mpam: Use non-atomic bitops when modifying feature bitmap
Posted by Ben Horgan 1 month, 3 weeks ago
In the test__props_mismatch() kunit test we rely on the struct mpam_props
being packed to ensure memcmp doesn't consider packing. Making it packed
reduces the alignment of the features bitmap and so breaks a requirement
for the use of atomics. As we don't rely on the set/clear of these bits
being atomic, just make them non-atomic.

Signed-off-by: Ben Horgan <ben.horgan@arm.com>
---
 drivers/resctrl/mpam_internal.h | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/resctrl/mpam_internal.h b/drivers/resctrl/mpam_internal.h
index 17cdc3080d58..aaaf31ca9210 100644
--- a/drivers/resctrl/mpam_internal.h
+++ b/drivers/resctrl/mpam_internal.h
@@ -200,8 +200,8 @@ struct mpam_props {
 } PACKED_FOR_KUNIT;
 
 #define mpam_has_feature(_feat, x)	test_bit(_feat, (x)->features)
-#define mpam_set_feature(_feat, x)	set_bit(_feat, (x)->features)
-#define mpam_clear_feature(_feat, x)	clear_bit(_feat, (x)->features)
+#define mpam_set_feature(_feat, x)	__set_bit(_feat, (x)->features)
+#define mpam_clear_feature(_feat, x)	__clear_bit(_feat, (x)->features)
 
 /* The values for MSMON_CFG_MBWU_FLT.RWBW */
 enum mon_filter_options {
-- 
2.43.0
Re: [PATCH v2 03/45] arm_mpam: Use non-atomic bitops when modifying feature bitmap
Posted by Jonathan Cameron 1 month ago
On Fri, 19 Dec 2025 18:11:05 +0000
Ben Horgan <ben.horgan@arm.com> wrote:

> In the test__props_mismatch() kunit test we rely on the struct mpam_props
> being packed to ensure memcmp doesn't consider packing. Making it packed
> reduces the alignment of the features bitmap and so breaks a requirement
> for the use of atomics. As we don't rely on the set/clear of these bits
> being atomic, just make them non-atomic.

oh. That's a bit horrible.

Whilst I guess no one is likely to 'upgrade' these it feels odd enough that
I'd be tempted to leave a breadcrumb of a comment next to them on why
they must be the non atomic versions.

Reviewed-by: Jonathan Cameron <jonathan.cameron@huawei.com>

Jonathan


> 
> Signed-off-by: Ben Horgan <ben.horgan@arm.com>
> ---
>  drivers/resctrl/mpam_internal.h | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/resctrl/mpam_internal.h b/drivers/resctrl/mpam_internal.h
> index 17cdc3080d58..aaaf31ca9210 100644
> --- a/drivers/resctrl/mpam_internal.h
> +++ b/drivers/resctrl/mpam_internal.h
> @@ -200,8 +200,8 @@ struct mpam_props {
>  } PACKED_FOR_KUNIT;
>  
>  #define mpam_has_feature(_feat, x)	test_bit(_feat, (x)->features)
> -#define mpam_set_feature(_feat, x)	set_bit(_feat, (x)->features)
> -#define mpam_clear_feature(_feat, x)	clear_bit(_feat, (x)->features)
> +#define mpam_set_feature(_feat, x)	__set_bit(_feat, (x)->features)
> +#define mpam_clear_feature(_feat, x)	__clear_bit(_feat, (x)->features)
>  
>  /* The values for MSMON_CFG_MBWU_FLT.RWBW */
>  enum mon_filter_options {
Re: [PATCH v2 03/45] arm_mpam: Use non-atomic bitops when modifying feature bitmap
Posted by Ben Horgan 1 month ago
Hi Jonathan,

On 1/5/26 16:34, Jonathan Cameron wrote:
> On Fri, 19 Dec 2025 18:11:05 +0000
> Ben Horgan <ben.horgan@arm.com> wrote:
> 
>> In the test__props_mismatch() kunit test we rely on the struct mpam_props
>> being packed to ensure memcmp doesn't consider packing. Making it packed
>> reduces the alignment of the features bitmap and so breaks a requirement
>> for the use of atomics. As we don't rely on the set/clear of these bits
>> being atomic, just make them non-atomic.
> 
> oh. That's a bit horrible.
> 
> Whilst I guess no one is likely to 'upgrade' these it feels odd enough that
> I'd be tempted to leave a breadcrumb of a comment next to them on why
> they must be the non atomic versions.

Sure, I've added the comment:

The non-atomic get/set operations are used because if struct mpam_props
is packed, the alignment requirements for atomics aren't met.

> 
> Reviewed-by: Jonathan Cameron <jonathan.cameron@huawei.com>
> 
> Jonathan
> 
> 
>>
>> Signed-off-by: Ben Horgan <ben.horgan@arm.com>
Thanks,

Ben