History

debugobjects: Convert to raw_spinlocks

Convert locks which cannot be sleeping locks in preempt-rt to raw_spinlocks.

Thomas Gleixner committed 17 years ago

Commit aef9cb01 parent e625cce1 file · +37 −37Browse files

Showing the changes to lib/debugobjects.c (1 of 1 file). Show all

Unified · Split

lib/debugobjects.c+37−37
@@ -26,14 +26,14 @@ · 25 unmodified lines
26 26
27struct debug_bucket {27struct debug_bucket {
28 struct hlist_head list;28 struct hlist_head list;
29 spinlock_t lock;29 raw_spinlock_t lock;
30};30};
31 31
32static struct debug_bucket obj_hash[ODEBUG_HASH_SIZE];32static struct debug_bucket obj_hash[ODEBUG_HASH_SIZE];
33 33
34static struct debug_obj obj_static_pool[ODEBUG_POOL_SIZE] __initdata;34static struct debug_obj obj_static_pool[ODEBUG_POOL_SIZE] __initdata;
35 35
36static DEFINE_SPINLOCK(pool_lock);36static DEFINE_RAW_SPINLOCK(pool_lock);
37 37
38static HLIST_HEAD(obj_pool);38static HLIST_HEAD(obj_pool);
39 39
@@ -96,10 +96,10 @@ static int fill_pool(void) · 56 unmodified lines
96 if (!new)96 if (!new)
97 return obj_pool_free;97 return obj_pool_free;
98 98
99 spin_lock_irqsave(&pool_lock, flags);99 raw_spin_lock_irqsave(&pool_lock, flags);
100 hlist_add_head(&new->node, &obj_pool);100 hlist_add_head(&new->node, &obj_pool);
101 obj_pool_free++;101 obj_pool_free++;
102 spin_unlock_irqrestore(&pool_lock, flags);102 raw_spin_unlock_irqrestore(&pool_lock, flags);
103 }103 }
104 return obj_pool_free;104 return obj_pool_free;
105}105}
@@ -133,7 +133,7 @@ alloc_object(void *addr, struct debug_bucket *b, struct debug_obj_descr *descr) · 27 unmodified lines
133{133{
134 struct debug_obj *obj = NULL;134 struct debug_obj *obj = NULL;
135 135
136 spin_lock(&pool_lock);136 raw_spin_lock(&pool_lock);
137 if (obj_pool.first) {137 if (obj_pool.first) {
138 obj = hlist_entry(obj_pool.first, typeof(*obj), node);138 obj = hlist_entry(obj_pool.first, typeof(*obj), node);
139 139
@@ -152,7 +152,7 @@ alloc_object(void *addr, struct debug_bucket *b, struct debug_obj_descr *descr) · 12 unmodified lines
152 if (obj_pool_free < obj_pool_min_free)152 if (obj_pool_free < obj_pool_min_free)
153 obj_pool_min_free = obj_pool_free;153 obj_pool_min_free = obj_pool_free;
154 }154 }
155 spin_unlock(&pool_lock);155 raw_spin_unlock(&pool_lock);
156 156
157 return obj;157 return obj;
158}158}
@@ -165,7 +165,7 @@ static void free_obj_work(struct work_struct *work) · 6 unmodified lines
165 struct debug_obj *obj;165 struct debug_obj *obj;
166 unsigned long flags;166 unsigned long flags;
167 167
168 spin_lock_irqsave(&pool_lock, flags);168 raw_spin_lock_irqsave(&pool_lock, flags);
169 while (obj_pool_free > ODEBUG_POOL_SIZE) {169 while (obj_pool_free > ODEBUG_POOL_SIZE) {
170 obj = hlist_entry(obj_pool.first, typeof(*obj), node);170 obj = hlist_entry(obj_pool.first, typeof(*obj), node);
171 hlist_del(&obj->node);171 hlist_del(&obj->node);
@@ -174,11 +174,11 @@ static void free_obj_work(struct work_struct *work) · 2 unmodified lines
174 * We release pool_lock across kmem_cache_free() to174 * We release pool_lock across kmem_cache_free() to
175 * avoid contention on pool_lock.175 * avoid contention on pool_lock.
176 */176 */
177 spin_unlock_irqrestore(&pool_lock, flags);177 raw_spin_unlock_irqrestore(&pool_lock, flags);
178 kmem_cache_free(obj_cache, obj);178 kmem_cache_free(obj_cache, obj);
179 spin_lock_irqsave(&pool_lock, flags);179 raw_spin_lock_irqsave(&pool_lock, flags);
180 }180 }
181 spin_unlock_irqrestore(&pool_lock, flags);181 raw_spin_unlock_irqrestore(&pool_lock, flags);
182}182}
183 183
184/*184/*
@@ -190,7 +190,7 @@ static void free_object(struct debug_obj *obj) · 5 unmodified lines
190 unsigned long flags;190 unsigned long flags;
191 int sched = 0;191 int sched = 0;
192 192
193 spin_lock_irqsave(&pool_lock, flags);193 raw_spin_lock_irqsave(&pool_lock, flags);
194 /*194 /*
195 * schedule work when the pool is filled and the cache is195 * schedule work when the pool is filled and the cache is
196 * initialized:196 * initialized:
@@ -200,7 +200,7 @@ static void free_object(struct debug_obj *obj) · 3 unmodified lines
200 hlist_add_head(&obj->node, &obj_pool);200 hlist_add_head(&obj->node, &obj_pool);
201 obj_pool_free++;201 obj_pool_free++;
202 obj_pool_used--;202 obj_pool_used--;
203 spin_unlock_irqrestore(&pool_lock, flags);203 raw_spin_unlock_irqrestore(&pool_lock, flags);
204 if (sched)204 if (sched)
205 schedule_work(&debug_obj_work);205 schedule_work(&debug_obj_work);
206}206}
@@ -221,9 +221,9 @@ static void debug_objects_oom(void) · 14 unmodified lines
221 printk(KERN_WARNING "ODEBUG: Out of memory. ODEBUG disabled\n");221 printk(KERN_WARNING "ODEBUG: Out of memory. ODEBUG disabled\n");
222 222
223 for (i = 0; i < ODEBUG_HASH_SIZE; i++, db++) {223 for (i = 0; i < ODEBUG_HASH_SIZE; i++, db++) {
224 spin_lock_irqsave(&db->lock, flags);224 raw_spin_lock_irqsave(&db->lock, flags);
225 hlist_move_list(&db->list, &freelist);225 hlist_move_list(&db->list, &freelist);
226 spin_unlock_irqrestore(&db->lock, flags);226 raw_spin_unlock_irqrestore(&db->lock, flags);
227 227
228 /* Now free them */228 /* Now free them */
229 hlist_for_each_entry_safe(obj, node, tmp, &freelist, node) {229 hlist_for_each_entry_safe(obj, node, tmp, &freelist, node) {
@@ -303,14 +303,14 @@ __debug_object_init(void *addr, struct debug_obj_descr *descr, int onstack) · 73 unmodified lines
303 303
304 db = get_bucket((unsigned long) addr);304 db = get_bucket((unsigned long) addr);
305 305
306 spin_lock_irqsave(&db->lock, flags);306 raw_spin_lock_irqsave(&db->lock, flags);
307 307
308 obj = lookup_object(addr, db);308 obj = lookup_object(addr, db);
309 if (!obj) {309 if (!obj) {
310 obj = alloc_object(addr, db, descr);310 obj = alloc_object(addr, db, descr);
311 if (!obj) {311 if (!obj) {
312 debug_objects_enabled = 0;312 debug_objects_enabled = 0;
313 spin_unlock_irqrestore(&db->lock, flags);313 raw_spin_unlock_irqrestore(&db->lock, flags);
314 debug_objects_oom();314 debug_objects_oom();
315 return;315 return;
316 }316 }
@@ -327,7 +327,7 @@ __debug_object_init(void *addr, struct debug_obj_descr *descr, int onstack) · 10 unmodified lines
327 case ODEBUG_STATE_ACTIVE:327 case ODEBUG_STATE_ACTIVE:
328 debug_print_object(obj, "init");328 debug_print_object(obj, "init");
329 state = obj->state;329 state = obj->state;
330 spin_unlock_irqrestore(&db->lock, flags);330 raw_spin_unlock_irqrestore(&db->lock, flags);
331 debug_object_fixup(descr->fixup_init, addr, state);331 debug_object_fixup(descr->fixup_init, addr, state);
332 return;332 return;
333 333
@@ -338,7 +338,7 @@ __debug_object_init(void *addr, struct debug_obj_descr *descr, int onstack) · 4 unmodified lines
338 break;338 break;
339 }339 }
340 340
341 spin_unlock_irqrestore(&db->lock, flags);341 raw_spin_unlock_irqrestore(&db->lock, flags);
342}342}
343 343
344/**344/**
@@ -385,7 +385,7 @@ void debug_object_activate(void *addr, struct debug_obj_descr *descr) · 40 unmodified lines
385 385
386 db = get_bucket((unsigned long) addr);386 db = get_bucket((unsigned long) addr);
387 387
388 spin_lock_irqsave(&db->lock, flags);388 raw_spin_lock_irqsave(&db->lock, flags);
389 389
390 obj = lookup_object(addr, db);390 obj = lookup_object(addr, db);
391 if (obj) {391 if (obj) {
@@ -398,7 +398,7 @@ void debug_object_activate(void *addr, struct debug_obj_descr *descr) · 6 unmodified lines
398 case ODEBUG_STATE_ACTIVE:398 case ODEBUG_STATE_ACTIVE:
399 debug_print_object(obj, "activate");399 debug_print_object(obj, "activate");
400 state = obj->state;400 state = obj->state;
401 spin_unlock_irqrestore(&db->lock, flags);401 raw_spin_unlock_irqrestore(&db->lock, flags);
402 debug_object_fixup(descr->fixup_activate, addr, state);402 debug_object_fixup(descr->fixup_activate, addr, state);
403 return;403 return;
404 404
@@ -408,11 +408,11 @@ void debug_object_activate(void *addr, struct debug_obj_descr *descr) · 3 unmodified lines
408 default:408 default:
409 break;409 break;
410 }410 }
411 spin_unlock_irqrestore(&db->lock, flags);411 raw_spin_unlock_irqrestore(&db->lock, flags);
412 return;412 return;
413 }413 }
414 414
415 spin_unlock_irqrestore(&db->lock, flags);415 raw_spin_unlock_irqrestore(&db->lock, flags);
416 /*416 /*
417 * This happens when a static object is activated. We417 * This happens when a static object is activated. We
418 * let the type specific code decide whether this is418 * let the type specific code decide whether this is
@@ -438,7 +438,7 @@ void debug_object_deactivate(void *addr, struct debug_obj_descr *descr) · 19 unmodified lines
438 438
439 db = get_bucket((unsigned long) addr);439 db = get_bucket((unsigned long) addr);
440 440
441 spin_lock_irqsave(&db->lock, flags);441 raw_spin_lock_irqsave(&db->lock, flags);
442 442
443 obj = lookup_object(addr, db);443 obj = lookup_object(addr, db);
444 if (obj) {444 if (obj) {
@@ -463,7 +463,7 @@ void debug_object_deactivate(void *addr, struct debug_obj_descr *descr) · 18 unmodified lines
463 debug_print_object(&o, "deactivate");463 debug_print_object(&o, "deactivate");
464 }464 }
465 465
466 spin_unlock_irqrestore(&db->lock, flags);466 raw_spin_unlock_irqrestore(&db->lock, flags);
467}467}
468 468
469/**469/**
@@ -483,7 +483,7 @@ void debug_object_destroy(void *addr, struct debug_obj_descr *descr) · 13 unmodified lines
483 483
484 db = get_bucket((unsigned long) addr);484 db = get_bucket((unsigned long) addr);
485 485
486 spin_lock_irqsave(&db->lock, flags);486 raw_spin_lock_irqsave(&db->lock, flags);
487 487
488 obj = lookup_object(addr, db);488 obj = lookup_object(addr, db);
489 if (!obj)489 if (!obj)
@@ -498,7 +498,7 @@ void debug_object_destroy(void *addr, struct debug_obj_descr *descr) · 8 unmodified lines
498 case ODEBUG_STATE_ACTIVE:498 case ODEBUG_STATE_ACTIVE:
499 debug_print_object(obj, "destroy");499 debug_print_object(obj, "destroy");
500 state = obj->state;500 state = obj->state;
501 spin_unlock_irqrestore(&db->lock, flags);501 raw_spin_unlock_irqrestore(&db->lock, flags);
502 debug_object_fixup(descr->fixup_destroy, addr, state);502 debug_object_fixup(descr->fixup_destroy, addr, state);
503 return;503 return;
504 504
@@ -509,7 +509,7 @@ void debug_object_destroy(void *addr, struct debug_obj_descr *descr) · 4 unmodified lines
509 break;509 break;
510 }510 }
511out_unlock:511out_unlock:
512 spin_unlock_irqrestore(&db->lock, flags);512 raw_spin_unlock_irqrestore(&db->lock, flags);
513}513}
514 514
515/**515/**
@@ -529,7 +529,7 @@ void debug_object_free(void *addr, struct debug_obj_descr *descr) · 13 unmodified lines
529 529
530 db = get_bucket((unsigned long) addr);530 db = get_bucket((unsigned long) addr);
531 531
532 spin_lock_irqsave(&db->lock, flags);532 raw_spin_lock_irqsave(&db->lock, flags);
533 533
534 obj = lookup_object(addr, db);534 obj = lookup_object(addr, db);
535 if (!obj)535 if (!obj)
@@ -539,17 +539,17 @@ void debug_object_free(void *addr, struct debug_obj_descr *descr) · 3 unmodified lines
539 case ODEBUG_STATE_ACTIVE:539 case ODEBUG_STATE_ACTIVE:
540 debug_print_object(obj, "free");540 debug_print_object(obj, "free");
541 state = obj->state;541 state = obj->state;
542 spin_unlock_irqrestore(&db->lock, flags);542 raw_spin_unlock_irqrestore(&db->lock, flags);
543 debug_object_fixup(descr->fixup_free, addr, state);543 debug_object_fixup(descr->fixup_free, addr, state);
544 return;544 return;
545 default:545 default:
546 hlist_del(&obj->node);546 hlist_del(&obj->node);
547 spin_unlock_irqrestore(&db->lock, flags);547 raw_spin_unlock_irqrestore(&db->lock, flags);
548 free_object(obj);548 free_object(obj);
549 return;549 return;
550 }550 }
551out_unlock:551out_unlock:
552 spin_unlock_irqrestore(&db->lock, flags);552 raw_spin_unlock_irqrestore(&db->lock, flags);
553}553}
554 554
555#ifdef CONFIG_DEBUG_OBJECTS_FREE555#ifdef CONFIG_DEBUG_OBJECTS_FREE
@@ -575,7 +575,7 @@ static void __debug_check_no_obj_freed(const void *address, unsigned long size) · 19 unmodified lines
575 575
576repeat:576repeat:
577 cnt = 0;577 cnt = 0;
578 spin_lock_irqsave(&db->lock, flags);578 raw_spin_lock_irqsave(&db->lock, flags);
579 hlist_for_each_entry_safe(obj, node, tmp, &db->list, node) {579 hlist_for_each_entry_safe(obj, node, tmp, &db->list, node) {
580 cnt++;580 cnt++;
581 oaddr = (unsigned long) obj->object;581 oaddr = (unsigned long) obj->object;
@@ -587,7 +587,7 @@ repeat: · 5 unmodified lines
587 debug_print_object(obj, "free");587 debug_print_object(obj, "free");
588 descr = obj->descr;588 descr = obj->descr;
589 state = obj->state;589 state = obj->state;
590 spin_unlock_irqrestore(&db->lock, flags);590 raw_spin_unlock_irqrestore(&db->lock, flags);
591 debug_object_fixup(descr->fixup_free,591 debug_object_fixup(descr->fixup_free,
592 (void *) oaddr, state);592 (void *) oaddr, state);
593 goto repeat;593 goto repeat;
@@ -597,7 +597,7 @@ repeat: · 3 unmodified lines
597 break;597 break;
598 }598 }
599 }599 }
600 spin_unlock_irqrestore(&db->lock, flags);600 raw_spin_unlock_irqrestore(&db->lock, flags);
601 601
602 /* Now free them */602 /* Now free them */
603 hlist_for_each_entry_safe(obj, node, tmp, &freelist, node) {603 hlist_for_each_entry_safe(obj, node, tmp, &freelist, node) {
@@ -783,7 +783,7 @@ check_results(void *addr, enum debug_obj_state state, int fixups, int warnings) · 179 unmodified lines
783 783
784 db = get_bucket((unsigned long) addr);784 db = get_bucket((unsigned long) addr);
785 785
786 spin_lock_irqsave(&db->lock, flags);786 raw_spin_lock_irqsave(&db->lock, flags);
787 787
788 obj = lookup_object(addr, db);788 obj = lookup_object(addr, db);
789 if (!obj && state != ODEBUG_STATE_NONE) {789 if (!obj && state != ODEBUG_STATE_NONE) {
@@ -807,7 +807,7 @@ check_results(void *addr, enum debug_obj_state state, int fixups, int warnings) · 17 unmodified lines
807 }807 }
808 res = 0;808 res = 0;
809out:809out:
810 spin_unlock_irqrestore(&db->lock, flags);810 raw_spin_unlock_irqrestore(&db->lock, flags);
811 if (res)811 if (res)
812 debug_objects_enabled = 0;812 debug_objects_enabled = 0;
813 return res;813 return res;
@@ -907,7 +907,7 @@ void __init debug_objects_early_init(void) · 93 unmodified lines
907 int i;907 int i;
908 908
909 for (i = 0; i < ODEBUG_HASH_SIZE; i++)909 for (i = 0; i < ODEBUG_HASH_SIZE; i++)
910 spin_lock_init(&obj_hash[i].lock);910 raw_spin_lock_init(&obj_hash[i].lock);
911 911
912 for (i = 0; i < ODEBUG_POOL_SIZE; i++)912 for (i = 0; i < ODEBUG_POOL_SIZE; i++)
913 hlist_add_head(&obj_static_pool[i].node, &obj_pool);913 hlist_add_head(&obj_static_pool[i].node, &obj_pool);