kernel_optimize_test/tools/perf/util
Stephane Eranian 410136f5dd tools/perf/stat: Add event unit and scale support
This patch adds perf stat support for handling event units and
scales as exported by the kernel.

The kernel can export PMU events actual unit and scaling factor
via sysfs:

  $ ls -1 /sys/devices/power/events/energy-*
  /sys/devices/power/events/energy-cores
  /sys/devices/power/events/energy-cores.scale
  /sys/devices/power/events/energy-cores.unit
  /sys/devices/power/events/energy-pkg
  /sys/devices/power/events/energy-pkg.scale
  /sys/devices/power/events/energy-pkg.unit
  $ cat /sys/devices/power/events/energy-cores.scale
  2.3283064365386962890625e-10
  $ cat cat /sys/devices/power/events/energy-cores.unit
  Joules

This patch modifies the pmu event alias code to check
for the presence of the .unit and .scale files to load
the corresponding values. They are then used by perf stat
transparently:

   # perf stat -a -e power/energy-pkg/,power/energy-cores/,cycles -I 1000 sleep 1000
   #          time             counts   unit events
       1.000214717               3.07 Joules power/energy-pkg/         [100.00%]
       1.000214717               0.53 Joules power/energy-cores/
       1.000214717           12965028        cycles                    [100.00%]
       2.000749289               3.01 Joules power/energy-pkg/
       2.000749289               0.52 Joules power/energy-cores/
       2.000749289           15817043        cycles

When the event does not have an explicit unit exported by
the kernel, nothing is printed. In csv output mode, there
will be an empty field.

Special thanks to Jiri for providing the supporting code
in the parser to trigger reading of the scale and unit files.

