From: Wei Yang Date: Tue, 2 Jun 2020 04:48:55 +0000 (-0700) Subject: mm/swapfile.c: simplify the calculation of n_goal X-Git-Tag: v5.10.7~2505^2~64 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=08d3090fc8dadd7b726dbda99d1baa39382c3f2c;p=platform%2Fkernel%2Flinux-rpi.git mm/swapfile.c: simplify the calculation of n_goal Use min3() to simplify the comparison and make it more self-explaining. Signed-off-by: Wei Yang Signed-off-by: Andrew Morton Reviewed-by: Andrew Morton Cc: Hugh Dickins Link: http://lkml.kernel.org/r/20200325220309.9803-1-richard.weiyang@gmail.com Signed-off-by: Linus Torvalds --- diff --git a/mm/swapfile.c b/mm/swapfile.c index f3af990..f3b0a2c 100644 --- a/mm/swapfile.c +++ b/mm/swapfile.c @@ -994,11 +994,7 @@ int get_swap_pages(int n_goal, swp_entry_t swp_entries[], int entry_size) if (avail_pgs <= 0) goto noswap; - if (n_goal > SWAP_BATCH) - n_goal = SWAP_BATCH; - - if (n_goal > avail_pgs) - n_goal = avail_pgs; + n_goal = min3((long)n_goal, (long)SWAP_BATCH, avail_pgs); atomic_long_sub(n_goal * size, &nr_swap_pages);