Skip to contentSkip to conversation

mm/slub: clamp slab_min_order to MAX_PAGE_ORDER

PATCH In review Sang-Heon Jeon 3 participants 4 messages Oct 11 – Oct 12

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH v2 1/1 mm/slub: clamp slab_min_order to MAX_PAGE_ORDER

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

---
Changes from v1 [1]
- Change fixes tag to 81819f0fc828 ("SLUB core")
- Remove stable tag

[1] https://lore.kernel.org/all/[email protected]/#t

---
 mm/slub.c | 2 ++
 1 file changed, 2 insertions(+)
mm/slub.c +2 -0
index 1559cbace469..8400df7c222e 100644
@@ -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

Signature · 1 line
2.43.0
#1 lore raw
Quoted 6 lines · Sang-Heon Jeon

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.

Quoted 7 lines

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

Hi,

this is effectively part of my bigger refactor here:

https://lore.kernel.org/linux-mm/[email protected]/

Thanks,
Vlastimil

Quoted 25 lines

---
Changes from v1 [1]
- Change fixes tag to 81819f0fc828 ("SLUB core")
- Remove stable tag

[1] https://lore.kernel.org/all/[email protected]/#t

---
 mm/slub.c | 2 ++
 1 file changed, 2 insertions(+)
mm/slub.c +2 -0
index 1559cbace469..8400df7c222e 100644
@@ -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 lore raw

Hi, Vlastimil

2026년 10월 12일 (월) 오후 5:23, Vlastimil Babka (SUSE) <[email protected]>님이 작성:

Quoted 13 lines · Sang-Heon Jeon
Quoted 11 lines

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.

Quoted 8 lines
Quoted 2 lines
Fixes 81819f0fc828 ("SLUB core")

Hi,

this is effectively part of my bigger refactor here:

https://lore.kernel.org/linux-mm/[email protected]/

Thanks for sharing the patchset. Then I'll happily drop this patch and look forward to it :)

Quoted 21 lines

Thanks,
Vlastimil

Quoted 18 lines

---
Changes from v1 [1]
- Change fixes tag to 81819f0fc828 ("SLUB core")
- Remove stable tag

[1] https://lore.kernel.org/all/[email protected]/#t

---
 mm/slub.c | 2 ++
 1 file changed, 2 insertions(+)
mm/slub.c +0 -0
index 1559cbace469..8400df7c222e 100644
@@ -8354,6 +8354,8 @@ static int __init setup_slub_min_order(const char *str, const struct kernel_para
      if (ret)
              return ret;
 
Quoted 8 lines
Quoted 7 lines
mm/slub.c +2 -0
+     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

Best regards,
Sang-Heon Jeon

maintainer
#3 lore raw
In reply to Vlastimil Babka (SUSE)
Quoted 10 lines · Vlastimil Babka (SUSE)
Quoted 9 lines · Sang-Heon Jeon

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

Quoted 8 lines
Quoted 4 lines

So clamp slab_min_order to MAX_PAGE_ORDER as well.

Fixes 81819f0fc828 ("SLUB core")

Hi,

this is effectively part of my bigger refactor here:

Ouch, I missed that point!

Quoted 1 line

https://lore.kernel.org/linux-mm/[email protected]/

Looking forward to seeing further updates on this ... (and hopefully do more review)

Signature · 2 lines
Cheers,
Harry / Hyeonggon