Re: [patch v4] mm: vmstat_kunit: add synthetic benchmark for vm stats

From: David Rientjes

Date: Sat Sep 26 2026 - 17:48:09 EST


On Fri, 18 Sep 2026, David Rientjes wrote:

> From: Christoph Lameter <cl@xxxxxxxxxx>
>
> Add a synthetic benchmark that can be used to measure performance of VM
> statistics. This is used to analyze any improvements or regressions in
> functions that are frequently used in hot code paths.
>
> The test is run by KUnit or doing modprobe vmstat_kunit directly.
>
> Sample output:
> KTAP version 1
> 1..1
> KTAP version 1
> # Subtest: vmstat
> # module: vmstat_kunit
> 1..3
> # vmstat_test_inc_dec_zone_page_state: 10000 ops: inc_zone_page_state -> 8 cycles (4 ns/op), dec_zone_page_state -> 9 cycles (4 ns/op)
> ok 1 vmstat_test_inc_dec_zone_page_state
> # vmstat_test_interleaved_zone_page_state: 10000 ops: inc/dec pair -> 17 cycles (8 ns/op)
> ok 2 vmstat_test_interleaved_zone_page_state
> # vmstat_test_count_vm_event: 10000 ops: count_vm_event -> 4 cycles (2 ns/op)
> ok 3 vmstat_test_count_vm_event
> # vmstat: pass:3 fail:0 skip:0 total:3
> # Totals: pass:3 fail:0 skip:0 total:3
> ok 1 vmstat
>
> Assisted-by: Gemini:gemini-3.8-flash
> Signed-off-by: Christoph Lameter <cl@xxxxxxxxxx>
> Signed-off-by: David Rientjes <rientjes@xxxxxxxxxx>
> ---
> v4:
> - included sample output in the commit description
> - switched to NR_MLOCK which is display only so no side effects
> - remove unnecessary "rem" variable
>
> Once we're happy with this change, I'll apply the same treatment to the
> proposed pgalloc and slab tests.
>

Andrew, let me know if there is any additional feedback for this one and
I'd be happy to integrate it. I've got the other two test cases converted
over to kunit tests as well per the feedback so will send this out as soon
as we're happy with this one. Thanks!