aboutsummaryrefslogtreecommitdiffstats
path: root/mm/madvise.c
diff options
context:
space:
mode:
authorPrasanna Meda <pmeda@akamai.com>2005-06-21 20:14:36 -0400
committerLinus Torvalds <torvalds@ppc970.osdl.org>2005-06-21 21:46:13 -0400
commite798c6e87b64d9fdbd5e9f757b1c033223763d9f (patch)
treeda4cdd7c60acff82d2fcc826cdbae43440a6df44 /mm/madvise.c
parentb15e0905f2b9964fc7426fecab57445e96021b61 (diff)
[PATCH] madvise: do not split the maps
This attempts to avoid splittings when it is not needed, that is when vm_flags are same as new flags. The idea is from the <2.6.11 mlock_fixup and others. This will provide base for the next madvise merging patch. Signed-off-by: Prasanna Meda <pmeda@akamai.com> Signed-off-by: Andrew Morton <akpm@osdl.org> Signed-off-by: Linus Torvalds <torvalds@osdl.org>
Diffstat (limited to 'mm/madvise.c')
-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)