Internet Explorer is not a supported browser for TI.com. For the best experience, please use a different browser.
Video Player is loading.
Current Time 0:00
Duration 0:00
Loaded: 0%
Stream Type LIVE
Remaining Time 0:00
 
1x
  • Chapters
  • descriptions off, selected

      [MUSIC PLAYING]

      Hello, everybody. This is the second video in this training series talking about a kernel logging system. This video gives some basics for next two videos, printk API and dynamic debug feature.

      In this video, I will first talk about a kernel logging architecture and then show a example of a kernel log and then how to retrieve a kernel log and how to adjust a kernel log buffer size, and then finally explain how to add log messages from a userspace application.

      This diagram shows the architecture of the kernel logging system. The logging system has three components. At bottom is the kernel log buffer, which is used as to store the kernel log messages. Another component is the logging API, which is used by the kernel module and the device drivers to generate logs. And another component is the I/O and the control API, which is used by the userspace application to control the log buffer and read the log messages from the buffer.

      This is example of a piece of a kernel log. Each line is a log message generated by the logging API in kernel. And also kernel adds a time stamp in the beginning of each message. Linux provides many ways to read the log buffer. But when debugging problems, dmesg command is the one we typically use. This commands the prints and it controls the log buffer. dmesg command can take many parameters, but here is the common usage. If you run the message without any parameter, it just simply print the log buffer. It doesn't change the buffer. If you run dmesg with capital C, it clean the log buffer. It doesn't print anything. If you run the message with lowercase c, it print the buffer and then clean it.

      The size of the kernel log buffer by default is 64 kilobytes. This size can be adjusted. You can either change it in a kernel config option or in a [INAUDIBLE]. Ox Either way, if you define a number n and then buffer size it's to power of n. For example, if you define n to be 16, and then the buffer size will be 64 kilobytes. If you define n to be 17, that's a specified buffer size to be 128 kilobytes.

      Kernel also provides an interface for userspace application to generate log messages into the kernel log buffer. The interface is /dev/kmsg. To use it you use echo and then message and direct to /dev/kmsg. The message will be added into the kernel log buffer, along with the kernel log messages.

      Here is example in which basically output [INAUDIBLE] the messages to the kernel log buffer which is unplug thumb drive and wait for a couple of seconds, and then replug the thumb drive.

      Why we need this interface? Well, it can be useful when you debug a [INAUDIBLE] which involves multiple steps of operations. With all this, the log only has a kernel messages. It doesn't tell what it did, what you changed. But with this interface, you can add comments into the kernel log to explain what you have done. For example, remove the thumb drive, which gives more clue why kernel generates such log.

      To summarize this video, kernel modules and device drivers use the logging API to generate logs into the kernel internal log buffer. And dmesg command can be used to retrieve the log. The log buffer size can be adjusted.

      This is all for this video, and here are some links for more information. If you have any questions, please let us know. And thanks for watching.

      [MUSIC PLAYING]

      This video is part of a series