aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--mm/madvise.c27
1 files changed, 16 insertions, 11 deletions
diff --git a/mm/madvise.c b/mm/madvise.c
index 944b5e52d812..75b81ad1f98c 100644
--- a/mm/madvise.c
+++ b/mm/madvise.c
@@ -19,6 +19,21 @@ static long madvise_behavior(struct vm_area_struct * vma, unsigned long start,
19{ 19{
20 struct mm_struct * mm = vma->vm_mm; 20 struct mm_struct * mm = vma->vm_mm;
21 int error = 0; 21 int error = 0;
22 int new_flags = vma->vm_flags & ~VM_READHINTMASK;
23
24 switch (behavior) {
25 case MADV_SEQUENTIAL:
26 new_flags |= VM_SEQ_READ;
27 break;
28 case MADV_RANDOM:
29 new_flags |= VM_RAND_READ;
30 break;
31 default:
32 break;
33 }
34
35 if (new_flags == vma->vm_flags)
36 goto out;
22 37
23 if (start != vma->vm_start) { 38 if (start != vma->vm_start) {
24 error = split_vma(mm, vma, start, 1); 39 error = split_vma(mm, vma, start, 1);
@@ -36,17 +51,7 @@ static long madvise_behavior(struct vm_area_struct * vma, unsigned long start,
36 * vm_flags is protected by the mmap_sem held in write mode. 51 * vm_flags is protected by the mmap_sem held in write mode.
37 */ 52 */
38 VM_ClearReadHint(vma); 53 VM_ClearReadHint(vma);
39 54 vma->vm_flags = new_flags;
40 switch (behavior) {
41 case MADV_SEQUENTIAL:
42 vma->vm_flags |= VM_SEQ_READ;
43 break;
44 case MADV_RANDOM:
45 vma->vm_flags |= VM_RAND_READ;
46 break;
47 default:
48 break;
49 }
50 55
51out: 56out:
52 if (error == -ENOMEM) 57 if (error == -ENOMEM)