linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Jiri Olsa <jolsa@redhat.com>
To: Andi Kleen <andi@firstfloor.org>
Cc: acme@kernel.org, jolsa@kernel.org, linux-kernel@vger.kernel.org,
	linux-perf-users@vger.kernel.org, Andi Kleen <ak@linux.intel.com>
Subject: Re: [PATCH 2/4] perf, tools: Implement duration_time as a proper event
Date: Wed, 27 Mar 2019 09:58:13 +0100	[thread overview]
Message-ID: <20190327085813.GB24156@krava> (raw)
In-Reply-To: <20190326221823.11518-3-andi@firstfloor.org>

On Tue, Mar 26, 2019 at 03:18:21PM -0700, Andi Kleen wrote:
> From: Andi Kleen <ak@linux.intel.com>
> 
> The perf metric expression use duration_time internally to normalize
> events. Normal perf stat without -x also prints the duration time.
> But when using -x, the interval is not output anywhere, which
> is inconvenient for any post processing which often wants to
> normalize values to time.
> 
> So implement duration_time as a proper perf event that
> can be specified explicitely with -e.
> 
> The previous implementation of duration_time only worked
> for metric processing. This adds the concept of a tool
> event that is handled by the tool. On the kernel level
> it is still mapped to the dummy software event, but the
> values are not read anymore, but instead computed by the tool.
> 
> Add proper plumbing to handle this in the event parser,
> and display it in perf stat. We don't want duration_time to be added up,
> so it's only printed for the first CPU.
> 
> % perf stat -e duration_time,cycles true
> 
>  Performance counter stats for 'true':
> 
>            555,476 ns   duration_time
>            771,958      cycles
> 
>        0.000555476 seconds time elapsed
> 
>        0.000644000 seconds user
>        0.000000000 seconds sys
> 
> Signed-off-by: Andi Kleen <ak@linux.intel.com>
> ---
>  tools/perf/builtin-stat.c      | 28 ++++++++++++++++++-------
>  tools/perf/util/evsel.h        |  6 ++++++
>  tools/perf/util/parse-events.c | 38 +++++++++++++++++++++++++++++-----
>  tools/perf/util/parse-events.h |  4 ++++
>  tools/perf/util/parse-events.l | 11 +++++++++-
>  tools/perf/util/parse-events.y | 12 +++++++++++
>  6 files changed, 86 insertions(+), 13 deletions(-)
> 
> diff --git a/tools/perf/builtin-stat.c b/tools/perf/builtin-stat.c
> index 49ee3c2033ec..7f9c4b7f5d69 100644
> --- a/tools/perf/builtin-stat.c
> +++ b/tools/perf/builtin-stat.c
> @@ -244,11 +244,25 @@ perf_evsel__write_stat_event(struct perf_evsel *counter, u32 cpu, u32 thread,
>  					   process_synthesized_event, NULL);
>  }
>  
> +static int read_single_counter(struct perf_evsel *counter, int cpu,
> +			       int thread, struct timespec *rs)
> +{
> +	if (counter->tool_event == PERF_TOOL_DURATION_TIME) {
> +		u64 val = rs->tv_nsec + rs->tv_sec*1000000000ULL;
> +		struct perf_counts_values *count =
> +			perf_counts(counter->counts, cpu, thread);
> +		count->ena = count->run = val;
> +		count->val = val;
> +		return 0;
> +	}
> +	return perf_evsel__read_counter(counter, cpu, thread);
> +}

so now that we have time in a separate event, we could
get rid of the isolated update_stats(&walltime_nsecs_stats) calls
and move them to perf_stat__update_shadow_stats?

jirka

  reply	other threads:[~2019-03-27  8:58 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-03-26 22:18 perf: Add duration_time to perf stat Andi Kleen
2019-03-26 22:18 ` [PATCH 1/4] perf, tools: Revert checks for duration_time Andi Kleen
2019-04-05 11:38   ` [tip:perf/core] perf stat: " tip-bot for Andi Kleen
2019-03-26 22:18 ` [PATCH 2/4] perf, tools: Implement duration_time as a proper event Andi Kleen
2019-03-27  8:58   ` Jiri Olsa [this message]
2019-03-27 13:54     ` Andi Kleen
2019-04-05 11:39   ` [tip:perf/core] perf stat: " tip-bot for Andi Kleen
2019-03-26 22:18 ` [PATCH 3/4] perf, tools: Support name for duration_time Andi Kleen
2019-04-05 11:39   ` [tip:perf/core] perf evsel: Support printing evsel name for 'duration_time' tip-bot for Andi Kleen
2019-03-26 22:18 ` [PATCH 4/4] perf, tools, list: Output tool events Andi Kleen
2019-04-05 11:40   ` [tip:perf/core] perf " tip-bot for Andi Kleen
2019-03-27 19:51 ` perf: Add duration_time to perf stat Jiri Olsa

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=20190327085813.GB24156@krava \
    --to=jolsa@redhat.com \
    --cc=acme@kernel.org \
    --cc=ak@linux.intel.com \
    --cc=andi@firstfloor.org \
    --cc=jolsa@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-perf-users@vger.kernel.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).