Commit a4fc7ab1 authored by David Woodhouse's avatar David Woodhouse Committed by Linus Torvalds

[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: default avatarDavid Woodhouse <dwmw2@infradead.org>
Acked-by: default avatarIngo Molnar <mingo@elte.hu>
Signed-off-by: default avatarLinus Torvalds <torvalds@osdl.org>
parent a8b9ee73
...@@ -224,7 +224,7 @@ void kernel_map_pages(struct page *page, int numpages, int enable) ...@@ -224,7 +224,7 @@ void kernel_map_pages(struct page *page, int numpages, int enable)
return; return;
if (!enable) if (!enable)
mutex_debug_check_no_locks_freed(page_address(page), 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, /* the return value is ignored - the calls cannot fail,
* large pages are disabled at boot time. * large pages are disabled at boot time.
......
...@@ -1027,7 +1027,7 @@ kernel_map_pages(struct page *page, int numpages, int enable) ...@@ -1027,7 +1027,7 @@ kernel_map_pages(struct page *page, int numpages, int enable)
{ {
if (!PageHighMem(page) && !enable) if (!PageHighMem(page) && !enable)
mutex_debug_check_no_locks_freed(page_address(page), mutex_debug_check_no_locks_freed(page_address(page),
page_address(page + numpages)); numpages * PAGE_SIZE);
} }
#endif #endif
......
...@@ -18,6 +18,6 @@ extern void FASTCALL(mutex_destroy(struct mutex *lock)); ...@@ -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_all_locks(void);
extern void mutex_debug_show_held_locks(struct task_struct *filter); 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_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 #endif
...@@ -79,7 +79,7 @@ struct mutex_waiter { ...@@ -79,7 +79,7 @@ struct mutex_waiter {
# define mutex_debug_show_all_locks() do { } while (0) # define mutex_debug_show_all_locks() do { } while (0)
# define mutex_debug_show_held_locks(p) 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_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 #endif
#define __MUTEX_INITIALIZER(lockname) \ #define __MUTEX_INITIALIZER(lockname) \
......
...@@ -333,9 +333,10 @@ void mutex_debug_check_no_locks_held(struct task_struct *task) ...@@ -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 * is destroyed or reinitialized - this code checks whether there is
* any held lock in the memory range of <from> to <to>: * any held lock in the memory range of <from> to <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; struct list_head *curr, *next;
const void *to = from + len;
unsigned long flags; unsigned long flags;
struct mutex *lock; struct mutex *lock;
void *lock_addr; void *lock_addr;
...@@ -437,7 +438,7 @@ void debug_mutex_init(struct mutex *lock, const char *name) ...@@ -437,7 +438,7 @@ void debug_mutex_init(struct mutex *lock, const char *name)
/* /*
* Make sure we are not reinitializing a held lock: * 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; lock->owner = NULL;
INIT_LIST_HEAD(&lock->held_list); INIT_LIST_HEAD(&lock->held_list);
lock->name = name; lock->name = name;
......
...@@ -417,7 +417,7 @@ static void __free_pages_ok(struct page *page, unsigned int order) ...@@ -417,7 +417,7 @@ static void __free_pages_ok(struct page *page, unsigned int order)
arch_free_page(page, order); arch_free_page(page, order);
if (!PageHighMem(page)) if (!PageHighMem(page))
mutex_debug_check_no_locks_freed(page_address(page), mutex_debug_check_no_locks_freed(page_address(page),
page_address(page+(1<<order))); PAGE_SIZE<<order);
#ifndef CONFIG_MMU #ifndef CONFIG_MMU
for (i = 1 ; i < (1 << order) ; ++i) for (i = 1 ; i < (1 << order) ; ++i)
......
...@@ -3071,7 +3071,7 @@ void kfree(const void *objp) ...@@ -3071,7 +3071,7 @@ void kfree(const void *objp)
local_irq_save(flags); local_irq_save(flags);
kfree_debugcheck(objp); kfree_debugcheck(objp);
c = page_get_cache(virt_to_page(objp)); c = page_get_cache(virt_to_page(objp));
mutex_debug_check_no_locks_freed(objp, objp+obj_reallen(c)); mutex_debug_check_no_locks_freed(objp, obj_reallen(c));
__cache_free(c, (void *)objp); __cache_free(c, (void *)objp);
local_irq_restore(flags); local_irq_restore(flags);
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment