Skip to contentSkip to conversation

tools/lib/traceevent: Round up in tep_print_event() time precision

PATCH Applied Steven Rostedt 2 participants 2 messages Sep 19, 2019 – Sep 23, 2019

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 tools/lib/traceevent: Round up in tep_print_event() time precision

From: "Steven Rostedt (VMware)" <[email protected]>

When testing the output of the old trace-cmd compared to the one that uses the updated tep_print_event() logic, it was different in that the time stamp precision in the old format would round up to the nearest precision, where as the new logic truncates. Bring back the old method of rounding up.

---
 tools/lib/traceevent/event-parse.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
tools/lib/traceevent/event-parse.c +3 -1
index bb22238debfe..eb84fbb49e4d 100644
@@ -5517,8 +5517,10 @@ static void print_event_time(struct tep_handle *tep, struct trace_seq *s,
 	if (divstr && isdigit(*(divstr + 1)))
 		div = atoi(divstr + 1);
 	time = record->ts;
-	if (div)
+	if (div) {
+		time += div / 2;
 		time /= div;
+	}
 	pr = prec;
 	while (pr--)
 		p10 *= 10;
Signature · 1 line
2.20.1
#1 lore raw

Em Thu, Sep 19, 2019 at 04:51:19PM -0400, Steven Rostedt escreveu:

Quoted 8 lines

From: "Steven Rostedt (VMware)" <[email protected]>

When testing the output of the old trace-cmd compared to the one that uses the updated tep_print_event() logic, it was different in that the time stamp precision in the old format would round up to the nearest precision, where as the new logic truncates. Bring back the old method of rounding up.

Thanks, applied.

- Arnaldo

Quoted 23 lines
---
 tools/lib/traceevent/event-parse.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
tools/lib/traceevent/event-parse.c +3 -1
index bb22238debfe..eb84fbb49e4d 100644
@@ -5517,8 +5517,10 @@ static void print_event_time(struct tep_handle *tep, struct trace_seq *s,
 	if (divstr && isdigit(*(divstr + 1)))
 		div = atoi(divstr + 1);
 	time = record->ts;
-	if (div)
+	if (div) {
+		time += div / 2;
 		time /= div;
+	}
 	pr = prec;
 	while (pr--)
 		p10 *= 10;
Signature · 1 line
2.20.1
Signature · 1 line
- Arnaldo