Re: [GIT pull] printk updates for 4.15

From: Mark Salyzyn
Date: Tue Nov 14 2017 - 17:10:46 EST


On 11/14/2017 01:29 PM, Linus Torvalds wrote:
And then maybe you can send a single patch that changes *ONLY*
print_time(), with an explanation of how Android uses
CONFIG_PRINTK_TIME and would like that to be realtime instead of the
monotonic clock that we traditionally use.
I would be pleased to be educated.

print_time() uses msg->ts_nsec; and AFAIK that needs to be in reference to the timebase. You can not after the fact acquire the correct synchronization and corrections between boottime and localtime/monotonic for example, it has to be landed at point of logging, not reconstructed at time of printing?

[TL;DR]

We would need to land the at-time-of-logging correction factor(s) for the timebase for each logged entry for print_time() to provide a correct fixed value when dumped. eg I would also need these values handy in the msg structure:

tk->xtime_sec;
tk->wall_to_monotonic->tv_sec
tk->wall_to_monotonic->tv_nsec
tk->raw_time.tv_sec;
tk->raw_time.tv_nsec
tk->tkr_raw.shift
tk->tkr_raw.xtime_nsec;
tk->tkr_raw.mult;
rk->tkr_raw.shift
tk->tkr_mono.xtime_nsec
tk->tkr_mono.xtime_nsec;
tk->tkr_mono.mult;
tk->tkr_mono.shift;
tk->tkr_mono.mask;
tk->tkr_mono.cycle_last;
tk->offs_boot;

(or live with it your way, klogd grabbing the 'relatively correct' entries ASAP, but then dmesg output will differ)

Having a periodic message with a hint for correction factors helps (which we have used in a prototype dmesg tool), but drift puts us in the ms region (which I was satisfied with, but some of our partners were not) when they would have liked us (or ns) time precision.

For Android, periodic correction prints at time disruptions is good enough, I am merely advocating for some of the partners needs.

-- Mark