From: Wei Yang <richard.weiyang@gmail.com>
To: akpm@linux-foundation.org
Cc: linux-mm@kvack.org, linux-kernel@vger.kernel.org,
Wei Yang <richard.weiyang@gmail.com>
Subject: [PATCH 1/2] mm/swapfile.c: simplify the calculation of n_goal
Date: Wed, 25 Mar 2020 22:03:08 +0000 [thread overview]
Message-ID: <20200325220309.9803-1-richard.weiyang@gmail.com> (raw)
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
next reply other threads:[~2020-03-25 22:03 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-03-25 22:03 Wei Yang [this message]
2020-03-25 22:03 ` [PATCH 2/2] mm/swapfile.c: remove the extra check in scan_swap_map_slots() Wei Yang
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20200325220309.9803-1-richard.weiyang@gmail.com \
--to=richard.weiyang@gmail.com \
--cc=akpm@linux-foundation.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).