aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-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
-rw-r--r--mm/madvise.c21
21 files changed, 57 insertions, 4 deletions
diff --git a/include/asm-alpha/mman.h b/include/asm-alpha/mman.h
index f6439532a262..a21515c16a43 100644
--- a/include/asm-alpha/mman.h
+++ b/include/asm-alpha/mman.h
@@ -43,6 +43,8 @@
43#define MADV_SPACEAVAIL 5 /* ensure resources are available */ 43#define MADV_SPACEAVAIL 5 /* ensure resources are available */
44#define MADV_DONTNEED 6 /* don't need these pages */ 44#define MADV_DONTNEED 6 /* don't need these pages */
45#define MADV_REMOVE 7 /* remove these pages & resources */ 45#define MADV_REMOVE 7 /* remove these pages & resources */
46#define MADV_DONTFORK 0x30 /* dont inherit across fork */
47#define MADV_DOFORK 0x31 /* do inherit across fork */
46 48
47/* compatibility flags */ 49/* compatibility flags */
48#define MAP_ANON MAP_ANONYMOUS 50#define MAP_ANON MAP_ANONYMOUS
diff --git a/include/asm-arm/mman.h b/include/asm-arm/mman.h
index f0bebca2ac21..693ed859e632 100644
--- a/include/asm-arm/mman.h
+++ b/include/asm-arm/mman.h
@@ -36,6 +36,8 @@
36#define MADV_WILLNEED 0x3 /* pre-fault pages */ 36#define MADV_WILLNEED 0x3 /* pre-fault pages */
37#define MADV_DONTNEED 0x4 /* discard these pages */ 37#define MADV_DONTNEED 0x4 /* discard these pages */
38#define MADV_REMOVE 0x5 /* remove these pages & resources */ 38#define MADV_REMOVE 0x5 /* remove these pages & resources */
39#define MADV_DONTFORK 0x30 /* dont inherit across fork */
40#define MADV_DOFORK 0x31 /* do inherit across fork */
39 41
40/* compatibility flags */ 42/* compatibility flags */
41#define MAP_ANON MAP_ANONYMOUS 43#define MAP_ANON MAP_ANONYMOUS
diff --git a/include/asm-arm26/mman.h b/include/asm-arm26/mman.h
index 0ed7780541fa..2096c50df888 100644
--- a/include/asm-arm26/mman.h
+++ b/include/asm-arm26/mman.h
@@ -36,6 +36,8 @@
36#define MADV_WILLNEED 0x3 /* pre-fault pages */ 36#define MADV_WILLNEED 0x3 /* pre-fault pages */
37#define MADV_DONTNEED 0x4 /* discard these pages */ 37#define MADV_DONTNEED 0x4 /* discard these pages */
38#define MADV_REMOVE 0x5 /* remove these pages & resources */ 38#define MADV_REMOVE 0x5 /* remove these pages & resources */
39#define MADV_DONTFORK 0x30 /* dont inherit across fork */
40#define MADV_DOFORK 0x31 /* do inherit across fork */
39 41
40/* compatibility flags */ 42/* compatibility flags */
41#define MAP_ANON MAP_ANONYMOUS 43#define MAP_ANON MAP_ANONYMOUS
diff --git a/include/asm-cris/mman.h b/include/asm-cris/mman.h
index 5a382b8bf3f7..deddfb239ff5 100644
--- a/include/asm-cris/mman.h
+++ b/include/asm-cris/mman.h
@@ -38,6 +38,8 @@
38#define MADV_WILLNEED 0x3 /* pre-fault pages */ 38#define MADV_WILLNEED 0x3 /* pre-fault pages */
39#define MADV_DONTNEED 0x4 /* discard these pages */ 39#define MADV_DONTNEED 0x4 /* discard these pages */
40#define MADV_REMOVE 0x5 /* remove these pages & resources */ 40#define MADV_REMOVE 0x5 /* remove these pages & resources */
41#define MADV_DONTFORK 0x30 /* dont inherit across fork */
42#define MADV_DOFORK 0x31 /* do inherit across fork */
41 43
42/* compatibility flags */ 44/* compatibility flags */
43#define MAP_ANON MAP_ANONYMOUS 45#define MAP_ANON MAP_ANONYMOUS
diff --git a/include/asm-frv/mman.h b/include/asm-frv/mman.h
index 8af4a41c255e..d3bca306da82 100644
--- a/include/asm-frv/mman.h
+++ b/include/asm-frv/mman.h
@@ -36,6 +36,8 @@
36#define MADV_WILLNEED 0x3 /* pre-fault pages */ 36#define MADV_WILLNEED 0x3 /* pre-fault pages */
37#define MADV_DONTNEED 0x4 /* discard these pages */ 37#define MADV_DONTNEED 0x4 /* discard these pages */
38#define MADV_REMOVE 0x5 /* remove these pages & resources */ 38#define MADV_REMOVE 0x5 /* remove these pages & resources */
39#define MADV_DONTFORK 0x30 /* dont inherit across fork */
40#define MADV_DOFORK 0x31 /* do inherit across fork */
39 41
40/* compatibility flags */ 42/* compatibility flags */
41#define MAP_ANON MAP_ANONYMOUS 43#define MAP_ANON MAP_ANONYMOUS
diff --git a/include/asm-h8300/mman.h b/include/asm-h8300/mman.h
index 744a8fb485c2..ac0346f7d11d 100644
--- a/include/asm-h8300/mman.h
+++ b/include/asm-h8300/mman.h
@@ -36,6 +36,8 @@
36#define MADV_WILLNEED 0x3 /* pre-fault pages */ 36#define MADV_WILLNEED 0x3 /* pre-fault pages */
37#define MADV_DONTNEED 0x4 /* discard these pages */ 37#define MADV_DONTNEED 0x4 /* discard these pages */
38#define MADV_REMOVE 0x5 /* remove these pages & resources */ 38#define MADV_REMOVE 0x5 /* remove these pages & resources */
39#define MADV_DONTFORK 0x30 /* dont inherit across fork */
40#define MADV_DOFORK 0x31 /* do inherit across fork */
39 41
40/* compatibility flags */ 42/* compatibility flags */
41#define MAP_ANON MAP_ANONYMOUS 43#define MAP_ANON MAP_ANONYMOUS
diff --git a/include/asm-i386/mman.h b/include/asm-i386/mman.h
index ba4941e6f643..ab2339a1d807 100644
--- a/include/asm-i386/mman.h
+++ b/include/asm-i386/mman.h
@@ -36,6 +36,8 @@
36#define MADV_WILLNEED 0x3 /* pre-fault pages */ 36#define MADV_WILLNEED 0x3 /* pre-fault pages */
37#define MADV_DONTNEED 0x4 /* discard these pages */ 37#define MADV_DONTNEED 0x4 /* discard these pages */
38#define MADV_REMOVE 0x5 /* remove these pages & resources */ 38#define MADV_REMOVE 0x5 /* remove these pages & resources */
39#define MADV_DONTFORK 0x30 /* dont inherit across fork */
40#define MADV_DOFORK 0x31 /* do inherit across fork */
39 41
40/* compatibility flags */ 42/* compatibility flags */
41#define MAP_ANON MAP_ANONYMOUS 43#define MAP_ANON MAP_ANONYMOUS
diff --git a/include/asm-ia64/mman.h b/include/asm-ia64/mman.h
index 828beb24a20e..357ebb780cc0 100644
--- a/include/asm-ia64/mman.h
+++ b/include/asm-ia64/mman.h
@@ -44,6 +44,8 @@
44#define MADV_WILLNEED 0x3 /* pre-fault pages */ 44#define MADV_WILLNEED 0x3 /* pre-fault pages */
45#define MADV_DONTNEED 0x4 /* discard these pages */ 45#define MADV_DONTNEED 0x4 /* discard these pages */
46#define MADV_REMOVE 0x5 /* remove these pages & resources */ 46#define MADV_REMOVE 0x5 /* remove these pages & resources */
47#define MADV_DONTFORK 0x30 /* dont inherit across fork */
48#define MADV_DOFORK 0x31 /* do inherit across fork */
47 49
48/* compatibility flags */ 50/* compatibility flags */
49#define MAP_ANON MAP_ANONYMOUS 51#define MAP_ANON MAP_ANONYMOUS
diff --git a/include/asm-m32r/mman.h b/include/asm-m32r/mman.h
index 12e29747bc84..6b02fe3fcff2 100644
--- a/include/asm-m32r/mman.h
+++ b/include/asm-m32r/mman.h
@@ -38,6 +38,8 @@
38#define MADV_WILLNEED 0x3 /* pre-fault pages */ 38#define MADV_WILLNEED 0x3 /* pre-fault pages */
39#define MADV_DONTNEED 0x4 /* discard these pages */ 39#define MADV_DONTNEED 0x4 /* discard these pages */
40#define MADV_REMOVE 0x5 /* remove these pages & resources */ 40#define MADV_REMOVE 0x5 /* remove these pages & resources */
41#define MADV_DONTFORK 0x30 /* dont inherit across fork */
42#define MADV_DOFORK 0x31 /* do inherit across fork */
41 43
42/* compatibility flags */ 44/* compatibility flags */
43#define MAP_ANON MAP_ANONYMOUS 45#define MAP_ANON MAP_ANONYMOUS
diff --git a/include/asm-m68k/mman.h b/include/asm-m68k/mman.h
index ea262ab88b3b..efd12bc4ccb7 100644
--- a/include/asm-m68k/mman.h
+++ b/include/asm-m68k/mman.h
@@ -36,6 +36,8 @@
36#define MADV_WILLNEED 0x3 /* pre-fault pages */ 36#define MADV_WILLNEED 0x3 /* pre-fault pages */
37#define MADV_DONTNEED 0x4 /* discard these pages */ 37#define MADV_DONTNEED 0x4 /* discard these pages */
38#define MADV_REMOVE 0x5 /* remove these pages & resources */ 38#define MADV_REMOVE 0x5 /* remove these pages & resources */
39#define MADV_DONTFORK 0x30 /* dont inherit across fork */
40#define MADV_DOFORK 0x31 /* do inherit across fork */
39 41
40/* compatibility flags */ 42/* compatibility flags */
41#define MAP_ANON MAP_ANONYMOUS 43#define MAP_ANON MAP_ANONYMOUS
diff --git a/include/asm-mips/mman.h b/include/asm-mips/mman.h
index dd17c8bd62a1..6d01e26830fa 100644
--- a/include/asm-mips/mman.h
+++ b/include/asm-mips/mman.h
@@ -66,6 +66,8 @@
66#define MADV_WILLNEED 0x3 /* pre-fault pages */ 66#define MADV_WILLNEED 0x3 /* pre-fault pages */
67#define MADV_DONTNEED 0x4 /* discard these pages */ 67#define MADV_DONTNEED 0x4 /* discard these pages */
68#define MADV_REMOVE 0x5 /* remove these pages & resources */ 68#define MADV_REMOVE 0x5 /* remove these pages & resources */
69#define MADV_DONTFORK 0x30 /* dont inherit across fork */
70#define MADV_DOFORK 0x31 /* do inherit across fork */
69 71
70/* compatibility flags */ 72/* compatibility flags */
71#define MAP_ANON MAP_ANONYMOUS 73#define MAP_ANON MAP_ANONYMOUS
diff --git a/include/asm-parisc/mman.h b/include/asm-parisc/mman.h
index 736b0abcac05..a381cf5c8f55 100644
--- a/include/asm-parisc/mman.h
+++ b/include/asm-parisc/mman.h
@@ -49,6 +49,8 @@
49#define MADV_4M_PAGES 22 /* Use 4 Megabyte pages */ 49#define MADV_4M_PAGES 22 /* Use 4 Megabyte pages */
50#define MADV_16M_PAGES 24 /* Use 16 Megabyte pages */ 50#define MADV_16M_PAGES 24 /* Use 16 Megabyte pages */
51#define MADV_64M_PAGES 26 /* Use 64 Megabyte pages */ 51#define MADV_64M_PAGES 26 /* Use 64 Megabyte pages */
52#define MADV_DONTFORK 0x30 /* dont inherit across fork */
53#define MADV_DOFORK 0x31 /* do inherit across fork */
52 54
53/* compatibility flags */ 55/* compatibility flags */
54#define MAP_ANON MAP_ANONYMOUS 56#define MAP_ANON MAP_ANONYMOUS
diff --git a/include/asm-powerpc/mman.h b/include/asm-powerpc/mman.h
index a2e34c21b44f..fcff25d13f13 100644
--- a/include/asm-powerpc/mman.h
+++ b/include/asm-powerpc/mman.h
@@ -45,6 +45,8 @@
45#define MADV_WILLNEED 0x3 /* pre-fault pages */ 45#define MADV_WILLNEED 0x3 /* pre-fault pages */
46#define MADV_DONTNEED 0x4 /* discard these pages */ 46#define MADV_DONTNEED 0x4 /* discard these pages */
47#define MADV_REMOVE 0x5 /* remove these pages & resources */ 47#define MADV_REMOVE 0x5 /* remove these pages & resources */
48#define MADV_DONTFORK 0x30 /* dont inherit across fork */
49#define MADV_DOFORK 0x31 /* do inherit across fork */
48 50
49/* compatibility flags */ 51/* compatibility flags */
50#define MAP_ANON MAP_ANONYMOUS 52#define MAP_ANON MAP_ANONYMOUS
diff --git a/include/asm-s390/mman.h b/include/asm-s390/mman.h
index c8d5409b5d56..d41ca1477010 100644
--- a/include/asm-s390/mman.h
+++ b/include/asm-s390/mman.h
@@ -44,6 +44,8 @@
44#define MADV_WILLNEED 0x3 /* pre-fault pages */ 44#define MADV_WILLNEED 0x3 /* pre-fault pages */
45#define MADV_DONTNEED 0x4 /* discard these pages */ 45#define MADV_DONTNEED 0x4 /* discard these pages */
46#define MADV_REMOVE 0x5 /* remove these pages & resources */ 46#define MADV_REMOVE 0x5 /* remove these pages & resources */
47#define MADV_DONTFORK 0x30 /* dont inherit across fork */
48#define MADV_DOFORK 0x31 /* do inherit across fork */
47 49
48/* compatibility flags */ 50/* compatibility flags */
49#define MAP_ANON MAP_ANONYMOUS 51#define MAP_ANON MAP_ANONYMOUS
diff --git a/include/asm-sh/mman.h b/include/asm-sh/mman.h
index 693bd55a3710..0e08d0573abc 100644
--- a/include/asm-sh/mman.h
+++ b/include/asm-sh/mman.h
@@ -36,6 +36,8 @@
36#define MADV_WILLNEED 0x3 /* pre-fault pages */ 36#define MADV_WILLNEED 0x3 /* pre-fault pages */
37#define MADV_DONTNEED 0x4 /* discard these pages */ 37#define MADV_DONTNEED 0x4 /* discard these pages */
38#define MADV_REMOVE 0x5 /* remove these pages & resources */ 38#define MADV_REMOVE 0x5 /* remove these pages & resources */
39#define MADV_DONTFORK 0x30 /* dont inherit across fork */
40#define MADV_DOFORK 0x31 /* do inherit across fork */
39 41
40/* compatibility flags */ 42/* compatibility flags */
41#define MAP_ANON MAP_ANONYMOUS 43#define MAP_ANON MAP_ANONYMOUS
diff --git a/include/asm-sparc/mman.h b/include/asm-sparc/mman.h
index 98435ad8619e..4a298b2be859 100644
--- a/include/asm-sparc/mman.h
+++ b/include/asm-sparc/mman.h
@@ -55,6 +55,8 @@
55#define MADV_DONTNEED 0x4 /* discard these pages */ 55#define MADV_DONTNEED 0x4 /* discard these pages */
56#define MADV_FREE 0x5 /* (Solaris) contents can be freed */ 56#define MADV_FREE 0x5 /* (Solaris) contents can be freed */
57#define MADV_REMOVE 0x6 /* remove these pages & resources */ 57#define MADV_REMOVE 0x6 /* remove these pages & resources */
58#define MADV_DONTFORK 0x30 /* dont inherit across fork */
59#define MADV_DOFORK 0x31 /* do inherit across fork */
58 60
59/* compatibility flags */ 61/* compatibility flags */
60#define MAP_ANON MAP_ANONYMOUS 62#define MAP_ANON MAP_ANONYMOUS
diff --git a/include/asm-sparc64/mman.h b/include/asm-sparc64/mman.h
index cb4b6156194d..d705ec92da8b 100644
--- a/include/asm-sparc64/mman.h
+++ b/include/asm-sparc64/mman.h
@@ -55,6 +55,8 @@
55#define MADV_DONTNEED 0x4 /* discard these pages */ 55#define MADV_DONTNEED 0x4 /* discard these pages */
56#define MADV_FREE 0x5 /* (Solaris) contents can be freed */ 56#define MADV_FREE 0x5 /* (Solaris) contents can be freed */
57#define MADV_REMOVE 0x6 /* remove these pages & resources */ 57#define MADV_REMOVE 0x6 /* remove these pages & resources */
58#define MADV_DONTFORK 0x30 /* dont inherit across fork */
59#define MADV_DOFORK 0x31 /* do inherit across fork */
58 60
59/* compatibility flags */ 61/* compatibility flags */
60#define MAP_ANON MAP_ANONYMOUS 62#define MAP_ANON MAP_ANONYMOUS
diff --git a/include/asm-v850/mman.h b/include/asm-v850/mman.h
index edc79965193a..7b851c310e41 100644
--- a/include/asm-v850/mman.h
+++ b/include/asm-v850/mman.h
@@ -33,6 +33,8 @@
33#define MADV_WILLNEED 0x3 /* pre-fault pages */ 33#define MADV_WILLNEED 0x3 /* pre-fault pages */
34#define MADV_DONTNEED 0x4 /* discard these pages */ 34#define MADV_DONTNEED 0x4 /* discard these pages */
35#define MADV_REMOVE 0x5 /* remove these pages & resources */ 35#define MADV_REMOVE 0x5 /* remove these pages & resources */
36#define MADV_DONTFORK 0x30 /* dont inherit across fork */
37#define MADV_DOFORK 0x31 /* do inherit across fork */
36 38
37/* compatibility flags */ 39/* compatibility flags */
38#define MAP_ANON MAP_ANONYMOUS 40#define MAP_ANON MAP_ANONYMOUS
diff --git a/include/asm-x86_64/mman.h b/include/asm-x86_64/mman.h
index d0e97b74f735..b699a38c1c3c 100644
--- a/include/asm-x86_64/mman.h
+++ b/include/asm-x86_64/mman.h
@@ -37,6 +37,8 @@
37#define MADV_WILLNEED 0x3 /* pre-fault pages */ 37#define MADV_WILLNEED 0x3 /* pre-fault pages */
38#define MADV_DONTNEED 0x4 /* discard these pages */ 38#define MADV_DONTNEED 0x4 /* discard these pages */
39#define MADV_REMOVE 0x5 /* remove these pages & resources */ 39#define MADV_REMOVE 0x5 /* remove these pages & resources */
40#define MADV_DONTFORK 0x30 /* dont inherit across fork */
41#define MADV_DOFORK 0x31 /* do inherit across fork */
40 42
41/* compatibility flags */ 43/* compatibility flags */
42#define MAP_ANON MAP_ANONYMOUS 44#define MAP_ANON MAP_ANONYMOUS
diff --git a/include/asm-xtensa/mman.h b/include/asm-xtensa/mman.h
index 082a7504925e..e2d7afb679c8 100644
--- a/include/asm-xtensa/mman.h
+++ b/include/asm-xtensa/mman.h
@@ -73,6 +73,8 @@
73#define MADV_WILLNEED 0x3 /* pre-fault pages */ 73#define MADV_WILLNEED 0x3 /* pre-fault pages */
74#define MADV_DONTNEED 0x4 /* discard these pages */ 74#define MADV_DONTNEED 0x4 /* discard these pages */
75#define MADV_REMOVE 0x5 /* remove these pages & resources */ 75#define MADV_REMOVE 0x5 /* remove these pages & resources */
76#define MADV_DONTFORK 0x30 /* dont inherit across fork */
77#define MADV_DOFORK 0x31 /* do inherit across fork */
76 78
77/* compatibility flags */ 79/* compatibility flags */
78#define MAP_ANON MAP_ANONYMOUS 80#define MAP_ANON MAP_ANONYMOUS
diff --git a/mm/madvise.c b/mm/madvise.c
index ae0ae3ea299a..af3d573b0141 100644
--- a/mm/madvise.c
+++ b/mm/madvise.c
@@ -22,16 +22,23 @@ static long madvise_behavior(struct vm_area_struct * vma,
22 struct mm_struct * mm = vma->vm_mm; 22 struct mm_struct * mm = vma->vm_mm;
23 int error = 0; 23 int error = 0;
24 pgoff_t pgoff; 24 pgoff_t pgoff;
25 int new_flags = vma->vm_flags & ~VM_READHINTMASK; 25 int new_flags = vma->vm_flags;
26 26
27 switch (behavior) { 27 switch (behavior) {
28 case MADV_NORMAL:
29 new_flags = new_flags & ~VM_RAND_READ & ~VM_SEQ_READ;
30 break;
28 case MADV_SEQUENTIAL: 31 case MADV_SEQUENTIAL:
29 new_flags |= VM_SEQ_READ; 32 new_flags = (new_flags & ~VM_RAND_READ) | VM_SEQ_READ;
30 break; 33 break;
31 case MADV_RANDOM: 34 case MADV_RANDOM:
32 new_flags |= VM_RAND_READ; 35 new_flags = (new_flags & ~VM_SEQ_READ) | VM_RAND_READ;
33 break; 36 break;
34 default: 37 case MADV_DONTFORK:
38 new_flags |= VM_DONTCOPY;
39 break;
40 case MADV_DOFORK:
41 new_flags &= ~VM_DONTCOPY;
35 break; 42 break;
36 } 43 }
37 44
@@ -177,6 +184,12 @@ madvise_vma(struct vm_area_struct *vma, struct vm_area_struct **prev,
177 long error; 184 long error;
178 185
179 switch (behavior) { 186 switch (behavior) {
187 case MADV_DOFORK:
188 if (vma->vm_flags & VM_IO) {
189 error = -EINVAL;
190 break;
191 }
192 case MADV_DONTFORK:
180 case MADV_NORMAL: 193 case MADV_NORMAL:
181 case MADV_SEQUENTIAL: 194 case MADV_SEQUENTIAL:
182 case MADV_RANDOM: 195 case MADV_RANDOM: