diff options
author | Linus Torvalds <torvalds@linux-foundation.org> | 2008-09-05 17:28:19 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2008-09-05 17:28:19 -0400 |
commit | 54e2a3270f4d5f50aefb08630a3c3c758b9c2723 (patch) | |
tree | 2d28170316f42778217fb16a0df1afe5898a2ce7 | |
parent | 41c9229498a2eb89db1c0a77321c61b448738de4 (diff) | |
parent | 673d62cc5ea6fca046650f17f77985b112c62322 (diff) |
Merge branch 'core/debugobjects' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/linux-2.6-tip
* 'core/debugobjects' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/linux-2.6-tip:
debugobjects: fix lockdep warning
-rw-r--r-- | include/linux/list.h | 13 | ||||
-rw-r--r-- | lib/debugobjects.c | 31 |
2 files changed, 36 insertions, 8 deletions
diff --git a/include/linux/list.h b/include/linux/list.h index db35ef02e745..969f6e92d089 100644 --- a/include/linux/list.h +++ b/include/linux/list.h | |||
@@ -619,6 +619,19 @@ static inline void hlist_add_after(struct hlist_node *n, | |||
619 | next->next->pprev = &next->next; | 619 | next->next->pprev = &next->next; |
620 | } | 620 | } |
621 | 621 | ||
622 | /* | ||
623 | * Move a list from one list head to another. Fixup the pprev | ||
624 | * reference of the first entry if it exists. | ||
625 | */ | ||
626 | static inline void hlist_move_list(struct hlist_head *old, | ||
627 | struct hlist_head *new) | ||
628 | { | ||
629 | new->first = old->first; | ||
630 | if (new->first) | ||
631 | new->first->pprev = &new->first; | ||
632 | old->first = NULL; | ||
633 | } | ||
634 | |||
622 | #define hlist_entry(ptr, type, member) container_of(ptr,type,member) | 635 | #define hlist_entry(ptr, type, member) container_of(ptr,type,member) |
623 | 636 | ||
624 | #define hlist_for_each(pos, head) \ | 637 | #define hlist_for_each(pos, head) \ |
diff --git a/lib/debugobjects.c b/lib/debugobjects.c index 45a6bde762d1..e3ab374e1334 100644 --- a/lib/debugobjects.c +++ b/lib/debugobjects.c | |||
@@ -112,6 +112,7 @@ static struct debug_obj *lookup_object(void *addr, struct debug_bucket *b) | |||
112 | 112 | ||
113 | /* | 113 | /* |
114 | * Allocate a new object. If the pool is empty, switch off the debugger. | 114 | * Allocate a new object. If the pool is empty, switch off the debugger. |
115 | * Must be called with interrupts disabled. | ||
115 | */ | 116 | */ |
116 | static struct debug_obj * | 117 | static struct debug_obj * |
117 | alloc_object(void *addr, struct debug_bucket *b, struct debug_obj_descr *descr) | 118 | alloc_object(void *addr, struct debug_bucket *b, struct debug_obj_descr *descr) |
@@ -148,17 +149,18 @@ alloc_object(void *addr, struct debug_bucket *b, struct debug_obj_descr *descr) | |||
148 | static void free_object(struct debug_obj *obj) | 149 | static void free_object(struct debug_obj *obj) |
149 | { | 150 | { |
150 | unsigned long idx = (unsigned long)(obj - obj_static_pool); | 151 | unsigned long idx = (unsigned long)(obj - obj_static_pool); |
152 | unsigned long flags; | ||
151 | 153 | ||
152 | if (obj_pool_free < ODEBUG_POOL_SIZE || idx < ODEBUG_POOL_SIZE) { | 154 | if (obj_pool_free < ODEBUG_POOL_SIZE || idx < ODEBUG_POOL_SIZE) { |
153 | spin_lock(&pool_lock); | 155 | spin_lock_irqsave(&pool_lock, flags); |
154 | hlist_add_head(&obj->node, &obj_pool); | 156 | hlist_add_head(&obj->node, &obj_pool); |
155 | obj_pool_free++; | 157 | obj_pool_free++; |
156 | obj_pool_used--; | 158 | obj_pool_used--; |
157 | spin_unlock(&pool_lock); | 159 | spin_unlock_irqrestore(&pool_lock, flags); |
158 | } else { | 160 | } else { |
159 | spin_lock(&pool_lock); | 161 | spin_lock_irqsave(&pool_lock, flags); |
160 | obj_pool_used--; | 162 | obj_pool_used--; |
161 | spin_unlock(&pool_lock); | 163 | spin_unlock_irqrestore(&pool_lock, flags); |
162 | kmem_cache_free(obj_cache, obj); | 164 | kmem_cache_free(obj_cache, obj); |
163 | } | 165 | } |
164 | } | 166 | } |
@@ -171,6 +173,7 @@ static void debug_objects_oom(void) | |||
171 | { | 173 | { |
172 | struct debug_bucket *db = obj_hash; | 174 | struct debug_bucket *db = obj_hash; |
173 | struct hlist_node *node, *tmp; | 175 | struct hlist_node *node, *tmp; |
176 | HLIST_HEAD(freelist); | ||
174 | struct debug_obj *obj; | 177 | struct debug_obj *obj; |
175 | unsigned long flags; | 178 | unsigned long flags; |
176 | int i; | 179 | int i; |
@@ -179,11 +182,14 @@ static void debug_objects_oom(void) | |||
179 | 182 | ||
180 | for (i = 0; i < ODEBUG_HASH_SIZE; i++, db++) { | 183 | for (i = 0; i < ODEBUG_HASH_SIZE; i++, db++) { |
181 | spin_lock_irqsave(&db->lock, flags); | 184 | spin_lock_irqsave(&db->lock, flags); |
182 | hlist_for_each_entry_safe(obj, node, tmp, &db->list, node) { | 185 | hlist_move_list(&db->list, &freelist); |
186 | spin_unlock_irqrestore(&db->lock, flags); | ||
187 | |||
188 | /* Now free them */ | ||
189 | hlist_for_each_entry_safe(obj, node, tmp, &freelist, node) { | ||
183 | hlist_del(&obj->node); | 190 | hlist_del(&obj->node); |
184 | free_object(obj); | 191 | free_object(obj); |
185 | } | 192 | } |
186 | spin_unlock_irqrestore(&db->lock, flags); | ||
187 | } | 193 | } |
188 | } | 194 | } |
189 | 195 | ||
@@ -498,8 +504,9 @@ void debug_object_free(void *addr, struct debug_obj_descr *descr) | |||
498 | return; | 504 | return; |
499 | default: | 505 | default: |
500 | hlist_del(&obj->node); | 506 | hlist_del(&obj->node); |
507 | spin_unlock_irqrestore(&db->lock, flags); | ||
501 | free_object(obj); | 508 | free_object(obj); |
502 | break; | 509 | return; |
503 | } | 510 | } |
504 | out_unlock: | 511 | out_unlock: |
505 | spin_unlock_irqrestore(&db->lock, flags); | 512 | spin_unlock_irqrestore(&db->lock, flags); |
@@ -510,6 +517,7 @@ static void __debug_check_no_obj_freed(const void *address, unsigned long size) | |||
510 | { | 517 | { |
511 | unsigned long flags, oaddr, saddr, eaddr, paddr, chunks; | 518 | unsigned long flags, oaddr, saddr, eaddr, paddr, chunks; |
512 | struct hlist_node *node, *tmp; | 519 | struct hlist_node *node, *tmp; |
520 | HLIST_HEAD(freelist); | ||
513 | struct debug_obj_descr *descr; | 521 | struct debug_obj_descr *descr; |
514 | enum debug_obj_state state; | 522 | enum debug_obj_state state; |
515 | struct debug_bucket *db; | 523 | struct debug_bucket *db; |
@@ -545,11 +553,18 @@ repeat: | |||
545 | goto repeat; | 553 | goto repeat; |
546 | default: | 554 | default: |
547 | hlist_del(&obj->node); | 555 | hlist_del(&obj->node); |
548 | free_object(obj); | 556 | hlist_add_head(&obj->node, &freelist); |
549 | break; | 557 | break; |
550 | } | 558 | } |
551 | } | 559 | } |
552 | spin_unlock_irqrestore(&db->lock, flags); | 560 | spin_unlock_irqrestore(&db->lock, flags); |
561 | |||
562 | /* Now free them */ | ||
563 | hlist_for_each_entry_safe(obj, node, tmp, &freelist, node) { | ||
564 | hlist_del(&obj->node); | ||
565 | free_object(obj); | ||
566 | } | ||
567 | |||
553 | if (cnt > debug_objects_maxchain) | 568 | if (cnt > debug_objects_maxchain) |
554 | debug_objects_maxchain = cnt; | 569 | debug_objects_maxchain = cnt; |
555 | } | 570 | } |