From: Ben LaHaise <bcrl@redhat.com>
To: Linus Torvalds <torvalds@transmeta.com>
Cc: alan@redhat.com, linux-mm@kvack.org
Subject: [PATCH] mremap merging.
Date: Wed, 15 Aug 2001 15:44:16 -0400 (EDT) [thread overview]
Message-ID: <Pine.LNX.4.33.0108151539240.28240-100000@touchme.toronto.redhat.com> (raw)
In-Reply-To: <Pine.LNX.4.33.0108151036350.2407-100000@penguin.transmeta.com>
This one should actually be correct -- it just looks big as it flattens
the code in do_mremap somewhat. There's a test program at
http://www.kvack.org/~blah/mremap_test5.c that will trigger the "merged!"
printk and show the results from /proc/<pid>/maps. Mozilla isn't
triggering it, though, so I'm looking at mprotect now.
Also, mmap/mremap are failing to merge some segments as the BSS of a
program is marked with the executable bit. At least on x86, X on a page
does nothing, so I'm wondering if we should strip that out from vm_flags
as I was originally suspecting? At least on my machine it seems to be hit
occasionally.
-ben
diff -ur /md0/kernels/2.4/v2.4.8-ac5/mm/mremap.c work-v2.4.8-ac5/mm/mremap.c
--- /md0/kernels/2.4/v2.4.8-ac5/mm/mremap.c Wed Aug 15 12:57:40 2001
+++ work-v2.4.8-ac5/mm/mremap.c Wed Aug 15 14:59:02 2001
@@ -132,10 +132,23 @@
unsigned long new_addr)
{
struct vm_area_struct * new_vma;
+ int allocated_vma = 0;
- new_vma = kmem_cache_alloc(vm_area_cachep, SLAB_KERNEL);
- if (new_vma) {
- if (!move_page_tables(current->mm, new_addr, addr, old_len)) {
+ /* First, check if we can merge a mapping. -ben */
+ new_vma = find_vma(current->mm, new_addr-1);
+ if (new_vma && new_vma->vm_end == new_addr && !new_vma->vm_file &&
+ new_vma->vm_flags == vma->vm_flags) {
+ new_vma->vm_end = new_addr + new_len;
+printk("merged!\n");
+ } else {
+ new_vma = kmem_cache_alloc(vm_area_cachep, SLAB_KERNEL);
+ if (!new_vma)
+ goto no_mem;
+ allocated_vma = 1;
+ }
+
+ if (!move_page_tables(current->mm, new_addr, addr, old_len)) {
+ if (allocated_vma) {
*new_vma = *vma;
new_vma->vm_start = new_addr;
new_vma->vm_end = new_addr+new_len;
@@ -146,17 +159,20 @@
if (new_vma->vm_ops && new_vma->vm_ops->open)
new_vma->vm_ops->open(new_vma);
insert_vm_struct(current->mm, new_vma);
- do_munmap(current->mm, addr, old_len);
- current->mm->total_vm += new_len >> PAGE_SHIFT;
- if (new_vma->vm_flags & VM_LOCKED) {
- current->mm->locked_vm += new_len >> PAGE_SHIFT;
- make_pages_present(new_vma->vm_start,
- new_vma->vm_end);
- }
- return new_addr;
}
- kmem_cache_free(vm_area_cachep, new_vma);
+ do_munmap(current->mm, addr, old_len);
+ current->mm->total_vm += new_len >> PAGE_SHIFT;
+ if (new_vma->vm_flags & VM_LOCKED) {
+ current->mm->locked_vm += new_len >> PAGE_SHIFT;
+ make_pages_present(new_vma->vm_start,
+ new_vma->vm_end);
+ }
+ return new_addr;
}
+ if (allocated_vma)
+ kmem_cache_free(vm_area_cachep, new_vma);
+
+no_mem:
return -ENOMEM;
}
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org. For more info on Linux MM,
see: http://www.linux-mm.org/
next prev parent reply other threads:[~2001-08-15 19:44 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2001-08-15 17:35 [PATCH] Ben LaHaise
2001-08-15 17:40 ` [PATCH] Linus Torvalds
2001-08-15 17:53 ` [PATCH] Ben LaHaise
2001-08-15 18:26 ` [PATCH] Daniel Phillips
2001-08-15 19:44 ` Ben LaHaise [this message]
2001-08-15 22:41 ` [PATCH] mmap tail merging Ben LaHaise
2001-08-15 23:04 ` Rik van Riel
2001-08-16 3:26 ` Ben LaHaise
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=Pine.LNX.4.33.0108151539240.28240-100000@touchme.toronto.redhat.com \
--to=bcrl@redhat.com \
--cc=alan@redhat.com \
--cc=linux-mm@kvack.org \
--cc=torvalds@transmeta.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox