From: Jamie Lokier <jamie@shareable.org>
To: linux-kernel@vger.kernel.org
Subject: msync() needed before munmap() when writing to shared mapping?
Date: Fri, 16 Apr 2004 23:02:23 +0100 [thread overview]
Message-ID: <20040416220223.GA27084@mail.shareable.org> (raw)
I'm verifying that writing to a shared mapping and then calling
munmap() or exit() definitely propagates the dirty bits from the page
tables to the file.
This has been asked before, 1 year ago, in a thread called "Memory
mapped files question", and hpa said:
> munmap() and fsync() or msync() will flush it to disk; there is no
> reason munmap() should unless perhaps the file was opened O_SYNC.
That was talking about flushing data all the way to disk. The
implication of hpa's response is that munmap() does propagate the
dirty bits from the page table to the file. That is the obvious
behaviour, and what I've always assumed.
I've followed the logic from do_munmap() and it looks good:
unmap_vmas->zap_pte_range->page_remove_rmap->set_page_dirty.
Can someone confirm this is correct, please?
Also, I recall a mention on lkml that some flavour of BSD doesn't
propagate the dirty bits when unmapping, and msync is needed to ensure
data is properly written to the file. I haven't been able to find the
message, though; perhaps I imagined it.
Can someone confirm or refute that, and similarly does anyone know of
any other OS that needs msync before munmap or exit, to ensure written
data reaches the file?
Thanks,
-- Jamie
next reply other threads:[~2004-04-16 22:12 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2004-04-16 22:02 Jamie Lokier [this message]
2004-04-16 22:46 ` msync() needed before munmap() when writing to shared mapping? Andrew Morton
2004-04-16 23:10 ` Jamie Lokier
2004-04-16 23:59 ` Andrew Morton
2004-04-16 23:55 ` Hugh Dickins
2004-04-17 20:23 ` H. Peter Anvin
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=20040416220223.GA27084@mail.shareable.org \
--to=jamie@shareable.org \
--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