Search code examples
printk

What does the numbers at the beginning of prink() mean?


If you use prink() to print kernel message and read it in the console, it looks like this:

<6>[ 2809.666228] amp_enable: amp enable bypass(2)  
<6>[ 2809.666747] amp_enable: AMP_EN is set to 0  
<3>[ 2810.084296] init: untracked pid 4196 exited  
<3>[ 2810.873706] init: untracked pid 4817 exited  
<6>[ 2810.933923] msm_ta_detect_work: USB exit ta detection - frindex  
<6>[ 2817.483839] amp_enable: AMP_EN is set to 1  
<6>[ 2823.084022] adjust_soc: ibat_ua = -114500, vbat_uv = 4296066, soc = 95, batt_temp=302  
<6>[ 2823.669799] SLIM_CL: skip reconfig sequence  
<6>[ 2823.685578] amp_enable: amp enable bypass(2)  
<6>[ 2823.686372] amp_enable: AMP_EN is set to 0  

What does the number at the beginning of each line mean? Is it some kind of time stamp? How do I interpret it?


Solution

  • As NG mentioned, the <3> and <6> are log levels where <3> is KERN_ERR and <6> is KERN_INFO.

    Here's a list picked up from http://tuxthink.blogspot.com/2012/07/printk-and-console-log-level.html.

    0 KERN_EMERG
    1 KERN_ALERT
    2 KERN_CRIT
    3 KERN_ERR
    4 KERN_WARNING
    5 KERN_NOTICE
    6 KERN_INFO
    7 KERN_DEBUG
    

    The next number appears to be time in seconds since system boot. Did your system boot ~50 minutes ago when you saw these messages? The timestamps can help us track how long a task took. For example, amp_enable: amp enable bypass(2) took 0.519ms to complete. From first entry to the fourth entry, it took 1.207478s.

    <6>[ 2809.666228] amp_enable: amp enable bypass(2)  
    <6>[ 2809.666747] amp_enable: AMP_EN is set to 0  
    <3>[ 2810.084296] init: untracked pid 4196 exited  
    <3>[ 2810.873706] init: untracked pid 4817 exited 
    

    I learned this by visiting http://elinux.org/Printk_Times_Sample1.