All of lore.kernel.org
 help / color / mirror / Atom feed
From: Arnaldo Carvalho de Melo <acme@kernel.org>
To: Steven Rostedt <rostedt@goodmis.org>
Cc: linux-kernel@vger.kernel.org, Ingo Molnar <mingo@kernel.org>,
	Jiri Olsa <jolsa@redhat.com>, Namhyung Kim <namhyung@kernel.org>,
	Andrew Morton <akpm@linux-foundation.org>
Subject: Re: [PATCH 2/2] tools lib traceevent: Use USECS_PER_SEC instead of hardcoded number
Date: Mon, 21 Nov 2016 16:11:06 -0300	[thread overview]
Message-ID: <20161121191106.GA5390@kernel.org> (raw)
In-Reply-To: <20161121114149.67111981@gandalf.local.home>

Em Mon, Nov 21, 2016 at 11:41:49AM -0500, Steven Rostedt escreveu:
> On Fri, 18 Nov 2016 20:40:22 -0300
> Arnaldo Carvalho de Melo <acme@kernel.org> wrote:
> 
> > Em Fri, Nov 18, 2016 at 05:54:01PM -0500, Steven Rostedt escreveu:
> > > From: "Steven Rostedt (Red Hat)" <rostedt@goodmis.org>
> > > 
> > > Instead of using 1000000, define a USECS_PER_SEC macro and use that instead.  
> > 
> > We already have it in tools/include/linux/time64.h :-)
> 
> Here's v2 then. Can you take both patches?

Sure.

- Arnaldo
 
> -- Steve
> 
> 
> From 856b584cb783b658d200aa3fca8faba58d52ae82 Mon Sep 17 00:00:00 2001
> From: "Steven Rostedt (Red Hat)" <rostedt@goodmis.org>
> Date: Tue, 9 Feb 2016 15:40:15 -0500
> Subject: [PATCH] tools lib traceevent: Use USEC_PER_SEC instead of hardcoded
>  number
> 
> Instead of using 1000000, use the define in time64.h instead.
> 
> Also remove the the duplicate defines for NSECS_PER_SEC.
> 
> Link: http://lkml.kernel.org/r/20160209204237.006667394@goodmis.org
> 
> Signed-off-by: Steven Rostedt <rostedt@goodmis.org>
> ---
>  tools/lib/traceevent/event-parse.c | 11 ++++++-----
>  tools/lib/traceevent/event-parse.h |  3 ---
>  2 files changed, 6 insertions(+), 8 deletions(-)
> 
> diff --git a/tools/lib/traceevent/event-parse.c b/tools/lib/traceevent/event-parse.c
> index d6f3cc0a29b0..8206227866dc 100644
> --- a/tools/lib/traceevent/event-parse.c
> +++ b/tools/lib/traceevent/event-parse.c
> @@ -33,6 +33,7 @@
>  #include <stdint.h>
>  #include <limits.h>
>  #include <linux/string.h>
> +#include <linux/time64.h>
>  
>  #include <netinet/in.h>
>  #include "event-parse.h"
> @@ -5450,8 +5451,8 @@ void pevent_print_event_time(struct pevent *pevent, struct trace_seq *s,
>  	use_usec_format = is_timestamp_in_us(pevent->trace_clock,
>  							use_trace_clock);
>  	if (use_usec_format) {
> -		secs = record->ts / NSECS_PER_SEC;
> -		nsecs = record->ts - secs * NSECS_PER_SEC;
> +		secs = record->ts / NSEC_PER_SEC;
> +		nsecs = record->ts - secs * NSEC_PER_SEC;
>  	}
>  
>  	if (pevent->latency_format) {
> @@ -5463,10 +5464,10 @@ void pevent_print_event_time(struct pevent *pevent, struct trace_seq *s,
>  			usecs = nsecs;
>  			p = 9;
>  		} else {
> -			usecs = (nsecs + 500) / NSECS_PER_USEC;
> +			usecs = (nsecs + 500) / NSEC_PER_USEC;
>  			/* To avoid usecs larger than 1 sec */
> -			if (usecs >= 1000000) {
> -				usecs -= 1000000;
> +			if (usecs >= USEC_PER_SEC) {
> +				usecs -= USEC_PER_SEC;
>  				secs++;
>  			}
>  			p = 6;
> diff --git a/tools/lib/traceevent/event-parse.h b/tools/lib/traceevent/event-parse.h
> index 41b3d2238ed3..dfa06f4e7abf 100644
> --- a/tools/lib/traceevent/event-parse.h
> +++ b/tools/lib/traceevent/event-parse.h
> @@ -172,9 +172,6 @@ struct pevent_plugin_option {
>  #define PEVENT_PLUGIN_OPTIONS_NAME MAKE_STR(PEVENT_PLUGIN_OPTIONS)
>  #define PEVENT_PLUGIN_ALIAS_NAME MAKE_STR(PEVENT_PLUGIN_ALIAS)
>  
> -#define NSECS_PER_SEC		1000000000ULL
> -#define NSECS_PER_USEC		1000ULL
> -
>  enum format_flags {
>  	FIELD_IS_ARRAY		= 1,
>  	FIELD_IS_POINTER	= 2,
> -- 
> 2.1.0

  reply	other threads:[~2016-11-21 19:12 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-11-18 22:53 [PATCH 0/2] tools lib traceevent: A couple of updates Steven Rostedt
2016-11-18 22:54 ` [PATCH 1/2] tools lib traceevent: Add retrieval of preempt count and latency flags Steven Rostedt
2016-11-22  6:52   ` Namhyung Kim
2016-11-22 14:33     ` Steven Rostedt
2016-11-22 16:31     ` [PATCH v2] " Steven Rostedt
2016-11-22 18:06       ` Arnaldo Carvalho de Melo
2016-11-23  4:45         ` Namhyung Kim
2016-11-24  4:15       ` [tip:perf/core] " tip-bot for Steven Rostedt
2016-11-18 22:54 ` [PATCH 2/2] tools lib traceevent: Use USECS_PER_SEC instead of hardcoded number Steven Rostedt
2016-11-18 23:40   ` Arnaldo Carvalho de Melo
2016-11-21 16:41     ` Steven Rostedt
2016-11-21 19:11       ` Arnaldo Carvalho de Melo [this message]
2016-11-22  6:53       ` Namhyung Kim
2016-11-24  4:14       ` [tip:perf/core] " tip-bot for Steven Rostedt

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20161121191106.GA5390@kernel.org \
    --to=acme@kernel.org \
    --cc=akpm@linux-foundation.org \
    --cc=jolsa@redhat.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mingo@kernel.org \
    --cc=namhyung@kernel.org \
    --cc=rostedt@goodmis.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.