All of lore.kernel.org
 help / color / mirror / Atom feed
From: Andrea Arcangeli <andrea@qumranet.com>
To: Christoph Lameter <clameter@sgi.com>
Cc: Robin Holt <holt@sgi.com>,
	"Paul E. McKenney" <paulmck@linux.vnet.ibm.com>,
	kvm-devel@lists.sourceforge.net,
	Peter Zijlstra <a.p.zijlstra@chello.nl>,
	general@lists.openfabrics.org, steiner@sgi.com,
	linux-kernel@vger.kernel.org, linux-mm@kvack.org
Subject: Re: [patch 02/10] emm: notifier logic
Date: Mon, 7 Apr 2008 08:06:02 +0200	[thread overview]
Message-ID: <20080407060602.GE9309@duo.random> (raw)
In-Reply-To: <Pine.LNX.4.64.0804062246030.18148@schroedinger.engr.sgi.com>

On Sun, Apr 06, 2008 at 10:48:56PM -0700, Christoph Lameter wrote:
> On Sat, 5 Apr 2008, Andrea Arcangeli wrote:
> 
> > > +	rcu_assign_pointer(mm->emm_notifier, e);
> > > +	mm_unlock(mm);
> > 
> > My mm_lock solution makes all rcu serialization an unnecessary
> > overhead so you should remove it like I already did in #v11. If it
> > wasn't the case, then mm_lock wouldn't be a definitive fix for the
> > race.
> 
> There still could be junk in the cache of one cpu. If you just read the 
> new pointer but use the earlier content pointed to then you have a 
> problem.

There can't be junk, spinlocks provides semantics of proper memory
barriers, just like rcu, so it's entirely superflous.

There could be junk only if any of the mmu_notifier_* methods would be
invoked _outside_ the i_mmap_lock and _outside_ the anon_vma and
outside the mmap_sem, that is never the case of course.

> So a memory fence / barrier is needed to guarantee that the contents 
> pointed to are fetched after the pointer.

It's not needed... if you were right we could never possibly run a
list_for_each inside any spinlock protected critical section and we'd
always need to use the _rcu version instead. The _rcu version is
needed only when the list walk happens outside the spinlock critical
section of course (rcu = no spinlock cacheline exlusive write
operation in the read side, here the read side takes the spinlock big time).

WARNING: multiple messages have this Message-ID (diff)
From: Andrea Arcangeli <andrea@qumranet.com>
To: Christoph Lameter <clameter@sgi.com>
Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>,
	kvm-devel@lists.sourceforge.net, steiner@sgi.com,
	linux-kernel@vger.kernel.org, linux-mm@kvack.org,
	Robin Holt <holt@sgi.com>,
	general@lists.openfabrics.org,
	"Paul E. McKenney" <paulmck@linux.vnet.ibm.com>
Subject: Re: [patch 02/10] emm: notifier logic
Date: Mon, 7 Apr 2008 08:06:02 +0200	[thread overview]
Message-ID: <20080407060602.GE9309@duo.random> (raw)
In-Reply-To: <Pine.LNX.4.64.0804062246030.18148@schroedinger.engr.sgi.com>

On Sun, Apr 06, 2008 at 10:48:56PM -0700, Christoph Lameter wrote:
> On Sat, 5 Apr 2008, Andrea Arcangeli wrote:
> 
> > > +	rcu_assign_pointer(mm->emm_notifier, e);
> > > +	mm_unlock(mm);
> > 
> > My mm_lock solution makes all rcu serialization an unnecessary
> > overhead so you should remove it like I already did in #v11. If it
> > wasn't the case, then mm_lock wouldn't be a definitive fix for the
> > race.
> 
> There still could be junk in the cache of one cpu. If you just read the 
> new pointer but use the earlier content pointed to then you have a 
> problem.

There can't be junk, spinlocks provides semantics of proper memory
barriers, just like rcu, so it's entirely superflous.

There could be junk only if any of the mmu_notifier_* methods would be
invoked _outside_ the i_mmap_lock and _outside_ the anon_vma and
outside the mmap_sem, that is never the case of course.

> So a memory fence / barrier is needed to guarantee that the contents 
> pointed to are fetched after the pointer.

It's not needed... if you were right we could never possibly run a
list_for_each inside any spinlock protected critical section and we'd
always need to use the _rcu version instead. The _rcu version is
needed only when the list walk happens outside the spinlock critical
section of course (rcu = no spinlock cacheline exlusive write
operation in the read side, here the read side takes the spinlock big time).

