Add fine grained sampled metrics for perf script
This patch kit adds perf script support for computing metrics for sampled groups. This allows much more fine grained metrics measurement than perf stat allows.
The patchkit contains one extra bug fix (add missing documentation)
This allows things like fine grained IPC tracking.
Note that the metric is still averaged over the sampling period, it is not just for the sampling point.
For example to sample IPC:
$ perf record -e '{ref-cycles,cycles,instructions}:S' -a sleep 1
$ perf script -F metric,ip,sym,time,cpu,comm
...
alsa-sink-ALC32 [000] 42815.856074: 7fd65937d6cc [unknown]
alsa-sink-ALC32 [000] 42815.856074: 7fd65937d6cc [unknown]
alsa-sink-ALC32 [000] 42815.856074: 7fd65937d6cc [unknown]
alsa-sink-ALC32 [000] 42815.856074: metric: 0.13 insn per cycle
swapper [000] 42815.857961: ffffffff81655df0 __schedule
swapper [000] 42815.857961: ffffffff81655df0 __schedule
:1
swapper [000] 42815.857961: ffffffff81655df0 __schedule
swapper [000] 42815.857961: metric: 0.23 insn per cycle
qemu-system-x86 [000] 42815.858130: ffffffff8165ad0e
_raw_spin_unlock_irqrestore
qemu-system-x86 [000] 42815.858130: ffffffff8165ad0e
_raw_spin_unlock_irqrestore
qemu-system-x86 [000] 42815.858130: ffffffff8165ad0e
_raw_spin_unlock_irqrestore
qemu-system-x86 [000] 42815.858130: metric: 0.46 insn per cycle
:4972 [000] 42815.858312: ffffffffa080e5f2 vmx_vcpu_run
:4972 [000] 42815.858312: ffffffffa080e5f2 vmx_vcpu_run
:4972 [000] 42815.858312: ffffffffa080e5f2 vmx_vcpu_run
:4972 [000] 42815.858312: metric: 0.45 insn per cycleTopDown:
Note this requires disabling SMT if you have it enabled (e.g. by offlining the extra CPUs), because SMT would require sampling per core, which is not supported.
$ perf record -e '{ref-cycles,topdown-fetch-bubbles,topdown-recovery-bubbles,\
topdown-slots-retired,topdown-total-slots,topdown-slots-issued}:S' -a sleep 1
$ perf script --header -I -F cpu,ip,sym,event,metric,period
...
[000] 121108 ref-cycles: ffffffff8165222e copy_user_enhanced_fast_string
[000] 190350 topdown-fetch-bubbles: ffffffff8165222e copy_user_enhanced_fast_string
[000] 2055 topdown-recovery-bubbles: ffffffff8165222e copy_user_enhanced_fast_string
[000] 148729 topdown-slots-retired: ffffffff8165222e copy_user_enhanced_fast_string
[000] 144324 topdown-total-slots: ffffffff8165222e copy_user_enhanced_fast_string
[000] 160852 topdown-slots-issued: ffffffff8165222e copy_user_enhanced_fast_string
[000] metric: 33.0% frontend bound
[000] metric: 3.5% bad speculation
[000] metric: 25.8% retiring
[000] metric: 37.7% backend bound
[000] 112112 ref-cycles: ffffffff8165aec8 _raw_spin_lock_irqsave
[000] 357222 topdown-fetch-bubbles: ffffffff8165aec8 _raw_spin_lock_irqsave
[000] 3325 topdown-recovery-bubbles: ffffffff8165aec8 _raw_spin_lock_irqsave
[000] 323553 topdown-slots-retired: ffffffff8165aec8 _raw_spin_lock_irqsave
[000] 270507 topdown-total-slots: ffffffff8165aec8 _raw_spin_lock_irqsave
[000] 341226 topdown-slots-issued: ffffffff8165aec8 _raw_spin_lock_irqsave
[000] metric: 33.0% frontend bound
[000] metric: 2.9% bad speculation
[000] metric: 29.9% retiring
[000] metric: 34.2% backend boundGit tree:git://git.kernel.org/pub/scm/limux/kernel/git/ak/linux-misc.git perf/script-metric-1
v1: Initial post
PATCH 1/5 perf, tools: Document some missing perf.data headers
From: Andi Kleen <[email protected]>
Document STAT and CACHE header entries.
--- tools/perf/Documentation/perf.data-file-format.txt | 23 ++++++++++++++++++++++ 1 file changed, 23 insertions(+)
tools/perf/Documentation/perf.data-file-format.txt +23 -0
@@ -238,6 +238,29 @@ struct auxtrace_index { struct auxtrace_index_entry entries[PERF_AUXTRACE_INDEX_ENTRY_COUNT]; }; + HEADER_STAT = 19, + +This is merely a flag signifying that the data section contains data +recorded from perf stat record. + + HEADER_CACHE = 20, + +Description of the cache hierarchy. Based on the Linux sysfs format +in /sys/devices/system/cpu/cpu*/cache/ + + u32 version Currently always 1 + u32 number_of_cache_levels + +struct { + u32 level; + u32 line_size; + u32 sets; + u32 ways; + struct perf_header_string type; + struct perf_header_string size; + struct perf_header_string map; +}[number_of_cache_levels]; + other bits are reserved and should ignored for now HEADER_FEAT_BITS = 256,
Signature · 1 line
2.13.6
Re: [PATCH v1 1/5] perf, tools: Document some missing perf.data headers
Quoted 5 lines · Andi Kleen
From: Andi Kleen <[email protected]>
Document STAT and CACHE header entries.
Signed-off-by Andi Kleen <[email protected]>
thanks,
jirka
Quoted 41 lines
--- tools/perf/Documentation/perf.data-file-format.txt | 23 ++++++++++++++++++++++ 1 file changed, 23 insertions(+)tools/perf/Documentation/perf.data-file-format.txt +23
-0@@ -238,6 +238,29 @@ struct auxtrace_index { struct auxtrace_index_entry entries[PERF_AUXTRACE_INDEX_ENTRY_COUNT]; }; + HEADER_STAT = 19, + +This is merely a flag signifying that the data section contains data +recorded from perf stat record. + + HEADER_CACHE = 20, + +Description of the cache hierarchy. Based on the Linux sysfs format +in /sys/devices/system/cpu/cpu*/cache/ + + u32 version Currently always 1 + u32 number_of_cache_levels + +struct { + u32 level; + u32 line_size; + u32 sets; + u32 ways; + struct perf_header_string type; + struct perf_header_string size; + struct perf_header_string map; +}[number_of_cache_levels]; + other bits are reserved and should ignored for now HEADER_FEAT_BITS = 256,Signature · 1 line
2.13.6
Re: [PATCH v1 1/5] perf, tools: Document some missing perf.data headers
Em Mon, Nov 13, 2017 at 09:54:03AM +0100, Jiri Olsa escreveu:
Quoted 8 lines · Andi Kleen
Quoted 5 lines
From: Andi Kleen <[email protected]>
Document STAT and CACHE header entries.
Signed-off-by Andi Kleen <[email protected]>Acked-by Jiri Olsa <[email protected]>
Applied.
- Arnaldo
tip-bot for Andi Kleen
merge bot[tip:perf/core] perf tools: Document some missing perf.data headers
In reply to Andi Kleenperf tools: Document some missing perf.data headers
Commit-ID: 35c0a81a97692cc0afe3d005c9a737bbde06e784 Gitweb: https://git.kernel.org/tip/35c0a81a97692cc0afe3d005c9a737bbde06e784 Author: Andi Kleen <[email protected]> AuthorDate: Thu, 9 Nov 2017 06:55:24 -0800 Committer: Arnaldo Carvalho de Melo <[email protected]> CommitDate: Thu, 16 Nov 2017 14:49:55 -0300
perf tools: Document some missing perf.data headers
Document STAT and CACHE header entries.
--- tools/perf/Documentation/perf.data-file-format.txt | 23 ++++++++++++++++++++++ 1 file changed, 23 insertions(+)
tools/perf/Documentation/perf.data-file-format.txt +23 -0
@@ -238,6 +238,29 @@ struct auxtrace_index { struct auxtrace_index_entry entries[PERF_AUXTRACE_INDEX_ENTRY_COUNT]; }; + HEADER_STAT = 19, + +This is merely a flag signifying that the data section contains data +recorded from perf stat record. + + HEADER_CACHE = 20, + +Description of the cache hierarchy. Based on the Linux sysfs format +in /sys/devices/system/cpu/cpu*/cache/ + + u32 version Currently always 1 + u32 number_of_cache_levels + +struct { + u32 level; + u32 line_size; + u32 sets; + u32 ways; + struct perf_header_string type; + struct perf_header_string size; + struct perf_header_string map; +}[number_of_cache_levels]; + other bits are reserved and should ignored for now HEADER_FEAT_BITS = 256,
PATCH 2/5 perf, tools: Save event scaling factors in perf.data
In reply to Andi KleenFrom: Andi Kleen <[email protected]>
To process metrics, perf script needs to know the scaling factors reported by sysfs for events. Save the scaling factors in the perf.data metadata in a new SCALE header.
--- tools/perf/Documentation/perf.data-file-format.txt | 8 +++ tools/perf/util/header.c | 60 ++++++++++++++++++++++ tools/perf/util/header.h | 1 + 3 files changed, 69 insertions(+)
tools/perf/Documentation/perf.data-file-format.txt +8 -0
@@ -261,6 +261,14 @@ struct { struct perf_header_string map; }[number_of_cache_levels]; + HEADER_SCALE = 21, + +Save scaling factor of events. One entry for each event in the same +order as other events in the header. + + u32 nr; + double scale[nr]; + other bits are reserved and should ignored for now HEADER_FEAT_BITS = 256,
tools/perf/util/header.c +60 -0
72 lines not on this page · raw message
tools/perf/util/header.h +1 -0
@@ -33,6 +33,7 @@ enum {HEADER_AUXTRACE ,HEADER_STAT ,HEADER_CACHE , +HEADER_SCALE ,HEADER_LAST_FEATURE , HEADER_FEAT_BITS = 256, };
Signature · 1 line
2.13.6
Re: [PATCH v1 2/5] perf, tools: Save event scaling factors in perf.data
Quoted 7 lines · Andi Kleen
From: Andi Kleen <[email protected]>
To process metrics, perf script needs to know the scaling factors reported by sysfs for events. Save the scaling factors in the perf.data metadata in a new SCALE header.
Signed-off-by Andi Kleen <[email protected]>
there's event_update event for scale and some other evsel stuff that was before we were able to put header through pipe
it might be less code changes.. sythesize it via:
if (has_scale(counter)) {
err = perf_event__synthesize_event_update_scale(NULL, counter, process_synthesized_event);
if (err < 0) {
pr_err("Couldn't synthesize evsel scale.\n");
return err;
}
}and new tool's event_update callback, which is already implemented in perf_event__process_event_update
having event instead of header feature might have
other drawbacks.. not sure it will fit here
jirka
PATCH 3/5 perf, tools, script: Allow printing period for non freq mode groups
In reply to Andi KleenFrom: Andi Kleen <[email protected]>
When using leader sampling the values of the not sampled but counted events are shown by perf script in "period".
Currently printing period is only allowed when the main event has a period, that is it is in frequency mode.
This implies that we cannot dump the values of counted events when the leader event is not in frequency mode.
Just remove the check that the period must be set on all events. It will just be printed as 0 instead if it's not available.
This fixes the following:
$ perf record -c 100000 -e '{cycles,branches}:S'
$ perf script -F event,period--- tools/perf/builtin-script.c | 5 ----- 1 file changed, 5 deletions(-)
tools/perf/builtin-script.c +0 -5
@@ -377,11 +377,6 @@ static int perf_evsel__check_attr(struct perf_evsel *evsel, PERF_OUTPUT_CPU, allow_user_set))return -EINVAL ; -if (PRINT_FIELD (PERIOD ) && -perf_evsel__check_stype (evsel,PERF_SAMPLE_PERIOD ,"PERIOD" , -PERF_OUTPUT_PERIOD )) -return -EINVAL ; -if (PRINT_FIELD (IREGS ) &&perf_evsel__check_stype (evsel,PERF_SAMPLE_REGS_INTR ,"IREGS" ,PERF_OUTPUT_IREGS ))
Signature · 1 line
2.13.6
Re: [PATCH v1 3/5] perf, tools, script: Allow printing period for non freq mode groups
Quoted 8 lines · Andi Kleen
From: Andi Kleen <[email protected]>
When using leader sampling the values of the not sampled but counted events are shown by perf script in "period".
Currently printing period is only allowed when the main event has a period, that is it is in frequency mode.
Quoted 6 lines
This implies that we cannot dump the values of counted events when the leader event is not in frequency mode.
Just remove the check that the period must be set on all events. It will just be printed as 0 instead if it's not available.
it'll be the value of configured period, not 0
int perf_evsel__parse_sample(struct ...
...
data->period = evsel->attr.sample_period;
$ perf record -c 100000
$ perf script -F event,period | head -3
Failed to open /tmp/perf-2048.map, continuing without symbols
100000 cycles:ppp:
100000 cycles:ppp: other than that I think we can remove that check,
because we will have always sane number in period
thanks,
jirka
Re: [PATCH v1 3/5] perf, tools, script: Allow printing period for non freq mode groups
Em Mon, Nov 13, 2017 at 10:11:58AM +0100, Jiri Olsa escreveu:
Quoted 29 lines · Andi Kleen
Quoted 8 lines
From: Andi Kleen <[email protected]>
When using leader sampling the values of the not sampled but counted events are shown by perf script in "period".
Currently printing period is only allowed when the main event has a period, that is it is in frequency mode.
Quoted 6 lines
This implies that we cannot dump the values of counted events when the leader event is not in frequency mode.
Just remove the check that the period must be set on all events. It will just be printed as 0 instead if it's not available.
it'll be the value of configured period, not 0
int perf_evsel__parse_sample(struct ...
...
data->period=evsel->attr.sample_period;$ perf record -c 100000 $ perf script -F event,period | head -3 Failed to open /tmp/perf-2048.map, continuing without symbols 100000 cycles:ppp: 100000 cycles:ppp:
Quoted 4 lines
other than that I think we can remove that check,
because we will have always sane number in periodAcked-by Jiri Olsa <[email protected]>
Applied, after adding your comments.
- Arnaldo
tip-bot for Andi Kleen
merge bot[tip:perf/core] perf script: Allow printing period for non freq mode groups
In reply to Andi Kleenperf script: Allow printing period for non freq mode groups
Commit-ID: 5039c8a28fa97b8dce7b363a5ecd4bee2b87bf03 Gitweb: https://git.kernel.org/tip/5039c8a28fa97b8dce7b363a5ecd4bee2b87bf03 Author: Andi Kleen <[email protected]> AuthorDate: Thu, 9 Nov 2017 06:55:26 -0800 Committer: Arnaldo Carvalho de Melo <[email protected]> CommitDate: Thu, 16 Nov 2017 14:49:55 -0300
perf script: Allow printing period for non freq mode groups
When using leader sampling the values of the not sampled but counted events are shown by perf script in "period".
Currently printing period is only allowed when the main event has a period, that is it is in frequency mode.
This implies that we cannot dump the values of counted events when the leader event is not in frequency mode.
Just remove the check that the period must be set on all events. It will just be printed as 0 instead if it's not available.
This fixes the following:
$ perf record -c 100000 -e '{cycles,branches}:S'
$ perf script -F event,periodFurther commentary by Jiri Olsa:
The period will be the value of configured period, not 0:
int perf_evsel__parse_sample(struct ...
...
data->period = evsel->attr.sample_period;
$ perf record -c 100000
$ perf script -F event,period | head -3
Failed to open /tmp/perf-2048.map, continuing without symbols
100000 cycles:ppp:
100000 cycles:ppp:other than that I think we can remove that check, because we will have always sane number in period
--- tools/perf/builtin-script.c | 5 ----- 1 file changed, 5 deletions(-)
tools/perf/builtin-script.c +0 -5
@@ -423,11 +423,6 @@ static int perf_evsel__check_attr(struct perf_evsel *evsel, PERF_OUTPUT_CPU, allow_user_set))return -EINVAL ; -if (PRINT_FIELD (PERIOD ) && -perf_evsel__check_stype (evsel,PERF_SAMPLE_PERIOD ,"PERIOD" , -PERF_OUTPUT_PERIOD )) -return -EINVAL ; -if (PRINT_FIELD (IREGS ) &&perf_evsel__check_stype (evsel,PERF_SAMPLE_REGS_INTR ,"IREGS" ,PERF_OUTPUT_IREGS ))
PATCH 4/5 perf, tools: Add fallback in perf_evsel__nr_cpus for no map
In reply to Andi KleenFrom: Andi Kleen <[email protected]>
Support the case of the event having no cpumap in perf_evsel__nr_cpus. Just return 1 in this case. This can happen in perf script when it uses the perf stat shadow functions.
--- tools/perf/util/evsel.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
tools/perf/util/evsel.h +2 -1
@@ -157,7 +157,8 @@ static inline struct cpu_map *perf_evsel__cpus(struct perf_evsel *evsel)static inline int perf_evsel__nr_cpus (struct perf_evsel *evsel) { -return perf_evsel__cpus (evsel)->nr; +struct cpu_map *map =perf_evsel__cpus (evsel); +return map ? map->nr :1 ; } void perf_counts_values__scale(struct perf_counts_values *count,
Signature · 1 line
2.13.6
Re: [PATCH v1 4/5] perf, tools: Add fallback in perf_evsel__nr_cpus for no map
Quoted 5 lines · Andi Kleen
From: Andi Kleen <[email protected]>
Support the case of the event having no cpumap in
perf_evsel__nr_cpus. Just return 1 in this case. This can happen in perf script when it uses the perf stat shadow functions.
why 1, where in shadow code? you can synthesize cpus for event via event_update event
jirka
Quoted 23 lines
Signed-off-by Andi Kleen <[email protected]>--- tools/perf/util/evsel.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)tools/perf/util/evsel.h +2
-1@@ -157,7 +157,8 @@ static inline struct cpu_map *perf_evsel__cpus(struct perf_evsel *evsel)static inline int perf_evsel__nr_cpus (struct perf_evsel *evsel) { -return perf_evsel__cpus (evsel)->nr; +struct cpu_map *map =perf_evsel__cpus (evsel); +return map ? map->nr :1 ; } void perf_counts_values__scale(struct perf_counts_values *count,Signature · 1 line
2.13.6
Re: [PATCH v1 4/5] perf, tools: Add fallback in perf_evsel__nr_cpus for no map
Quoted 9 lines · Jiri Olsa
Quoted 5 lines · Andi Kleen
From: Andi Kleen <[email protected]>
Support the case of the event having no cpumap in
perf_evsel__nr_cpus. Just return 1 in this case. This can happen in perf script when it uses the perf stat shadow functions.why 1, where in shadow code? you can synthesize cpus for event via
event_updateevent
For sampling it should be always 1, right?
Where:
#0 0x0000000000570e03 in __perf_evsel_stat__is (evsel=0x2690ce0, id=PERF_STAT_EVSEL_ID__CYCLES_IN_TX) at util/stat.c:75 #1 0x0000000000572375 in perf_stat__update_shadow_stats (counter=0x2690ce0, count=3744, cpu=0) at util/stat-shadow.c:194
-Andi
PATCH 5/5 perf, tools, script: Allow computing metrics in perf script
In reply to Andi KleenFrom: Andi Kleen <[email protected]>
Add support for computing perf stat style metrics in perf script.
When using leader sampling we can get metrics for each sampling period by computing formulas over the values of the different group members.
This allows things like fine grained IPC tracking through sampling, much more fine grained than with perf stat.
Note that the metric is still averaged over the sampling period, it is not just for the sampling point.
This patch adds a new metric output field for perf script that uses the existing perf stat metrics infrastructure to compute any metrics supported by perf stat.
For example to sample IPC:
$ perf record -e '{ref-cycles,cycles,instructions}:S' -a sleep 1
$ perf script -F metric,ip,sym,time,cpu,comm
...
alsa-sink-ALC32 [000] 42815.856074: 7fd65937d6cc [unknown]
alsa-sink-ALC32 [000] 42815.856074: 7fd65937d6cc [unknown]
alsa-sink-ALC32 [000] 42815.856074: 7fd65937d6cc [unknown]
alsa-sink-ALC32 [000] 42815.856074: metric: 0.13 insn per cycle
swapper [000] 42815.857961: ffffffff81655df0 __schedule
swapper [000] 42815.857961: ffffffff81655df0 __schedule
swapper [000] 42815.857961: ffffffff81655df0 __schedule
swapper [000] 42815.857961: metric: 0.23 insn per cycle
qemu-system-x86 [000] 42815.858130: ffffffff8165ad0e
_raw_spin_unlock_irqrestore
qemu-system-x86 [000] 42815.858130: ffffffff8165ad0e
_raw_spin_unlock_irqrestore
qemu-system-x86 [000] 42815.858130: ffffffff8165ad0e
_raw_spin_unlock_irqrestore
qemu-system-x86 [000] 42815.858130: metric: 0.46 insn per cycle
:4972 [000] 42815.858312: ffffffffa080e5f2 vmx_vcpu_run
:4972 [000] 42815.858312: ffffffffa080e5f2 vmx_vcpu_run
:4972 [000] 42815.858312: ffffffffa080e5f2 vmx_vcpu_run
:4972 [000] 42815.858312: metric: 0.45 insn per cycleTopDown:
Note this requires disabling SMT if you have it enabled, because SMT would require sampling per core, which is not supported.
$ perf record -e '{ref-cycles,topdown-fetch-bubbles,topdown-recovery-bubbles,\
topdown-slots-retired,topdown-total-slots,topdown-slots-issued}:S' -a sleep 1
$ perf script --header -I -F cpu,ip,sym,event,metric,period
...
[000] 121108 ref-cycles: ffffffff8165222e copy_user_enhanced_fast_string
[000] 190350 topdown-fetch-bubbles: ffffffff8165222e copy_user_enhanced_fast_string
[000] 2055 topdown-recovery-bubbles: ffffffff8165222e copy_user_enhanced_fast_string
[000] 148729 topdown-slots-retired: ffffffff8165222e copy_user_enhanced_fast_string
[000] 144324 topdown-total-slots: ffffffff8165222e copy_user_enhanced_fast_string
[000] 160852 topdown-slots-issued: ffffffff8165222e copy_user_enhanced_fast_string
[000] metric: 33.0% frontend bound
[000] metric: 3.5% bad speculation
[000] metric: 25.8% retiring
[000] metric: 37.7% backend bound
[000] 112112 ref-cycles: ffffffff8165aec8 _raw_spin_lock_irqsave
[000] 357222 topdown-fetch-bubbles: ffffffff8165aec8 _raw_spin_lock_irqsave
[000] 3325 topdown-recovery-bubbles: ffffffff8165aec8 _raw_spin_lock_irqsave
[000] 323553 topdown-slots-retired: ffffffff8165aec8 _raw_spin_lock_irqsave
[000] 270507 topdown-total-slots: ffffffff8165aec8 _raw_spin_lock_irqsave
[000] 341226 topdown-slots-issued: ffffffff8165aec8 _raw_spin_lock_irqsave
[000] metric: 33.0% frontend bound
[000] metric: 2.9% bad speculation
[000] metric: 29.9% retiring
[000] metric: 34.2% backend bound
...--- tools/perf/Documentation/perf-script.txt | 10 +++- tools/perf/builtin-script.c | 82 ++++++++++++++++++++++++++++++++ tools/perf/util/evsel.h | 2 + tools/perf/util/metricgroup.c | 4 ++ 4 files changed, 97 insertions(+), 1 deletion(-)
tools/perf/Documentation/perf-script.txt +9 -1
@@ -117,7 +117,7 @@ OPTIONS Comma separated list of fields to print. Options are: comm, tid, pid, time, cpu, event, trace, ip, sym, dso, addr, symoff, srcline, period, iregs, uregs, brstack, brstacksym, flags, bpf-output, brstackinsn, - brstackoff, callindent, insn, insnlen, synth, phys_addr. + brstackoff, callindent, insn, insnlen, synth, phys_addr, metric. Field list can be prepended with the type, trace, sw or hw, to indicate to which event type the field list applies. e.g., -F sw:comm,tid,time,ip,sym and -F trace:time,cpu,trace
@@ -217,6 +217,14 @@ OPTIONS The brstackoff field will print an offset into a specific dso/binary. + With the metric option perf script can compute metrics for + sampling periods, similar to perf stat. This requires + specifying a group with multiple metrics with the :S option + for perf record. perf will sample on the first event, and + compute metrics for all the events in the group. Please note + that the metric computed is averaged over the whole sampling + period, not just for the sample point. + -k:: --vmlinux=<file>:: vmlinux pathname
tools/perf/builtin-script.c +82 -0
112 lines not on this page · raw message
tools/perf/util/evsel.h +2 -0
@@ -108,6 +108,8 @@ struct perf_evsel {struct cpu_map *cpus;struct cpu_map *own_cpus;struct thread_map *threads; +u64 val; +int gnum;unsigned int sample_size;int id_pos;int is_pos;
tools/perf/util/metricgroup.c +4 -0
@@ -38,6 +38,10 @@ struct metric_event *metricgroup__lookup(struct rblist *metric_events,struct metric_event me = { .evsel = evsel }; + +if (!metric_events) +return NULL ; + nd =rblist__find (metric_events, &me);if (nd) return container_of(nd, struct metric_event, nd);
Signature · 1 line
2.13.6
Re: [PATCH v1 5/5] perf, tools, script: Allow computing metrics in perf script
On Thu, Nov 09, 2017 at 06:55:28AM -0800, Andi Kleen wrote:
SNIP
Quoted 18 lines
static void process_event(struct
perf_script*script,tools/perf/builtin-script.c +3
-0struct perf_sample *sample, struct perf_evsel *evsel, struct addr_location *al,@@ -1481,6 +1560,9 @@ static void process_event(struct perf_script *script,if (PRINT_FIELD (PHYS_ADDR ))printf ("%16" PRIx64, sample->phys_addr);printf ("\n" ); + +if (PRINT_FIELD (METRIC )) +print_metric (script, thread, evsel, sample); }static struct scripting_ops *scripting_ops;tools/perf/util/evsel.h +0
-0
tools/perf/util/evsel.h struct perf_evsel { · line 112
Quoted 5 lines
tools/perf/util/evsel.h +2
-0@@ -108,6 +108,8 @@ struct perf_evsel {struct cpu_map *cpus;struct cpu_map *own_cpus;struct thread_map *threads; +u64 val; +int gnum;
please put this to the priv (struct perf_stat_evsel) with some comments that it's used in script only
also there's per event dump feature that uses evsel->priv (please rebase to latest Arnaldo's perf/core) in script, so make sure you are mutualy exclusive
thanks,
jirka
Arnaldo Carvalho de Melo
maintainerRe: [PATCH v1 5/5] perf, tools, script: Allow computing metrics in perf script
Em Mon, Nov 13, 2017 at 10:30:11AM +0100, Jiri Olsa escreveu:
Quoted 31 lines · Andi Kleen
SNIP
Quoted 18 lines
static void process_event(struct
perf_script*script,tools/perf/builtin-script.c +3
-0struct perf_sample *sample, struct perf_evsel *evsel, struct addr_location *al,@@ -1481,6 +1560,9 @@ static void process_event(struct perf_script *script,if (PRINT_FIELD (PHYS_ADDR ))printf ("%16" PRIx64, sample->phys_addr);printf ("\n" ); + +if (PRINT_FIELD (METRIC )) +print_metric (script, thread, evsel, sample); }static struct scripting_ops *scripting_ops;tools/perf/util/evsel.h +0
-0tools/perf/util/evsel.h struct perf_evsel { · line 112
Quoted 5 lines
tools/perf/util/evsel.h +2
-0@@ -108,6 +108,8 @@ struct perf_evsel {struct cpu_map *cpus;struct cpu_map *own_cpus;struct thread_map *threads; +u64 val; +int gnum;please put this to the priv (struct
perf_stat_evsel) with some comments that it's used in script only
Quoted 3 lines
also there's per event dump feature that uses
evsel->priv(please rebase to latest Arnaldo's perf/core) in script, so make sure you are mutualy exclusive
No need, priv is supposed to be used by one tool only, i.e. its a too private area, that perf_evsel_stats thing started to be used by multiple tools, so I moved it to perf_evsel->stats and made perf_evsel->priv be a tool priv area again.
I.e. move the above values to perf_stat_evsel and access it via evsel->stats.
- Arnaldo
Quoted 2 lines
thanks,
jirka