Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

mmap file sync after process killing

390 views
Skip to first unread message

duddn

unread,
Jul 28, 2010, 1:58:08 AM7/28/10
to
Hi.

Does linux flush dirty memory pages of regular files which are mapped
using mmap() with MAP_SHARED flag if the process is killed by "kill -9
PID" ? Or they are just discarded?
If the pages are flushed back to the files, is it possible to find the
time that I can access the changed contents with direct IO using
open() with O_DIRECT flag?

Jasen Betts

unread,
Jul 28, 2010, 7:45:27 AM7/28/10
to
On 2010-07-28, duddn <ich...@gmail.com> wrote:
> Hi.
>
> Does linux flush dirty memory pages of regular files which are mapped
> using mmap() with MAP_SHARED flag if the process is killed by "kill -9
> PID" ? Or they are just discarded?

as I understand it death is an implicit munmap().

> If the pages are flushed back to the files, is it possible to find the
> time that I can access the changed contents with direct IO using
> open() with O_DIRECT flag?

AIUI the change should be immediately visible in the file (even before
munmap).

--- news://freenews.netfront.net/ - complaints: ne...@netfront.net ---

John Reiser

unread,
Jul 28, 2010, 9:06:31 AM7/28/10
to
>> Does linux flush dirty memory pages of regular files which are mapped
>> using mmap() with MAP_SHARED flag if the process is killed by "kill -9
>> PID" ? Or they are just discarded?
>
> as I understand it death is an implicit munmap().

Yes, and munmap() includes an implicit msync(). Thus the changes
become visible.

>> If the pages are flushed back to the files, is it possible to find the
>> time that I can access the changed contents with direct IO using
>> open() with O_DIRECT flag?
>
> AIUI the change should be immediately visible in the file (even before
> munmap).

That's true today for buffered I/O on a "one-box" system, but the
original poster asked for O_DIRECT, which means that fsync() is required.
Because msync() does not imply fsync(), then the user of O_DIRECT
must issue the fsync() in this case.

Immediate propagation to I/O from a STORE into a mapped page depends
on coherency between the paging memory management and the buffer I/O
subsystems. This is true on all "one-box" systems today, although
there were some old HP-UX systems in which those subsystems were
separate and not coherent. However if NFS or other remote filesystem
is involved, then coherency can be disrupted even today by delays
due to communication "over the wire." Also remember that NFS allows
inconsistencies to be visible for up to 1 second, even after msync().

--

0 new messages