lkml.org 
[lkml]   [2015]   [Apr]   [8]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
Date
From
SubjectRe: [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@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


\
 
 \ /
  Last update: 2015-04-08 16:01    [W:1.238 / U:0.012 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site