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: Rename and tidy up per CPU pools

No point in having a separate data structure. Reuse struct obj_pool and
tidy up the code.

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

+17 -26
+17 -26
lib/debugobjects.c
··· 43 43 raw_spinlock_t lock; 44 44 }; 45 45 46 - /* 47 - * Debug object percpu free list 48 - * Access is protected by disabling irq 49 - */ 50 - struct debug_percpu_free { 51 - struct hlist_head free_objs; 52 - int obj_free; 53 - }; 54 - 55 46 struct obj_pool { 56 47 struct hlist_head objects; 57 48 unsigned int cnt; 58 49 } ____cacheline_aligned; 59 50 60 - static DEFINE_PER_CPU(struct debug_percpu_free, percpu_obj_pool); 51 + static DEFINE_PER_CPU(struct obj_pool, pool_pcpu); 61 52 62 53 static struct debug_bucket obj_hash[ODEBUG_HASH_SIZE]; 63 54 ··· 262 271 static struct debug_obj * 263 272 alloc_object(void *addr, struct debug_bucket *b, const struct debug_obj_descr *descr) 264 273 { 265 - struct debug_percpu_free *percpu_pool = this_cpu_ptr(&percpu_obj_pool); 274 + struct obj_pool *percpu_pool = this_cpu_ptr(&pool_pcpu); 266 275 struct debug_obj *obj; 267 276 268 277 if (likely(obj_cache)) { 269 - obj = __alloc_object(&percpu_pool->free_objs); 278 + obj = __alloc_object(&percpu_pool->objects); 270 279 if (obj) { 271 - percpu_pool->obj_free--; 280 + percpu_pool->cnt--; 272 281 goto init_obj; 273 282 } 274 283 } else { ··· 295 304 obj2 = __alloc_object(&pool_global.objects); 296 305 if (!obj2) 297 306 break; 298 - hlist_add_head(&obj2->node, &percpu_pool->free_objs); 299 - percpu_pool->obj_free++; 307 + hlist_add_head(&obj2->node, &percpu_pool->objects); 308 + percpu_pool->cnt++; 300 309 obj_pool_used++; 301 310 WRITE_ONCE(pool_global.cnt, pool_global.cnt - 1); 302 311 } ··· 375 384 static void __free_object(struct debug_obj *obj) 376 385 { 377 386 struct debug_obj *objs[ODEBUG_BATCH_SIZE]; 378 - struct debug_percpu_free *percpu_pool; 387 + struct obj_pool *percpu_pool; 379 388 int lookahead_count = 0; 380 389 bool work; 381 390 ··· 389 398 /* 390 399 * Try to free it into the percpu pool first. 391 400 */ 392 - percpu_pool = this_cpu_ptr(&percpu_obj_pool); 393 - if (percpu_pool->obj_free < ODEBUG_POOL_PERCPU_SIZE) { 394 - hlist_add_head(&obj->node, &percpu_pool->free_objs); 395 - percpu_pool->obj_free++; 401 + percpu_pool = this_cpu_ptr(&pool_pcpu); 402 + if (percpu_pool->cnt < ODEBUG_POOL_PERCPU_SIZE) { 403 + hlist_add_head(&obj->node, &percpu_pool->objects); 404 + percpu_pool->cnt++; 396 405 return; 397 406 } 398 407 ··· 401 410 * of objects from the percpu pool and free them as well. 402 411 */ 403 412 for (; lookahead_count < ODEBUG_BATCH_SIZE; lookahead_count++) { 404 - objs[lookahead_count] = __alloc_object(&percpu_pool->free_objs); 413 + objs[lookahead_count] = __alloc_object(&percpu_pool->objects); 405 414 if (!objs[lookahead_count]) 406 415 break; 407 - percpu_pool->obj_free--; 416 + percpu_pool->cnt--; 408 417 } 409 418 410 419 raw_spin_lock(&pool_lock); ··· 485 494 static int object_cpu_offline(unsigned int cpu) 486 495 { 487 496 /* Remote access is safe as the CPU is dead already */ 488 - struct debug_percpu_free *pcp = per_cpu_ptr(&percpu_obj_pool, cpu); 497 + struct obj_pool *pcp = per_cpu_ptr(&pool_pcpu, cpu); 489 498 490 - put_objects(&pcp->free_objs); 491 - pcp->obj_free = 0; 499 + put_objects(&pcp->objects); 500 + pcp->cnt = 0; 492 501 return 0; 493 502 } 494 503 #endif ··· 1067 1076 int cpu, obj_percpu_free = 0; 1068 1077 1069 1078 for_each_possible_cpu(cpu) 1070 - obj_percpu_free += per_cpu(percpu_obj_pool.obj_free, cpu); 1079 + obj_percpu_free += per_cpu(pool_pcpu.cnt, cpu); 1071 1080 1072 1081 seq_printf(m, "max_chain :%d\n", debug_objects_maxchain); 1073 1082 seq_printf(m, "max_checked :%d\n", debug_objects_maxchecked);