aboutsummaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorThomas Gleixner <tglx@linutronix.de>2009-11-17 12:11:28 -0500
committerThomas Gleixner <tglx@linutronix.de>2009-12-14 17:55:34 -0500
commitaef9cb05247df3d7615773737beb4f83d78577bb (patch)
tree32e45f7d7cacb58c01b2a9fc1a49466cb0de6dfc /lib
parente625cce1b73fb38b74e5387226534f7bcbfc36fe (diff)
debugobjects: Convert to raw_spinlocks
Convert locks which cannot be sleeping locks in preempt-rt to raw_spinlocks. Signed-off-by: Thomas Gleixner <tglx@linutronix.de> Acked-by: Peter Zijlstra <peterz@infradead.org> Acked-by: Ingo Molnar <mingo@elte.hu>
Diffstat (limited to 'lib')
-rw-r--r--lib/debugobjects.c74
1 files changed, 37 insertions, 37 deletions
diff --git a/lib/debugobjects.c b/lib/debugobjects.c
index eae56fddfa3b..a9a8996d286a 100644
--- a/lib/debugobjects.c
+++ b/lib/debugobjects.c
@@ -26,14 +26,14 @@
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)
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)
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)
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)
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)
174 * We release pool_lock across kmem_cache_free() to 174 * 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)
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 is 195 * 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)
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)
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)
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)
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)
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)
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)
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)
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. We 417 * This happens when a static object is activated. We
418 * let the type specific code decide whether this is 418 * let the type specific code decide whether this is
@@ -438,7 +438,7 @@ void debug_object_deactivate(void *addr, struct debug_obj_descr *descr)
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)
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)
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)
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)
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)
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)
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_FREE 555#ifdef CONFIG_DEBUG_OBJECTS_FREE
@@ -575,7 +575,7 @@ static void __debug_check_no_obj_freed(const void *address, unsigned long size)
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:
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:
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)
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)
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)
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);