mm/slub: clamp slab_min_order to MAX_PAGE_ORDER
Subsystems (2)
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.
---
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
@@ -8354,6 +8354,8 @@ static int __init setup_slub_min_order(const char *str, const struct kernel_paraif (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
Vlastimil Babka (SUSE)
maintainerQuoted 6 lines · Sang-Heon Jeon
setup_slub_max_order()clampsslab_max_ordertoMAX_PAGE_ORDER, butsetup_slub_min_order()has no such clamp.The buddy allocator cannot allocate more than 2^MAX_PAGE_ORDER pages at once, so
slab_min_orderabove it makes no sense.
Quoted 7 lines
If
slab_min_orderis set aboveMAX_PAGE_ORDER, it can even panic at boot or invoke undefined behavior inorder_objects().So clamp
slab_min_ordertoMAX_PAGE_ORDERas well.Fixes 81819f0fc828 ("SLUB core")Signed-off-by Sang-Heon Jeon <[email protected]>
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 to81819f0fc828("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@@ -8354,6 +8354,8 @@ static int __init setup_slub_min_order(const char *str, const struct kernel_paraif (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
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()clampsslab_max_ordertoMAX_PAGE_ORDER, butsetup_slub_min_order()has no such clamp.The buddy allocator cannot allocate more than 2^MAX_PAGE_ORDER pages at once, so
slab_min_orderabove it makes no sense.If
slab_min_orderis set aboveMAX_PAGE_ORDER, it can even panic at boot or invoke undefined behavior inorder_objects().So clamp
slab_min_ordertoMAX_PAGE_ORDERas well.
Quoted 8 lines
Quoted 2 lines
Fixes 81819f0fc828 ("SLUB core")Signed-off-by Sang-Heon Jeon <[email protected]>Hi,
this is effectively part of my bigger refactor here:
Thanks for sharing the patchset. Then I'll happily drop this patch and look forward to it :)
Quoted 21 lines
Thanks,
VlastimilQuoted 18 lines
---
Changes from v1 [1]
- Change fixes tag to81819f0fc828("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@@ -8354,6 +8354,8 @@ static int __init setup_slub_min_order(const char *str, const struct kernel_paraif (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
Harry Yoo
maintainerQuoted 10 lines · Vlastimil Babka (SUSE)
Quoted 9 lines · Sang-Heon Jeon
setup_slub_max_order()clampsslab_max_ordertoMAX_PAGE_ORDER, butsetup_slub_min_order()has no such clamp.The buddy allocator cannot allocate more than 2^MAX_PAGE_ORDER pages at once, so
slab_min_orderabove it makes no sense.If
slab_min_orderis set aboveMAX_PAGE_ORDER, it can even panic at boot or invoke undefined behavior inorder_objects().
Quoted 8 lines
Quoted 4 lines
So clamp
slab_min_ordertoMAX_PAGE_ORDERas well.Fixes 81819f0fc828 ("SLUB core")Signed-off-by Sang-Heon Jeon <[email protected]>Hi,
this is effectively part of my bigger refactor here:
Ouch, I missed that point!
Quoted 1 line
Looking forward to seeing further updates on this ... (and hopefully do more review)
Signature · 2 lines
Cheers, Harry / Hyeonggon