Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 20323
b: refs/heads/master
c: f822566
h: refs/heads/master
i:
  20321: fae9807
  20319: 8571eec
v: v3
  • Loading branch information
Michael S. Tsirkin authored and Linus Torvalds committed Feb 15, 2006
1 parent 15e8abd commit 465766c
Show file tree
Hide file tree
Showing 22 changed files with 58 additions and 5 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: 8861da31e3b3e3df7b05e7b157230de3d486e53b
refs/heads/master: f822566165dd46ff5de9bf895cfa6c51f53bb0c4
2 changes: 2 additions & 0 deletions trunk/include/asm-alpha/mman.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 2 additions & 0 deletions trunk/include/asm-arm/mman.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 2 additions & 0 deletions trunk/include/asm-arm26/mman.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 2 additions & 0 deletions trunk/include/asm-cris/mman.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 2 additions & 0 deletions trunk/include/asm-frv/mman.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 2 additions & 0 deletions trunk/include/asm-h8300/mman.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 2 additions & 0 deletions trunk/include/asm-i386/mman.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 2 additions & 0 deletions trunk/include/asm-ia64/mman.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 2 additions & 0 deletions trunk/include/asm-m32r/mman.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 2 additions & 0 deletions trunk/include/asm-m68k/mman.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 2 additions & 0 deletions trunk/include/asm-mips/mman.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 2 additions & 0 deletions trunk/include/asm-parisc/mman.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 2 additions & 0 deletions trunk/include/asm-powerpc/mman.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 2 additions & 0 deletions trunk/include/asm-s390/mman.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 2 additions & 0 deletions trunk/include/asm-sh/mman.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 2 additions & 0 deletions trunk/include/asm-sparc/mman.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 2 additions & 0 deletions trunk/include/asm-sparc64/mman.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 2 additions & 0 deletions trunk/include/asm-v850/mman.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 2 additions & 0 deletions trunk/include/asm-x86_64/mman.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 2 additions & 0 deletions trunk/include/asm-xtensa/mman.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
21 changes: 17 additions & 4 deletions trunk/mm/madvise.c
Original file line number Diff line number Diff line change
Expand Up @@ -22,16 +22,23 @@ static long madvise_behavior(struct vm_area_struct * vma,
struct mm_struct * mm = vma->vm_mm;
int error = 0;
pgoff_t pgoff;
int new_flags = vma->vm_flags & ~VM_READHINTMASK;
int new_flags = vma->vm_flags;

switch (behavior) {
case MADV_NORMAL:
new_flags = new_flags & ~VM_RAND_READ & ~VM_SEQ_READ;
break;
case MADV_SEQUENTIAL:
new_flags |= VM_SEQ_READ;
new_flags = (new_flags & ~VM_RAND_READ) | VM_SEQ_READ;
break;
case MADV_RANDOM:
new_flags |= VM_RAND_READ;
new_flags = (new_flags & ~VM_SEQ_READ) | VM_RAND_READ;
break;
default:
case MADV_DONTFORK:
new_flags |= VM_DONTCOPY;
break;
case MADV_DOFORK:
new_flags &= ~VM_DONTCOPY;
break;
}

Expand Down Expand Up @@ -177,6 +184,12 @@ madvise_vma(struct vm_area_struct *vma, struct vm_area_struct **prev,
long error;

switch (behavior) {
case MADV_DOFORK:
if (vma->vm_flags & VM_IO) {
error = -EINVAL;
break;
}
case MADV_DONTFORK:
case MADV_NORMAL:
case MADV_SEQUENTIAL:
case MADV_RANDOM:
Expand Down

0 comments on commit 465766c

Please sign in to comment.