linux-arm-kernel.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
From: jamie@shareable.org (Jamie Lokier)
To: linux-arm-kernel@lists.infradead.org
Subject: flush_dcache_page does too much?
Date: Tue, 19 Jan 2010 18:33:29 +0000	[thread overview]
Message-ID: <20100119183328.GG1323@shareable.org> (raw)
In-Reply-To: <20100119174450.GB1886@n2100.arm.linux.org.uk>

Russell King - ARM Linux wrote:
> On Tue, Jan 19, 2010 at 09:05:47PM +0800, anfei wrote:
> > Do you think this is a bug and I can send the patch, or it's the problem
> > of the test case?
> 
> Yes, it's a bug, but it needs to be reported elsewhere; neither this
> list nor I can sanction patches to generic code.

It's not necessarily a bug if the appropriate msync() call fixes the
test.  Linux doesn't guarantee coherence between mappings and
read/write without msync() on some architectures, but I haven't seen
an official statement of whether it *should* or not in this type of
case.

I have looked at this in some detail a few years ago.  When I looked
at MIPS and some other architecture code, I wasn't sure it was correct
even with msync() calls everywhere.  It looked distinctly undertested.

The Linux msync(2) man page says:

       msync()  flushes  changes  made  to the in-core copy of a file that was
       mapped into memory using mmap(2) back to disk.   Without  use  of  this
       call  there  is  no guarantee that changes are written back before mun?
       map(2) is called.  To be more precise, the part of the file that corre?
       sponds  to the memory area starting at addr and having length length is
       updated.

It's not a great description.  MS_INVALIDATE talks about invalidating
"other mappings", not this one, in the Linux man page.

But on other OSes (SunOS, HP-UX for example), MS_INVALIDATE
invalidates _this_ mapping so that it sees the latest data written by
write() to the file.

In other words, Linux is a complete mess in this area.  It happens to
work on some architectures, it's broken a little bit on others, broken
a lot on some, and despite reading a fair bit of code I'm still not
sure what the kernel is trying to promise.

Probably different people have different ideas about what's expected,
which is why MIPS and ARM kernels differ.

-- Jamie

      reply	other threads:[~2010-01-19 18:33 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-01-18 13:13 flush_dcache_page does too much? anfei
2010-01-18 13:33 ` Russell King - ARM Linux
2010-01-18 13:54   ` anfei
2010-01-18 14:00     ` Russell King - ARM Linux
2010-01-18 14:15       ` anfei
2010-01-18 14:44         ` Russell King - ARM Linux
2010-01-18 14:53           ` anfei
2010-01-18 14:57           ` anfei
2010-01-18 15:01             ` Russell King - ARM Linux
2010-01-19  0:16               ` anfei
2010-01-19 13:05                 ` anfei
2010-01-19 17:44                   ` Russell King - ARM Linux
2010-01-19 18:33                     ` Jamie Lokier [this message]

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=20100119183328.GG1323@shareable.org \
    --to=jamie@shareable.org \
    --cc=linux-arm-kernel@lists.infradead.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;
as well as URLs for NNTP newsgroup(s).