summaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
authorMichael S. Tsirkin <mst@mellanox.co.il>2006-02-14 13:53:08 -0800
committerLinus Torvalds <torvalds@g5.osdl.org>2006-02-14 16:09:34 -0800
commitf822566165dd46ff5de9bf895cfa6c51f53bb0c4 (patch)
treee052f406d5a14140d17f76dc8914d33bbc8e5f1d /include
parent8861da31e3b3e3df7b05e7b157230de3d486e53b (diff)
downloadlinux-3.10-f822566165dd46ff5de9bf895cfa6c51f53bb0c4.tar.gz
linux-3.10-f822566165dd46ff5de9bf895cfa6c51f53bb0c4.tar.bz2
linux-3.10-f822566165dd46ff5de9bf895cfa6c51f53bb0c4.zip
[PATCH] madvise MADV_DONTFORK/MADV_DOFORK
Currently, copy-on-write may change the physical address of a page even if the user requested that the page is pinned in memory (either by mlock or by get_user_pages). This happens if the process forks meanwhile, and the parent writes to that page. As a result, the page is orphaned: in case of get_user_pages, the application will never see any data hardware DMA's into this page after the COW. In case of mlock'd memory, the parent is not getting the realtime/security benefits of mlock. In particular, this affects the Infiniband modules which do DMA from and into user pages all the time. This patch adds madvise options to control whether memory range is inherited across fork. Useful e.g. for when hardware is doing DMA from/into these pages. Could also be useful to an application wanting to speed up its forks by cutting large areas out of consideration. Signed-off-by: Michael S. Tsirkin <mst@mellanox.co.il> Acked-by: Hugh Dickins <hugh@veritas.com> Cc: Michael Kerrisk <mtk-manpages@gmx.net> Signed-off-by: Andrew Morton <akpm@osdl.org> Signed-off-by: Linus Torvalds <torvalds@osdl.org>
Diffstat (limited to 'include')
-rw-r--r--include/asm-alpha/mman.h2
-rw-r--r--include/asm-arm/mman.h2
-rw-r--r--include/asm-arm26/mman.h2
-rw-r--r--include/asm-cris/mman.h2
-rw-r--r--include/asm-frv/mman.h2
-rw-r--r--include/asm-h8300/mman.h2
-rw-r--r--include/asm-i386/mman.h2
-rw-r--r--include/asm-ia64/mman.h2
-rw-r--r--include/asm-m32r/mman.h2
-rw-r--r--include/asm-m68k/mman.h2
-rw-r--r--include/asm-mips/mman.h2
-rw-r--r--include/asm-parisc/mman.h2
-rw-r--r--include/asm-powerpc/mman.h2
-rw-r--r--include/asm-s390/mman.h2
-rw-r--r--include/asm-sh/mman.h2
-rw-r--r--include/asm-sparc/mman.h2
-rw-r--r--include/asm-sparc64/mman.h2
-rw-r--r--include/asm-v850/mman.h2
-rw-r--r--include/asm-x86_64/mman.h2
-rw-r--r--include/asm-xtensa/mman.h2
20 files changed, 40 insertions, 0 deletions
diff --git a/include/asm-alpha/mman.h b/include/asm-alpha/mman.h
index f6439532a26..a21515c16a4 100644
--- a/include/asm-alpha/mman.h
+++ b/include/asm-alpha/mman.h
@@ -43,6 +43,8 @@
#define MADV_SPACEAVAIL 5 /* ensure resources are available */
#define MADV_DONTNEED 6 /* don't need these pages */
#define MADV_REMOVE 7 /* remove these pages & resources */
+#define MADV_DONTFORK 0x30 /* dont inherit across fork */
+#define MADV_DOFORK 0x31 /* do inherit across fork */
/* compatibility flags */
#define MAP_ANON MAP_ANONYMOUS
diff --git a/include/asm-arm/mman.h b/include/asm-arm/mman.h
index f0bebca2ac2..693ed859e63 100644
--- a/include/asm-arm/mman.h
+++ b/include/asm-arm/mman.h
@@ -36,6 +36,8 @@
#define MADV_WILLNEED 0x3 /* pre-fault pages */
#define MADV_DONTNEED 0x4 /* discard these pages */
#define MADV_REMOVE 0x5 /* remove these pages & resources */
+#define MADV_DONTFORK 0x30 /* dont inherit across fork */
+#define MADV_DOFORK 0x31 /* do inherit across fork */
/* compatibility flags */
#define MAP_ANON MAP_ANONYMOUS
diff --git a/include/asm-arm26/mman.h b/include/asm-arm26/mman.h
index 0ed7780541f..2096c50df88 100644
--- a/include/asm-arm26/mman.h
+++ b/include/asm-arm26/mman.h
@@ -36,6 +36,8 @@
#define MADV_WILLNEED 0x3 /* pre-fault pages */
#define MADV_DONTNEED 0x4 /* discard these pages */
#define MADV_REMOVE 0x5 /* remove these pages & resources */
+#define MADV_DONTFORK 0x30 /* dont inherit across fork */
+#define MADV_DOFORK 0x31 /* do inherit across fork */
/* compatibility flags */
#define MAP_ANON MAP_ANONYMOUS
diff --git a/include/asm-cris/mman.h b/include/asm-cris/mman.h
index 5a382b8bf3f..deddfb239ff 100644
--- a/include/asm-cris/mman.h
+++ b/include/asm-cris/mman.h
@@ -38,6 +38,8 @@
#define MADV_WILLNEED 0x3 /* pre-fault pages */
#define MADV_DONTNEED 0x4 /* discard these pages */
#define MADV_REMOVE 0x5 /* remove these pages & resources */
+#define MADV_DONTFORK 0x30 /* dont inherit across fork */
+#define MADV_DOFORK 0x31 /* do inherit across fork */
/* compatibility flags */
#define MAP_ANON MAP_ANONYMOUS
diff --git a/include/asm-frv/mman.h b/include/asm-frv/mman.h
index 8af4a41c255..d3bca306da8 100644
--- a/include/asm-frv/mman.h
+++ b/include/asm-frv/mman.h
@@ -36,6 +36,8 @@
#define MADV_WILLNEED 0x3 /* pre-fault pages */
#define MADV_DONTNEED 0x4 /* discard these pages */
#define MADV_REMOVE 0x5 /* remove these pages & resources */
+#define MADV_DONTFORK 0x30 /* dont inherit across fork */
+#define MADV_DOFORK 0x31 /* do inherit across fork */
/* compatibility flags */
#define MAP_ANON MAP_ANONYMOUS
diff --git a/include/asm-h8300/mman.h b/include/asm-h8300/mman.h
index 744a8fb485c..ac0346f7d11 100644
--- a/include/asm-h8300/mman.h
+++ b/include/asm-h8300/mman.h
@@ -36,6 +36,8 @@
#define MADV_WILLNEED 0x3 /* pre-fault pages */
#define MADV_DONTNEED 0x4 /* discard these pages */
#define MADV_REMOVE 0x5 /* remove these pages & resources */
+#define MADV_DONTFORK 0x30 /* dont inherit across fork */
+#define MADV_DOFORK 0x31 /* do inherit across fork */
/* compatibility flags */
#define MAP_ANON MAP_ANONYMOUS
diff --git a/include/asm-i386/mman.h b/include/asm-i386/mman.h
index ba4941e6f64..ab2339a1d80 100644
--- a/include/asm-i386/mman.h
+++ b/include/asm-i386/mman.h
@@ -36,6 +36,8 @@
#define MADV_WILLNEED 0x3 /* pre-fault pages */
#define MADV_DONTNEED 0x4 /* discard these pages */
#define MADV_REMOVE 0x5 /* remove these pages & resources */
+#define MADV_DONTFORK 0x30 /* dont inherit across fork */
+#define MADV_DOFORK 0x31 /* do inherit across fork */
/* compatibility flags */
#define MAP_ANON MAP_ANONYMOUS
diff --git a/include/asm-ia64/mman.h b/include/asm-ia64/mman.h
index 828beb24a20..357ebb780cc 100644
--- a/include/asm-ia64/mman.h
+++ b/include/asm-ia64/mman.h
@@ -44,6 +44,8 @@
#define MADV_WILLNEED 0x3 /* pre-fault pages */
#define MADV_DONTNEED 0x4 /* discard these pages */
#define MADV_REMOVE 0x5 /* remove these pages & resources */
+#define MADV_DONTFORK 0x30 /* dont inherit across fork */
+#define MADV_DOFORK 0x31 /* do inherit across fork */
/* compatibility flags */
#define MAP_ANON MAP_ANONYMOUS
diff --git a/include/asm-m32r/mman.h b/include/asm-m32r/mman.h
index 12e29747bc8..6b02fe3fcff 100644
--- a/include/asm-m32r/mman.h
+++ b/include/asm-m32r/mman.h
@@ -38,6 +38,8 @@
#define MADV_WILLNEED 0x3 /* pre-fault pages */
#define MADV_DONTNEED 0x4 /* discard these pages */
#define MADV_REMOVE 0x5 /* remove these pages & resources */
+#define MADV_DONTFORK 0x30 /* dont inherit across fork */
+#define MADV_DOFORK 0x31 /* do inherit across fork */
/* compatibility flags */
#define MAP_ANON MAP_ANONYMOUS
diff --git a/include/asm-m68k/mman.h b/include/asm-m68k/mman.h
index ea262ab88b3..efd12bc4ccb 100644
--- a/include/asm-m68k/mman.h
+++ b/include/asm-m68k/mman.h
@@ -36,6 +36,8 @@
#define MADV_WILLNEED 0x3 /* pre-fault pages */
#define MADV_DONTNEED 0x4 /* discard these pages */
#define MADV_REMOVE 0x5 /* remove these pages & resources */
+#define MADV_DONTFORK 0x30 /* dont inherit across fork */
+#define MADV_DOFORK 0x31 /* do inherit across fork */
/* compatibility flags */
#define MAP_ANON MAP_ANONYMOUS
diff --git a/include/asm-mips/mman.h b/include/asm-mips/mman.h
index dd17c8bd62a..6d01e26830f 100644
--- a/include/asm-mips/mman.h
+++ b/include/asm-mips/mman.h
@@ -66,6 +66,8 @@
#define MADV_WILLNEED 0x3 /* pre-fault pages */
#define MADV_DONTNEED 0x4 /* discard these pages */
#define MADV_REMOVE 0x5 /* remove these pages & resources */
+#define MADV_DONTFORK 0x30 /* dont inherit across fork */
+#define MADV_DOFORK 0x31 /* do inherit across fork */
/* compatibility flags */
#define MAP_ANON MAP_ANONYMOUS
diff --git a/include/asm-parisc/mman.h b/include/asm-parisc/mman.h
index 736b0abcac0..a381cf5c8f5 100644
--- a/include/asm-parisc/mman.h
+++ b/include/asm-parisc/mman.h
@@ -49,6 +49,8 @@
#define MADV_4M_PAGES 22 /* Use 4 Megabyte pages */
#define MADV_16M_PAGES 24 /* Use 16 Megabyte pages */
#define MADV_64M_PAGES 26 /* Use 64 Megabyte pages */
+#define MADV_DONTFORK 0x30 /* dont inherit across fork */
+#define MADV_DOFORK 0x31 /* do inherit across fork */
/* compatibility flags */
#define MAP_ANON MAP_ANONYMOUS
diff --git a/include/asm-powerpc/mman.h b/include/asm-powerpc/mman.h
index a2e34c21b44..fcff25d13f1 100644
--- a/include/asm-powerpc/mman.h
+++ b/include/asm-powerpc/mman.h
@@ -45,6 +45,8 @@
#define MADV_WILLNEED 0x3 /* pre-fault pages */
#define MADV_DONTNEED 0x4 /* discard these pages */
#define MADV_REMOVE 0x5 /* remove these pages & resources */
+#define MADV_DONTFORK 0x30 /* dont inherit across fork */
+#define MADV_DOFORK 0x31 /* do inherit across fork */
/* compatibility flags */
#define MAP_ANON MAP_ANONYMOUS
diff --git a/include/asm-s390/mman.h b/include/asm-s390/mman.h
index c8d5409b5d5..d41ca147701 100644
--- a/include/asm-s390/mman.h
+++ b/include/asm-s390/mman.h
@@ -44,6 +44,8 @@
#define MADV_WILLNEED 0x3 /* pre-fault pages */
#define MADV_DONTNEED 0x4 /* discard these pages */
#define MADV_REMOVE 0x5 /* remove these pages & resources */
+#define MADV_DONTFORK 0x30 /* dont inherit across fork */
+#define MADV_DOFORK 0x31 /* do inherit across fork */
/* compatibility flags */
#define MAP_ANON MAP_ANONYMOUS
diff --git a/include/asm-sh/mman.h b/include/asm-sh/mman.h
index 693bd55a371..0e08d0573ab 100644
--- a/include/asm-sh/mman.h
+++ b/include/asm-sh/mman.h
@@ -36,6 +36,8 @@
#define MADV_WILLNEED 0x3 /* pre-fault pages */
#define MADV_DONTNEED 0x4 /* discard these pages */
#define MADV_REMOVE 0x5 /* remove these pages & resources */
+#define MADV_DONTFORK 0x30 /* dont inherit across fork */
+#define MADV_DOFORK 0x31 /* do inherit across fork */
/* compatibility flags */
#define MAP_ANON MAP_ANONYMOUS
diff --git a/include/asm-sparc/mman.h b/include/asm-sparc/mman.h
index 98435ad8619..4a298b2be85 100644
--- a/include/asm-sparc/mman.h
+++ b/include/asm-sparc/mman.h
@@ -55,6 +55,8 @@
#define MADV_DONTNEED 0x4 /* discard these pages */
#define MADV_FREE 0x5 /* (Solaris) contents can be freed */
#define MADV_REMOVE 0x6 /* remove these pages & resources */
+#define MADV_DONTFORK 0x30 /* dont inherit across fork */
+#define MADV_DOFORK 0x31 /* do inherit across fork */
/* compatibility flags */
#define MAP_ANON MAP_ANONYMOUS
diff --git a/include/asm-sparc64/mman.h b/include/asm-sparc64/mman.h
index cb4b6156194..d705ec92da8 100644
--- a/include/asm-sparc64/mman.h
+++ b/include/asm-sparc64/mman.h
@@ -55,6 +55,8 @@
#define MADV_DONTNEED 0x4 /* discard these pages */
#define MADV_FREE 0x5 /* (Solaris) contents can be freed */
#define MADV_REMOVE 0x6 /* remove these pages & resources */
+#define MADV_DONTFORK 0x30 /* dont inherit across fork */
+#define MADV_DOFORK 0x31 /* do inherit across fork */
/* compatibility flags */
#define MAP_ANON MAP_ANONYMOUS
diff --git a/include/asm-v850/mman.h b/include/asm-v850/mman.h
index edc79965193..7b851c310e4 100644
--- a/include/asm-v850/mman.h
+++ b/include/asm-v850/mman.h
@@ -33,6 +33,8 @@
#define MADV_WILLNEED 0x3 /* pre-fault pages */
#define MADV_DONTNEED 0x4 /* discard these pages */
#define MADV_REMOVE 0x5 /* remove these pages & resources */
+#define MADV_DONTFORK 0x30 /* dont inherit across fork */
+#define MADV_DOFORK 0x31 /* do inherit across fork */
/* compatibility flags */
#define MAP_ANON MAP_ANONYMOUS
diff --git a/include/asm-x86_64/mman.h b/include/asm-x86_64/mman.h
index d0e97b74f73..b699a38c1c3 100644
--- a/include/asm-x86_64/mman.h
+++ b/include/asm-x86_64/mman.h
@@ -37,6 +37,8 @@
#define MADV_WILLNEED 0x3 /* pre-fault pages */
#define MADV_DONTNEED 0x4 /* discard these pages */
#define MADV_REMOVE 0x5 /* remove these pages & resources */
+#define MADV_DONTFORK 0x30 /* dont inherit across fork */
+#define MADV_DOFORK 0x31 /* do inherit across fork */
/* compatibility flags */
#define MAP_ANON MAP_ANONYMOUS
diff --git a/include/asm-xtensa/mman.h b/include/asm-xtensa/mman.h
index 082a7504925..e2d7afb679c 100644
--- a/include/asm-xtensa/mman.h
+++ b/include/asm-xtensa/mman.h
@@ -73,6 +73,8 @@
#define MADV_WILLNEED 0x3 /* pre-fault pages */
#define MADV_DONTNEED 0x4 /* discard these pages */
#define MADV_REMOVE 0x5 /* remove these pages & resources */
+#define MADV_DONTFORK 0x30 /* dont inherit across fork */
+#define MADV_DOFORK 0x31 /* do inherit across fork */
/* compatibility flags */
#define MAP_ANON MAP_ANONYMOUS