LKML Archive on lore.kernel.org
help / color / mirror / Atom feed
From: Hugh Dickins <hugh@veritas.com>
To: Oleg Nesterov <oleg@tv-sign.ru>
Cc: Andrew Morton <akpm@linux-foundation.org>,
"Paul E. McKenney" <paulmck@linux.vnet.ibm.com>,
Christoph Lameter <clameter@sgi.com>,
linux-kernel@vger.kernel.org
Subject: Re: [PATCH] adapt page_lock_anon_vma() to PREEMPT_RCU
Date: Wed, 28 Feb 2007 19:48:23 +0000 (GMT) [thread overview]
Message-ID: <Pine.LNX.4.64.0702281946140.5568@blonde.wat.veritas.com> (raw)
In-Reply-To: <20070225200621.GA2259@tv-sign.ru>
On Sun, 25 Feb 2007, Oleg Nesterov wrote:
> page_lock_anon_vma() uses spin_lock() to block RCU. This doesn't work with
> PREEMPT_RCU, we have to do rcu_read_lock() explicitely. Otherwise, it is
> theoretically possible that slab returns anon_vma's memory to the system
> before we do spin_unlock(&anon_vma->lock).
>
> Signed-off-by: Oleg Nesterov <oleg@tv-sign.ru>
Acked-by: Hugh Dickins <hugh@veritas.com>
Thanks for doing this, and sorry for my delay.
Hugh
>
> --- WQ/mm/rmap.c~ 2007-02-18 22:56:49.000000000 +0300
> +++ WQ/mm/rmap.c 2007-02-25 22:43:00.000000000 +0300
> @@ -183,7 +183,7 @@ void __init anon_vma_init(void)
> */
> static struct anon_vma *page_lock_anon_vma(struct page *page)
> {
> - struct anon_vma *anon_vma = NULL;
> + struct anon_vma *anon_vma;
> unsigned long anon_mapping;
>
> rcu_read_lock();
> @@ -195,9 +195,16 @@ static struct anon_vma *page_lock_anon_v
>
> anon_vma = (struct anon_vma *) (anon_mapping - PAGE_MAPPING_ANON);
> spin_lock(&anon_vma->lock);
> + return anon_vma;
> out:
> rcu_read_unlock();
> - return anon_vma;
> + return NULL;
> +}
> +
> +static void page_unlock_anon_vma(struct anon_vma *anon_vma)
> +{
> + spin_unlock(&anon_vma->lock);
> + rcu_read_unlock();
> }
>
> /*
> @@ -333,7 +340,8 @@ static int page_referenced_anon(struct p
> if (!mapcount)
> break;
> }
> - spin_unlock(&anon_vma->lock);
> +
> + page_unlock_anon_vma(anon_vma);
> return referenced;
> }
>
> @@ -809,7 +817,8 @@ static int try_to_unmap_anon(struct page
> !page_mapped(page))
> break;
> }
> - spin_unlock(&anon_vma->lock);
> +
> + page_unlock_anon_vma(anon_vma);
> return ret;
> }
>
>
prev parent reply other threads:[~2007-02-28 20:28 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2007-02-25 20:06 Oleg Nesterov
2007-02-27 20:25 ` Andrew Morton
2007-02-27 21:46 ` Oleg Nesterov
2007-02-27 23:13 ` Paul E. McKenney
2007-02-28 19:48 ` Hugh Dickins [this message]
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=Pine.LNX.4.64.0702281946140.5568@blonde.wat.veritas.com \
--to=hugh@veritas.com \
--cc=akpm@linux-foundation.org \
--cc=clameter@sgi.com \
--cc=linux-kernel@vger.kernel.org \
--cc=oleg@tv-sign.ru \
--cc=paulmck@linux.vnet.ibm.com \
--subject='Re: [PATCH] adapt page_lock_anon_vma() to PREEMPT_RCU' \
/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
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).