* [PATCH] printk: fix wrong number of CPUs required to increase the ring buffer
@ 2026-09-21 16:38 Sang-Heon Jeon
2026-09-23 11:57 ` Petr Mladek
0 siblings, 1 reply; 2+ messages in thread
From: Sang-Heon Jeon @ 2026-09-21 16:38 UTC (permalink / raw)
To: Petr Mladek; +Cc: John Ogness, linux-kernel, Sergey Senozhatsky, Steven Rostedt
The default LOG_BUF_SHIFT is 17, which means 128 KB, and
LOG_CPU_MAX_BUF_SHIFT is 12, which means 4 KB per CPU.
By default the ring buffer is increased when
(num_possible_cpus() - 1) * 4 KB > 64 KB, which requires 18 or more CPUs.
Fix the wrong comment and help text.
Signed-off-by: Sang-Heon Jeon <ekffu200098@gmail.com>
---
init/Kconfig | 2 +-
kernel/printk/printk.c | 2 +-
2 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/init/Kconfig b/init/Kconfig
index 60448fd4ee12..446cbb59a43b 100644
--- a/init/Kconfig
+++ b/init/Kconfig
@@ -843,7 +843,7 @@ config LOG_CPU_MAX_BUF_SHIFT
with more CPUs. Therefore this value is used only when the sum of
contributions is greater than the half of the default kernel ring
buffer as defined by LOG_BUF_SHIFT. The default values are set
- so that more than 16 CPUs are needed to trigger the allocation.
+ so that 18 or more CPUs are needed to trigger the allocation.
Also this option is ignored when "log_buf_len" kernel parameter is
used as it forces an exact (power of two) size of the ring buffer.
diff --git a/kernel/printk/printk.c b/kernel/printk/printk.c
index 00f8e1291564..c7d961256c88 100644
--- a/kernel/printk/printk.c
+++ b/kernel/printk/printk.c
@@ -1087,7 +1087,7 @@ static void __init log_buf_add_cpu(void)
cpu_extra = (num_possible_cpus() - 1) * __LOG_CPU_MAX_BUF_LEN;
- /* by default this will only continue through for large > 64 CPUs */
+ /* by default this will only continue through for 18 or more CPUs */
if (cpu_extra <= __LOG_BUF_LEN / 2)
return;
base-commit: b03d22ec8186f3f6b40b95a5a678100cf80116cb
--
2.43.0
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: [PATCH] printk: fix wrong number of CPUs required to increase the ring buffer
2026-09-21 16:38 [PATCH] printk: fix wrong number of CPUs required to increase the ring buffer Sang-Heon Jeon
@ 2026-09-23 11:57 ` Petr Mladek
0 siblings, 0 replies; 2+ messages in thread
From: Petr Mladek @ 2026-09-23 11:57 UTC (permalink / raw)
To: Sang-Heon Jeon
Cc: John Ogness, linux-kernel, Sergey Senozhatsky, Steven Rostedt
On Tue 2026-09-22 01:38:27, Sang-Heon Jeon wrote:
> The default LOG_BUF_SHIFT is 17, which means 128 KB, and
> LOG_CPU_MAX_BUF_SHIFT is 12, which means 4 KB per CPU.
>
> By default the ring buffer is increased when
> (num_possible_cpus() - 1) * 4 KB > 64 KB, which requires 18 or more CPUs.
Good catch!
> Fix the wrong comment and help text.
>
> Signed-off-by: Sang-Heon Jeon <ekffu200098@gmail.com>
> ---
> init/Kconfig | 2 +-
> kernel/printk/printk.c | 2 +-
> 2 files changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/init/Kconfig b/init/Kconfig
> index 60448fd4ee12..446cbb59a43b 100644
> --- a/init/Kconfig
> +++ b/init/Kconfig
> @@ -843,7 +843,7 @@ config LOG_CPU_MAX_BUF_SHIFT
> with more CPUs. Therefore this value is used only when the sum of
> contributions is greater than the half of the default kernel ring
> buffer as defined by LOG_BUF_SHIFT. The default values are set
> - so that more than 16 CPUs are needed to trigger the allocation.
> + so that 18 or more CPUs are needed to trigger the allocation.
The number 18 is pretty ugly. It was supposed to be a power of 2.
I would prefer to fix the computation instead.
>
> Also this option is ignored when "log_buf_len" kernel parameter is
> used as it forces an exact (power of two) size of the ring buffer.
> diff --git a/kernel/printk/printk.c b/kernel/printk/printk.c
> index 00f8e1291564..c7d961256c88 100644
> --- a/kernel/printk/printk.c
> +++ b/kernel/printk/printk.c
> @@ -1087,7 +1087,7 @@ static void __init log_buf_add_cpu(void)
>
> cpu_extra = (num_possible_cpus() - 1) * __LOG_CPU_MAX_BUF_LEN;
If we remove the minus one:
cpu_extra = num_possible_cpus() * __LOG_CPU_MAX_BUF_LEN;
The it should be > 16 and we could keep init/Kconfig as is.
> - /* by default this will only continue through for large > 64 CPUs */
> + /* by default this will only continue through for 18 or more CPUs */
Right, this should be > 16 with the current defaults.
> if (cpu_extra <= __LOG_BUF_LEN / 2)
> return;
Would you like to prepare v2?
Best Regards,
Petr
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2026-09-23 11:57 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-09-21 16:38 [PATCH] printk: fix wrong number of CPUs required to increase the ring buffer Sang-Heon Jeon
2026-09-23 11:57 ` Petr Mladek
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®