aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDavid Woodhouse <dwmw2@infradead.org>2006-01-11 09:41:26 -0500
committerLinus Torvalds <torvalds@g5.osdl.org>2006-01-11 11:14:16 -0500
commita4fc7ab1d065a9dd89ed0e74439ef87d4a16e980 (patch)
tree6312597ad183ee45e8769b1bc5b0035bfa681d64
parenta8b9ee7396ccc8db3bdb4108993556acbe2d3527 (diff)
[PATCH] fix/simplify mutex debugging code
Let's switch mutex_debug_check_no_locks_freed() to take (addr, len) as arguments instead, since all its callers were just calculating the 'to' address for themselves anyway... (and sometimes doing so badly). Signed-off-by: David Woodhouse <dwmw2@infradead.org> Acked-by: Ingo Molnar <mingo@elte.hu> Signed-off-by: Linus Torvalds <torvalds@osdl.org>
-rw-r--r--arch/i386/mm/pageattr.c2
-rw-r--r--include/linux/mm.h2
-rw-r--r--include/linux/mutex-debug.h2
-rw-r--r--include/linux/mutex.h2
-rw-r--r--kernel/mutex-debug.c5
-rw-r--r--mm/page_alloc.c2
-rw-r--r--mm/slab.c2
7 files changed, 9 insertions, 8 deletions
diff --git a/arch/i386/mm/pageattr.c b/arch/i386/mm/pageattr.c
index e8a53552b13d..d0cadb33b54c 100644
--- a/arch/i386/mm/pageattr.c
+++ b/arch/i386/mm/pageattr.c
@@ -224,7 +224,7 @@ void kernel_map_pages(struct page *page, int numpages, int enable)
224 return; 224 return;
225 if (!enable) 225 if (!enable)
226 mutex_debug_check_no_locks_freed(page_address(page), 226 mutex_debug_check_no_locks_freed(page_address(page),
227 page_address(page+numpages)); 227 numpages * PAGE_SIZE);
228 228
229 /* the return value is ignored - the calls cannot fail, 229 /* the return value is ignored - the calls cannot fail,
230 * large pages are disabled at boot time. 230 * large pages are disabled at boot time.
diff --git a/include/linux/mm.h b/include/linux/mm.h
index 3f1fafc0245e..e53d2c6fd5f4 100644
--- a/include/linux/mm.h
+++ b/include/linux/mm.h
@@ -1027,7 +1027,7 @@ kernel_map_pages(struct page *page, int numpages, int enable)
1027{ 1027{
1028 if (!PageHighMem(page) && !enable) 1028 if (!PageHighMem(page) && !enable)
1029 mutex_debug_check_no_locks_freed(page_address(page), 1029 mutex_debug_check_no_locks_freed(page_address(page),
1030 page_address(page + numpages)); 1030 numpages * PAGE_SIZE);
1031} 1031}
1032#endif 1032#endif
1033 1033
diff --git a/include/linux/mutex-debug.h b/include/linux/mutex-debug.h
index 8138d9eb58ec..8b5769f00467 100644
--- a/include/linux/mutex-debug.h
+++ b/include/linux/mutex-debug.h
@@ -18,6 +18,6 @@ extern void FASTCALL(mutex_destroy(struct mutex *lock));
18extern void mutex_debug_show_all_locks(void); 18extern void mutex_debug_show_all_locks(void);
19extern void mutex_debug_show_held_locks(struct task_struct *filter); 19extern void mutex_debug_show_held_locks(struct task_struct *filter);
20extern void mutex_debug_check_no_locks_held(struct task_struct *task); 20extern void mutex_debug_check_no_locks_held(struct task_struct *task);
21extern void mutex_debug_check_no_locks_freed(const void *from, const void *to); 21extern void mutex_debug_check_no_locks_freed(const void *from, unsigned long len);
22 22
23#endif 23#endif
diff --git a/include/linux/mutex.h b/include/linux/mutex.h
index f1c84b1252f5..f1ac507fa20d 100644
--- a/include/linux/mutex.h
+++ b/include/linux/mutex.h
@@ -79,7 +79,7 @@ struct mutex_waiter {
79# define mutex_debug_show_all_locks() do { } while (0) 79# define mutex_debug_show_all_locks() do { } while (0)
80# define mutex_debug_show_held_locks(p) do { } while (0) 80# define mutex_debug_show_held_locks(p) do { } while (0)
81# define mutex_debug_check_no_locks_held(task) do { } while (0) 81# define mutex_debug_check_no_locks_held(task) do { } while (0)
82# define mutex_debug_check_no_locks_freed(from, to) do { } while (0) 82# define mutex_debug_check_no_locks_freed(from, len) do { } while (0)
83#endif 83#endif
84 84
85#define __MUTEX_INITIALIZER(lockname) \ 85#define __MUTEX_INITIALIZER(lockname) \
diff --git a/kernel/mutex-debug.c b/kernel/mutex-debug.c
index 6f829058ae4a..f4913c376950 100644
--- a/kernel/mutex-debug.c
+++ b/kernel/mutex-debug.c
@@ -333,9 +333,10 @@ void mutex_debug_check_no_locks_held(struct task_struct *task)
333 * is destroyed or reinitialized - this code checks whether there is 333 * is destroyed or reinitialized - this code checks whether there is
334 * any held lock in the memory range of <from> to <to>: 334 * any held lock in the memory range of <from> to <to>:
335 */ 335 */
336void mutex_debug_check_no_locks_freed(const void *from, const void *to) 336void mutex_debug_check_no_locks_freed(const void *from, unsigned long len)
337{ 337{
338 struct list_head *curr, *next; 338 struct list_head *curr, *next;
339 const void *to = from + len;
339 unsigned long flags; 340 unsigned long flags;
340 struct mutex *lock; 341 struct mutex *lock;
341 void *lock_addr; 342 void *lock_addr;
@@ -437,7 +438,7 @@ void debug_mutex_init(struct mutex *lock, const char *name)
437 /* 438 /*
438 * Make sure we are not reinitializing a held lock: 439 * Make sure we are not reinitializing a held lock:
439 */ 440 */
440 mutex_debug_check_no_locks_freed((void *)lock, (void *)(lock + 1)); 441 mutex_debug_check_no_locks_freed((void *)lock, sizeof(*lock));
441 lock->owner = NULL; 442 lock->owner = NULL;
442 INIT_LIST_HEAD(&lock->held_list); 443 INIT_LIST_HEAD(&lock->held_list);
443 lock->name = name; 444 lock->name = name;
diff --git a/mm/page_alloc.c b/mm/page_alloc.c
index a5e6891f7bb6..8e363536e2da 100644
--- a/mm/page_alloc.c
+++ b/mm/page_alloc.c
@@ -417,7 +417,7 @@ static void __free_pages_ok(struct page *page, unsigned int order)
417 arch_free_page(page, order); 417 arch_free_page(page, order);
418 if (!PageHighMem(page)) 418 if (!PageHighMem(page))
419 mutex_debug_check_no_locks_freed(page_address(page), 419 mutex_debug_check_no_locks_freed(page_address(page),
420 page_address(page+(1<<order))); 420 PAGE_SIZE<<order);
421 421
422#ifndef CONFIG_MMU 422#ifndef CONFIG_MMU
423 for (i = 1 ; i < (1 << order) ; ++i) 423 for (i = 1 ; i < (1 << order) ; ++i)
diff --git a/mm/slab.c b/mm/slab.c
index 33aab345cd4a..9374293a3012 100644
--- a/mm/slab.c
+++ b/mm/slab.c
@@ -3071,7 +3071,7 @@ void kfree(const void *objp)
3071 local_irq_save(flags); 3071 local_irq_save(flags);
3072 kfree_debugcheck(objp); 3072 kfree_debugcheck(objp);
3073 c = page_get_cache(virt_to_page(objp)); 3073 c = page_get_cache(virt_to_page(objp));
3074 mutex_debug_check_no_locks_freed(objp, objp+obj_reallen(c)); 3074 mutex_debug_check_no_locks_freed(objp, obj_reallen(c));
3075 __cache_free(c, (void *)objp); 3075 __cache_free(c, (void *)objp);
3076 local_irq_restore(flags); 3076 local_irq_restore(flags);
3077} 3077}