Linux-mm Archive on lore.kernel.org
 help / color / Atom feed
* [PATCH 1/2] mm/swapfile.c: simplify the calculation of n_goal
@ 2020-03-25 22:03 Wei Yang
  2020-03-25 22:03 ` [PATCH 2/2] mm/swapfile.c: remove the extra check in scan_swap_map_slots() Wei Yang
  0 siblings, 1 reply; 2+ messages in thread
From: Wei Yang @ 2020-03-25 22:03 UTC (permalink / raw)
  To: akpm; +Cc: linux-mm, linux-kernel, Wei Yang

Use min3() to simplify the comparison and make it more self-explaining.

Signed-off-by: Wei Yang <richard.weiyang@gmail.com>
---
 mm/swapfile.c | 6 +-----
 1 file changed, 1 insertion(+), 5 deletions(-)

diff --git a/mm/swapfile.c b/mm/swapfile.c
index 2c33ff456ed5..85b151d73128 100644
--- a/mm/swapfile.c
+++ b/mm/swapfile.c
@@ -1004,11 +1004,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);
 
-- 
2.23.0



^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, back to index

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-03-25 22:03 [PATCH 1/2] mm/swapfile.c: simplify the calculation of n_goal Wei Yang
2020-03-25 22:03 ` [PATCH 2/2] mm/swapfile.c: remove the extra check in scan_swap_map_slots() Wei Yang

Linux-mm Archive on lore.kernel.org

Archives are clonable:
	git clone --mirror https://lore.kernel.org/linux-mm/0 linux-mm/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 linux-mm linux-mm/ https://lore.kernel.org/linux-mm \
		linux-mm@kvack.org
	public-inbox-index linux-mm

Example config snippet for mirrors

Newsgroup available over NNTP:
	nntp://nntp.lore.kernel.org/org.kvack.linux-mm


AGPL code for this site: git clone https://public-inbox.org/public-inbox.git