Re: [PATCH for-next v3 1/9] slub_kunit: fall back to SW perf events when HW PMU is not available

From: Harry Yoo

Date: Mon Jun 15 2026 - 08:59:21 EST




On 6/15/26 8:05 PM, Harry Yoo (Oracle) wrote:
> slub_kunit uses hardware perf events to invoke _nolock() APIs from NMI
> context. However, creating a HW perf event fails when there is no
> hardware PMU, or when running in a virtualized environment without a
> virtual PMU configured.
>
> Since tests are often performed in virtualized environments, fall back
> to a SW perf event so that the test can still run, even if it cannot
> cover IRQ-disabled sections.
>
> For the sheaves path, IRQs are not disabled until the barn is accessed.
> So some coverage is still expected.
>
> Signed-off-by: Harry Yoo (Oracle) <harry@xxxxxxxxxx>
> ---
> lib/tests/slub_kunit.c | 70 +++++++++++++++++++++++++++++++++++++++-----------
> 1 file changed, 55 insertions(+), 15 deletions(-)
>
> diff --git a/lib/tests/slub_kunit.c b/lib/tests/slub_kunit.c
> index fa6d31dbca16..11255fc8eb78 100644
> --- a/lib/tests/slub_kunit.c
> +++ b/lib/tests/slub_kunit.c
> @@ -303,6 +303,7 @@ struct test_nolock_context {
> int alloc_ok;
> int alloc_fail;
> struct perf_event *event;
> + bool is_perf_type_hw;
> };

nit: should have checked struct perf_event.type instead of introducing
a new field. Will fix.

--
Cheers,
Harry / Hyeonggon

Attachment: OpenPGP_signature.asc
Description: OpenPGP digital signature