[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20150408132833.GA2607@danjae.kornet>
Date: Wed, 8 Apr 2015 22:28:33 +0900
From: Namhyung Kim <namhyung@...nel.org>
To: Jiri Olsa <jolsa@...nel.org>
Cc: Arnaldo Carvalho de Melo <acme@...nel.org>,
lkml <linux-kernel@...r.kernel.org>,
Peter Zijlstra <a.p.zijlstra@...llo.nl>,
Paul Mackerras <paulus@...ba.org>,
David Ahern <dsahern@...il.com>,
Ingo Molnar <mingo@...nel.org>,
Andi Kleen <andi@...stfloor.org>,
William Cohen <wcohen@...hat.com>
Subject: Re: [PATCH 2/6] perf stat: Fix metrics calculation with event
qualifiers
Hi Jiri and Andi,
On Tue, Apr 07, 2015 at 11:25:15PM +0200, Jiri Olsa wrote:
> From: Andi Kleen <ak@...ux.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@...nel.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@...ux.intel.com>
Signed-off-by: Namhyung Kim <namhyung@...nel.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
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Powered by blists - more mailing lists