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]
Message-ID: <20251210002629.34448-1-haoli.tcs@gmail.com>
Date: Wed, 10 Dec 2025 08:26:31 +0800
From: Hao Li <haolee.swjtu@...il.com>
To: vbabka@...e.cz, akpm@...ux-foundation.org, harry.yoo@...cle.com, 
	cl@...two.org, rientjes@...gle.com, roman.gushchin@...ux.dev, 
	linux-mm@...ck.org, linux-kernel@...r.kernel.org, haolee.swjtu@...il.com
Cc: cl@...two.org, rientjes@...gle.com, roman.gushchin@...ux.dev, 
	linux-mm@...ck.org, linux-kernel@...r.kernel.org, Hao Li <haolee.swjtu@...il.com>
Subject: [PATCH v2] slub: keep empty main sheaf as spare in
 __pcs_replace_empty_main()

From: Hao Li <haolee.swjtu@...il.com>

When __pcs_replace_empty_main() fails to obtain a full sheaf directly
from the barn, it may either:

  - Refill an empty sheaf obtained via barn_get_empty_sheaf(), or
  - Allocate a brand new full sheaf via alloc_full_sheaf().

After reacquiring the per-CPU lock, if pcs->main is still empty and
pcs->spare is NULL, the current code donates the empty main sheaf to
the barn via barn_put_empty_sheaf() and installs the full sheaf as
pcs->main, leaving pcs->spare unpopulated.

Instead, keep the existing empty main sheaf locally as the spare:

  pcs->spare = pcs->main;
  pcs->main = full;

This populates pcs->spare earlier, which can reduce future barn traffic.

Suggested-by: Vlastimil Babka <vbabka@...e.cz>
Signed-off-by: Hao Li <haolee.swjtu@...il.com>
---

The Gmail account(haoli.tcs) I used to send v1 of the patch has been
restricted from sending emails for unknown reasons, so I'm sending v2
from this address instead. Thanks.

 mm/slub.c | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/mm/slub.c b/mm/slub.c
index a0b905c2a557..a3e73ebb0cc8 100644
--- a/mm/slub.c
+++ b/mm/slub.c
@@ -5077,6 +5077,11 @@ __pcs_replace_empty_main(struct kmem_cache *s, struct slub_percpu_sheaves *pcs,
 	 */
 
 	if (pcs->main->size == 0) {
+		if (!pcs->spare) {
+			pcs->spare = pcs->main;
+			pcs->main = full;
+			return pcs;
+		}
 		barn_put_empty_sheaf(barn, pcs->main);
 		pcs->main = full;
 		return pcs;
-- 
2.50.1


Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