Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

mm: add MAP_HUGETLB for mmaping pseudo-anonymous huge page regions

Add a flag for mmap that will be used to request a huge page region that
will look like anonymous memory to user space. This is accomplished by
using a file on the internal vfsmount. MAP_HUGETLB is a modifier of
MAP_ANONYMOUS and so must be specified with it. The region will behave
the same as a MAP_ANONYMOUS region using small pages.

The patch also adds the MAP_STACK flag, which was previously defined only
on some architectures but not on others. Since MAP_STACK is meant to be a
hint only, architectures can define it without assigning a specific
meaning to it.

Signed-off-by: Arnd Bergmann <arnd@arndb.de>
Cc: Eric B Munson <ebmunson@us.ibm.com>
Cc: Hugh Dickins <hugh.dickins@tiscali.co.uk>
Cc: David Rientjes <rientjes@google.com>
Cc: <linux-arch@vger.kernel.org>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>

authored by

Arnd Bergmann and committed by
Linus Torvalds
90f72aa5 6bfde05b

+33
+2
arch/alpha/include/asm/mman.h
··· 28 28 #define MAP_NORESERVE 0x10000 /* don't check for reservations */ 29 29 #define MAP_POPULATE 0x20000 /* populate (prefault) pagetables */ 30 30 #define MAP_NONBLOCK 0x40000 /* do not block on IO */ 31 + #define MAP_STACK 0x80000 /* give out an address that is best suited for process/thread stacks */ 32 + #define MAP_HUGETLB 0x100000 /* create a huge page mapping */ 31 33 32 34 #define MS_ASYNC 1 /* sync memory asynchronously */ 33 35 #define MS_SYNC 2 /* synchronous memory sync */
+2
arch/arm/include/asm/mman.h
··· 10 10 #define MAP_NORESERVE 0x4000 /* don't check for reservations */ 11 11 #define MAP_POPULATE 0x8000 /* populate (prefault) page tables */ 12 12 #define MAP_NONBLOCK 0x10000 /* do not block on IO */ 13 + #define MAP_STACK 0x20000 /* give out an address that is best suited for process/thread stacks */ 14 + #define MAP_HUGETLB 0x40000 /* create a huge page mapping */ 13 15 14 16 #define MCL_CURRENT 1 /* lock all current mappings */ 15 17 #define MCL_FUTURE 2 /* lock all future mappings */
+2
arch/avr32/include/asm/mman.h
··· 10 10 #define MAP_NORESERVE 0x4000 /* don't check for reservations */ 11 11 #define MAP_POPULATE 0x8000 /* populate (prefault) page tables */ 12 12 #define MAP_NONBLOCK 0x10000 /* do not block on IO */ 13 + #define MAP_STACK 0x20000 /* give out an address that is best suited for process/thread stacks */ 14 + #define MAP_HUGETLB 0x40000 /* create a huge page mapping */ 13 15 14 16 #define MCL_CURRENT 1 /* lock all current mappings */ 15 17 #define MCL_FUTURE 2 /* lock all future mappings */
+2
arch/cris/include/asm/mman.h
··· 12 12 #define MAP_NORESERVE 0x4000 /* don't check for reservations */ 13 13 #define MAP_POPULATE 0x8000 /* populate (prefault) pagetables */ 14 14 #define MAP_NONBLOCK 0x10000 /* do not block on IO */ 15 + #define MAP_STACK 0x20000 /* give out an address that is best suited for process/thread stacks */ 16 + #define MAP_HUGETLB 0x40000 /* create a huge page mapping */ 15 17 16 18 #define MCL_CURRENT 1 /* lock all current mappings */ 17 19 #define MCL_FUTURE 2 /* lock all future mappings */
+2
arch/frv/include/asm/mman.h
··· 10 10 #define MAP_NORESERVE 0x4000 /* don't check for reservations */ 11 11 #define MAP_POPULATE 0x8000 /* populate (prefault) pagetables */ 12 12 #define MAP_NONBLOCK 0x10000 /* do not block on IO */ 13 + #define MAP_STACK 0x20000 /* give out an address that is best suited for process/thread stacks */ 14 + #define MAP_HUGETLB 0x40000 /* create a huge page mapping */ 13 15 14 16 #define MCL_CURRENT 1 /* lock all current mappings */ 15 17 #define MCL_FUTURE 2 /* lock all future mappings */
+2
arch/h8300/include/asm/mman.h
··· 10 10 #define MAP_NORESERVE 0x4000 /* don't check for reservations */ 11 11 #define MAP_POPULATE 0x8000 /* populate (prefault) pagetables */ 12 12 #define MAP_NONBLOCK 0x10000 /* do not block on IO */ 13 + #define MAP_STACK 0x20000 /* give out an address that is best suited for process/thread stacks */ 14 + #define MAP_HUGETLB 0x40000 /* create a huge page mapping */ 13 15 14 16 #define MCL_CURRENT 1 /* lock all current mappings */ 15 17 #define MCL_FUTURE 2 /* lock all future mappings */
+2
arch/ia64/include/asm/mman.h
··· 18 18 #define MAP_NORESERVE 0x04000 /* don't check for reservations */ 19 19 #define MAP_POPULATE 0x08000 /* populate (prefault) pagetables */ 20 20 #define MAP_NONBLOCK 0x10000 /* do not block on IO */ 21 + #define MAP_STACK 0x20000 /* give out an address that is best suited for process/thread stacks */ 22 + #define MAP_HUGETLB 0x40000 /* create a huge page mapping */ 21 23 22 24 #define MCL_CURRENT 1 /* lock all current mappings */ 23 25 #define MCL_FUTURE 2 /* lock all future mappings */
+2
arch/m32r/include/asm/mman.h
··· 10 10 #define MAP_NORESERVE 0x4000 /* don't check for reservations */ 11 11 #define MAP_POPULATE 0x8000 /* populate (prefault) pagetables */ 12 12 #define MAP_NONBLOCK 0x10000 /* do not block on IO */ 13 + #define MAP_STACK 0x20000 /* give out an address that is best suited for process/thread stacks */ 14 + #define MAP_HUGETLB 0x40000 /* create a huge page mapping */ 13 15 14 16 #define MCL_CURRENT 1 /* lock all current mappings */ 15 17 #define MCL_FUTURE 2 /* lock all future mappings */
+2
arch/m68k/include/asm/mman.h
··· 10 10 #define MAP_NORESERVE 0x4000 /* don't check for reservations */ 11 11 #define MAP_POPULATE 0x8000 /* populate (prefault) pagetables */ 12 12 #define MAP_NONBLOCK 0x10000 /* do not block on IO */ 13 + #define MAP_STACK 0x20000 /* give out an address that is best suited for process/thread stacks */ 14 + #define MAP_HUGETLB 0x40000 /* create a huge page mapping */ 13 15 14 16 #define MCL_CURRENT 1 /* lock all current mappings */ 15 17 #define MCL_FUTURE 2 /* lock all future mappings */
+2
arch/mips/include/asm/mman.h
··· 46 46 #define MAP_LOCKED 0x8000 /* pages are locked */ 47 47 #define MAP_POPULATE 0x10000 /* populate (prefault) pagetables */ 48 48 #define MAP_NONBLOCK 0x20000 /* do not block on IO */ 49 + #define MAP_STACK 0x40000 /* give out an address that is best suited for process/thread stacks */ 50 + #define MAP_HUGETLB 0x80000 /* create a huge page mapping */ 49 51 50 52 /* 51 53 * Flags for msync
+2
arch/mn10300/include/asm/mman.h
··· 21 21 #define MAP_NORESERVE 0x4000 /* don't check for reservations */ 22 22 #define MAP_POPULATE 0x8000 /* populate (prefault) pagetables */ 23 23 #define MAP_NONBLOCK 0x10000 /* do not block on IO */ 24 + #define MAP_STACK 0x20000 /* give out an address that is best suited for process/thread stacks */ 25 + #define MAP_HUGETLB 0x40000 /* create a huge page mapping */ 24 26 25 27 #define MCL_CURRENT 1 /* lock all current mappings */ 26 28 #define MCL_FUTURE 2 /* lock all future mappings */
+2
arch/parisc/include/asm/mman.h
··· 22 22 #define MAP_GROWSDOWN 0x8000 /* stack-like segment */ 23 23 #define MAP_POPULATE 0x10000 /* populate (prefault) pagetables */ 24 24 #define MAP_NONBLOCK 0x20000 /* do not block on IO */ 25 + #define MAP_STACK 0x40000 /* give out an address that is best suited for process/thread stacks */ 26 + #define MAP_HUGETLB 0x80000 /* create a huge page mapping */ 25 27 26 28 #define MS_SYNC 1 /* synchronous memory sync */ 27 29 #define MS_ASYNC 2 /* sync memory asynchronously */
+2
arch/powerpc/include/asm/mman.h
··· 25 25 26 26 #define MAP_POPULATE 0x8000 /* populate (prefault) pagetables */ 27 27 #define MAP_NONBLOCK 0x10000 /* do not block on IO */ 28 + #define MAP_STACK 0x20000 /* give out an address that is best suited for process/thread stacks */ 29 + #define MAP_HUGETLB 0x40000 /* create a huge page mapping */ 28 30 29 31 #ifdef __KERNEL__ 30 32 #ifdef CONFIG_PPC64
+2
arch/s390/include/asm/mman.h
··· 18 18 #define MAP_NORESERVE 0x4000 /* don't check for reservations */ 19 19 #define MAP_POPULATE 0x8000 /* populate (prefault) pagetables */ 20 20 #define MAP_NONBLOCK 0x10000 /* do not block on IO */ 21 + #define MAP_STACK 0x20000 /* give out an address that is best suited for process/thread stacks */ 22 + #define MAP_HUGETLB 0x40000 /* create a huge page mapping */ 21 23 22 24 #define MCL_CURRENT 1 /* lock all current mappings */ 23 25 #define MCL_FUTURE 2 /* lock all future mappings */
+2
arch/sparc/include/asm/mman.h
··· 20 20 21 21 #define MAP_POPULATE 0x8000 /* populate (prefault) pagetables */ 22 22 #define MAP_NONBLOCK 0x10000 /* do not block on IO */ 23 + #define MAP_STACK 0x20000 /* give out an address that is best suited for process/thread stacks */ 24 + #define MAP_HUGETLB 0x40000 /* create a huge page mapping */ 23 25 24 26 #ifdef __KERNEL__ 25 27 #ifndef __ASSEMBLY__
+2
arch/xtensa/include/asm/mman.h
··· 53 53 #define MAP_LOCKED 0x8000 /* pages are locked */ 54 54 #define MAP_POPULATE 0x10000 /* populate (prefault) pagetables */ 55 55 #define MAP_NONBLOCK 0x20000 /* do not block on IO */ 56 + #define MAP_STACK 0x40000 /* give out an address that is best suited for process/thread stacks */ 57 + #define MAP_HUGETLB 0x80000 /* create a huge page mapping */ 56 58 57 59 /* 58 60 * Flags for msync
+1
include/asm-generic/mman.h
··· 11 11 #define MAP_POPULATE 0x8000 /* populate (prefault) pagetables */ 12 12 #define MAP_NONBLOCK 0x10000 /* do not block on IO */ 13 13 #define MAP_STACK 0x20000 /* give out an address that is best suited for process/thread stacks */ 14 + #define MAP_HUGETLB 0x40000 /* create a huge page mapping */ 14 15 15 16 #define MCL_CURRENT 1 /* lock all current mappings */ 16 17 #define MCL_FUTURE 2 /* lock all future mappings */