Skip to content

debugobjects: Rework object handling

Thomas Gleixner lkml 1 version Applied

Status from this message: The following commit has been merged into the core/debugobjects branch of tip:

Get series with b4
b4 am [email protected]

Versions newest first

  1. v1 Latest25 patches 33 repliesApplied

Patches in v1 Applied

#Subject and filesSizeRepliesApplied
1/25debugobjects: Delete a piece of redundant codelib/debugobjects.c+4 -40 replies
2/25debugobjects: Collect newly allocated objects in a list to reduce lock contentionlib/debugobjects.c+10 -80 replies
3/25debugobjects: Dont destroy kmem cache in init()lib/debugobjects.c+35 -335 replies
4/25debugobjects: Remove pointless hlist initializationlib/debugobjects.c+1 -101 reply
5/25debugobjects: Dont free objects directly on CPU hotpluglib/debugobjects.c+14 -131 reply
6/25debugobjects: Reuse put_objects() on OOMlib/debugobjects.c+7 -191 reply
7/25debugobjects: Remove pointless debug printklib/debugobjects.c+1 -41 reply
8/25debugobjects: Provide and use free_object_list()lib/debugobjects.c+16 -62 replies
9/25debugobjects: Make debug_objects_enabled boollib/debugobjects.c+8 -91 reply
10/25debugobjects: Reduce parallel pool fill attemptslib/debugobjects.c+59 -250 replies
11/25debugobjects: Move pools into a datastructurelib/debugobjects.c+78 -621 reply
12/25debugobjects: Use separate list head for boot poollib/debugobjects.c+16 -121 reply
13/25debugobjects: Rename and tidy up per CPU poolslib/debugobjects.c+17 -261 reply
14/25debugobjects: Move min/max count into pool structlib/debugobjects.c+31 -241 reply
15/25debugobjects: Rework object allocationlib/debugobjects.c+69 -751 reply
16/25debugobjects: Rework object freeinglib/debugobjects.c+24 -751 reply
17/25debugobjects: Rework free_object_work()lib/debugobjects.c+38 -421 reply
18/25debugobjects: Use static key for boot pool selectionlib/debugobjects.c+11 -81 reply
19/25debugobjects: Prepare for batchinginclude/linux/debugobjects.h lib/debugobjects.c+15 -71 reply
20/25debugobjects: Prepare kmem_cache allocations for batchinglib/debugobjects.c+49 -313 replies
21/25debugobjects: Implement batch processinglib/debugobjects.c+46 -152 replies
22/25debugobjects: Move pool statistics into global_pool structlib/debugobjects.c+51 -341 reply
23/25debugobjects: Double the per CPU slotslib/debugobjects.c+1 -11 reply
24/25debugobjects: Refill per CPU pool more agressivelylib/debugobjects.c+18 -02 replies
25/25debugobjects: Track object usage to avoid premature freeing of objectslib/debugobjects.c+57 -53 replies

Reviews trailers per patch

19 of 25 patches have a Reviewed-by or Acked-by.

PatchZhen Lei
1/25
2/25
3/25
4/25R-b
5/25R-b
6/25R-b
7/25R-b
8/25
9/25R-b
10/25
11/25R-b
12/25R-b
13/25R-b
14/25R-b
15/25R-b
16/25R-b
17/25R-b
18/25R-b
19/25R-b
20/25
21/25R-b
22/25R-b
23/25R-b
24/25R-b
25/25R-b

Trailers given in replies are filled; those carried in the patches from earlier versions are outlined with dashes.

Read the v1 thread

Cover letter [patch 00/25] debugobjects: Rework object handling

Zhen reported that the global lock in debug objects is problematic. There are several issues:

1) Parallel pool refill attempts result in long wait times

2) The operations under the lock move batches of objects by moving them one by one from one list to another

This takes quite some time and is also a cache line dirtying festival.

For further context see:

https://lore.kernel.org/all/[email protected]
https://lore.kernel.org/all/[email protected]

Address this with the following changes:

1) Avoid parallel pool refills unless the fill level is critical

2) Release and reacquire the pool look between batches in the worker thread.

3) Convert the pool handling to a stack of batches which can be moved with trivial hlist operations which are fast and do not touch a gazillion of cache lines

While working on this, I noticed that the kmem_cache allocation/free rate is rather high. This is addressed by:

1) Doubling the per CPU pool size

2) Agressively refilling the per CPU pool from the free list

3) Throttling the kmem_cache_free() operations by monitoring the object usage with a exponentially wheighed moving average

The resulting reduction for a full kernel compile:

kmem_cache_alloc() kmem_cache_free()
Base: 380k 330k

#1:   295k			245k      
#2:   225k			245k
#3:   170k			117k

Especially the reduction of allocations makes a difference as that happens in the hot path.

There are further possibilities to enhance this:

1) Move the lock into the new global pool data structure
2) Provide a per-node "global" pool which is brought up before the first CPU of a node is brought up

That's left as an exercise for the reader. :)

The series has incorporated the latest changes from Zhen:

https://lore.kernel.org/all/[email protected]

to avoid conflicts.

It is based on v6.12-rc1 and also available from git:

git://git.kernel.org/pub/scm/linux/kernel/git/tglx/devel.git core/debugobjects

Thanks,

tglx

---
 include/linux/debugobjects.h |   12 
 lib/debugobjects.c           |  866 ++++++++++++++++++++++++-------------------
 2 files changed, 503 insertions(+), 375 deletions(-)