public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Namhyung Kim <namhyung@kernel.org>
To: Jiri Olsa <jolsa@kernel.org>
Cc: Arnaldo Carvalho de Melo <acme@kernel.org>,
	lkml <linux-kernel@vger.kernel.org>,
	Peter Zijlstra <a.p.zijlstra@chello.nl>,
	Paul Mackerras <paulus@samba.org>,
	David Ahern <dsahern@gmail.com>, Ingo Molnar <mingo@kernel.org>,
	Andi Kleen <andi@firstfloor.org>,
	William Cohen <wcohen@redhat.com>
Subject: Re: [PATCH 2/6] perf stat: Fix metrics calculation with event qualifiers
Date: Wed, 8 Apr 2015 22:28:33 +0900	[thread overview]
Message-ID: <20150408132833.GA2607@danjae.kornet> (raw)
In-Reply-To: <1428441919-23099-3-git-send-email-jolsa@kernel.org>

Hi Jiri and Andi,

On Tue, Apr 07, 2015 at 11:25:15PM +0200, Jiri Olsa wrote:
> From: Andi Kleen <ak@linux.intel.com>
> 
> Currently in perf IPC and other metrics cannot be directly shown
> separately for both user and kernel in a single run. The problem was
> that the metrics matching code did not check event qualifiers.
> 
> With this patch the following case works correctly.
> 
> % perf stat -e cycles:k,cycles:u,instructions:k,instructions:u true
> 
>  Performance counter stats for 'true':
> 
>            531,718      cycles:k
>            203,895      cycles:u
>            338,151      instructions:k            #    0.64  insns per cycle
>            105,961      instructions:u            #    0.52  insns per cycle
> 
>        0.002989739 seconds time elapsed
> 
> Previously it would misreport the ratios because they were matching
> the wrong value.

This patch reminds me of following change:


>From a8ae843bf7cff7b68dc39b6f088c43669d140d00 Mon Sep 17 00:00:00 2001
From: Namhyung Kim <namhyung@kernel.org>
Date: Wed, 8 Apr 2015 21:56:12 +0900
Subject: [RFC] perf stat: Add -U/--user option

The -U/--user option is to control event modifier for all events easily.
It has same effect as if adding 'u' modifier to every events.

An example follows:

  $ perf stat -U true

   Performance counter stats for 'true':

            0.722461      task-clock:uH (msec)      #    0.520 CPUs utilized
                   0      context-switches:uH       #    0.000 K/sec
                   0      cpu-migrations:uH         #    0.000 K/sec
                  41      page-faults:uH            #    0.057 M/sec
             145,341      cycles:uH                 #    0.201 GHz
             517,317      stalled-cycles-frontend:uH #  355.93% frontend cycles idle
             497,570      stalled-cycles-backend:uH #  342.35% backend  cycles idle
              98,846      instructions:uH           #    0.68  insns per cycle
                                                    #    5.23  stalled cycles per insn
              19,552      branches:uH               #   27.063 M/sec
       <not counted>      branch-misses:uH

         0.001389613 seconds time elapsed

Cc: Andi Kleen <ak@linux.intel.com>
Signed-off-by: Namhyung Kim <namhyung@kernel.org>
---
 tools/perf/Documentation/perf-stat.txt |  5 ++++-
 tools/perf/builtin-stat.c              | 11 +++++++++++
 2 files changed, 15 insertions(+), 1 deletion(-)

diff --git a/tools/perf/Documentation/perf-stat.txt b/tools/perf/Documentation/perf-stat.txt
index 04e150d83e7d..54b0734028a6 100644
--- a/tools/perf/Documentation/perf-stat.txt
+++ b/tools/perf/Documentation/perf-stat.txt
@@ -151,9 +151,12 @@ filter out the startup phase of the program, which is often very different.
 
 -T::
 --transaction::
-
 Print statistics of transactional execution if supported.
 
+-U::
+--user::
+Collect events only in user mode execution
+
 EXAMPLES
 --------
 
diff --git a/tools/perf/builtin-stat.c b/tools/perf/builtin-stat.c
index fec089f1c364..d191af942cb4 100644
--- a/tools/perf/builtin-stat.c
+++ b/tools/perf/builtin-stat.c
@@ -141,6 +141,7 @@ static unsigned int		interval			= 0;
 static unsigned int		initial_delay			= 0;
 static unsigned int		unit_width			= 4; /* strlen("unit") */
 static bool			forever				= false;
+static bool			mod_user			= false;
 static struct timespec		ref_time;
 static struct cpu_map		*aggr_map;
 static int			(*aggr_get_id)(struct cpu_map *m, int cpu);
@@ -1809,6 +1810,7 @@ int cmd_stat(int argc, const char **argv, const char *prefix __maybe_unused)
 		     "aggregate counts per physical processor core", AGGR_CORE),
 	OPT_UINTEGER('D', "delay", &initial_delay,
 		     "ms to wait before starting measurement after program start"),
+	OPT_BOOLEAN('U', "user", &mod_user, "Count event only in user mode"),
 	OPT_END()
 	};
 	const char * const stat_usage[] = {
@@ -1913,6 +1915,15 @@ int cmd_stat(int argc, const char **argv, const char *prefix __maybe_unused)
 	if (add_default_attributes())
 		goto out;
 
+	if (mod_user) {
+		struct perf_evsel *evsel;
+
+		evlist__for_each(evsel_list, evsel) {
+			evsel->attr.exclude_kernel = 1;
+			evsel->attr.exclude_hv = 1;
+		}
+	}
+
 	target__validate(&target);
 
 	if (perf_evlist__create_maps(evsel_list, &target) < 0) {
-- 
2.3.5


  reply	other threads:[~2015-04-08 13:29 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-04-07 21:25 [RFC 0/6] perf stat: Metrics calculation fix Jiri Olsa
2015-04-07 21:25 ` [PATCH 1/6] perf tools: Add 'I' event modifier for exclude_idle bit Jiri Olsa
2015-04-08 12:56   ` Arnaldo Carvalho de Melo
2015-04-08 15:15   ` [tip:perf/core] " tip-bot for Jiri Olsa
2015-04-07 21:25 ` [PATCH 2/6] perf stat: Fix metrics calculation with event qualifiers Jiri Olsa
2015-04-08 13:28   ` Namhyung Kim [this message]
2015-04-23 22:15     ` Arnaldo Carvalho de Melo
2015-05-06  3:07   ` [tip:perf/core] " tip-bot for Andi Kleen
2015-04-07 21:25 ` [PATCH 3/6] perf stat: Change metrics context calculation Jiri Olsa
2015-05-06  3:08   ` [tip:perf/core] " tip-bot for Jiri Olsa
2015-04-07 21:25 ` [PATCH 4/6] perf stat: Add metrics support for exclude_hv Jiri Olsa
2015-05-06  3:08   ` [tip:perf/core] " tip-bot for Jiri Olsa
2015-04-07 21:25 ` [PATCH 5/6] perf stat: Add metrics support for exclude_(host|guest) Jiri Olsa
2015-05-06  3:08   ` [tip:perf/core] perf stat: Add metrics support for exclude_( host|guest) tip-bot for Jiri Olsa
2015-04-07 21:25 ` [PATCH 6/6] perf stat: Add metrics support for exclude_idle Jiri Olsa
2015-05-06  3:08   ` [tip:perf/core] " tip-bot for Jiri Olsa
2015-04-07 21:30 ` [RFC 0/6] perf stat: Metrics calculation fix Jiri Olsa
2015-04-18 13:40 ` Jiri Olsa
2015-04-19  3:46 ` Namhyung Kim

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=20150408132833.GA2607@danjae.kornet \
    --to=namhyung@kernel.org \
    --cc=a.p.zijlstra@chello.nl \
    --cc=acme@kernel.org \
    --cc=andi@firstfloor.org \
    --cc=dsahern@gmail.com \
    --cc=jolsa@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mingo@kernel.org \
    --cc=paulus@samba.org \
    --cc=wcohen@redhat.com \
    /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