mm/slub: directly load freelist from cpu partial slab in the likely case
authorChengming Zhou <zhouchengming@bytedance.com>
Tue, 23 Jan 2024 09:33:29 +0000 (09:33 +0000)
committerVlastimil Babka <vbabka@suse.cz>
Tue, 23 Jan 2024 10:43:40 +0000 (11:43 +0100)
commit90b1e56641bbab801e22141c56aa79dc095a3764
tree7daef46f8995ad55f604c7658602663dcafe371b
parent6613476e225e090cc9aad49be7fa504e290dd33d
mm/slub: directly load freelist from cpu partial slab in the likely case

The likely case is that we get a usable slab from the cpu partial list,
we can directly load freelist from it and return back, instead of going
the other way that need more work, like reenable interrupt and recheck.

But we need to remove the "VM_BUG_ON(!new.frozen)" in get_freelist()
for reusing it, since cpu partial slab is not frozen. It seems
acceptable since it's only for debug purpose.

And get_freelist() also assumes it can return NULL if the freelist is
empty, which is not possible for the cpu partial slab case, so we
add "VM_BUG_ON(!freelist)" after get_freelist() to make it explicit.

There is some small performance improvement too, which shows by:
perf bench sched messaging -g 5 -t -l 100000

            mm-stable   slub-optimize
Total time      7.473    7.209

Signed-off-by: Chengming Zhou <zhouchengming@bytedance.com>
Reviewed-by: Vlastimil Babka <vbabka@suse.cz>
Signed-off-by: Vlastimil Babka <vbabka@suse.cz>
mm/slub.c