mm/slab: introduce kvfree_rcu_barrier_on_cache() for cache destruction
Subsystems (4)
PATCH v3 1/1 mm/slab: introduce kvfree_rcu_barrier_on_cache() for cache destruction
Currently, kvfree_rcu_barrier() flushes RCU sheaves across all slab caches when a cache is destroyed. This is unnecessary; only the RCU sheaves belonging to the cache being destroyed need to be flushed.
As suggested by Vlastimil Babka, introduce a weaker form of kvfree_rcu_barrier() that operates on a specific slab cache.
Factor out flush_rcu_sheaves_on_cache() from flush_all_rcu_sheaves() and call it from flush_all_rcu_sheaves() and kvfree_rcu_barrier_on_cache().
Call kvfree_rcu_barrier_on_cache() instead of kvfree_rcu_barrier() on cache destruction.
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)
They are fixed by this change.
---
v2 -> v3:
- Addressed Suren's comment [1], thanks!
[1] https://lore.kernel.org/linux-mm/CAJuCfpE+g65Dm8-r=psDJQf_O1rfBG62DOzx4mE1mb+ottUKmQ@mail.gmail.com
include/linux/slab.h | 7 ++++++ mm/slab.h | 1 + mm/slab_common.c | 52 +++++++++++++++++++++++++++++------------ mm/slub.c | 55 ++++++++++++++++++++++++-------------------- 4 files changed, 75 insertions(+), 40 deletions(-)
include/linux/slab.h +7 -0
@@ -1150,10 +1150,17 @@ static inline void kvfree_rcu_barrier(void) rcu_barrier(); } +static inline void kvfree_rcu_barrier_on_cache (struct kmem_cache *s) +{ +rcu_barrier (); +} +static inline void kfree_rcu_scheduler_running (void ) { }#else void kvfree_rcu_barrier (void ); +void kvfree_rcu_barrier_on_cache (struct kmem_cache *s); +void kfree_rcu_scheduler_running (void );#endif
mm/slab.h +1 -0
@@ -422,6 +422,7 @@ static inline bool is_kmalloc_normal(struct kmem_cache *s)bool __kfree_rcu_sheaf (struct kmem_cache *s,void *obj);void flush_all_rcu_sheaves (void ); +void flush_rcu_sheaves_on_cache (struct kmem_cache *s);#define SLAB_CORE_FLAGS (SLAB_HWCACHE_ALIGN | SLAB_CACHE_DMA | \ SLAB_CACHE_DMA32 | SLAB_PANIC | \
mm/slab_common.c +37 -15
81 lines not on this page · raw message
mm/slub.c +30 -25
72 lines not on this page · raw message
Signature · 1 line
2.43.0
Quoted 41 lines · Harry Yoo
Currently,
kvfree_rcu_barrier()flushes RCU sheaves across all slab caches when a cache is destroyed. This is unnecessary; only the RCU sheaves belonging to the cache being destroyed need to be flushed.As suggested by Vlastimil Babka, introduce a weaker form of
kvfree_rcu_barrier()that operates on a specific slab cache.Factor out
flush_rcu_sheaves_on_cache()fromflush_all_rcu_sheaves()and call it fromflush_all_rcu_sheaves()andkvfree_rcu_barrier_on_cache().Call
kvfree_rcu_barrier_on_cache()instead ofkvfree_rcu_barrier()on cache destruction.The performance benefit is evaluated on a 12 core 24 threads AMD Ryzen 5900X machine (1 socket), by loading
slub_kunitmodule.Before:
Total calls: 19
Average latency (us): 18127
Total time (us): 344414After:
Total calls: 19
Average latency (us): 10066
Total time (us): 191264Two 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)They are fixed by this change.
Suggested-by Vlastimil Babka <[email protected]>Fixes ec66e0d59952 ("slab: add sheaf support for batching kfree_rcu() operations")Cc <[email protected]>Reported-and-tested-by Daniel Gomez <[email protected]>Reported-and-tested-by Jon Hunter <[email protected]>Signed-off-by Harry Yoo <[email protected]>
Quoted 4 lines
---
v2 -> v3:
- Addressed Suren's comment [1], thanks!
Thanks, replaced.