Freq/CPU%/CORE_BUSY% support
cover Freq/CPU%/CORE_BUSY% support
This patch set supports per-sample freq/CPU%/CORE_BUSY% print in perf report -D and --stdio.
For printing these information, the perf.data file must have been obtained by group read and using special events cycles, ref-cycles, msr/tsc/, msr/aperf/ or msr/mperf/.
- Freq (MHz): The frequency during the sample interval. Needs cycles ref-cycles event.
- CPU%: CPU utilization during the sample interval. Needs ref-cycles and msr/tsc/ events.
- CORE_BUSY%: actual percent performance (APERF/MPERF%) during the sample interval. Needs msr/aperf/ and msr/mperf/ events.
For printing CPU% and CORE_BUSY%, please also apply the kernel patch.
http://marc.info/?l=linux-kernel&m=143747254926369&w=2
Here is an example:
$ perf record -e
'{cycles,ref-cycles,msr/tsc/,msr/mperf/,msr/aperf/}:S' ~/tchain_edit$ perf report --stdio --group --show-freq-perf
Overhead FREQ MHz CPU% CORE_BUSY%
Command Shared Object Symbol
........................................ ......... ..... ..........
........... ................ ......................
99.54% 99.54% 99.53% 99.53% 99.53% 2301 96 99
tchain_edit tchain_edit [.] f3
0.20% 0.20% 0.20% 0.20% 0.20% 2301 98 99
tchain_edit tchain_edit [.] f2
0.05% 0.05% 0.05% 0.05% 0.05% 2300 98 99
tchain_edit [kernel.vmlinux] [k] read_tscKan Liang (5):
perf,tools: introduce get_cpu_max_freq
perf,tools: Dump per-sample freq/CPU%/CORE_BUSY% in report -D perf,tools: save misc sample read value in struct perf_sample perf,tools: caculate and save freq/CPU%/CORE_BUSY% in he_stat perf,tools: Show freq/CPU%/CORE_BUSY% in perf report --stdio
tools/perf/Documentation/perf-report.txt | 12 ++++++ tools/perf/builtin-annotate.c | 2 +- tools/perf/builtin-diff.c | 2 +- tools/perf/builtin-report.c | 24 +++++++++++ tools/perf/perf.h | 1 + tools/perf/tests/hists_link.c | 4 +- tools/perf/ui/hist.c | 71 +++++++++++++++++++++++++++++--- tools/perf/util/cpumap.c | 32 ++++++++++++++ tools/perf/util/cpumap.h | 2 + tools/perf/util/event.h | 11 +++++ tools/perf/util/hist.c | 51 ++++++++++++++++++++--- tools/perf/util/hist.h | 5 +++ tools/perf/util/pmu.h | 2 + tools/perf/util/session.c | 50 +++++++++++++++++++--- tools/perf/util/session.h | 28 +++++++++++++ tools/perf/util/sort.c | 3 ++ tools/perf/util/sort.h | 3 ++ tools/perf/util/symbol.h | 9 +++- tools/perf/util/util.c | 2 + 19 files changed, 293 insertions(+), 21 deletions(-)
Signature · 1 line
1.8.3.1
PATCH 1/5 perf,tools: introduce get_cpu_max_freq
Get cpu max frequency from the first online cpu, and save the MHz value in get_cpu_max_freq.
--- tools/perf/builtin-report.c | 2 ++ tools/perf/util/cpumap.c | 32 ++++++++++++++++++++++++++++++++ tools/perf/util/cpumap.h | 2 ++ 3 files changed, 36 insertions(+)
tools/perf/builtin-report.c +2 -0
@@ -818,6 +818,8 @@ repeat: symbol_conf.cumulate_callchain = false; } + cpu_max_freq =get_cpu_max_freq () /1000 ; +if (setup_sorting () <0 ) {if (sort_order)parse_options_usage (report_usage, options,"s" ,1 );
tools/perf/util/cpumap.c +32 -0
@@ -499,3 +499,35 @@ int cpu__setup_cpunode_map(void)closedir (dir1);return 0 ; } + +unsigned int get_cpu_max_freq (void ) +{ +const char *mnt; +char path[PATH_MAX ], tmp; +FILE *fp; +unsigned int freq; +int cpu =0 ; +int ret; + + mnt =sysfs__mountpoint (); +if (!mnt) +return 0 ; + +snprintf (path,PATH_MAX ,"%s/devices/system/cpu/online" , mnt); + fp =fopen (path,"r" ); +if (fp) { + ret =fscanf (fp,"%u%c" , &cpu, &tmp); +fclose (fp); +if (ret <1 ) +return 0 ; + } + +snprintf (path,PATH_MAX ,"%s/devices/system/cpu/cpu%d/cpufreq/cpuinfo_max_freq" , mnt, cpu); + fp =fopen (path,"r" ); +if (!fp) +return 0 ; + ret =fscanf (fp,"%u" , &freq); +fclose (fp); + +return (ret ==1 ) ? freq :0 ; +}
tools/perf/util/cpumap.h +2 -0
@@ -56,8 +56,10 @@ static inline bool cpu_map__empty(const struct cpu_map *map)int max_cpu_num;int max_node_num;int *cpunode_map; +unsigned int cpu_max_freq;int cpu__setup_cpunode_map (void ); +unsigned int get_cpu_max_freq (void );static inline int cpu__max_node (void ) {
Signature · 1 line
1.8.3.1
PATCH 2/5 perf,tools: Dump per-sample freq/CPU%/CORE_BUSY% in report -D
In reply to Kan LiangThe group read results from cycles/ref-cycles/TSC/ASTATE/MSTATE event can be used to calculate the frequency, CPU Utilization and percent performance during each sampling period.
This patch shows them in report -D.
Here is an example:
$ perf record -e
'{cycles,ref-cycles,msr/tsc/,msr/mperf/,msr/aperf/}:S' ~/tchain_editHere is one sample from perf report -D
1972044565107 0x3498 [0x88]: PERF_RECORD_SAMPLE(IP, 0x2): 10608/10608:0x4005fd period: 564686 addr: 0
... sample_read:
.... group nr 5
..... id 0000000000000012, value 0000000002143901
..... id 0000000000000052, value 0000000002143896
..... id 0000000000000094, value 00000000021e443d
..... id 00000000000000d4, value 00000000021db984
..... id 0000000000000114, value 00000000021db964
..... Freq 2301 MHz
..... CPU% 98%
..... CORE_BUSY% 99%
--- tools/perf/builtin-report.c | 3 +++ tools/perf/util/pmu.h | 2 ++ tools/perf/util/session.c | 34 +++++++++++++++++++++++++++++----- tools/perf/util/session.h | 38 ++++++++++++++++++++++++++++++++++++++ 4 files changed, 72 insertions(+), 5 deletions(-)
tools/perf/builtin-report.c +3 -0
@@ -38,6 +38,8 @@#include "util/auxtrace.h" +#include "util/pmu.h" +#include <dlfcn.h> #include <linux/bitmap.h>
@@ -818,6 +820,7 @@ repeat: symbol_conf.cumulate_callchain = false; } + msr_pmu =perf_pmu__find ("msr" ); cpu_max_freq =get_cpu_max_freq () /1000 ;if (setup_sorting () <0 ) {
tools/perf/util/pmu.h +2 -0
@@ -27,6 +27,8 @@ struct perf_pmu {struct list_head list;/* ELEM */ }; +struct perf_pmu *msr_pmu; +struct perf_pmu_info {const char *unit;double scale;
tools/perf/util/session.c +29 -5
@@ -17,6 +17,7 @@#include "asm/bug.h" #include "auxtrace.h" #include "thread-stack.h" +#include "pmu.h" static int perf_session__deliver_event(struct perf_session *session, union perf_event *event,
@@ -851,8 +852,14 @@ static void perf_evlist__print_tstamp(struct perf_evlist *evlist,printf ("%" PRIu64" " , sample->time); } -static void sample_read__printf (struct perf_sample *sample,u64 read_format) +static void sample_read__printf (struct perf_evlist *evlist, +struct perf_sample *sample, +u64 read_format) { +struct perf_evsel *evsel; +struct perf_sample_id *sid; +u64 data[FREQ_PERF_MAX ] = {0 }; +printf ("... sample_read:\n" );if (read_format &PERF_FORMAT_TOTAL_TIME_ENABLED )
@@ -875,10 +882,26 @@ static void sample_read__printf(struct perf_sample *sample, u64 read_format)printf ("..... id %016" PRIx64", value %016" PRIx64"\n" , value->id, value->value); + + sid =perf_evlist__id2sid (evlist, value->id); + evsel = sid->evsel; +if (evsel !=NULL ) +SET_FREQ_PERF_VALUE (evsel, data, + value->value); } }else printf ("..... id %016" PRIx64", value %016" PRIx64"\n" , sample->read.one.id, sample->read.one.value); + +if (HAS_FREQ (data)) +printf ("..... Freq %lu MHz\n" , + (data[FREQ_PERF_CYCLES ] * cpu_max_freq) / data[FREQ_PERF_REF_CYCLES ]); +if (HAS_CPU_U (data)) +printf ("..... CPU%% %lu%%\n" , + (100 * data[FREQ_PERF_REF_CYCLES ]) / data[FREQ_PERF_TSC ]); +if (HAS_CORE_BUSY (data)) +printf ("..... CORE_BUSY%% %lu%%\n" , + (100 * data[FREQ_PERF_APERF ]) / data[FREQ_PERF_MPERF ]); } static void dump_event(struct perf_evlist *evlist, union perf_event *event,
@@ -899,8 +922,8 @@ static void dump_event(struct perf_evlist *evlist, union perf_event *event, event->header.size, perf_event__name(event->header.type)); } -static void dump_sample (struct perf_evsel *evsel,union perf_event *event, -struct perf_sample *sample) +static void dump_sample (struct perf_evlist *evlist,struct perf_evsel *evsel, +union perf_event *event,struct perf_sample *sample) {u64 sample_type;
@@ -938,7 +961,7 @@ static void dump_sample(struct perf_evsel *evsel, union perf_event *event,printf ("... transaction: %" PRIx64"\n" , sample->transaction);if (sample_type &PERF_SAMPLE_READ ) -sample_read__printf (sample, evsel->attr.read_format); +sample_read__printf (evlist, sample, evsel->attr.read_format); } static struct machine *machines__find_for_cpumode(struct machines *machines,
@@ -1053,11 +1076,12 @@ static int machines__deliver_event(struct machines *machines,switch (event->header.type) {case PERF_RECORD_SAMPLE : -dump_sample (evsel, event, sample);if (evsel ==NULL ) { ++evlist->stats.nr_unknown_id;return 0 ; } +dump_sample (evlist, evsel, event, sample); +if (machine ==NULL ) { ++evlist->stats.nr_unprocessable_samples;return 0 ;
tools/perf/util/session.h +38 -0
@@ -42,6 +42,44 @@ struct perf_session {#define PRINT_IP_OPT_ONELINE (1<<4)#define PRINT_IP_OPT_SRCLINE (1<<5) +#define PERF_MSR_TSC 0 +#define PERF_MSR_APERF 1 +#define PERF_MSR_MPERF 2 + +enum perf_freq_perf_index { +FREQ_PERF_TSC =0 , +FREQ_PERF_APERF =1 , +FREQ_PERF_MPERF =2 , +FREQ_PERF_CYCLES =3 , +FREQ_PERF_REF_CYCLES =4 , + +FREQ_PERF_MAX +}; + +#define SET_FREQ_PERF_VALUE (event, array, value) \ +{ \ + if (event->attr.type == msr_pmu->type) { \ + if (event->attr.config == PERF_MSR_TSC) \ + array[FREQ_PERF_TSC] = value; \ + if (event->attr.config == PERF_MSR_APERF) \ + array[FREQ_PERF_APERF] = value; \ + if (event->attr.config == PERF_MSR_MPERF) \ + array[FREQ_PERF_MPERF] = value; \ + } \ + if (event->attr.type == PERF_TYPE_HARDWARE) { \ + if (event->attr.config == PERF_COUNT_HW_CPU_CYCLES) \ + array[FREQ_PERF_CYCLES] = value; \ + if (event->attr.config == PERF_COUNT_HW_REF_CPU_CYCLES) \ + array[FREQ_PERF_REF_CYCLES] = value; \ + } \ +} + +#define HAS_FREQ (array) \ + ((array[FREQ_PERF_CYCLES] > 0) && (array[FREQ_PERF_REF_CYCLES] > 0)) +#define HAS_CPU_U (array) \ + ((array[FREQ_PERF_TSC] > 0) && (array[FREQ_PERF_REF_CYCLES] > 0)) +#define HAS_CORE_BUSY (array) \ + ((array[FREQ_PERF_APERF] > 0) && (array[FREQ_PERF_MPERF] > 0))struct perf_tool ; struct perf_session *perf_session__new(struct perf_data_file *file,
Signature · 1 line
1.8.3.1
PATCH 3/5 perf,tools: save misc sample read value in struct perf_sample
In reply to Kan LiangSave group read results from cycles/ref-cycles/TSC/ASTATE/MSTATE in struct perf_sample. The following sample process function can easily use them to caculate freq/CPU%/CORE_BUSY% and add them in hists.
--- tools/perf/util/event.h | 11 +++++++++++ tools/perf/util/session.c | 16 ++++++++++++++++ tools/perf/util/session.h | 10 ---------- 3 files changed, 27 insertions(+), 10 deletions(-)
tools/perf/util/event.h +11 -0
@@ -176,6 +176,16 @@ enum { PERF_IP_FLAG_TRACE_BEGIN |\ PERF_IP_FLAG_TRACE_END) +enum perf_freq_perf_index { +FREQ_PERF_TSC =0 , +FREQ_PERF_APERF =1 , +FREQ_PERF_MPERF =2 , +FREQ_PERF_CYCLES =3 , +FREQ_PERF_REF_CYCLES =4 , + +FREQ_PERF_MAX +}; +struct perf_sample {u64 ip;u32 pid, tid;
@@ -191,6 +201,7 @@ struct perf_sample {u64 data_src;u32 flags;u16 insn_len; +u64 freq_perf_data[FREQ_PERF_MAX ];void *raw_data;struct ip_callchain *callchain;struct branch_stack *branch_stack;
tools/perf/util/session.c +16 -0
@@ -999,6 +999,8 @@ static int deliver_sample_value(struct perf_evlist *evlist, struct machine *machine) {struct perf_sample_id *sid =perf_evlist__id2sid (evlist, v->id); +struct perf_evsel *evsel; +u64 nr =0 ;if (sid) { sample->id = v->id;
@@ -1011,6 +1013,20 @@ static int deliver_sample_value(struct perf_evlist *evlist,return 0 ; } +if (perf_evsel__is_group_leader (sid->evsel)) { + evsel = sid->evsel; +SET_FREQ_PERF_VALUE (evsel, sample->freq_perf_data, + sample->read.group.values[nr].value); +evlist__for_each_continue (evlist, evsel) { +if ((evsel->leader != sid->evsel) || + (++nr >= sample->read.group.nr)) +break ; + +SET_FREQ_PERF_VALUE (evsel, sample->freq_perf_data, + sample->read.group.values[nr].value); + } + } +return tool->sample (tool, event, sample, sid->evsel, machine); }
tools/perf/util/session.h +0 -10
@@ -46,16 +46,6 @@ struct perf_session {#define PERF_MSR_APERF 1#define PERF_MSR_MPERF 2 -enum perf_freq_perf_index { -FREQ_PERF_TSC =0 , -FREQ_PERF_APERF =1 , -FREQ_PERF_MPERF =2 , -FREQ_PERF_CYCLES =3 , -FREQ_PERF_REF_CYCLES =4 , - -FREQ_PERF_MAX -}; -#define SET_FREQ_PERF_VALUE (event, array, value) \ { \ if (event->attr.type == msr_pmu->type) { \
Signature · 1 line
1.8.3.1
PATCH 4/5 perf,tools: caculate and save freq/CPU%/CORE_BUSY% in he_stat
In reply to Kan LiangIntroduce a new hist_iter ops (hist_iter_freq_perf) to caculate the freq/CPU%/CORE_BUSY% freq when processing samples, and save them in hist_entry.
--- tools/perf/builtin-annotate.c | 2 +- tools/perf/builtin-diff.c | 2 +- tools/perf/tests/hists_link.c | 4 ++-- tools/perf/util/hist.c | 51 ++++++++++++++++++++++++++++++++++++++----- tools/perf/util/hist.h | 2 ++ tools/perf/util/sort.h | 3 +++ tools/perf/util/symbol.h | 6 +++++ 7 files changed, 60 insertions(+), 10 deletions(-)
tools/perf/builtin-annotate.c +1 -1
@@ -71,7 +71,7 @@ static int perf_evsel__add_sample(struct perf_evsel *evsel,return 0 ; } - he =__hists__add_entry (hists, al,NULL ,NULL ,NULL ,1 ,1 ,0 , true); + he =__hists__add_entry (hists, al,NULL ,NULL ,NULL ,1 ,1 ,0 ,NULL , true);if (he ==NULL )return -ENOMEM ;
tools/perf/builtin-diff.c +1 -1
@@ -315,7 +315,7 @@ static int hists__add_entry(struct hists *hists, u64 weight, u64 transaction) { if (__hists__add_entry(hists, al, NULL, NULL, NULL, period, weight, - transaction, true) != NULL) + transaction, NULL, true) != NULL) return 0;return -ENOMEM ; }
tools/perf/tests/hists_link.c +2 -2
@@ -90,7 +90,7 @@ static int add_hist_entries(struct perf_evlist *evlist, struct machine *machine) goto out; he =__hists__add_entry (hists, &al,NULL , -NULL ,NULL ,1 ,1 ,0 , true); +NULL ,NULL ,1 ,1 ,0 ,NULL , true);if (he ==NULL ) {addr_location__put (&al); goto out;
@@ -116,7 +116,7 @@ static int add_hist_entries(struct perf_evlist *evlist, struct machine *machine) goto out; he =__hists__add_entry (hists, &al,NULL , -NULL ,NULL ,1 ,1 ,0 , true); +NULL ,NULL ,1 ,1 ,0 ,NULL , true);if (he ==NULL ) {addr_location__put (&al); goto out;
tools/perf/util/hist.c +45 -6
105 lines not on this page · raw message
tools/perf/util/hist.h +2 -0
@@ -102,6 +102,7 @@ extern const struct hist_iter_ops hist_iter_normal;extern const struct hist_iter_ops hist_iter_branch;extern const struct hist_iter_ops hist_iter_mem;extern const struct hist_iter_ops hist_iter_cumulative; +extern const struct hist_iter_ops hist_iter_freq_perf; struct hist_entry *__hists__add_entry(struct hists *hists, struct addr_location *al,
@@ -109,6 +110,7 @@ struct hist_entry *__hists__add_entry(struct hists *hists,struct branch_info *bi, struct mem_info *mi, u64 period, u64 weight, u64 transaction, + struct freq_perf_info *freq_perf, bool sample_self);int hist_entry_iter__add (struct hist_entry_iter *iter,struct addr_location *al,int max_stack_depth,void *arg);
tools/perf/util/sort.h +3 -0
@@ -54,6 +54,9 @@ struct he_stat {u64 period_guest_us;u64 weight;u32 nr_events; +u64 freq; +u64 cpu_u; +u64 core_busy; };struct hist_entry_diff {
tools/perf/util/symbol.h +6 -0
@@ -180,6 +180,12 @@ struct mem_info {union perf_mem_data_src data_src; }; +struct freq_perf_info { +u64 freq; +u64 cpu_u; +u64 core_busy; +}; +struct addr_location {struct machine *machine;struct thread *thread;
Signature · 1 line
1.8.3.1
PATCH 5/5 perf,tools: Show freq/CPU%/CORE_BUSY% in perf report --stdio
In reply to Kan LiangShow frequency, CPU Utilization and percent performance for each symbol in perf report by --stdio --show-freq-perf
In sampling group, only group leader do sampling. So only need to print group leader's freq in --group.
Here is an example.
$ perf report --stdio --group --show-freq-perf
Overhead FREQ MHz CPU% CORE_BUSY%
Command Shared Object Symbol
........................................ ......... ..... ..........
........... ................ ......................
99.54% 99.54% 99.53% 99.53% 99.53% 2301 96 99
tchain_edit tchain_edit [.] f3
0.20% 0.20% 0.20% 0.20% 0.20% 2301 98 99
tchain_edit tchain_edit [.] f2
0.05% 0.05% 0.05% 0.05% 0.05% 2300 98 99
tchain_edit [kernel.vmlinux] [k] read_tsc--- tools/perf/Documentation/perf-report.txt | 12 ++++++ tools/perf/builtin-report.c | 19 +++++++++ tools/perf/perf.h | 1 + tools/perf/ui/hist.c | 71 +++++++++++++++++++++++++++++--- tools/perf/util/hist.h | 3 ++ tools/perf/util/session.c | 2 +- tools/perf/util/sort.c | 3 ++ tools/perf/util/symbol.h | 3 +- tools/perf/util/util.c | 2 + 9 files changed, 109 insertions(+), 7 deletions(-)
tools/perf/Documentation/perf-report.txt +12 -0
@@ -303,6 +303,18 @@ OPTIONS special event -e cpu/mem-loads/ or -e cpu/mem-stores/. See 'perf mem' for simpler access. +--show-freq-perf:: + Show CPU frequency and performance result from sample read. + To generate the frequency and performance output, the perf.data file + must have been obtained by group read and using special events cycles, + ref-cycles, msr/tsc/, msr/aperf/ or msr/mperf/ + Freq MHz: The frequency during the sample interval. Needs cycles and + ref-cycles event. + CPU%: CPU utilization during the sample interval. Needs ref-cycles and + msr/tsc/ events. + CORE_BUSY%: actual percent performance (APERF/MPERF%) during the + sample interval. Needs msr/aperf/ and msr/mperf/ events. + --percent-limit:: Do not show entries which have an overhead under that percent. (Default: 0).
tools/perf/builtin-report.c +19 -0
@@ -166,6 +166,8 @@ static int process_sample_event(struct perf_tool *tool, iter.ops = &hist_iter_mem; else if (symbol_conf.cumulate_callchain) iter.ops = &hist_iter_cumulative; + else if (symbol_conf.show_freq_perf) + iter.ops = &hist_iter_freq_perf; else iter.ops = &hist_iter_normal;
@@ -723,6 +725,8 @@ int cmd_report(int argc, const char **argv, const char *prefix __maybe_unused)OPT_BOOLEAN (0 ,"demangle-kernel" , &symbol_conf.demangle_kernel,"Enable kernel symbol demangling" ),OPT_BOOLEAN (0 ,"mem-mode" , &report.mem_mode,"mem access profile" ), +OPT_BOOLEAN (0 ,"show-freq-perf" , &symbol_conf.show_freq_perf, +"show CPU freqency and performance info" ),OPT_CALLBACK (0 ,"percent-limit" , &report,"percent" ,"Don't show entries under that percent" , parse_percent_limit), OPT_CALLBACK(0, "percentage", NULL, "relative|absolute",
@@ -735,7 +739,9 @@ int cmd_report(int argc, const char **argv, const char *prefix __maybe_unused)struct perf_data_file file = { .mode =PERF_DATA_MODE_READ , }; +struct perf_evsel *pos;int ret =hists__init (); +bool freq_perf_info[FREQ_PERF_MAX ] = {0 };if (ret <0 )return ret;
@@ -823,6 +829,19 @@ repeat: msr_pmu =perf_pmu__find ("msr" ); cpu_max_freq =get_cpu_max_freq () /1000 ; +if (symbol_conf.show_freq_perf) { + perf_freq = perf_cpu_u = perf_core_busy = false; +evlist__for_each (session->evlist, pos) { +SET_FREQ_PERF_VALUE (pos, freq_perf_info, true); + } +if (HAS_FREQ (freq_perf_info)) + perf_freq = true; +if (HAS_CPU_U (freq_perf_info)) + perf_cpu_u = true; +if (HAS_CORE_BUSY (freq_perf_info)) + perf_core_busy = true; + } +if (setup_sorting () <0 ) {if (sort_order)parse_options_usage (report_usage, options,"s" ,1 );
tools/perf/perf.h +1 -0
@@ -33,6 +33,7 @@ static inline unsigned long long rdclock(void)extern const char *input_name;extern bool perf_host, perf_guest; +extern bool perf_freq, perf_cpu_u, perf_core_busy;extern const char perf_version_string[];void pthread__unblock_sigwinch (void );
tools/perf/ui/hist.c +66 -5
140 lines not on this page · raw message
tools/perf/util/hist.h +3 -0
@@ -237,6 +237,9 @@ enum {PERF_HPP__OVERHEAD_ACC ,PERF_HPP__SAMPLES ,PERF_HPP__PERIOD , +PERF_HPP__FREQ , +PERF_HPP__CPU_U , +PERF_HPP__CORE_BUSY , PERF_HPP__MAX_INDEX };
tools/perf/util/session.c +1 -1
@@ -1013,7 +1013,7 @@ static int deliver_sample_value(struct perf_evlist *evlist,return 0 ; } -if (perf_evsel__is_group_leader (sid->evsel)) { +if (symbol_conf.show_freq_perf &&perf_evsel__is_group_leader (sid->evsel)) { evsel = sid->evsel;SET_FREQ_PERF_VALUE (evsel, sample->freq_perf_data, sample->read.group.values[nr].value);
tools/perf/util/sort.c +3 -0
@@ -1225,6 +1225,9 @@ static struct hpp_dimension hpp_sort_dimensions[] = {DIM (PERF_HPP__OVERHEAD_ACC ,"overhead_children" ),DIM (PERF_HPP__SAMPLES ,"sample" ),DIM (PERF_HPP__PERIOD ,"period" ), +DIM (PERF_HPP__FREQ ,"freq" ), +DIM (PERF_HPP__CPU_U ,"cpu_u" ), + DIM(PERF_HPP__CORE_BUSY, "core_busy"), };#undef DIM
tools/perf/util/symbol.h +2 -1
@@ -106,7 +106,8 @@ struct symbol_conf { filter_relative, show_hist_headers, branch_callstack, - has_filter; + has_filter, + show_freq_perf;const char *vmlinux_name, *kallsyms_name, *source_prefix,
tools/perf/util/util.c +2 -0
@@ -34,6 +34,8 @@ bool test_attr__enabled;bool perf_host = true;bool perf_guest = false; +bool perf_freq, perf_cpu_u, perf_core_busy; +char tracing_events_path[PATH_MAX +1 ] ="/sys/kernel/debug/tracing/events" ;void event_attr_init (struct perf_event_attr *attr)
Signature · 1 line
1.8.3.1
Quoted 16 lines · Kan Liang
This patch set supports per-sample freq/CPU%/CORE_BUSY% print in perf report -D and --stdio.
For printing these information, the perf.data file must have been obtained by group read and using special events cycles, ref-cycles, msr/tsc/, msr/aperf/ or msr/mperf/.- Freq (MHz): The frequency during the sample interval. Needs cycles ref-cycles event.
- CPU%: CPU utilization during the sample interval. Needs ref-cycles and msr/tsc/ events.
- CORE_BUSY%: actual percent performance (APERF/MPERF%) during the sample interval. Needs msr/aperf/ and msr/mperf/ events.For printing CPU% and CORE_BUSY%, please also apply the kernel patch.
http://marc.info/?l=linux-kernel&m=143747254926369&w=2
Quoted 7 lines
Here is an example:
$ perf record -e '{cycles,ref-cycles,msr/tsc/,msr/mperf/,msr/aperf/}:S' ~/tchain_edit$ perf report --stdio --group --show-freq-perf
Based on what I see in the patch, you are assuming that you ALWAYS run perf report on the same system as where you ran perf record. This is a problem on servers. so you need to have all the information you need in the perf.data file. You cannot fish the information from sysfs on the host where perf report runs.
Quoted 43 lines
Overhead FREQ MHz CPU% CORE_BUSY%
Command Shared Object Symbol
........................................ ......... ..... ..........
........... ................ ......................99.54% 99.54% 99.53% 99.53% 99.53% 2301 96 99 tchain_edit tchain_edit [.] f3 0.20% 0.20% 0.20% 0.20% 0.20% 2301 98 99 tchain_edit tchain_edit [.] f2 0.05% 0.05% 0.05% 0.05% 0.05% 2300 98 99 tchain_edit [kernel.vmlinux] [k] read_tscKan Liang (5):
perf,tools: introduceget_cpu_max_freq
perf,tools: Dump per-sample freq/CPU%/CORE_BUSY% in report -D perf,tools: save misc sample read value in structperf_sampleperf,tools: caculate and save freq/CPU%/CORE_BUSY% inhe_statperf,tools: Show freq/CPU%/CORE_BUSY% in perf report --stdiotools/perf/Documentation/perf-report.txt | 12 ++++++ tools/perf/builtin-annotate.c | 2 +- tools/perf/builtin-diff.c | 2 +- tools/perf/builtin-report.c | 24 +++++++++++ tools/perf/perf.h | 1 + tools/perf/tests/hists_link.c | 4 +- tools/perf/ui/hist.c | 71 +++++++++++++++++++++++++++++--- tools/perf/util/cpumap.c | 32 ++++++++++++++ tools/perf/util/cpumap.h | 2 + tools/perf/util/event.h | 11 +++++ tools/perf/util/hist.c | 51 ++++++++++++++++++++--- tools/perf/util/hist.h | 5 +++ tools/perf/util/pmu.h | 2 + tools/perf/util/session.c | 50 +++++++++++++++++++--- tools/perf/util/session.h | 28 +++++++++++++ tools/perf/util/sort.c | 3 ++ tools/perf/util/sort.h | 3 ++ tools/perf/util/symbol.h | 9 +++- tools/perf/util/util.c | 2 + 19 files changed, 293 insertions(+), 21 deletions(-)--
1.8.3.1