linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
From: Nick Piggin <npiggin@suse.de>
To: Linus Torvalds <torvalds@linux-foundation.org>
Cc: Hugh Dickins <hugh@veritas.com>, Mel Gorman <mel@skynet.ie>,
	linux-mm@kvack.org
Subject: Re: [PATCH] Remove unnecessary smp_wmb from clear_user_highpage()
Date: Thu, 19 Jul 2007 04:58:07 +0200	[thread overview]
Message-ID: <20070719025807.GE23641@wotan.suse.de> (raw)
In-Reply-To: <alpine.LFD.0.999.0707181912210.27353@woody.linux-foundation.org>

On Wed, Jul 18, 2007 at 07:28:26PM -0700, Linus Torvalds wrote:
> 
> 
> On Wed, 18 Jul 2007, Hugh Dickins wrote:
> 
> > >     making the barrier unnecessary. A hint of lack of necessity is that there
> > >     does not appear to be a read barrier anywhere for this zeroed page.
> > 
> > Yes, I think Nick was similarly suspicious of a wmb without an rmb; but
> > Linus is _very_ barrier-savvy, so we might want to ask him about it (CC'ed).
> 
> A smp_wmb() should in general always have a paired smp_rmb(), or it's 
> pointless. A special case is when the wmb() is between the "data" and the 
> "exposure" of that data (ie the pointer write that makes the data 
> visible), in which case the other end doesn't need a smp_rmb(), but may 
> well still need a "smp_read_barrier_depends()".

I think the core mm should be OK, because setting and getting ptes should
(AFAIKS) always take the ptl. arch code that does lockless pte lookups
(ppc64's find_linux_pte for example seems to), and hardware fills of course
need a causal ordering there. So if there was something like find_linux_pte
used to load the TLB on alpha without smp_read_barrier_depends, I think
that would be a bug.


> > >  	void *addr = kmap_atomic(page, KM_USER0);
> > >  	clear_user_page(addr, vaddr, page);
> > >  	kunmap_atomic(addr, KM_USER0);
> > > -	/* Make sure this page is cleared on other CPU's too before using it */
> > > -	smp_wmb();
> 
> I suspect that the smp_wmb() is probably a good idea, since the 
> "kunmap_atomic()" is generally a no-op, and other CPU's may read the page 
> through the page tables without any other serialization.
> 
> And in that case, the others only need the "smp_read_barrier_depends()", 
> and the fact is, that's a no-op for pretty much everybody, and a TLB 
> lookup *has* to have that even on alpha, because otherwise the race is 
> simply unfixable.
> 
> But I did *not* look through the whole sequence, so who knows. If there is 
> a full lock/unlock pair between the clear_user_highpage() and actually 
> making it available in the page tables, the wmb wouldn't be needed.

Pretty sure Paulus, Ben, or Anton ran into it, yes. Actually, from
memory they submitted a variant on that patch which you didn't like ;)


--
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:"dont@kvack.org"> email@kvack.org </a>

  reply	other threads:[~2007-07-19  2:58 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-07-18 15:05 Mel Gorman
2007-07-18 16:45 ` Hugh Dickins
2007-07-19  2:17   ` Nick Piggin
2007-07-20 13:08     ` Mel Gorman
2007-07-23  2:02       ` Nick Piggin
2007-07-19  2:28   ` Linus Torvalds
2007-07-19  2:58     ` Nick Piggin [this message]
2007-07-19  2:36   ` Nick Piggin
2007-07-19 11:16   ` Mel Gorman
2007-07-19  1:57 ` Nick Piggin
2007-07-20 21:06 Oleg Nesterov
2007-07-20 21:57 ` Linus Torvalds

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=20070719025807.GE23641@wotan.suse.de \
    --to=npiggin@suse.de \
    --cc=hugh@veritas.com \
    --cc=linux-mm@kvack.org \
    --cc=mel@skynet.ie \
    --cc=torvalds@linux-foundation.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