All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 0/2] printk: allow different timestamps for printk.time
@ 2017-07-25 12:17 Prarit Bhargava
  2017-07-25 12:17 ` [PATCH 1/2] printk: Make CONFIG_PRINTK_TIME an int Prarit Bhargava
  2017-07-25 12:17 ` [PATCH 2/2] printk: Add boottime and real timestamps Prarit Bhargava
  0 siblings, 2 replies; 10+ messages in thread
From: Prarit Bhargava @ 2017-07-25 12:17 UTC (permalink / raw)
  To: linux-kernel
  Cc: Prarit Bhargava, Mark Salyzyn, Jonathan Corbet, Petr Mladek,
	Sergey Senozhatsky, Steven Rostedt, John Stultz, Thomas Gleixner,
	Stephen Boyd, Andrew Morton, Greg Kroah-Hartman,
	Paul E. McKenney, Christoffer Dall, Deepa Dinamani, Ingo Molnar,
	Joel Fernandes, Kees Cook, Peter Zijlstra, Geert Uytterhoeven,
	Luis R. Rodriguez, Nicholas Piggin, Jason A. Donenfeld,
	Olof Johansson, Theodore Ts'o, Josh Poimboeuf, linux-doc

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.  This
also makes determining the time of a failure difficult in cases where
/var/log/messages is unavailable.

For example,

[root@intel-wildcatpass-06 ~]# date; echo "Hello!" > /dev/kmsg ; date
Thu Jul 20 11:38:22 EST 2017
Thu Jul 20 11:38:22 EST 2017

which displays

[83973.768912] Hello!

on the serial console.

Running a script to convert this to the stamped time,

[root@intel-wildcatpass-06 ~]# ./human.sh  | tail -1
[Thu July 17 11:39:45 2017] Hello!

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

This occurs because the printk 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
The other timestamps are and that results in situations external
time sources are further and further offset from the kernel log
timestamps.

Implement printk.time settings to allow a user to specify the monotonic
or real clocks.  The default is the local clock (hardware clock).

Real clock & 32-bit systems:  Selecting the real clock printk timestamp may
lead to unlikely situations where a timestamp is wrong because the real time
offset is read without the protection of a sequence lock in the call to
ktime_get_log_ts() in printk_get_ts().

Signed-off-by: Prarit Bhargava <prarit@redhat.com>
Cc: Mark Salyzyn <salyzyn@android.com>
Cc: Jonathan Corbet <corbet@lwn.net>
Cc: Petr Mladek <pmladek@suse.com>
Cc: Sergey Senozhatsky <sergey.senozhatsky@gmail.com>
Cc: Steven Rostedt <rostedt@goodmis.org>
Cc: John Stultz <john.stultz@linaro.org>
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: Stephen Boyd <sboyd@codeaurora.org>
Cc: Andrew Morton <akpm@linux-foundation.org>
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Cc: "Paul E. McKenney" <paulmck@linux.vnet.ibm.com>
Cc: Christoffer Dall <cdall@linaro.org>
Cc: Deepa Dinamani <deepa.kernel@gmail.com>
Cc: Ingo Molnar <mingo@kernel.org>
Cc: Joel Fernandes <joelaf@google.com>
Cc: Kees Cook <keescook@chromium.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Geert Uytterhoeven <geert+renesas@glider.be>
Cc: "Luis R. Rodriguez" <mcgrof@kernel.org>
Cc: Nicholas Piggin <npiggin@gmail.com>
Cc: "Jason A. Donenfeld" <Jason@zx2c4.com>
Cc: Olof Johansson <olof@lixom.net>
Cc: "Theodore Ts'o" <tytso@mit.edu>
Cc: Josh Poimboeuf <jpoimboe@redhat.com>
Cc: linux-doc@vger.kernel.org

