Generic Linux architectural discussions
 help / color / mirror / Atom feed
From: David Miller <davem@davemloft.net>
To: buytenh@wantstofly.org
Cc: James.Bottomley@steeleye.com, rmk@arm.linux.org.uk,
	linux-arch@vger.kernel.org, akpm@linux-foundation.org
Subject: Re: [CFT] read+shared mmap write+read data corruption
Date: Mon, 28 May 2007 22:35:50 -0700 (PDT)	[thread overview]
Message-ID: <20070528.223550.39158516.davem@davemloft.net> (raw)
In-Reply-To: <20070528124411.GA31764@xi.wantstofly.org>

From: Lennert Buytenhek <buytenh@wantstofly.org>
Date: Mon, 28 May 2007 14:44:11 +0200

> On Sun, May 27, 2007 at 07:31:27PM -0500, James Bottomley wrote:
> 
> > On munmap we do a flush_cache_range for the unmapped vmas ... we
> > have to, otherwise the data might be lost as the user mapping is
> > zapped and we wouldn't be able to guarantee coherency writing it
> > to the backing store.
> 
> As far as I understand it, the munmap() does flush out the copy of
> the data at the user virtual address, but the subsequent read() call
> reads from an address in the kernel direct mapped window, for which
> there is still data in the cache due to the earlier read() syscall,
> and the mapping_writably_mapped() test fails so we don't end up
> calling flush_dcache_page().

That is what is happening for sure.

That mapping_writably_mapped() check depends upon munmap()
flush out the lines from the cache on the user side at
least enough to make them coherent on the kernel side.

As I said my flush_cache_range() on sparc64 used to do this,
but I removed it for whatever reason, perhaps I did not
consider this case back then.

I'm not advocating a full flush on flush_cache_range(), but rather to
set a page state bit, which will force a flush on the
"check_dcache_page()" call which we could replace this conditionalized
flush_dcache_page() call with.

  reply	other threads:[~2007-05-29  5:58 UTC|newest]

Thread overview: 25+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-05-27 10:49 [CFT] read+shared mmap write+read data corruption Russell King
2007-05-27 14:16 ` James Bottomley
2007-05-27 22:25   ` Lennert Buytenhek
2007-05-27 23:06     ` David Miller
2007-05-27 23:05   ` David Miller
2007-05-28  0:31     ` James Bottomley
2007-05-28 12:44       ` Lennert Buytenhek
2007-05-29  5:35         ` David Miller [this message]
2007-05-29  9:12           ` Russell King
2007-05-29 10:26             ` David Miller
2007-05-27 22:24 ` Lennert Buytenhek
2007-05-28  0:00   ` James Bottomley
2007-05-28 10:05     ` Russell King
2007-05-28 14:17       ` James Bottomley
2007-05-28 14:39         ` Lennert Buytenhek
2007-05-29  3:06           ` James Bottomley
2007-05-29  3:15             ` Lennert Buytenhek
2007-05-29 14:32               ` James Bottomley
2007-05-29 17:13                 ` Russell King
2007-05-29  5:58           ` David Miller
2007-05-28 15:04         ` Russell King
2007-05-29 15:42       ` Lennert Buytenhek
2007-05-28 12:33     ` Lennert Buytenhek
2007-05-28 14:22       ` James Bottomley
2007-05-28 12:38 ` Lennert Buytenhek

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=20070528.223550.39158516.davem@davemloft.net \
    --to=davem@davemloft.net \
    --cc=James.Bottomley@steeleye.com \
    --cc=akpm@linux-foundation.org \
    --cc=buytenh@wantstofly.org \
    --cc=linux-arch@vger.kernel.org \
    --cc=rmk@arm.linux.org.uk \
    /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