linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
From: Andrea Arcangeli <andrea@suse.de>
To: Linus Torvalds <torvalds@osdl.org>
Cc: Matthew Wilcox <willy@debian.org>,
	Benjamin Herrenschmidt <benh@kernel.crashing.org>,
	Andrew Morton <akpm@osdl.org>,
	Linux Kernel list <linux-kernel@vger.kernel.org>,
	Ingo Molnar <mingo@elte.hu>, Ben LaHaise <bcrl@kvack.org>,
	linux-mm@kvack.org,
	Architectures Group <linux-arch@vger.kernel.org>
Subject: Re: [PATCH] ppc64: Fix possible race with set_pte on a present PTE
Date: Tue, 25 May 2004 23:55:00 +0200	[thread overview]
Message-ID: <20040525215500.GI29378@dualathlon.random> (raw)
In-Reply-To: <Pine.LNX.4.58.0405251440120.9951@ppc970.osdl.org>

On Tue, May 25, 2004 at 02:43:46PM -0700, Linus Torvalds wrote:
> 
> 
> On Tue, 25 May 2004, Andrea Arcangeli wrote:
> > 
> > 			entry = ptep_get_and_clear(pte);
> > 			set_pte(pte, pte_modify(entry, newprot));
> > 
> > Again no atomic instructions.
> 
> Well, actually, that "ptep_get_and_clear()" is actually an atomic 
> instruction. Or at least it had _better_ be.

sure, I really meant no "new" atomic instruction.

> > I believe using ptep_establish in handle_mm_fault makes little sense,
> > to make the most obvious example there's no need of flushing the tlb in
> > handle_mm_fault to resolve young or dirty page faults. Not a big deal
> > for x86 and x86-64 that reaches that path only if a race happens, but on
> > alpha we shouldn't flush the tlb. If some weird architecture really need
> > to flush the tlb they still can inside
> > ptep_handle_[young|dirty]_page_fault.
> 
> Actually, especially on alpha we _do_ need to flush the TLB.
> 
> Think about it: the TLB clearly contains the right virt->physical mapping, 
> but the TLB contains the wrong "control bits". 
> 
> If we don't flush the TLB, the TLB will _continue_ to contain the wrong 
> control bits.

I expected the pal code to re-read the pte if the control bits asked for
page fault, like it must happen if the control bits are set to
non-present. This latter this must be true or linux wouldn't run at all
on alpha.  We certainly don't flush the tlb after marking the page from
non-present to present, example in do_anonymous_page. Anyways if the pal
code behaves like that specifically with the KWE/UWE/KRE/URE and not
with the PAGE_VALID bit, I obviously agree have to flush the tlb. I just
didn't expect it, though I admit I couldn't easily find specs about it.

> And as you saw earlier, if those bits are wrong, you get some really nasty 
> behaviour, like infinite page faults. If the TLB still says that the page 
> is non-readable, even though _memory_ says it is readable, it doesn't much 
> matter that we updated the page tables correctly in memory. The CPU will 
> use the TLB.
> 
> So that TLB flush actually _is_ fundamental. 
> 
> Arguably we could remove it from x86. On the other hand, arguably it 
> doesn't actually matter on x86, so..

it doesn't matter in handle_mm_fault but it does matter in do_wp_page.
since we've to mess with ptep_establish to fix this race, it would be
nice to remove such flush_tlb_page from do_wp_page. Or is the x86 tlb
also not refilling the pte automatically if the control bits asks for
page-fault? In mprotect obviously we've to flush since we can upgrade
and downgrade the control bits, but in do_wp_page we only ugprade, so
there should be no need of tlb flush. I'll try to find some
documentation about this to be sure, at least for x86 it should be easy
to find.
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org.  For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"aart@kvack.org"> aart@kvack.org </a>

  reply	other threads:[~2004-05-25 21:55 UTC|newest]

Thread overview: 71+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <1085369393.15315.28.camel@gaston>
     [not found] ` <Pine.LNX.4.58.0405232046210.25502@ppc970.osdl.org>
     [not found]   ` <1085371988.15281.38.camel@gaston>
     [not found]     ` <Pine.LNX.4.58.0405232134480.25502@ppc970.osdl.org>
     [not found]       ` <1085373839.14969.42.camel@gaston>