Prarit Bhargava (2):
  printk: Make CONFIG_PRINTK_TIME an int
  printk: Add boottime and real timestamps

 Documentation/admin-guide/kernel-parameters.txt    |  6 +-
 arch/arm/configs/aspeed_g4_defconfig               |  2 +-
 arch/arm/configs/aspeed_g5_defconfig               |  2 +-
 arch/arm/configs/axm55xx_defconfig                 |  2 +-
 arch/arm/configs/bcm2835_defconfig                 |  2 +-
 arch/arm/configs/colibri_pxa270_defconfig          |  2 +-
 arch/arm/configs/colibri_pxa300_defconfig          |  2 +-
 arch/arm/configs/dove_defconfig                    |  2 +-
 arch/arm/configs/efm32_defconfig                   |  2 +-
 arch/arm/configs/exynos_defconfig                  |  2 +-
 arch/arm/configs/ezx_defconfig                     |  2 +-
 arch/arm/configs/h5000_defconfig                   |  2 +-
 arch/arm/configs/hisi_defconfig                    |  2 +-
 arch/arm/configs/imote2_defconfig                  |  2 +-
 arch/arm/configs/imx_v6_v7_defconfig               |  2 +-
 arch/arm/configs/keystone_defconfig                |  2 +-
 arch/arm/configs/lpc18xx_defconfig                 |  2 +-
 arch/arm/configs/magician_defconfig                |  2 +-
 arch/arm/configs/mmp2_defconfig                    |  2 +-
 arch/arm/configs/moxart_defconfig                  |  2 +-
 arch/arm/configs/mps2_defconfig                    |  2 +-
 arch/arm/configs/multi_v7_defconfig                |  2 +-
 arch/arm/configs/mvebu_v7_defconfig                |  2 +-
 arch/arm/configs/mxs_defconfig                     |  2 +-
 arch/arm/configs/omap2plus_defconfig               |  2 +-
 arch/arm/configs/pxa168_defconfig                  |  2 +-
 arch/arm/configs/pxa3xx_defconfig                  |  2 +-
 arch/arm/configs/pxa910_defconfig                  |  2 +-
 arch/arm/configs/pxa_defconfig                     |  2 +-
 arch/arm/configs/qcom_defconfig                    |  2 +-
 arch/arm/configs/raumfeld_defconfig                |  2 +-
 arch/arm/configs/shmobile_defconfig                |  2 +-
 arch/arm/configs/socfpga_defconfig                 |  2 +-
 arch/arm/configs/stm32_defconfig                   |  2 +-
 arch/arm/configs/sunxi_defconfig                   |  2 +-
 arch/arm/configs/tango4_defconfig                  |  2 +-
 arch/arm/configs/tegra_defconfig                   |  2 +-
 arch/arm/configs/u300_defconfig                    |  2 +-
 arch/arm/configs/u8500_defconfig                   |  2 +-
 arch/arm/configs/vt8500_v6_v7_defconfig            |  2 +-
 arch/arm/configs/xcep_defconfig                    |  2 +-
 arch/arm/configs/zx_defconfig                      |  2 +-
 arch/arm64/configs/defconfig                       |  2 +-
 arch/m68k/configs/amcore_defconfig                 |  2 +-
 arch/mips/configs/ath25_defconfig                  |  2 +-
 arch/mips/configs/bcm47xx_defconfig                |  2 +-
 arch/mips/configs/bmips_be_defconfig               |  2 +-
 arch/mips/configs/bmips_stb_defconfig              |  2 +-
 arch/mips/configs/ci20_defconfig                   |  2 +-
 arch/mips/configs/generic_defconfig                |  2 +-
 arch/mips/configs/lemote2f_defconfig               |  2 +-
 arch/mips/configs/loongson3_defconfig              |  2 +-
 arch/mips/configs/nlm_xlp_defconfig                |  2 +-
 arch/mips/configs/nlm_xlr_defconfig                |  2 +-
 arch/mips/configs/pistachio_defconfig              |  2 +-
 arch/mips/configs/qi_lb60_defconfig                |  2 +-
 arch/mips/configs/rt305x_defconfig                 |  2 +-
 arch/mips/configs/xway_defconfig                   |  2 +-
 arch/parisc/configs/generic-64bit_defconfig        |  2 +-
 arch/powerpc/configs/40x/virtex_defconfig          |  2 +-
 arch/powerpc/configs/44x/fsp2_defconfig            |  2 +-
 arch/powerpc/configs/44x/virtex5_defconfig         |  2 +-
 arch/powerpc/configs/44x/warp_defconfig            |  2 +-
 arch/powerpc/configs/52xx/cm5200_defconfig         |  2 +-
 arch/powerpc/configs/52xx/lite5200b_defconfig      |  2 +-
 arch/powerpc/configs/52xx/motionpro_defconfig      |  2 +-
 arch/powerpc/configs/52xx/tqm5200_defconfig        |  2 +-
 arch/powerpc/configs/gamecube_defconfig            |  2 +-
 arch/powerpc/configs/mpc5200_defconfig             |  2 +-
 arch/powerpc/configs/pasemi_defconfig              |  2 +-
 arch/powerpc/configs/wii_defconfig                 |  2 +-
 arch/s390/configs/default_defconfig                |  2 +-
 arch/s390/configs/gcov_defconfig                   |  2 +-
 arch/s390/configs/performance_defconfig            |  2 +-
 arch/s390/configs/zfcpdump_defconfig               |  2 +-
 arch/sh/configs/edosk7760_defconfig                |  2 +-
 arch/sh/configs/sdk7786_defconfig                  |  2 +-
 arch/sh/configs/se7722_defconfig                   |  2 +-
 arch/sh/configs/sh7785lcr_32bit_defconfig          |  2 +-
 arch/sh/configs/urquell_defconfig                  |  2 +-
 arch/sparc/configs/sparc64_defconfig               |  2 +-
 arch/x86/configs/i386_defconfig                    |  2 +-
 arch/x86/configs/x86_64_defconfig                  |  2 +-
 arch/xtensa/configs/audio_kc705_defconfig          |  2 +-
 arch/xtensa/configs/cadence_csp_defconfig          |  2 +-
 arch/xtensa/configs/generic_kc705_defconfig        |  2 +-
 arch/xtensa/configs/nommu_kc705_defconfig          |  2 +-
 arch/xtensa/configs/smp_lx200_defconfig            |  2 +-
 include/linux/timekeeping.h                        |  1 +
 kernel/printk/printk.c                             | 95 +++++++++++++++++++++-
 kernel/time/timekeeping.c                          | 14 ++++
 lib/Kconfig.debug                                  |  8 +-
 .../selftests/rcutorture/configs/lock/CFcommon     |  2 +-
 .../selftests/rcutorture/configs/rcu/CFcommon      |  2 +-
 .../selftests/rcutorture/configs/rcuperf/CFcommon  |  2 +-
 95 files changed, 206 insertions(+), 98 deletions(-)

-- 
1.8.5.5

^ permalink raw reply	[flat|nested] 10+ messages in thread

end of thread, other threads:[~2017-07-31 17:11 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-07-25 12:17 [PATCH 0/2] printk: allow different timestamps for printk.time Prarit Bhargava
2017-07-25 12:17 ` [PATCH 1/2] printk: Make CONFIG_PRINTK_TIME an int Prarit Bhargava
2017-07-25 12:55   ` Luis R. Rodriguez
2017-07-31 17:11     ` Prarit Bhargava
2017-07-25 12:17 ` [PATCH 2/2] printk: Add boottime and real timestamps Prarit Bhargava
2017-07-25 13:00   ` Peter Zijlstra
2017-07-25 22:39     ` Mark Salyzyn
2017-07-28 15:01     ` Prarit Bhargava
2017-07-28 16:28       ` Thomas Gleixner
2017-07-27  3:02   ` kbuild test robot

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.