From: Andi Kleen <ak@suse.de>
To: akpm@osdl.org, mingo@elte.hu, torvalds@osdl.org
Cc: linux-kernel@vger.kernel.org
Subject: [PATCH] Use address hint in mmap for search
Date: Wed, 28 Jan 2004 17:33:20 +0100 [thread overview]
Message-ID: <20040128173320.5daeb18a.ak@suse.de> (raw)
When the user gave an address hint in mmap use it as starting point for the
search for !MAP_FIXED. Currently it is only checked directly and when already
used the free area cache is used as starting point. With this change
you can use mmap(4096, ....) to e.g. get the lowest free address in your
address space, which is sometimes useful. For example on x86-64 glibc
wants to preferably allocate thread local data in the first 4GB but use
higher addresses when this is not possible.
This can be a bit more costly in CPU time because it may have to skip over more
VMAs, but gives better semantics for most cases. Most programs pass NULL as hint anyways
so it won't make any difference for them.
I did it for the generic mmap and for x86-64 for now. Also minor white space
fixes for x86-64.
-Andi
diff -u linux-2.6.2rc2-amd64/arch/x86_64/kernel/sys_x86_64.c-o linux-2.6.2rc2-amd64/arch/x86_64/kernel/sys_x86_64.c
--- linux-2.6.2rc2-amd64/arch/x86_64/kernel/sys_x86_64.c-o 2004-01-28 07:50:31.000000000 -0800
+++ linux-2.6.2rc2-amd64/arch/x86_64/kernel/sys_x86_64.c 2004-01-28 08:11:59.291265619 -0800
@@ -105,13 +105,13 @@
return -ENOMEM;
if (addr) {
- addr = PAGE_ALIGN(addr);
+ addr = PAGE_ALIGN(addr);
vma = find_vma(mm, addr);
if (end - len >= addr &&
(!vma || addr + len <= vma->vm_start))
return addr;
- }
- addr = mm->free_area_cache;
+ } else
+ addr = mm->free_area_cache;
if (addr < begin)
addr = begin;
start_addr = addr;
diff -u linux-2.6.2rc2-amd64/mm/mmap.c-o linux-2.6.2rc2-amd64/mm/mmap.c
--- linux-2.6.2rc2-amd64/mm/mmap.c-o 2004-01-28 07:50:41.000000000 -0800
+++ linux-2.6.2rc2-amd64/mm/mmap.c 2004-01-28 08:12:37.009510784 -0800
@@ -743,8 +743,9 @@
if (TASK_SIZE - len >= addr &&
(!vma || addr + len <= vma->vm_start))
return addr;
- }
- start_addr = addr = mm->free_area_cache;
+ } else
+ addr = mm->free_area_cache;
+ start_addr = addr;
full_search:
for (vma = find_vma(mm, addr); ; vma = vma->vm_next) {
reply other threads:[~2004-01-28 16:34 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
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=20040128173320.5daeb18a.ak@suse.de \
--to=ak@suse.de \
--cc=akpm@osdl.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mingo@elte.hu \
--cc=torvalds@osdl.org \
/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