[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <4BEB2923.8030200@redhat.com>
Date: Wed, 12 May 2010 18:18:11 -0400
From: Rik van Riel <riel@...hat.com>
To: Linus Torvalds <torvalds@...ux-foundation.org>
CC: Andrew Morton <akpm@...ux-foundation.org>,
Mel Gorman <mel@....ul.ie>,
Andrea Arcangeli <aarcange@...hat.com>,
Minchan Kim <minchan.kim@...il.com>,
Linux-MM <linux-mm@...ck.org>,
KAMEZAWA Hiroyuki <kamezawa.hiroyu@...fujitsu.com>,
LKML <linux-kernel@...r.kernel.org>
Subject: Re: [PATCH 4/5] always lock the root (oldest) anon_vma
On 05/12/2010 05:55 PM, Linus Torvalds wrote:
> Wouldn't it be sufficient to do
>
> if (atomic_dec_and_test(&anon_vma->ksm_refcount)) {
> anon_vma_lock(anon_vma);
>
> instead? The "atomic_dec_and_lock()" semantics are _much_ stricter than a
> regular "decrement and test and then lock", and that strictness means that
> it's way more complicated and expensive. So if you don't need the
> semantics, you shouldn't use them.
I suspect the atomic_dec_and_lock in the KVM code is being used
to prevent the following race:
1) KSM code reduces the refcount to 0
2) munmap on other CPU frees the anon_vma
3) KSM code takes the anon_vma lock,
which now lives in freed memory
Am I totally confused by this and can we use a nicer approach?
--
All rights reversed
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Powered by blists - more mailing lists