All of lore.kernel.org
 help / color / mirror / Atom feed
From: Chris Friesen <cfriesen@nortelnetworks.com>
To: linux-kernel@vger.kernel.org
Subject: msync() more expensive than fsync()?
Date: Tue, 08 Apr 2003 12:37:58 -0400	[thread overview]
Message-ID: <3E92FAE6.8000300@nortelnetworks.com> (raw)

I have some code that runs on a ramdisk-based filesystem.  Through a special 
device it mmaps a section of memory that is persistant over reboots, to be used 
for logging.  In order to guarantee that the logs were flushed to the memory 
area, I  assume that I need to use some kind of sync operation.  This is where 
things get a bit odd.

I did some testing with relatively small messages, 50 bytes or so, with results 
as follows:


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.

The kernel was 2.4.18.

Chris


-- 
Chris Friesen                    | MailStop: 043/33/F10
Nortel Networks                  | work: (613) 765-0557
3500 Carling Avenue              | fax:  (613) 765-2986
Nepean, ON K2H 8E9 Canada        | email: cfriesen@nortelnetworks.com


             reply	other threads:[~2003-04-08 16:26 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2003-04-08 16:37 Chris Friesen [this message]
2003-04-09 17:48 ` msync() more expensive than fsync()? Rik van Riel
2003-04-10 19:36 ` H. Peter Anvin

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=3E92FAE6.8000300@nortelnetworks.com \
    --to=cfriesen@nortelnetworks.com \
    --cc=linux-kernel@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.