mailing list of musl libc
 help / color / mirror / code / Atom feed
From: Rich Felker <dalias@aerifal.cx>
To: musl@lists.openwall.com
Cc: Theo de Raadt <deraadt@cvs.openbsd.org>
Subject: Re: Re: Removing sbrk and brk
Date: Tue, 7 Jan 2014 17:00:53 -0500	[thread overview]
Message-ID: <20140107220053.GG24286@brightrain.aerifal.cx> (raw)
In-Reply-To: <20140107160627.GD24286@brightrain.aerifal.cx>

It seems like I've made some incorrect statements in this thread which
the OpenBSD folks weren't too happy about, so now that I'm more clear
on the details I'd like to correct those mistakes for the record...

On Tue, Jan 07, 2014 at 11:06:27AM -0500, Rich Felker wrote:
> On Tue, Jan 07, 2014 at 09:43:26AM +0000, Thorsten Glaser wrote:
> > Rich Felker <dalias <at> aerifal.cx> writes:
> > 
> > > This seems to be optional behavior; using guard pages with all
> > > allocations would blow up memory usage several thousand times and
> > 
> > No, they aren’t accessible, so the kernel (should) never maps them
> > to any real RAM.
> 
> The point is that even a 1-byte allocation (in fairness, that would be
> rounded up to at least 16 bytes) ends up consuming a whole page and
> thus 4k of storage, plus another 4k of virtual address space for the
> guard page. On MIPS it may be even worse (16k pages are required on
> some hardwasre).

This is both incorrect and misleading. I was under the impression that
omalloc had a (non-default) option to use guard pages for all
allocations, even sub-page-size ones. This is not the case, and my
only excuse is that I wrote the above a day or two after last reading
the source and seeing that it had configurable options, but without
taking the time to confirm their nature.

So in reality, guard pages are only used for allocations that take up
at least a whole page, and so from what I can tell now, the maximum
overhead is something like 100% (not 25600%) committed memory and 200%
virtual address space and occurs for allocations just larger than one
page (where you end up needing one extra page for the rest of the
storage, and one guard page).

This is comparable to the overhead for small allocations (less than a
page), which are rounded up to a power-of-two size and thus have a
worst-case overhead of near-100%.

So there's no pathologically huge over-allocation going on, just
moderate overhead, which the OpenBSD folks have claimed (and I believe
them on this) has caught serious bugs in lots of major software.

Hope this clears things up.

Rich


  reply	other threads:[~2014-01-07 22:00 UTC|newest]

Thread overview: 23+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-12-21 23:40 Rich Felker
2013-12-22  2:15 ` Luca Barbato
2013-12-22 17:58   ` Richard Pennington
2013-12-22 18:21     ` Luca Barbato
2013-12-22 18:48 ` Szabolcs Nagy
2013-12-22 21:55   ` Christian Neukirchen
2013-12-23  4:46   ` Rich Felker
2014-01-02 22:03     ` Rich Felker
2014-01-03 11:51       ` Thorsten Glaser
2014-01-03 12:59         ` Daniel Cegiełka
2014-01-03 17:33         ` Rich Felker
2014-01-03 18:19           ` Rich Felker
2014-01-03 19:03             ` Rich Felker
2014-01-06 14:51               ` Thorsten Glaser
2014-01-06 22:40                 ` Rich Felker
2014-01-07  9:43                   ` Thorsten Glaser
2014-01-07 16:06                     ` Rich Felker
2014-01-07 22:00                       ` Rich Felker [this message]
2014-02-21 16:03                         ` Daniel Cegiełka
2014-02-21 16:36                           ` Szabolcs Nagy
2014-02-21 16:47                             ` Daniel Cegiełka
2014-02-21 17:09                               ` Rich Felker
2014-02-21 22:34                                 ` Daniel Cegiełka

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=20140107220053.GG24286@brightrain.aerifal.cx \
    --to=dalias@aerifal.cx \
    --cc=deraadt@cvs.openbsd.org \
    --cc=musl@lists.openwall.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.
Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/musl/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).