2004-05-24  5:10         ` Linus Torvalds
2004-05-24  5:34           ` Benjamin Herrenschmidt
2004-05-24  5:38             ` Benjamin Herrenschmidt
2004-05-24  5:52               ` Benjamin Herrenschmidt
2004-05-24  7:39           ` Ingo Molnar
2004-05-24  5:39             ` Benjamin Herrenschmidt
2004-05-25  3:43           ` Andrea Arcangeli
2004-05-25  4:00             ` Linus Torvalds
2004-05-25  4:17               ` Benjamin Herrenschmidt
2004-05-25  4:37                 ` Andrea Arcangeli
2004-05-25  4:40                   ` Benjamin Herrenschmidt
2004-05-25  4:20               ` Andrea Arcangeli
2004-05-25  4:39                 ` Linus Torvalds
2004-05-25  4:44                   ` Linus Torvalds
2004-05-25  4:59                     ` Andrea Arcangeli
2004-05-25  5:09                       ` Andrea Arcangeli
2004-05-25  4:50                   ` Andrea Arcangeli
2004-05-25  4:59                     ` Linus Torvalds
2004-05-25  4:43                 ` David Mosberger
2004-05-25  4:53                   ` Andrea Arcangeli
2004-05-27 21:56                     ` David Mosberger
2004-05-27 22:00                       ` Benjamin Herrenschmidt
2004-05-27 22:12                         ` David Mosberger
2004-05-25 11:44               ` Matthew Wilcox
2004-05-25 14:48                 ` Linus Torvalds
2004-05-25 15:35                   ` Keith M Wesolowski
2004-05-25 16:19                     ` Linus Torvalds
2004-05-25 17:25                       ` David S. Miller
2004-05-25 17:49                         ` Linus Torvalds
2004-05-25 17:54                           ` David S. Miller
2004-05-25 18:05                             ` Linus Torvalds
2004-05-25 20:30                               ` Linus Torvalds
2004-05-25 20:35                               ` David S. Miller
2004-05-25 20:49                                 ` Linus Torvalds
2004-05-25 20:57                                   ` David S. Miller
2004-05-26  6:20                                   ` Keith M Wesolowski
2004-05-25 21:40                               ` Benjamin Herrenschmidt
2004-05-25 21:54                                 ` Linus Torvalds
2004-05-25 22:00                                   ` Linus Torvalds
2004-05-25 22:07                                     ` Benjamin Herrenschmidt
2004-05-25 22:14                                       ` Linus Torvalds
2004-05-26  0:21                                         ` Benjamin Herrenschmidt
2004-05-26  0:50                                           ` Linus Torvalds
2004-05-26  3:25                                             ` Benjamin Herrenschmidt
2004-05-26  4:08                                               ` Linus Torvalds
2004-05-26  4:12                                                 ` Benjamin Herrenschmidt
2004-05-26  4:18                                                   ` Benjamin Herrenschmidt
2004-05-26  4:50                                                     ` Linus Torvalds
2004-05-26  4:49                                                       ` Benjamin Herrenschmidt
2004-05-26  4:28                                                   ` Linus Torvalds
2004-05-26  4:46                                                 ` Benjamin Herrenschmidt
2004-05-26  4:54                                                   ` Linus Torvalds
2004-05-26  4:55                                                     ` Benjamin Herrenschmidt
2004-05-26  5:41                                                     ` Benjamin Herrenschmidt
2004-05-26  5:59                                                     ` [PATCH] (signoff) " Benjamin Herrenschmidt
2004-05-26  6:55                                                       ` Benjamin Herrenschmidt
2004-05-25 22:05                                   ` [PATCH] " Benjamin Herrenschmidt
2004-05-25 22:09                                 ` Linus Torvalds
2004-05-25 22:19                                   ` Benjamin Herrenschmidt
2004-05-25 22:24                                     ` Linus Torvalds
2004-05-25 21:27                   ` Andrea Arcangeli
2004-05-25 21:43                     ` Linus Torvalds
2004-05-25 21:55                       ` Andrea Arcangeli [this message]
2004-05-25 22:01                         ` Linus Torvalds
2004-05-25 22:18                           ` Ivan Kokshaysky
2004-05-25 22:42                             ` Andrea Arcangeli
2004-05-26  2:26                               ` Linus Torvalds
2004-05-26  7:06                                 ` Andrea Arcangeli
2004-05-25 21:44                     ` Andrea Arcangeli
2004-06-01 12:04 Martin Schwidefsky
2004-06-01 12:10 Martin Schwidefsky

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=20040525215500.GI29378@dualathlon.random \
    --to=andrea@suse.de \
    --cc=akpm@osdl.org \
    --cc=bcrl@kvack.org \
    --cc=benh@kernel.crashing.org \
    --cc=linux-arch@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=mingo@elte.hu \
    --cc=torvalds@osdl.org \
    --cc=willy@debian.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