2 * Generic infrastructure for lifetime debugging of objects.
4 * Started by Thomas Gleixner
6 * Copyright (C) 2008, Thomas Gleixner <tglx@linutronix.de>
8 * For licencing details see kernel-base/COPYING
10 #include <linux/debugobjects.h>
11 #include <linux/interrupt.h>
12 #include <linux/seq_file.h>
13 #include <linux/debugfs.h>
14 #include <linux/hash.h>
16 #define ODEBUG_HASH_BITS 14
17 #define ODEBUG_HASH_SIZE (1 << ODEBUG_HASH_BITS)
19 #define ODEBUG_POOL_SIZE 512
20 #define ODEBUG_POOL_MIN_LEVEL 256
22 #define ODEBUG_CHUNK_SHIFT PAGE_SHIFT
23 #define ODEBUG_CHUNK_SIZE (1 << ODEBUG_CHUNK_SHIFT)
24 #define ODEBUG_CHUNK_MASK (~(ODEBUG_CHUNK_SIZE - 1))
27 struct hlist_head list;
31 static struct debug_bucket obj_hash[ODEBUG_HASH_SIZE];
33 static struct debug_obj obj_static_pool[ODEBUG_POOL_SIZE] __initdata;
35 static DEFINE_SPINLOCK(pool_lock);
37 static HLIST_HEAD(obj_pool);
39 static int obj_pool_min_free = ODEBUG_POOL_SIZE;
40 static int obj_pool_free = ODEBUG_POOL_SIZE;
41 static int obj_pool_used;
42 static int obj_pool_max_used;
43 static struct kmem_cache *obj_cache;
45 static int debug_objects_maxchain __read_mostly;
46 static int debug_objects_fixups __read_mostly;
47 static int debug_objects_warnings __read_mostly;
48 static int debug_objects_enabled __read_mostly
49 = CONFIG_DEBUG_OBJECTS_ENABLE_DEFAULT;
51 static struct debug_obj_descr *descr_test __read_mostly;
53 static int __init enable_object_debug(char *str)
55 debug_objects_enabled = 1;
59 static int __init disable_object_debug(char *str)
61 debug_objects_enabled = 0;
65 early_param("debug_objects", enable_object_debug);
66 early_param("no_debug_objects", disable_object_debug);
68 static const char *obj_states[ODEBUG_STATE_MAX] = {
69 [ODEBUG_STATE_NONE] = "none",
70 [ODEBUG_STATE_INIT] = "initialized",
71 [ODEBUG_STATE_INACTIVE] = "inactive",
72 [ODEBUG_STATE_ACTIVE] = "active",
73 [ODEBUG_STATE_DESTROYED] = "destroyed",
74 [ODEBUG_STATE_NOTAVAILABLE] = "not available",
77 static int fill_pool(void)
79 gfp_t gfp = GFP_ATOMIC | __GFP_NORETRY | __GFP_NOWARN;
80 struct debug_obj *new;
83 if (likely(obj_pool_free >= ODEBUG_POOL_MIN_LEVEL))
86 if (unlikely(!obj_cache))
89 while (obj_pool_free < ODEBUG_POOL_MIN_LEVEL) {
91 new = kmem_cache_zalloc(obj_cache, gfp);
95 spin_lock_irqsave(&pool_lock, flags);
96 hlist_add_head(&new->node, &obj_pool);
98 spin_unlock_irqrestore(&pool_lock, flags);
100 return obj_pool_free;
104 * Lookup an object in the hash bucket.
106 static struct debug_obj *lookup_object(void *addr, struct debug_bucket *b)
108 struct hlist_node *node;
109 struct debug_obj *obj;
112 hlist_for_each_entry(obj, node, &b->list, node) {
114 if (obj->object == addr)
117 if (cnt > debug_objects_maxchain)
118 debug_objects_maxchain = cnt;
124 * Allocate a new object. If the pool is empty, switch off the debugger.
125 * Must be called with interrupts disabled.
127 static struct debug_obj *
128 alloc_object(void *addr, struct debug_bucket *b, struct debug_obj_descr *descr)
130 struct debug_obj *obj = NULL;
132 spin_lock(&pool_lock);
133 if (obj_pool.first) {
134 obj = hlist_entry(obj_pool.first, typeof(*obj), node);
138 obj->state = ODEBUG_STATE_NONE;
139 hlist_del(&obj->node);
141 hlist_add_head(&obj->node, &b->list);
144 if (obj_pool_used > obj_pool_max_used)
145 obj_pool_max_used = obj_pool_used;
148 if (obj_pool_free < obj_pool_min_free)
149 obj_pool_min_free = obj_pool_free;
151 spin_unlock(&pool_lock);
157 * Put the object back into the pool or give it back to kmem_cache:
159 static void free_object(struct debug_obj *obj)
161 unsigned long idx = (unsigned long)(obj - obj_static_pool);
164 if (obj_pool_free < ODEBUG_POOL_SIZE || idx < ODEBUG_POOL_SIZE) {
165 spin_lock_irqsave(&pool_lock, flags);
166 hlist_add_head(&obj->node, &obj_pool);
169 spin_unlock_irqrestore(&pool_lock, flags);
171 spin_lock_irqsave(&pool_lock, flags);
173 spin_unlock_irqrestore(&pool_lock, flags);
174 kmem_cache_free(obj_cache, obj);
179 * We run out of memory. That means we probably have tons of objects
182 static void debug_objects_oom(void)
184 struct debug_bucket *db = obj_hash;
185 struct hlist_node *node, *tmp;
186 HLIST_HEAD(freelist);
187 struct debug_obj *obj;
191 printk(KERN_WARNING "ODEBUG: Out of memory. ODEBUG disabled\n");
193 for (i = 0; i < ODEBUG_HASH_SIZE; i++, db++) {
194 spin_lock_irqsave(&db->lock, flags);
195 hlist_move_list(&db->list, &freelist);
196 spin_unlock_irqrestore(&db->lock, flags);
199 hlist_for_each_entry_safe(obj, node, tmp, &freelist, node) {
200 hlist_del(&obj->node);
207 * We use the pfn of the address for the hash. That way we can check
208 * for freed objects simply by checking the affected bucket.
210 static struct debug_bucket *get_bucket(unsigned long addr)
214 hash = hash_long((addr >> ODEBUG_CHUNK_SHIFT), ODEBUG_HASH_BITS);
215 return &obj_hash[hash];
218 static void debug_print_object(struct debug_obj *obj, char *msg)
222 if (limit < 5 && obj->descr != descr_test) {
224 WARN(1, KERN_ERR "ODEBUG: %s %s object type: %s\n", msg,
225 obj_states[obj->state], obj->descr->name);
227 debug_objects_warnings++;
231 * Try to repair the damage, so we have a better chance to get useful
235 debug_object_fixup(int (*fixup)(void *addr, enum debug_obj_state state),
236 void * addr, enum debug_obj_state state)
239 debug_objects_fixups += fixup(addr, state);
242 static void debug_object_is_on_stack(void *addr, int onstack)
250 is_on_stack = object_is_on_stack(addr);
251 if (is_on_stack == onstack)
257 "ODEBUG: object is on stack, but not annotated\n");
260 "ODEBUG: object is not on stack, but annotated\n");
265 __debug_object_init(void *addr, struct debug_obj_descr *descr, int onstack)
267 enum debug_obj_state state;
268 struct debug_bucket *db;
269 struct debug_obj *obj;
274 db = get_bucket((unsigned long) addr);
276 spin_lock_irqsave(&db->lock, flags);
278 obj = lookup_object(addr, db);
280 obj = alloc_object(addr, db, descr);
282 debug_objects_enabled = 0;
283 spin_unlock_irqrestore(&db->lock, flags);
287 debug_object_is_on_stack(addr, onstack);
290 switch (obj->state) {
291 case ODEBUG_STATE_NONE:
292 case ODEBUG_STATE_INIT:
293 case ODEBUG_STATE_INACTIVE:
294 obj->state = ODEBUG_STATE_INIT;
297 case ODEBUG_STATE_ACTIVE:
298 debug_print_object(obj, "init");
300 spin_unlock_irqrestore(&db->lock, flags);
301 debug_object_fixup(descr->fixup_init, addr, state);
304 case ODEBUG_STATE_DESTROYED:
305 debug_print_object(obj, "init");
311 spin_unlock_irqrestore(&db->lock, flags);
315 * debug_object_init - debug checks when an object is initialized
316 * @addr: address of the object
317 * @descr: pointer to an object specific debug description structure
319 void debug_object_init(void *addr, struct debug_obj_descr *descr)
321 if (!debug_objects_enabled)
324 __debug_object_init(addr, descr, 0);
328 * debug_object_init_on_stack - debug checks when an object on stack is
330 * @addr: address of the object
331 * @descr: pointer to an object specific debug description structure
333 void debug_object_init_on_stack(void *addr, struct debug_obj_descr *descr)
335 if (!debug_objects_enabled)
338 __debug_object_init(addr, descr, 1);
342 * debug_object_activate - debug checks when an object is activated
343 * @addr: address of the object
344 * @descr: pointer to an object specific debug description structure
346 void debug_object_activate(void *addr, struct debug_obj_descr *descr)
348 enum debug_obj_state state;
349 struct debug_bucket *db;
350 struct debug_obj *obj;
353 if (!debug_objects_enabled)
356 db = get_bucket((unsigned long) addr);
358 spin_lock_irqsave(&db->lock, flags);
360 obj = lookup_object(addr, db);
362 switch (obj->state) {
363 case ODEBUG_STATE_INIT:
364 case ODEBUG_STATE_INACTIVE:
365 obj->state = ODEBUG_STATE_ACTIVE;
368 case ODEBUG_STATE_ACTIVE:
369 debug_print_object(obj, "activate");
371 spin_unlock_irqrestore(&db->lock, flags);
372 debug_object_fixup(descr->fixup_activate, addr, state);
375 case ODEBUG_STATE_DESTROYED:
376 debug_print_object(obj, "activate");
381 spin_unlock_irqrestore(&db->lock, flags);
385 spin_unlock_irqrestore(&db->lock, flags);
387 * This happens when a static object is activated. We
388 * let the type specific code decide whether this is
391 debug_object_fixup(descr->fixup_activate, addr,
392 ODEBUG_STATE_NOTAVAILABLE);
396 * debug_object_deactivate - debug checks when an object is deactivated
397 * @addr: address of the object
398 * @descr: pointer to an object specific debug description structure
400 void debug_object_deactivate(void *addr, struct debug_obj_descr *descr)
402 struct debug_bucket *db;
403 struct debug_obj *obj;
406 if (!debug_objects_enabled)
409 db = get_bucket((unsigned long) addr);
411 spin_lock_irqsave(&db->lock, flags);
413 obj = lookup_object(addr, db);
415 switch (obj->state) {
416 case ODEBUG_STATE_INIT:
417 case ODEBUG_STATE_INACTIVE:
418 case ODEBUG_STATE_ACTIVE:
419 obj->state = ODEBUG_STATE_INACTIVE;
422 case ODEBUG_STATE_DESTROYED:
423 debug_print_object(obj, "deactivate");
429 struct debug_obj o = { .object = addr,
430 .state = ODEBUG_STATE_NOTAVAILABLE,
433 debug_print_object(&o, "deactivate");
436 spin_unlock_irqrestore(&db->lock, flags);
440 * debug_object_destroy - debug checks when an object is destroyed
441 * @addr: address of the object
442 * @descr: pointer to an object specific debug description structure
444 void debug_object_destroy(void *addr, struct debug_obj_descr *descr)
446 enum debug_obj_state state;
447 struct debug_bucket *db;
448 struct debug_obj *obj;
451 if (!debug_objects_enabled)
454 db = get_bucket((unsigned long) addr);
456 spin_lock_irqsave(&db->lock, flags);
458 obj = lookup_object(addr, db);
462 switch (obj->state) {
463 case ODEBUG_STATE_NONE:
464 case ODEBUG_STATE_INIT:
465 case ODEBUG_STATE_INACTIVE:
466 obj->state = ODEBUG_STATE_DESTROYED;
468 case ODEBUG_STATE_ACTIVE:
469 debug_print_object(obj, "destroy");
471 spin_unlock_irqrestore(&db->lock, flags);
472 debug_object_fixup(descr->fixup_destroy, addr, state);
475 case ODEBUG_STATE_DESTROYED:
476 debug_print_object(obj, "destroy");
482 spin_unlock_irqrestore(&db->lock, flags);
486 * debug_object_free - debug checks when an object is freed
487 * @addr: address of the object
488 * @descr: pointer to an object specific debug description structure
490 void debug_object_free(void *addr, struct debug_obj_descr *descr)
492 enum debug_obj_state state;
493 struct debug_bucket *db;
494 struct debug_obj *obj;
497 if (!debug_objects_enabled)
500 db = get_bucket((unsigned long) addr);
502 spin_lock_irqsave(&db->lock, flags);
504 obj = lookup_object(addr, db);
508 switch (obj->state) {
509 case ODEBUG_STATE_ACTIVE:
510 debug_print_object(obj, "free");
512 spin_unlock_irqrestore(&db->lock, flags);
513 debug_object_fixup(descr->fixup_free, addr, state);
516 hlist_del(&obj->node);
517 spin_unlock_irqrestore(&db->lock, flags);
522 spin_unlock_irqrestore(&db->lock, flags);
525 #ifdef CONFIG_DEBUG_OBJECTS_FREE
526 static void __debug_check_no_obj_freed(const void *address, unsigned long size)
528 unsigned long flags, oaddr, saddr, eaddr, paddr, chunks;
529 struct hlist_node *node, *tmp;
530 HLIST_HEAD(freelist);
531 struct debug_obj_descr *descr;
532 enum debug_obj_state state;
533 struct debug_bucket *db;
534 struct debug_obj *obj;
537 saddr = (unsigned long) address;
538 eaddr = saddr + size;
539 paddr = saddr & ODEBUG_CHUNK_MASK;
540 chunks = ((eaddr - paddr) + (ODEBUG_CHUNK_SIZE - 1));
541 chunks >>= ODEBUG_CHUNK_SHIFT;
543 for (;chunks > 0; chunks--, paddr += ODEBUG_CHUNK_SIZE) {
544 db = get_bucket(paddr);
548 spin_lock_irqsave(&db->lock, flags);
549 hlist_for_each_entry_safe(obj, node, tmp, &db->list, node) {
551 oaddr = (unsigned long) obj->object;
552 if (oaddr < saddr || oaddr >= eaddr)
555 switch (obj->state) {
556 case ODEBUG_STATE_ACTIVE:
557 debug_print_object(obj, "free");
560 spin_unlock_irqrestore(&db->lock, flags);
561 debug_object_fixup(descr->fixup_free,
562 (void *) oaddr, state);
565 hlist_del(&obj->node);
566 hlist_add_head(&obj->node, &freelist);
570 spin_unlock_irqrestore(&db->lock, flags);
573 hlist_for_each_entry_safe(obj, node, tmp, &freelist, node) {
574 hlist_del(&obj->node);
578 if (cnt > debug_objects_maxchain)
579 debug_objects_maxchain = cnt;
583 void debug_check_no_obj_freed(const void *address, unsigned long size)
585 if (debug_objects_enabled)
586 __debug_check_no_obj_freed(address, size);
590 #ifdef CONFIG_DEBUG_FS
592 static int debug_stats_show(struct seq_file *m, void *v)
594 seq_printf(m, "max_chain :%d\n", debug_objects_maxchain);
595 seq_printf(m, "warnings :%d\n", debug_objects_warnings);
596 seq_printf(m, "fixups :%d\n", debug_objects_fixups);
597 seq_printf(m, "pool_free :%d\n", obj_pool_free);
598 seq_printf(m, "pool_min_free :%d\n", obj_pool_min_free);
599 seq_printf(m, "pool_used :%d\n", obj_pool_used);
600 seq_printf(m, "pool_max_used :%d\n", obj_pool_max_used);
604 static int debug_stats_open(struct inode *inode, struct file *filp)
606 return single_open(filp, debug_stats_show, NULL);
609 static const struct file_operations debug_stats_fops = {
610 .open = debug_stats_open,
613 .release = single_release,
616 static int __init debug_objects_init_debugfs(void)
618 struct dentry *dbgdir, *dbgstats;
620 if (!debug_objects_enabled)
623 dbgdir = debugfs_create_dir("debug_objects", NULL);
627 dbgstats = debugfs_create_file("stats", 0444, dbgdir, NULL,
635 debugfs_remove(dbgdir);
639 __initcall(debug_objects_init_debugfs);
642 static inline void debug_objects_init_debugfs(void) { }
645 #ifdef CONFIG_DEBUG_OBJECTS_SELFTEST
647 /* Random data structure for the self test */
649 unsigned long dummy1[6];
651 unsigned long dummy2[3];
654 static __initdata struct debug_obj_descr descr_type_test;
657 * fixup_init is called when:
658 * - an active object is initialized
660 static int __init fixup_init(void *addr, enum debug_obj_state state)
662 struct self_test *obj = addr;
665 case ODEBUG_STATE_ACTIVE:
666 debug_object_deactivate(obj, &descr_type_test);
667 debug_object_init(obj, &descr_type_test);
675 * fixup_activate is called when:
676 * - an active object is activated
677 * - an unknown object is activated (might be a statically initialized object)
679 static int __init fixup_activate(void *addr, enum debug_obj_state state)
681 struct self_test *obj = addr;
684 case ODEBUG_STATE_NOTAVAILABLE:
685 if (obj->static_init == 1) {
686 debug_object_init(obj, &descr_type_test);
687 debug_object_activate(obj, &descr_type_test);
689 * Real code should return 0 here ! This is
690 * not a fixup of some bad behaviour. We
691 * merily call the debug_init function to keep
692 * track of the object.
696 /* Real code needs to emit a warning here */
700 case ODEBUG_STATE_ACTIVE:
701 debug_object_deactivate(obj, &descr_type_test);
702 debug_object_activate(obj, &descr_type_test);
711 * fixup_destroy is called when:
712 * - an active object is destroyed
714 static int __init fixup_destroy(void *addr, enum debug_obj_state state)
716 struct self_test *obj = addr;
719 case ODEBUG_STATE_ACTIVE:
720 debug_object_deactivate(obj, &descr_type_test);
721 debug_object_destroy(obj, &descr_type_test);
729 * fixup_free is called when:
730 * - an active object is freed
732 static int __init fixup_free(void *addr, enum debug_obj_state state)
734 struct self_test *obj = addr;
737 case ODEBUG_STATE_ACTIVE:
738 debug_object_deactivate(obj, &descr_type_test);
739 debug_object_free(obj, &descr_type_test);
747 check_results(void *addr, enum debug_obj_state state, int fixups, int warnings)
749 struct debug_bucket *db;
750 struct debug_obj *obj;
754 db = get_bucket((unsigned long) addr);
756 spin_lock_irqsave(&db->lock, flags);
758 obj = lookup_object(addr, db);
759 if (!obj && state != ODEBUG_STATE_NONE) {
760 WARN(1, KERN_ERR "ODEBUG: selftest object not found\n");
763 if (obj && obj->state != state) {
764 WARN(1, KERN_ERR "ODEBUG: selftest wrong state: %d != %d\n",
768 if (fixups != debug_objects_fixups) {
769 WARN(1, KERN_ERR "ODEBUG: selftest fixups failed %d != %d\n",
770 fixups, debug_objects_fixups);
773 if (warnings != debug_objects_warnings) {
774 WARN(1, KERN_ERR "ODEBUG: selftest warnings failed %d != %d\n",
775 warnings, debug_objects_warnings);
780 spin_unlock_irqrestore(&db->lock, flags);
782 debug_objects_enabled = 0;
786 static __initdata struct debug_obj_descr descr_type_test = {
788 .fixup_init = fixup_init,
789 .fixup_activate = fixup_activate,
790 .fixup_destroy = fixup_destroy,
791 .fixup_free = fixup_free,
794 static __initdata struct self_test obj = { .static_init = 0 };
796 static void __init debug_objects_selftest(void)
798 int fixups, oldfixups, warnings, oldwarnings;
801 local_irq_save(flags);
803 fixups = oldfixups = debug_objects_fixups;
804 warnings = oldwarnings = debug_objects_warnings;
805 descr_test = &descr_type_test;
807 debug_object_init(&obj, &descr_type_test);
808 if (check_results(&obj, ODEBUG_STATE_INIT, fixups, warnings))
810 debug_object_activate(&obj, &descr_type_test);
811 if (check_results(&obj, ODEBUG_STATE_ACTIVE, fixups, warnings))
813 debug_object_activate(&obj, &descr_type_test);
814 if (check_results(&obj, ODEBUG_STATE_ACTIVE, ++fixups, ++warnings))
816 debug_object_deactivate(&obj, &descr_type_test);
817 if (check_results(&obj, ODEBUG_STATE_INACTIVE, fixups, warnings))
819 debug_object_destroy(&obj, &descr_type_test);
820 if (check_results(&obj, ODEBUG_STATE_DESTROYED, fixups, warnings))
822 debug_object_init(&obj, &descr_type_test);
823 if (check_results(&obj, ODEBUG_STATE_DESTROYED, fixups, ++warnings))
825 debug_object_activate(&obj, &descr_type_test);
826 if (check_results(&obj, ODEBUG_STATE_DESTROYED, fixups, ++warnings))
828 debug_object_deactivate(&obj, &descr_type_test);
829 if (check_results(&obj, ODEBUG_STATE_DESTROYED, fixups, ++warnings))
831 debug_object_free(&obj, &descr_type_test);
832 if (check_results(&obj, ODEBUG_STATE_NONE, fixups, warnings))
836 debug_object_activate(&obj, &descr_type_test);
837 if (check_results(&obj, ODEBUG_STATE_ACTIVE, ++fixups, warnings))
839 debug_object_init(&obj, &descr_type_test);
840 if (check_results(&obj, ODEBUG_STATE_INIT, ++fixups, ++warnings))
842 debug_object_free(&obj, &descr_type_test);
843 if (check_results(&obj, ODEBUG_STATE_NONE, fixups, warnings))
846 #ifdef CONFIG_DEBUG_OBJECTS_FREE
847 debug_object_init(&obj, &descr_type_test);
848 if (check_results(&obj, ODEBUG_STATE_INIT, fixups, warnings))
850 debug_object_activate(&obj, &descr_type_test);
851 if (check_results(&obj, ODEBUG_STATE_ACTIVE, fixups, warnings))
853 __debug_check_no_obj_freed(&obj, sizeof(obj));
854 if (check_results(&obj, ODEBUG_STATE_NONE, ++fixups, ++warnings))
857 printk(KERN_INFO "ODEBUG: selftest passed\n");
860 debug_objects_fixups = oldfixups;
861 debug_objects_warnings = oldwarnings;
864 local_irq_restore(flags);
867 static inline void debug_objects_selftest(void) { }
871 * Called during early boot to initialize the hash buckets and link
872 * the static object pool objects into the poll list. After this call
873 * the object tracker is fully operational.
875 void __init debug_objects_early_init(void)
879 for (i = 0; i < ODEBUG_HASH_SIZE; i++)
880 spin_lock_init(&obj_hash[i].lock);
882 for (i = 0; i < ODEBUG_POOL_SIZE; i++)
883 hlist_add_head(&obj_static_pool[i].node, &obj_pool);
887 * Convert the statically allocated objects to dynamic ones:
889 static int debug_objects_replace_static_objects(void)
891 struct debug_bucket *db = obj_hash;
892 struct hlist_node *node, *tmp;
893 struct debug_obj *obj, *new;
897 for (i = 0; i < ODEBUG_POOL_SIZE; i++) {
898 obj = kmem_cache_zalloc(obj_cache, GFP_KERNEL);
901 hlist_add_head(&obj->node, &objects);
905 * When debug_objects_mem_init() is called we know that only
906 * one CPU is up, so disabling interrupts is enough
907 * protection. This avoids the lockdep hell of lock ordering.
911 /* Remove the statically allocated objects from the pool */
912 hlist_for_each_entry_safe(obj, node, tmp, &obj_pool, node)
913 hlist_del(&obj->node);
914 /* Move the allocated objects to the pool */
915 hlist_move_list(&objects, &obj_pool);
917 /* Replace the active object references */
918 for (i = 0; i < ODEBUG_HASH_SIZE; i++, db++) {
919 hlist_move_list(&db->list, &objects);
921 hlist_for_each_entry(obj, node, &objects, node) {
922 new = hlist_entry(obj_pool.first, typeof(*obj), node);
923 hlist_del(&new->node);
924 /* copy object data */
926 hlist_add_head(&new->node, &db->list);
931 printk(KERN_DEBUG "ODEBUG: %d of %d active objects replaced\n", cnt,
936 hlist_for_each_entry_safe(obj, node, tmp, &objects, node) {
937 hlist_del(&obj->node);
938 kmem_cache_free(obj_cache, obj);
944 * Called after the kmem_caches are functional to setup a dedicated
945 * cache pool, which has the SLAB_DEBUG_OBJECTS flag set. This flag
946 * prevents that the debug code is called on kmem_cache_free() for the
947 * debug tracker objects to avoid recursive calls.
949 void __init debug_objects_mem_init(void)
951 if (!debug_objects_enabled)
954 obj_cache = kmem_cache_create("debug_objects_cache",
955 sizeof (struct debug_obj), 0,
956 SLAB_DEBUG_OBJECTS, NULL);
958 if (!obj_cache || debug_objects_replace_static_objects()) {
959 debug_objects_enabled = 0;
961 kmem_cache_destroy(obj_cache);
962 printk(KERN_WARNING "ODEBUG: out of memory.\n");
964 debug_objects_selftest();