[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <1450381644-25674-33-git-send-email-acme@kernel.org>
Date: Thu, 17 Dec 2015 16:47:13 -0300
From: Arnaldo Carvalho de Melo <acme@...nel.org>
To: Ingo Molnar <mingo@...nel.org>
Cc: linux-kernel@...r.kernel.org, Jiri Olsa <jolsa@...nel.org>,
David Ahern <dsahern@...il.com>,
Namhyung Kim <namhyung@...nel.org>,
Peter Zijlstra <a.p.zijlstra@...llo.nl>,
Arnaldo Carvalho de Melo <acme@...hat.com>
Subject: [PATCH 32/43] perf stat record: Write stat events on record
From: Jiri Olsa <jolsa@...nel.org>
Writing stat events on 'perf stat record' at the time we read counter
values from kernel.
Committer note:
After the patch:
$ perf stat record usleep 1
Performance counter stats for 'usleep 1':
0.598006 task-clock (msec) # 0.484 CPUs utilized
1 context-switches # 0.002 M/sec
0 cpu-migrations # 0.000 K/sec
52 page-faults # 0.087 M/sec
882,744 cycles # 1.476 GHz
581,416 stalled-cycles-frontend # 65.86% frontend cycles idle
<not supported> stalled-cycles-backend
636,479 instructions # 0.72 insns per cycle
# 0.91 stalled cycles per insn
129,334 branches # 216.275 M/sec
7,512 branch-misses # 5.81% of all branches
0.001235157 seconds time elapsed
$ oldperf evlist
task-clock
context-switches
cpu-migrations
page-faults
cycles
stalled-cycles-frontend
stalled-cycles-backend
instructions
branches
branch-misses
$ oldperf report --stdio
Error:
The perf.data file has no samples!
# To display the perf.data header info, please use --header/--header-only options.
#
$ perf report -D | grep PERF_RECORD
0x5b0 [0x28]: PERF_RECORD_THREAD_MAP nr: 1 thread: 5504
0x5d8 [0x12]: PERF_RECORD_CPU_MAP nr: 1 cpu: 65535
0x5ea [0x40]: PERF_RECORD_STAT_CONFIG
0x62a [0x30]: PERF_RECORD_STAT
0x65a [0x30]: PERF_RECORD_STAT
0x68a [0x30]: PERF_RECORD_STAT
0x6ba [0x30]: PERF_RECORD_STAT
0x6ea [0x30]: PERF_RECORD_STAT
0x71a [0x30]: PERF_RECORD_STAT
0x74a [0x30]: PERF_RECORD_STAT
0x77a [0x30]: PERF_RECORD_STAT
0x7aa [0x30]: PERF_RECORD_STAT
-1 -1 0x7da [0x40]: PERF_RECORD_MMAP -1/0: [0xffffffff81000000(0x1f000000) @ 0xffffffff81000000]: x [kernel.kallsyms]_text
$
Signed-off-by: Jiri Olsa <jolsa@...nel.org>
Tested-by: Kan Liang <kan.liang@...el.com>
Cc: David Ahern <dsahern@...il.com>
Cc: Namhyung Kim <namhyung@...nel.org>
Cc: Peter Zijlstra <a.p.zijlstra@...llo.nl>
Link: http://lkml.kernel.org/r/1446734469-11352-8-git-send-email-jolsa@kernel.org
Signed-off-by: Arnaldo Carvalho de Melo <acme@...hat.com>
---
tools/perf/builtin-stat.c | 19 +++++++++++++++++++
1 file changed, 19 insertions(+)
diff --git a/tools/perf/builtin-stat.c b/tools/perf/builtin-stat.c
index 8a2f9ce677e7..32aa2ea1c553 100644
--- a/tools/perf/builtin-stat.c
+++ b/tools/perf/builtin-stat.c
@@ -231,6 +231,18 @@ static int process_synthesized_event(struct perf_tool *tool __maybe_unused,
return 0;
}
+#define SID(e, x, y) xyarray__entry(e->sample_id, x, y)
+
+static int
+perf_evsel__write_stat_event(struct perf_evsel *counter, u32 cpu, u32 thread,
+ struct perf_counts_values *count)
+{
+ struct perf_sample_id *sid = SID(counter, cpu, thread);
+
+ return perf_event__synthesize_stat(NULL, cpu, thread, sid->id, count,
+ process_synthesized_event, NULL);
+}
+
/*
* Read out the results of a single counter:
* do not aggregate counts across CPUs in system-wide mode
@@ -254,6 +266,13 @@ static int read_counter(struct perf_evsel *counter)
count = perf_counts(counter->counts, cpu, thread);
if (perf_evsel__read(counter, cpu, thread, count))
return -1;
+
+ if (STAT_RECORD) {
+ if (perf_evsel__write_stat_event(counter, cpu, thread, count)) {
+ pr_err("failed to write stat event\n");
+ return -1;
+ }
+ }
}
}
--
2.1.0
--
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