提交 85c6e8dd 编写于 作者: A Andrea Arcangeli 提交者: Linus Torvalds

ksm: use find_mergeable_vma in try_to_merge_with_ksm_page

Doing the VM_MERGEABLE check after the page == kpage check won't provide
any meaningful benefit.  The !vma->anon_vma check of find_mergeable_vma is
the only superfluous bit in using find_mergeable_vma because the !PageAnon
check of try_to_merge_one_page() implicitly checks for that, but it still
looks cleaner to share the same find_mergeable_vma().
Signed-off-by: NAndrea Arcangeli <aarcange@redhat.com>
Acked-by: NHugh Dickins <hughd@google.com>
Cc: Petr Holasek <pholasek@redhat.com>
Signed-off-by: NAndrew Morton <akpm@linux-foundation.org>
Signed-off-by: NLinus Torvalds <torvalds@linux-foundation.org>
上级 98666f8a
...@@ -1021,8 +1021,6 @@ static int try_to_merge_one_page(struct vm_area_struct *vma, ...@@ -1021,8 +1021,6 @@ static int try_to_merge_one_page(struct vm_area_struct *vma,
if (page == kpage) /* ksm page forked */ if (page == kpage) /* ksm page forked */
return 0; return 0;
if (!(vma->vm_flags & VM_MERGEABLE))
goto out;
if (PageTransCompound(page) && page_trans_compound_anon_split(page)) if (PageTransCompound(page) && page_trans_compound_anon_split(page))
goto out; goto out;
BUG_ON(PageTransCompound(page)); BUG_ON(PageTransCompound(page));
...@@ -1087,10 +1085,8 @@ static int try_to_merge_with_ksm_page(struct rmap_item *rmap_item, ...@@ -1087,10 +1085,8 @@ static int try_to_merge_with_ksm_page(struct rmap_item *rmap_item,
int err = -EFAULT; int err = -EFAULT;
down_read(&mm->mmap_sem); down_read(&mm->mmap_sem);
if (ksm_test_exit(mm)) vma = find_mergeable_vma(mm, rmap_item->address);
goto out; if (!vma)
vma = find_vma(mm, rmap_item->address);
if (!vma || vma->vm_start > rmap_item->address)
goto out; goto out;
err = try_to_merge_one_page(vma, page, kpage); err = try_to_merge_one_page(vma, page, kpage);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册