Re: can we make anonymous memory non-EXECUTABLE?

Rob Landley (landley@trommello.org)
Wed, 9 Jan 2002 06:32:39 -0500


On Tuesday 08 January 2002 09:52 pm, H. Peter Anvin wrote:
> Rik van Riel wrote:
> > On 8 Jan 2002, H. Peter Anvin wrote:
> >>One way to do this would be to create a newbrk() syscall which takes a
> >>permission argument (for new pages.)
> >
> > ITYM mmap(2)
>
> That's an idea, too. WTF do we actually need brk() for? If it's only
> there to be annoying, let's get rid of it completely and let the C
> library implement it -- stating its assumptions explicitly.
>
> -hpa

There was a fun little panel a few months back at Atlanta Linux Showcase
(which was inexplicably held in california this year, but I'm told they're
patching that in the next release... :)

Apparently, for mallocs below a certain size, glibc uses brk, and above a
certain size, it uses mmap. And the mmap variant is something like 10 times
slower than the brk variant, because of all the soft page faults, fiddling
with page tables, associated cache trashing, etc. (The guy found it trying
to figure out why his app was SLOWER on Linux than on Irix, and eventually
found a glibc variable that could make linux faster: raising glibc's
threshold where it does brk for malloc to infinity.)

Glibc does mmap instead of brk because theoretically brk can leave wasted
memory between fragments, although apparently nobody's ever seen more than
10% waste in a live program, and the speed penality of taking a soft page
fault at access time to muck about with the page tables is a LOT bigger than
10%...

Rob
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/