Skip to content

printk, Add a printk.clock kernel parameter

Prarit Bhargava lkml 1 version In review

Get series with b4
b4 am [email protected]

Versions newest first

  1. v1 Latest2 patches 17 repliesIn review

Patches in v1 No applies recorded yet

#Subject and filesSizeRepliesApplied
1/2kernel, timekeeping, add trylock option to ktime_get_with_offset()include/linux/timekeeping.h kernel/time/timekeeping.c+60 -512 replies
2/2printk, Add printk.clock kernel parameterinclude/linux/time64.h kernel/printk/printk.c+99 -84 replies

Reviews trailers per patch

No Reviewed-by, Acked-by or Tested-by trailers for v1 yet.

Read the v1 thread

Cover letter [PATCH 0/2] printk, Add a printk.clock kernel parameter

Over the past years I've seen many reports of bugs that include time-stamped kernel logs (enabled when CONFIG_PRINTK_TIME=y or print.time=1 is specified as a kernel parameter) that do not align with either external time stamped logs or /var/log/messages.

For example,

[root@intel-wildcatpass-06 ~]# date; echo "Hello!" > /dev/kmsg ; date Thu Dec 17 13:58:31 EST 2015
Thu Dec 17 13:58:31 EST 2015

which displays

[83973.768912] Hello!

on the serial console.

Running a script to convert this to "boot time",

[root@intel-wildcatpass-06 ~]# ./human.sh | tail -1

[Thu Dec 17 13:59:57 2015] Hello!

which is already off by 1 minute and 26 seconds off after ~24 hours of uptime.

This occurs because the time stamp is obtained from a call to local_clock() which (on x86) is a direct call to the hardware. These hardware clock reads are not modified by the standard ntp or ptp protocol, while the other timestamps are, and that results in situations where /var/log/messages timestamps are further and further offset from the hardware clock timestamps.

This patch introduces printk.clock=[local|boot|real|tai] allowing a user to specify an adjusted clock to use with printk timestamps. The hardware clock, or the existing functionality, is preserved by default.

Cc John Stultz <[email protected]>
Cc Xunlei Pang <[email protected]>
Cc Thomas Gleixner <[email protected]>
Cc Baolin Wang <[email protected]>
Cc Andrew Morton <[email protected]>
Cc Greg Kroah-Hartman <[email protected]>
Cc Petr Mladek <[email protected]>
Cc Tejun Heo <[email protected]>
Cc Peter Hurley <[email protected]>
Cc Vasily Averin <[email protected]>
Cc Joe Perches <[email protected]>

Prarit Bhargava (2):
kernel, timekeeping, add trylock option to ktime_get_with_offset() printk, Add printk.clock kernel parameter

 include/linux/time64.h      |    2 +
 include/linux/timekeeping.h |   50 +++++++++++++++++++--
 kernel/printk/printk.c      |  105 +++++++++++++++++++++++++++++++++++++++----
 kernel/time/timekeeping.c   |   15 ++++++-
 4 files changed, 159 insertions(+), 13 deletions(-)
Signature · 1 line
1.7.9.3