linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v2] mm/slub: clamp slab_min_order to MAX_PAGE_ORDER
@ 2026-10-11  1:48 Sang-Heon Jeon
  2026-10-12  8:23 ` Vlastimil Babka (SUSE)
  0 siblings, 1 reply; 4+ messages in thread
From: Sang-Heon Jeon @ 2026-10-11  1:48 UTC (permalink / raw)
  To: Andrew Morton, Harry Yoo, Vlastimil Babka
  Cc: Christoph Lameter, David Rientjes, Hao Li, linux-mm,
	Roman Gushchin

setup_slub_max_order() clamps slab_max_order to MAX_PAGE_ORDER, but
setup_slub_min_order() has no such clamp.

The buddy allocator cannot allocate more than 2^MAX_PAGE_ORDER pages
at once, so slab_min_order above it makes no sense.

If slab_min_order is set above MAX_PAGE_ORDER, it can even panic at
boot or invoke undefined behavior in order_objects().

So clamp slab_min_order to MAX_PAGE_ORDER as well.

Fixes: 81819f0fc828 ("SLUB core")
Signed-off-by: Sang-Heon Jeon <ekffu200098@gmail.com>
---
Changes from v1 [1]
- Change fixes tag to 81819f0fc828 ("SLUB core")
- Remove stable tag

[1] https://lore.kernel.org/all/20261007163403.1643768-1-ekffu200098@gmail.com/#t
---
 mm/slub.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/mm/slub.c b/mm/slub.c
index 1559cbace469..8400df7c222e 100644
--- a/mm/slub.c
+++ b/mm/slub.c
@@ -8354,6 +8354,8 @@ static int __init setup_slub_min_order(const char *str, const struct kernel_para
 	if (ret)
 		return ret;
 
+	slub_min_order = min_t(unsigned int, slub_min_order, MAX_PAGE_ORDER);
+
 	if (slub_min_order > slub_max_order)
 		slub_max_order = slub_min_order;
 

base-commit: d755441b7672c74f29d1241ffdd2b067ecab1ca0
-- 
2.43.0



^ permalink raw reply related	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2026-10-12 14:09 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-10-11  1:48 [PATCH v2] mm/slub: clamp slab_min_order to MAX_PAGE_ORDER Sang-Heon Jeon
2026-10-12  8:23 ` Vlastimil Babka (SUSE)
2026-10-12 13:21   ` Sang-Heon Jeon
2026-10-12 14:09   ` Harry Yoo

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).