Linux-Trace-Devel Archive on lore.kernel.org
 help / color / Atom feed
* [PATCH] tools/lib/traceevent: Round up in tep_print_event() time precision
@ 2019-09-19 20:51 Steven Rostedt
  2019-09-23 14:24 ` Arnaldo Carvalho de Melo
  0 siblings, 1 reply; 2+ messages in thread
From: Steven Rostedt @ 2019-09-19 20:51 UTC (permalink / raw)
  To: LKML
  Cc: Linux Trace Devel, Arnaldo Carvalho de Melo, Jiri Olsa,
	Tzvetomir Stoyanov


From: "Steven Rostedt (VMware)" <rostedt@goodmis.org>


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.

Signed-off-by: Steven Rostedt (VMware) <rostedt@goodmis.org>
---
 tools/lib/traceevent/event-parse.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/tools/lib/traceevent/event-parse.c b/tools/lib/traceevent/event-parse.c
index bb22238debfe..eb84fbb49e4d 100644
--- a/tools/lib/traceevent/event-parse.c
+++ b/tools/lib/traceevent/event-parse.c
@@ -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;
-- 
2.20.1


^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [PATCH] tools/lib/traceevent: Round up in tep_print_event() time precision
  2019-09-19 20:51 [PATCH] tools/lib/traceevent: Round up in tep_print_event() time precision Steven Rostedt
@ 2019-09-23 14:24 ` Arnaldo Carvalho de Melo
  0 siblings, 0 replies; 2+ messages in thread
From: Arnaldo Carvalho de Melo @ 2019-09-23 14:24 UTC (permalink / raw)
  To: Steven Rostedt; +Cc: LKML, Linux Trace Devel, Jiri Olsa, Tzvetomir Stoyanov

Em Thu, Sep 19, 2019 at 04:51:19PM -0400, Steven Rostedt escreveu:
> 
> From: "Steven Rostedt (VMware)" <rostedt@goodmis.org>
> 
> 
> 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
 
> Signed-off-by: Steven Rostedt (VMware) <rostedt@goodmis.org>
> ---
>  tools/lib/traceevent/event-parse.c | 4 +++-
>  1 file changed, 3 insertions(+), 1 deletion(-)
> 
> diff --git a/tools/lib/traceevent/event-parse.c b/tools/lib/traceevent/event-parse.c
> index bb22238debfe..eb84fbb49e4d 100644
> --- a/tools/lib/traceevent/event-parse.c
> +++ b/tools/lib/traceevent/event-parse.c
> @@ -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;
> -- 
> 2.20.1

-- 

- Arnaldo

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, back to index

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-09-19 20:51 [PATCH] tools/lib/traceevent: Round up in tep_print_event() time precision Steven Rostedt
2019-09-23 14:24 ` Arnaldo Carvalho de Melo

Linux-Trace-Devel Archive on lore.kernel.org

Archives are clonable:
	git clone --mirror https://lore.kernel.org/linux-trace-devel/0 linux-trace-devel/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 linux-trace-devel linux-trace-devel/ https://lore.kernel.org/linux-trace-devel \
		linux-trace-devel@vger.kernel.org linux-trace-devel@archiver.kernel.org
	public-inbox-index linux-trace-devel

Example config snippet for mirrors

Newsgroup available over NNTP:
	nntp://nntp.lore.kernel.org/org.kernel.vger.linux-trace-devel


AGPL code for this site: git clone https://public-inbox.org/ public-inbox