linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: James Bottomley <James.Bottomley@steeleye.com>
To: Linux Kernel <linux-kernel@vger.kernel.org>,
	PARISC list <parisc-linux@lists.parisc-linux.org>
Cc: davem@redhat.com, drepper@redhat.com
Subject: Problems with kernel mmap (failing tst-mmap-eofsync in glibc on parisc)
Date: 22 Aug 2003 09:40:37 -0500	[thread overview]
Message-ID: <1061563239.2090.25.camel@mulgrave> (raw)

[-- Attachment #1: Type: text/plain, Size: 1298 bytes --]

This test essentially opens a file (via open(2)), writes something,
opens it via a mmaped file object *read only* (via fopen(...,"rm)) reads
what was writtent, writes some more and reads it via the mmaped file
object.

This last read fails to get the data on parisc.  The problem is that our
CPU cache is virtually indexed, and the page the write is storing the
data to (in the buffer cache) and the page it is mmapped to have the
same physical, but different virtual addresses.  We need the write() to
trigger a cache update via flush_dcache_page to get the virtually
indexed cache in sync.

The reason this doesn't happen is because the mapping is not on the
mmap_shared list that flush_dcache_page() updates.

And the reason it's not on the correct list is because there's a check
in mm/mmap.c:do_mmap_pgoff() that drops the VM_SHARED flag on the
mapping if the file wasn't opened for writing (about line 541).

Semantically, it seems that whether the mmaping sees a write or not on a
different descriptor shouldn't depend on whether the underlying file was
opened read only or read write, so I think the glibc test is correct,
and we should keep the VM_SHARED flag even if the underlying file was
opened read only.

The patch is attached (and makes the test pass on parisc).

Comments?

James


[-- Attachment #2: tmp.diff --]
[-- Type: text/plain, Size: 363 bytes --]

===== mm/mmap.c 1.89 vs edited =====
--- 1.89/mm/mmap.c	Thu Jul 10 21:46:52 2003
+++ edited/mm/mmap.c	Fri Aug 22 09:36:32 2003
@@ -539,7 +539,7 @@
 
 			vm_flags |= VM_SHARED | VM_MAYSHARE;
 			if (!(file->f_mode & FMODE_WRITE))
-				vm_flags &= ~(VM_MAYWRITE | VM_SHARED);
+				vm_flags &= ~VM_MAYWRITE;
 
 			/* fall through */
 		case MAP_PRIVATE:

             reply	other threads:[~2003-08-22 14:40 UTC|newest]

Thread overview: 30+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2003-08-22 14:40 James Bottomley [this message]
2003-08-22 16:14 ` Problems with kernel mmap (failing tst-mmap-eofsync in glibc on parisc) David S. Miller
2003-08-22 16:34   ` [parisc-linux] " Matthew Wilcox
2003-08-22 16:39     ` David S. Miller
2003-08-22 17:41       ` Matthew Wilcox
2003-08-22 17:36         ` David S. Miller
2003-08-22 18:01           ` David S. Miller
2003-08-22 18:34             ` Hugh Dickins
2003-08-22 18:31               ` David S. Miller
2003-08-22 18:56                 ` James Bottomley
2003-08-22 19:19                   ` David S. Miller
2003-08-22 22:27                     ` James Bottomley
2003-08-22 22:41                       ` David S. Miller
2003-08-23  1:09                         ` James Bottomley
2003-08-23  7:22                           ` Hugh Dickins
2003-08-23 15:59                             ` James Bottomley
2003-08-23 21:44                             ` David S. Miller
2003-08-23 21:43                           ` David S. Miller
2003-08-23 22:21                             ` James Bottomley
2003-08-23 22:51                               ` David S. Miller
2003-08-23 23:01                                 ` James Bottomley
2003-08-23 22:53                               ` David S. Miller
2003-08-23 23:11                                 ` James Bottomley
2003-08-24  0:22                                   ` David S. Miller
     [not found]                                     ` <1061702282.1992.1153.camel@mulgrave>
     [not found]                                       ` <20030823222300.4695a0c4.davem@redhat.com>
2003-08-24 16:54                                         ` James Bottomley
2003-08-22 18:41               ` James Bottomley
2003-08-22 19:02                 ` Hugh Dickins
2003-08-22 19:09                 ` Randolph Chung
2003-08-22 16:42     ` Russell King
2003-08-22 16:39       ` David S. Miller

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=1061563239.2090.25.camel@mulgrave \
    --to=james.bottomley@steeleye.com \
    --cc=davem@redhat.com \
    --cc=drepper@redhat.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=parisc-linux@lists.parisc-linux.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).