diff options
author | Linus Torvalds <torvalds@ppc970.osdl.org> | 2005-01-11 16:26:35 -0800 |
---|---|---|
committer | Linus Torvalds <torvalds@ppc970.osdl.org> | 2005-01-11 16:26:35 -0800 |
commit | bf2efbc58504f0ab67b8f52e820a8287d0015cbc (patch) | |
tree | c793b7676d0d3706f285d8d2cc0626ae61926599 /mm | |
parent | 6a424edaddfcd5b68be2e1e641962764b57d7680 (diff) | |
download | history-bf2efbc58504f0ab67b8f52e820a8287d0015cbc.tar.gz |
Make mm writelock testing less intrusive.
This enables it only for debug kernels, and also makes sure
that if some external module is still broken, we don't leave
the mmap-sem locked after warning about it.
Diffstat (limited to 'mm')
-rw-r--r-- | mm/mmap.c | 12 |
1 files changed, 11 insertions, 1 deletions
diff --git a/mm/mmap.c b/mm/mmap.c index 6eeae1d510d76c..21329bf3dea3b6 100644 --- a/mm/mmap.c +++ b/mm/mmap.c @@ -1870,6 +1870,16 @@ asmlinkage long sys_munmap(unsigned long addr, size_t len) return ret; } +static inline void verify_mm_writelocked(struct mm_struct *mm) +{ +#ifdef CONFIG_DEBUG_KERNEL + if (unlikely(down_read_trylock(&mm->mmap_sem))) { + WARN_ON(1); + up_read(&mm->mmap_sem); + } +#endif +} + /* * this is really a simplified "do_mmap". it only handles * anonymous maps. eventually we may be able to do some @@ -1906,7 +1916,7 @@ unsigned long do_brk(unsigned long addr, unsigned long len) * mm->mmap_sem is required to protect against another thread * changing the mappings in case we sleep. */ - WARN_ON(down_read_trylock(&mm->mmap_sem)); + verify_mm_writelocked(mm); /* * Clear old maps. this also does some error checking for us |