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

From: Andrew Morton
Date: Thu Jun 14 2012 - 06:07:55 EST


On Thu, 14 Jun 2012 11:02:02 +0200 Paolo Bonzini <pbonzini@xxxxxxxxxx> wrote:

> Il 13/06/2012 23:29, Andrew Morton ha scritto:
> > > If the application does not want to start I/O, it can simply call msync
> > > with flags equal to MS_INVALIDATE. This one remains a no-op, as it should
> > > be on a reasonable implementation.
> >
> > Means that people will find that their msync(MS_ASYNC) call will newly
> > start IO. This may well be undesirable for some.
>
> 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.

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

So it wasn't a no-op, and with this patch, such applications will newly
find themselves to be starting I/O within the msync() call.

--
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/