* [PATCH] mm: swap: calculate pages via roundup() in __swapin_nr_pages()
@ 2024-04-08 11:12 Zhaoyu Liu
0 siblings, 0 replies; only message in thread
From: Zhaoyu Liu @ 2024-04-08 11:12 UTC (permalink / raw)
To: liuzhaoyu.zackary; +Cc: linux-kernel
Use roundup() to replace while&shift. When the "pages" is large,
using roundup() will be faster than while&shift.
Signed-off-by: Zhaoyu Liu <liuzhaoyu.zackary@bytedance.com>
---
mm/swap_state.c | 8 ++------
1 file changed, 2 insertions(+), 6 deletions(-)
diff --git a/mm/swap_state.c b/mm/swap_state.c
index 642c30d8376c..d34dc95d0910 100644
--- a/mm/swap_state.c
+++ b/mm/swap_state.c
@@ -590,12 +590,8 @@ static unsigned int __swapin_nr_pages(unsigned long prev_offset,
*/
if (offset != prev_offset + 1 && offset != prev_offset - 1)
pages = 1;
- } else {
- unsigned int roundup = 4;
- while (roundup < pages)
- roundup <<= 1;
- pages = roundup;
- }
+ } else
+ pages = roundup(pages, 4);
if (pages > max_pages)
pages = max_pages;
--
2.25.1
^ permalink raw reply related [flat|nested] only message in thread
only message in thread, other threads:[~2024-04-08 11:12 UTC | newest]
Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-04-08 11:12 [PATCH] mm: swap: calculate pages via roundup() in __swapin_nr_pages() Zhaoyu Liu
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox