Re: [PATCH V1 2/2] lib/tests/slub_kunit: add a test case for {kmalloc,kfree}_nolock

Harry Yoo (Oracle)
2026-04-03T10:01:20Z

On Thu, Apr 02, 2026 at 04:36:59PM +0200, Vlastimil Babka (SUSE) wrote:
> On 3/30/26 2:05 PM, Harry Yoo (Oracle) wrote:
> > Testing invocation of {kmalloc,kfree}_nolock() during kmalloc() or
> > kfree() is tricky, and it is even harder to ensure that slowpaths are
> > properly tested. Lack of such testing has led to late discovery of
> > the bug fixed by commit a1e244a9f177 ("mm/slab: use prandom if
> > !allow_spin").
> >
> > Add a slub_kunit test that allocates and frees objects in a tight loop
> > while a perf event triggers NMIs on the same task, invoking
> > {kmalloc,kfree}_nolock() from the NMI handler.
> >
> > Signed-off-by: Harry Yoo (Oracle) <harry@kernel.org>
>
> perf_event_create_kernel_counter() seems to only exist with
> CONFIG_PERF_EVENTS,

Thanks for catching that!

> there's not even some "return -EINVAL" skeleton
> otherwise, AFAICS.

Right.

> Didn't check the various other definitions, but guess
> we'll need to put some/all of this behind #ifdef's then?

I'll make sure it builds w/o CONFIG_PERF_EVENTS and send v2.

--
Cheers,
Harry / Hyeonggon