Linux – How to find out a linux kernel ring buffer size

kernellinuxlinux-kernel

Quite interested in the size of the kernel ring buffer, how much information it can hold, and what data types?

Best Answer

Regarding the size, it's recorded in your kernel's config file. For example, on Amazon EC2 here, it's 256 KiB.

# grep CONFIG_LOG_BUF_SHIFT /boot/config-`uname -r`
CONFIG_LOG_BUF_SHIFT=18
# perl -e 'printf "%d KiB\n",(1<<18)/1024'
256 KiB
#

Referenced in /kernel/printk/printk.c

#define __LOG_BUF_LEN (1 << CONFIG_LOG_BUF_SHIFT)

More information in /kernel/trace/ring_buffer.c

Note that if you've passed a kernel boot param "log_buf_len=N" (check using cat /proc/cmdline) then that overrides the value in the config file.

Related Question