Re: [PATCH V9 6/6] perf,tools: Show freq/CPU%/CORE_BUSY% in perf report by --freq-perf

2015-09-09 Thread Jiri Olsa
On Tue, Sep 08, 2015 at 03:32:49PM -0400, kan.li...@intel.com wrote:
> From: Kan Liang 
> 
> Show frequency, CPU Utilization and percent performance for each symbol
> in perf report by --freq-perf
> 
> In sampling group, only group leader do sampling. So only need to print
> group leader's freq in --group.
> 
> --freq-perf option also implies --group.
> 
> Here is an example.
> 
> $ perf report --stdio --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
> 
> Signed-off-by: Kan Liang 

it seems ok to me, though I think it could be split
into HPP__SINGLE_PRINT_FNS support and the rest..

but I prefer if Arnaldo or Namhyung could review this one

thanks,
jirka
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH V9 6/6] perf,tools: Show freq/CPU%/CORE_BUSY% in perf report by --freq-perf

2015-09-08 Thread kan . liang
From: Kan Liang 

Show frequency, CPU Utilization and percent performance for each symbol
in perf report by --freq-perf

In sampling group, only group leader do sampling. So only need to print
group leader's freq in --group.

--freq-perf option also implies --group.

Here is an example.

$ perf report --stdio --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

Signed-off-by: Kan Liang 
---
 tools/perf/Documentation/perf-report.txt | 12 ++
 tools/perf/builtin-report.c  | 25 ++-
 tools/perf/ui/hist.c | 71 +---
 tools/perf/util/hist.h   |  3 ++
 tools/perf/util/session.c| 33 ---
 tools/perf/util/sort.c   |  3 ++
 tools/perf/util/symbol.h | 12 +-
 7 files changed, 137 insertions(+), 22 deletions(-)

diff --git a/tools/perf/Documentation/perf-report.txt 
b/tools/perf/Documentation/perf-report.txt
index b941d5e..9804e63 100644
--- a/tools/perf/Documentation/perf-report.txt
+++ b/tools/perf/Documentation/perf-report.txt
@@ -307,6 +307,18 @@ OPTIONS
special event -e cpu/mem-loads/ or -e cpu/mem-stores/. See
'perf mem' for simpler access.
 
+--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).
diff --git a/tools/perf/builtin-report.c b/tools/perf/builtin-report.c
index d6e5203..bd466d8 100644
--- a/tools/perf/builtin-report.c
+++ b/tools/perf/builtin-report.c
@@ -134,7 +134,8 @@ static int hist_iter__report_callback(struct 
hist_entry_iter *iter,
struct branch_info *bi;
 
if ((iter->ops == &hist_iter_normal) &&
-   perf_evsel__is_group_leader(evsel))
+   perf_evsel__is_group_leader(evsel) &&
+   symbol_conf.freq_perf)
set_he_freq_perf(rep->session, iter);
 
if (!ui__has_annotation())
@@ -785,6 +786,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, "freq-perf", &symbol_conf.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",
@@ -803,7 +806,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();
+   perf_freq_t freq_data_status = { 0 };
 
if (ret < 0)
return ret;
@@ -888,6 +893,24 @@ repeat:
symbol_conf.cumulate_callchain = false;
}
 
+
+   if (symbol_conf.freq_perf) {
+   symbol_conf.freq_perf_type = 0;
+   evlist__for_each(session->evlist, pos) {
+   perf_freq__init(session->header.env.msr_pmu_type,
+   pos, freq_data_status, 1);
+   }
+   if (perf_freq__has_freq(freq_data_status))
+   symbol_conf.freq_perf_type |= 1U << DISPLAY_FREQ;
+   if (perf_freq__has_cpu_util(freq_data_status))
+   symbol_conf.freq_perf_type |= 1U << DISPLAY_CPU_UTIL;
+   if (perf_freq__has_core_busy(freq_data_status))
+   symbol_conf.freq_perf_type |= 1U << DISPLAY_CORE_BUSY;
+
+   /* --freq-perf option imply --group */
+   symbol_conf.event