]> www.infradead.org Git - users/hch/misc.git/commit
debugobjects: Track object usage to avoid premature freeing of objects
authorThomas Gleixner <tglx@linutronix.de>
Sun, 13 Oct 2024 18:45:57 +0000 (20:45 +0200)
committerThomas Gleixner <tglx@linutronix.de>
Tue, 15 Oct 2024 15:30:33 +0000 (17:30 +0200)
commitff8d523cc4520a5ce86cde0fd57c304e2b4f61b3
tree9c4775caac92aa7d5d2f52a11ba88c76a729ca69
parent13f9ca723900ae3ae8e0a1e76ba86e7786e60645
debugobjects: Track object usage to avoid premature freeing of objects

The freelist is freed at a constant rate independent of the actual usage
requirements. That's bad in scenarios where usage comes in bursts. The end
of a burst puts the objects on the free list and freeing proceeds even when
the next burst which requires objects started again.

Keep track of the usage with a exponentially wheighted moving average and
take that into account in the worker function which frees objects from the
free list.

This further reduces the kmem_cache allocation/free rate for a full kernel
compile:

        kmem_cache_alloc() kmem_cache_free()
Baseline:   225k 173k
Usage:     170k 117k

Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Reviewed-by: Zhen Lei <thunder.leizhen@huawei.com>
Link: https://lore.kernel.org/all/87bjznhme2.ffs@tglx
lib/debugobjects.c