From a4fc7ab1d065a9dd89ed0e74439ef87d4a16e980 Mon Sep 17 00:00:00 2001 From: David Woodhouse Date: Wed, 11 Jan 2006 14:41:26 +0000 Subject: [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 Acked-by: Ingo Molnar Signed-off-by: Linus Torvalds --- arch/i386/mm/pageattr.c | 2 +- include/linux/mm.h | 2 +- include/linux/mutex-debug.h | 2 +- include/linux/mutex.h | 2 +- kernel/mutex-debug.c | 5 +++-- mm/page_alloc.c | 2 +- mm/slab.c | 2 +- 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) return; if (!enable) mutex_debug_check_no_locks_freed(page_address(page), - page_address(page+numpages)); + numpages * PAGE_SIZE); /* the return value is ignored - the calls cannot fail, * 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) { if (!PageHighMem(page) && !enable) mutex_debug_check_no_locks_freed(page_address(page), - page_address(page + numpages)); + numpages * PAGE_SIZE); } #endif 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)); extern void mutex_debug_show_all_locks(void); extern void mutex_debug_show_held_locks(struct task_struct *filter); extern void mutex_debug_check_no_locks_held(struct task_struct *task); -extern void mutex_debug_check_no_locks_freed(const void *from, const void *to); +extern void mutex_debug_check_no_locks_freed(const void *from, unsigned long len); #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 { # define mutex_debug_show_all_locks() do { } while (0) # define mutex_debug_show_held_locks(p) do { } while (0) # define mutex_debug_check_no_locks_held(task) do { } while (0) -# define mutex_debug_check_no_locks_freed(from, to) do { } while (0) +# define mutex_debug_check_no_locks_freed(from, len) do { } while (0) #endif #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) * is destroyed or reinitialized - this code checks whether there is * any held lock in the memory range of to : */ -void mutex_debug_check_no_locks_freed(const void *from, const void *to) +void mutex_debug_check_no_locks_freed(const void *from, unsigned long len) { struct list_head *curr, *next; + const void *to = from + len; unsigned long flags; struct mutex *lock; void *lock_addr; @@ -437,7 +438,7 @@ void debug_mutex_init(struct mutex *lock, const char *name) /* * Make sure we are not reinitializing a held lock: */ - mutex_debug_check_no_locks_freed((void *)lock, (void *)(lock + 1)); + mutex_debug_check_no_locks_freed((void *)lock, sizeof(*lock)); lock->owner = NULL; INIT_LIST_HEAD(&lock->held_list); 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) arch_free_page(page, order); if (!PageHighMem(page)) mutex_debug_check_no_locks_freed(page_address(page), - page_address(page+(1<