Re: [patch v2 2/2] mm: slab_kunit: add synthetic benchmark for the slab allocator

From: Vlastimil Babka (SUSE)

Date: Wed Dec 02 2026 - 07:11:47 EST


On 11/29/26 22:25, David Rientjes wrote:
> From: Christoph Lameter <cl@xxxxxxxxxx>
>
> Add a synthetic benchmark that can be used to measure performance of the
> slab allocator. This is used to analyze any improvements or regressions
> in kmalloc() and kfree(), which are used throughout the kernel in hot code
> paths.
>
> This is the third of three tests that measure the execution times of
> critical MM functions anticipated to be used by developers to measure the
> impact of any core changes that would end up causing workload performance
> issues. Google has carried these tests internally and kept them updated
> since Christoph posted them back in 2009 for this purpose.
>
> This can also be used to detect regressions over time, from kernel
> version to kernel version, independent of development use cases.
>
> The benchmark covers, for kmalloc object sizes that are powers of two:
>
> - allocating a batch of objects and then freeing them, from a single
> thread
> - allocating and immediately freeing an object, from a single thread
> - both of the above concurrently on all online CPUs
> - allocating objects on all CPUs but one and freeing them all from that
> one CPU (remote free)
> - allocating objects on one CPU while all other CPUs concurrently free
> them (1 alloc N free)
>
> Allocations use __GFP_NORETRY | __GFP_NOWARN so that the benchmark does not
> invoke the oom killer on small systems; if memory runs out, the results
> are reported for the objects that could be allocated.
>
> This is a performance benchmark and is complementary to the functional
> tests in lib/tests/slub_kunit.c.
>
> The test is run by KUnit or doing modprobe slab_kunit directly.
>
> Sample output (abbreviated):
> KTAP version 1
> 1..1
> KTAP version 1
> # Subtest: slab
> # module: slab_kunit
> 1..6
> # slab_test_kmalloc_then_kfree: size 8: 10000 ops: kmalloc -> 996 cycles (248 ns/op), kfree -> 449 cycles (111 ns/op)
> ...
> ok 1 slab_test_kmalloc_then_kfree
> # slab_test_kmalloc_kfree_pair: size 8: 10000 ops: kmalloc/kfree pair -> 832 cycles (206 ns/op)
> ...
> ok 2 slab_test_kmalloc_kfree_pair
> # slab_test_concurrent_kmalloc_then_kfree: size 8: 4 cpus, 40000 ops: kmalloc -> 951 cycles (236 ns/op), kfree -> 530 cycles (131 ns/op)
> ...
> ok 3 slab_test_concurrent_kmalloc_then_kfree
> # slab_test_concurrent_kmalloc_kfree_pair: size 8: 4 cpus, 40000 ops: kmalloc/kfree pair -> 1071 cycles (263 ns/op)
> ...
> ok 4 slab_test_concurrent_kmalloc_kfree_pair
> # slab_test_remote_free: size 8: 4 cpus, 30000 ops: kmalloc -> 1118 cycles (280 ns/op), remote kfree -> 420 cycles (103 ns/op)
> ...
> ok 5 slab_test_remote_free
> # slab_test_alloc_n_free: size 8: 4 cpus, 30000 ops: kmalloc -> 902 cycles (223 ns/op), remote wait+kfree -> 2705 cycles (665 ns/op)
> ...
> ok 6 slab_test_alloc_n_free
> # slab: pass:6 fail:0 skip:0 total:6
> # Totals: pass:6 fail:0 skip:0 total:6
> ok 1 slab
>
> Signed-off-by: Christoph Lameter <cl@xxxxxxxxxx>
> Signed-off-by: David Rientjes <rientjes@xxxxxxxxxx>

In this case the co-developed-by should include Mathieu as well? And then
also S-o-b to be according to the rules?

...

> +
> +MODULE_LICENSE("GPL");
> +MODULE_AUTHOR("Christoph Lameter <cl@xxxxxxxxxx>");
> +MODULE_AUTHOR("Mathieu Desnoyers <mathieu.desnoyers@xxxxxxxxxxxx>");

^ because this

> +MODULE_AUTHOR("David Rientjes <rientjes@xxxxxxxxxx>");
> +MODULE_DESCRIPTION("KUnit benchmark test for the slab allocator");