-------------------------------------------------------------------------
This SF.net email is sponsored by the 2008 JavaOne(SM) Conference 
Register now and save $200. Hurry, offer ends at 11:59 p.m., 
Monday, April 7! Use priority code J8TLD2. 
http://ad.doubleclick.net/clk;198757673;13503038;p?http://java.sun.com/javaone

  reply	other threads:[~2008-04-07  6:06 UTC|newest]

Thread overview: 48+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-04-04 22:30 [patch 00/10] [RFC] EMM Notifier V3 Christoph Lameter
2008-04-04 22:30 ` [ofa-general] " Christoph Lameter
2008-04-04 22:30 ` [patch 01/10] emm: mm_lock: Lock a process against reclaim Christoph Lameter
2008-04-04 22:30   ` [ofa-general] " Christoph Lameter
2008-04-04 23:12   ` Jeremy Fitzhardinge
2008-04-04 23:12     ` [ofa-general] " Jeremy Fitzhardinge
2008-04-05  0:41     ` Andrea Arcangeli
2008-04-05  0:41       ` [ofa-general] " Andrea Arcangeli
2008-04-07 13:55       ` Peter Zijlstra
2008-04-07 13:55         ` [ofa-general] " Peter Zijlstra
2008-04-07 19:02       ` Jeremy Fitzhardinge
2008-04-07 19:02         ` [ofa-general] " Jeremy Fitzhardinge
2008-04-07 19:35         ` Andrea Arcangeli
2008-04-07 19:35           ` [ofa-general] " Andrea Arcangeli
2008-04-04 22:30 ` [patch 02/10] emm: notifier logic Christoph Lameter
2008-04-04 22:30   ` Christoph Lameter
2008-04-05  0:57   ` Andrea Arcangeli
2008-04-05  0:57     ` [ofa-general] " Andrea Arcangeli
2008-04-07  5:48     ` Christoph Lameter
2008-04-07  5:48       ` [ofa-general] " Christoph Lameter
2008-04-07  6:06       ` Andrea Arcangeli [this message]
2008-04-07  6:06         ` Andrea Arcangeli
2008-04-07  6:20         ` Christoph Lameter
2008-04-07  6:20           ` Christoph Lameter
2008-04-07  7:13           ` Andrea Arcangeli
2008-04-07  7:13             ` [ofa-general] " Andrea Arcangeli
2008-04-08 20:23             ` Christoph Lameter
2008-04-08 20:23               ` Christoph Lameter
2008-04-08 20:23               ` [ofa-general] " Christoph Lameter
2008-04-09 14:29               ` Andrea Arcangeli
2008-04-09 14:29                 ` Andrea Arcangeli
2008-04-09 14:29                 ` [ofa-general] " Andrea Arcangeli
2008-04-04 22:30 ` [patch 03/10] emm: Move tlb flushing into free_pgtables Christoph Lameter
2008-04-04 22:30   ` Christoph Lameter
2008-04-04 22:30 ` [patch 04/10] emm: Convert i_mmap_lock to i_mmap_sem Christoph Lameter
2008-04-04 22:30   ` [ofa-general] " Christoph Lameter
2008-04-04 22:30 ` [patch 05/10] emm: Remove tlb pointer from the parameters of unmap vmas Christoph Lameter
2008-04-04 22:30   ` Christoph Lameter
2008-04-04 22:30 ` [patch 06/10] emm: Convert anon_vma lock to rw_sem and refcount Christoph Lameter
2008-04-04 22:30   ` [ofa-general] " Christoph Lameter
2008-04-04 22:30 ` [patch 07/10] xpmem: This patch exports zap_page_range as it is needed by XPMEM Christoph Lameter
2008-04-04 22:30   ` Christoph Lameter
2008-04-04 22:30 ` [patch 08/10] xpmem: Locking rules for taking multiple mmap_sem locks Christoph Lameter
2008-04-04 22:30   ` Christoph Lameter
2008-04-04 22:30 ` [patch 09/10] xpmem: The device driver Christoph Lameter
2008-04-04 22:30   ` Christoph Lameter
2008-04-04 22:30 ` [patch 10/10] xpmem: Simple example Christoph Lameter
2008-04-04 22:30   ` [ofa-general] " Christoph Lameter

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=20080407060602.GE9309@duo.random \
    --to=andrea@qumranet.com \
    --cc=a.p.zijlstra@chello.nl \
    --cc=clameter@sgi.com \
    --cc=general@lists.openfabrics.org \
    --cc=holt@sgi.com \
    --cc=kvm-devel@lists.sourceforge.net \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=paulmck@linux.vnet.ibm.com \
    --cc=steiner@sgi.com \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.