diff options
| author | Andrew Morton <akpm@osdl.org> | 2004-05-22 08:10:23 -0700 |
|---|---|---|
| committer | Linus Torvalds <torvalds@ppc970.osdl.org> | 2004-05-22 08:10:23 -0700 |
| commit | 17e8935ff8a2dee9c34add6784d0a073d3e79c66 (patch) | |
| tree | 3f2efd23d44cb90e87d22d96bdcfdd5019928881 /include/linux/mm.h | |
| parent | 8aa3448cabdfca146aa3fd36e852d0209fb2276a (diff) | |
[PATCH] rmap 40 better anon_vma sharing
From: Hugh Dickins <hugh@veritas.com>
anon_vma rmap will always necessarily be more restrictive about vma merging
than before: according to the history of the vmas in an mm, they are liable to
be allocated different anon_vma heads, and from that point on be unmergeable.
Most of the time this doesn't matter at all; but in two cases it may matter.
One case is that mremap refuses (-EFAULT) to span more than a single vma: so
it is conceivable that some app has relied on vma merging prior to mremap in
the past, and will now fail with anon_vma. Conceivable but unlikely, let's
cross that bridge if we come to it: and the right answer would be to extend
mremap, which should not be exporting the kernel's implementation detail of
vma to user interface.
The other case that matters is when a reasonable repetitive sequence of
syscalls and faults ends up with a large number of separate unmergeable vmas,
instead of the single merged vma it could have.
Andrea's mprotect-vma-merging patch fixed some such instances, but left other
plausible cases unmerged. There is no perfect solution, and the harder you
try to allow vmas to be merged, the less efficient anon_vma becomes, in the
extreme there being one to span the whole address space, from which hangs
every private vma; but anonmm rmap is clearly superior to that extreme.
Andrea's principle was that neighbouring vmas which could be mprotected into
mergeable vmas should be allowed to share anon_vma: good insight. His
implementation was to arrange this sharing when trying vma merge, but that
seems to be too early. This patch sticks to the principle, but implements it
in anon_vma_prepare, when handling the first write fault on a private vma:
with better results. The drawback is that this first write fault needs an
extra find_vma_prev (whereas prev was already to hand when implementing
anon_vma sharing at try-to-merge time).
Diffstat (limited to 'include/linux/mm.h')
| -rw-r--r-- | include/linux/mm.h | 1 |
1 files changed, 1 insertions, 0 deletions
diff --git a/include/linux/mm.h b/include/linux/mm.h index ec7c6767aae7..78a8e1604a60 100644 --- a/include/linux/mm.h +++ b/include/linux/mm.h @@ -627,6 +627,7 @@ extern struct vm_area_struct *vma_merge(struct mm_struct *, struct vm_area_struct *prev, unsigned long addr, unsigned long end, unsigned long vm_flags, struct anon_vma *, struct file *, pgoff_t, struct mempolicy *); +extern struct anon_vma *find_mergeable_anon_vma(struct vm_area_struct *); extern int split_vma(struct mm_struct *, struct vm_area_struct *, unsigned long addr, int new_below); extern void insert_vm_struct(struct mm_struct *, struct vm_area_struct *); |
