Thomas Gleixner | 3ac7fe5 | 2008-04-30 00:55:01 -0700 | [diff] [blame] | 1 | /* |
| 2 | * Generic infrastructure for lifetime debugging of objects. |
| 3 | * |
| 4 | * Started by Thomas Gleixner |
| 5 | * |
| 6 | * Copyright (C) 2008, Thomas Gleixner <tglx@linutronix.de> |
| 7 | * |
| 8 | * For licencing details see kernel-base/COPYING |
| 9 | */ |
Fabian Frederick | 719e484 | 2014-06-04 16:06:04 -0700 | [diff] [blame] | 10 | |
| 11 | #define pr_fmt(fmt) "ODEBUG: " fmt |
| 12 | |
Thomas Gleixner | 3ac7fe5 | 2008-04-30 00:55:01 -0700 | [diff] [blame] | 13 | #include <linux/debugobjects.h> |
| 14 | #include <linux/interrupt.h> |
Alexey Dobriyan | d43c36d | 2009-10-07 17:09:06 +0400 | [diff] [blame] | 15 | #include <linux/sched.h> |
Ingo Molnar | 68db0cf | 2017-02-08 18:51:37 +0100 | [diff] [blame] | 16 | #include <linux/sched/task_stack.h> |
Thomas Gleixner | 3ac7fe5 | 2008-04-30 00:55:01 -0700 | [diff] [blame] | 17 | #include <linux/seq_file.h> |
| 18 | #include <linux/debugfs.h> |
Tejun Heo | 5a0e3ad | 2010-03-24 17:04:11 +0900 | [diff] [blame] | 19 | #include <linux/slab.h> |
Thomas Gleixner | 3ac7fe5 | 2008-04-30 00:55:01 -0700 | [diff] [blame] | 20 | #include <linux/hash.h> |
Waiman Long | caba4cb | 2017-08-14 09:52:13 -0400 | [diff] [blame] | 21 | #include <linux/kmemleak.h> |
Thomas Gleixner | 3ac7fe5 | 2008-04-30 00:55:01 -0700 | [diff] [blame] | 22 | |
| 23 | #define ODEBUG_HASH_BITS 14 |
| 24 | #define ODEBUG_HASH_SIZE (1 << ODEBUG_HASH_BITS) |
| 25 | |
Christian Borntraeger | 0b6ec8c | 2016-01-27 15:37:58 +0100 | [diff] [blame] | 26 | #define ODEBUG_POOL_SIZE 1024 |
Thomas Gleixner | 3ac7fe5 | 2008-04-30 00:55:01 -0700 | [diff] [blame] | 27 | #define ODEBUG_POOL_MIN_LEVEL 256 |
Waiman Long | d86998b | 2019-05-20 10:14:46 -0400 | [diff] [blame] | 28 | #define ODEBUG_POOL_PERCPU_SIZE 64 |
Waiman Long | 634d61f | 2019-05-20 10:14:47 -0400 | [diff] [blame] | 29 | #define ODEBUG_BATCH_SIZE 16 |
Thomas Gleixner | 3ac7fe5 | 2008-04-30 00:55:01 -0700 | [diff] [blame] | 30 | |
| 31 | #define ODEBUG_CHUNK_SHIFT PAGE_SHIFT |
| 32 | #define ODEBUG_CHUNK_SIZE (1 << ODEBUG_CHUNK_SHIFT) |
| 33 | #define ODEBUG_CHUNK_MASK (~(ODEBUG_CHUNK_SIZE - 1)) |
| 34 | |
| 35 | struct debug_bucket { |
| 36 | struct hlist_head list; |
Thomas Gleixner | aef9cb0 | 2009-11-17 18:11:28 +0100 | [diff] [blame] | 37 | raw_spinlock_t lock; |
Thomas Gleixner | 3ac7fe5 | 2008-04-30 00:55:01 -0700 | [diff] [blame] | 38 | }; |
| 39 | |
Waiman Long | d86998b | 2019-05-20 10:14:46 -0400 | [diff] [blame] | 40 | /* |
| 41 | * Debug object percpu free list |
| 42 | * Access is protected by disabling irq |
| 43 | */ |
| 44 | struct debug_percpu_free { |
| 45 | struct hlist_head free_objs; |
| 46 | int obj_free; |
| 47 | }; |
| 48 | |
| 49 | static DEFINE_PER_CPU(struct debug_percpu_free, percpu_obj_pool); |
| 50 | |
Thomas Gleixner | 3ac7fe5 | 2008-04-30 00:55:01 -0700 | [diff] [blame] | 51 | static struct debug_bucket obj_hash[ODEBUG_HASH_SIZE]; |
| 52 | |
Thomas Gleixner | 1be1cb7 | 2009-03-16 18:53:18 +0100 | [diff] [blame] | 53 | static struct debug_obj obj_static_pool[ODEBUG_POOL_SIZE] __initdata; |
Thomas Gleixner | 3ac7fe5 | 2008-04-30 00:55:01 -0700 | [diff] [blame] | 54 | |
Thomas Gleixner | aef9cb0 | 2009-11-17 18:11:28 +0100 | [diff] [blame] | 55 | static DEFINE_RAW_SPINLOCK(pool_lock); |
Thomas Gleixner | 3ac7fe5 | 2008-04-30 00:55:01 -0700 | [diff] [blame] | 56 | |
| 57 | static HLIST_HEAD(obj_pool); |
Yang Shi | 36c4ead | 2018-02-06 07:18:26 +0800 | [diff] [blame] | 58 | static HLIST_HEAD(obj_to_free); |
Thomas Gleixner | 3ac7fe5 | 2008-04-30 00:55:01 -0700 | [diff] [blame] | 59 | |
Waiman Long | d86998b | 2019-05-20 10:14:46 -0400 | [diff] [blame] | 60 | /* |
| 61 | * Because of the presence of percpu free pools, obj_pool_free will |
| 62 | * under-count those in the percpu free pools. Similarly, obj_pool_used |
| 63 | * will over-count those in the percpu free pools. Adjustments will be |
| 64 | * made at debug_stats_show(). Both obj_pool_min_free and obj_pool_max_used |
| 65 | * can be off. |
| 66 | */ |
Thomas Gleixner | 3ac7fe5 | 2008-04-30 00:55:01 -0700 | [diff] [blame] | 67 | static int obj_pool_min_free = ODEBUG_POOL_SIZE; |
| 68 | static int obj_pool_free = ODEBUG_POOL_SIZE; |
| 69 | static int obj_pool_used; |
| 70 | static int obj_pool_max_used; |
Yang Shi | 36c4ead | 2018-02-06 07:18:26 +0800 | [diff] [blame] | 71 | /* The number of objs on the global free list */ |
| 72 | static int obj_nr_tofree; |
Thomas Gleixner | 3ac7fe5 | 2008-04-30 00:55:01 -0700 | [diff] [blame] | 73 | |
| 74 | static int debug_objects_maxchain __read_mostly; |
Arnd Bergmann | 163cf84 | 2018-03-13 14:18:46 +0100 | [diff] [blame] | 75 | static int __maybe_unused debug_objects_maxchecked __read_mostly; |
Thomas Gleixner | 3ac7fe5 | 2008-04-30 00:55:01 -0700 | [diff] [blame] | 76 | static int debug_objects_fixups __read_mostly; |
| 77 | static int debug_objects_warnings __read_mostly; |
Ingo Molnar | 3ae7020 | 2008-11-26 10:02:00 +0100 | [diff] [blame] | 78 | static int debug_objects_enabled __read_mostly |
| 79 | = CONFIG_DEBUG_OBJECTS_ENABLE_DEFAULT; |
Waiman Long | 97dd552 | 2017-01-05 15:17:04 -0500 | [diff] [blame] | 80 | static int debug_objects_pool_size __read_mostly |
| 81 | = ODEBUG_POOL_SIZE; |
| 82 | static int debug_objects_pool_min_level __read_mostly |
| 83 | = ODEBUG_POOL_MIN_LEVEL; |
Thomas Gleixner | 3ac7fe5 | 2008-04-30 00:55:01 -0700 | [diff] [blame] | 84 | static struct debug_obj_descr *descr_test __read_mostly; |
Waiman Long | d86998b | 2019-05-20 10:14:46 -0400 | [diff] [blame] | 85 | static struct kmem_cache *obj_cache __read_mostly; |
Thomas Gleixner | 3ac7fe5 | 2008-04-30 00:55:01 -0700 | [diff] [blame] | 86 | |
Waiman Long | c4b73aa | 2017-01-05 15:17:03 -0500 | [diff] [blame] | 87 | /* |
Waiman Long | 0cad93c | 2017-02-07 16:40:30 -0500 | [diff] [blame] | 88 | * Track numbers of kmem_cache_alloc()/free() calls done. |
Waiman Long | c4b73aa | 2017-01-05 15:17:03 -0500 | [diff] [blame] | 89 | */ |
Waiman Long | 0cad93c | 2017-02-07 16:40:30 -0500 | [diff] [blame] | 90 | static int debug_objects_allocated; |
Waiman Long | c4b73aa | 2017-01-05 15:17:03 -0500 | [diff] [blame] | 91 | static int debug_objects_freed; |
| 92 | |
Thomas Gleixner | 337fff8 | 2009-03-16 10:04:53 +0100 | [diff] [blame] | 93 | static void free_obj_work(struct work_struct *work); |
| 94 | static DECLARE_WORK(debug_obj_work, free_obj_work); |
| 95 | |
Thomas Gleixner | 3ac7fe5 | 2008-04-30 00:55:01 -0700 | [diff] [blame] | 96 | static int __init enable_object_debug(char *str) |
| 97 | { |
| 98 | debug_objects_enabled = 1; |
| 99 | return 0; |
| 100 | } |
Kyle McMartin | 3e8ebb5 | 2009-03-01 20:41:41 -0500 | [diff] [blame] | 101 | |
| 102 | static int __init disable_object_debug(char *str) |
| 103 | { |
| 104 | debug_objects_enabled = 0; |
| 105 | return 0; |
| 106 | } |
| 107 | |
Thomas Gleixner | 3ac7fe5 | 2008-04-30 00:55:01 -0700 | [diff] [blame] | 108 | early_param("debug_objects", enable_object_debug); |
Kyle McMartin | 3e8ebb5 | 2009-03-01 20:41:41 -0500 | [diff] [blame] | 109 | early_param("no_debug_objects", disable_object_debug); |
Thomas Gleixner | 3ac7fe5 | 2008-04-30 00:55:01 -0700 | [diff] [blame] | 110 | |
| 111 | static const char *obj_states[ODEBUG_STATE_MAX] = { |
| 112 | [ODEBUG_STATE_NONE] = "none", |
| 113 | [ODEBUG_STATE_INIT] = "initialized", |
| 114 | [ODEBUG_STATE_INACTIVE] = "inactive", |
| 115 | [ODEBUG_STATE_ACTIVE] = "active", |
| 116 | [ODEBUG_STATE_DESTROYED] = "destroyed", |
| 117 | [ODEBUG_STATE_NOTAVAILABLE] = "not available", |
| 118 | }; |
| 119 | |
Thomas Gleixner | 1fda107 | 2012-04-11 11:52:18 +0200 | [diff] [blame] | 120 | static void fill_pool(void) |
Thomas Gleixner | 3ac7fe5 | 2008-04-30 00:55:01 -0700 | [diff] [blame] | 121 | { |
| 122 | gfp_t gfp = GFP_ATOMIC | __GFP_NORETRY | __GFP_NOWARN; |
Waiman Long | d26bf50 | 2019-05-20 10:14:48 -0400 | [diff] [blame^] | 123 | struct debug_obj *obj; |
Vegard Nossum | 50db04dd | 2008-06-15 00:47:36 +0200 | [diff] [blame] | 124 | unsigned long flags; |
Thomas Gleixner | 3ac7fe5 | 2008-04-30 00:55:01 -0700 | [diff] [blame] | 125 | |
Waiman Long | 97dd552 | 2017-01-05 15:17:04 -0500 | [diff] [blame] | 126 | if (likely(obj_pool_free >= debug_objects_pool_min_level)) |
Thomas Gleixner | 1fda107 | 2012-04-11 11:52:18 +0200 | [diff] [blame] | 127 | return; |
Thomas Gleixner | 3ac7fe5 | 2008-04-30 00:55:01 -0700 | [diff] [blame] | 128 | |
Yang Shi | 36c4ead | 2018-02-06 07:18:26 +0800 | [diff] [blame] | 129 | /* |
| 130 | * Reuse objs from the global free list; they will be reinitialized |
| 131 | * when allocating. |
| 132 | */ |
| 133 | while (obj_nr_tofree && (obj_pool_free < obj_pool_min_free)) { |
| 134 | raw_spin_lock_irqsave(&pool_lock, flags); |
| 135 | /* |
| 136 | * Recheck with the lock held as the worker thread might have |
| 137 | * won the race and freed the global free list already. |
| 138 | */ |
Waiman Long | d26bf50 | 2019-05-20 10:14:48 -0400 | [diff] [blame^] | 139 | while (obj_nr_tofree && (obj_pool_free < obj_pool_min_free)) { |
Yang Shi | 36c4ead | 2018-02-06 07:18:26 +0800 | [diff] [blame] | 140 | obj = hlist_entry(obj_to_free.first, typeof(*obj), node); |
| 141 | hlist_del(&obj->node); |
| 142 | obj_nr_tofree--; |
| 143 | hlist_add_head(&obj->node, &obj_pool); |
| 144 | obj_pool_free++; |
| 145 | } |
| 146 | raw_spin_unlock_irqrestore(&pool_lock, flags); |
| 147 | } |
| 148 | |
Thomas Gleixner | 3ac7fe5 | 2008-04-30 00:55:01 -0700 | [diff] [blame] | 149 | if (unlikely(!obj_cache)) |
Thomas Gleixner | 1fda107 | 2012-04-11 11:52:18 +0200 | [diff] [blame] | 150 | return; |
Thomas Gleixner | 3ac7fe5 | 2008-04-30 00:55:01 -0700 | [diff] [blame] | 151 | |
Waiman Long | 97dd552 | 2017-01-05 15:17:04 -0500 | [diff] [blame] | 152 | while (obj_pool_free < debug_objects_pool_min_level) { |
Waiman Long | d26bf50 | 2019-05-20 10:14:48 -0400 | [diff] [blame^] | 153 | struct debug_obj *new[ODEBUG_BATCH_SIZE]; |
| 154 | int cnt; |
Thomas Gleixner | 3ac7fe5 | 2008-04-30 00:55:01 -0700 | [diff] [blame] | 155 | |
Waiman Long | d26bf50 | 2019-05-20 10:14:48 -0400 | [diff] [blame^] | 156 | for (cnt = 0; cnt < ODEBUG_BATCH_SIZE; cnt++) { |
| 157 | new[cnt] = kmem_cache_zalloc(obj_cache, gfp); |
| 158 | if (!new[cnt]) |
| 159 | break; |
| 160 | } |
| 161 | if (!cnt) |
Dan Carpenter | 3340808 | 2012-04-18 14:28:10 +0300 | [diff] [blame] | 162 | return; |
Thomas Gleixner | 3ac7fe5 | 2008-04-30 00:55:01 -0700 | [diff] [blame] | 163 | |
Thomas Gleixner | aef9cb0 | 2009-11-17 18:11:28 +0100 | [diff] [blame] | 164 | raw_spin_lock_irqsave(&pool_lock, flags); |
Waiman Long | d26bf50 | 2019-05-20 10:14:48 -0400 | [diff] [blame^] | 165 | while (cnt) { |
| 166 | hlist_add_head(&new[--cnt]->node, &obj_pool); |
| 167 | debug_objects_allocated++; |
| 168 | obj_pool_free++; |
| 169 | } |
Thomas Gleixner | aef9cb0 | 2009-11-17 18:11:28 +0100 | [diff] [blame] | 170 | raw_spin_unlock_irqrestore(&pool_lock, flags); |
Thomas Gleixner | 3ac7fe5 | 2008-04-30 00:55:01 -0700 | [diff] [blame] | 171 | } |
Thomas Gleixner | 3ac7fe5 | 2008-04-30 00:55:01 -0700 | [diff] [blame] | 172 | } |
| 173 | |
| 174 | /* |
| 175 | * Lookup an object in the hash bucket. |
| 176 | */ |
| 177 | static struct debug_obj *lookup_object(void *addr, struct debug_bucket *b) |
| 178 | { |
Thomas Gleixner | 3ac7fe5 | 2008-04-30 00:55:01 -0700 | [diff] [blame] | 179 | struct debug_obj *obj; |
| 180 | int cnt = 0; |
| 181 | |
Sasha Levin | b67bfe0 | 2013-02-27 17:06:00 -0800 | [diff] [blame] | 182 | hlist_for_each_entry(obj, &b->list, node) { |
Thomas Gleixner | 3ac7fe5 | 2008-04-30 00:55:01 -0700 | [diff] [blame] | 183 | cnt++; |
| 184 | if (obj->object == addr) |
| 185 | return obj; |
| 186 | } |
| 187 | if (cnt > debug_objects_maxchain) |
| 188 | debug_objects_maxchain = cnt; |
| 189 | |
| 190 | return NULL; |
| 191 | } |
| 192 | |
| 193 | /* |
Waiman Long | d86998b | 2019-05-20 10:14:46 -0400 | [diff] [blame] | 194 | * Allocate a new object from the hlist |
| 195 | */ |
| 196 | static struct debug_obj *__alloc_object(struct hlist_head *list) |
| 197 | { |
| 198 | struct debug_obj *obj = NULL; |
| 199 | |
| 200 | if (list->first) { |
| 201 | obj = hlist_entry(list->first, typeof(*obj), node); |
| 202 | hlist_del(&obj->node); |
| 203 | } |
| 204 | |
| 205 | return obj; |
| 206 | } |
| 207 | |
| 208 | /* |
Vegard Nossum | 50db04dd | 2008-06-15 00:47:36 +0200 | [diff] [blame] | 209 | * Allocate a new object. If the pool is empty, switch off the debugger. |
Vegard Nossum | 673d62cc | 2008-08-31 23:39:21 +0200 | [diff] [blame] | 210 | * Must be called with interrupts disabled. |
Thomas Gleixner | 3ac7fe5 | 2008-04-30 00:55:01 -0700 | [diff] [blame] | 211 | */ |
| 212 | static struct debug_obj * |
| 213 | alloc_object(void *addr, struct debug_bucket *b, struct debug_obj_descr *descr) |
| 214 | { |
Waiman Long | 634d61f | 2019-05-20 10:14:47 -0400 | [diff] [blame] | 215 | struct debug_percpu_free *percpu_pool = this_cpu_ptr(&percpu_obj_pool); |
Waiman Long | d86998b | 2019-05-20 10:14:46 -0400 | [diff] [blame] | 216 | struct debug_obj *obj; |
| 217 | |
| 218 | if (likely(obj_cache)) { |
Waiman Long | d86998b | 2019-05-20 10:14:46 -0400 | [diff] [blame] | 219 | obj = __alloc_object(&percpu_pool->free_objs); |
| 220 | if (obj) { |
| 221 | percpu_pool->obj_free--; |
| 222 | goto init_obj; |
| 223 | } |
| 224 | } |
Thomas Gleixner | 3ac7fe5 | 2008-04-30 00:55:01 -0700 | [diff] [blame] | 225 | |
Thomas Gleixner | aef9cb0 | 2009-11-17 18:11:28 +0100 | [diff] [blame] | 226 | raw_spin_lock(&pool_lock); |
Waiman Long | d86998b | 2019-05-20 10:14:46 -0400 | [diff] [blame] | 227 | obj = __alloc_object(&obj_pool); |
| 228 | if (obj) { |
Thomas Gleixner | 3ac7fe5 | 2008-04-30 00:55:01 -0700 | [diff] [blame] | 229 | obj_pool_used++; |
Waiman Long | 634d61f | 2019-05-20 10:14:47 -0400 | [diff] [blame] | 230 | obj_pool_free--; |
| 231 | |
| 232 | /* |
| 233 | * Looking ahead, allocate one batch of debug objects and |
| 234 | * put them into the percpu free pool. |
| 235 | */ |
| 236 | if (likely(obj_cache)) { |
| 237 | int i; |
| 238 | |
| 239 | for (i = 0; i < ODEBUG_BATCH_SIZE; i++) { |
| 240 | struct debug_obj *obj2; |
| 241 | |
| 242 | obj2 = __alloc_object(&obj_pool); |
| 243 | if (!obj2) |
| 244 | break; |
| 245 | hlist_add_head(&obj2->node, |
| 246 | &percpu_pool->free_objs); |
| 247 | percpu_pool->obj_free++; |
| 248 | obj_pool_used++; |
| 249 | obj_pool_free--; |
| 250 | } |
| 251 | } |
| 252 | |
Thomas Gleixner | 3ac7fe5 | 2008-04-30 00:55:01 -0700 | [diff] [blame] | 253 | if (obj_pool_used > obj_pool_max_used) |
| 254 | obj_pool_max_used = obj_pool_used; |
| 255 | |
Thomas Gleixner | 3ac7fe5 | 2008-04-30 00:55:01 -0700 | [diff] [blame] | 256 | if (obj_pool_free < obj_pool_min_free) |
| 257 | obj_pool_min_free = obj_pool_free; |
| 258 | } |
Thomas Gleixner | aef9cb0 | 2009-11-17 18:11:28 +0100 | [diff] [blame] | 259 | raw_spin_unlock(&pool_lock); |
Thomas Gleixner | 3ac7fe5 | 2008-04-30 00:55:01 -0700 | [diff] [blame] | 260 | |
Waiman Long | d86998b | 2019-05-20 10:14:46 -0400 | [diff] [blame] | 261 | init_obj: |
| 262 | if (obj) { |
| 263 | obj->object = addr; |
| 264 | obj->descr = descr; |
| 265 | obj->state = ODEBUG_STATE_NONE; |
| 266 | obj->astate = 0; |
| 267 | hlist_add_head(&obj->node, &b->list); |
| 268 | } |
Thomas Gleixner | 3ac7fe5 | 2008-04-30 00:55:01 -0700 | [diff] [blame] | 269 | return obj; |
| 270 | } |
| 271 | |
| 272 | /* |
Thomas Gleixner | 337fff8 | 2009-03-16 10:04:53 +0100 | [diff] [blame] | 273 | * workqueue function to free objects. |
Waiman Long | 858274b | 2017-01-05 15:17:05 -0500 | [diff] [blame] | 274 | * |
| 275 | * To reduce contention on the global pool_lock, the actual freeing of |
Yang Shi | 636e197 | 2018-02-06 07:18:27 +0800 | [diff] [blame] | 276 | * debug objects will be delayed if the pool_lock is busy. |
Thomas Gleixner | 337fff8 | 2009-03-16 10:04:53 +0100 | [diff] [blame] | 277 | */ |
| 278 | static void free_obj_work(struct work_struct *work) |
| 279 | { |
Yang Shi | 36c4ead | 2018-02-06 07:18:26 +0800 | [diff] [blame] | 280 | struct hlist_node *tmp; |
| 281 | struct debug_obj *obj; |
Thomas Gleixner | 337fff8 | 2009-03-16 10:04:53 +0100 | [diff] [blame] | 282 | unsigned long flags; |
Yang Shi | 36c4ead | 2018-02-06 07:18:26 +0800 | [diff] [blame] | 283 | HLIST_HEAD(tofree); |
Thomas Gleixner | 337fff8 | 2009-03-16 10:04:53 +0100 | [diff] [blame] | 284 | |
Waiman Long | 858274b | 2017-01-05 15:17:05 -0500 | [diff] [blame] | 285 | if (!raw_spin_trylock_irqsave(&pool_lock, flags)) |
| 286 | return; |
Yang Shi | 36c4ead | 2018-02-06 07:18:26 +0800 | [diff] [blame] | 287 | |
| 288 | /* |
| 289 | * The objs on the pool list might be allocated before the work is |
| 290 | * run, so recheck if pool list it full or not, if not fill pool |
Waiman Long | d26bf50 | 2019-05-20 10:14:48 -0400 | [diff] [blame^] | 291 | * list from the global free list. |
Yang Shi | 36c4ead | 2018-02-06 07:18:26 +0800 | [diff] [blame] | 292 | */ |
| 293 | while (obj_nr_tofree && obj_pool_free < debug_objects_pool_size) { |
| 294 | obj = hlist_entry(obj_to_free.first, typeof(*obj), node); |
| 295 | hlist_del(&obj->node); |
| 296 | hlist_add_head(&obj->node, &obj_pool); |
| 297 | obj_pool_free++; |
| 298 | obj_nr_tofree--; |
| 299 | } |
| 300 | |
| 301 | /* |
| 302 | * Pool list is already full and there are still objs on the free |
| 303 | * list. Move remaining free objs to a temporary list to free the |
| 304 | * memory outside the pool_lock held region. |
| 305 | */ |
| 306 | if (obj_nr_tofree) { |
| 307 | hlist_move_list(&obj_to_free, &tofree); |
Arnd Bergmann | 0414818 | 2018-02-22 16:52:58 +0100 | [diff] [blame] | 308 | debug_objects_freed += obj_nr_tofree; |
Yang Shi | 36c4ead | 2018-02-06 07:18:26 +0800 | [diff] [blame] | 309 | obj_nr_tofree = 0; |
| 310 | } |
Thomas Gleixner | aef9cb0 | 2009-11-17 18:11:28 +0100 | [diff] [blame] | 311 | raw_spin_unlock_irqrestore(&pool_lock, flags); |
Yang Shi | 36c4ead | 2018-02-06 07:18:26 +0800 | [diff] [blame] | 312 | |
| 313 | hlist_for_each_entry_safe(obj, tmp, &tofree, node) { |
| 314 | hlist_del(&obj->node); |
| 315 | kmem_cache_free(obj_cache, obj); |
| 316 | } |
Thomas Gleixner | 337fff8 | 2009-03-16 10:04:53 +0100 | [diff] [blame] | 317 | } |
| 318 | |
Yang Shi | 636e197 | 2018-02-06 07:18:27 +0800 | [diff] [blame] | 319 | static bool __free_object(struct debug_obj *obj) |
| 320 | { |
Waiman Long | 634d61f | 2019-05-20 10:14:47 -0400 | [diff] [blame] | 321 | struct debug_obj *objs[ODEBUG_BATCH_SIZE]; |
| 322 | struct debug_percpu_free *percpu_pool; |
| 323 | int lookahead_count = 0; |
Yang Shi | 636e197 | 2018-02-06 07:18:27 +0800 | [diff] [blame] | 324 | unsigned long flags; |
| 325 | bool work; |
| 326 | |
Waiman Long | d86998b | 2019-05-20 10:14:46 -0400 | [diff] [blame] | 327 | local_irq_save(flags); |
Waiman Long | 634d61f | 2019-05-20 10:14:47 -0400 | [diff] [blame] | 328 | if (!obj_cache) |
| 329 | goto free_to_obj_pool; |
| 330 | |
Waiman Long | d86998b | 2019-05-20 10:14:46 -0400 | [diff] [blame] | 331 | /* |
| 332 | * Try to free it into the percpu pool first. |
| 333 | */ |
| 334 | percpu_pool = this_cpu_ptr(&percpu_obj_pool); |
Waiman Long | 634d61f | 2019-05-20 10:14:47 -0400 | [diff] [blame] | 335 | if (percpu_pool->obj_free < ODEBUG_POOL_PERCPU_SIZE) { |
Waiman Long | d86998b | 2019-05-20 10:14:46 -0400 | [diff] [blame] | 336 | hlist_add_head(&obj->node, &percpu_pool->free_objs); |
| 337 | percpu_pool->obj_free++; |
| 338 | local_irq_restore(flags); |
| 339 | return false; |
| 340 | } |
| 341 | |
Waiman Long | 634d61f | 2019-05-20 10:14:47 -0400 | [diff] [blame] | 342 | /* |
| 343 | * As the percpu pool is full, look ahead and pull out a batch |
| 344 | * of objects from the percpu pool and free them as well. |
| 345 | */ |
| 346 | for (; lookahead_count < ODEBUG_BATCH_SIZE; lookahead_count++) { |
| 347 | objs[lookahead_count] = __alloc_object(&percpu_pool->free_objs); |
| 348 | if (!objs[lookahead_count]) |
| 349 | break; |
| 350 | percpu_pool->obj_free--; |
| 351 | } |
| 352 | |
| 353 | free_to_obj_pool: |
Waiman Long | d86998b | 2019-05-20 10:14:46 -0400 | [diff] [blame] | 354 | raw_spin_lock(&pool_lock); |
Yang Shi | 636e197 | 2018-02-06 07:18:27 +0800 | [diff] [blame] | 355 | work = (obj_pool_free > debug_objects_pool_size) && obj_cache; |
| 356 | obj_pool_used--; |
| 357 | |
| 358 | if (work) { |
| 359 | obj_nr_tofree++; |
| 360 | hlist_add_head(&obj->node, &obj_to_free); |
Waiman Long | 634d61f | 2019-05-20 10:14:47 -0400 | [diff] [blame] | 361 | if (lookahead_count) { |
| 362 | obj_nr_tofree += lookahead_count; |
| 363 | obj_pool_used -= lookahead_count; |
| 364 | while (lookahead_count) { |
| 365 | hlist_add_head(&objs[--lookahead_count]->node, |
| 366 | &obj_to_free); |
| 367 | } |
| 368 | } |
Yang Shi | 636e197 | 2018-02-06 07:18:27 +0800 | [diff] [blame] | 369 | } else { |
| 370 | obj_pool_free++; |
| 371 | hlist_add_head(&obj->node, &obj_pool); |
Waiman Long | 634d61f | 2019-05-20 10:14:47 -0400 | [diff] [blame] | 372 | if (lookahead_count) { |
| 373 | obj_pool_free += lookahead_count; |
| 374 | obj_pool_used -= lookahead_count; |
| 375 | while (lookahead_count) { |
| 376 | hlist_add_head(&objs[--lookahead_count]->node, |
| 377 | &obj_pool); |
| 378 | } |
| 379 | } |
Yang Shi | 636e197 | 2018-02-06 07:18:27 +0800 | [diff] [blame] | 380 | } |
Waiman Long | d86998b | 2019-05-20 10:14:46 -0400 | [diff] [blame] | 381 | raw_spin_unlock(&pool_lock); |
| 382 | local_irq_restore(flags); |
Yang Shi | 636e197 | 2018-02-06 07:18:27 +0800 | [diff] [blame] | 383 | return work; |
| 384 | } |
| 385 | |
Thomas Gleixner | 337fff8 | 2009-03-16 10:04:53 +0100 | [diff] [blame] | 386 | /* |
| 387 | * Put the object back into the pool and schedule work to free objects |
| 388 | * if necessary. |
Thomas Gleixner | 3ac7fe5 | 2008-04-30 00:55:01 -0700 | [diff] [blame] | 389 | */ |
| 390 | static void free_object(struct debug_obj *obj) |
| 391 | { |
Yang Shi | 636e197 | 2018-02-06 07:18:27 +0800 | [diff] [blame] | 392 | if (__free_object(obj)) |
Thomas Gleixner | 337fff8 | 2009-03-16 10:04:53 +0100 | [diff] [blame] | 393 | schedule_work(&debug_obj_work); |
Thomas Gleixner | 3ac7fe5 | 2008-04-30 00:55:01 -0700 | [diff] [blame] | 394 | } |
| 395 | |
| 396 | /* |
| 397 | * We run out of memory. That means we probably have tons of objects |
| 398 | * allocated. |
| 399 | */ |
| 400 | static void debug_objects_oom(void) |
| 401 | { |
| 402 | struct debug_bucket *db = obj_hash; |
Sasha Levin | b67bfe0 | 2013-02-27 17:06:00 -0800 | [diff] [blame] | 403 | struct hlist_node *tmp; |
Vegard Nossum | 673d62cc | 2008-08-31 23:39:21 +0200 | [diff] [blame] | 404 | HLIST_HEAD(freelist); |
Thomas Gleixner | 3ac7fe5 | 2008-04-30 00:55:01 -0700 | [diff] [blame] | 405 | struct debug_obj *obj; |
| 406 | unsigned long flags; |
| 407 | int i; |
| 408 | |
Fabian Frederick | 719e484 | 2014-06-04 16:06:04 -0700 | [diff] [blame] | 409 | pr_warn("Out of memory. ODEBUG disabled\n"); |
Thomas Gleixner | 3ac7fe5 | 2008-04-30 00:55:01 -0700 | [diff] [blame] | 410 | |
| 411 | for (i = 0; i < ODEBUG_HASH_SIZE; i++, db++) { |
Thomas Gleixner | aef9cb0 | 2009-11-17 18:11:28 +0100 | [diff] [blame] | 412 | raw_spin_lock_irqsave(&db->lock, flags); |
Vegard Nossum | 673d62cc | 2008-08-31 23:39:21 +0200 | [diff] [blame] | 413 | hlist_move_list(&db->list, &freelist); |
Thomas Gleixner | aef9cb0 | 2009-11-17 18:11:28 +0100 | [diff] [blame] | 414 | raw_spin_unlock_irqrestore(&db->lock, flags); |
Vegard Nossum | 673d62cc | 2008-08-31 23:39:21 +0200 | [diff] [blame] | 415 | |
| 416 | /* Now free them */ |
Sasha Levin | b67bfe0 | 2013-02-27 17:06:00 -0800 | [diff] [blame] | 417 | hlist_for_each_entry_safe(obj, tmp, &freelist, node) { |
Thomas Gleixner | 3ac7fe5 | 2008-04-30 00:55:01 -0700 | [diff] [blame] | 418 | hlist_del(&obj->node); |
| 419 | free_object(obj); |
| 420 | } |
Thomas Gleixner | 3ac7fe5 | 2008-04-30 00:55:01 -0700 | [diff] [blame] | 421 | } |
| 422 | } |
| 423 | |
| 424 | /* |
| 425 | * We use the pfn of the address for the hash. That way we can check |
| 426 | * for freed objects simply by checking the affected bucket. |
| 427 | */ |
| 428 | static struct debug_bucket *get_bucket(unsigned long addr) |
| 429 | { |
| 430 | unsigned long hash; |
| 431 | |
| 432 | hash = hash_long((addr >> ODEBUG_CHUNK_SHIFT), ODEBUG_HASH_BITS); |
| 433 | return &obj_hash[hash]; |
| 434 | } |
| 435 | |
| 436 | static void debug_print_object(struct debug_obj *obj, char *msg) |
| 437 | { |
Stanislaw Gruszka | 9977728 | 2011-03-07 09:58:33 +0100 | [diff] [blame] | 438 | struct debug_obj_descr *descr = obj->descr; |
Thomas Gleixner | 3ac7fe5 | 2008-04-30 00:55:01 -0700 | [diff] [blame] | 439 | static int limit; |
| 440 | |
Stanislaw Gruszka | 9977728 | 2011-03-07 09:58:33 +0100 | [diff] [blame] | 441 | if (limit < 5 && descr != descr_test) { |
| 442 | void *hint = descr->debug_hint ? |
| 443 | descr->debug_hint(obj->object) : NULL; |
Thomas Gleixner | 3ac7fe5 | 2008-04-30 00:55:01 -0700 | [diff] [blame] | 444 | limit++; |
Mathieu Desnoyers | a5d8e46 | 2010-04-17 08:48:38 -0400 | [diff] [blame] | 445 | WARN(1, KERN_ERR "ODEBUG: %s %s (active state %u) " |
Stanislaw Gruszka | 9977728 | 2011-03-07 09:58:33 +0100 | [diff] [blame] | 446 | "object type: %s hint: %pS\n", |
Mathieu Desnoyers | a5d8e46 | 2010-04-17 08:48:38 -0400 | [diff] [blame] | 447 | msg, obj_states[obj->state], obj->astate, |
Stanislaw Gruszka | 9977728 | 2011-03-07 09:58:33 +0100 | [diff] [blame] | 448 | descr->name, hint); |
Thomas Gleixner | 3ac7fe5 | 2008-04-30 00:55:01 -0700 | [diff] [blame] | 449 | } |
| 450 | debug_objects_warnings++; |
| 451 | } |
| 452 | |
| 453 | /* |
| 454 | * Try to repair the damage, so we have a better chance to get useful |
| 455 | * debug output. |
| 456 | */ |
Du, Changbin | b1e4d9d | 2016-05-19 17:09:20 -0700 | [diff] [blame] | 457 | static bool |
| 458 | debug_object_fixup(bool (*fixup)(void *addr, enum debug_obj_state state), |
Thomas Gleixner | 3ac7fe5 | 2008-04-30 00:55:01 -0700 | [diff] [blame] | 459 | void * addr, enum debug_obj_state state) |
| 460 | { |
Du, Changbin | b1e4d9d | 2016-05-19 17:09:20 -0700 | [diff] [blame] | 461 | if (fixup && fixup(addr, state)) { |
| 462 | debug_objects_fixups++; |
| 463 | return true; |
| 464 | } |
| 465 | return false; |
Thomas Gleixner | 3ac7fe5 | 2008-04-30 00:55:01 -0700 | [diff] [blame] | 466 | } |
| 467 | |
| 468 | static void debug_object_is_on_stack(void *addr, int onstack) |
| 469 | { |
Thomas Gleixner | 3ac7fe5 | 2008-04-30 00:55:01 -0700 | [diff] [blame] | 470 | int is_on_stack; |
| 471 | static int limit; |
| 472 | |
| 473 | if (limit > 4) |
| 474 | return; |
| 475 | |
FUJITA Tomonori | 8b05c7e | 2008-07-23 21:26:53 -0700 | [diff] [blame] | 476 | is_on_stack = object_is_on_stack(addr); |
Thomas Gleixner | 3ac7fe5 | 2008-04-30 00:55:01 -0700 | [diff] [blame] | 477 | if (is_on_stack == onstack) |
| 478 | return; |
| 479 | |
| 480 | limit++; |
| 481 | if (is_on_stack) |
Joel Fernandes (Google) | fc91a3c | 2018-07-23 14:25:31 -0700 | [diff] [blame] | 482 | pr_warn("object %p is on stack %p, but NOT annotated.\n", addr, |
| 483 | task_stack_page(current)); |
Thomas Gleixner | 3ac7fe5 | 2008-04-30 00:55:01 -0700 | [diff] [blame] | 484 | else |
Joel Fernandes (Google) | fc91a3c | 2018-07-23 14:25:31 -0700 | [diff] [blame] | 485 | pr_warn("object %p is NOT on stack %p, but annotated.\n", addr, |
| 486 | task_stack_page(current)); |
| 487 | |
Thomas Gleixner | 3ac7fe5 | 2008-04-30 00:55:01 -0700 | [diff] [blame] | 488 | WARN_ON(1); |
| 489 | } |
| 490 | |
| 491 | static void |
| 492 | __debug_object_init(void *addr, struct debug_obj_descr *descr, int onstack) |
| 493 | { |
| 494 | enum debug_obj_state state; |
| 495 | struct debug_bucket *db; |
| 496 | struct debug_obj *obj; |
| 497 | unsigned long flags; |
| 498 | |
Vegard Nossum | 50db04dd | 2008-06-15 00:47:36 +0200 | [diff] [blame] | 499 | fill_pool(); |
| 500 | |
Thomas Gleixner | 3ac7fe5 | 2008-04-30 00:55:01 -0700 | [diff] [blame] | 501 | db = get_bucket((unsigned long) addr); |
| 502 | |
Thomas Gleixner | aef9cb0 | 2009-11-17 18:11:28 +0100 | [diff] [blame] | 503 | raw_spin_lock_irqsave(&db->lock, flags); |
Thomas Gleixner | 3ac7fe5 | 2008-04-30 00:55:01 -0700 | [diff] [blame] | 504 | |
| 505 | obj = lookup_object(addr, db); |
| 506 | if (!obj) { |
| 507 | obj = alloc_object(addr, db, descr); |
| 508 | if (!obj) { |
| 509 | debug_objects_enabled = 0; |
Thomas Gleixner | aef9cb0 | 2009-11-17 18:11:28 +0100 | [diff] [blame] | 510 | raw_spin_unlock_irqrestore(&db->lock, flags); |
Thomas Gleixner | 3ac7fe5 | 2008-04-30 00:55:01 -0700 | [diff] [blame] | 511 | debug_objects_oom(); |
| 512 | return; |
| 513 | } |
| 514 | debug_object_is_on_stack(addr, onstack); |
| 515 | } |
| 516 | |
| 517 | switch (obj->state) { |
| 518 | case ODEBUG_STATE_NONE: |
| 519 | case ODEBUG_STATE_INIT: |
| 520 | case ODEBUG_STATE_INACTIVE: |
| 521 | obj->state = ODEBUG_STATE_INIT; |
| 522 | break; |
| 523 | |
| 524 | case ODEBUG_STATE_ACTIVE: |
| 525 | debug_print_object(obj, "init"); |
| 526 | state = obj->state; |
Thomas Gleixner | aef9cb0 | 2009-11-17 18:11:28 +0100 | [diff] [blame] | 527 | raw_spin_unlock_irqrestore(&db->lock, flags); |
Thomas Gleixner | 3ac7fe5 | 2008-04-30 00:55:01 -0700 | [diff] [blame] | 528 | debug_object_fixup(descr->fixup_init, addr, state); |
| 529 | return; |
| 530 | |
| 531 | case ODEBUG_STATE_DESTROYED: |
| 532 | debug_print_object(obj, "init"); |
| 533 | break; |
| 534 | default: |
| 535 | break; |
| 536 | } |
| 537 | |
Thomas Gleixner | aef9cb0 | 2009-11-17 18:11:28 +0100 | [diff] [blame] | 538 | raw_spin_unlock_irqrestore(&db->lock, flags); |
Thomas Gleixner | 3ac7fe5 | 2008-04-30 00:55:01 -0700 | [diff] [blame] | 539 | } |
| 540 | |
| 541 | /** |
| 542 | * debug_object_init - debug checks when an object is initialized |
| 543 | * @addr: address of the object |
| 544 | * @descr: pointer to an object specific debug description structure |
| 545 | */ |
| 546 | void debug_object_init(void *addr, struct debug_obj_descr *descr) |
| 547 | { |
| 548 | if (!debug_objects_enabled) |
| 549 | return; |
| 550 | |
| 551 | __debug_object_init(addr, descr, 0); |
| 552 | } |
Chris Wilson | f8ff04e | 2016-11-30 15:54:10 -0800 | [diff] [blame] | 553 | EXPORT_SYMBOL_GPL(debug_object_init); |
Thomas Gleixner | 3ac7fe5 | 2008-04-30 00:55:01 -0700 | [diff] [blame] | 554 | |
| 555 | /** |
| 556 | * debug_object_init_on_stack - debug checks when an object on stack is |
| 557 | * initialized |
| 558 | * @addr: address of the object |
| 559 | * @descr: pointer to an object specific debug description structure |
| 560 | */ |
| 561 | void debug_object_init_on_stack(void *addr, struct debug_obj_descr *descr) |
| 562 | { |
| 563 | if (!debug_objects_enabled) |
| 564 | return; |
| 565 | |
| 566 | __debug_object_init(addr, descr, 1); |
| 567 | } |
Chris Wilson | f8ff04e | 2016-11-30 15:54:10 -0800 | [diff] [blame] | 568 | EXPORT_SYMBOL_GPL(debug_object_init_on_stack); |
Thomas Gleixner | 3ac7fe5 | 2008-04-30 00:55:01 -0700 | [diff] [blame] | 569 | |
| 570 | /** |
| 571 | * debug_object_activate - debug checks when an object is activated |
| 572 | * @addr: address of the object |
| 573 | * @descr: pointer to an object specific debug description structure |
Paul E. McKenney | b778ae2 | 2013-04-23 12:51:11 -0700 | [diff] [blame] | 574 | * Returns 0 for success, -EINVAL for check failed. |
Thomas Gleixner | 3ac7fe5 | 2008-04-30 00:55:01 -0700 | [diff] [blame] | 575 | */ |
Paul E. McKenney | b778ae2 | 2013-04-23 12:51:11 -0700 | [diff] [blame] | 576 | int debug_object_activate(void *addr, struct debug_obj_descr *descr) |
Thomas Gleixner | 3ac7fe5 | 2008-04-30 00:55:01 -0700 | [diff] [blame] | 577 | { |
| 578 | enum debug_obj_state state; |
| 579 | struct debug_bucket *db; |
| 580 | struct debug_obj *obj; |
| 581 | unsigned long flags; |
Paul E. McKenney | b778ae2 | 2013-04-23 12:51:11 -0700 | [diff] [blame] | 582 | int ret; |
Stephen Boyd | feac18d | 2011-11-07 19:48:26 -0800 | [diff] [blame] | 583 | struct debug_obj o = { .object = addr, |
| 584 | .state = ODEBUG_STATE_NOTAVAILABLE, |
| 585 | .descr = descr }; |
Thomas Gleixner | 3ac7fe5 | 2008-04-30 00:55:01 -0700 | [diff] [blame] | 586 | |
| 587 | if (!debug_objects_enabled) |
Paul E. McKenney | b778ae2 | 2013-04-23 12:51:11 -0700 | [diff] [blame] | 588 | return 0; |
Thomas Gleixner | 3ac7fe5 | 2008-04-30 00:55:01 -0700 | [diff] [blame] | 589 | |
| 590 | db = get_bucket((unsigned long) addr); |
| 591 | |
Thomas Gleixner | aef9cb0 | 2009-11-17 18:11:28 +0100 | [diff] [blame] | 592 | raw_spin_lock_irqsave(&db->lock, flags); |
Thomas Gleixner | 3ac7fe5 | 2008-04-30 00:55:01 -0700 | [diff] [blame] | 593 | |
| 594 | obj = lookup_object(addr, db); |
| 595 | if (obj) { |
| 596 | switch (obj->state) { |
| 597 | case ODEBUG_STATE_INIT: |
| 598 | case ODEBUG_STATE_INACTIVE: |
| 599 | obj->state = ODEBUG_STATE_ACTIVE; |
Paul E. McKenney | b778ae2 | 2013-04-23 12:51:11 -0700 | [diff] [blame] | 600 | ret = 0; |
Thomas Gleixner | 3ac7fe5 | 2008-04-30 00:55:01 -0700 | [diff] [blame] | 601 | break; |
| 602 | |
| 603 | case ODEBUG_STATE_ACTIVE: |
| 604 | debug_print_object(obj, "activate"); |
| 605 | state = obj->state; |
Thomas Gleixner | aef9cb0 | 2009-11-17 18:11:28 +0100 | [diff] [blame] | 606 | raw_spin_unlock_irqrestore(&db->lock, flags); |
Paul E. McKenney | b778ae2 | 2013-04-23 12:51:11 -0700 | [diff] [blame] | 607 | ret = debug_object_fixup(descr->fixup_activate, addr, state); |
Du, Changbin | e7a8e78 | 2016-05-19 17:09:23 -0700 | [diff] [blame] | 608 | return ret ? 0 : -EINVAL; |
Thomas Gleixner | 3ac7fe5 | 2008-04-30 00:55:01 -0700 | [diff] [blame] | 609 | |
| 610 | case ODEBUG_STATE_DESTROYED: |
| 611 | debug_print_object(obj, "activate"); |
Paul E. McKenney | b778ae2 | 2013-04-23 12:51:11 -0700 | [diff] [blame] | 612 | ret = -EINVAL; |
Thomas Gleixner | 3ac7fe5 | 2008-04-30 00:55:01 -0700 | [diff] [blame] | 613 | break; |
| 614 | default: |
Paul E. McKenney | b778ae2 | 2013-04-23 12:51:11 -0700 | [diff] [blame] | 615 | ret = 0; |
Thomas Gleixner | 3ac7fe5 | 2008-04-30 00:55:01 -0700 | [diff] [blame] | 616 | break; |
| 617 | } |
Thomas Gleixner | aef9cb0 | 2009-11-17 18:11:28 +0100 | [diff] [blame] | 618 | raw_spin_unlock_irqrestore(&db->lock, flags); |
Paul E. McKenney | b778ae2 | 2013-04-23 12:51:11 -0700 | [diff] [blame] | 619 | return ret; |
Thomas Gleixner | 3ac7fe5 | 2008-04-30 00:55:01 -0700 | [diff] [blame] | 620 | } |
| 621 | |
Thomas Gleixner | aef9cb0 | 2009-11-17 18:11:28 +0100 | [diff] [blame] | 622 | raw_spin_unlock_irqrestore(&db->lock, flags); |
Thomas Gleixner | 3ac7fe5 | 2008-04-30 00:55:01 -0700 | [diff] [blame] | 623 | /* |
Du, Changbin | b9fdac7f | 2016-05-19 17:09:41 -0700 | [diff] [blame] | 624 | * We are here when a static object is activated. We |
| 625 | * let the type specific code confirm whether this is |
| 626 | * true or not. if true, we just make sure that the |
| 627 | * static object is tracked in the object tracker. If |
| 628 | * not, this must be a bug, so we try to fix it up. |
Thomas Gleixner | 3ac7fe5 | 2008-04-30 00:55:01 -0700 | [diff] [blame] | 629 | */ |
Du, Changbin | b9fdac7f | 2016-05-19 17:09:41 -0700 | [diff] [blame] | 630 | if (descr->is_static_object && descr->is_static_object(addr)) { |
| 631 | /* track this static object */ |
| 632 | debug_object_init(addr, descr); |
| 633 | debug_object_activate(addr, descr); |
| 634 | } else { |
Stephen Boyd | feac18d | 2011-11-07 19:48:26 -0800 | [diff] [blame] | 635 | debug_print_object(&o, "activate"); |
Du, Changbin | b9fdac7f | 2016-05-19 17:09:41 -0700 | [diff] [blame] | 636 | ret = debug_object_fixup(descr->fixup_activate, addr, |
| 637 | ODEBUG_STATE_NOTAVAILABLE); |
| 638 | return ret ? 0 : -EINVAL; |
Paul E. McKenney | b778ae2 | 2013-04-23 12:51:11 -0700 | [diff] [blame] | 639 | } |
| 640 | return 0; |
Thomas Gleixner | 3ac7fe5 | 2008-04-30 00:55:01 -0700 | [diff] [blame] | 641 | } |
Chris Wilson | f8ff04e | 2016-11-30 15:54:10 -0800 | [diff] [blame] | 642 | EXPORT_SYMBOL_GPL(debug_object_activate); |
Thomas Gleixner | 3ac7fe5 | 2008-04-30 00:55:01 -0700 | [diff] [blame] | 643 | |
| 644 | /** |
| 645 | * debug_object_deactivate - debug checks when an object is deactivated |
| 646 | * @addr: address of the object |
| 647 | * @descr: pointer to an object specific debug description structure |
| 648 | */ |
| 649 | void debug_object_deactivate(void *addr, struct debug_obj_descr *descr) |
| 650 | { |
| 651 | struct debug_bucket *db; |
| 652 | struct debug_obj *obj; |
| 653 | unsigned long flags; |
| 654 | |
| 655 | if (!debug_objects_enabled) |
| 656 | return; |
| 657 | |
| 658 | db = get_bucket((unsigned long) addr); |
| 659 | |
Thomas Gleixner | aef9cb0 | 2009-11-17 18:11:28 +0100 | [diff] [blame] | 660 | raw_spin_lock_irqsave(&db->lock, flags); |
Thomas Gleixner | 3ac7fe5 | 2008-04-30 00:55:01 -0700 | [diff] [blame] | 661 | |
| 662 | obj = lookup_object(addr, db); |
| 663 | if (obj) { |
| 664 | switch (obj->state) { |
| 665 | case ODEBUG_STATE_INIT: |
| 666 | case ODEBUG_STATE_INACTIVE: |
| 667 | case ODEBUG_STATE_ACTIVE: |
Mathieu Desnoyers | a5d8e46 | 2010-04-17 08:48:38 -0400 | [diff] [blame] | 668 | if (!obj->astate) |
| 669 | obj->state = ODEBUG_STATE_INACTIVE; |
| 670 | else |
| 671 | debug_print_object(obj, "deactivate"); |
Thomas Gleixner | 3ac7fe5 | 2008-04-30 00:55:01 -0700 | [diff] [blame] | 672 | break; |
| 673 | |
| 674 | case ODEBUG_STATE_DESTROYED: |
| 675 | debug_print_object(obj, "deactivate"); |
| 676 | break; |
| 677 | default: |
| 678 | break; |
| 679 | } |
| 680 | } else { |
| 681 | struct debug_obj o = { .object = addr, |
| 682 | .state = ODEBUG_STATE_NOTAVAILABLE, |
| 683 | .descr = descr }; |
| 684 | |
| 685 | debug_print_object(&o, "deactivate"); |
| 686 | } |
| 687 | |
Thomas Gleixner | aef9cb0 | 2009-11-17 18:11:28 +0100 | [diff] [blame] | 688 | raw_spin_unlock_irqrestore(&db->lock, flags); |
Thomas Gleixner | 3ac7fe5 | 2008-04-30 00:55:01 -0700 | [diff] [blame] | 689 | } |
Chris Wilson | f8ff04e | 2016-11-30 15:54:10 -0800 | [diff] [blame] | 690 | EXPORT_SYMBOL_GPL(debug_object_deactivate); |
Thomas Gleixner | 3ac7fe5 | 2008-04-30 00:55:01 -0700 | [diff] [blame] | 691 | |
| 692 | /** |
| 693 | * debug_object_destroy - debug checks when an object is destroyed |
| 694 | * @addr: address of the object |
| 695 | * @descr: pointer to an object specific debug description structure |
| 696 | */ |
| 697 | void debug_object_destroy(void *addr, struct debug_obj_descr *descr) |
| 698 | { |
| 699 | enum debug_obj_state state; |
| 700 | struct debug_bucket *db; |
| 701 | struct debug_obj *obj; |
| 702 | unsigned long flags; |
| 703 | |
| 704 | if (!debug_objects_enabled) |
| 705 | return; |
| 706 | |
| 707 | db = get_bucket((unsigned long) addr); |
| 708 | |
Thomas Gleixner | aef9cb0 | 2009-11-17 18:11:28 +0100 | [diff] [blame] | 709 | raw_spin_lock_irqsave(&db->lock, flags); |
Thomas Gleixner | 3ac7fe5 | 2008-04-30 00:55:01 -0700 | [diff] [blame] | 710 | |
| 711 | obj = lookup_object(addr, db); |
| 712 | if (!obj) |
| 713 | goto out_unlock; |
| 714 | |
| 715 | switch (obj->state) { |
| 716 | case ODEBUG_STATE_NONE: |
| 717 | case ODEBUG_STATE_INIT: |
| 718 | case ODEBUG_STATE_INACTIVE: |
| 719 | obj->state = ODEBUG_STATE_DESTROYED; |
| 720 | break; |
| 721 | case ODEBUG_STATE_ACTIVE: |
| 722 | debug_print_object(obj, "destroy"); |
| 723 | state = obj->state; |
Thomas Gleixner | aef9cb0 | 2009-11-17 18:11:28 +0100 | [diff] [blame] | 724 | raw_spin_unlock_irqrestore(&db->lock, flags); |
Thomas Gleixner | 3ac7fe5 | 2008-04-30 00:55:01 -0700 | [diff] [blame] | 725 | debug_object_fixup(descr->fixup_destroy, addr, state); |
| 726 | return; |
| 727 | |
| 728 | case ODEBUG_STATE_DESTROYED: |
| 729 | debug_print_object(obj, "destroy"); |
| 730 | break; |
| 731 | default: |
| 732 | break; |
| 733 | } |
| 734 | out_unlock: |
Thomas Gleixner | aef9cb0 | 2009-11-17 18:11:28 +0100 | [diff] [blame] | 735 | raw_spin_unlock_irqrestore(&db->lock, flags); |
Thomas Gleixner | 3ac7fe5 | 2008-04-30 00:55:01 -0700 | [diff] [blame] | 736 | } |
Chris Wilson | f8ff04e | 2016-11-30 15:54:10 -0800 | [diff] [blame] | 737 | EXPORT_SYMBOL_GPL(debug_object_destroy); |
Thomas Gleixner | 3ac7fe5 | 2008-04-30 00:55:01 -0700 | [diff] [blame] | 738 | |
| 739 | /** |
| 740 | * debug_object_free - debug checks when an object is freed |
| 741 | * @addr: address of the object |
| 742 | * @descr: pointer to an object specific debug description structure |
| 743 | */ |
| 744 | void debug_object_free(void *addr, struct debug_obj_descr *descr) |
| 745 | { |
| 746 | enum debug_obj_state state; |
| 747 | struct debug_bucket *db; |
| 748 | struct debug_obj *obj; |
| 749 | unsigned long flags; |
| 750 | |
| 751 | if (!debug_objects_enabled) |
| 752 | return; |
| 753 | |
| 754 | db = get_bucket((unsigned long) addr); |
| 755 | |
Thomas Gleixner | aef9cb0 | 2009-11-17 18:11:28 +0100 | [diff] [blame] | 756 | raw_spin_lock_irqsave(&db->lock, flags); |
Thomas Gleixner | 3ac7fe5 | 2008-04-30 00:55:01 -0700 | [diff] [blame] | 757 | |
| 758 | obj = lookup_object(addr, db); |
| 759 | if (!obj) |
| 760 | goto out_unlock; |
| 761 | |
| 762 | switch (obj->state) { |
| 763 | case ODEBUG_STATE_ACTIVE: |
| 764 | debug_print_object(obj, "free"); |
| 765 | state = obj->state; |
Thomas Gleixner | aef9cb0 | 2009-11-17 18:11:28 +0100 | [diff] [blame] | 766 | raw_spin_unlock_irqrestore(&db->lock, flags); |
Thomas Gleixner | 3ac7fe5 | 2008-04-30 00:55:01 -0700 | [diff] [blame] | 767 | debug_object_fixup(descr->fixup_free, addr, state); |
| 768 | return; |
| 769 | default: |
| 770 | hlist_del(&obj->node); |
Thomas Gleixner | aef9cb0 | 2009-11-17 18:11:28 +0100 | [diff] [blame] | 771 | raw_spin_unlock_irqrestore(&db->lock, flags); |
Thomas Gleixner | 3ac7fe5 | 2008-04-30 00:55:01 -0700 | [diff] [blame] | 772 | free_object(obj); |
Vegard Nossum | 673d62cc | 2008-08-31 23:39:21 +0200 | [diff] [blame] | 773 | return; |
Thomas Gleixner | 3ac7fe5 | 2008-04-30 00:55:01 -0700 | [diff] [blame] | 774 | } |
| 775 | out_unlock: |
Thomas Gleixner | aef9cb0 | 2009-11-17 18:11:28 +0100 | [diff] [blame] | 776 | raw_spin_unlock_irqrestore(&db->lock, flags); |
Thomas Gleixner | 3ac7fe5 | 2008-04-30 00:55:01 -0700 | [diff] [blame] | 777 | } |
Chris Wilson | f8ff04e | 2016-11-30 15:54:10 -0800 | [diff] [blame] | 778 | EXPORT_SYMBOL_GPL(debug_object_free); |
Thomas Gleixner | 3ac7fe5 | 2008-04-30 00:55:01 -0700 | [diff] [blame] | 779 | |
Mathieu Desnoyers | a5d8e46 | 2010-04-17 08:48:38 -0400 | [diff] [blame] | 780 | /** |
Christine Chan | b84d435 | 2011-11-07 19:48:27 -0800 | [diff] [blame] | 781 | * debug_object_assert_init - debug checks when object should be init-ed |
| 782 | * @addr: address of the object |
| 783 | * @descr: pointer to an object specific debug description structure |
| 784 | */ |
| 785 | void debug_object_assert_init(void *addr, struct debug_obj_descr *descr) |
| 786 | { |
| 787 | struct debug_bucket *db; |
| 788 | struct debug_obj *obj; |
| 789 | unsigned long flags; |
| 790 | |
| 791 | if (!debug_objects_enabled) |
| 792 | return; |
| 793 | |
| 794 | db = get_bucket((unsigned long) addr); |
| 795 | |
| 796 | raw_spin_lock_irqsave(&db->lock, flags); |
| 797 | |
| 798 | obj = lookup_object(addr, db); |
| 799 | if (!obj) { |
| 800 | struct debug_obj o = { .object = addr, |
| 801 | .state = ODEBUG_STATE_NOTAVAILABLE, |
| 802 | .descr = descr }; |
| 803 | |
| 804 | raw_spin_unlock_irqrestore(&db->lock, flags); |
| 805 | /* |
Du, Changbin | b9fdac7f | 2016-05-19 17:09:41 -0700 | [diff] [blame] | 806 | * Maybe the object is static, and we let the type specific |
| 807 | * code confirm. Track this static object if true, else invoke |
| 808 | * fixup. |
Christine Chan | b84d435 | 2011-11-07 19:48:27 -0800 | [diff] [blame] | 809 | */ |
Du, Changbin | b9fdac7f | 2016-05-19 17:09:41 -0700 | [diff] [blame] | 810 | if (descr->is_static_object && descr->is_static_object(addr)) { |
| 811 | /* Track this static object */ |
| 812 | debug_object_init(addr, descr); |
| 813 | } else { |
Christine Chan | b84d435 | 2011-11-07 19:48:27 -0800 | [diff] [blame] | 814 | debug_print_object(&o, "assert_init"); |
Du, Changbin | b9fdac7f | 2016-05-19 17:09:41 -0700 | [diff] [blame] | 815 | debug_object_fixup(descr->fixup_assert_init, addr, |
| 816 | ODEBUG_STATE_NOTAVAILABLE); |
| 817 | } |
Christine Chan | b84d435 | 2011-11-07 19:48:27 -0800 | [diff] [blame] | 818 | return; |
| 819 | } |
| 820 | |
| 821 | raw_spin_unlock_irqrestore(&db->lock, flags); |
| 822 | } |
Chris Wilson | f8ff04e | 2016-11-30 15:54:10 -0800 | [diff] [blame] | 823 | EXPORT_SYMBOL_GPL(debug_object_assert_init); |
Christine Chan | b84d435 | 2011-11-07 19:48:27 -0800 | [diff] [blame] | 824 | |
| 825 | /** |
Mathieu Desnoyers | a5d8e46 | 2010-04-17 08:48:38 -0400 | [diff] [blame] | 826 | * debug_object_active_state - debug checks object usage state machine |
| 827 | * @addr: address of the object |
| 828 | * @descr: pointer to an object specific debug description structure |
| 829 | * @expect: expected state |
| 830 | * @next: state to move to if expected state is found |
| 831 | */ |
| 832 | void |
| 833 | debug_object_active_state(void *addr, struct debug_obj_descr *descr, |
| 834 | unsigned int expect, unsigned int next) |
| 835 | { |
| 836 | struct debug_bucket *db; |
| 837 | struct debug_obj *obj; |
| 838 | unsigned long flags; |
| 839 | |
| 840 | if (!debug_objects_enabled) |
| 841 | return; |
| 842 | |
| 843 | db = get_bucket((unsigned long) addr); |
| 844 | |
| 845 | raw_spin_lock_irqsave(&db->lock, flags); |
| 846 | |
| 847 | obj = lookup_object(addr, db); |
| 848 | if (obj) { |
| 849 | switch (obj->state) { |
| 850 | case ODEBUG_STATE_ACTIVE: |
| 851 | if (obj->astate == expect) |
| 852 | obj->astate = next; |
| 853 | else |
| 854 | debug_print_object(obj, "active_state"); |
| 855 | break; |
| 856 | |
| 857 | default: |
| 858 | debug_print_object(obj, "active_state"); |
| 859 | break; |
| 860 | } |
| 861 | } else { |
| 862 | struct debug_obj o = { .object = addr, |
| 863 | .state = ODEBUG_STATE_NOTAVAILABLE, |
| 864 | .descr = descr }; |
| 865 | |
| 866 | debug_print_object(&o, "active_state"); |
| 867 | } |
| 868 | |
| 869 | raw_spin_unlock_irqrestore(&db->lock, flags); |
| 870 | } |
Chris Wilson | f8ff04e | 2016-11-30 15:54:10 -0800 | [diff] [blame] | 871 | EXPORT_SYMBOL_GPL(debug_object_active_state); |
Mathieu Desnoyers | a5d8e46 | 2010-04-17 08:48:38 -0400 | [diff] [blame] | 872 | |
Thomas Gleixner | 3ac7fe5 | 2008-04-30 00:55:01 -0700 | [diff] [blame] | 873 | #ifdef CONFIG_DEBUG_OBJECTS_FREE |
| 874 | static void __debug_check_no_obj_freed(const void *address, unsigned long size) |
| 875 | { |
| 876 | unsigned long flags, oaddr, saddr, eaddr, paddr, chunks; |
Thomas Gleixner | 3ac7fe5 | 2008-04-30 00:55:01 -0700 | [diff] [blame] | 877 | struct debug_obj_descr *descr; |
| 878 | enum debug_obj_state state; |
| 879 | struct debug_bucket *db; |
Yang Shi | 1ea9b98 | 2018-02-06 07:18:28 +0800 | [diff] [blame] | 880 | struct hlist_node *tmp; |
Thomas Gleixner | 3ac7fe5 | 2008-04-30 00:55:01 -0700 | [diff] [blame] | 881 | struct debug_obj *obj; |
Yang Shi | bd9dcd0 | 2018-02-06 07:18:25 +0800 | [diff] [blame] | 882 | int cnt, objs_checked = 0; |
Yang Shi | 1ea9b98 | 2018-02-06 07:18:28 +0800 | [diff] [blame] | 883 | bool work = false; |
Thomas Gleixner | 3ac7fe5 | 2008-04-30 00:55:01 -0700 | [diff] [blame] | 884 | |
| 885 | saddr = (unsigned long) address; |
| 886 | eaddr = saddr + size; |
| 887 | paddr = saddr & ODEBUG_CHUNK_MASK; |
| 888 | chunks = ((eaddr - paddr) + (ODEBUG_CHUNK_SIZE - 1)); |
| 889 | chunks >>= ODEBUG_CHUNK_SHIFT; |
| 890 | |
| 891 | for (;chunks > 0; chunks--, paddr += ODEBUG_CHUNK_SIZE) { |
| 892 | db = get_bucket(paddr); |
| 893 | |
| 894 | repeat: |
| 895 | cnt = 0; |
Thomas Gleixner | aef9cb0 | 2009-11-17 18:11:28 +0100 | [diff] [blame] | 896 | raw_spin_lock_irqsave(&db->lock, flags); |
Sasha Levin | b67bfe0 | 2013-02-27 17:06:00 -0800 | [diff] [blame] | 897 | hlist_for_each_entry_safe(obj, tmp, &db->list, node) { |
Thomas Gleixner | 3ac7fe5 | 2008-04-30 00:55:01 -0700 | [diff] [blame] | 898 | cnt++; |
| 899 | oaddr = (unsigned long) obj->object; |
| 900 | if (oaddr < saddr || oaddr >= eaddr) |
| 901 | continue; |
| 902 | |
| 903 | switch (obj->state) { |
| 904 | case ODEBUG_STATE_ACTIVE: |
| 905 | debug_print_object(obj, "free"); |
| 906 | descr = obj->descr; |
| 907 | state = obj->state; |
Thomas Gleixner | aef9cb0 | 2009-11-17 18:11:28 +0100 | [diff] [blame] | 908 | raw_spin_unlock_irqrestore(&db->lock, flags); |
Thomas Gleixner | 3ac7fe5 | 2008-04-30 00:55:01 -0700 | [diff] [blame] | 909 | debug_object_fixup(descr->fixup_free, |
| 910 | (void *) oaddr, state); |
| 911 | goto repeat; |
| 912 | default: |
| 913 | hlist_del(&obj->node); |
Yang Shi | 1ea9b98 | 2018-02-06 07:18:28 +0800 | [diff] [blame] | 914 | work |= __free_object(obj); |
Thomas Gleixner | 3ac7fe5 | 2008-04-30 00:55:01 -0700 | [diff] [blame] | 915 | break; |
| 916 | } |
| 917 | } |
Thomas Gleixner | aef9cb0 | 2009-11-17 18:11:28 +0100 | [diff] [blame] | 918 | raw_spin_unlock_irqrestore(&db->lock, flags); |
Vegard Nossum | 673d62cc | 2008-08-31 23:39:21 +0200 | [diff] [blame] | 919 | |
Thomas Gleixner | 3ac7fe5 | 2008-04-30 00:55:01 -0700 | [diff] [blame] | 920 | if (cnt > debug_objects_maxchain) |
| 921 | debug_objects_maxchain = cnt; |
Yang Shi | bd9dcd0 | 2018-02-06 07:18:25 +0800 | [diff] [blame] | 922 | |
| 923 | objs_checked += cnt; |
Thomas Gleixner | 3ac7fe5 | 2008-04-30 00:55:01 -0700 | [diff] [blame] | 924 | } |
Yang Shi | bd9dcd0 | 2018-02-06 07:18:25 +0800 | [diff] [blame] | 925 | |
| 926 | if (objs_checked > debug_objects_maxchecked) |
| 927 | debug_objects_maxchecked = objs_checked; |
Yang Shi | 1ea9b98 | 2018-02-06 07:18:28 +0800 | [diff] [blame] | 928 | |
| 929 | /* Schedule work to actually kmem_cache_free() objects */ |
| 930 | if (work) |
| 931 | schedule_work(&debug_obj_work); |
Thomas Gleixner | 3ac7fe5 | 2008-04-30 00:55:01 -0700 | [diff] [blame] | 932 | } |
| 933 | |
| 934 | void debug_check_no_obj_freed(const void *address, unsigned long size) |
| 935 | { |
| 936 | if (debug_objects_enabled) |
| 937 | __debug_check_no_obj_freed(address, size); |
| 938 | } |
| 939 | #endif |
| 940 | |
| 941 | #ifdef CONFIG_DEBUG_FS |
| 942 | |
| 943 | static int debug_stats_show(struct seq_file *m, void *v) |
| 944 | { |
Waiman Long | d86998b | 2019-05-20 10:14:46 -0400 | [diff] [blame] | 945 | int cpu, obj_percpu_free = 0; |
| 946 | |
| 947 | for_each_possible_cpu(cpu) |
| 948 | obj_percpu_free += per_cpu(percpu_obj_pool.obj_free, cpu); |
| 949 | |
Thomas Gleixner | 3ac7fe5 | 2008-04-30 00:55:01 -0700 | [diff] [blame] | 950 | seq_printf(m, "max_chain :%d\n", debug_objects_maxchain); |
Yang Shi | bd9dcd0 | 2018-02-06 07:18:25 +0800 | [diff] [blame] | 951 | seq_printf(m, "max_checked :%d\n", debug_objects_maxchecked); |
Thomas Gleixner | 3ac7fe5 | 2008-04-30 00:55:01 -0700 | [diff] [blame] | 952 | seq_printf(m, "warnings :%d\n", debug_objects_warnings); |
| 953 | seq_printf(m, "fixups :%d\n", debug_objects_fixups); |
Waiman Long | d86998b | 2019-05-20 10:14:46 -0400 | [diff] [blame] | 954 | seq_printf(m, "pool_free :%d\n", obj_pool_free + obj_percpu_free); |
| 955 | seq_printf(m, "pool_pcp_free :%d\n", obj_percpu_free); |
Thomas Gleixner | 3ac7fe5 | 2008-04-30 00:55:01 -0700 | [diff] [blame] | 956 | seq_printf(m, "pool_min_free :%d\n", obj_pool_min_free); |
Waiman Long | d86998b | 2019-05-20 10:14:46 -0400 | [diff] [blame] | 957 | seq_printf(m, "pool_used :%d\n", obj_pool_used - obj_percpu_free); |
Thomas Gleixner | 3ac7fe5 | 2008-04-30 00:55:01 -0700 | [diff] [blame] | 958 | seq_printf(m, "pool_max_used :%d\n", obj_pool_max_used); |
Yang Shi | 36c4ead | 2018-02-06 07:18:26 +0800 | [diff] [blame] | 959 | seq_printf(m, "on_free_list :%d\n", obj_nr_tofree); |
Waiman Long | 0cad93c | 2017-02-07 16:40:30 -0500 | [diff] [blame] | 960 | seq_printf(m, "objs_allocated:%d\n", debug_objects_allocated); |
| 961 | seq_printf(m, "objs_freed :%d\n", debug_objects_freed); |
Thomas Gleixner | 3ac7fe5 | 2008-04-30 00:55:01 -0700 | [diff] [blame] | 962 | return 0; |
| 963 | } |
| 964 | |
| 965 | static int debug_stats_open(struct inode *inode, struct file *filp) |
| 966 | { |
| 967 | return single_open(filp, debug_stats_show, NULL); |
| 968 | } |
| 969 | |
| 970 | static const struct file_operations debug_stats_fops = { |
| 971 | .open = debug_stats_open, |
| 972 | .read = seq_read, |
| 973 | .llseek = seq_lseek, |
| 974 | .release = single_release, |
| 975 | }; |
| 976 | |
| 977 | static int __init debug_objects_init_debugfs(void) |
| 978 | { |
Greg Kroah-Hartman | fecb0d9 | 2019-06-12 17:35:13 +0200 | [diff] [blame] | 979 | struct dentry *dbgdir; |
Thomas Gleixner | 3ac7fe5 | 2008-04-30 00:55:01 -0700 | [diff] [blame] | 980 | |
| 981 | if (!debug_objects_enabled) |
| 982 | return 0; |
| 983 | |
| 984 | dbgdir = debugfs_create_dir("debug_objects", NULL); |
Thomas Gleixner | 3ac7fe5 | 2008-04-30 00:55:01 -0700 | [diff] [blame] | 985 | |
Greg Kroah-Hartman | fecb0d9 | 2019-06-12 17:35:13 +0200 | [diff] [blame] | 986 | debugfs_create_file("stats", 0444, dbgdir, NULL, &debug_stats_fops); |
Thomas Gleixner | 3ac7fe5 | 2008-04-30 00:55:01 -0700 | [diff] [blame] | 987 | |
| 988 | return 0; |
Thomas Gleixner | 3ac7fe5 | 2008-04-30 00:55:01 -0700 | [diff] [blame] | 989 | } |
| 990 | __initcall(debug_objects_init_debugfs); |
| 991 | |
| 992 | #else |
| 993 | static inline void debug_objects_init_debugfs(void) { } |
| 994 | #endif |
| 995 | |
| 996 | #ifdef CONFIG_DEBUG_OBJECTS_SELFTEST |
| 997 | |
| 998 | /* Random data structure for the self test */ |
| 999 | struct self_test { |
| 1000 | unsigned long dummy1[6]; |
| 1001 | int static_init; |
| 1002 | unsigned long dummy2[3]; |
| 1003 | }; |
| 1004 | |
| 1005 | static __initdata struct debug_obj_descr descr_type_test; |
| 1006 | |
Du, Changbin | b9fdac7f | 2016-05-19 17:09:41 -0700 | [diff] [blame] | 1007 | static bool __init is_static_object(void *addr) |
| 1008 | { |
| 1009 | struct self_test *obj = addr; |
| 1010 | |
| 1011 | return obj->static_init; |
| 1012 | } |
| 1013 | |
Thomas Gleixner | 3ac7fe5 | 2008-04-30 00:55:01 -0700 | [diff] [blame] | 1014 | /* |
| 1015 | * fixup_init is called when: |
| 1016 | * - an active object is initialized |
| 1017 | */ |
Du, Changbin | b1e4d9d | 2016-05-19 17:09:20 -0700 | [diff] [blame] | 1018 | static bool __init fixup_init(void *addr, enum debug_obj_state state) |
Thomas Gleixner | 3ac7fe5 | 2008-04-30 00:55:01 -0700 | [diff] [blame] | 1019 | { |
| 1020 | struct self_test *obj = addr; |
| 1021 | |
| 1022 | switch (state) { |
| 1023 | case ODEBUG_STATE_ACTIVE: |
| 1024 | debug_object_deactivate(obj, &descr_type_test); |
| 1025 | debug_object_init(obj, &descr_type_test); |
Du, Changbin | b1e4d9d | 2016-05-19 17:09:20 -0700 | [diff] [blame] | 1026 | return true; |
Thomas Gleixner | 3ac7fe5 | 2008-04-30 00:55:01 -0700 | [diff] [blame] | 1027 | default: |
Du, Changbin | b1e4d9d | 2016-05-19 17:09:20 -0700 | [diff] [blame] | 1028 | return false; |
Thomas Gleixner | 3ac7fe5 | 2008-04-30 00:55:01 -0700 | [diff] [blame] | 1029 | } |
| 1030 | } |
| 1031 | |
| 1032 | /* |
| 1033 | * fixup_activate is called when: |
| 1034 | * - an active object is activated |
Du, Changbin | b9fdac7f | 2016-05-19 17:09:41 -0700 | [diff] [blame] | 1035 | * - an unknown non-static object is activated |
Thomas Gleixner | 3ac7fe5 | 2008-04-30 00:55:01 -0700 | [diff] [blame] | 1036 | */ |
Du, Changbin | b1e4d9d | 2016-05-19 17:09:20 -0700 | [diff] [blame] | 1037 | static bool __init fixup_activate(void *addr, enum debug_obj_state state) |
Thomas Gleixner | 3ac7fe5 | 2008-04-30 00:55:01 -0700 | [diff] [blame] | 1038 | { |
| 1039 | struct self_test *obj = addr; |
| 1040 | |
| 1041 | switch (state) { |
| 1042 | case ODEBUG_STATE_NOTAVAILABLE: |
Du, Changbin | b1e4d9d | 2016-05-19 17:09:20 -0700 | [diff] [blame] | 1043 | return true; |
Thomas Gleixner | 3ac7fe5 | 2008-04-30 00:55:01 -0700 | [diff] [blame] | 1044 | case ODEBUG_STATE_ACTIVE: |
| 1045 | debug_object_deactivate(obj, &descr_type_test); |
| 1046 | debug_object_activate(obj, &descr_type_test); |
Du, Changbin | b1e4d9d | 2016-05-19 17:09:20 -0700 | [diff] [blame] | 1047 | return true; |
Thomas Gleixner | 3ac7fe5 | 2008-04-30 00:55:01 -0700 | [diff] [blame] | 1048 | |
| 1049 | default: |
Du, Changbin | b1e4d9d | 2016-05-19 17:09:20 -0700 | [diff] [blame] | 1050 | return false; |
Thomas Gleixner | 3ac7fe5 | 2008-04-30 00:55:01 -0700 | [diff] [blame] | 1051 | } |
| 1052 | } |
| 1053 | |
| 1054 | /* |
| 1055 | * fixup_destroy is called when: |
| 1056 | * - an active object is destroyed |
| 1057 | */ |
Du, Changbin | b1e4d9d | 2016-05-19 17:09:20 -0700 | [diff] [blame] | 1058 | static bool __init fixup_destroy(void *addr, enum debug_obj_state state) |
Thomas Gleixner | 3ac7fe5 | 2008-04-30 00:55:01 -0700 | [diff] [blame] | 1059 | { |
| 1060 | struct self_test *obj = addr; |
| 1061 | |
| 1062 | switch (state) { |
| 1063 | case ODEBUG_STATE_ACTIVE: |
| 1064 | debug_object_deactivate(obj, &descr_type_test); |
| 1065 | debug_object_destroy(obj, &descr_type_test); |
Du, Changbin | b1e4d9d | 2016-05-19 17:09:20 -0700 | [diff] [blame] | 1066 | return true; |
Thomas Gleixner | 3ac7fe5 | 2008-04-30 00:55:01 -0700 | [diff] [blame] | 1067 | default: |
Du, Changbin | b1e4d9d | 2016-05-19 17:09:20 -0700 | [diff] [blame] | 1068 | return false; |
Thomas Gleixner | 3ac7fe5 | 2008-04-30 00:55:01 -0700 | [diff] [blame] | 1069 | } |
| 1070 | } |
| 1071 | |
| 1072 | /* |
| 1073 | * fixup_free is called when: |
| 1074 | * - an active object is freed |
| 1075 | */ |
Du, Changbin | b1e4d9d | 2016-05-19 17:09:20 -0700 | [diff] [blame] | 1076 | static bool __init fixup_free(void *addr, enum debug_obj_state state) |
Thomas Gleixner | 3ac7fe5 | 2008-04-30 00:55:01 -0700 | [diff] [blame] | 1077 | { |
| 1078 | struct self_test *obj = addr; |
| 1079 | |
| 1080 | switch (state) { |
| 1081 | case ODEBUG_STATE_ACTIVE: |
| 1082 | debug_object_deactivate(obj, &descr_type_test); |
| 1083 | debug_object_free(obj, &descr_type_test); |
Du, Changbin | b1e4d9d | 2016-05-19 17:09:20 -0700 | [diff] [blame] | 1084 | return true; |
Thomas Gleixner | 3ac7fe5 | 2008-04-30 00:55:01 -0700 | [diff] [blame] | 1085 | default: |
Du, Changbin | b1e4d9d | 2016-05-19 17:09:20 -0700 | [diff] [blame] | 1086 | return false; |
Thomas Gleixner | 3ac7fe5 | 2008-04-30 00:55:01 -0700 | [diff] [blame] | 1087 | } |
| 1088 | } |
| 1089 | |
Henrik Kretzschmar | 1fb2f77 | 2010-03-26 20:38:35 +0100 | [diff] [blame] | 1090 | static int __init |
Thomas Gleixner | 3ac7fe5 | 2008-04-30 00:55:01 -0700 | [diff] [blame] | 1091 | check_results(void *addr, enum debug_obj_state state, int fixups, int warnings) |
| 1092 | { |
| 1093 | struct debug_bucket *db; |
| 1094 | struct debug_obj *obj; |
| 1095 | unsigned long flags; |
| 1096 | int res = -EINVAL; |
| 1097 | |
| 1098 | db = get_bucket((unsigned long) addr); |
| 1099 | |
Thomas Gleixner | aef9cb0 | 2009-11-17 18:11:28 +0100 | [diff] [blame] | 1100 | raw_spin_lock_irqsave(&db->lock, flags); |
Thomas Gleixner | 3ac7fe5 | 2008-04-30 00:55:01 -0700 | [diff] [blame] | 1101 | |
| 1102 | obj = lookup_object(addr, db); |
| 1103 | if (!obj && state != ODEBUG_STATE_NONE) { |
Arjan van de Ven | 5cd2b45 | 2008-07-25 19:45:39 -0700 | [diff] [blame] | 1104 | WARN(1, KERN_ERR "ODEBUG: selftest object not found\n"); |
Thomas Gleixner | 3ac7fe5 | 2008-04-30 00:55:01 -0700 | [diff] [blame] | 1105 | goto out; |
| 1106 | } |
| 1107 | if (obj && obj->state != state) { |
Arjan van de Ven | 5cd2b45 | 2008-07-25 19:45:39 -0700 | [diff] [blame] | 1108 | WARN(1, KERN_ERR "ODEBUG: selftest wrong state: %d != %d\n", |
Thomas Gleixner | 3ac7fe5 | 2008-04-30 00:55:01 -0700 | [diff] [blame] | 1109 | obj->state, state); |
Thomas Gleixner | 3ac7fe5 | 2008-04-30 00:55:01 -0700 | [diff] [blame] | 1110 | goto out; |
| 1111 | } |
| 1112 | if (fixups != debug_objects_fixups) { |
Arjan van de Ven | 5cd2b45 | 2008-07-25 19:45:39 -0700 | [diff] [blame] | 1113 | WARN(1, KERN_ERR "ODEBUG: selftest fixups failed %d != %d\n", |
Thomas Gleixner | 3ac7fe5 | 2008-04-30 00:55:01 -0700 | [diff] [blame] | 1114 | fixups, debug_objects_fixups); |
Thomas Gleixner | 3ac7fe5 | 2008-04-30 00:55:01 -0700 | [diff] [blame] | 1115 | goto out; |
| 1116 | } |
| 1117 | if (warnings != debug_objects_warnings) { |
Arjan van de Ven | 5cd2b45 | 2008-07-25 19:45:39 -0700 | [diff] [blame] | 1118 | WARN(1, KERN_ERR "ODEBUG: selftest warnings failed %d != %d\n", |
Thomas Gleixner | 3ac7fe5 | 2008-04-30 00:55:01 -0700 | [diff] [blame] | 1119 | warnings, debug_objects_warnings); |
Thomas Gleixner | 3ac7fe5 | 2008-04-30 00:55:01 -0700 | [diff] [blame] | 1120 | goto out; |
| 1121 | } |
| 1122 | res = 0; |
| 1123 | out: |
Thomas Gleixner | aef9cb0 | 2009-11-17 18:11:28 +0100 | [diff] [blame] | 1124 | raw_spin_unlock_irqrestore(&db->lock, flags); |
Thomas Gleixner | 3ac7fe5 | 2008-04-30 00:55:01 -0700 | [diff] [blame] | 1125 | if (res) |
| 1126 | debug_objects_enabled = 0; |
| 1127 | return res; |
| 1128 | } |
| 1129 | |
| 1130 | static __initdata struct debug_obj_descr descr_type_test = { |
| 1131 | .name = "selftest", |
Du, Changbin | b9fdac7f | 2016-05-19 17:09:41 -0700 | [diff] [blame] | 1132 | .is_static_object = is_static_object, |
Thomas Gleixner | 3ac7fe5 | 2008-04-30 00:55:01 -0700 | [diff] [blame] | 1133 | .fixup_init = fixup_init, |
| 1134 | .fixup_activate = fixup_activate, |
| 1135 | .fixup_destroy = fixup_destroy, |
| 1136 | .fixup_free = fixup_free, |
| 1137 | }; |
| 1138 | |
| 1139 | static __initdata struct self_test obj = { .static_init = 0 }; |
| 1140 | |
| 1141 | static void __init debug_objects_selftest(void) |
| 1142 | { |
| 1143 | int fixups, oldfixups, warnings, oldwarnings; |
| 1144 | unsigned long flags; |
| 1145 | |
| 1146 | local_irq_save(flags); |
| 1147 | |
| 1148 | fixups = oldfixups = debug_objects_fixups; |
| 1149 | warnings = oldwarnings = debug_objects_warnings; |
| 1150 | descr_test = &descr_type_test; |
| 1151 | |
| 1152 | debug_object_init(&obj, &descr_type_test); |
| 1153 | if (check_results(&obj, ODEBUG_STATE_INIT, fixups, warnings)) |
| 1154 | goto out; |
| 1155 | debug_object_activate(&obj, &descr_type_test); |
| 1156 | if (check_results(&obj, ODEBUG_STATE_ACTIVE, fixups, warnings)) |
| 1157 | goto out; |
| 1158 | debug_object_activate(&obj, &descr_type_test); |
| 1159 | if (check_results(&obj, ODEBUG_STATE_ACTIVE, ++fixups, ++warnings)) |
| 1160 | goto out; |
| 1161 | debug_object_deactivate(&obj, &descr_type_test); |
| 1162 | if (check_results(&obj, ODEBUG_STATE_INACTIVE, fixups, warnings)) |
| 1163 | goto out; |
| 1164 | debug_object_destroy(&obj, &descr_type_test); |
| 1165 | if (check_results(&obj, ODEBUG_STATE_DESTROYED, fixups, warnings)) |
| 1166 | goto out; |
| 1167 | debug_object_init(&obj, &descr_type_test); |
| 1168 | if (check_results(&obj, ODEBUG_STATE_DESTROYED, fixups, ++warnings)) |
| 1169 | goto out; |
| 1170 | debug_object_activate(&obj, &descr_type_test); |
| 1171 | if (check_results(&obj, ODEBUG_STATE_DESTROYED, fixups, ++warnings)) |
| 1172 | goto out; |
| 1173 | debug_object_deactivate(&obj, &descr_type_test); |
| 1174 | if (check_results(&obj, ODEBUG_STATE_DESTROYED, fixups, ++warnings)) |
| 1175 | goto out; |
| 1176 | debug_object_free(&obj, &descr_type_test); |
| 1177 | if (check_results(&obj, ODEBUG_STATE_NONE, fixups, warnings)) |
| 1178 | goto out; |
| 1179 | |
| 1180 | obj.static_init = 1; |
| 1181 | debug_object_activate(&obj, &descr_type_test); |
Stephen Boyd | 9f78ff0 | 2012-03-05 14:59:17 -0800 | [diff] [blame] | 1182 | if (check_results(&obj, ODEBUG_STATE_ACTIVE, fixups, warnings)) |
Thomas Gleixner | 3ac7fe5 | 2008-04-30 00:55:01 -0700 | [diff] [blame] | 1183 | goto out; |
| 1184 | debug_object_init(&obj, &descr_type_test); |
| 1185 | if (check_results(&obj, ODEBUG_STATE_INIT, ++fixups, ++warnings)) |
| 1186 | goto out; |
| 1187 | debug_object_free(&obj, &descr_type_test); |
| 1188 | if (check_results(&obj, ODEBUG_STATE_NONE, fixups, warnings)) |
| 1189 | goto out; |
| 1190 | |
| 1191 | #ifdef CONFIG_DEBUG_OBJECTS_FREE |
| 1192 | debug_object_init(&obj, &descr_type_test); |
| 1193 | if (check_results(&obj, ODEBUG_STATE_INIT, fixups, warnings)) |
| 1194 | goto out; |
| 1195 | debug_object_activate(&obj, &descr_type_test); |
| 1196 | if (check_results(&obj, ODEBUG_STATE_ACTIVE, fixups, warnings)) |
| 1197 | goto out; |
| 1198 | __debug_check_no_obj_freed(&obj, sizeof(obj)); |
| 1199 | if (check_results(&obj, ODEBUG_STATE_NONE, ++fixups, ++warnings)) |
| 1200 | goto out; |
| 1201 | #endif |
Fabian Frederick | 719e484 | 2014-06-04 16:06:04 -0700 | [diff] [blame] | 1202 | pr_info("selftest passed\n"); |
Thomas Gleixner | 3ac7fe5 | 2008-04-30 00:55:01 -0700 | [diff] [blame] | 1203 | |
| 1204 | out: |
| 1205 | debug_objects_fixups = oldfixups; |
| 1206 | debug_objects_warnings = oldwarnings; |
| 1207 | descr_test = NULL; |
| 1208 | |
| 1209 | local_irq_restore(flags); |
| 1210 | } |
| 1211 | #else |
| 1212 | static inline void debug_objects_selftest(void) { } |
| 1213 | #endif |
| 1214 | |
| 1215 | /* |
| 1216 | * Called during early boot to initialize the hash buckets and link |
| 1217 | * the static object pool objects into the poll list. After this call |
| 1218 | * the object tracker is fully operational. |
| 1219 | */ |
| 1220 | void __init debug_objects_early_init(void) |
| 1221 | { |
| 1222 | int i; |
| 1223 | |
| 1224 | for (i = 0; i < ODEBUG_HASH_SIZE; i++) |
Thomas Gleixner | aef9cb0 | 2009-11-17 18:11:28 +0100 | [diff] [blame] | 1225 | raw_spin_lock_init(&obj_hash[i].lock); |
Thomas Gleixner | 3ac7fe5 | 2008-04-30 00:55:01 -0700 | [diff] [blame] | 1226 | |
| 1227 | for (i = 0; i < ODEBUG_POOL_SIZE; i++) |
| 1228 | hlist_add_head(&obj_static_pool[i].node, &obj_pool); |
| 1229 | } |
| 1230 | |
| 1231 | /* |
Thomas Gleixner | 1be1cb7 | 2009-03-16 18:53:18 +0100 | [diff] [blame] | 1232 | * Convert the statically allocated objects to dynamic ones: |
| 1233 | */ |
Henrik Kretzschmar | 1fb2f77 | 2010-03-26 20:38:35 +0100 | [diff] [blame] | 1234 | static int __init debug_objects_replace_static_objects(void) |
Thomas Gleixner | 1be1cb7 | 2009-03-16 18:53:18 +0100 | [diff] [blame] | 1235 | { |
| 1236 | struct debug_bucket *db = obj_hash; |
Sasha Levin | b67bfe0 | 2013-02-27 17:06:00 -0800 | [diff] [blame] | 1237 | struct hlist_node *tmp; |
Thomas Gleixner | 1be1cb7 | 2009-03-16 18:53:18 +0100 | [diff] [blame] | 1238 | struct debug_obj *obj, *new; |
| 1239 | HLIST_HEAD(objects); |
| 1240 | int i, cnt = 0; |
| 1241 | |
| 1242 | for (i = 0; i < ODEBUG_POOL_SIZE; i++) { |
| 1243 | obj = kmem_cache_zalloc(obj_cache, GFP_KERNEL); |
| 1244 | if (!obj) |
| 1245 | goto free; |
| 1246 | hlist_add_head(&obj->node, &objects); |
| 1247 | } |
| 1248 | |
| 1249 | /* |
Qian Cai | a9ee3a6 | 2018-12-28 00:32:32 -0800 | [diff] [blame] | 1250 | * debug_objects_mem_init() is now called early that only one CPU is up |
| 1251 | * and interrupts have been disabled, so it is safe to replace the |
| 1252 | * active object references. |
Thomas Gleixner | 1be1cb7 | 2009-03-16 18:53:18 +0100 | [diff] [blame] | 1253 | */ |
Thomas Gleixner | 1be1cb7 | 2009-03-16 18:53:18 +0100 | [diff] [blame] | 1254 | |
| 1255 | /* Remove the statically allocated objects from the pool */ |
Sasha Levin | b67bfe0 | 2013-02-27 17:06:00 -0800 | [diff] [blame] | 1256 | hlist_for_each_entry_safe(obj, tmp, &obj_pool, node) |
Thomas Gleixner | 1be1cb7 | 2009-03-16 18:53:18 +0100 | [diff] [blame] | 1257 | hlist_del(&obj->node); |
| 1258 | /* Move the allocated objects to the pool */ |
| 1259 | hlist_move_list(&objects, &obj_pool); |
| 1260 | |
| 1261 | /* Replace the active object references */ |
| 1262 | for (i = 0; i < ODEBUG_HASH_SIZE; i++, db++) { |
| 1263 | hlist_move_list(&db->list, &objects); |
| 1264 | |
Sasha Levin | b67bfe0 | 2013-02-27 17:06:00 -0800 | [diff] [blame] | 1265 | hlist_for_each_entry(obj, &objects, node) { |
Thomas Gleixner | 1be1cb7 | 2009-03-16 18:53:18 +0100 | [diff] [blame] | 1266 | new = hlist_entry(obj_pool.first, typeof(*obj), node); |
| 1267 | hlist_del(&new->node); |
| 1268 | /* copy object data */ |
| 1269 | *new = *obj; |
| 1270 | hlist_add_head(&new->node, &db->list); |
| 1271 | cnt++; |
| 1272 | } |
| 1273 | } |
| 1274 | |
Fabian Frederick | c0f35cc | 2014-06-04 16:06:05 -0700 | [diff] [blame] | 1275 | pr_debug("%d of %d active objects replaced\n", |
| 1276 | cnt, obj_pool_used); |
Thomas Gleixner | 1be1cb7 | 2009-03-16 18:53:18 +0100 | [diff] [blame] | 1277 | return 0; |
| 1278 | free: |
Sasha Levin | b67bfe0 | 2013-02-27 17:06:00 -0800 | [diff] [blame] | 1279 | hlist_for_each_entry_safe(obj, tmp, &objects, node) { |
Thomas Gleixner | 1be1cb7 | 2009-03-16 18:53:18 +0100 | [diff] [blame] | 1280 | hlist_del(&obj->node); |
| 1281 | kmem_cache_free(obj_cache, obj); |
| 1282 | } |
| 1283 | return -ENOMEM; |
| 1284 | } |
| 1285 | |
| 1286 | /* |
Thomas Gleixner | 3ac7fe5 | 2008-04-30 00:55:01 -0700 | [diff] [blame] | 1287 | * Called after the kmem_caches are functional to setup a dedicated |
| 1288 | * cache pool, which has the SLAB_DEBUG_OBJECTS flag set. This flag |
| 1289 | * prevents that the debug code is called on kmem_cache_free() for the |
| 1290 | * debug tracker objects to avoid recursive calls. |
| 1291 | */ |
| 1292 | void __init debug_objects_mem_init(void) |
| 1293 | { |
Waiman Long | 634d61f | 2019-05-20 10:14:47 -0400 | [diff] [blame] | 1294 | int cpu, extras; |
Waiman Long | d86998b | 2019-05-20 10:14:46 -0400 | [diff] [blame] | 1295 | |
Thomas Gleixner | 3ac7fe5 | 2008-04-30 00:55:01 -0700 | [diff] [blame] | 1296 | if (!debug_objects_enabled) |
| 1297 | return; |
| 1298 | |
Waiman Long | d86998b | 2019-05-20 10:14:46 -0400 | [diff] [blame] | 1299 | /* |
| 1300 | * Initialize the percpu object pools |
| 1301 | * |
| 1302 | * Initialization is not strictly necessary, but was done for |
| 1303 | * completeness. |
| 1304 | */ |
| 1305 | for_each_possible_cpu(cpu) |
| 1306 | INIT_HLIST_HEAD(&per_cpu(percpu_obj_pool.free_objs, cpu)); |
| 1307 | |
Thomas Gleixner | 3ac7fe5 | 2008-04-30 00:55:01 -0700 | [diff] [blame] | 1308 | obj_cache = kmem_cache_create("debug_objects_cache", |
| 1309 | sizeof (struct debug_obj), 0, |
Qian Cai | 8de456c | 2018-11-30 14:09:48 -0800 | [diff] [blame] | 1310 | SLAB_DEBUG_OBJECTS | SLAB_NOLEAKTRACE, |
| 1311 | NULL); |
Thomas Gleixner | 3ac7fe5 | 2008-04-30 00:55:01 -0700 | [diff] [blame] | 1312 | |
Thomas Gleixner | 1be1cb7 | 2009-03-16 18:53:18 +0100 | [diff] [blame] | 1313 | if (!obj_cache || debug_objects_replace_static_objects()) { |
Thomas Gleixner | 3ac7fe5 | 2008-04-30 00:55:01 -0700 | [diff] [blame] | 1314 | debug_objects_enabled = 0; |
Zhong Jiang | 3ff4f80 | 2018-08-01 00:24:58 +0800 | [diff] [blame] | 1315 | kmem_cache_destroy(obj_cache); |
Fabian Frederick | 719e484 | 2014-06-04 16:06:04 -0700 | [diff] [blame] | 1316 | pr_warn("out of memory.\n"); |
Thomas Gleixner | 1be1cb7 | 2009-03-16 18:53:18 +0100 | [diff] [blame] | 1317 | } else |
Thomas Gleixner | 3ac7fe5 | 2008-04-30 00:55:01 -0700 | [diff] [blame] | 1318 | debug_objects_selftest(); |
Waiman Long | 634d61f | 2019-05-20 10:14:47 -0400 | [diff] [blame] | 1319 | |
| 1320 | /* |
| 1321 | * Increase the thresholds for allocating and freeing objects |
| 1322 | * according to the number of possible CPUs available in the system. |
| 1323 | */ |
| 1324 | extras = num_possible_cpus() * ODEBUG_BATCH_SIZE; |
| 1325 | debug_objects_pool_size += extras; |
| 1326 | debug_objects_pool_min_level += extras; |
Thomas Gleixner | 3ac7fe5 | 2008-04-30 00:55:01 -0700 | [diff] [blame] | 1327 | } |