Re: msync() needed before munmap() when writing to shared mapping?

From: Hugh Dickins
Date: Fri Apr 16 2004 - 18:56:19 EST


On Fri, 16 Apr 2004, Andrew Morton wrote:
> Jamie Lokier <jamie@xxxxxxxxxxxxx> wrote:
> >
> > 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?
>
> yup, zap_pte_range() transfers pte dirtiness into pagecache dirtiness when
> tearing down the mapping, leaving the dirty page floating about in
> pagecache for kupdate/kswapd/fsync to catch. Longstanding behaviour.

May I add a clarification? Jamie has focussed on the set_page_dirty
in page_remove_rmap: that's a special for s390, on everything else the
"page_test_and_clear_dirty" preceding it evaluates to 0. For most
arches it is indeed the set_page_dirty actually in zap_pte_range
which smears the dirt from pte to page. (Please don't ask me
to explain the s390 case, I'm no expert.)

Hugh

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