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>] [thread-next>] [day] [month] [year] [list]
Message-Id: <1763965157-58413-1-git-send-email-junchuan.tzh@antgroup.com>
Date: Mon, 24 Nov 2025 14:19:17 +0800
From: Zhiheng Tao <junchuan.tzh@...group.com>
To: akpm@...ux-foundation.org,
	david@...nel.org,
	lorenzo.stoakes@...cle.com
Cc: ziy@...dia.com,
	baolin.wang@...ux.alibaba.com,
	Liam.Howlett@...cle.com,
	npache@...hat.com,
	ryan.roberts@....com,
	dev.jain@....com,
	baohua@...nel.org,
	lance.yang@...ux.dev,
	shy828301@...il.com,
	zokeefe@...gle.com,
	peterx@...hat.com,
	linux-mm@...ck.org,
	linux-kernel@...r.kernel.org,
	Zhiheng Tao <junchuan.tzh@...group.com>
Subject: [PATCH] mm/khugepaged: Fix skipping of alloc sleep after second failure

In khugepaged_do_scan(), two consecutive allocation failures cause
the logic to skip the dedicated 60s throttling sleep
(khugepaged_alloc_sleep_millisecs), forcing a fallback to the
shorter 10s scanning interval via the outer loop

Since fragmentation is unlikely to resolve in 10s, this results in
wasted CPU cycles on immediate retries.

Reorder the failure logic to ensure khugepaged_alloc_sleep() is
always called on each allocation failure.

Fixes: c6a7f445a272 ("mm: khugepaged: don't carry huge page to the next loop for !CONFIG_NUMA")
Signed-off-by: Zhiheng Tao <junchuan.tzh@...group.com>
---
 mm/khugepaged.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/mm/khugepaged.c b/mm/khugepaged.c
index abe54f0..c3f9721 100644
--- a/mm/khugepaged.c
+++ b/mm/khugepaged.c
@@ -2562,12 +2562,12 @@ static void khugepaged_do_scan(struct collapse_control *cc)
 		if (result == SCAN_ALLOC_HUGE_PAGE_FAIL) {
 			/*
 			 * If fail to allocate the first time, try to sleep for
-			 * a while.  When hit again, cancel the scan.
+			 * a while.  When hit again, sleep and cancel the scan.
 			 */
+			khugepaged_alloc_sleep();
 			if (!wait)
 				break;
 			wait = false;
-			khugepaged_alloc_sleep();
 		}
 	}
 }
-- 
1.8.3.1


Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