Signed-off-by: Stephane Eranian <eranian@google.com>
Reviewed-by: Jiri Olsa <jolsa@redhat.com>
Reviewed-by: Andi Kleen <ak@linux.intel.com>
Signed-off-by: Peter Zijlstra <peterz@infradead.org>
Cc: zheng.z.yan@intel.com
Cc: bp@alien8.de
Cc: maria.n.dimakopoulou@gmail.com
Cc: acme@redhat.com
Link: http://lkml.kernel.org/r/1384275531-10892-3-git-send-email-eranian@google.com
Signed-off-by: Ingo Molnar <mingo@kernel.org>
2013-11-27 11:16:39 +01:00
..
include perf fs: Add procfs support 2013-11-05 15:15:07 -03:00
scripting-engines perf tools: Use an accessor to read thread comm 2013-11-04 11:50:28 -03:00
abspath.c
alias.c
annotate.c perf annotate: Find kcore symbols on other maps 2013-10-14 10:29:20 -03:00
annotate.h perf tools: Separate out GTK codes to libperf-gtk.so 2013-10-09 15:55:25 -03:00
bitmap.c
build-id.c perf tools: Stop using 'self' in some more places 2013-10-23 09:55:37 -03:00
build-id.h perf tools: Finish the removal of 'self' arguments 2013-11-05 15:32:36 -03:00
cache.h tools/perf: Turn strlcpy() into a __weak function 2013-10-09 08:48:49 +02:00
callchain.c perf callchain: Convert children list to rbtree 2013-10-21 17:33:23 -03:00
callchain.h Merge branch 'perf/urgent' into perf/core 2013-10-29 11:23:32 +01:00
cgroup.c
cgroup.h
color.c perf tools: Remove cast of non-variadic function to variadic 2013-11-01 10:40:51 -03:00
color.h perf tools: Remove cast of non-variadic function to variadic 2013-11-01 10:40:51 -03:00
comm.c perf tools: Get current comm instead of last one 2013-11-04 12:16:39 -03:00
comm.h perf tools: Get current comm instead of last one 2013-11-04 12:16:39 -03:00
config.c
cpumap.c perf fs: Rename NAME_find_mountpoint() to NAME__mountpoint() 2013-11-05 15:15:00 -03:00
cpumap.h perf tools: Rename cpu_map__all() to cpu_map__empty() 2013-07-12 13:45:44 -03:00
ctype.c
data.c perf tools: Add perf_data_file__open interface to data object 2013-10-21 17:33:24 -03:00
data.h perf session: Separating data file properties from session 2013-10-21 17:33:25 -03:00
debug.c
debug.h
dso.c perf tools: Save failed result of get_srcline() 2013-10-09 16:02:02 -03:00
dso.h perf tools: Save failed result of get_srcline() 2013-10-09 16:02:02 -03:00
dwarf-aux.c perf probe: Fix to find line information for probe list 2013-10-04 15:16:05 -03:00
dwarf-aux.h perf probe: Fix to find line information for probe list 2013-10-04 15:16:05 -03:00
environment.c
event.c perf tools: Synthesize anon MMAP records again 2013-11-14 16:00:01 -03:00
event.h perf record: Synthesize non-exec MMAP records when --data used 2013-11-11 15:56:39 -03:00
evlist.c perf record: Add an option to force per-cpu mmaps 2013-11-14 16:10:27 -03:00
evlist.h perf target: Shorten perf_target__ to target__ 2013-11-12 16:51:03 -03:00
evsel.c tools/perf/stat: Add event unit and scale support 2013-11-27 11:16:39 +01:00
evsel.h tools/perf/stat: Add event unit and scale support 2013-11-27 11:16:39 +01:00
exec_cmd.c
exec_cmd.h
fs.c perf fs: Add procfs support 2013-11-05 15:15:07 -03:00
fs.h perf fs: Add procfs support 2013-11-05 15:15:07 -03:00
generate-cmdlist.sh tools/perf: Standardize feature support define names to: HAVE_{FEATURE}_SUPPORT 2013-10-09 08:48:28 +02:00
header.c perf header: Fix possible memory leaks in process_group_desc() 2013-11-19 10:34:05 -03:00
header.h perf header: Recognize version number for perf data file 2013-07-17 17:04:00 -03:00
help.c
help.h
hist.c perf hists: Consolidate __hists__add_*entry() 2013-11-04 20:59:09 -03:00
hist.h perf tools: Finish the removal of 'self' arguments 2013-11-05 15:32:36 -03:00
hweight.c
intlist.c perf util: Add findnew method to intlist 2013-10-14 10:28:48 -03:00
intlist.h perf util: Add findnew method to intlist 2013-10-14 10:28:48 -03:00
levenshtein.c
levenshtein.h
machine.c perf symbols: Limit max callchain using max_stack on DWARF unwinding too 2013-11-14 16:00:23 -03:00
machine.h perf target: Shorten perf_target__ to target__ 2013-11-12 16:51:03 -03:00
map.c perf annotate: Another fix for annotate_browser__callq() 2013-10-14 12:21:18 -03:00
map.h perf annotate: Another fix for annotate_browser__callq() 2013-10-14 12:21:18 -03:00
pager.c
parse-events.c tools/perf/stat: Add event unit and scale support 2013-11-27 11:16:39 +01:00
parse-events.h perf parse events: Demystify memory allocations 2013-07-12 13:52:05 -03:00
parse-events.l perf tools: Move start conditions to start of the flex file 2013-10-11 12:17:31 -03:00
parse-events.y perf parse events: Demystify memory allocations 2013-07-12 13:52:05 -03:00
parse-options.c perf stat: Enhance option parse error message 2013-11-04 12:57:36 -03:00
parse-options.h perf tools: Show single option when failed to parse 2013-11-04 12:51:45 -03:00
path.c tools/perf: Turn strlcpy() into a __weak function 2013-10-09 08:48:49 +02:00
perf_regs.h tools/perf: Standardize feature support define names to: HAVE_{FEATURE}_SUPPORT 2013-10-09 08:48:28 +02:00
PERF-VERSION-GEN perf tools: Fix version when building out of tree 2013-11-07 10:40:47 -03:00
pmu.c tools/perf/stat: Add event unit and scale support 2013-11-27 11:16:39 +01:00
pmu.h tools/perf/stat: Add event unit and scale support 2013-11-27 11:16:39 +01:00
pmu.l
pmu.y
probe-event.c perf probe: Support "$vars" meta argument syntax for local variables 2013-10-23 09:55:37 -03:00
probe-event.h
probe-finder.c perf tools: Finish the removal of 'self' arguments 2013-11-05 15:32:36 -03:00
probe-finder.h perf tools: Finish the removal of 'self' arguments 2013-11-05 15:32:36 -03:00
pstack.c
pstack.h perf tools: Finish the removal of 'self' arguments 2013-11-05 15:32:36 -03:00
python-ext-sources perf tools: Factor sysfs code into generic fs object 2013-11-05 14:44:26 -03:00
python.c Merge branch 'perf/urgent' into perf/core 2013-10-29 11:23:32 +01:00
quote.c
quote.h
rblist.c perf util: Add findnew method to intlist 2013-10-14 10:28:48 -03:00
rblist.h perf util: Add findnew method to intlist 2013-10-14 10:28:48 -03:00
record.c perf tools: Check maximum frequency rate for record/top 2013-11-05 15:15:08 -03:00
run-command.c
run-command.h
session.c perf evsel: Ditch evsel->handler.data field 2013-11-07 10:40:47 -03:00
session.h perf tools: Finish the removal of 'self' arguments 2013-11-05 15:32:36 -03:00
setup.py perf tools: Merge all *CFLAGS* make variable into CFLAGS 2013-05-30 16:12:03 +03:00
sigchain.c
sigchain.h
sort.c perf tools: Prevent condition that all sort keys are elided 2013-11-11 15:56:40 -03:00
sort.h perf tools: Remove unneeded include 2013-11-07 11:51:19 -03:00
srcline.c perf tools: Fix old GCC build error in 'get_srcline' 2013-10-14 10:28:52 -03:00
stat.c perf stats: Add max and min stats 2013-08-07 17:35:26 -03:00
stat.h perf stats: Add max and min stats 2013-08-07 17:35:26 -03:00
strbuf.c
strbuf.h
strfilter.c perf tools: Finish the removal of 'self' arguments 2013-11-05 15:32:36 -03:00
strfilter.h perf tools: Finish the removal of 'self' arguments 2013-11-05 15:32:36 -03:00
string.c perf tools: Default to cpu// for events v5 2013-07-12 13:53:52 -03:00
strlist.c
strlist.h
svghelper.c
svghelper.h
symbol-elf.c perf symbols: Fix a mmap and munmap mismatched bug 2013-10-14 12:21:23 -03:00
symbol-minimal.c perf buildid-cache: Add ability to add kcore to the cache 2013-10-14 12:20:38 -03:00
symbol.c perf symbols: Fix a memory leak due to symbol__delete not being used 2013-10-14 12:21:20 -03:00
symbol.h perf buildid-cache: Add ability to add kcore to the cache 2013-10-14 12:20:38 -03:00
target.c perf target: Shorten perf_target__ to target__ 2013-11-12 16:51:03 -03:00
target.h perf record: Add an option to force per-cpu mmaps 2013-11-14 16:10:27 -03:00
thread_map.c
thread_map.h
thread.c perf tools: Tag thread comm as overriden 2013-11-19 10:33:29 -03:00
thread.h perf tools: Finish the removal of 'self' arguments 2013-11-05 15:32:36 -03:00
tool.h perf tools: Add attr->mmap2 support 2013-09-11 10:09:32 -03:00
top.c perf target: Shorten perf_target__ to target__ 2013-11-12 16:51:03 -03:00
top.h perf top: Add --max-stack option to limit callchain stack scan 2013-10-21 17:36:25 -03:00
trace-event-info.c perf util: No need to call read_trace_init() in tracing_data_header() 2013-07-12 13:52:31 -03:00
trace-event-parse.c perf tools: Remove unused trace-event-* code 2013-10-09 11:15:28 -03:00
trace-event-read.c perf util: Parse header_page to get proper long size 2013-07-12 13:52:24 -03:00
trace-event-scripting.c perf script: Fix named threads support 2013-07-22 11:55:53 -03:00
trace-event.h perf tools: Remove unused trace-event-* code 2013-10-09 11:15:28 -03:00
types.h
unwind.c perf symbols: Limit max callchain using max_stack on DWARF unwinding too 2013-11-14 16:00:23 -03:00
unwind.h perf symbols: Limit max callchain using max_stack on DWARF unwinding too 2013-11-14 16:00:23 -03:00
usage.c
util.c perf tools: Do not accept parse_tag_value() overflow 2013-10-23 10:59:09 -03:00
util.h perf tools: Introduce filename__read_int helper 2013-10-17 16:33:43 -03:00
values.c
values.h
vdso.c perf symbols: Fix vdso list searching 2013-07-08 17:59:07 -03:00
vdso.h
wrapper.c
xyarray.c
xyarray.h