From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1760409AbcCEIT1 (ORCPT ); Sat, 5 Mar 2016 03:19:27 -0500 Received: from torg.zytor.com ([198.137.202.12]:58852 "EHLO terminus.zytor.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1752494AbcCEITT (ORCPT ); Sat, 5 Mar 2016 03:19:19 -0500 Date: Sat, 5 Mar 2016 00:19:06 -0800 From: "tip-bot for Chaos.Chen" Message-ID: Cc: rainboy1215@gmail.com, akpm@linux-foundation.org, rostedt@goodmis.org, tglx@linutronix.de, linux-kernel@vger.kernel.org, mingo@kernel.org, acme@redhat.com, hpa@zytor.com Reply-To: hpa@zytor.com, acme@redhat.com, mingo@kernel.org, linux-kernel@vger.kernel.org, tglx@linutronix.de, rostedt@goodmis.org, rainboy1215@gmail.com, akpm@linux-foundation.org In-Reply-To: <20160209204236.824426460@goodmis.org> References: <20160209204236.824426460@goodmis.org> To: linux-tip-commits@vger.kernel.org Subject: [tip:perf/core] tools lib traceevent: Fix time stamp rounding issue Git-Commit-ID: 21a30100453516004905d4d5f0806ebaffa95131 X-Mailer: tip-git-log-daemon Robot-ID: Robot-Unsubscribe: Contact to get blacklisted from these emails MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain; charset=UTF-8 Content-Disposition: inline Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Commit-ID: 21a30100453516004905d4d5f0806ebaffa95131 Gitweb: http://git.kernel.org/tip/21a30100453516004905d4d5f0806ebaffa95131 Author: Chaos.Chen AuthorDate: Tue, 9 Feb 2016 15:40:14 -0500 Committer: Arnaldo Carvalho de Melo CommitDate: Thu, 3 Mar 2016 11:10:37 -0300 tools lib traceevent: Fix time stamp rounding issue 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 Cc: Andrew Morton Link: http://lkml.kernel.org/r/20160209204236.824426460@goodmis.org [ fixed incrementing "secs" instead of decrementing it ] Signed-off-by: Steven Rostedt Signed-off-by: Arnaldo Carvalho de Melo --- 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 9a1e48a..ce59f48 100644 --- a/tools/lib/traceevent/event-parse.c +++ b/tools/lib/traceevent/event-parse.c @@ -5429,6 +5429,11 @@ void pevent_print_event_time(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; }