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

H. Peter Anvin (hpa@zytor.com)
10 Apr 2003 12:36:16 -0700


Followup to: <3E92FAE6.8000300@nortelnetworks.com>
By author: Chris Friesen <cfriesen@nortelnetworks.com>
In newsgroup: linux.dev.kernel
>
> Without any explicit flushing it takes 8 usec to log a message.
>
> 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()? I would have thought it would be faster
> since it is explicitely for mmapped memory areas. As a side note, the
> difference is even more extreme if a file is used on a disk-backed filesystem.
>

Because fsync() does less work. In particular, fsync() doesn't do the
work you want: unlike msync() it doesn't guarantee that memory maps
are consistent with the filesystem.

-hpa

-- 
<hpa@transmeta.com> at work, <hpa@zytor.com> in private!
"Unix gives you enough rope to shoot yourself in the foot."
Architectures needed: ia64 m68k mips64 ppc ppc64 s390 s390x sh v850 x86-64
-
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/