From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932739AbcBIUn0 (ORCPT ); Tue, 9 Feb 2016 15:43:26 -0500 Received: from mail.kernel.org ([198.145.29.136]:34382 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755367AbcBIUmm (ORCPT ); Tue, 9 Feb 2016 15:42:42 -0500 Message-Id: <20160209204236.824426460@goodmis.org> User-Agent: quilt/0.61-1 Date: Tue, 09 Feb 2016 15:40:14 -0500 From: Steven Rostedt To: linux-kernel@vger.kernel.org Cc: Arnaldo Carvalho de Melo , Ingo Molnar , Andrew Morton , "Chaos.Chen" Subject: [PATCH 1/4] tools lib traceevent: Fix time stamp rounding issue References: <20160209204013.951400594@goodmis.org> MIME-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-15 Content-Disposition: inline; filename=0001-tools-lib-traceevent-Fix-time-stamp-rounding-issue.patch Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: "Chaos.Chen" When rounding to microseconds, if the timestamp subsecond is between .999999500 and .999999999, it is rounded to .1000000, when it should instead increment the second counter due to the overflow. For example, if the timestamp is 1234.999999501 instead of seeing: 1235.000000 we see 1234.1000000 Signed-off-by: Chaos.Chen [ fixed incrementing "secs" instead of decrementing it ] Signed-off-by: Steven Rostedt --- tools/lib/traceevent/event-parse.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/tools/lib/traceevent/event-parse.c b/tools/lib/traceevent/event-parse.c index c3bd294a63d1..a6f1ce779e05 100644 --- a/tools/lib/traceevent/event-parse.c +++ b/tools/lib/traceevent/event-parse.c @@ -5387,6 +5387,11 @@ void pevent_print_event(struct pevent *pevent, struct trace_seq *s, p = 9; } else { usecs = (nsecs + 500) / NSECS_PER_USEC; + /* To avoid usecs larger than 1 sec */ + if (usecs >= 1000000) { + usecs -= 1000000; + secs++; + } p = 6; } -- 2.6.4