Re: [PATCH] mm: fix hang on anon_vma->root->lock

Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]
From: Hugh Dickins
Date: Friday, August 27, 2010 - 1:14 pm

On Fri, Aug 27, 2010 at 12:29 PM, Christoph Lameter <cl@linux.com> wrote:

Nothing ensures that the root pointer was not changed after the
ACCESS_ONCE, that's exactly why we use ACCESS_ONCE there: once we've
got the lock and realize that what we've locked may not be what we
wanted (or may change from what we were wanting at any moment, the
page no longer being mapped there - but in that case we no longer want
it), we have to be sure to unlock the one we locked, rather than the
one which anon_vma->root might subsequently point to.

(Umm, maybe I'm not the clearest of explainers, sorry!  If you get my
point, fine; if it's gibberish to you, please ask me to try again.)


There's no lock (other than RCU's read "lock")  taken before the
original mapped check, and that's important, otherwise our attempt to
lock might actually spinon or corrupt something that was long ago an
anon_vma.  But we do take the anon_vma->root->lock before the second
mapped check which I added.  If the page is still mapped at the point
of that second check, then we know that we got the right anon_vma,
that the page might be mapped in it, and anon_vma->root is not going
to change underneath us before the page_unlock_anon_vma().  (The page
may get unmapped at any time, the lock does not protect against that;
but if it's still mapped once we hold the lock, free_pgtables() cannot
free the anon_vma until we're done.)

Hugh
--
Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]

Messages in current thread:
[PATCH] mm: fix hang on anon_vma-&gt;root-&gt;lock, Hugh Dickins, (Wed Aug 25, 11:12 pm)
Re: [PATCH] mm: fix hang on anon_vma-&gt;root-&gt;lock, David Miller, (Wed Aug 25, 11:41 pm)
Re: [PATCH] mm: fix hang on anon_vma-&gt;root-&gt;lock, Hugh Dickins, (Thu Aug 26, 3:54 am)
Re: [PATCH] mm: fix hang on anon_vma-&gt;root-&gt;lock, Rik van Riel, (Thu Aug 26, 6:32 am)
Re: [PATCH] mm: fix hang on anon_vma-&gt;root-&gt;lock, David Miller, (Thu Aug 26, 12:00 pm)
Re: [PATCH] mm: fix hang on anon_vma-&gt;root-&gt;lock, Andrea Arcangeli, (Thu Aug 26, 4:50 pm)
Re: [PATCH] mm: fix hang on anon_vma-&gt;root-&gt;lock, Andrea Arcangeli, (Thu Aug 26, 5:19 pm)
Re: [PATCH] mm: fix hang on anon_vma-&gt;root-&gt;lock, Hugh Dickins, (Thu Aug 26, 6:43 pm)
Re: [PATCH] mm: fix hang on anon_vma-&gt;root-&gt;lock, Andrea Arcangeli, (Fri Aug 27, 2:55 am)
Re: [PATCH] mm: fix hang on anon_vma-&gt;root-&gt;lock, Hugh Dickins, (Fri Aug 27, 9:43 am)
Re: [PATCH] mm: fix hang on anon_vma-&gt;root-&gt;lock, Christoph Lameter, (Fri Aug 27, 10:13 am)
Re: [PATCH] mm: fix hang on anon_vma-&gt;root-&gt;lock, Hugh Dickins, (Fri Aug 27, 10:55 am)
Re: [PATCH] mm: fix hang on anon_vma-&gt;root-&gt;lock, Christoph Lameter, (Fri Aug 27, 12:29 pm)
Re: [PATCH] mm: fix hang on anon_vma->root->lock, Hugh Dickins, (Fri Aug 27, 1:14 pm)
Re: [PATCH] mm: fix hang on anon_vma-&gt;root-&gt;lock, Christoph Lameter, (Fri Aug 27, 1:56 pm)
Re: [PATCH] mm: fix hang on anon_vma-&gt;root-&gt;lock, Hugh Dickins, (Fri Aug 27, 2:28 pm)
Re: [PATCH] mm: fix hang on anon_vma-&gt;root-&gt;lock, Hugh Dickins, (Fri Aug 27, 2:33 pm)
Re: [PATCH] mm: fix hang on anon_vma-&gt;root-&gt;lock, Christoph Lameter, (Fri Aug 27, 4:06 pm)
Re: [PATCH] mm: fix hang on anon_vma-&gt;root-&gt;lock, Hugh Dickins, (Fri Aug 27, 6:07 pm)
Re: [PATCH] mm: fix hang on anon_vma-&gt;root-&gt;lock, Christoph Lameter, (Fri Aug 27, 7:47 pm)
Re: [PATCH] mm: fix hang on anon_vma-&gt;root-&gt;lock, Peter Zijlstra, (Sat Aug 28, 3:17 am)
Re: [PATCH] mm: fix hang on anon_vma-&gt;root-&gt;lock, Andrea Arcangeli, (Sat Aug 28, 8:54 am)