Attempt to merge VMRs during mprotect
authorBarret Rhoden <brho@cs.berkeley.edu>
Fri, 29 Apr 2016 18:26:57 +0000 (14:26 -0400)
committerBarret Rhoden <brho@cs.berkeley.edu>
Mon, 2 May 2016 21:11:15 +0000 (17:11 -0400)
If you do a bunch of mprotects on parts of an mmaped region with different
settings, you'd break it up.  But if we mprotected to make a collection of
regions the same, then we wouldn't merge the VMRs back.

You'd notice this with vmrunkernel - we'd have O(100) VMRs, many of the
adjacent VMRs had the same settings.  Now those ones are merged.

Signed-off-by: Barret Rhoden <brho@cs.berkeley.edu>
kern/src/mm.c

index 8abeef8..bf6ed35 100644 (file)
@@ -795,6 +795,7 @@ int __do_mprotect(struct proc *p, uintptr_t addr, size_t len, int prot)
                        }
                }
                spin_unlock(&p->pte_lock);
                        }
                }
                spin_unlock(&p->pte_lock);
+               vmr = merge_me(vmr);
                next_vmr = TAILQ_NEXT(vmr, vm_link);
                vmr = next_vmr;
        }
                next_vmr = TAILQ_NEXT(vmr, vm_link);
                vmr = next_vmr;
        }