diff mbox series

libtraceevent: Allow for decimal time stamps less than zero

Message ID 20210324141451.0b4af13b@gandalf.local.home (mailing list archive)
State Accepted
Commit cd9cf71c1ac1c57037e2749eef210116b9f1ce64
Headers show
Series libtraceevent: Allow for decimal time stamps less than zero | expand

Commit Message

Steven Rostedt March 24, 2021, 6:14 p.m. UTC
From: Steven Rostedt (VMware) <rostedt@goodmis.org>

The time parsing of the time stamp should not care if the divisor is less
than the time to decide to print a decimal output or not. If it does, then
we can get output that looks like this:

       trace-cmd-4332  [006]       997355: lock_acquire:         0xffffffffb4a7ee00 fs_reclaim
       trace-cmd-4332  [006]       997356: lock_acquire:         0xffffffffb4a81480 mmu_notifier_invalidate_range_start
       trace-cmd-4332  [006]       997357: lock_release:         0xffffffffb4a81480 mmu_notifier_invalidate_range_start
       trace-cmd-4332  [006]       997357: lock_release:         0xffffffffb4a7ee00 fs_reclaim
       trace-cmd-4332  [006]       997358: kmalloc:              (tracing_buffers_splice_read+0x233) call_site=tracing_buffers_splice_read+0x233 
       trace-cmd-4240  [007]     1.000684: lock_acquire:         0xffffffffb4a3ae48 read tk_core.seq.seqcount
       trace-cmd-4240  [007]     1.000684: lock_release:         0xffffffffb4a3ae48 tk_core.seq.seqcount
       trace-cmd-4240  [007]     1.000684: irq_enable:           caller=ktime_get_coarse_real_ts64+0xc8 parent=0x0
       trace-cmd-4240  [007]     1.000685: ext4_da_write_begin:  dev 253,2 ino 4724578 pos 24150016 len 4096 flags 0

Which is obviously incorrect.

Should be:

       trace-cmd-4332  [006]     0.997355: lock_acquire:         0xffffffffb4a7ee00 fs_reclaim
       trace-cmd-4332  [006]     0.997356: lock_acquire:         0xffffffffb4a81480 mmu_notifier_invalidate_range_start
       trace-cmd-4332  [006]     0.997357: lock_release:         0xffffffffb4a81480 mmu_notifier_invalidate_range_start
       trace-cmd-4332  [006]     0.997357: lock_release:         0xffffffffb4a7ee00 fs_reclaim
       trace-cmd-4332  [006]     0.997358: kmalloc:              (tracing_buffers_splice_read+0x233) call_site=tracing_buffers_splice_read+0x233
       trace-cmd-4240  [007]     1.000684: lock_acquire:         0xffffffffb4a3ae48 read tk_core.seq.seqcount
       trace-cmd-4240  [007]     1.000684: lock_release:         0xffffffffb4a3ae48 tk_core.seq.seqcount
       trace-cmd-4240  [007]     1.000684: irq_enable:           caller=ktime_get_coarse_real_ts64+0xc8 parent=0x0
       trace-cmd-4240  [007]     1.000685: ext4_da_write_begin:  dev 253,2 ino 4724578 pos 24150016 len 4096 flags 0


Signed-off-by: Steven Rostedt (VMware) <rostedt@goodmis.org>
---
diff mbox series

Patch

diff --git a/src/event-parse.c b/src/event-parse.c
index 2a10c2e..e2a7278 100644
--- a/src/event-parse.c
+++ b/src/event-parse.c
@@ -6110,7 +6110,7 @@  static void print_event_time(struct tep_handle *tep, struct trace_seq *s,
 	while (pr--)
 		p10 *= 10;
 
-	if (p10 > 1 && p10 < time)
+	if (p10 > 1)
 		trace_seq_printf(s, "%5llu.%0*llu", time / p10, prec, time % p10);
 	else
 		trace_seq_printf(s, "%12llu", time);