
A performance fix has been submitted to the Linux kernel for dealing with a regression in the Slab memory allocation code.
The sole patch with today’s slab pull request for Linux 6.19 and to be back-ported to Linux 6.18 LTS stable is fixing a performance regression for code involving heavy kmem_cache_destroy() usage.
The kmem_cache_destroy() calls kvfree_rcu_barrier() that ends up flushing RCU sheaves across all slab caches when a cache is destroyed. But that isn’t mnecessary with only the RCU sheaves belonging to the cache being destroy should need to be flushed. This stable fix introduces kvfree_rcu_barrier_on_…

A performance fix has been submitted to the Linux kernel for dealing with a regression in the Slab memory allocation code.
The sole patch with today’s slab pull request for Linux 6.19 and to be back-ported to Linux 6.18 LTS stable is fixing a performance regression for code involving heavy kmem_cache_destroy() usage.
The kmem_cache_destroy() calls kvfree_rcu_barrier() that ends up flushing RCU sheaves across all slab caches when a cache is destroyed. But that isn’t mnecessary with only the RCU sheaves belonging to the cache being destroy should need to be flushed. This stable fix introduces kvfree_rcu_barrier_on_cache() to be more selective about the sheaves being flushed so only the relevant ones are removed.
This new code is now faster and addresses some known performance regressions in the kernel code:
The performance benefit is evaluated on a 12 core 24 threads AMD Ryzen 5900X machine (1 socket), by loading slub_kunit module.
Before: Total calls: 19 Average latency (us): 18127 Total time (us): 344414
After: Total calls: 19 Average latency (us): 10066 Total time (us): 191264
Two performance regression have been reported:
- stress module loader test’s runtime increases by 50-60% (Daniel)
- internal graphics test’s runtime on Tegra23 increases by 35% (Jon)
The performance regression was introduced back in Linux 6.18-rc1 with the introduction of sheaves and persisted through the Linux 6.18 stable release. In the days ahead this patch should be back-ported to a stable Linux 6.18 point release.