hulk inclusion category: performance bugzilla: https://gitee.com/src-openeuler/kernel/issues/IBA1TU
--------------------------------
Check the anon_vma of pvma ahead to dup_mmap(), so we can avoid the function call overhead if the ctx is NULL.
The Unixbench single core process create has 2 ~ 3% improve with this and previous patch.
Signed-off-by: Jinjie Ruan ruanjinjie@huawei.com --- kernel/fork.c | 6 ++++-- mm/rmap.c | 4 ---- 2 files changed, 4 insertions(+), 6 deletions(-)
diff --git a/kernel/fork.c b/kernel/fork.c index 919ccd202698..3f3d15321e38 100644 --- a/kernel/fork.c +++ b/kernel/fork.c @@ -746,8 +746,10 @@ static __latent_entropy int dup_mmap(struct mm_struct *mm, * copy page for current vma. */ tmp->anon_vma = NULL; - } else if (anon_vma_fork(tmp, mpnt)) - goto fail_nomem_anon_vma_fork; + } else if (unlikely(mpnt->anon_vma)) { + if (anon_vma_fork(tmp, mpnt)) + goto fail_nomem_anon_vma_fork; + } vm_flags_clear(tmp, VM_LOCKED_MASK); /* * Copy/update hugetlb private vma information. diff --git a/mm/rmap.c b/mm/rmap.c index dbcdac9bb7a3..b533c613d515 100644 --- a/mm/rmap.c +++ b/mm/rmap.c @@ -337,10 +337,6 @@ int anon_vma_fork(struct vm_area_struct *vma, struct vm_area_struct *pvma) struct anon_vma *anon_vma; int error;
- /* Don't bother if the parent process has no anon_vma here. */ - if (!pvma->anon_vma) - return 0; - /* Drop inherited anon_vma, we'll reuse existing or allocate new. */ vma->anon_vma = NULL;