2024-02-04 23:31:29

by Yoann Congal

[permalink] [raw]
Subject: [PATCH v3 1/2] printk: Fix LOG_CPU_MAX_BUF_SHIFT when BASE_SMALL is enabled

LOG_CPU_MAX_BUF_SHIFT default value depends on BASE_SMALL:
config LOG_CPU_MAX_BUF_SHIFT
default 12 if !BASE_SMALL
default 0 if BASE_SMALL
But, BASE_SMALL is a config of type int and "!BASE_SMALL" is always
evaluated to true whatever is the value of BASE_SMALL.

This patch fixes this by using BASE_FULL (type bool) which is equivalent
to BASE_SMALL==0.

Note: This changes CONFIG_LOG_CPU_MAX_BUF_SHIFT=12 to
CONFIG_LOG_CPU_MAX_BUF_SHIFT=0 for BASE_SMALL defconfigs, but that will
not be a big impact due to this code in kernel/printk/printk.c:
/* by default this will only continue through for large > 64 CPUs */
if (cpu_extra <= __LOG_BUF_LEN / 2)
return;
Systems using CONFIG_BASE_SMALL and having 64+ CPUs should be quite
rare.

John Ogness <[email protected]> (printk reviewer) wrote:
> For printk this will mean that BASE_SMALL systems were probably
> previously allocating/using the dynamic ringbuffer and now they will
> just continue to use the static ringbuffer. Which is fine and saves
> memory (as it should).

Signed-off-by: Yoann Congal <[email protected]>
Reported-by: Geert Uytterhoeven <[email protected]>
Closes: https://lore.kernel.org/all/CAMuHMdWm6u1wX7efZQf=2XUAHascps76YQac6rdnQGhc8nop_Q@mail.gmail.com/
Reported-by: Vegard Nossum <[email protected]>
Closes: https://lore.kernel.org/all/[email protected]/
Fixes: 4e244c10eab3 ("kconfig: remove unneeded symbol_empty variable")
---
init/Kconfig | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/init/Kconfig b/init/Kconfig
index deda3d14135bb..73efb76f38734 100644
--- a/init/Kconfig
+++ b/init/Kconfig
@@ -734,8 +734,8 @@ config LOG_CPU_MAX_BUF_SHIFT
int "CPU kernel log buffer size contribution (13 => 8 KB, 17 => 128KB)"
depends on SMP
range 0 21
- default 12 if !BASE_SMALL
- default 0 if BASE_SMALL
+ default 12 if BASE_FULL
+ default 0
depends on PRINTK
help
This option allows to increase the default ring buffer size
--
2.39.2



2024-02-05 03:02:54

by Masahiro Yamada

[permalink] [raw]
Subject: Re: [PATCH v3 1/2] printk: Fix LOG_CPU_MAX_BUF_SHIFT when BASE_SMALL is enabled

On Mon, Feb 5, 2024 at 8:30 AM Yoann Congal <[email protected]> wrote:
>
> LOG_CPU_MAX_BUF_SHIFT default value depends on BASE_SMALL:
> config LOG_CPU_MAX_BUF_SHIFT
> default 12 if !BASE_SMALL
> default 0 if BASE_SMALL
> But, BASE_SMALL is a config of type int and "!BASE_SMALL" is always
> evaluated to true whatever is the value of BASE_SMALL.
>
> This patch fixes this by using BASE_FULL (type bool) which is equivalent
> to BASE_SMALL==0.
>
> Note: This changes CONFIG_LOG_CPU_MAX_BUF_SHIFT=12 to
> CONFIG_LOG_CPU_MAX_BUF_SHIFT=0 for BASE_SMALL defconfigs, but that will
> not be a big impact due to this code in kernel/printk/printk.c:
> /* by default this will only continue through for large > 64 CPUs */
> if (cpu_extra <= __LOG_BUF_LEN / 2)
> return;
> Systems using CONFIG_BASE_SMALL and having 64+ CPUs should be quite
> rare.
>
> John Ogness <[email protected]> (printk reviewer) wrote:
> > For printk this will mean that BASE_SMALL systems were probably
> > previously allocating/using the dynamic ringbuffer and now they will
> > just continue to use the static ringbuffer. Which is fine and saves
> > memory (as it should).
>
> Signed-off-by: Yoann Congal <[email protected]>
> Reported-by: Geert Uytterhoeven <[email protected]>
> Closes: https://lore.kernel.org/all/CAMuHMdWm6u1wX7efZQf=2XUAHascps76YQac6rdnQGhc8nop_Q@mail.gmail.com/
> Reported-by: Vegard Nossum <[email protected]>
> Closes: https://lore.kernel.org/all/[email protected]/
> Fixes: 4e244c10eab3 ("kconfig: remove unneeded symbol_empty variable")
> ---
> init/Kconfig | 4 ++--
> 1 file changed, 2 insertions(+), 2 deletions(-)



