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

Merge branch 'core-debugobjects-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip

Pull debugobjects updates from Thomas Gleixner:
"A set of updates for debugobjects:

- A series of changes to make debugobjects more scalable by
introducing per cpu pools and reducing the number of lock
acquisitions

- debugfs cleanup"

* 'core-debugobjects-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip:
debugobjects: Move printk out of db->lock critical sections
debugobjects: Less aggressive freeing of excess debug objects
debugobjects: Reduce number of pool_lock acquisitions in fill_pool()
debugobjects: Percpu pool lookahead freeing/allocation
debugobjects: Add percpu free pools
debugobjects: No need to check return value of debugfs_create()

+254 -69
+254 -69
lib/debugobjects.c
··· 25 25 26 26 #define ODEBUG_POOL_SIZE 1024 27 27 #define ODEBUG_POOL_MIN_LEVEL 256 28 + #define ODEBUG_POOL_PERCPU_SIZE 64 29 + #define ODEBUG_BATCH_SIZE 16 28 30 29 31 #define ODEBUG_CHUNK_SHIFT PAGE_SHIFT 30 32 #define ODEBUG_CHUNK_SIZE (1 << ODEBUG_CHUNK_SHIFT) 31 33 #define ODEBUG_CHUNK_MASK (~(ODEBUG_CHUNK_SIZE - 1)) 32 34 35 + /* 36 + * We limit the freeing of debug objects via workqueue at a maximum 37 + * frequency of 10Hz and about 1024 objects for each freeing operation. 38 + * So it is freeing at most 10k debug objects per second. 39 + */ 40 + #define ODEBUG_FREE_WORK_MAX 1024 41 + #define ODEBUG_FREE_WORK_DELAY DIV_ROUND_UP(HZ, 10) 42 + 33 43 struct debug_bucket { 34 44 struct hlist_head list; 35 45 raw_spinlock_t lock; 36 46 }; 47 + 48 + /* 49 + * Debug object percpu free list 50 + * Access is protected by disabling irq 51 + */ 52 + struct debug_percpu_free { 53 + struct hlist_head free_objs; 54 + int obj_free; 55 + }; 56 + 57 + static DEFINE_PER_CPU(struct debug_percpu_free, percpu_obj_pool); 37 58 38 59 static struct debug_bucket obj_hash[ODEBUG_HASH_SIZE]; 39 60 ··· 65 44 static HLIST_HEAD(obj_pool); 66 45 static HLIST_HEAD(obj_to_free); 67 46 47 + /* 48 + * Because of the presence of percpu free pools, obj_pool_free will 49 + * under-count those in the percpu free pools. Similarly, obj_pool_used 50 + * will over-count those in the percpu free pools. Adjustments will be 51 + * made at debug_stats_show(). Both obj_pool_min_free and obj_pool_max_used 52 + * can be off. 53 + */ 68 54 static int obj_pool_min_free = ODEBUG_POOL_SIZE; 69 55 static int obj_pool_free = ODEBUG_POOL_SIZE; 70 56 static int obj_pool_used; 71 57 static int obj_pool_max_used; 58 + static bool obj_freeing; 72 59 /* The number of objs on the global free list */ 73 60 static int obj_nr_tofree; 74 - static struct kmem_cache *obj_cache; 75 61 76 62 static int debug_objects_maxchain __read_mostly; 77 63 static int __maybe_unused debug_objects_maxchecked __read_mostly; ··· 91 63 static int debug_objects_pool_min_level __read_mostly 92 64 = ODEBUG_POOL_MIN_LEVEL; 93 65 static struct debug_obj_descr *descr_test __read_mostly; 66 + static struct kmem_cache *obj_cache __read_mostly; 94 67 95 68 /* 96 69 * Track numbers of kmem_cache_alloc()/free() calls done. ··· 100 71 static int debug_objects_freed; 101 72 102 73 static void free_obj_work(struct work_struct *work); 103 - static DECLARE_WORK(debug_obj_work, free_obj_work); 74 + static DECLARE_DELAYED_WORK(debug_obj_work, free_obj_work); 104 75 105 76 static int __init enable_object_debug(char *str) 106 77 { ··· 129 100 static void fill_pool(void) 130 101 { 131 102 gfp_t gfp = GFP_ATOMIC | __GFP_NORETRY | __GFP_NOWARN; 132 - struct debug_obj *new, *obj; 103 + struct debug_obj *obj; 133 104 unsigned long flags; 134 105 135 106 if (likely(obj_pool_free >= debug_objects_pool_min_level)) ··· 145 116 * Recheck with the lock held as the worker thread might have 146 117 * won the race and freed the global free list already. 147 118 */ 148 - if (obj_nr_tofree) { 119 + while (obj_nr_tofree && (obj_pool_free < obj_pool_min_free)) { 149 120 obj = hlist_entry(obj_to_free.first, typeof(*obj), node); 150 121 hlist_del(&obj->node); 151 122 obj_nr_tofree--; ··· 159 130 return; 160 131 161 132 while (obj_pool_free < debug_objects_pool_min_level) { 133 + struct debug_obj *new[ODEBUG_BATCH_SIZE]; 134 + int cnt; 162 135 163 - new = kmem_cache_zalloc(obj_cache, gfp); 164 - if (!new) 136 + for (cnt = 0; cnt < ODEBUG_BATCH_SIZE; cnt++) { 137 + new[cnt] = kmem_cache_zalloc(obj_cache, gfp); 138 + if (!new[cnt]) 139 + break; 140 + } 141 + if (!cnt) 165 142 return; 166 143 167 144 raw_spin_lock_irqsave(&pool_lock, flags); 168 - hlist_add_head(&new->node, &obj_pool); 169 - debug_objects_allocated++; 170 - obj_pool_free++; 145 + while (cnt) { 146 + hlist_add_head(&new[--cnt]->node, &obj_pool); 147 + debug_objects_allocated++; 148 + obj_pool_free++; 149 + } 171 150 raw_spin_unlock_irqrestore(&pool_lock, flags); 172 151 } 173 152 } ··· 200 163 } 201 164 202 165 /* 166 + * Allocate a new object from the hlist 167 + */ 168 + static struct debug_obj *__alloc_object(struct hlist_head *list) 169 + { 170 + struct debug_obj *obj = NULL; 171 + 172 + if (list->first) { 173 + obj = hlist_entry(list->first, typeof(*obj), node); 174 + hlist_del(&obj->node); 175 + } 176 + 177 + return obj; 178 + } 179 + 180 + /* 203 181 * Allocate a new object. If the pool is empty, switch off the debugger. 204 182 * Must be called with interrupts disabled. 205 183 */ 206 184 static struct debug_obj * 207 185 alloc_object(void *addr, struct debug_bucket *b, struct debug_obj_descr *descr) 208 186 { 209 - struct debug_obj *obj = NULL; 187 + struct debug_percpu_free *percpu_pool = this_cpu_ptr(&percpu_obj_pool); 188 + struct debug_obj *obj; 189 + 190 + if (likely(obj_cache)) { 191 + obj = __alloc_object(&percpu_pool->free_objs); 192 + if (obj) { 193 + percpu_pool->obj_free--; 194 + goto init_obj; 195 + } 196 + } 210 197 211 198 raw_spin_lock(&pool_lock); 212 - if (obj_pool.first) { 213 - obj = hlist_entry(obj_pool.first, typeof(*obj), node); 214 - 215 - obj->object = addr; 216 - obj->descr = descr; 217 - obj->state = ODEBUG_STATE_NONE; 218 - obj->astate = 0; 219 - hlist_del(&obj->node); 220 - 221 - hlist_add_head(&obj->node, &b->list); 222 - 199 + obj = __alloc_object(&obj_pool); 200 + if (obj) { 223 201 obj_pool_used++; 202 + obj_pool_free--; 203 + 204 + /* 205 + * Looking ahead, allocate one batch of debug objects and 206 + * put them into the percpu free pool. 207 + */ 208 + if (likely(obj_cache)) { 209 + int i; 210 + 211 + for (i = 0; i < ODEBUG_BATCH_SIZE; i++) { 212 + struct debug_obj *obj2; 213 + 214 + obj2 = __alloc_object(&obj_pool); 215 + if (!obj2) 216 + break; 217 + hlist_add_head(&obj2->node, 218 + &percpu_pool->free_objs); 219 + percpu_pool->obj_free++; 220 + obj_pool_used++; 221 + obj_pool_free--; 222 + } 223 + } 224 + 224 225 if (obj_pool_used > obj_pool_max_used) 225 226 obj_pool_max_used = obj_pool_used; 226 227 227 - obj_pool_free--; 228 228 if (obj_pool_free < obj_pool_min_free) 229 229 obj_pool_min_free = obj_pool_free; 230 230 } 231 231 raw_spin_unlock(&pool_lock); 232 232 233 + init_obj: 234 + if (obj) { 235 + obj->object = addr; 236 + obj->descr = descr; 237 + obj->state = ODEBUG_STATE_NONE; 238 + obj->astate = 0; 239 + hlist_add_head(&obj->node, &b->list); 240 + } 233 241 return obj; 234 242 } 235 243 ··· 291 209 unsigned long flags; 292 210 HLIST_HEAD(tofree); 293 211 212 + WRITE_ONCE(obj_freeing, false); 294 213 if (!raw_spin_trylock_irqsave(&pool_lock, flags)) 295 214 return; 215 + 216 + if (obj_pool_free >= debug_objects_pool_size) 217 + goto free_objs; 296 218 297 219 /* 298 220 * The objs on the pool list might be allocated before the work is 299 221 * run, so recheck if pool list it full or not, if not fill pool 300 - * list from the global free list 222 + * list from the global free list. As it is likely that a workload 223 + * may be gearing up to use more and more objects, don't free any 224 + * of them until the next round. 301 225 */ 302 226 while (obj_nr_tofree && obj_pool_free < debug_objects_pool_size) { 303 227 obj = hlist_entry(obj_to_free.first, typeof(*obj), node); ··· 312 224 obj_pool_free++; 313 225 obj_nr_tofree--; 314 226 } 227 + raw_spin_unlock_irqrestore(&pool_lock, flags); 228 + return; 315 229 230 + free_objs: 316 231 /* 317 232 * Pool list is already full and there are still objs on the free 318 233 * list. Move remaining free objs to a temporary list to free the ··· 334 243 } 335 244 } 336 245 337 - static bool __free_object(struct debug_obj *obj) 246 + static void __free_object(struct debug_obj *obj) 338 247 { 248 + struct debug_obj *objs[ODEBUG_BATCH_SIZE]; 249 + struct debug_percpu_free *percpu_pool; 250 + int lookahead_count = 0; 339 251 unsigned long flags; 340 252 bool work; 341 253 342 - raw_spin_lock_irqsave(&pool_lock, flags); 343 - work = (obj_pool_free > debug_objects_pool_size) && obj_cache; 254 + local_irq_save(flags); 255 + if (!obj_cache) 256 + goto free_to_obj_pool; 257 + 258 + /* 259 + * Try to free it into the percpu pool first. 260 + */ 261 + percpu_pool = this_cpu_ptr(&percpu_obj_pool); 262 + if (percpu_pool->obj_free < ODEBUG_POOL_PERCPU_SIZE) { 263 + hlist_add_head(&obj->node, &percpu_pool->free_objs); 264 + percpu_pool->obj_free++; 265 + local_irq_restore(flags); 266 + return; 267 + } 268 + 269 + /* 270 + * As the percpu pool is full, look ahead and pull out a batch 271 + * of objects from the percpu pool and free them as well. 272 + */ 273 + for (; lookahead_count < ODEBUG_BATCH_SIZE; lookahead_count++) { 274 + objs[lookahead_count] = __alloc_object(&percpu_pool->free_objs); 275 + if (!objs[lookahead_count]) 276 + break; 277 + percpu_pool->obj_free--; 278 + } 279 + 280 + free_to_obj_pool: 281 + raw_spin_lock(&pool_lock); 282 + work = (obj_pool_free > debug_objects_pool_size) && obj_cache && 283 + (obj_nr_tofree < ODEBUG_FREE_WORK_MAX); 344 284 obj_pool_used--; 345 285 346 286 if (work) { 347 287 obj_nr_tofree++; 348 288 hlist_add_head(&obj->node, &obj_to_free); 289 + if (lookahead_count) { 290 + obj_nr_tofree += lookahead_count; 291 + obj_pool_used -= lookahead_count; 292 + while (lookahead_count) { 293 + hlist_add_head(&objs[--lookahead_count]->node, 294 + &obj_to_free); 295 + } 296 + } 297 + 298 + if ((obj_pool_free > debug_objects_pool_size) && 299 + (obj_nr_tofree < ODEBUG_FREE_WORK_MAX)) { 300 + int i; 301 + 302 + /* 303 + * Free one more batch of objects from obj_pool. 304 + */ 305 + for (i = 0; i < ODEBUG_BATCH_SIZE; i++) { 306 + obj = __alloc_object(&obj_pool); 307 + hlist_add_head(&obj->node, &obj_to_free); 308 + obj_pool_free--; 309 + obj_nr_tofree++; 310 + } 311 + } 349 312 } else { 350 313 obj_pool_free++; 351 314 hlist_add_head(&obj->node, &obj_pool); 315 + if (lookahead_count) { 316 + obj_pool_free += lookahead_count; 317 + obj_pool_used -= lookahead_count; 318 + while (lookahead_count) { 319 + hlist_add_head(&objs[--lookahead_count]->node, 320 + &obj_pool); 321 + } 322 + } 352 323 } 353 - raw_spin_unlock_irqrestore(&pool_lock, flags); 354 - return work; 324 + raw_spin_unlock(&pool_lock); 325 + local_irq_restore(flags); 355 326 } 356 327 357 328 /* ··· 422 269 */ 423 270 static void free_object(struct debug_obj *obj) 424 271 { 425 - if (__free_object(obj)) 426 - schedule_work(&debug_obj_work); 272 + __free_object(obj); 273 + if (!obj_freeing && obj_nr_tofree) { 274 + WRITE_ONCE(obj_freeing, true); 275 + schedule_delayed_work(&debug_obj_work, ODEBUG_FREE_WORK_DELAY); 276 + } 427 277 } 428 278 429 279 /* ··· 528 372 __debug_object_init(void *addr, struct debug_obj_descr *descr, int onstack) 529 373 { 530 374 enum debug_obj_state state; 375 + bool check_stack = false; 531 376 struct debug_bucket *db; 532 377 struct debug_obj *obj; 533 378 unsigned long flags; ··· 548 391 debug_objects_oom(); 549 392 return; 550 393 } 551 - debug_object_is_on_stack(addr, onstack); 394 + check_stack = true; 552 395 } 553 396 554 397 switch (obj->state) { ··· 559 402 break; 560 403 561 404 case ODEBUG_STATE_ACTIVE: 562 - debug_print_object(obj, "init"); 563 405 state = obj->state; 564 406 raw_spin_unlock_irqrestore(&db->lock, flags); 407 + debug_print_object(obj, "init"); 565 408 debug_object_fixup(descr->fixup_init, addr, state); 566 409 return; 567 410 568 411 case ODEBUG_STATE_DESTROYED: 412 + raw_spin_unlock_irqrestore(&db->lock, flags); 569 413 debug_print_object(obj, "init"); 570 - break; 414 + return; 571 415 default: 572 416 break; 573 417 } 574 418 575 419 raw_spin_unlock_irqrestore(&db->lock, flags); 420 + if (check_stack) 421 + debug_object_is_on_stack(addr, onstack); 576 422 } 577 423 578 424 /** ··· 633 473 634 474 obj = lookup_object(addr, db); 635 475 if (obj) { 476 + bool print_object = false; 477 + 636 478 switch (obj->state) { 637 479 case ODEBUG_STATE_INIT: 638 480 case ODEBUG_STATE_INACTIVE: ··· 643 481 break; 644 482 645 483 case ODEBUG_STATE_ACTIVE: 646 - debug_print_object(obj, "activate"); 647 484 state = obj->state; 648 485 raw_spin_unlock_irqrestore(&db->lock, flags); 486 + debug_print_object(obj, "activate"); 649 487 ret = debug_object_fixup(descr->fixup_activate, addr, state); 650 488 return ret ? 0 : -EINVAL; 651 489 652 490 case ODEBUG_STATE_DESTROYED: 653 - debug_print_object(obj, "activate"); 491 + print_object = true; 654 492 ret = -EINVAL; 655 493 break; 656 494 default: ··· 658 496 break; 659 497 } 660 498 raw_spin_unlock_irqrestore(&db->lock, flags); 499 + if (print_object) 500 + debug_print_object(obj, "activate"); 661 501 return ret; 662 502 } 663 503 664 504 raw_spin_unlock_irqrestore(&db->lock, flags); 505 + 665 506 /* 666 507 * We are here when a static object is activated. We 667 508 * let the type specific code confirm whether this is ··· 696 531 struct debug_bucket *db; 697 532 struct debug_obj *obj; 698 533 unsigned long flags; 534 + bool print_object = false; 699 535 700 536 if (!debug_objects_enabled) 701 537 return; ··· 714 548 if (!obj->astate) 715 549 obj->state = ODEBUG_STATE_INACTIVE; 716 550 else 717 - debug_print_object(obj, "deactivate"); 551 + print_object = true; 718 552 break; 719 553 720 554 case ODEBUG_STATE_DESTROYED: 721 - debug_print_object(obj, "deactivate"); 555 + print_object = true; 722 556 break; 723 557 default: 724 558 break; 725 559 } 726 - } else { 560 + } 561 + 562 + raw_spin_unlock_irqrestore(&db->lock, flags); 563 + if (!obj) { 727 564 struct debug_obj o = { .object = addr, 728 565 .state = ODEBUG_STATE_NOTAVAILABLE, 729 566 .descr = descr }; 730 567 731 568 debug_print_object(&o, "deactivate"); 569 + } else if (print_object) { 570 + debug_print_object(obj, "deactivate"); 732 571 } 733 - 734 - raw_spin_unlock_irqrestore(&db->lock, flags); 735 572 } 736 573 EXPORT_SYMBOL_GPL(debug_object_deactivate); 737 574 ··· 749 580 struct debug_bucket *db; 750 581 struct debug_obj *obj; 751 582 unsigned long flags; 583 + bool print_object = false; 752 584 753 585 if (!debug_objects_enabled) 754 586 return; ··· 769 599 obj->state = ODEBUG_STATE_DESTROYED; 770 600 break; 771 601 case ODEBUG_STATE_ACTIVE: 772 - debug_print_object(obj, "destroy"); 773 602 state = obj->state; 774 603 raw_spin_unlock_irqrestore(&db->lock, flags); 604 + debug_print_object(obj, "destroy"); 775 605 debug_object_fixup(descr->fixup_destroy, addr, state); 776 606 return; 777 607 778 608 case ODEBUG_STATE_DESTROYED: 779 - debug_print_object(obj, "destroy"); 609 + print_object = true; 780 610 break; 781 611 default: 782 612 break; 783 613 } 784 614 out_unlock: 785 615 raw_spin_unlock_irqrestore(&db->lock, flags); 616 + if (print_object) 617 + debug_print_object(obj, "destroy"); 786 618 } 787 619 EXPORT_SYMBOL_GPL(debug_object_destroy); 788 620 ··· 813 641 814 642 switch (obj->state) { 815 643 case ODEBUG_STATE_ACTIVE: 816 - debug_print_object(obj, "free"); 817 644 state = obj->state; 818 645 raw_spin_unlock_irqrestore(&db->lock, flags); 646 + debug_print_object(obj, "free"); 819 647 debug_object_fixup(descr->fixup_free, addr, state); 820 648 return; 821 649 default: ··· 888 716 struct debug_bucket *db; 889 717 struct debug_obj *obj; 890 718 unsigned long flags; 719 + bool print_object = false; 891 720 892 721 if (!debug_objects_enabled) 893 722 return; ··· 904 731 if (obj->astate == expect) 905 732 obj->astate = next; 906 733 else 907 - debug_print_object(obj, "active_state"); 734 + print_object = true; 908 735 break; 909 736 910 737 default: 911 - debug_print_object(obj, "active_state"); 738 + print_object = true; 912 739 break; 913 740 } 914 - } else { 741 + } 742 + 743 + raw_spin_unlock_irqrestore(&db->lock, flags); 744 + if (!obj) { 915 745 struct debug_obj o = { .object = addr, 916 746 .state = ODEBUG_STATE_NOTAVAILABLE, 917 747 .descr = descr }; 918 748 919 749 debug_print_object(&o, "active_state"); 750 + } else if (print_object) { 751 + debug_print_object(obj, "active_state"); 920 752 } 921 - 922 - raw_spin_unlock_irqrestore(&db->lock, flags); 923 753 } 924 754 EXPORT_SYMBOL_GPL(debug_object_active_state); 925 755 ··· 936 760 struct hlist_node *tmp; 937 761 struct debug_obj *obj; 938 762 int cnt, objs_checked = 0; 939 - bool work = false; 940 763 941 764 saddr = (unsigned long) address; 942 765 eaddr = saddr + size; ··· 957 782 958 783 switch (obj->state) { 959 784 case ODEBUG_STATE_ACTIVE: 960 - debug_print_object(obj, "free"); 961 785 descr = obj->descr; 962 786 state = obj->state; 963 787 raw_spin_unlock_irqrestore(&db->lock, flags); 788 + debug_print_object(obj, "free"); 964 789 debug_object_fixup(descr->fixup_free, 965 790 (void *) oaddr, state); 966 791 goto repeat; 967 792 default: 968 793 hlist_del(&obj->node); 969 - work |= __free_object(obj); 794 + __free_object(obj); 970 795 break; 971 796 } 972 797 } ··· 982 807 debug_objects_maxchecked = objs_checked; 983 808 984 809 /* Schedule work to actually kmem_cache_free() objects */ 985 - if (work) 986 - schedule_work(&debug_obj_work); 810 + if (!obj_freeing && obj_nr_tofree) { 811 + WRITE_ONCE(obj_freeing, true); 812 + schedule_delayed_work(&debug_obj_work, ODEBUG_FREE_WORK_DELAY); 813 + } 987 814 } 988 815 989 816 void debug_check_no_obj_freed(const void *address, unsigned long size) ··· 999 822 1000 823 static int debug_stats_show(struct seq_file *m, void *v) 1001 824 { 825 + int cpu, obj_percpu_free = 0; 826 + 827 + for_each_possible_cpu(cpu) 828 + obj_percpu_free += per_cpu(percpu_obj_pool.obj_free, cpu); 829 + 1002 830 seq_printf(m, "max_chain :%d\n", debug_objects_maxchain); 1003 831 seq_printf(m, "max_checked :%d\n", debug_objects_maxchecked); 1004 832 seq_printf(m, "warnings :%d\n", debug_objects_warnings); 1005 833 seq_printf(m, "fixups :%d\n", debug_objects_fixups); 1006 - seq_printf(m, "pool_free :%d\n", obj_pool_free); 834 + seq_printf(m, "pool_free :%d\n", obj_pool_free + obj_percpu_free); 835 + seq_printf(m, "pool_pcp_free :%d\n", obj_percpu_free); 1007 836 seq_printf(m, "pool_min_free :%d\n", obj_pool_min_free); 1008 - seq_printf(m, "pool_used :%d\n", obj_pool_used); 837 + seq_printf(m, "pool_used :%d\n", obj_pool_used - obj_percpu_free); 1009 838 seq_printf(m, "pool_max_used :%d\n", obj_pool_max_used); 1010 839 seq_printf(m, "on_free_list :%d\n", obj_nr_tofree); 1011 840 seq_printf(m, "objs_allocated:%d\n", debug_objects_allocated); ··· 1033 850 1034 851 static int __init debug_objects_init_debugfs(void) 1035 852 { 1036 - struct dentry *dbgdir, *dbgstats; 853 + struct dentry *dbgdir; 1037 854 1038 855 if (!debug_objects_enabled) 1039 856 return 0; 1040 857 1041 858 dbgdir = debugfs_create_dir("debug_objects", NULL); 1042 - if (!dbgdir) 1043 - return -ENOMEM; 1044 859 1045 - dbgstats = debugfs_create_file("stats", 0444, dbgdir, NULL, 1046 - &debug_stats_fops); 1047 - if (!dbgstats) 1048 - goto err; 860 + debugfs_create_file("stats", 0444, dbgdir, NULL, &debug_stats_fops); 1049 861 1050 862 return 0; 1051 - 1052 - err: 1053 - debugfs_remove(dbgdir); 1054 - 1055 - return -ENOMEM; 1056 863 } 1057 864 __initcall(debug_objects_init_debugfs); 1058 865 ··· 1348 1175 */ 1349 1176 void __init debug_objects_mem_init(void) 1350 1177 { 1178 + int cpu, extras; 1179 + 1351 1180 if (!debug_objects_enabled) 1352 1181 return; 1182 + 1183 + /* 1184 + * Initialize the percpu object pools 1185 + * 1186 + * Initialization is not strictly necessary, but was done for 1187 + * completeness. 1188 + */ 1189 + for_each_possible_cpu(cpu) 1190 + INIT_HLIST_HEAD(&per_cpu(percpu_obj_pool.free_objs, cpu)); 1353 1191 1354 1192 obj_cache = kmem_cache_create("debug_objects_cache", 1355 1193 sizeof (struct debug_obj), 0, ··· 1378 1194 * Increase the thresholds for allocating and freeing objects 1379 1195 * according to the number of possible CPUs available in the system. 1380 1196 */ 1381 - debug_objects_pool_size += num_possible_cpus() * 32; 1382 - debug_objects_pool_min_level += num_possible_cpus() * 4; 1197 + extras = num_possible_cpus() * ODEBUG_BATCH_SIZE; 1198 + debug_objects_pool_size += extras; 1199 + debug_objects_pool_min_level += extras; 1383 1200 }