[PATCH 4/4] mm/rmap.c: move anon_vma initialization code into anon_vma_ctor

Yuanhan Liu
2013-11-01T07:54:30Z

Cc: Ingo Molnar <mingo@kernel.org>
Cc: Linus Torvalds <torvalds@linux-foundation.org>
Cc: Andrew Morton <akpm@linux-foundation.org>
Cc: Rik van Riel <riel@redhat.com>
Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
Cc: Michel Lespinasse <walken@google.com>
Signed-off-by: Yuanhan Liu <yuanhan.liu@linux.intel.com>
---
mm/rmap.c | 23 +++++++++--------------
1 files changed, 9 insertions(+), 14 deletions(-)

diff --git a/mm/rmap.c b/mm/rmap.c
index 246b5fe..831dd4e 100644
--- a/mm/rmap.c
+++ b/mm/rmap.c
@@ -67,19 +67,7 @@ static struct kmem_cache *anon_vma_chain_cachep;

static inline struct anon_vma *anon_vma_alloc(void)
{
- struct anon_vma *anon_vma;
-
- anon_vma = kmem_cache_alloc(anon_vma_cachep, GFP_KERNEL);
- if (anon_vma) {
- atomic_set(&anon_vma->refcount, 1);
- /*
- * Initialise the anon_vma root to point to itself. If called
- * from fork, the root will be reset to the parents anon_vma.
- */
- anon_vma->root = anon_vma;
- }
-
- return anon_vma;
+ return kmem_cache_alloc(anon_vma_cachep, GFP_KERNEL);
}

static inline void anon_vma_free(struct anon_vma *anon_vma)
@@ -293,8 +281,15 @@ static void anon_vma_ctor(void *data)
struct anon_vma *anon_vma = data;

rwlock_init(&anon_vma->rwlock);
- atomic_set(&anon_vma->refcount, 0);
anon_vma->rb_root = RB_ROOT;
+
+ atomic_set(&anon_vma->refcount, 1);
+ /*
+ * Initialise the anon_vma root to point to itself. If called
+ * from fork, the root will be reset to the parents anon_vma.
+ */
+ anon_vma->root = anon_vma;
+
}

void __init anon_vma_init(void)
--
1.7.7.6