ring-buffer: Have absolute time stamps handle large numbers
authorSteven Rostedt (Google) <rostedt@goodmis.org>
Wed, 27 Apr 2022 19:33:39 +0000 (15:33 -0400)
committerSteven Rostedt (Google) <rostedt@goodmis.org>
Wed, 27 Apr 2022 19:59:44 +0000 (15:59 -0400)
commit6695da58f9445f386516ed53a3e870f534d2645d
treee64b63fc18f5546270addb37f874045e06ba3ad1
parent6621a7004684bfcff5af4c8e4d37989941f42a6b
ring-buffer: Have absolute time stamps handle large numbers

There's an absolute timestamp event in the ring buffer, but this only
saves 59 bits of the timestamp, as the 5 MSB is used for meta data
(stating it is an absolute time stamp). This was never an issue as all the
clocks currently in use never used those 5 MSB. But now there's a new
clock (TAI) that does.

To handle this case, when reading an absolute timestamp, a previous full
timestamp is passed in, and the 5 MSB of that timestamp is OR'd to the
absolute timestamp (if any of the 5 MSB are set), and then to test for
overflow, if the new result is smaller than the passed in previous
timestamp, then 1 << 59 is added to it.

All the extra processing is done on the reader "slow" path, with the
exception of the "too big delta" check, and the reading of timestamps
for histograms.

Note, libtraceevent will need to be updated to handle this case as well.
But this is not a user space regression, as user space was never able to
handle any timestamps that used more than 59 bits.

Link: https://lore.kernel.org/all/20220426175338.3807ca4f@gandalf.local.home/
Link: https://lkml.kernel.org/r/20220427153339.16c33f75@gandalf.local.home
Cc: Tom Zanussi <zanussi@kernel.org>
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: Kurt Kanzenbach <kurt@linutronix.de>
Signed-off-by: Steven Rostedt (Google) <rostedt@goodmis.org>
kernel/trace/ring_buffer.c