mirror of
https://github.com/team-infusion-developers/android_kernel_samsung_msm8976.git
synced 2024-10-31 18:09:19 +00:00
rmap: anon_vma_prepare: Reduce code duplication by calling anon_vma_chain_link
Reduce code duplication by calling anon_vma_chain_link() from anon_vma_prepare(). Also move anon_vmal_chain_link() to a more suitable location in the file. Signed-off-by: Kautuk Consul <consul.kautuk@gmail.com> Acked-by: Peter Zijlstra <a.p.zijlstra@chello.nl> Cc: Hugh Dickins <hughd@google.com> Reviewed-by: KAMEZWA Hiroyuki <kamezawa.hiroyu@jp.fujitsu.com> Cc: Mel Gorman <mgorman@suse.de> Acked-by: David Rientjes <rientjes@google.com> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
This commit is contained in:
parent
28073b02bf
commit
6583a84304
1 changed files with 16 additions and 19 deletions
35
mm/rmap.c
35
mm/rmap.c
|
@ -120,6 +120,21 @@ static void anon_vma_chain_free(struct anon_vma_chain *anon_vma_chain)
|
||||||
kmem_cache_free(anon_vma_chain_cachep, anon_vma_chain);
|
kmem_cache_free(anon_vma_chain_cachep, anon_vma_chain);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void anon_vma_chain_link(struct vm_area_struct *vma,
|
||||||
|
struct anon_vma_chain *avc,
|
||||||
|
struct anon_vma *anon_vma)
|
||||||
|
{
|
||||||
|
avc->vma = vma;
|
||||||
|
avc->anon_vma = anon_vma;
|
||||||
|
list_add(&avc->same_vma, &vma->anon_vma_chain);
|
||||||
|
|
||||||
|
/*
|
||||||
|
* It's critical to add new vmas to the tail of the anon_vma,
|
||||||
|
* see comment in huge_memory.c:__split_huge_page().
|
||||||
|
*/
|
||||||
|
list_add_tail(&avc->same_anon_vma, &anon_vma->head);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* anon_vma_prepare - attach an anon_vma to a memory region
|
* anon_vma_prepare - attach an anon_vma to a memory region
|
||||||
* @vma: the memory region in question
|
* @vma: the memory region in question
|
||||||
|
@ -175,10 +190,7 @@ int anon_vma_prepare(struct vm_area_struct *vma)
|
||||||
spin_lock(&mm->page_table_lock);
|
spin_lock(&mm->page_table_lock);
|
||||||
if (likely(!vma->anon_vma)) {
|
if (likely(!vma->anon_vma)) {
|
||||||
vma->anon_vma = anon_vma;
|
vma->anon_vma = anon_vma;
|
||||||
avc->anon_vma = anon_vma;
|
anon_vma_chain_link(vma, avc, anon_vma);
|
||||||
avc->vma = vma;
|
|
||||||
list_add(&avc->same_vma, &vma->anon_vma_chain);
|
|
||||||
list_add_tail(&avc->same_anon_vma, &anon_vma->head);
|
|
||||||
allocated = NULL;
|
allocated = NULL;
|
||||||
avc = NULL;
|
avc = NULL;
|
||||||
}
|
}
|
||||||
|
@ -224,21 +236,6 @@ static inline void unlock_anon_vma_root(struct anon_vma *root)
|
||||||
mutex_unlock(&root->mutex);
|
mutex_unlock(&root->mutex);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void anon_vma_chain_link(struct vm_area_struct *vma,
|
|
||||||
struct anon_vma_chain *avc,
|
|
||||||
struct anon_vma *anon_vma)
|
|
||||||
{
|
|
||||||
avc->vma = vma;
|
|
||||||
avc->anon_vma = anon_vma;
|
|
||||||
list_add(&avc->same_vma, &vma->anon_vma_chain);
|
|
||||||
|
|
||||||
/*
|
|
||||||
* It's critical to add new vmas to the tail of the anon_vma,
|
|
||||||
* see comment in huge_memory.c:__split_huge_page().
|
|
||||||
*/
|
|
||||||
list_add_tail(&avc->same_anon_vma, &anon_vma->head);
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Attach the anon_vmas from src to dst.
|
* Attach the anon_vmas from src to dst.
|
||||||
* Returns 0 on success, -ENOMEM on failure.
|
* Returns 0 on success, -ENOMEM on failure.
|
||||||
|
|
Loading…
Reference in a new issue