diff options
author | Mikulas Patocka <mikulas@artax.karlin.mff.cuni.cz> | 2011-05-09 07:01:09 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2011-05-09 19:22:07 -0400 |
commit | a09a79f66874c905af35d5bb5e5f2fdc7b6b894d (patch) | |
tree | 9cb2ae1fef7083af91a49c19411e9871e0e59a37 /include/linux/mm.h | |
parent | 26822eebb25500fb0776c7c256a6af041e9f538b (diff) |
Don't lock guardpage if the stack is growing up
Linux kernel excludes guard page when performing mlock on a VMA with
down-growing stack. However, some architectures have up-growing stack
and locking the guard page should be excluded in this case too.
This patch fixes lvm2 on PA-RISC (and possibly other architectures with
up-growing stack). lvm2 calculates number of used pages when locking and
when unlocking and reports an internal error if the numbers mismatch.
[ Patch changed fairly extensively to also fix /proc/<pid>/maps for the
grows-up case, and to move things around a bit to clean it all up and
share the infrstructure with the /proc bits.
Tested on ia64 that has both grow-up and grow-down segments - Linus ]
Signed-off-by: Mikulas Patocka <mikulas@artax.karlin.mff.cuni.cz>
Tested-by: Tony Luck <tony.luck@gmail.com>
Cc: stable@kernel.org
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'include/linux/mm.h')
-rw-r--r-- | include/linux/mm.h | 24 |
1 files changed, 23 insertions, 1 deletions
diff --git a/include/linux/mm.h b/include/linux/mm.h index 2348db26bc3d..6507dde38b16 100644 --- a/include/linux/mm.h +++ b/include/linux/mm.h | |||
@@ -1011,11 +1011,33 @@ int set_page_dirty_lock(struct page *page); | |||
1011 | int clear_page_dirty_for_io(struct page *page); | 1011 | int clear_page_dirty_for_io(struct page *page); |
1012 | 1012 | ||
1013 | /* Is the vma a continuation of the stack vma above it? */ | 1013 | /* Is the vma a continuation of the stack vma above it? */ |
1014 | static inline int vma_stack_continue(struct vm_area_struct *vma, unsigned long addr) | 1014 | static inline int vma_growsdown(struct vm_area_struct *vma, unsigned long addr) |
1015 | { | 1015 | { |
1016 | return vma && (vma->vm_end == addr) && (vma->vm_flags & VM_GROWSDOWN); | 1016 | return vma && (vma->vm_end == addr) && (vma->vm_flags & VM_GROWSDOWN); |
1017 | } | 1017 | } |
1018 | 1018 | ||
1019 | static inline int stack_guard_page_start(struct vm_area_struct *vma, | ||
1020 | unsigned long addr) | ||
1021 | { | ||
1022 | return (vma->vm_flags & VM_GROWSDOWN) && | ||
1023 | (vma->vm_start == addr) && | ||
1024 | !vma_growsdown(vma->vm_prev, addr); | ||
1025 | } | ||
1026 | |||
1027 | /* Is the vma a continuation of the stack vma below it? */ | ||
1028 | static inline int vma_growsup(struct vm_area_struct *vma, unsigned long addr) | ||
1029 | { | ||
1030 | return vma && (vma->vm_start == addr) && (vma->vm_flags & VM_GROWSUP); | ||
1031 | } | ||
1032 | |||
1033 | static inline int stack_guard_page_end(struct vm_area_struct *vma, | ||
1034 | unsigned long addr) | ||
1035 | { | ||
1036 | return (vma->vm_flags & VM_GROWSUP) && | ||
1037 | (vma->vm_end == addr) && | ||
1038 | !vma_growsup(vma->vm_next, addr); | ||
1039 | } | ||
1040 | |||
1019 | extern unsigned long move_page_tables(struct vm_area_struct *vma, | 1041 | extern unsigned long move_page_tables(struct vm_area_struct *vma, |
1020 | unsigned long old_addr, struct vm_area_struct *new_vma, | 1042 | unsigned long old_addr, struct vm_area_struct *new_vma, |
1021 | unsigned long new_addr, unsigned long len); | 1043 | unsigned long new_addr, unsigned long len); |