Re: [patch 0/2] timekeeping: NMI safe timekeeper enhancements

From: Petr Mladek
Date: Thu Aug 20 2020 - 04:47:50 EST


On Fri 2020-08-14 12:19:33, Thomas Gleixner wrote:
> printk intends to store various timestamps (MONOTONIC, REALTIME, BOOTTIME)
> to make correlation of dmesg accross different machines easier.
>
> The NMI safe timekeeper allows to retrieve these timestamps from any
> context.

For both patches:

Tested-by: Petr Mladek <pmladek@xxxxxxxx>

I am not familiar with the timekeeping code so that I could not
provide a valuable review. Anyway, the patches seem to work
as expected.

The interface is perfectly fine for printk() needs.


I tested them with the patch below. The first timestamps appear
as early as before:

[ 0.000000] [ 0.000000][1970-01-01T00:00:00][ T0] kvm-clock: Using msrs 4b564d01 and 4b564d00
[ 0.000000] [ 0.000000][1970-01-01T00:00:00][ T0] kvm-clock: cpu 0, msr 129c01001, primary cpu clock
[ 0.000000] [ 0.000000][1970-01-01T00:00:00][ T0] kvm-clock: using sched offset of 56519600356309 cycles
[ 0.000008] [ 0.000008][1970-01-01T00:00:00][ T0] clocksource: kvm-clock: mask: 0xffffffffffffffff max_cycles: 0x1cd42e4dffb, max_idle_ns: 881590591483 ns
[ 0.000022] [ 0.000022][1970-01-01T00:00:00][ T0] tsc: Detected 2112.000 MHz processor
[ 0.000835] [ 0.000835][1970-01-01T00:00:00][ T0] e820: update [mem 0x00000000-0x00000fff] usable ==> reserved

The realtime timestamps get ready later as expected:

[ 0.073075] [ 0.073075][1970-01-01T00:00:00][ T0] rcu: Adjusting geometry for rcu_fanout_leaf=16, nr_cpu_ids=3
[ 0.075847] [ 0.075847][1970-01-01T00:00:00][ T0] NR_IRQS: 524544, nr_irqs: 448, preallocated irqs: 16
[ 0.076014] [ 0.076014][2020-08-20T07:58:46][ T0] Console: colour dummy device 80x25
[ 0.076014] [ 0.076014][2020-08-20T07:58:46][ T0] printk: console [tty0] enabled

Also suspend resume seems to work as expected. I tested it the follwing way:

echo core > /sys/power/pm_test
echo reboot > /sys/power/disk
echo disk > /sys/power/state

and the result is:

[ 224.422540] [ 224.422540][2020-08-20T08:02:31][ T5124] Disabling non-boot CPUs ...
[ 224.424171] [ 224.424171][2020-08-20T08:02:31][ T15] IRQ fixup: irq 21 move in progress, old vector 36
[ 224.425304] [ 224.425304][2020-08-20T08:02:31][ T5124] smpboot: CPU 1 is now offline
[ 224.426664] [ 224.426664][2020-08-20T08:02:31][ T20] IRQ 21: no longer affine to CPU2
[ 224.426685] [ 224.426685][2020-08-20T08:02:31][ T20] IRQ 24: no longer affine to CPU2
[ 224.426717] [ 224.426717][2020-08-20T08:02:31][ T20] IRQ 27: no longer affine to CPU2
[ 224.427765] [ 224.427765][2020-08-20T08:02:31][ T5124] smpboot: CPU 2 is now offline
[ 224.428016] [ 224.428016][2020-08-20T08:02:31][ T5124] PM: hibernation: debug: Waiting for 5 seconds.
[ 224.428218] [ 229.618141][2020-08-20T08:02:36][ T5124] Enabling non-boot CPUs ...
^^^ ^^^ ^^
[ 224.428560] [ 229.618483][2020-08-20T08:02:36][ T5124] x86: Booting SMP configuration:
[ 224.428564] [ 229.618486][2020-08-20T08:02:36][ T5124] smpboot: Booting Node 0 Processor 1 APIC 0x1
[ 224.428766] [ 229.618688][2020-08-20T08:02:36][ T0] kvm-clock: cpu 1, msr 129c01041, secondary cpu clock
[ 224.449192] [ 229.639115][2020-08-20T08:02:36][ T14] kvm-guest: stealtime: cpu 1, msr 17fbf2080


And here is the patch that I used for testing: