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 <wsw9603@163.com>
Reviewed-by: Xu Xin <xu.xin16@zte.com.cn>
Acked-by: David Hildenbrand (Arm) <david@kernel.org>
Cc: Chengming Zhou <chengming.zhou@linux.dev>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
This commit is contained in:
Wang Wensheng 2026-07-26 21:35:01 +08:00 committed by Andrew Morton
parent 41f2c0f716
commit 6be12ddb52

View File

@ -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;