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
2626
2727 struct debug_bucket {
2828 struct hlist_head list;
29− spinlock_t lock;
29+ raw_spinlock_t lock;
3030 };
3131
3232 static struct debug_bucket obj_hash[ODEBUG_HASH_SIZE];
3333
3434 static struct debug_obj obj_static_pool[ODEBUG_POOL_SIZE] __initdata;
3535
36−static DEFINE_SPINLOCK(pool_lock);
36+static DEFINE_RAW_SPINLOCK(pool_lock);
3737
3838 static HLIST_HEAD(obj_pool);
3939
@@ -96,10 +96,10 @@ static int fill_pool(void) · 56 unmodified lines
9696 if (!new)
9797 return obj_pool_free;
9898
99− spin_lock_irqsave(&pool_lock, flags);
99+ raw_spin_lock_irqsave(&pool_lock, flags);
100100 hlist_add_head(&new->node, &obj_pool);
101101 obj_pool_free++;
102− spin_unlock_irqrestore(&pool_lock, flags);
102+ raw_spin_unlock_irqrestore(&pool_lock, flags);
103103 }
104104 return obj_pool_free;
105105 }
@@ -133,7 +133,7 @@ alloc_object(void *addr, struct debug_bucket *b, struct debug_obj_descr *descr) · 27 unmodified lines
133133 {
134134 struct debug_obj *obj = NULL;
135135
136− spin_lock(&pool_lock);
136+ raw_spin_lock(&pool_lock);
137137 if (obj_pool.first) {
138138 obj = hlist_entry(obj_pool.first, typeof(*obj), node);
139139
@@ -152,7 +152,7 @@ alloc_object(void *addr, struct debug_bucket *b, struct debug_obj_descr *descr) · 12 unmodified lines
152152 if (obj_pool_free < obj_pool_min_free)
153153 obj_pool_min_free = obj_pool_free;
154154 }
155− spin_unlock(&pool_lock);
155+ raw_spin_unlock(&pool_lock);
156156
157157 return obj;
158158 }
@@ -165,7 +165,7 @@ static void free_obj_work(struct work_struct *work) · 6 unmodified lines
165165 struct debug_obj *obj;
166166 unsigned long flags;
167167
168− spin_lock_irqsave(&pool_lock, flags);
168+ raw_spin_lock_irqsave(&pool_lock, flags);
169169 while (obj_pool_free > ODEBUG_POOL_SIZE) {
170170 obj = hlist_entry(obj_pool.first, typeof(*obj), node);
171171 hlist_del(&obj->node);
@@ -174,11 +174,11 @@ static void free_obj_work(struct work_struct *work) · 2 unmodified lines
174174 * We release pool_lock across kmem_cache_free() to
175175 * avoid contention on pool_lock.
176176 */
177− spin_unlock_irqrestore(&pool_lock, flags);
177+ raw_spin_unlock_irqrestore(&pool_lock, flags);
178178 kmem_cache_free(obj_cache, obj);
179− spin_lock_irqsave(&pool_lock, flags);
179+ raw_spin_lock_irqsave(&pool_lock, flags);
180180 }
181− spin_unlock_irqrestore(&pool_lock, flags);
181+ raw_spin_unlock_irqrestore(&pool_lock, flags);
182182 }
183183
184184 /*
@@ -190,7 +190,7 @@ static void free_object(struct debug_obj *obj) · 5 unmodified lines
190190 unsigned long flags;
191191 int sched = 0;
192192
193− spin_lock_irqsave(&pool_lock, flags);
193+ raw_spin_lock_irqsave(&pool_lock, flags);
194194 /*
195195 * schedule work when the pool is filled and the cache is
196196 * initialized:
@@ -200,7 +200,7 @@ static void free_object(struct debug_obj *obj) · 3 unmodified lines
200200 hlist_add_head(&obj->node, &obj_pool);
201201 obj_pool_free++;
202202 obj_pool_used--;
203− spin_unlock_irqrestore(&pool_lock, flags);
203+ raw_spin_unlock_irqrestore(&pool_lock, flags);
204204 if (sched)
205205 schedule_work(&debug_obj_work);
206206 }
@@ -221,9 +221,9 @@ static void debug_objects_oom(void) · 14 unmodified lines
221221 printk(KERN_WARNING "ODEBUG: Out of memory. ODEBUG disabled\n");
222222
223223 for (i = 0; i < ODEBUG_HASH_SIZE; i++, db++) {
224− spin_lock_irqsave(&db->lock, flags);
224+ raw_spin_lock_irqsave(&db->lock, flags);
225225 hlist_move_list(&db->list, &freelist);
226− spin_unlock_irqrestore(&db->lock, flags);
226+ raw_spin_unlock_irqrestore(&db->lock, flags);
227227
228228 /* Now free them */
229229 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
303303
304304 db = get_bucket((unsigned long) addr);
305305
306− spin_lock_irqsave(&db->lock, flags);
306+ raw_spin_lock_irqsave(&db->lock, flags);
307307
308308 obj = lookup_object(addr, db);
309309 if (!obj) {
310310 obj = alloc_object(addr, db, descr);
311311 if (!obj) {
312312 debug_objects_enabled = 0;
313− spin_unlock_irqrestore(&db->lock, flags);
313+ raw_spin_unlock_irqrestore(&db->lock, flags);
314314 debug_objects_oom();
315315 return;
316316 }
@@ -327,7 +327,7 @@ __debug_object_init(void *addr, struct debug_obj_descr *descr, int onstack) · 10 unmodified lines
327327 case ODEBUG_STATE_ACTIVE:
328328 debug_print_object(obj, "init");
329329 state = obj->state;
330− spin_unlock_irqrestore(&db->lock, flags);
330+ raw_spin_unlock_irqrestore(&db->lock, flags);
331331 debug_object_fixup(descr->fixup_init, addr, state);
332332 return;
333333
@@ -338,7 +338,7 @@ __debug_object_init(void *addr, struct debug_obj_descr *descr, int onstack) · 4 unmodified lines
338338 break;
339339 }
340340
341− spin_unlock_irqrestore(&db->lock, flags);
341+ raw_spin_unlock_irqrestore(&db->lock, flags);
342342 }
343343
344344 /**
@@ -385,7 +385,7 @@ void debug_object_activate(void *addr, struct debug_obj_descr *descr) · 40 unmodified lines
385385
386386 db = get_bucket((unsigned long) addr);
387387
388− spin_lock_irqsave(&db->lock, flags);
388+ raw_spin_lock_irqsave(&db->lock, flags);
389389
390390 obj = lookup_object(addr, db);
391391 if (obj) {
@@ -398,7 +398,7 @@ void debug_object_activate(void *addr, struct debug_obj_descr *descr) · 6 unmodified lines
398398 case ODEBUG_STATE_ACTIVE:
399399 debug_print_object(obj, "activate");
400400 state = obj->state;
401− spin_unlock_irqrestore(&db->lock, flags);
401+ raw_spin_unlock_irqrestore(&db->lock, flags);
402402 debug_object_fixup(descr->fixup_activate, addr, state);
403403 return;
404404
@@ -408,11 +408,11 @@ void debug_object_activate(void *addr, struct debug_obj_descr *descr) · 3 unmodified lines
408408 default:
409409 break;
410410 }
411− spin_unlock_irqrestore(&db->lock, flags);
411+ raw_spin_unlock_irqrestore(&db->lock, flags);
412412 return;
413413 }
414414
415− spin_unlock_irqrestore(&db->lock, flags);
415+ raw_spin_unlock_irqrestore(&db->lock, flags);
416416 /*
417417 * This happens when a static object is activated. We
418418 * 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
438438
439439 db = get_bucket((unsigned long) addr);
440440
441− spin_lock_irqsave(&db->lock, flags);
441+ raw_spin_lock_irqsave(&db->lock, flags);
442442
443443 obj = lookup_object(addr, db);
444444 if (obj) {
@@ -463,7 +463,7 @@ void debug_object_deactivate(void *addr, struct debug_obj_descr *descr) · 18 unmodified lines
463463 debug_print_object(&o, "deactivate");
464464 }
465465
466− spin_unlock_irqrestore(&db->lock, flags);
466+ raw_spin_unlock_irqrestore(&db->lock, flags);
467467 }
468468
469469 /**
@@ -483,7 +483,7 @@ void debug_object_destroy(void *addr, struct debug_obj_descr *descr) · 13 unmodified lines
483483
484484 db = get_bucket((unsigned long) addr);
485485
486− spin_lock_irqsave(&db->lock, flags);
486+ raw_spin_lock_irqsave(&db->lock, flags);
487487
488488 obj = lookup_object(addr, db);
489489 if (!obj)
@@ -498,7 +498,7 @@ void debug_object_destroy(void *addr, struct debug_obj_descr *descr) · 8 unmodified lines
498498 case ODEBUG_STATE_ACTIVE:
499499 debug_print_object(obj, "destroy");
500500 state = obj->state;
501− spin_unlock_irqrestore(&db->lock, flags);
501+ raw_spin_unlock_irqrestore(&db->lock, flags);
502502 debug_object_fixup(descr->fixup_destroy, addr, state);
503503 return;
504504
@@ -509,7 +509,7 @@ void debug_object_destroy(void *addr, struct debug_obj_descr *descr) · 4 unmodified lines
509509 break;
510510 }
511511 out_unlock:
512− spin_unlock_irqrestore(&db->lock, flags);
512+ raw_spin_unlock_irqrestore(&db->lock, flags);
513513 }
514514
515515 /**
@@ -529,7 +529,7 @@ void debug_object_free(void *addr, struct debug_obj_descr *descr) · 13 unmodified lines
529529
530530 db = get_bucket((unsigned long) addr);
531531
532− spin_lock_irqsave(&db->lock, flags);
532+ raw_spin_lock_irqsave(&db->lock, flags);
533533
534534 obj = lookup_object(addr, db);
535535 if (!obj)
@@ -539,17 +539,17 @@ void debug_object_free(void *addr, struct debug_obj_descr *descr) · 3 unmodified lines
539539 case ODEBUG_STATE_ACTIVE:
540540 debug_print_object(obj, "free");
541541 state = obj->state;
542− spin_unlock_irqrestore(&db->lock, flags);
542+ raw_spin_unlock_irqrestore(&db->lock, flags);
543543 debug_object_fixup(descr->fixup_free, addr, state);
544544 return;
545545 default:
546546 hlist_del(&obj->node);
547− spin_unlock_irqrestore(&db->lock, flags);
547+ raw_spin_unlock_irqrestore(&db->lock, flags);
548548 free_object(obj);
549549 return;
550550 }
551551 out_unlock:
552− spin_unlock_irqrestore(&db->lock, flags);
552+ raw_spin_unlock_irqrestore(&db->lock, flags);
553553 }
554554
555555 #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
575575
576576 repeat:
577577 cnt = 0;
578− spin_lock_irqsave(&db->lock, flags);
578+ raw_spin_lock_irqsave(&db->lock, flags);
579579 hlist_for_each_entry_safe(obj, node, tmp, &db->list, node) {
580580 cnt++;
581581 oaddr = (unsigned long) obj->object;
@@ -587,7 +587,7 @@ repeat: · 5 unmodified lines
587587 debug_print_object(obj, "free");
588588 descr = obj->descr;
589589 state = obj->state;
590− spin_unlock_irqrestore(&db->lock, flags);
590+ raw_spin_unlock_irqrestore(&db->lock, flags);
591591 debug_object_fixup(descr->fixup_free,
592592 (void *) oaddr, state);
593593 goto repeat;
@@ -597,7 +597,7 @@ repeat: · 3 unmodified lines
597597 break;
598598 }
599599 }
600− spin_unlock_irqrestore(&db->lock, flags);
600+ raw_spin_unlock_irqrestore(&db->lock, flags);
601601
602602 /* Now free them */
603603 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
783783
784784 db = get_bucket((unsigned long) addr);
785785
786− spin_lock_irqsave(&db->lock, flags);
786+ raw_spin_lock_irqsave(&db->lock, flags);
787787
788788 obj = lookup_object(addr, db);
789789 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
807807 }
808808 res = 0;
809809 out:
810− spin_unlock_irqrestore(&db->lock, flags);
810+ raw_spin_unlock_irqrestore(&db->lock, flags);
811811 if (res)
812812 debug_objects_enabled = 0;
813813 return res;
@@ -907,7 +907,7 @@ void __init debug_objects_early_init(void) · 93 unmodified lines
907907 int i;
908908
909909 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);
911911
912912 for (i = 0; i < ODEBUG_POOL_SIZE; i++)
913913 hlist_add_head(&obj_static_pool[i].node, &obj_pool);