Linux PARISC architecture development
 help / color / mirror / Atom feed
From: Matthew Wilcox <willy@debian.org>
To: John Marvin <jsm@udlkern.fc.hp.com>
Cc: parisc-linux@lists.parisc-linux.org, davem@redhat.com
Subject: Re: [parisc-linux] Re: RFC: mmap patch
Date: Thu, 6 Mar 2003 14:31:49 +0000	[thread overview]
Message-ID: <20030306143149.B1549@parcelfarce.linux.theplanet.co.uk> (raw)
In-Reply-To: <200303061414.HAA26321@udlkern.fc.hp.com>; from jsm@udlkern.fc.hp.com on Thu, Mar 06, 2003 at 07:14:53AM -0700

On Thu, Mar 06, 2003 at 07:14:53AM -0700, John Marvin wrote:
> In my opinion this patch is a hack workaround for a real bug. parisc is
> not the only architecture that has virtual tagged caches.  Some mips
> machines, sparc and ultrasparc machines have virtual tagged caches,
> although none of them have virtual tagged caches as large as parisc (the
> other architectures typically have a larger physical cache at a higher
> level in the cache hierarchy).
> 
> Dave Miller designed the cache flushing strategy to have hooks in the
> machine independent code to support virtual tagged caches.  Probably there
> is simply a cache flush that is missing that doesn't show itself as a bug
> as easily on the smaller virtually tagged caches of the other
> architectures. At most this particular scenario wasn't considered
> for virtual tagged caches (maintaining coherence between fd writes and
> mmap'ed regions) and will require a design change to fix.
> 
> The fix for this bug should be made in machine independent code, not in
> our machine dependent code.

Unfortunately, the flush is in the right place according to the
definition.  Here's how it looks in 2.4 (2.5 is more complex but has
essentially the same flush in it):

generic_file_write(struct file *file,const char *buf,size_t count, loff_t *ppos)
{
[...]
                kaddr = kmap(page);
                status = mapping->a_ops->prepare_write(file, page, offset, offse
t+bytes);
                if (status)
                        goto sync_failure;
                page_fault = __copy_from_user(kaddr+offset, buf, bytes);
                flush_dcache_page(page);
                status = mapping->a_ops->commit_write(file, page, offset, offset
+bytes);

So our flush_dcache_page() flushes the kernel's view of that page,
no problem.  Memory now has the right contents.  But the dcache still
has the stale data in it for the user's mapping of the same page.

There's a few ways to fix it.

1) This patch tausq did.  Now we flush both user & kernel mappings for the
data.

2) Split flush_dcache_page into flush_dcache_page_user_mapping() and
flush_dcache_page_kernel_mapping().  Hopefully with better names.

3) (ab)use kmap to hand back an address which virtually aliases the user
mapping.  flush_dcache_page() would only have to writeback to memory if
the page was not mapped.

-- 
"It's not Hollywood.  War is real, war is primarily not about defeat or
victory, it is about death.  I've seen thousands and thousands of dead bodies.
Do you think I want to have an academic debate on this subject?" -- Robert Fisk

  reply	other threads:[~2003-03-06 14:31 UTC|newest]

Thread overview: 27+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2003-03-06 14:14 [parisc-linux] Re: RFC: mmap patch John Marvin
2003-03-06 14:31 ` Matthew Wilcox [this message]
2003-03-06 15:31   ` Randolph Chung
2003-03-08  6:30 ` Grant Grundler
2003-03-08  6:29   ` David S. Miller
2003-03-08 17:24     ` Grant Grundler
2003-03-08 19:04       ` David S. Miller
2003-03-08 20:42         ` Grant Grundler
2003-03-08 22:45         ` Matthew Wilcox
2003-03-08 23:00           ` David S. Miller
2003-03-08 23:27             ` Matthew Wilcox
2003-03-08 23:14               ` David S. Miller
2003-03-08 23:31             ` Randolph Chung
2003-03-08 23:15               ` David S. Miller
2003-03-09  2:15             ` Grant Grundler
2003-03-08 23:11     ` Matthew Wilcox
2003-03-08 23:02       ` David S. Miller
2003-03-09 14:42         ` Matthew Wilcox
2003-03-09 21:38           ` David S. Miller
2003-03-10  1:50             ` Matthew Wilcox
2003-03-10  5:18               ` David S. Miller
2003-03-14 13:04           ` Jochen Friedrich
2003-03-14 16:23             ` Grant Grundler
  -- strict thread matches above, loose matches on Subject: below --
2003-03-09  3:42 John Marvin
2003-03-09 21:29 ` David S. Miller
2003-03-09  3:51 John Marvin
2003-03-09 21:31 ` 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=20030306143149.B1549@parcelfarce.linux.theplanet.co.uk \
    --to=willy@debian.org \
    --cc=davem@redhat.com \
    --cc=jsm@udlkern.fc.hp.com \
    --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