public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Chris Friesen <cfriesen@nortelnetworks.com>
To: linux-kernel@vger.kernel.org
Subject: trying to understand mmap, msync, O_SYNC, and devices
Date: Thu, 17 Apr 2003 17:06:38 -0400	[thread overview]
Message-ID: <3E9F175E.1000504@nortelnetworks.com> (raw)


With the discussions over the past while, it is now clear that shared mappings 
of normal files will not be written out until forced to, and that this is the 
correct thing to do in almost all cases.

In this case, changing something in the mapped area will make the changes 
visible to all other processes mapping the same area, but the changes are not 
guaranteed to be flushed to the backing store.

What I am not clear on is how this interacts with mapping *devices*.  Does it 
still go through the buffer cache?


Details follow for those who are interested:

I have hardware which does not wipe ram on reset as long as it is not powered 
off.  On boot I force a limit on the amount of memory used by the kernel, which 
leaves a chunk of unused memory beyond normally-accessable memory.  I have a 
char driver which then implements mmap by mapping this memory to the calling 
process.  This mapping is shared between many processes and is used for logging, 
with appropriate locking mechanisms.

My key issue is this--how do I ensure that the contents of this memory are 
consistant and up to date when the board may be rebooted at any time?

I have three levels of enforcement that I have considered:

1) Opening the device with O_SYNC.  This also tells the mmap code in the driver 
to set the memory to uncached, the same way that mem.c does in pgprot_noncached().

2) Calls to wmb() in the code to enforce order when setting critical fields.

3) Explicit calls to msync() in place of the wmb() calls. (Which slows it down 
by a factor of 2.5 as compared to #2.)


I assume that #1 is required to guard against resetting of the board.  Beyond 
that is #2 sufficient, or is #3 required?

Thanks,

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-17 20:54 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

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=3E9F175E.1000504@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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox