Don't lock guardpage if the stack is growing up
authorMikulas Patocka <mikulas@artax.karlin.mff.cuni.cz>
Mon, 9 May 2011 11:01:09 +0000 (13:01 +0200)
committerSteve Conklin <sconklin@canonical.com>
Thu, 2 Jun 2011 19:23:21 +0000 (14:23 -0500)
commitd6d59c04288cdd4549b8cce32b173c4e8797ae11
tree48546e82cc4ff7eb51ae331faece672be2a17082
parent900dffb791f20b8402394df54a8264309a7af600
Don't lock guardpage if the stack is growing up

BugLink: http://bugs.launchpad.net/bugs/788691

commit a09a79f66874c905af35d5bb5e5f2fdc7b6b894d upstream.

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>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
Signed-off-by: Steve Conklin <sconklin@canonical.com>
fs/proc/task_mmu.c
include/linux/mm.h
mm/memory.c