From: Baoquan He Date: Wed, 5 Feb 2025 09:27:11 +0000 (+0800) Subject: mm/swap_state.c: optimize the code in clear_shadow_from_swap_cache() X-Git-Tag: v6.15-rc1~81^2~377 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=cd57a3fb37f91ef6106bc970d2b5c5878d3b5627;p=thirdparty%2Flinux.git mm/swap_state.c: optimize the code in clear_shadow_from_swap_cache() Use ALIGN to achieve the same effect and simplify the code. Link: https://lkml.kernel.org/r/20250205092721.9395-3-bhe@redhat.com Signed-off-by: Baoquan He Cc: Chris Li Cc: Kairui Song Signed-off-by: Andrew Morton --- diff --git a/mm/swap_state.c b/mm/swap_state.c index aabde86d1f47e..8a84371980e94 100644 --- a/mm/swap_state.c +++ b/mm/swap_state.c @@ -270,9 +270,7 @@ void clear_shadow_from_swap_cache(int type, unsigned long begin, xa_unlock_irq(&address_space->i_pages); /* search the next swapcache until we meet end */ - curr >>= SWAP_ADDRESS_SPACE_SHIFT; - curr++; - curr <<= SWAP_ADDRESS_SPACE_SHIFT; + curr = ALIGN((curr + 1), SWAP_ADDRESS_SPACE_PAGES); if (curr > end) break; }