perf report: Add function for verbose dump of raw data
PATCH 1/4 perf report: Add function for verbose dump of raw data
Add support to call an architecture dependend function to interpret raw data verbatim when dumping the perf.data file with option -D.
This allows to display the event's raw data more verbatim than just plain hex data.
--- tools/perf/util/session.c | 7 +++++++ tools/perf/util/session.h | 3 +++ 2 files changed, 10 insertions(+)
tools/perf/util/session.c +7 -0
@@ -1050,6 +1050,12 @@ static void sample_read__printf(struct perf_sample *sample, u64 read_format) sample->read.one.id, sample->read.one.value); } +void __weak arch__trace_event (struct perf_evlist *evlist__maybe_unused , +union perf_event *event__maybe_unused , +struct perf_sample *sample__maybe_unused ) +{ +} +static void dump_event (struct perf_evlist *evlist,union perf_event *event,u64 file_offset,struct perf_sample *sample) {
@@ -1060,6 +1066,7 @@ static void dump_event(struct perf_evlist *evlist, union perf_event *event, file_offset, event->header.size, event->header.type);trace_event (event); +arch__trace_event (evlist, event, sample);if (sample)perf_evlist__print_tstamp (evlist, event, sample);
tools/perf/util/session.h +3 -0
@@ -128,4 +128,7 @@ int perf_event__synthesize_id_index(struct perf_tool *tool,struct perf_evlist *evlist, struct machine *machine); +void arch__trace_event (struct perf_evlist *evlist__maybe_unused , +union perf_event *event__maybe_unused , +struct perf_sample *sample__maybe_unused );#endif /* __PERF_SESSION_H */
Signature · 1 line
2.14.3
PATCH 2/4 perf report: Display s390 diagnostic counter sets
On s390 the event bc000 (also named CF_DIAG) extracts the CPU Measurement Facility diagnostic counter sets and displays them as counter number and counter value pairs sorted by counter set number.
Output:
[root@s35lp76 perf]# ./perf report -D --stdio
[00000000] Counterset:0 Counters:6
Counter:000 Value:0x000000000085ec36 Counter:001 Value:0x0000000000796c94 Counter:002 Value:0x0000000000005ada Counter:003 Value:0x0000000000092460 Counter:004 Value:0x0000000000006073 Counter:005 Value:0x00000000001a9a73
[0x000038] Counterset:1 Counters:2
Counter:000 Value:0x000000000007c59f Counter:001 Value:0x000000000002fad6
[0x000050] Counterset:2 Counters:16
Counter:000 Value:000000000000000000 Counter:001 Value:000000000000000000 Counter:002 Value:000000000000000000 Counter:003 Value:000000000000000000 Counter:004 Value:000000000000000000 Counter:005 Value:000000000000000000 Counter:006 Value:000000000000000000 Counter:007 Value:000000000000000000 Counter:008 Value:000000000000000000 Counter:009 Value:000000000000000000 Counter:010 Value:000000000000000000 Counter:011 Value:000000000000000000 Counter:012 Value:000000000000000000 Counter:013 Value:000000000000000000 Counter:014 Value:000000000000000000 Counter:015 Value:000000000000000000
[0x0000d8] Counterset:3 Counters:128
Counter:000 Value:0x000000000000020f Counter:001 Value:0x00000000000001d8 Counter:002 Value:0x000000000000d7fa Counter:003 Value:0x000000000000008b
...
The number in brackets is the offset into the raw data field of the sample.
--- tools/perf/arch/s390/util/Build | 2 +- tools/perf/arch/s390/util/trace_event.c | 146 ++++++++++++++++++++++++++++++++ tools/perf/util/s390-cpumcf-kernel.h | 61 +++++++++++++ 3 files changed, 208 insertions(+), 1 deletion(-) create mode 100644 tools/perf/arch/s390/util/trace_event.c create mode 100644 tools/perf/util/s390-cpumcf-kernel.h
tools/perf/arch/s390/util/Build +1 -1
@@ -4,6 +4,6 @@ libperf-y += kvm-stat.o libperf-$(CONFIG_DWARF) += dwarf-regs.o libperf-$(CONFIG_LIBDW_DWARF_UNWIND) += unwind-libdw.o -libperf-y += machine.o +libperf-y += machine.o trace_event.o libperf-$(CONFIG_AUXTRACE) += auxtrace.o
tools/perf/arch/s390/util/trace_event.c new file +146 -0
146 lines not on this page · raw message
tools/perf/util/s390-cpumcf-kernel.h new file +61 -0
61 lines not on this page · raw message
Signature · 1 line
2.14.3
PATCH 3/4 perf report: Display names in s390 diagnostic counter sets
In reply to Thomas RichterOn s390 the CPU Measurement Facility diagnostic counter sets are displayed by counter number and value. Add the logical counter name in the output (if it is avaliable). Otherwise "unknown" is shown.
Output before:
[root@s35lp76 perf]# ./perf report -D --stdio
[00000000] Counterset:0 Counters:6
Counter:000 Value:0x000000000085ec36 Counter:001 Value:0x0000000000796c94 Counter:002 Value:0x0000000000005ada Counter:003 Value:0x0000000000092460 Counter:004 Value:0x0000000000006073 Counter:005 Value:0x00000000001a9a73
[0x000038] Counterset:1 Counters:2
Counter:000 Value:0x000000000007c59f Counter:001 Value:0x000000000002fad6
[0x000050] Counterset:2 Counters:16
Counter:000 Value:000000000000000000 Counter:001 Value:000000000000000000
Output after:
[root@s35lp76 perf]# ./perf report -D --stdio
[00000000] Counterset:0 Counters:6
Counter:000 cpu_cycles Value:0x000000000085ec36
Counter:001 instructions Value:0x0000000000796c94
Counter:002 l1i_dir_writes Value:0x0000000000005ada
Counter:003 l1i_penalty_cycles Value:0x0000000000092460
Counter:004 l1d_dir_writes Value:0x0000000000006073
Counter:005 l1d_penalty_cycles Value:0x00000000001a9a73
[0x000038] Counterset:1 Counters:2
Counter:000 problem_state_cpu_cycles Value:0x000000000007c59f
Counter:001 problem_state_instructions Value:0x000000000002fad6
[0x000050] Counterset:2 Counters:16
Counter:000 prng_functions Value:000000000000000000--- tools/perf/arch/s390/util/trace_event.c | 55 ++++++++++++++++++++++++++++++--- 1 file changed, 51 insertions(+), 4 deletions(-)
tools/perf/arch/s390/util/trace_event.c +51 -4
@@ -27,6 +27,7 @@#include "config.h" #include "color.h" #include "s390-cpumcf-kernel.h" +#include "pmu-events/pmu-events.h" static size_t ctrset_size (struct cf_ctrset_entry *set) {
@@ -90,14 +91,59 @@ static void s390_cpumcfdg_dumptrail(const char *color, size_t offset, te->tod_base, te->mach_type); } +/* Return starting number of a counter set */ +static int get_counterset_start (int setnr) +{ +switch (setnr) { +case CPUMF_CTR_SET_BASIC :/* Basic counter set */ +return 0 ; +case CPUMF_CTR_SET_USER :/* Problem state counter set */ +return 32 ; +case CPUMF_CTR_SET_CRYPTO :/* Crypto counter set */ +return 64 ; +case CPUMF_CTR_SET_EXT :/* Extended counter set */ +return 128 ; +case CPUMF_CTR_SET_MT_DIAG :/* Diagnostic counter set */ +return 448 ; +default : +return -1 ; + } +} + +/* Scan the PMU table and extract the logical name of a counter from the +* PMU events table. Input is the counter set and counter number with in the +* set. Construct the event number and use this as key. If they match return +* the name of this counter. +* If no match is found a NULL pointer is returned. +*/ +static const char *get_counter_name (int set,int nr,struct pmu_events_map *map) +{ +int rc, event_nr, wanted =get_counterset_start (set) + nr; +struct pmu_event *evp = map->table; + +if (map) +for (; evp->name || evp->event || evp->desc; ++evp) { +if (evp->name ==NULL || evp->event ==NULL ) +continue ; + rc =sscanf (evp->event,"event=%x" , &event_nr); +if (rc ==1 && event_nr == wanted) +return evp->name; + } +return NULL ; +} +static void s390_cpumcfdg_dump (struct perf_sample *sample) {size_t i, len = sample->raw_size, offset =0 ;unsigned char *buf = sample->raw_data;const char *color =PERF_COLOR_BLUE ;struct cf_ctrset_entry *ce; +struct pmu_events_map *map; +struct perf_pmu pmu;u64 *p; +memset (&pmu,0 ,sizeof (pmu)); + map =perf_pmu__find_map (&pmu);while (offset < len) { ce = (struct cf_ctrset_entry *)(buf + offset);
@@ -109,11 +155,12 @@ static void s390_cpumcfdg_dump(struct perf_sample *sample)color_fprintf (stdout, color," [%#08zx] Counterset:%d" " Counters:%d\n" , offset, ce->set, ce->ctr); -for (i =0 , p = (u64 *)(ce +1 ); i < ce->ctr; i +=2 , p +=2 ) +for (i =0 , p = (u64 *)(ce +1 ); i < ce->ctr; ++i, ++p) { +const char *ev_name =get_counter_name (ce->set, i, map);color_fprintf (stdout, color, -"\tCounter:%03d Value:%#018lx" -" Counter:%03d Value:%#018lx\n" , - i, *p, i +1 , *(p +1 )); +"\tCounter:%03d %s Value:%#018lx\n" , i, + ev_name ?:"<unknown>" , *p); + } offset +=ctrset_size (ce); } }
Signature · 1 line
2.14.3
PATCH 4/4 perf/report: s390 dump counter set data to file.
In reply to Thomas RichterAdd support for the new s390 PMU device cpum_cf_diag to extract the counter set diagnostic data. This data is available as event raw data and can be created with this command:
[root@s35lp76 perf]# ./perf record -R -e '{rbd000,rbc000}' --
~/mytests/facultaet 2500
[ perf record: Woken up 1 times to write data ] [ perf record: Captured and wrote 0.009 MB perf.data ] [root@s35lp76 perf]#
The new event 0xbc000 generated this counter set diagnostic trace data. The data can be extracted using command:
[root@s35lp76 perf]# ./perf report --stdio --itrace=d
#
# Total Lost Samples: 0
#
# Samples: 21 of events 'anon group { rbd000, rbc000 }'
# Event count (approx.): 21
#
# Overhead Command Shared Object Symbol
# ................ ......... ................. ........................
#
80.95% 0.00% facultaet facultaet [.] facultaet
4.76% 0.00% facultaet [kernel.kallsyms] [k] check_chain_key
4.76% 0.00% facultaet [kernel.kallsyms] [k] ftrace_likely_update
4.76% 0.00% facultaet [kernel.kallsyms] [k] lock_release
4.76% 0.00% facultaet libc-2.26.so [.] _dl_addr
[root@s35lp76 perf]# ll aux*
-rw-r--r-- 1 root root 3408 Oct 16 12:40 aux.ctr.02
-rw-r--r-- 1 root root 4096 Oct 16 12:40 aux.smp.02
[root@s35lp76 perf]#The files named aux.ctr.## contain the counter set diagnstic data and the files named aux.smp.## contain the sampling diagnostic data. ## stand for the CPU number the data was taken from.
--- tools/perf/arch/s390/util/trace_event.c | 2 +- tools/perf/util/s390-cpumcf-kernel.h | 1 + tools/perf/util/s390-cpumsf.c | 76 +++++++++++++++++++++++++++++++-- 3 files changed, 74 insertions(+), 5 deletions(-)
tools/perf/arch/s390/util/trace_event.c +1 -1
@@ -181,7 +181,7 @@ void arch__trace_event(struct perf_evlist *evlist, union perf_event *event,return ; ev_bc000 =perf_evlist__event2evsel (evlist, event); -if (ev_bc000 ==NULL || ev_bc000->attr.config !=0xbc000 ) +if (ev_bc000 ==NULL || ev_bc000->attr.config !=PERF_EVENT_CPUM_CF_DIAG )return ;/* Display raw data on screen */
tools/perf/util/s390-cpumcf-kernel.h +1 -0
@@ -10,6 +10,7 @@#define S390_CPUMCF_KERNEL_H #define S390_CPUMCF_DIAG_DEF 0xfeef/* Counter diagnostic entry ID */ +#define PERF_EVENT_CPUM_CF_DIAG 0xBC000/* Event: Counter sets */ struct cf_ctrset_entry {/* CPU-M CF counter set entry (8 byte) */ unsigned int def:16 ;/* 0-15 Data Entry Format */
tools/perf/util/s390-cpumsf.c +72 -4
114 lines not on this page · raw message
Signature · 1 line
2.14.3
Arnaldo Carvalho de Melo
maintainerEm Fri, Jan 11, 2019 at 12:52:56PM +0100, Thomas Richter escreveu:
Quoted 3 lines
Add support to call an architecture dependend function to interpret raw data verbatim when dumping the perf.data file with option -D.
Please add "per-arch" to the summary, so that just by looking at my inbox main page I can see what this is about.
Also how this will deal with processing a perf.data file generated on a S/390 machine in another arch? I.e.
on s/390:
perf record -a sleep 10
on a x86_64:
scp that file
perf report -i perf.data.from.s390
?
report code should lookup a function for the architecture the perf.data was recorded on, using the perf.data file header, etc.
const char *arch_name = perf_env__arch(session->header->env);
Then lookup a table to find the right function, ok? See arch__find() for an example used in the annotation code.
- Arnaldo
Quoted 48 lines
This allows to display the event's raw data more verbatim than just plain hex data.
Signed-off-by Thomas Richter <[email protected]>--- tools/perf/util/session.c | 7 +++++++ tools/perf/util/session.h | 3 +++ 2 files changed, 10 insertions(+)tools/perf/util/session.c +7
-0@@ -1050,6 +1050,12 @@ static void sample_read__printf(struct perf_sample *sample, u64 read_format) sample->read.one.id, sample->read.one.value); } +void __weak arch__trace_event (struct perf_evlist *evlist__maybe_unused , +union perf_event *event__maybe_unused , +struct perf_sample *sample__maybe_unused ) +{ +} +static void dump_event (struct perf_evlist *evlist,union perf_event *event,u64 file_offset,struct perf_sample *sample) {@@ -1060,6 +1066,7 @@ static void dump_event(struct perf_evlist *evlist, union perf_event *event, file_offset, event->header.size, event->header.type);trace_event (event); +arch__trace_event (evlist, event, sample);if (sample)perf_evlist__print_tstamp (evlist, event, sample);tools/perf/util/session.h +3
-0@@ -128,4 +128,7 @@ int perf_event__synthesize_id_index(struct perf_tool *tool,struct perf_evlist *evlist, struct machine *machine); +void arch__trace_event (struct perf_evlist *evlist__maybe_unused , +union perf_event *event__maybe_unused , +struct perf_sample *sample__maybe_unused );#endif /* __PERF_SESSION_H */ Signature · 1 line
2.14.3
Signature · 1 line
- Arnaldo
Quoted 8 lines · Arnaldo Carvalho de Melo
Em Fri, Jan 11, 2019 at 12:52:56PM +0100, Thomas Richter escreveu:
Quoted 3 lines
Add support to call an architecture dependend function to interpret raw data verbatim when dumping the perf.data file with option -D.
Please add "per-arch" to the summary, so that just by looking at my inbox main page I can see what this is about.
Will do.
Quoted 5 lines
Also how this will deal with processing a perf.data file generated on a S/390 machine in another arch? I.e.
on s/390:
Quoted 9 lines
perf record -a sleep 10
on a
x86_64:scp that file
perf report -i perf.data.from.s390?
This is then the raw data in byte format, as in
[root@f29 perf]# ./perf report -D \
-i ~/perf-s390-ctrset/perf.data.s390.ctrset....0x750 [0x6e8]: event: 9
.
. ... raw event: size 1768 bytes
. 0000: 09 00 00 00 01 00 e8 06 1d 00 00 00 00 00 00 00 ................ . 0010: 00 00 00 00 00 00 00 00 34 82 00 00 34 82 00 00 ........4...4... . 0020: 04 a3 d3 1e c4 01 00 00 00 00 00 00 00 00 00 00 ................ . 0030: a0 0f 00 00 00 00 00 00 00 00 06 ac fe ef 00 00 ................ . 0040: 00 06 00 00 00 00 00 00 01 6c c8 ad 00 00 00 00 .........l...... . 0050: 00 d2 cf a5 00 00 00 00 00 00 39 93 00 00 00 00 ..........9..... . 0060: 00 04 0c df 00 00 00 00 00 00 2c 97 00 00 00 00 ..........,..... . 0070: 00 08 82 01 fe ef 00 01 00 02 00 00 00 00 00 00 ................ . 06b0: 00 00 14 58 d5 80 20 9a 29 34 a5 53 d5 80 20 9a ...X.. .)4.S.. . . 06c0: 28 15 83 53 00 00 00 00 00 00 00 00 00 00 00 00 (..S............ . 06d0: 00 00 00 00 d5 80 19 5e 46 96 8a 74 39 06 00 00 .......^F..t9... . 06e0: 00 00 00 00 00 00 00 00 ........
0 1941842404100 0x750 [0x6e8]: PERF_RECORD_SAMPLE(IP, 0x1): 33332/33332: 0 peri>
... thread: facultaet:33332
...... dso: <not found>
Quoted 10 lines
report code should lookup a function for the architecture the perf.data was recorded on, using the perf.data file header, etc.
const char *arch_name = perf_env__arch(session->header->env);Then lookup a table to find the right function, ok? See
arch__find()for an example used in the annotation code.- Arnaldo
I can make this platform independent and call a function to display the event raw data collected on a s/390 and any other platform. I will start with s390 and x86.
Signature · 5 lines
Thomas Richter, Dept 3303, IBM s390 Linux Development, Boeblingen, Germany -- Vorsitzende des Aufsichtsrats: Martina Koederitz Geschäftsführung: Dirk Wittkopp Sitz der Gesellschaft: Böblingen / Registergericht: Amtsgericht Stuttgart, HRB 243294