linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
From: Florian Weimer <fw@deneb.enyo.de>
To: linux-mm@kvack.org
Subject: How to reserve address space without actual backing store
Date: Sun, 24 Feb 2008 13:05:34 +0100	[thread overview]
Message-ID: <87k5kublv5.fsf@mid.deneb.enyo.de> (raw)

This is more or less a userspace API question, but the documentation
I've found in manpages does not match actual kernel behavior, so I'm
asking here.

With vm.overcommit_memory and address space randomization, a lot of
applications (particularly those who use certain types of garbage
collectors) need a way to reserve a chunk of the address space, without
actually counting towards the vm.overcommit_memory limit.  Typically,
you want to allocate all the heap in a single, continuous range.  As the
heap usage increases, you gradually allocate backing store from the
kernel.  (Without address space randomization, you can use some
heuristics to avoid DSO space etc. and use MAP_FIXED to grow the heap as
needed, I suppose.)

MAP_NORESERVE does not work for this purpose because memory allocated
that way still counts as comitted.  What seems to work is to reserve
address space with PROT_NONE, and later use mprotected to get backing
store.  My question is if this is an accident, or if this approach is
guaranteed to work in the future.

(mprotect to subsequently add PROT_EXEC has been broken on some
architectures unless you take special measures, so I guess that this is
genuine concern.)

--
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/ .
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>

                 reply	other threads:[~2008-02-24 12:05 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=87k5kublv5.fsf@mid.deneb.enyo.de \
    --to=fw@deneb.enyo.de \
    --cc=linux-mm@kvack.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;
as well as URLs for NNTP newsgroup(s).