Skip to contentSkip to conversation

printk: increase the ring buffer for more than 16 CPUs by default

PATCH In review Sang-Heon Jeon 3 participants 4 messages Sep 27 – Sep 29 Printk

lore
Share & tools
lore
#0 lore raw

PATCH v2 1/1 printk: increase the ring buffer for more than 16 CPUs by default

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 more than 17 CPUs.

Remove the explicit subtraction of one, so the ring buffer is increased for more than 16 CPUs, which is a power of two. Also fix the outdated comment.

---
Changes from v1 [1]
- Adjust default threshold to power of two, as suggested by Petr

[1] https://lore.kernel.org/all/[email protected]/

---
 kernel/printk/printk.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
kernel/printk/printk.c +2 -2
index 00f8e1291564..1ba440c1193e 100644
@@ -1085,9 +1085,9 @@ static void __init log_buf_add_cpu(void)
 	if (num_possible_cpus() == 1)
 		return;
 
-	cpu_extra = (num_possible_cpus() - 1) * __LOG_CPU_MAX_BUF_LEN;
+	cpu_extra = num_possible_cpus() * __LOG_CPU_MAX_BUF_LEN;
 
-	/* by default this will only continue through for large > 64 CPUs */
+	/* by default this will only continue through for more than 16 CPUs */
 	if (cpu_extra <= __LOG_BUF_LEN / 2)
 		return;
 

base-commit: b03d22ec8186f3f6b40b95a5a678100cf80116cb

Signature · 1 line
2.43.0
maintainer Reviewed-by on v2 1/1
#1 lore raw
Quoted 7 lines · Sang-Heon Jeon

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 more than 17 CPUs.

Quoted 6 lines

Remove the explicit subtraction of one, so the ring buffer is increased for more than 16 CPUs, which is a power of two. Also fix the outdated comment.

maintainer Reviewed-by on v2 1/1
#2 lore raw
In reply to Sang-Heon Jeon
Quoted 7 lines · Sang-Heon Jeon

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 more than 17 CPUs.

Quoted 6 lines

Remove the explicit subtraction of one, so the ring buffer is increased for more than 16 CPUs, which is a power of two. Also fix the outdated comment.

Looks good to me:

Best Regards,
Petr

maintainer
#3 lore raw
In reply to Sang-Heon Jeon
Quoted 7 lines · Sang-Heon Jeon

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 more than 17 CPUs.

Quoted 6 lines

Remove the explicit subtraction of one, so the ring buffer is increased for more than 16 CPUs, which is a power of two. Also fix the outdated comment.

JFYI, the patch has been comitted into printk/linux.git, branch for-7.4.

Best Regards,
Petr