Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

debugobjects: Use separate list head for boot pool

There is no point to handle the statically allocated objects during early
boot in the actual pool list. This phase does not require accounting, so
all of the related complexity can be avoided.

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

+16 -12
+16 -12
lib/debugobjects.c
··· 68 68 static struct obj_pool pool_global; 69 69 static struct obj_pool pool_to_free; 70 70 71 + static HLIST_HEAD(pool_boot); 72 + 71 73 /* 72 74 * Because of the presence of percpu free pools, obj_pool_free will 73 75 * under-count those in the percpu free pools. Similarly, obj_pool_used ··· 280 278 percpu_pool->obj_free--; 281 279 goto init_obj; 282 280 } 281 + } else { 282 + obj = __alloc_object(&pool_boot); 283 + goto init_obj; 283 284 } 284 285 285 286 raw_spin_lock(&pool_lock); ··· 386 381 struct debug_obj *objs[ODEBUG_BATCH_SIZE]; 387 382 struct debug_percpu_free *percpu_pool; 388 383 int lookahead_count = 0; 389 - unsigned long flags; 390 384 bool work; 391 385 392 - local_irq_save(flags); 393 - if (!obj_cache) 394 - goto free_to_obj_pool; 386 + guard(irqsave)(); 387 + 388 + if (unlikely(!obj_cache)) { 389 + hlist_add_head(&obj->node, &pool_boot); 390 + return; 391 + } 395 392 396 393 /* 397 394 * Try to free it into the percpu pool first. ··· 402 395 if (percpu_pool->obj_free < ODEBUG_POOL_PERCPU_SIZE) { 403 396 hlist_add_head(&obj->node, &percpu_pool->free_objs); 404 397 percpu_pool->obj_free++; 405 - local_irq_restore(flags); 406 398 return; 407 399 } 408 400 ··· 416 410 percpu_pool->obj_free--; 417 411 } 418 412 419 - free_to_obj_pool: 420 413 raw_spin_lock(&pool_lock); 421 414 work = (pool_global.cnt > debug_objects_pool_size) && obj_cache && 422 415 (pool_to_free.cnt < ODEBUG_FREE_WORK_MAX); ··· 460 455 } 461 456 } 462 457 raw_spin_unlock(&pool_lock); 463 - local_irq_restore(flags); 464 458 } 465 459 466 460 /* ··· 1345 1341 for (i = 0; i < ODEBUG_HASH_SIZE; i++) 1346 1342 raw_spin_lock_init(&obj_hash[i].lock); 1347 1343 1344 + /* Keep early boot simple and add everything to the boot list */ 1348 1345 for (i = 0; i < ODEBUG_POOL_SIZE; i++) 1349 - hlist_add_head(&obj_static_pool[i].node, &pool_global.objects); 1350 - 1351 - pool_global.cnt = ODEBUG_POOL_SIZE; 1346 + hlist_add_head(&obj_static_pool[i].node, &pool_boot); 1352 1347 } 1353 1348 1354 1349 /* ··· 1375 1372 pool_global.cnt = ODEBUG_POOL_SIZE; 1376 1373 1377 1374 /* 1378 - * Replace the statically allocated objects list with the allocated 1379 - * objects list. 1375 + * Move the allocated objects to the global pool and disconnect the 1376 + * boot pool. 1380 1377 */ 1381 1378 hlist_move_list(&objects, &pool_global.objects); 1379 + pool_boot.first = NULL; 1382 1380 1383 1381 /* Replace the active object references */ 1384 1382 for (i = 0; i < ODEBUG_HASH_SIZE; i++, db++) {