mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: "Miquel van Smoorenburg" <miquels@cistron.nl>
To: linux-kernel@vger.kernel.org
Subject: MAP_PRIVATE that stays private even on external write
Date: 02 Dec 2008 10:06:45 GMT	[thread overview]
Message-ID: <493508b5$0$200$e4fe514c@news.xs4all.nl> (raw)

I have an application that mmaps blocks from a file and then
sends it out over a TCP socket.

The contents of the file may be overwritten while the blocks
are sent out, but there is a very low chance of that.

To prevent this, I can ofcourse just use read() all blocks into
memory in advance, check consistency, and go ahead .. but since
there may be a lot of network connections active this might cost
a lot of memory.

What I am looking for is a MAP_PRIVATE type flag that, when another
process modifies pages of the file (through mmap() or write())
makes sure that my mapping never sees that.

I found out that mmap(MAP_PRIVATE|MAP_POPULATE) does exactly what
I want, but ofcourse it reads in the entire mapping all at once,
which is equivalent to plain read().

There has been talk of a MAP_SNAPSHOT flag before, e.g.
http://lkml.indiana.edu/hypermail/linux/kernel/0407.1/0416.htm

Has anyone ever looked at implementing something like this ?

Mike.

             reply	other threads:[~2008-12-02 10:14 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-12-02 10:06 Miquel van Smoorenburg [this message]
2008-12-02 10:27 ` Peter Zijlstra
2008-12-02 14:34   ` Miquel van Smoorenburg
2008-12-02 15:02     ` Peter Zijlstra

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='493508b5$0$200$e4fe514c@news.xs4all.nl' \
    --to=miquels@cistron.nl \
    --cc=linux-kernel@vger.kernel.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

all inboxes | Powered by JetHome®