* [PATCH] mm/slub: add sanity check for slub_min/max_order cmdline setup
@ 2023-09-20 7:44 Feng Tang
2023-09-20 9:25 ` Vlastimil Babka
0 siblings, 1 reply; 2+ messages in thread
From: Feng Tang @ 2023-09-20 7:44 UTC (permalink / raw)
To: Vlastimil Babka, Christoph Lameter, Andrew Morton, Pekka Enberg,
David Rientjes, Joonsoo Kim, Roman Gushchin, Hyeonggon Yoo,
linux-mm, linux-kernel
Cc: Feng Tang
Currently there are 2 parameters could be setup from kernel cmdline:
slub_min_order and slub_max_order. It's possible that the user
configured slub_min_order is bigger than the default slub_max_order
[1], which can still take effect, as calculate_oder() will use MAX_ORDER
as a fallback to check against, but has some downsides:
* the kernel message about SLUB will be strange in showing min/max
orders:
SLUB: HWalign=64, Order=9-3, MinObjects=0, CPUs=16, Nodes=1
* in calculate_order() called by each slab, the 2 loops of
calc_slab_order() will all be meaningless due to slub_min_order
is bigger than slub_max_order
* prevent future code cleanup like in [2].
Fix it by adding some sanity check to enforce the min/max semantics.
[1]. https://lore.kernel.org/lkml/21a0ba8b-bf05-0799-7c78-2a35f8c8d52a@os.amperecomputing.com/
[2]. https://lore.kernel.org/lkml/20230908145302.30320-7-vbabka@suse.cz/
Signed-off-by: Feng Tang <feng.tang@intel.com>
---
mm/slub.c | 6 ++++++
1 file changed, 6 insertions(+)
diff --git a/mm/slub.c b/mm/slub.c
index f7940048138c..b36e5eb0ccb7 100644
--- a/mm/slub.c
+++ b/mm/slub.c
@@ -4711,6 +4711,9 @@ static int __init setup_slub_min_order(char *str)
{
get_option(&str, (int *)&slub_min_order);
+ if (slub_min_order > slub_max_order)
+ slub_max_order = slub_min_order;
+
return 1;
}
@@ -4721,6 +4724,9 @@ static int __init setup_slub_max_order(char *str)
get_option(&str, (int *)&slub_max_order);
slub_max_order = min_t(unsigned int, slub_max_order, MAX_ORDER);
+ if (slub_min_order > slub_max_order)
+ slub_min_order = slub_max_order;
+
return 1;
}
--
2.27.0
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: [PATCH] mm/slub: add sanity check for slub_min/max_order cmdline setup
2023-09-20 7:44 [PATCH] mm/slub: add sanity check for slub_min/max_order cmdline setup Feng Tang
@ 2023-09-20 9:25 ` Vlastimil Babka
0 siblings, 0 replies; 2+ messages in thread
From: Vlastimil Babka @ 2023-09-20 9:25 UTC (permalink / raw)
To: Feng Tang, Christoph Lameter, Andrew Morton, Pekka Enberg,
David Rientjes, Joonsoo Kim, Roman Gushchin, Hyeonggon Yoo,
linux-mm, linux-kernel
On 9/20/23 09:44, Feng Tang wrote:
> Currently there are 2 parameters could be setup from kernel cmdline:
> slub_min_order and slub_max_order. It's possible that the user
> configured slub_min_order is bigger than the default slub_max_order
> [1], which can still take effect, as calculate_oder() will use MAX_ORDER
> as a fallback to check against, but has some downsides:
>
> * the kernel message about SLUB will be strange in showing min/max
> orders:
>
> SLUB: HWalign=64, Order=9-3, MinObjects=0, CPUs=16, Nodes=1
>
> * in calculate_order() called by each slab, the 2 loops of
> calc_slab_order() will all be meaningless due to slub_min_order
> is bigger than slub_max_order
>
> * prevent future code cleanup like in [2].
>
> Fix it by adding some sanity check to enforce the min/max semantics.
>
> [1]. https://lore.kernel.org/lkml/21a0ba8b-bf05-0799-7c78-2a35f8c8d52a@os.amperecomputing.com/
> [2]. https://lore.kernel.org/lkml/20230908145302.30320-7-vbabka@suse.cz/
> Signed-off-by: Feng Tang <feng.tang@intel.com>
Thanks, applied!
> ---
> mm/slub.c | 6 ++++++
> 1 file changed, 6 insertions(+)
>
> diff --git a/mm/slub.c b/mm/slub.c
> index f7940048138c..b36e5eb0ccb7 100644
> --- a/mm/slub.c
> +++ b/mm/slub.c
> @@ -4711,6 +4711,9 @@ static int __init setup_slub_min_order(char *str)
> {
> get_option(&str, (int *)&slub_min_order);
>
> + if (slub_min_order > slub_max_order)
> + slub_max_order = slub_min_order;
> +
> return 1;
> }
>
> @@ -4721,6 +4724,9 @@ static int __init setup_slub_max_order(char *str)
> get_option(&str, (int *)&slub_max_order);
> slub_max_order = min_t(unsigned int, slub_max_order, MAX_ORDER);
>
> + if (slub_min_order > slub_max_order)
> + slub_min_order = slub_max_order;
> +
> return 1;
> }
>
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2023-09-20 9:25 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-09-20 7:44 [PATCH] mm/slub: add sanity check for slub_min/max_order cmdline setup Feng Tang
2023-09-20 9:25 ` Vlastimil Babka
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox