Skip to content

Commit 74fe1ad

Browse files
committed
debugobjects: Prepare for batching
Move the debug_obj::object pointer into a union and add a pointer to the last node in a batch. That allows to implement batch processing efficiently by utilizing the stack property of hlist: When the first object of a batch is added to the list, then the batch pointer is set to the hlist node of the object itself. Any subsequent add retrieves the pointer to the last node from the first object in the list and uses that for storing the last node pointer in the newly added object. Add the pointer to the data structure and ensure that all relevant pool sizes are strictly batch sized. The actual batching implementation follows in subsequent changes. Signed-off-by: Thomas Gleixner <tglx@linutronix.de> Reviewed-by: Zhen Lei <thunder.leizhen@huawei.com> Link: https://lore.kernel.org/all/20241007164914.139204961@linutronix.de
1 parent 14077b9 commit 74fe1ad

File tree

2 files changed

+15
-7
lines changed

2 files changed

+15
-7
lines changed

include/linux/debugobjects.h

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,13 +23,17 @@ struct debug_obj_descr;
2323
* @state: tracked object state
2424
* @astate: current active state
2525
* @object: pointer to the real object
26+
* @batch_last: pointer to the last hlist node in a batch
2627
* @descr: pointer to an object type specific debug description structure
2728
*/
2829
struct debug_obj {
29-
struct hlist_node node;
30-
enum debug_obj_state state;
31-
unsigned int astate;
32-
void *object;
30+
struct hlist_node node;
31+
enum debug_obj_state state;
32+
unsigned int astate;
33+
union {
34+
void *object;
35+
struct hlist_node *batch_last;
36+
};
3337
const struct debug_obj_descr *descr;
3438
};
3539

lib/debugobjects.c

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,11 +21,15 @@
2121
#define ODEBUG_HASH_BITS 14
2222
#define ODEBUG_HASH_SIZE (1 << ODEBUG_HASH_BITS)
2323

24-
#define ODEBUG_POOL_SIZE 1024
25-
#define ODEBUG_POOL_MIN_LEVEL 256
26-
#define ODEBUG_POOL_PERCPU_SIZE 64
24+
/* Must be power of two */
2725
#define ODEBUG_BATCH_SIZE 16
2826

27+
/* Initial values. Must all be a multiple of batch size */
28+
#define ODEBUG_POOL_SIZE (64 * ODEBUG_BATCH_SIZE)
29+
#define ODEBUG_POOL_MIN_LEVEL (ODEBUG_POOL_SIZE / 4)
30+
31+
#define ODEBUG_POOL_PERCPU_SIZE (4 * ODEBUG_BATCH_SIZE)
32+
2933
#define ODEBUG_CHUNK_SHIFT PAGE_SHIFT
3034
#define ODEBUG_CHUNK_SIZE (1 << ODEBUG_CHUNK_SHIFT)
3135
#define ODEBUG_CHUNK_MASK (~(ODEBUG_CHUNK_SIZE - 1))

0 commit comments

Comments
 (0)