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. Signed-off-by: Wang Wensheng --- mm/ksm.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mm/ksm.c b/mm/ksm.c index 7d5b76478f0b..5ed9db676b9f 100644 --- a/mm/ksm.c +++ b/mm/ksm.c @@ -2666,7 +2666,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; -- 2.43.0