From 6be12ddb52f9a3fa62f078a0b61573416de5ff5c Mon Sep 17 00:00:00 2001 From: Wang Wensheng Date: Sun, 26 Jul 2026 21:35:01 +0800 Subject: [PATCH] ksm: stop iterating VMAs when ksm_test_exit returns true In scan_get_next_rmap_item() the break statement only exits the inner while loop, leaving remaining VMAs to be iterated even if ksm_test_exit() returns true. Replace it with a goto statement to avoid the unnecessary work. Link: https://lore.kernel.org/20260726133501.504048-1-wsw9603@163.com Signed-off-by: Wang Wensheng Reviewed-by: Xu Xin Acked-by: David Hildenbrand (Arm) Cc: Chengming Zhou Signed-off-by: Andrew Morton --- mm/ksm.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mm/ksm.c b/mm/ksm.c index 47006f494fcb..b4142746777e 100644 --- a/mm/ksm.c +++ b/mm/ksm.c @@ -2700,7 +2700,7 @@ static struct ksm_rmap_item *scan_get_next_rmap_item(struct page **page) struct folio *folio; if (ksm_test_exit(mm)) - break; + goto no_vmas; int found;