aboutsummaryrefslogtreecommitdiffstats
path: root/lib/debugobjects.c
diff options
context:
space:
mode:
Diffstat (limited to 'lib/debugobjects.c')
-rw-r--r--lib/debugobjects.c32
1 files changed, 23 insertions, 9 deletions
diff --git a/lib/debugobjects.c b/lib/debugobjects.c
index dc78217b2199..5e1bf2f4a5ec 100644
--- a/lib/debugobjects.c
+++ b/lib/debugobjects.c
@@ -172,25 +172,39 @@ alloc_object(void *addr, struct debug_bucket *b, struct debug_obj_descr *descr)
172 172
173/* 173/*
174 * workqueue function to free objects. 174 * workqueue function to free objects.
175 *
176 * To reduce contention on the global pool_lock, the actual freeing of
177 * debug objects will be delayed if the pool_lock is busy. We also free
178 * the objects in a batch of 4 for each lock/unlock cycle.
175 */ 179 */
180#define ODEBUG_FREE_BATCH 4
181
176static void free_obj_work(struct work_struct *work) 182static void free_obj_work(struct work_struct *work)
177{ 183{
178 struct debug_obj *obj; 184 struct debug_obj *objs[ODEBUG_FREE_BATCH];
179 unsigned long flags; 185 unsigned long flags;
186 int i;
180 187
181 raw_spin_lock_irqsave(&pool_lock, flags); 188 if (!raw_spin_trylock_irqsave(&pool_lock, flags))
182 while (obj_pool_free > debug_objects_pool_size) { 189 return;
183 obj = hlist_entry(obj_pool.first, typeof(*obj), node); 190 while (obj_pool_free >= debug_objects_pool_size + ODEBUG_FREE_BATCH) {
184 hlist_del(&obj->node); 191 for (i = 0; i < ODEBUG_FREE_BATCH; i++) {
185 obj_pool_free--; 192 objs[i] = hlist_entry(obj_pool.first,
186 debug_objects_freed++; 193 typeof(*objs[0]), node);
194 hlist_del(&objs[i]->node);
195 }
196
197 obj_pool_free -= ODEBUG_FREE_BATCH;
198 debug_objects_freed += ODEBUG_FREE_BATCH;
187 /* 199 /*
188 * We release pool_lock across kmem_cache_free() to 200 * We release pool_lock across kmem_cache_free() to
189 * avoid contention on pool_lock. 201 * avoid contention on pool_lock.
190 */ 202 */
191 raw_spin_unlock_irqrestore(&pool_lock, flags); 203 raw_spin_unlock_irqrestore(&pool_lock, flags);
192 kmem_cache_free(obj_cache, obj); 204 for (i = 0; i < ODEBUG_FREE_BATCH; i++)
193 raw_spin_lock_irqsave(&pool_lock, flags); 205 kmem_cache_free(obj_cache, objs[i]);
206 if (!raw_spin_trylock_irqsave(&pool_lock, flags))
207 return;
194 } 208 }
195 raw_spin_unlock_irqrestore(&pool_lock, flags); 209 raw_spin_unlock_irqrestore(&pool_lock, flags);
196} 210}