Re: [PATCH 2/2] msync: start async writeout when MS_ASYNC

From: Paolo Bonzini
Date: Thu Jun 14 2012 - 06:19:32 EST


Il 14/06/2012 12:07, Andrew Morton ha scritto:
>> > If they knew it was a no-op, and relying on it, they might as well not
>> > have called it at all and save a syscall.
> Nope. Back in the day (3+ years ago?), msync(MS_ASYNC) would flush
> pte-dirty bits into page->flags:PG_Dirty. So it was used to make the
> filesystem aware that userspace had modified some MAP_SHARED memory.
> The fs would then perform writeback within (typically) 30 seconds. So
> a legitimate use would be for the app to periodically run
> msync(MS_ASYNC) to avoid having modified data floating about
> un-written-back for arbitrarily long periods.

This is in fact the same thing I would like to do in my application.
The fact that I/O is started immediately rather than within 30 seconds
is an implementation detail.

An application that calls msync(MS_ASYNC) periodically indeed wants to
start I/O _sooner or later_, it doesn't really matter when.

> Nowadays we mark the pte's read-only and take a fault on first write,
> and mark the page dirty at that time.

We mark pages dirty but we don't promise writing them back (sooner or
later we will, of course). Otherwise there would be no need for
sync_file_range(..., SYNC_FILE_RANGE_WRITE).

Paolo
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/