diff mbox series

[4/6] mm, hwpoison: avoid unneeded page_mapped_in_vma() overhead in collect_procs_anon()

Message ID 20220830123604.25763-5-linmiaohe@huawei.com (mailing list archive)
State New
Headers show
Series A few cleanup patches for memory-failure | expand

Commit Message

Miaohe Lin Aug. 30, 2022, 12:36 p.m. UTC
If vma->vm_mm != t->mm, there's no need to call page_mapped_in_vma() as
add_to_kill() won't be called in this case. Move up the mm check to avoid
possible unneeded calling to page_mapped_in_vma().

Signed-off-by: Miaohe Lin <linmiaohe@huawei.com>
---
 mm/memory-failure.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

Comments

HORIGUCHI NAOYA(堀口 直也) Sept. 5, 2022, 5:24 a.m. UTC | #1
On Tue, Aug 30, 2022 at 08:36:02PM +0800, Miaohe Lin wrote:
> If vma->vm_mm != t->mm, there's no need to call page_mapped_in_vma() as
> add_to_kill() won't be called in this case. Move up the mm check to avoid
> possible unneeded calling to page_mapped_in_vma().
> 
> Signed-off-by: Miaohe Lin <linmiaohe@huawei.com>

Acked-by: Naoya Horiguchi <naoya.horiguchi@nec.com>
diff mbox series

Patch

diff --git a/mm/memory-failure.c b/mm/memory-failure.c
index 69c4d1b48ad6..904c2b6284a4 100644
--- a/mm/memory-failure.c
+++ b/mm/memory-failure.c
@@ -521,11 +521,11 @@  static void collect_procs_anon(struct page *page, struct list_head *to_kill,
 		anon_vma_interval_tree_foreach(vmac, &av->rb_root,
 					       pgoff, pgoff) {
 			vma = vmac->vma;
+			if (vma->vm_mm != t->mm)
+				continue;
 			if (!page_mapped_in_vma(page, vma))
 				continue;
-			if (vma->vm_mm == t->mm)
-				add_to_kill(t, page, FSDAX_INVALID_PGOFF, vma,
-					    to_kill);
+			add_to_kill(t, page, FSDAX_INVALID_PGOFF, vma, to_kill);
 		}
 	}
 	read_unlock(&tasklist_lock);