HOW TO CHANGE LINUX KERNEL DMESG BUFFER SIZE

https://rajanvaja.wordpress.com/2015/06/04/how-to-change-linux-kernel-dmesg-buffer-size/

 

Printk is implemented by using a ring buffer in the kernel with a size of __LOG_BUF_LEN bytes where __LOG_BUF_LEN equals (1 << CONFIG_LOG_BUF_SHIFT).

dmesg buffer size can be changed using “CONFIG_LOG_BUF_SHIFT” Kconfig.

As per kernel source (4.1.0), default value of this config is 17 (i.e. 1 << 17 = 128KB). The range for this config is 12 to 21.

Addign  below line in defconfig sets

Note: If invalid value (out of range value) is set, default value is taken.

CONFIG_LOG_BUF_SHIFT can be changed from menuconfig or from defconfig as below:

CONFIG_LOG_BUF_SHIFT=21



https://elixir.bootlin.com/linux/v4.9.253/source/init/Kconfig#L823

config LOG_BUF_SHIFT
    int "Kernel log buffer size (16 => 64KB, 17 => 128KB)"
    range 12 25 if !H8300
    range 12 19 if H8300
    default 17
    depends on PRINTK
    help
      Select the minimal kernel log buffer size as a power of 2.
      The final size is affected by LOG_CPU_MAX_BUF_SHIFT config
      parameter, see below. Any higher size also might be forced
      by "log_buf_len" boot parameter.

      Examples:
             17 => 128 KB
             16 => 64 KB
             15 => 32 KB
             14 => 16 KB
             13 =>  8 KB
             12 =>  4 KB
posted @   张同光  阅读(265)  评论(0编辑  收藏  举报
编辑推荐:
· 基于Microsoft.Extensions.AI核心库实现RAG应用
· Linux系列:如何用heaptrack跟踪.NET程序的非托管内存泄露
· 开发者必知的日志记录最佳实践
· SQL Server 2025 AI相关能力初探
· Linux系列:如何用 C#调用 C方法造成内存泄露
阅读排行:
· 无需6万激活码!GitHub神秘组织3小时极速复刻Manus,手把手教你使用OpenManus搭建本
· Manus爆火,是硬核还是营销?
· 终于写完轮子一部分:tcp代理 了,记录一下
· 别再用vector<bool>了!Google高级工程师:这可能是STL最大的设计失误
· 单元测试从入门到精通
点击右上角即可分享
微信分享提示