summaryrefslogtreecommitdiff
path: root/mm/madvise.c
diff options
context:
space:
mode:
authorPrasanna Meda <pmeda@akamai.com>2005-06-21 17:14:36 -0700
committerLinus Torvalds <torvalds@ppc970.osdl.org>2005-06-21 18:46:13 -0700
commite798c6e87b64d9fdbd5e9f757b1c033223763d9f (patch)
treeda4cdd7c60acff82d2fcc826cdbae43440a6df44 /mm/madvise.c
parentb15e0905f2b9964fc7426fecab57445e96021b61 (diff)
downloadlinux-3.10-e798c6e87b64d9fdbd5e9f757b1c033223763d9f.tar.gz
linux-3.10-e798c6e87b64d9fdbd5e9f757b1c033223763d9f.tar.bz2
linux-3.10-e798c6e87b64d9fdbd5e9f757b1c033223763d9f.zip
[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 944b5e52d81..75b81ad1f98 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,
{
struct mm_struct * mm = vma->vm_mm;
int error = 0;
+ int new_flags = vma->vm_flags & ~VM_READHINTMASK;
+
+ switch (behavior) {
+ case MADV_SEQUENTIAL:
+ new_flags |= VM_SEQ_READ;
+ break;
+ case MADV_RANDOM:
+ new_flags |= VM_RAND_READ;
+ break;
+ default:
+ break;
+ }
+
+ if (new_flags == vma->vm_flags)
+ goto out;
if (start != vma->vm_start) {
error = split_vma(mm, vma, start, 1);
@@ -36,17 +51,7 @@ static long madvise_behavior(struct vm_area_struct * vma, unsigned long start,
* vm_flags is protected by the mmap_sem held in write mode.
*/
VM_ClearReadHint(vma);
-
- switch (behavior) {
- case MADV_SEQUENTIAL:
- vma->vm_flags |= VM_SEQ_READ;
- break;
- case MADV_RANDOM:
- vma->vm_flags |= VM_RAND_READ;
- break;
- default:
- break;
- }
+ vma->vm_flags = new_flags;
out:
if (error == -ENOMEM)