Re: msync() more expensive than fsync()?

Rik van Riel (riel@redhat.com)
Wed, 9 Apr 2003 13:48:51 -0400 (EDT)


On Tue, 8 Apr 2003, Chris Friesen wrote:

> If I msync() only the pages that were touched in writing (usually 3
> pages) it takes 39 usecs to log a message.
>
> If I fsync() the entire file (200KB) it takes 12 usec to log a message.
>
> Why the additional cost for msync()?

If you only write into the file through an mmap()d area, then
I guess that fsync() is a NOP since it doesn't check the page
tables for dirty bits, while msync() does check the page tables.

This also means that fsync() won't see any dirty bits as long
as they're still only in the page tables, and consequently won't
write anything to disk, while msync() will write.

Note that I don't remember the details 100%, but IIRC it was
something like this.

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