lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [day] [month] [year] [list]
Date: Mon, 8 Apr 2024 19:12:03 +0800
From: Zhaoyu Liu <liuzhaoyu.zackary@...edance.com>
To: liuzhaoyu.zackary@...edance.com
Cc: linux-kernel@...r.kernel.org
Subject: [PATCH] mm: swap: calculate pages via roundup() in
 __swapin_nr_pages()

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@...edance.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


Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