Commit Graph

3 Commits

Author SHA1 Message Date
Edward Chron 5977936c0a Add "log -c" option to display printk caller id
Add support so that dmesg entries include the optional Linux Kernel
debug CONFIG option PRINTK_CALLER which adds an optional dmesg field
that contains the Thread Id or CPU Id that is issuing the printk to
add the message to the kernel ring buffer. If enabled, this CONFIG
option makes debugging simpler as dmesg entries for a specific
thread or CPU can be recognized. The config option was introduced
with Linux 5.1 [1].

Size of the PRINTK_CALLER field is determined by the maximum number
tasks that can be run on the system which is limited by the value of
/proc/sys/kernel/pid_max as pid values are from 0 to value - 1.
This value determines the number of id digits needed by the caller id.
The PRINTK_CALLER field is printed as T<id> for a Task Id or C<id>
for a CPU Id for a printk in CPU context. The values are left space
padded and enclosed in parentheses such as:
         [    T123]   or   [     C16]

Our patch adds the PRINTK_CALLER field after the timestamp if the
printk caller log / dmesg option (-c) is selected:

  crash> log -m -c
  ...
  [    0.014179] [     T1] <6>Secure boot disabled
  [    0.014179] [    T29] <6>RAMDISK: [mem 0x3cf4f000-0x437bbfff]
  ...

[1] 15ff2069cb7f ("printk: Add caller information to printk() output.")

Resolves: https://github.com/crash-utility/crash/issues/164
Signed-off-by: Ivan Delalande <colona@arista.com>
Signed-off-by: Edward Chron <echron@arista.com>
Signed-off-by: Kazuhito Hagio <k-hagio-ab@nec.com>
2024-01-31 11:48:18 +09:00
John Ogness 71e159c640 printk: use committed/finalized state values
An addendum to the previous crash commit a5531b2475.
The ringbuffer entries use 2 state values (committed and finalized)
rather than a single flag to represent being available for reading.
Copy the definitions and state lookup function directly from the
kernel source and use the new states.

Signed-off-by: John Ogness <john.ogness@linutronix.de>
Signed-off-by: Nikolay Borisov <nborisov@suse.com>
2020-12-01 15:22:36 +09:00
John Ogness a5531b2475 printk: add support for lockless ringbuffer
Linux 5.10 introduces a new lockless ringbuffer. The new ringbuffer
is structured completely different to the previous iterations.
Add support for dumping the ringbuffer with the "log" command.
The new ringbuffer is detected based on the availability of
the "prb" symbol.

Signed-off-by: John Ogness <john.ogness@linutronix.de>
Signed-off-by: Kazuhito Hagio <k-hagio-ab@nec.com>
2020-12-01 15:06:33 +09:00