Linux-mm Archive on lore.kernel.org
 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

* Re: [PATCH v2] mm/slub: clamp slab_min_order to MAX_PAGE_ORDER
  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
  0 siblings, 2 replies; 4+ messages in thread
From: Vlastimil Babka (SUSE) @ 2026-10-12  8:23 UTC (permalink / raw)
  To: Sang-Heon Jeon, Andrew Morton, Harry Yoo
  Cc: Christoph Lameter, David Rientjes, Hao Li, linux-mm,
	Roman Gushchin

On 10/11/26 03:48, Sang-Heon Jeon wrote:
> 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>

Hi,

this is effectively part of my bigger refactor here:

https://lore.kernel.org/linux-mm/20260923-slub_tiny_rework-v1-1-a0e66d536eb5@kernel.org/

Thanks,
Vlastimil

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



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

* Re: [PATCH v2] mm/slub: clamp slab_min_order to MAX_PAGE_ORDER
  2026-10-12  8:23 ` Vlastimil Babka (SUSE)
@ 2026-10-12 13:21   ` Sang-Heon Jeon
  2026-10-12 14:09   ` Harry Yoo
  1 sibling, 0 replies; 4+ messages in thread
From: Sang-Heon Jeon @ 2026-10-12 13:21 UTC (permalink / raw)
  To: Vlastimil Babka (SUSE)
  Cc: Andrew Morton, Harry Yoo, Christoph Lameter, David Rientjes,
	Hao Li, linux-mm, Roman Gushchin

Hi, Vlastimil

2026년 10월 12일 (월) 오후 5:23, Vlastimil Babka (SUSE) <vbabka@kernel.org>님이 작성:
>
> On 10/11/26 03:48, Sang-Heon Jeon wrote:
> > 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>
>
> Hi,
>
> this is effectively part of my bigger refactor here:
>
> https://lore.kernel.org/linux-mm/20260923-slub_tiny_rework-v1-1-a0e66d536eb5@kernel.org/

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

> Thanks,
> Vlastimil
>
> > ---
> > 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
>

Best regards,
Sang-Heon Jeon


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

* Re: [PATCH v2] mm/slub: clamp slab_min_order to MAX_PAGE_ORDER
  2026-10-12  8:23 ` Vlastimil Babka (SUSE)
  2026-10-12 13:21   ` Sang-Heon Jeon
@ 2026-10-12 14:09   ` Harry Yoo
  1 sibling, 0 replies; 4+ messages in thread
From: Harry Yoo @ 2026-10-12 14:09 UTC (permalink / raw)
  To: Vlastimil Babka (SUSE)
  Cc: Sang-Heon Jeon, Andrew Morton, Christoph Lameter, David Rientjes,
	Hao Li, linux-mm, Roman Gushchin

On Mon, Oct 12, 2026 at 10:23:16AM +0200, Vlastimil Babka (SUSE) wrote:
> On 10/11/26 03:48, Sang-Heon Jeon wrote:
> > 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>
> 
> Hi,
> 
> this is effectively part of my bigger refactor here:

Ouch, I missed that point!

> https://lore.kernel.org/linux-mm/20260923-slub_tiny_rework-v1-1-a0e66d536eb5@kernel.org/

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

-- 
Cheers,
Harry / Hyeonggon


^ permalink raw reply	[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