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 @ 2021-02-20 10:07  张同光  阅读(253)  评论(0编辑  收藏  举报