Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 164400
b: refs/heads/master
c: 3866ea9
h: refs/heads/master
v: v3
  • Loading branch information
Hugh Dickins authored and Linus Torvalds committed Sep 22, 2009
1 parent 0a32c19 commit 51168b5
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 27 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: 828502d30073036a486d96b1fe051e0f08b6df83
refs/heads/master: 3866ea90d3635ddddcd77ce51087222ac7de85f2
39 changes: 13 additions & 26 deletions trunk/mm/madvise.c
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ 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;
unsigned long new_flags = vma->vm_flags;

switch (behavior) {
case MADV_NORMAL:
Expand All @@ -57,6 +57,10 @@ static long madvise_behavior(struct vm_area_struct * vma,
new_flags |= VM_DONTCOPY;
break;
case MADV_DOFORK:
if (vma->vm_flags & VM_IO) {
error = -EINVAL;
goto out;
}
new_flags &= ~VM_DONTCOPY;
break;
}
Expand Down Expand Up @@ -211,37 +215,16 @@ static long
madvise_vma(struct vm_area_struct *vma, struct vm_area_struct **prev,
unsigned long start, unsigned long end, int behavior)
{
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:
error = madvise_behavior(vma, prev, start, end, behavior);
break;
case MADV_REMOVE:
error = madvise_remove(vma, prev, start, end);
break;

return madvise_remove(vma, prev, start, end);
case MADV_WILLNEED:
error = madvise_willneed(vma, prev, start, end);
break;

return madvise_willneed(vma, prev, start, end);
case MADV_DONTNEED:
error = madvise_dontneed(vma, prev, start, end);
break;

return madvise_dontneed(vma, prev, start, end);
default:
BUG();
break;
return madvise_behavior(vma, prev, start, end, behavior);
}
return error;
}

static int
Expand All @@ -262,6 +245,7 @@ madvise_behavior_valid(int behavior)
return 0;
}
}

/*
* The madvise(2) system call.
*
Expand All @@ -286,6 +270,9 @@ madvise_behavior_valid(int behavior)
* so the kernel can free resources associated with it.
* MADV_REMOVE - the application wants to free up the given range of
* pages and associated backing store.
* MADV_DONTFORK - omit this area from child's address space when forking:
* typically, to avoid COWing pages pinned by get_user_pages().
* MADV_DOFORK - cancel MADV_DONTFORK: no longer omit this area when forking.
*
* return values:
* zero - success
Expand Down

0 comments on commit 51168b5

Please sign in to comment.