From: Ingo Molnar <mingo@elte.hu>
To: Andi Kleen <ak@suse.de>
Cc: Jamie Lokier <jamie@shareable.org>,
torvalds@osdl.org, benh@kernel.crashing.org,
linux-kernel@vger.kernel.org, akpm@osdl.org,
Ulrich Drepper <drepper@redhat.com>
Subject: Re: [BUG] get_unmapped_area() change -> non booting machine
Date: Thu, 12 Feb 2004 11:04:46 +0100 [thread overview]
Message-ID: <20040212100446.GA2862@elte.hu> (raw)
In-Reply-To: <20040213002358.1dd5c93a.ak@suse.de>
* Andi Kleen <ak@suse.de> wrote:
> > The real question is - why does malloc() break? I'd expect malloc()
> > to use MAP_ANON these days, when brk() fails. But it seems not.
>
> Yep, that's the real bug.
i've pasted the relevant glibc malloc code below - it does use mmap() as
a fallback.
why in this particular case it failed i dont know - i believe some
_minimal_ brk space is supposed to be available though, so if you break
mmap() to fill in the brk space then that might break glibc assumptions.
Ingo
if (size > 0)
brk = (char*)(MORECORE(size));
if (brk != (char*)(MORECORE_FAILURE)) {
/* Call the `morecore' hook if necessary. */
if (__after_morecore_hook)
(*__after_morecore_hook) ();
} else {
/*
If have mmap, try using it as a backup when MORECORE fails or
cannot be used. This is worth doing on systems that have "holes" in
address space, so sbrk cannot extend to give contiguous space, but
space is available elsewhere. Note that we ignore mmap max count
and threshold limits, since the space will not be used as a
segregated mmap region.
*/
#if HAVE_MMAP
/* Cannot merge with old top, so add its size back in */
if (contiguous(av))
size = (size + old_size + pagemask) & ~pagemask;
/* If we are relying on mmap as backup, then use larger units */
if ((unsigned long)(size) < (unsigned long)(MMAP_AS_MORECORE_SIZE))
size = MMAP_AS_MORECORE_SIZE;
/* Don't try if size wraps around 0 */
if ((unsigned long)(size) > (unsigned long)(nb)) {
char *mbrk = (char*)(MMAP(0, size, PROT_READ|PROT_WRITE, MAP_PRIVATE));
if (mbrk != MAP_FAILED) {
/* We do not need, and cannot use, another sbrk call to find end */
brk = mbrk;
snd_brk = brk + size;
/*
Record that we no longer have a contiguous sbrk region.
After the first time mmap is used as backup, we do not
ever rely on contiguous space since this could incorrectly
bridge regions.
*/
set_noncontiguous(av);
}
}
#endif
}
next prev parent reply other threads:[~2004-02-12 10:04 UTC|newest]
Thread overview: 22+ messages / expand[flat|nested] mbox.gz Atom feed top
2004-02-10 3:47 [BUG] get_unmapped_area() change -> non booting machine Benjamin Herrenschmidt
2004-02-10 16:25 ` Linus Torvalds
2004-02-10 17:37 ` Jamie Lokier
2004-02-10 22:25 ` Benjamin Herrenschmidt
2004-02-12 23:23 ` Andi Kleen
2004-02-12 10:04 ` Ingo Molnar [this message]
2004-02-12 16:36 ` Linus Torvalds
2004-02-12 17:02 ` Dave McCracken
2004-02-12 17:17 ` Linus Torvalds
2004-02-12 17:31 ` Dave McCracken
2004-02-12 18:19 ` Linus Torvalds
2004-02-12 18:25 ` Dave McCracken
2004-02-12 20:49 ` Benjamin Herrenschmidt
2004-02-13 3:26 ` Jamie Lokier
2004-02-15 5:25 ` Andi Kleen
2004-02-13 18:33 ` Martin J. Bligh
2004-02-13 1:52 ` Andi Kleen
2004-02-13 6:26 ` H. Peter Anvin
2004-02-10 22:17 ` Benjamin Herrenschmidt
2004-02-14 8:34 ` Andi Kleen
2004-02-11 23:23 ` Andi Kleen
2004-02-10 7:48 ` Benjamin Herrenschmidt
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=20040212100446.GA2862@elte.hu \
--to=mingo@elte.hu \
--cc=ak@suse.de \
--cc=akpm@osdl.org \
--cc=benh@kernel.crashing.org \
--cc=drepper@redhat.com \
--cc=jamie@shareable.org \
--cc=linux-kernel@vger.kernel.org \
--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