diff options
author | Wei Yang <richard.weiyang@gmail.com> | 2020-06-02 07:48:55 +0300 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2020-06-02 20:59:08 +0300 |
commit | 08d3090fc8dadd7b726dbda99d1baa39382c3f2c (patch) | |
tree | 013385473643942fa98063f9d16dfb3d2acfd79b /mm/swapfile.c | |
parent | bd2d18da4a4f182c3627a74dc768bd437e64c582 (diff) | |
download | linux-08d3090fc8dadd7b726dbda99d1baa39382c3f2c.tar.xz |
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 <richard.weiyang@gmail.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Reviewed-by: Andrew Morton <akpm@linux-foundation.org>
Cc: Hugh Dickins <hughd@google.com>
Link: http://lkml.kernel.org/r/20200325220309.9803-1-richard.weiyang@gmail.com
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'mm/swapfile.c')
-rw-r--r-- | mm/swapfile.c | 6 |
1 files changed, 1 insertions, 5 deletions
diff --git a/mm/swapfile.c b/mm/swapfile.c index f3af9901d8cd..f3b0a2c4972a 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); |