Re: [PATCH v1 2/2] arm_mpam: Disable preemption when making accesses to fake MSC in kunit test
From: James Morse
Date: Fri Mar 06 2026 - 13:24:35 EST
Hi Ben,
On 27/02/2026 11:03, Ben Horgan wrote:
> Accesses to MSC must be made from a cpu that is affine to that MSC and the
> driver checks this in __mpam_write_reg() using smp_processor_id(). A fake
> in-memory MSC is used for testing. When using that, it doesn't matter which
> cpu we access it from but calling smp_processor_id() from a preemptible
> context gives warnings when running with CONFIG_DEBUG_PREEMPT.
Bah!
> Add a test helper that wraps mpam_reset_msc_bitmap() with preemption
> disabled to ensure all (fake) MSC accesses are made with preemption
> disabled.
> diff --git a/drivers/resctrl/test_mpam_devices.c b/drivers/resctrl/test_mpam_devices.c
> index 3e8d564a0c64..75bd41bcc395 100644
> --- a/drivers/resctrl/test_mpam_devices.c
> +++ b/drivers/resctrl/test_mpam_devices.c
> @@ -322,6 +322,14 @@ static void test_mpam_enable_merge_features(struct kunit *test)
> mutex_unlock(&mpam_list_lock);
> }
>
> +static void __test_mpam_reset_msc_bitmap(struct mpam_msc *msc, u16 reg, u16 wd)
> +{
> + /* Avoid warnings when running with CONFIG_DEBUG_PREEMPT */
> + guard(preempt)();
> +
> + mpam_reset_msc_bitmap(msc, reg, wd);
> +}
Reviewed-by: James Morse <james.morse@xxxxxxx>
Thanks,
James