aboutsummaryrefslogtreecommitdiffstats
path: root/mm
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@ppc970.osdl.org>2005-01-11 16:26:35 -0800
committerLinus Torvalds <torvalds@ppc970.osdl.org>2005-01-11 16:26:35 -0800
commitbf2efbc58504f0ab67b8f52e820a8287d0015cbc (patch)
treec793b7676d0d3706f285d8d2cc0626ae61926599 /mm
parent6a424edaddfcd5b68be2e1e641962764b57d7680 (diff)
downloadhistory-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.c12
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