Reviewed-by: Masahiro Yamada <[email protected]>



--
Best Regards
Masahiro Yamada

2024-02-05 08:41:50

by John Ogness

[permalink] [raw]
Subject: Re: [PATCH v3 1/2] printk: Fix LOG_CPU_MAX_BUF_SHIFT when BASE_SMALL is enabled

On 2024-02-05, Yoann Congal <[email protected]> wrote:
> LOG_CPU_MAX_BUF_SHIFT default value depends on BASE_SMALL:
> config LOG_CPU_MAX_BUF_SHIFT
> default 12 if !BASE_SMALL
> default 0 if BASE_SMALL
> But, BASE_SMALL is a config of type int and "!BASE_SMALL" is always
> evaluated to true whatever is the value of BASE_SMALL.
>
> This patch fixes this by using BASE_FULL (type bool) which is equivalent
> to BASE_SMALL==0.
>
> Note: This changes CONFIG_LOG_CPU_MAX_BUF_SHIFT=12 to
> CONFIG_LOG_CPU_MAX_BUF_SHIFT=0 for BASE_SMALL defconfigs, but that will
> not be a big impact due to this code in kernel/printk/printk.c:
> /* by default this will only continue through for large > 64 CPUs */
> if (cpu_extra <= __LOG_BUF_LEN / 2)
> return;
> Systems using CONFIG_BASE_SMALL and having 64+ CPUs should be quite
> rare.
>
> John Ogness <[email protected]> (printk reviewer) wrote:
>> For printk this will mean that BASE_SMALL systems were probably
>> previously allocating/using the dynamic ringbuffer and now they will
>> just continue to use the static ringbuffer. Which is fine and saves
>> memory (as it should).
>
> Signed-off-by: Yoann Congal <[email protected]>
> Reported-by: Geert Uytterhoeven <[email protected]>
> Closes: https://lore.kernel.org/all/CAMuHMdWm6u1wX7efZQf=2XUAHascps76YQac6rdnQGhc8nop_Q@mail.gmail.com/
> Reported-by: Vegard Nossum <[email protected]>
> Closes: https://lore.kernel.org/all/[email protected]/
> Fixes: 4e244c10eab3 ("kconfig: remove unneeded symbol_empty variable")

Reviewed-by: John Ogness <[email protected]>

2024-02-05 13:34:48

by Petr Mladek

[permalink] [raw]
Subject: Re: [PATCH v3 1/2] printk: Fix LOG_CPU_MAX_BUF_SHIFT when BASE_SMALL is enabled

On Mon 2024-02-05 00:29:44, Yoann Congal wrote:
> LOG_CPU_MAX_BUF_SHIFT default value depends on BASE_SMALL:
> config LOG_CPU_MAX_BUF_SHIFT
> default 12 if !BASE_SMALL
> default 0 if BASE_SMALL
> But, BASE_SMALL is a config of type int and "!BASE_SMALL" is always
> evaluated to true whatever is the value of BASE_SMALL.
>
> This patch fixes this by using BASE_FULL (type bool) which is equivalent
> to BASE_SMALL==0.
>
> Note: This changes CONFIG_LOG_CPU_MAX_BUF_SHIFT=12 to
> CONFIG_LOG_CPU_MAX_BUF_SHIFT=0 for BASE_SMALL defconfigs, but that will
> not be a big impact due to this code in kernel/printk/printk.c:
> /* by default this will only continue through for large > 64 CPUs */
> if (cpu_extra <= __LOG_BUF_LEN / 2)
> return;
> Systems using CONFIG_BASE_SMALL and having 64+ CPUs should be quite
> rare.
>
> John Ogness <[email protected]> (printk reviewer) wrote:
> > For printk this will mean that BASE_SMALL systems were probably
> > previously allocating/using the dynamic ringbuffer and now they will
> > just continue to use the static ringbuffer. Which is fine and saves
> > memory (as it should).

More precisely, it allocated the buffer dynamically when the sum
of per-CPU-extra space exceeded half of the default static ring
buffer. This happened for systems with more than 64 CPUs with
the default config values.

I believe that this patch won't have any effect in practice.
It is hard to imagine a system with >64 CPUs which would require
BASE_SMALL kernel. Well, never say never ;-)

> Signed-off-by: Yoann Congal <[email protected]>
> Reported-by: Geert Uytterhoeven <[email protected]>
> Closes: https://lore.kernel.org/all/CAMuHMdWm6u1wX7efZQf=2XUAHascps76YQac6rdnQGhc8nop_Q@mail.gmail.com/
> Reported-by: Vegard Nossum <[email protected]>
> Closes: https://lore.kernel.org/all/[email protected]/
> Fixes: 4e244c10eab3 ("kconfig: remove unneeded symbol_empty variable")

Reviewed-by: Petr Mladek <[email protected]>

Best Regards,
Petr