All of lore.kernel.org
 help / color / mirror / Atom feed
From: Ulrich Drepper <drepper@redhat.com>
To: Hugh Dickins <hugh@veritas.com>
Cc: Linux Kernel <linux-kernel@vger.kernel.org>,
	Linus Torvalds <torvalds@osdl.org>
Subject: Re: mremap() use is racy
Date: Tue, 23 Aug 2005 13:56:54 -0700	[thread overview]
Message-ID: <430B8D96.5080002@redhat.com> (raw)
In-Reply-To: <Pine.LNX.4.61.0508232135480.12189@goblin.wat.veritas.com>

[-- Attachment #1: Type: text/plain, Size: 1305 bytes --]

Hugh Dickins wrote:
> If the app can plan ahead as you're proposing, why doesn't it just
> mmap the maximum it might need, mprotect PROT_NONE the end it doesn't
> need yet, then progressively re-mprotect parts to make them accessible
> as needed?

Because the underlying file isn't larger than the initial mapping.  In
the one case I'm working on now the file can grow over time.  More data
is added at the end but the mapping cannot move in the address space.

Using mmap with a too-large size for the underlying file and then hoping
that future file growth is magically handled when those pages are
accessed is not valid.


> I'm missing what mremap gives you here that mprotect doesn't.  Though
> I do see that it would be nice not to be forced into mremap moving
> all the time, because of other maps blocking you off: nice perhaps
> to know what region of the layout is least likely to be so affected.

Just accept here that moving is not an option.  If remap cannot be used
then a complete new mmap() with adjusted length is needed.  That is
unnecessarily expensive.  It is the reason why there is mremap().  But
mremap() with MREMAP_MAYMOVE is unreliable as it is implemented today.

-- 
➧ Ulrich Drepper ➧ Red Hat, Inc. ➧ 444 Castro St ➧ Mountain View, CA ❖


[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 251 bytes --]

  reply	other threads:[~2005-08-23 20:57 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2005-08-23 19:53 mremap() use is racy Ulrich Drepper
2005-08-23 20:45 ` Hugh Dickins
2005-08-23 20:56   ` Ulrich Drepper [this message]
2005-08-23 21:28     ` Linus Torvalds
2005-08-23 22:08       ` Ulrich Drepper
2005-08-23 23:46         ` Hugh Dickins
2005-08-24  0:08         ` Linus Torvalds
2005-08-24 12:00           ` Hugh Dickins

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=430B8D96.5080002@redhat.com \
    --to=drepper@redhat.com \
    --cc=hugh@veritas.com \
    --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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.