perf/core improvements and fixes
Arnaldo Carvalho de Melo
maintainerHi Ingo,
Please consider pulling,
- Arnaldo
Test results at the end of this message, as usual.
The following changes since commit 1b2f76d77a277bb70d38ad0991ed7f16bbc115a9:
Merge tag 'perf-core-for-mingo-4.14-20170829' of git://git.kernel.org/pub/scm/linux/kernel/git/acme/linux into perf/core (2017-08-29 23:13:56 +0200)
are available in the git repository at:
git://git.kernel.org/pub/scm/linux/kernel/git/acme/linux.git tags/perf-core-for-mingo-4.14-20170901
for you to fetch changes up to eba9fac017617e685d648339e29a1453a30cb065:
perf annotate browser: Help for cycling thru hottest instructions with TAB/shift+TAB (2017-09-01 14:55:40 -0300)
----------------------------------------------------------------
perf/core improvements and fixes:
- Support syscall name glob matching in 'perf trace' (Arnaldo Carvalho de Melo)
e.g.:
# perf trace -e pkey_* 32.784 (0.006 ms): pkey/16018 pkey_alloc(init_val: DISABLE_WRITE) = -1 EINVAL Invalid argument 32.795 (0.004 ms): pkey/16018 pkey_mprotect(start: 0x7f380d0a6000, len: 4096, prot: READ|WRITE, pkey: -1) = 0 32.801 (0.002 ms): pkey/16018 pkey_free(pkey: -1 ) = -1 EINVAL Invalid argument ^C#
- Do not auto merge counts for explicitely specified events in 'perf stat' (Arnaldo Carvalho de Melo)
- Fix syntax in documentation of .perfconfig intel-pt option (Jack Henschel)
- Calculate the average cycles of iterations for loops detected by the branch history support in 'perf report' (Jin Yao)
- Support PERF_SAMPLE_PHYS_ADDR as a sort key "phys_daddr" in the 'script', 'mem', 'top' and 'report'. Also add a test entry for it in 'perf test' (Kan Liang)
- Fix 'Object code reading' 'perf test' entry in PowerPC (Ravi Bangoria)
- Remove some duplicate Power9 duplicate vendor events (described in JSON files) (Sukadev Bhattiprolu)
- Add help entry in the TUI annotate browser about cycling thru hottest instructions with TAB/shift+TAB (Arnaldo Carvalho de Melo)
----------------------------------------------------------------
Arnaldo Carvalho de Melo (4):
perf syscalltbl: Support glob matching on syscall names
perf trace: Support syscall name globbing
perf stat: Only auto-merge events that are PMU aliases
perf annotate browser: Help for cycling thru hottest instructions with TAB/shift+TAB
Jack Henschel (1):
perf intel-pt: Fix syntax in documentation of config option
Jin Yao (1):
perf report: Calculate the average cycles of iterations
Kan Liang (5):
perf tools: Support new sample type for physical address perf sort: Add sort option for physical address perf mem: Support physical address
perf script: Support physical address
perf test: Add test case for PERF_SAMPLE_PHYS_ADDR
Ravi Bangoria (1):
perf test powerpc: Fix 'Object code reading' test
Sukadev Bhattiprolu (1):
perf vendor events powerpc: Remove duplicate events
tools/include/uapi/linux/perf_event.h | 4 +- tools/perf/Documentation/intel-pt.txt | 2 +- tools/perf/Documentation/perf-mem.txt | 4 + tools/perf/Documentation/perf-record.txt | 5 +- tools/perf/Documentation/perf-report.txt | 1 + tools/perf/Documentation/perf-script.txt | 2 +- tools/perf/Documentation/perf-trace.txt | 2 +- tools/perf/builtin-mem.c | 97 ++++++++++++----- tools/perf/builtin-record.c | 2 + tools/perf/builtin-script.c | 15 ++- tools/perf/builtin-stat.c | 2 +- tools/perf/builtin-trace.c | 39 ++++++- tools/perf/perf.h | 1 + .../pmu-events/arch/powerpc/power9/frontend.json | 7 +- .../perf/pmu-events/arch/powerpc/power9/other.json | 120 --------------------- .../pmu-events/arch/powerpc/power9/pipeline.json | 7 +- tools/perf/pmu-events/arch/powerpc/power9/pmc.json | 7 +- tools/perf/tests/code-reading.c | 5 + tools/perf/tests/sample-parsing.c | 6 +- tools/perf/ui/browsers/annotate.c | 3 +- tools/perf/ui/browsers/hists.c | 8 +- tools/perf/ui/stdio/hist.c | 10 +- tools/perf/util/callchain.c | 49 ++++----- tools/perf/util/callchain.h | 9 +- tools/perf/util/event.h | 1 + tools/perf/util/evsel.c | 19 +++- tools/perf/util/evsel.h | 1 + tools/perf/util/hist.c | 4 + tools/perf/util/hist.h | 1 + tools/perf/util/machine.c | 96 ++++++++++------- tools/perf/util/parse-events.c | 24 +++-- tools/perf/util/session.c | 3 + tools/perf/util/sort.c | 42 ++++++++ tools/perf/util/sort.h | 1 + tools/perf/util/symbol.h | 1 + tools/perf/util/syscalltbl.c | 33 ++++++ tools/perf/util/syscalltbl.h | 3 + 37 files changed, 368 insertions(+), 268 deletions(-)
Test results:
The first ones are container (docker) based builds of tools/perf with and without libelf support, objtool where it is supported and samples/bpf/, ditto. Where clang is available, it is also used to build perf with/without libelf.
Several are cross builds, the ones with -x-ARCH, and the android one, and those may not have all the features built, due to lack of multi-arch devel packages, available and being used so far on just a few, like debian:experimental-x-{arm64,mipsel}.
The 'perf test' one will perform a variety of tests exercising tools/perf/util/, tools/lib/{bpf,traceevent,etc}, as well as run perf commands with a variety of command line event specifications to then intercept the sys_perf_event syscall to check that the perf_event_attr fields are set up as expected, among a variety of other unit tests.
The 'perf test' also runs shell scripts exercising the tools, checking if they affect the system in certain ways, like setting up kprobes and uprobes, request callchains for well known programs and check that they are the expected ones, see if 'perf trace' beautifies system call arguments correctly, etc.
Additionally, a new set of tests, script based, runs the tools in a live system, setting probes in place that then gets used by 'perf trace', with its output compared against expected results.
Then there is the 'make -C tools/perf build-test' ones, that build tools/perf/ with a variety of feature sets, exercising the build with an incomplete set of features as well as with a complete one. It is planned to have it run on each of the containers mentioned above, using some container orchestration infrastructure. Get in contact if interested in helping having this in place.
# time dm 1 alpine:3.4: Ok 2 alpine:3.5: Ok 3 alpine:3.6: Ok 4 alpine:edge: Ok 5 android-ndk:r12b-arm: Ok 6 archlinux:latest: Ok 7 centos:5: Ok 8 centos:6: Ok 9 centos:7: Ok 10 debian:7: Ok 11 debian:8: Ok 12 debian:9: Ok 13 debian:experimental: Ok 14 debian:experimental-x-arm64: Ok 15 debian:experimental-x-mips: Ok 16 debian:experimental-x-mips64: Ok 17 debian:experimental-x-mipsel: Ok 18 fedora:20: Ok 19 fedora:21: Ok 20 fedora:22: Ok 21 fedora:23: Ok 22 fedora:24: Ok 23 fedora:24-x-ARC-uClibc: Ok 24 fedora:25: Ok 25 fedora:26: Ok 26 fedora:rawhide: Ok 27 mageia:5: Ok 28 opensuse:13.2: Ok 29 opensuse:42.1: Ok 30 opensuse:42.2: Ok 31 opensuse:42.3: Ok 32 opensuse:tumbleweed: Ok 33 oraclelinux:6: Ok 34 oraclelinux:7: Ok 35 ubuntu:12.04.5: Ok 36 ubuntu:14.04.4: Ok 37 ubuntu:14.04.4-x-linaro-arm64: Ok 38 ubuntu:15.10: Ok 39 ubuntu:16.04: Ok 40 ubuntu:16.04-x-arm: Ok 41 ubuntu:16.04-x-arm64: Ok 42 ubuntu:16.04-x-powerpc: Ok 43 ubuntu:16.04-x-powerpc64: Ok 44 ubuntu:16.04-x-powerpc64el: Ok 45 ubuntu:16.04-x-s390: Ok 46 ubuntu:16.10: Ok 47 ubuntu:17.04: Ok 48 ubuntu:17.10: Ok #
# uname -a Linux jouet 4.13.0-rc4+ #2 SMP Fri Aug 11 12:39:09 -03 2017 x86_64 x86_64 x86_64 GNU/Linux # perf test 1: vmlinux symtab matches kallsyms : Ok 2: Detect openat syscall event : Ok 3: Detect openat syscall event on all cpus : Ok 4: Read samples using the mmap interface : Ok 5: Test data source output : Ok 6: Parse event definition strings : Ok 7: Simple expression parser : Ok 8: PERF_RECORD_* events & perf_sample fields : Ok 9: Parse perf pmu format : Ok 10: DSO data read : Ok 11: DSO data cache : Ok 12: DSO data reopen : Ok 13: Roundtrip evsel->name : Ok 14: Parse sched tracepoints fields : Ok 15: syscalls:sys_enter_openat event fields : Ok 16: Setup struct perf_event_attr : Ok 17: Match and link multiple hists : Ok 18: 'import perf' in python : Ok 19: Breakpoint overflow signal handler : Ok 20: Breakpoint overflow sampling : Ok 21: Number of exit events of a simple workload : Ok 22: Software clock events period values : Ok 23: Object code reading : Ok 24: Sample parsing : Ok 25: Use a dummy software event to keep tracking : Ok 26: Parse with no sample_id_all bit set : Ok 27: Filter hist entries : Ok 28: Lookup mmap thread : Ok 29: Share thread mg : Ok 30: Sort output of hist entries : Ok 31: Cumulate child hist entries : Ok 32: Track with sched_switch : Ok 33: Filter fds with revents mask in a fdarray : Ok 34: Add fd to a fdarray, making it autogrow : Ok 35: kmod_path__parse : Ok 36: Thread map : Ok 37: LLVM search and compile : 37.1: Basic BPF llvm compile : Ok 37.2: kbuild searching : Ok 37.3: Compile source for BPF prologue generation : Ok 37.4: Compile source for BPF relocation : Ok 38: Session topology : Ok 39: BPF filter : 39.1: Basic BPF filtering : Ok 39.2: BPF pinning : Ok 39.3: BPF prologue generation : Ok 39.4: BPF relocation checker : Ok 40: Synthesize thread map : Ok 41: Remove thread map : Ok 42: Synthesize cpu map : Ok 43: Synthesize stat config : Ok 44: Synthesize stat : Ok 45: Synthesize stat round : Ok 46: Synthesize attr update : Ok 47: Event times : Ok 48: Read backward ring buffer : Ok 49: Print cpu map : Ok 50: Probe SDT events : Ok 51: is_printable_array : Ok 52: Print bitmap : Ok 53: perf hooks : Ok 54: builtin clang support : Skip (not compiled in) 55: unit_number__scnprintf : Ok 56: x86 rdpmc : Ok 57: Convert perf time to TSC : Ok 58: DWARF unwind : Ok 59: x86 instruction decoder - new instructions : Ok 60: Intel cqm nmi context read : Skip 61: Use vfs_getname probe to get syscall args filenames : Ok 62: probe libc's inet_pton & backtrace it with ping : Ok 63: Check open filename arg using perf trace + vfs_getname: Ok 64: Add vfs_getname probe to get syscall args filenames : Ok #
$ time make -C tools/perf build-test
make: Entering directory '/home/acme/git/linux/tools/perf'
- tarpkg: ./tests/perf-targz-src-pkg .
make_no_libbionic_O: make NO_LIBBIONIC=1
make_debug_O: make DEBUG=1
make_util_pmu_bison_o_O: make util/pmu-bison.o
make_no_libperl_O: make NO_LIBPERL=1
make_help_O: make help
make_no_libdw_dwarf_unwind_O: make NO_LIBDW_DWARF_UNWIND=1
make_with_babeltrace_O: make LIBBABELTRACE=1
make_no_auxtrace_O: make NO_AUXTRACE=1
make_no_demangle_O: make NO_DEMANGLE=1
make_no_scripts_O: make NO_LIBPYTHON=1 NO_LIBPERL=1
make_tags_O: make tags
make_no_newt_O: make NO_NEWT=1
make_no_ui_O: make NO_NEWT=1 NO_SLANG=1 NO_GTK2=1
make_no_libaudit_O: make NO_LIBAUDIT=1
make_install_prefix_slash_O: make install prefix=/tmp/krava/
make_no_libpython_O: make NO_LIBPYTHON=1
make_no_gtk2_O: make NO_GTK2=1
make_util_map_o_O: make util/map.o
make_perf_o_O: make perf.o
make_doc_O: make doc
make_static_O: make LDFLAGS=-static
make_no_libunwind_O: make NO_LIBUNWIND=1
make_no_libnuma_O: make NO_LIBNUMA=1
make_install_bin_O: make install-bin
make_minimal_O: make NO_LIBPERL=1 NO_LIBPYTHON=1 NO_NEWT=1 NO_GTK2=1 NO_DEMANGLE=1 NO_LIBELF=1 NO_LIBUNWIND=1 NO_BACKTRACE=1 NO_LIBNUMA=1 NO_LIBAUDIT=1 NO_LIBBIONIC=1 NO_LIBDW_DWARF_UNWIND=1 NO_AUXTRACE=1 NO_LIBBPF=1 NO_LIBCRYPTO=1 NO_SDT=1 NO_JVMTI=1
make_pure_O: make
make_with_clangllvm_O: make LIBCLANGLLVM=1
make_no_libelf_O: make NO_LIBELF=1
make_no_libbpf_O: make NO_LIBBPF=1
make_no_backtrace_O: make NO_BACKTRACE=1
make_install_prefix_O: make install prefix=/tmp/krava
make_install_O: make install
make_clean_all_O: make clean all
make_no_slang_O: make NO_SLANG=1
OK
$Arnaldo Carvalho de Melo
maintainerPATCH 1/13 perf report: Calculate the average cycles of iterations
From: Jin Yao <[email protected]>
The branch history code has a loop detection function. With this, we can get the number of iterations by calculating the removed loops.
While it would be nice for knowing the average cycles of iterations. This patch adds up the cycles in branch entries of removed loops and save the result to the next branch entry (e.g. branch entry A).
Finally it will display the iteration number and average cycles at the "from" of branch entry A.
For example:
perf record -g -j any,save_type ./div
perf report --branch-history --no-children --stdio
--22.63%--main div.c:42 (RET CROSS_2M)
compute_flag div.c:28 (cycles:2 iter:173115 avg_cycles:2)
|
--10.73%--compute_flag div.c:27 (RET CROSS_2M)
rand rand.c:28 (cycles:1)
rand rand.c:28 (RET CROSS_2M)
__random random.c:298 (cycles:1)
__random random.c:297 (COND_BWD CROSS_2M)
__random random.c:295 (cycles:1)
__random random.c:295 (COND_BWD CROSS_2M)
__random random.c:295 (cycles:1)
__random random.c:295 (RET CROSS_2M)--- tools/perf/ui/browsers/hists.c | 8 +--- tools/perf/ui/stdio/hist.c | 10 ++--- tools/perf/util/callchain.c | 49 +++++++++++------------ tools/perf/util/callchain.h | 9 ++--- tools/perf/util/machine.c | 88 +++++++++++++++++++++++++----------------- 5 files changed, 85 insertions(+), 79 deletions(-)
tools/perf/ui/browsers/hists.c +2 -6
@@ -931,12 +931,8 @@ static int hist_browser__show_callchain_list(struct hist_browser *browser, browser->show_dso);if (symbol_conf.show_branchflag_count) { -if (need_percent) -callchain_list_counts__printf_value (node, chain,NULL , - buf,sizeof (buf)); -else -callchain_list_counts__printf_value (NULL , chain,NULL , - buf,sizeof (buf)); +callchain_list_counts__printf_value (chain,NULL , + buf,sizeof (buf));if (asprintf (&alloc_str2,"%s%s" , str, buf) <0 ) str ="Not enough memory!" ;
tools/perf/ui/stdio/hist.c +3 -7
@@ -124,12 +124,8 @@ static size_t ipchain__fprintf_graph(FILE *fp, struct callchain_node *node, str =callchain_list__sym_name (chain, bf,sizeof (bf), false);if (symbol_conf.show_branchflag_count) { -if (!period) -callchain_list_counts__printf_value (node, chain,NULL , - buf,sizeof (buf)); -else -callchain_list_counts__printf_value (NULL , chain,NULL , - buf,sizeof (buf)); +callchain_list_counts__printf_value (chain,NULL , + buf,sizeof (buf));if (asprintf (&alloc_str,"%s%s" , str, buf) <0 ) str ="Not enough memory!" ;
@@ -313,7 +309,7 @@ static size_t callchain__fprintf_graph(FILE *fp, struct rb_root *root,if (symbol_conf.show_branchflag_count) ret +=callchain_list_counts__printf_value ( -NULL , chain, fp,NULL ,0 ); + chain, fp,NULL ,0 ); ret +=fprintf (fp,"\n" );if (++entries_printed == callchain_param.print_limit)
tools/perf/util/callchain.c +23 -26
133 lines not on this page · raw message
tools/perf/util/callchain.h +4 -5
@@ -119,7 +119,7 @@ struct callchain_list {u64 abort_count;u64 cycles_count;u64 iter_count; -u64 samples_count; +u64 iter_cycles;struct branch_type_stat brtype_stat;char *srcline;struct list_head list;
@@ -139,7 +139,7 @@ struct callchain_cursor_node {struct branch_flags branch_flags;u64 branch_from;int nr_loop_iter; -int samples; +u64 iter_cycles;struct callchain_cursor_node *next; };
@@ -201,7 +201,7 @@ static inline void callchain_cursor_reset(struct callchain_cursor *cursor)int callchain_cursor_append (struct callchain_cursor *cursor,u64 ip,struct map *map,struct symbol *sym,bool branch,struct branch_flags *flags, -int nr_loop_iter,int samples,u64 branch_from); +int nr_loop_iter,u64 iter_cycles,u64 branch_from);/* Close a cursor writing session. Initialize for the reader */ static inline void callchain_cursor_commit (struct callchain_cursor *cursor)
@@ -282,8 +282,7 @@ char *callchain_node__scnprintf_value(struct callchain_node *node,int callchain_node__fprintf_value (struct callchain_node *node,FILE *fp,u64 total); -int callchain_list_counts__printf_value (struct callchain_node *node, -struct callchain_list *clist, +int callchain_list_counts__printf_value (struct callchain_list *clist,FILE *fp,char *bf,int bfsize);void free_callchain (struct callchain_root *root);
tools/perf/util/machine.c +53 -35
165 lines not on this page · raw message
Signature · 1 line
2.13.5
Arnaldo Carvalho de Melo
maintainerPATCH 2/13 perf syscalltbl: Support glob matching on syscall names
In reply to Arnaldo Carvalho de MeloFrom: Arnaldo Carvalho de Melo <[email protected]>
With two new methods, one to find the first match, returning its syscall id and its index in whatever internal database it keeps the syscall into, then one to find the next match, if any.
Implemented only on arches where we actually read the syscall table from the kernel sources, i.e. x86-64 for now, all the others use the libaudit method for which this returns -1, i.e. just stubs were added, with the actual implementation using whatever libaudit functions for matching that may be available.
--- tools/perf/util/syscalltbl.c | 33 +++++++++++++++++++++++++++++++++ tools/perf/util/syscalltbl.h | 3 +++ 2 files changed, 36 insertions(+)
tools/perf/util/syscalltbl.c +33 -0
@@ -19,6 +19,7 @@#ifdef HAVE_SYSCALL_TABLE #include <linux/compiler.h> #include <string.h> +#include "string2.h" #include "util.h" #if defined(__x86_64__)
@@ -105,6 +106,27 @@ int syscalltbl__id(struct syscalltbl *tbl, const char *name) return sc ? sc->id : -1; } +int syscalltbl__strglobmatch_next (struct syscalltbl *tbl,const char *syscall_glob,int *idx) +{ +int i; +struct syscall *syscalls = tbl->syscalls.entries; + +for (i = *idx +1 ; i < tbl->syscalls.nr_entries; ++i) { +if (strglobmatch (syscalls[i].name, syscall_glob)) { + *idx = i; +return syscalls[i].id; + } + } + +return -1 ; +} + +int syscalltbl__strglobmatch_first (struct syscalltbl *tbl,const char *syscall_glob,int *idx) +{ + *idx =-1 ; +return syscalltbl__strglobmatch_next (tbl, syscall_glob, idx); +} +#else /* HAVE_SYSCALL_TABLE */ #include <libaudit.h>
@@ -131,4 +153,15 @@ int syscalltbl__id(struct syscalltbl *tbl, const char *name) {return audit_name_to_syscall (name, tbl->audit_machine); } + +int syscalltbl__strglobmatch_next (struct syscalltbl *tbl__maybe_unused , +const char *syscall_glob__maybe_unused ,int *idx__maybe_unused ) +{ +return -1 ; +} + +int syscalltbl__strglobmatch_first (struct syscalltbl *tbl,const char *syscall_glob,int *idx) +{ +return syscalltbl__strglobmatch_next (tbl, syscall_glob, idx); +}#endif /* HAVE_SYSCALL_TABLE */
tools/perf/util/syscalltbl.h +3 -0
@@ -17,4 +17,7 @@ void syscalltbl__delete(struct syscalltbl *tbl);const char *syscalltbl__name (const struct syscalltbl *tbl,int id);int syscalltbl__id (struct syscalltbl *tbl,const char *name); +int syscalltbl__strglobmatch_first (struct syscalltbl *tbl,const char *syscall_glob,int *idx); +int syscalltbl__strglobmatch_next (struct syscalltbl *tbl,const char *syscall_glob,int *idx); +#endif /* __PERF_SYSCALLTBL_H */
Signature · 1 line
2.13.5
Arnaldo Carvalho de Melo
maintainerPATCH 3/13 perf trace: Support syscall name globbing
In reply to Arnaldo Carvalho de MeloFrom: Arnaldo Carvalho de Melo <[email protected]>
So now we can use:
# perf trace -e pkey_* 532.784 ( 0.006 ms): pkey/16018 pkey_alloc(init_val: DISABLE_WRITE) = -1 EINVAL Invalid argument 532.795 ( 0.004 ms): pkey/16018 pkey_mprotect(start: 0x7f380d0a6000, len: 4096, prot: READ|WRITE, pkey: -1) = 0 532.801 ( 0.002 ms): pkey/16018 pkey_free(pkey: -1 ) = -1 EINVAL Invalid argument ^C[root@jouet ~]#
Or '-e epoll*', '-e *msg*', etc.
Combining syscall names with perf events, tracepoints, etc, continues to be valid, i.e. this is possible:
# perf probe -L sys_nanosleep
<SyS_nanosleep@/home/acme/git/linux/kernel/time/hrtimer.c:0>
0 SYSCALL_DEFINE2(nanosleep, struct timespec __user *, rqtp,
struct timespec __user *, rmtp)
{
struct timespec64 tu; 5 if (get_timespec64(&tu, rqtp))
6 return -EFAULT;
if (!timespec64_valid(&tu))
9 return -EINVAL;
11 current->restart_block.nanosleep.type = rmtp ? TT_NATIVE : TT_NONE;
12 current->restart_block.nanosleep.rmtp = rmtp;
13 return hrtimer_nanosleep(&tu, HRTIMER_MODE_REL, CLOCK_MONOTONIC);
} # perf probe my_probe="sys_nanosleep:12 rmtp"
Added new event:
probe:my_probe (on sys_nanosleep:12 with rmtp)You can now use it in all perf tools, such as:
perf record -e probe:my_probe -aR sleep 1
#
# perf trace -e probe:my_probe/max-stack=5/,*sleep sleep 1
0.427 ( 0.003 ms): sleep/16690 nanosleep(rqtp: 0x7ffefc245090) ...
0.430 ( ): probe:my_probe:(ffffffffbd112923) rmtp=0)
sys_nanosleep ([kernel.kallsyms])
do_syscall_64 ([kernel.kallsyms])
return_from_SYSCALL_64 ([kernel.kallsyms])
__nanosleep_nocancel (/usr/lib64/libc-2.25.so)
0.427 (1000.208 ms): sleep/16690 ... [continued]: nanosleep()) = 0
#--- tools/perf/Documentation/perf-trace.txt | 2 +- tools/perf/builtin-trace.c | 39 +++++++++++++++++++++++++++++---- 2 files changed, 36 insertions(+), 5 deletions(-)
tools/perf/Documentation/perf-trace.txt +1 -1
@@ -37,7 +37,7 @@ OPTIONS --expr:: --event:: List of syscalls and other perf events (tracepoints, HW cache events, - etc) to show. + etc) to show. Globbing is supported, e.g.: "epoll_*", "*msg*", etc. See 'perf list' for a complete list of events. Prefixing with ! shows all syscalls but the ones specified. You may need to escape it.
tools/perf/builtin-trace.c +35 -4
@@ -1261,6 +1261,7 @@ static int trace__read_syscall_info(struct trace *trace, int id)static int trace__validate_ev_qualifier (struct trace *trace) {int err =0 , i; +size_t nr_allocated;struct str_node *pos; trace->ev_qualifier_ids.nr =strlist__nr_entries (trace->ev_qualifier);
@@ -1274,13 +1275,18 @@ static int trace__validate_ev_qualifier(struct trace *trace) goto out; } + nr_allocated = trace->ev_qualifier_ids.nr; i =0 ;strlist__for_each_entry (pos, trace->ev_qualifier) {const char *sc = pos->s; -int id =syscalltbl__id (trace->sctbl, sc); +int id =syscalltbl__id (trace->sctbl, sc), match_next =-1 ;if (id <0 ) { + id =syscalltbl__strglobmatch_first (trace->sctbl, sc, &match_next); +if (id >=0 ) + goto matches; +if (err ==0 ) {fputs ("Error:\tInvalid syscall " , trace->output); err = -EINVAL ;
@@ -1290,13 +1296,37 @@ static int trace__validate_ev_qualifier(struct trace *trace)fputs (sc, trace->output); } - +matches: trace->ev_qualifier_ids.entries[i++] = id; +if (match_next ==-1 ) +continue ; + +while (1 ) { + id =syscalltbl__strglobmatch_next (trace->sctbl, sc, &match_next); +if (id <0 ) +break ; +if (nr_allocated == trace->ev_qualifier_ids.nr) { +void *entries; + + nr_allocated +=8 ; + entries =realloc (trace->ev_qualifier_ids.entries, + nr_allocated *sizeof (trace->ev_qualifier_ids.entries[0 ])); +if (entries ==NULL ) { + err = -ENOMEM ; +fputs ("\nError:\t Not enough memory for parsing\n" , trace->output); + goto out_free; + } + trace->ev_qualifier_ids.entries = entries; + } + trace->ev_qualifier_ids.nr++; + trace->ev_qualifier_ids.entries[i++] = id; + } }if (err <0 ) {fputs ("\nHint:\ttry 'perf list syscalls:sys_enter_*'" "\nHint:\tand: 'man syscalls'\n" , trace->output); +out_free:zfree (&trace->ev_qualifier_ids.entries); trace->ev_qualifier_ids.nr =0 ; }
@@ -2814,7 +2844,7 @@ static int trace__parse_events_option(const struct option *opt, const char *str,struct trace *trace = (struct trace *)opt->value;const char *s = str;char *sep =NULL , *lists[2 ] = {NULL ,NULL , }; -int len =strlen (str) +1 , err =-1 , list; +int len =strlen (str) +1 , err =-1 , list, idx;char *strace_groups_dir =system_path (STRACE_GROUPS_DIR );char group_name[PATH_MAX ];
@@ -2831,7 +2861,8 @@ static int trace__parse_events_option(const struct option *opt, const char *str, *sep ='\0' ; list =0 ; -if (syscalltbl__id (trace->sctbl, s) >=0 ) { +if (syscalltbl__id (trace->sctbl, s) >=0 || +syscalltbl__strglobmatch_first (trace->sctbl, s, &idx) >=0 ) { list =1 ; }else {path__join (group_name,sizeof (group_name), strace_groups_dir, s);
Signature · 1 line
2.13.5
Arnaldo Carvalho de Melo
maintainerPATCH 4/13 perf test powerpc: Fix 'Object code reading' test
In reply to Arnaldo Carvalho de MeloFrom: Ravi Bangoria <[email protected]>
'Object code reading' test always fails on powerpc guest. Two reasons for the failure are:
1. When elf section is too big (size beyond 'unsigned int' max value). objdump fails to disassemble from such section. This was fixed with commit 0f6329bd7fc ("binutils/objdump: Fix disassemble for huge elf sections") in binutils.
2. When the sample is from hypervisor. Hypervisor symbols can not be resolved within guest and thus thread__find_addr_map() fails for such symbols. Fix this by ignoring hypervisor symbols in the test.
--- tools/perf/tests/code-reading.c | 5 +++++ 1 file changed, 5 insertions(+)
tools/perf/tests/code-reading.c +5 -0
@@ -237,6 +237,11 @@ static int read_object_code(u64 addr, size_t len, u8 cpumode,thread__find_addr_map (thread, cpumode,MAP__FUNCTION , addr, &al);if (!al.map || !al.map->dso) { +if (cpumode ==PERF_RECORD_MISC_HYPERVISOR ) { +pr_debug ("Hypervisor address can not be resolved - skipping\n" ); +return 0 ; + } +pr_debug ("thread__find_addr_map failed\n" );return -1 ; }
Signature · 1 line
2.13.5
Arnaldo Carvalho de Melo
maintainerPATCH 5/13 perf intel-pt: Fix syntax in documentation of config option
In reply to Arnaldo Carvalho de MeloFrom: Jack Henschel <[email protected]>
As specified in tools/perf/Documentation/perf-config.txt, perf configuration items must be in 'key = value' format, otherwise the following error message occurs:
$ perf record -e intel_pt//u -- ls
bad config file line 2 in ~/.perfconfig
$ cat .perfconfig
[intel-pt]
mispred-allChanging to assigning a value to the key 'mispred-all' fixes the issue:
$ perf record -e intel_pt//u -- ls
[ perf record: Woken up 1 times to write data ]
[ perf record: Capured and wrote 0.031 MB perf.data]
$ cat .perfconfig
[intel-pt]
mispred-all = true--- tools/perf/Documentation/intel-pt.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
tools/perf/Documentation/intel-pt.txt +1 -1
@@ -873,7 +873,7 @@ amended to take the number of elements as a parameter. $ cat ~/.perfconfig [intel-pt] - mispred-all + mispred-all = on $ perf record -e intel_pt//u ./sort 3000 Bubble sorting array of 3000 elements
Signature · 1 line
2.13.5
Arnaldo Carvalho de Melo
maintainerPATCH 6/13 perf vendor events powerpc: Remove duplicate events
In reply to Arnaldo Carvalho de MeloFrom: Sukadev Bhattiprolu <[email protected]>
Some POWER PMU event names have multiple/alternate event codes. These alternate event codes were listed in the POWER9 JSON files for reference.
But the perf tool does not seem to handle duplicates cleanly. 'perf list' shows such duplicate events only once, but 'perf stat' ends up counting the first event code twice, multiplexing if necessary and we end up with double the event counts.
Remove the duplicate event codes from the JSON files for now.
--- .../pmu-events/arch/powerpc/power9/frontend.json | 7 +- .../perf/pmu-events/arch/powerpc/power9/other.json | 120 --------------------- .../pmu-events/arch/powerpc/power9/pipeline.json | 7 +- tools/perf/pmu-events/arch/powerpc/power9/pmc.json | 7 +- 4 files changed, 3 insertions(+), 138 deletions(-)
tools/perf/pmu-events/arch/powerpc/power9/frontend.json +1 -6
@@ -80,11 +80,6 @@ "BriefDescription": "Load Missed L1, counted at execution time (can be greater than loads finished). LMQ merges are not included in this count. i.e. if a load instruction misses on an address that is already allocated on the LMQ, this event will not increment for that load). Note that this count is per slice, so if a load spans multiple slices this event will increment multiple times for a single load." }, {, - "EventCode": "0x400F0", - "EventName": "PM_LD_MISS_L1", - "BriefDescription": "Load Missed L1, counted at execution time (can be greater than loads finished). LMQ merges are not included in this count. i.e. if a load instruction misses on an address that is already allocated on the LMQ, this event will not increment for that load). Note that this count is per slice, so if a load spans multiple slices this event will increment multiple times for a single load." - }, - {, "EventCode": "0x2E01A", "EventName": "PM_CMPLU_STALL_LSU_FLUSH_NEXT", "BriefDescription": "Completion stall of one cycle because the LSU requested to flush the next iop in the sequence. It takes 1 cycle for the ISU to process this request before the LSU instruction is allowed to complete"
@@ -374,4 +369,4 @@ "EventName": "PM_IPTEG_FROM_L31_ECO_MOD", "BriefDescription": "A Page Table Entry was loaded into the TLB with Modified (M) data from another core's ECO L3 on the same chip due to a instruction side request" } -] +]
tools/perf/pmu-events/arch/powerpc/power9/other.json +0 -120
254 lines not on this page · raw message
tools/perf/pmu-events/arch/powerpc/power9/pipeline.json +1 -6
@@ -420,11 +420,6 @@ "BriefDescription": "Final Pump Scope (Group) ended up larger than Initial Pump Scope (Chip) for an instruction fetch" }, {, - "EventCode": "0x10016", - "EventName": "PM_DSLB_MISS", - "BriefDescription": "Data SLB Miss - Total of all segment sizes" - }, - {, "EventCode": "0xD0A8", "EventName": "PM_DSLB_MISS", "BriefDescription": "Data SLB Miss - Total of all segment sizes"
@@ -554,4 +549,4 @@ "EventName": "PM_MRK_DATA_FROM_L21_SHR_CYC", "BriefDescription": "Duration in cycles to reload with Shared (S) data from another core's L2 on the same chip due to a marked load" } -] +]
tools/perf/pmu-events/arch/powerpc/power9/pmc.json +1 -6
@@ -5,11 +5,6 @@ "BriefDescription": "Branches that are not strongly biased" }, {, - "EventCode": "0x40036", - "EventName": "PM_BR_2PATH", - "BriefDescription": "Branches that are not strongly biased" - }, - {, "EventCode": "0x40056", "EventName": "PM_MEM_LOC_THRESH_LSU_HIGH", "BriefDescription": "Local memory above threshold for LSU medium"
@@ -124,4 +119,4 @@ "EventName": "PM_1FLOP_CMPL", "BriefDescription": "one flop (fadd, fmul, fsub, fcmp, fsel, fabs, fnabs, fres, fsqrte, fneg) operation completed" } -] +]
Signature · 1 line
2.13.5
Re: [PATCH 06/13] perf vendor events powerpc: Remove duplicate events
Quoted 6 lines · Arnaldo Carvalho de Melo
From: Sukadev Bhattiprolu <[email protected]>
Some POWER PMU event names have multiple/alternate event codes. These alternate event codes were listed in the POWER9 JSON files for reference.
Quoted 6 lines
But the perf tool does not seem to handle duplicates cleanly. 'perf list' shows such duplicate events only once, but 'perf stat' ends up counting the first event code twice, multiplexing if necessary and we end up with double the event counts.
Remove the duplicate event codes from the JSON files for now.
It would be better to fix it in perf. I assume it wouldn't be that hard. Intel may get multiple versions of events at some point too, as events get renamed, but the old names stay around for compatibility.
-Andi
Arnaldo Carvalho de Melo
maintainerPATCH 7/13 perf tools: Support new sample type for physical address
In reply to Arnaldo Carvalho de MeloFrom: Kan Liang <[email protected]>
Support new sample type PERF_SAMPLE_PHYS_ADDR for physical address.
Add new option --phys-data to record sample physical address.
--- tools/include/uapi/linux/perf_event.h | 4 +++- tools/perf/Documentation/perf-record.txt | 5 ++++- tools/perf/builtin-record.c | 2 ++ tools/perf/perf.h | 1 + tools/perf/util/event.h | 1 + tools/perf/util/evsel.c | 19 ++++++++++++++++++- 6 files changed, 29 insertions(+), 3 deletions(-)
tools/include/uapi/linux/perf_event.h +3 -1
@@ -139,8 +139,9 @@ enum perf_event_sample_format {PERF_SAMPLE_IDENTIFIER =1U <<16 ,PERF_SAMPLE_TRANSACTION =1U <<17 ,PERF_SAMPLE_REGS_INTR =1U <<18 , +PERF_SAMPLE_PHYS_ADDR =1U <<19 , - PERF_SAMPLE_MAX = 1U << 19, /* non-ABI */ + PERF_SAMPLE_MAX = 1U << 20, /* non-ABI */ };/*
@@ -814,6 +815,7 @@ enum perf_event_type {* { u64 transaction; } && PERF_SAMPLE_TRANSACTION * { u64 abi; # enum perf_sample_regs_abi * u64 regs[weight(mask)]; } && PERF_SAMPLE_REGS_INTR +* { u64 phys_addr;} && PERF_SAMPLE_PHYS_ADDR * }; */ PERF_RECORD_SAMPLE = 9,
tools/perf/Documentation/perf-record.txt +4 -1
@@ -249,7 +249,10 @@ OPTIONS -d:: --data:: - Record the sample addresses. + Record the sample virtual addresses. + +--phys-data:: + Record the sample physical addresses. -T:: --timestamp::
tools/perf/builtin-record.c +2 -0
@@ -1604,6 +1604,8 @@ static struct option __record_options[] = {OPT_BOOLEAN ('s' ,"stat" , &record.opts.inherit_stat,"per thread counts" ),OPT_BOOLEAN ('d' ,"data" , &record.opts.sample_address,"Record the sample addresses" ), +OPT_BOOLEAN (0 ,"phys-data" , &record.opts.sample_phys_addr, +"Record the sample physical addresses" ),OPT_BOOLEAN (0 ,"sample-cpu" , &record.opts.sample_cpu,"Record the sample cpu" ), OPT_BOOLEAN_SET('T', "timestamp", &record.opts.sample_time, &record.opts.sample_time_set,
tools/perf/perf.h +1 -0
@@ -43,6 +43,7 @@ struct record_opts {bool no_samples;bool raw_samples;bool sample_address; +bool sample_phys_addr;bool sample_weight;bool sample_time;bool sample_time_set;
tools/perf/util/event.h +1 -0
@@ -200,6 +200,7 @@ struct perf_sample {u32 cpu;u32 raw_size;u64 data_src; +u64 phys_addr;u32 flags;u16 insn_len;u8 cpumode;
tools/perf/util/evsel.c +18 -1
@@ -955,6 +955,9 @@ void perf_evsel__config(struct perf_evsel *evsel, struct record_opts *opts,if (opts->sample_address)perf_evsel__set_sample_bit (evsel,DATA_SRC ); +if (opts->sample_phys_addr) +perf_evsel__set_sample_bit (evsel,PHYS_ADDR ); +if (opts->no_buffering) { attr->watermark =0 ; attr->wakeup_events =1 ;
@@ -1464,7 +1467,7 @@ static void __p_sample_type(char *buf, size_t size, u64 value)bit_name (PERIOD ),bit_name (STREAM_ID ),bit_name (RAW ),bit_name (BRANCH_STACK ),bit_name (REGS_USER ),bit_name (STACK_USER ),bit_name (IDENTIFIER ),bit_name (REGS_INTR ),bit_name (DATA_SRC ), -bit_name (WEIGHT ), +bit_name (WEIGHT ),bit_name (PHYS_ADDR ), { .name = NULL, } };#undef bit_name
@@ -2206,6 +2209,12 @@ int perf_evsel__parse_sample(struct perf_evsel *evsel, union perf_event *event, } } + data->phys_addr =0 ; +if (type &PERF_SAMPLE_PHYS_ADDR ) { + data->phys_addr = *array; + array++; + } +return 0 ; }
@@ -2311,6 +2320,9 @@ size_t perf_event__sample_event_size(const struct perf_sample *sample, u64 type, } } +if (type &PERF_SAMPLE_PHYS_ADDR ) + result +=sizeof (u64); +return result; }
@@ -2500,6 +2512,11 @@ int perf_event__synthesize_sample(union perf_event *event, u64 type, } } +if (type &PERF_SAMPLE_PHYS_ADDR ) { + *array = sample->phys_addr; + array++; + } +return 0 ; }
Signature · 1 line
2.13.5
Arnaldo Carvalho de Melo
maintainerPATCH 8/13 perf sort: Add sort option for physical address
In reply to Arnaldo Carvalho de MeloFrom: Kan Liang <[email protected]>
Add a new sort option "phys_daddr" for --mem-mode sort. With this option applied, perf can sort and report by sample's physical address.
--- tools/perf/Documentation/perf-report.txt | 1 + tools/perf/util/hist.c | 4 +++ tools/perf/util/hist.h | 1 + tools/perf/util/machine.c | 8 ++++-- tools/perf/util/session.c | 3 +++ tools/perf/util/sort.c | 42 ++++++++++++++++++++++++++++++++ tools/perf/util/sort.h | 1 + tools/perf/util/symbol.h | 1 + 8 files changed, 59 insertions(+), 2 deletions(-)
tools/perf/Documentation/perf-report.txt +1 -0
@@ -137,6 +137,7 @@ OPTIONS - mem: type of memory access for the data at the time of the sample - snoop: type of snoop (if any) for the data at the time of the sample - dcacheline: the cacheline the data address is on at the time of the sample + - phys_daddr: physical address of data being executed on at the time of sample And the default sort keys are changed to local_weight, mem, sym, dso, symbol_daddr, dso_daddr, snoop, tlb, locked, see '--mem-mode'.
tools/perf/util/hist.c +4 -0
@@ -167,6 +167,10 @@ void hists__calc_col_len(struct hists *hists, struct hist_entry *h) symlen = unresolved_col_width +4 +2 ;hists__set_unres_dso_col_len (hists,HISTC_MEM_DADDR_DSO ); } + +hists__new_col_len (hists,HISTC_MEM_PHYS_DADDR , + unresolved_col_width +4 +2 ); + }else { symlen = unresolved_col_width +4 +2 ;hists__new_col_len (hists,HISTC_MEM_DADDR_SYMBOL , symlen);
tools/perf/util/hist.h +1 -0
@@ -47,6 +47,7 @@ enum hist_column {HISTC_GLOBAL_WEIGHT ,HISTC_MEM_DADDR_SYMBOL ,HISTC_MEM_DADDR_DSO , +HISTC_MEM_PHYS_DADDR ,HISTC_MEM_LOCKED ,HISTC_MEM_TLB , HISTC_MEM_LVL,
tools/perf/util/machine.c +6 -2
@@ -1635,10 +1635,12 @@ static void ip__resolve_ams(struct thread *thread, ams->al_addr = al.addr; ams->sym = al.sym; ams->map = al.map; + ams->phys_addr =0 ; }static void ip__resolve_data (struct thread *thread, -u8 m,struct addr_map_symbol *ams,u64 addr) +u8 m,struct addr_map_symbol *ams, +u64 addr,u64 phys_addr) {struct addr_location al;
@@ -1658,6 +1660,7 @@ static void ip__resolve_data(struct thread *thread, ams->al_addr = al.addr; ams->sym = al.sym; ams->map = al.map; + ams->phys_addr = phys_addr; } struct mem_info *sample__resolve_mem(struct perf_sample *sample,
@@ -1669,7 +1672,8 @@ struct mem_info *sample__resolve_mem(struct perf_sample *sample,return NULL ;ip__resolve_ams (al->thread, &mi->iaddr, sample->ip); -ip__resolve_data (al->thread, al->cpumode, &mi->daddr, sample->addr); +ip__resolve_data (al->thread, al->cpumode, &mi->daddr, + sample->addr, sample->phys_addr); mi->data_src.val = sample->data_src;return mi;
tools/perf/util/session.c +3 -0
@@ -1120,6 +1120,9 @@ static void dump_sample(struct perf_evsel *evsel, union perf_event *event,if (sample_type &PERF_SAMPLE_DATA_SRC )printf (" . data_src: 0x%" PRIx64"\n" , sample->data_src); +if (sample_type &PERF_SAMPLE_PHYS_ADDR ) +printf (" .. phys_addr: 0x%" PRIx64"\n" , sample->phys_addr); +if (sample_type &PERF_SAMPLE_TRANSACTION )printf ("... transaction: %" PRIx64"\n" , sample->transaction);
tools/perf/util/sort.c +42 -0
54 lines not on this page · raw message
tools/perf/util/sort.h +1 -0
@@ -245,6 +245,7 @@ enum sort_type {SORT_MEM_SNOOP ,SORT_MEM_DCACHELINE ,SORT_MEM_IADDR_SYMBOL , + SORT_MEM_PHYS_DADDR, };/*
tools/perf/util/symbol.h +1 -0
@@ -186,6 +186,7 @@ struct addr_map_symbol {struct symbol *sym;u64 addr;u64 al_addr; +u64 phys_addr; };struct branch_info {
Signature · 1 line
2.13.5
Arnaldo Carvalho de Melo
maintainerPATCH 9/13 perf mem: Support physical address
In reply to Arnaldo Carvalho de MeloFrom: Kan Liang <[email protected]>
Add option phys-data in "perf mem" to record/report physical address. The default mem sort order for physical address is changed accordingly.
--- tools/perf/Documentation/perf-mem.txt | 4 ++ tools/perf/builtin-mem.c | 97 +++++++++++++++++++++++++---------- 2 files changed, 75 insertions(+), 26 deletions(-)
tools/perf/Documentation/perf-mem.txt +4 -0
@@ -59,6 +59,10 @@ OPTIONS --ldload:: Specify desired latency for loads event. +-p:: +--phys-data:: + Record/Report sample physical addresses + SEE ALSO -------- linkperf:perf-record[1], linkperf:perf-report[1]
tools/perf/builtin-mem.c +71 -26
135 lines not on this page · raw message
Signature · 1 line
2.13.5
Arnaldo Carvalho de Melo
maintainerPATCH 10/13 perf script: Support physical address
In reply to Arnaldo Carvalho de MeloFrom: Kan Liang <[email protected]>
Display the physical address at the tail if it is available.
--- tools/perf/Documentation/perf-script.txt | 2 +- tools/perf/builtin-script.c | 15 +++++++++++++-- 2 files changed, 14 insertions(+), 3 deletions(-)
tools/perf/Documentation/perf-script.txt +1 -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, brstack, brstacksym, flags, bpf-output, brstackinsn, brstackoff, - callindent, insn, insnlen, synth. + callindent, insn, insnlen, synth, phys_addr. 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
tools/perf/builtin-script.c +13 -2
@@ -87,6 +87,7 @@ enum perf_output_field {PERF_OUTPUT_BRSTACKINSN =1U <<23 ,PERF_OUTPUT_BRSTACKOFF =1U <<24 ,PERF_OUTPUT_SYNTH =1U <<25 , + PERF_OUTPUT_PHYS_ADDR = 1U << 26, }; struct output_option {
@@ -119,6 +120,7 @@ struct output_option { {.str = "brstackinsn", .field = PERF_OUTPUT_BRSTACKINSN}, {.str = "brstackoff", .field = PERF_OUTPUT_BRSTACKOFF}, {.str = "synth", .field = PERF_OUTPUT_SYNTH}, + {.str = "phys_addr", .field = PERF_OUTPUT_PHYS_ADDR}, }; enum {
@@ -175,7 +177,8 @@ static struct {PERF_OUTPUT_EVNAME |PERF_OUTPUT_IP |PERF_OUTPUT_SYM |PERF_OUTPUT_DSO |PERF_OUTPUT_PERIOD |PERF_OUTPUT_ADDR | - PERF_OUTPUT_DATA_SRC | PERF_OUTPUT_WEIGHT, +PERF_OUTPUT_DATA_SRC |PERF_OUTPUT_WEIGHT | + PERF_OUTPUT_PHYS_ADDR, .invalid_fields = PERF_OUTPUT_TRACE | PERF_OUTPUT_BPF_OUTPUT, },
@@ -382,6 +385,11 @@ static int perf_evsel__check_attr(struct perf_evsel *evsel, PERF_OUTPUT_IREGS))return -EINVAL ; +if (PRINT_FIELD (PHYS_ADDR ) && +perf_evsel__check_stype (evsel,PERF_SAMPLE_PHYS_ADDR ,"PHYS_ADDR" , +PERF_OUTPUT_PHYS_ADDR )) +return -EINVAL ; +return 0 ; }
@@ -1446,6 +1454,9 @@ static void process_event(struct perf_script *script,if (perf_evsel__is_bpf_output (evsel) &&PRINT_FIELD (BPF_OUTPUT ))print_sample_bpf_output (sample);print_insn (sample, attr, thread, machine); + +if (PRINT_FIELD (PHYS_ADDR )) +printf ("%16" PRIx64, sample->phys_addr);printf ("\n" ); }
@@ -2729,7 +2740,7 @@ int cmd_script(int argc, const char **argv) "Valid types: hw,sw,trace,raw,synth. " "Fields: comm,tid,pid,time,cpu,event,trace,ip,sym,dso," "addr,symoff,period,iregs,brstack,brstacksym,flags," - "bpf-output,callindent,insn,insnlen,brstackinsn,synth", + "bpf-output,callindent,insn,insnlen,brstackinsn,synth,phys_addr", parse_output_fields),OPT_BOOLEAN ('a' ,"all-cpus" , &system_wide, "system-wide collection from all CPUs"),
Signature · 1 line
2.13.5
Arnaldo Carvalho de Melo
maintainerPATCH 11/13 perf test: Add test case for PERF_SAMPLE_PHYS_ADDR
In reply to Arnaldo Carvalho de MeloFrom: Kan Liang <[email protected]>
Extend sample-parsing test cases to support new sample type PERF_SAMPLE_PHYS_ADDR.
--- tools/perf/tests/sample-parsing.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-)
tools/perf/tests/sample-parsing.c +5 -1
@@ -141,6 +141,9 @@ static bool samples_same(const struct perf_sample *s1, } } +if (type &PERF_SAMPLE_PHYS_ADDR ) +COMP (phys_addr); +return true; }
@@ -206,6 +209,7 @@ static int do_test(u64 sample_type, u64 sample_regs, u64 read_format) .mask = sample_regs, .regs = regs, }, + .phys_addr = 113, };struct sample_read_value values[] = {{1 ,5 }, {9 ,3 }, {2 ,7 }, {6 ,4 },};struct perf_sample sample_out;
@@ -305,7 +309,7 @@ int test__sample_parsing(struct test *test __maybe_unused, int subtest __maybe_u* were added. Please actually update the test rather than just change * the condition below. */ -if (PERF_SAMPLE_MAX >PERF_SAMPLE_REGS_INTR <<1 ) { +if (PERF_SAMPLE_MAX >PERF_SAMPLE_PHYS_ADDR <<1 ) {pr_debug ("sample format has changed, some new PERF_SAMPLE_ bit was introduced - test needs updating\n" );return -1 ; }
Signature · 1 line
2.13.5
Arnaldo Carvalho de Melo
maintainerPATCH 12/13 perf stat: Only auto-merge events that are PMU aliases
In reply to Arnaldo Carvalho de MeloFrom: Arnaldo Carvalho de Melo <[email protected]>
Peter reported that when he explicitely asked for multiple events with the same name on the command line it got coalesced into just one line, i.e.:
# perf stat -e cycles -e cycles -e cycles usleep 1
Performance counter stats for 'usleep 1':
3,269,652 cycles
0.000884123 seconds time elapsed#
And while there is the --no-merges option to disable that auto-merging, this is a blunt change in behaviour for such explicit request, so change the code so that this auto merging is done only when handling the multi PMU aliases with the same name that introduced this coalescing, restoring the previous behaviour for the explicit case:
# perf stat -e cycles -e cycles -e cycles usleep 1
Performance counter stats for 'usleep 1':
1,472,837 cycles
1,472,837 cycles
1,472,837 cycles0.001764870 seconds time elapsed
#
--- tools/perf/builtin-stat.c | 2 +- tools/perf/util/evsel.h | 1 + tools/perf/util/parse-events.c | 24 ++++++++++++++++-------- 3 files changed, 18 insertions(+), 9 deletions(-)
tools/perf/builtin-stat.c +1 -1
@@ -1257,7 +1257,7 @@ static bool collect_data(struct perf_evsel *counter,if (counter->merged_stat)return false;cb (counter, data, true); -if (!no_merge) +if (!no_merge && counter->auto_merge_stats)collect_all_aliases (counter, cb, data);return true; }
tools/perf/util/evsel.h +1 -0
@@ -131,6 +131,7 @@ struct perf_evsel {bool cmdline_group_boundary;struct list_head config_terms;int bpf_fd; +bool auto_merge_stats;bool merged_stat;const char * metric_expr;const char * metric_name;
tools/perf/util/parse-events.c +16 -8
@@ -310,7 +310,7 @@ static struct perf_evsel * __add_event(struct list_head *list, int *idx, struct perf_event_attr *attr, char *name, struct cpu_map *cpus, - struct list_head *config_terms) + struct list_head *config_terms, bool auto_merge_stats) { struct perf_evsel *evsel;
@@ -324,6 +324,7 @@ __add_event(struct list_head *list, int *idx, evsel->cpus =cpu_map__get (cpus); evsel->own_cpus =cpu_map__get (cpus); evsel->system_wide = !!cpus; + evsel->auto_merge_stats = auto_merge_stats;if (name) evsel->name =strdup (name);
@@ -339,7 +340,7 @@ static int add_event(struct list_head *list, int *idx, struct perf_event_attr *attr, char *name, struct list_head *config_terms) { - return __add_event(list, idx, attr, name, NULL, config_terms) ? 0 : -ENOMEM; + return __add_event(list, idx, attr, name, NULL, config_terms, false) ? 0 : -ENOMEM; }static int parse_aliases (char *str,const char *names[][PERF_EVSEL__MAX_ALIASES ],int size)
@@ -1209,9 +1210,9 @@ int parse_events_add_numeric(struct parse_events_state *parse_state, get_config_name(head_config), &config_terms); } -int parse_events_add_pmu (struct parse_events_state *parse_state, +static int __parse_events_add_pmu (struct parse_events_state *parse_state,struct list_head *list,char *name, -struct list_head *head_config) +struct list_head *head_config,bool auto_merge_stats) {struct perf_event_attr attr;struct perf_pmu_info info;
@@ -1232,7 +1233,7 @@ int parse_events_add_pmu(struct parse_events_state *parse_state,if (!head_config) { attr.type = pmu->type; - evsel =__add_event (list, &parse_state->idx, &attr,NULL , pmu->cpus,NULL ); + evsel =__add_event (list, &parse_state->idx, &attr,NULL , pmu->cpus,NULL , auto_merge_stats);return evsel ?0 : -ENOMEM ; }
@@ -1254,7 +1255,7 @@ int parse_events_add_pmu(struct parse_events_state *parse_state, evsel =__add_event (list, &parse_state->idx, &attr,get_config_name (head_config), pmu->cpus, - &config_terms); + &config_terms, auto_merge_stats);if (evsel) { evsel->unit = info.unit; evsel->scale = info.scale;
@@ -1267,6 +1268,13 @@ int parse_events_add_pmu(struct parse_events_state *parse_state,return evsel ?0 : -ENOMEM ; } +int parse_events_add_pmu (struct parse_events_state *parse_state, +struct list_head *list,char *name, +struct list_head *head_config) +{ +return __parse_events_add_pmu (parse_state, list, name, head_config, false); +} +int parse_events_multi_pmu_add (struct parse_events_state *parse_state,char *str,struct list_head **listp) {
@@ -1296,8 +1304,8 @@ int parse_events_multi_pmu_add(struct parse_events_state *parse_state,return -1 ;list_add_tail (&term->list, head); -if (!parse_events_add_pmu (parse_state, list, - pmu->name, head)) { +if (!__parse_events_add_pmu (parse_state, list, + pmu->name, head, true)) {pr_debug ("%s -> %s/%s/\n" , str, pmu->name, alias->str); ok++;
Signature · 1 line
2.13.5
Arnaldo Carvalho de Melo
maintainerPATCH 13/13 perf annotate browser: Help for cycling thru hottest instructions with TAB/shift+TAB
In reply to Arnaldo Carvalho de MeloFrom: Arnaldo Carvalho de Melo <[email protected]>
The popup help accessed via 'h' wasn't mentioning about TAB and shift-TAB, just about 'H', which goes to the hottest line, while the former two are the hotkeys for actually cycling thru the hottest lines.
--- tools/perf/ui/browsers/annotate.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
tools/perf/ui/browsers/annotate.c +2 -1
@@ -829,7 +829,8 @@ static int annotate_browser__run(struct annotate_browser *browser,"q/ESC/CTRL+C Exit\n\n" "ENTER Go to target\n" "ESC Exit\n" -"H Cycle thru hottest instructions\n" +"H Go to hottest instruction\n" +"TAB/shift+TAB Cycle thru hottest instructions\n" "j Toggle showing jump to target arrows\n" "J Toggle showing number of jump sources on targets\n" "n Search next string\n"
Signature · 1 line
2.13.5
Quoted 110 lines · Arnaldo Carvalho de Melo
Hi Ingo,
Please consider pulling,
- Arnaldo
Test results at the end of this message, as usual.
The following changes since commit
1b2f76d77a277bb70d38ad0991ed7f16bbc115a9:Merge tag 'perf-core-for-mingo-4.14-20170829' of
git://git.kernel.org/pub/scm/linux/kernel/git/acme/linuxinto perf/core (2017-08-29 23:13:56 +0200)are available in the git repository at:
git://git.kernel.org/pub/scm/linux/kernel/git/acme/linux.gittags/perf-core-for-mingo-4.14-20170901for you to fetch changes up to
eba9fac017617e685d648339e29a1453a30cb065:perf annotate browser: Help for cycling thru hottest instructions with TAB/shift+TAB (2017-09-01 14:55:40 -0300)
----------------------------------------------------------------
perf/core improvements and fixes:- Support syscall name glob matching in 'perf trace' (Arnaldo Carvalho de Melo)
e.g.:
# perf trace -e pkey_* 32.784 (0.006 ms): pkey/16018 pkey_alloc(init_val: DISABLE_WRITE) = -1 EINVAL Invalid argument 32.795 (0.004 ms): pkey/16018 pkey_mprotect(start: 0x7f380d0a6000, len: 4096, prot: READ|WRITE, pkey: -1) = 0 32.801 (0.002 ms): pkey/16018 pkey_free(pkey: -1 ) = -1 EINVAL Invalid argument ^C#- Do not auto merge counts for explicitely specified events in 'perf stat' (Arnaldo Carvalho de Melo)
- Fix syntax in documentation of .perfconfig intel-pt option (Jack Henschel)
- Calculate the average cycles of iterations for loops detected by the branch history support in 'perf report' (Jin Yao)
- Support
PERF_SAMPLE_PHYS_ADDRas a sort key "phys_daddr" in the 'script', 'mem', 'top' and 'report'. Also add a test entry for it in 'perf test' (Kan Liang)- Fix 'Object code reading' 'perf test' entry in PowerPC (Ravi Bangoria)
- Remove some duplicate Power9 duplicate vendor events (described in JSON files) (Sukadev Bhattiprolu)
- Add help entry in the TUI annotate browser about cycling thru hottest instructions with TAB/shift+TAB (Arnaldo Carvalho de Melo)
Signed-off-by Arnaldo Carvalho de Melo <[email protected]>----------------------------------------------------------------
Arnaldo Carvalho de Melo (4):
perf syscalltbl: Support glob matching on syscall names
perf trace: Support syscall name globbing
perf stat: Only auto-merge events that are PMU aliases
perf annotate browser: Help for cycling thru hottest instructions with TAB/shift+TABJack Henschel (1):
perf intel-pt: Fix syntax in documentation of config optionJin Yao (1):
perf report: Calculate the average cycles of iterationsKan Liang (5):
perf tools: Support new sample type for physical address perf sort: Add sort option for physical address perf mem: Support physical address
perf script: Support physical address
perf test: Add test case forPERF_SAMPLE_PHYS_ADDRRavi Bangoria (1):
perf test powerpc: Fix 'Object code reading' testSukadev Bhattiprolu (1):
perf vendor events powerpc: Remove duplicate eventstools/include/uapi/linux/perf_event.h | 4 +- tools/perf/Documentation/intel-pt.txt | 2 +- tools/perf/Documentation/perf-mem.txt | 4 + tools/perf/Documentation/perf-record.txt | 5 +- tools/perf/Documentation/perf-report.txt | 1 + tools/perf/Documentation/perf-script.txt | 2 +- tools/perf/Documentation/perf-trace.txt | 2 +- tools/perf/builtin-mem.c | 97 ++++++++++++----- tools/perf/builtin-record.c | 2 + tools/perf/builtin-script.c | 15 ++- tools/perf/builtin-stat.c | 2 +- tools/perf/builtin-trace.c | 39 ++++++- tools/perf/perf.h | 1 + .../pmu-events/arch/powerpc/power9/frontend.json | 7 +- .../perf/pmu-events/arch/powerpc/power9/other.json | 120 --------------------- .../pmu-events/arch/powerpc/power9/pipeline.json | 7 +- tools/perf/pmu-events/arch/powerpc/power9/pmc.json | 7 +- tools/perf/tests/code-reading.c | 5 + tools/perf/tests/sample-parsing.c | 6 +- tools/perf/ui/browsers/annotate.c | 3 +- tools/perf/ui/browsers/hists.c | 8 +- tools/perf/ui/stdio/hist.c | 10 +- tools/perf/util/callchain.c | 49 ++++----- tools/perf/util/callchain.h | 9 +- tools/perf/util/event.h | 1 + tools/perf/util/evsel.c | 19 +++- tools/perf/util/evsel.h | 1 + tools/perf/util/hist.c | 4 + tools/perf/util/hist.h | 1 + tools/perf/util/machine.c | 96 ++++++++++-------
Quoted 8 lines
tools/perf/util/parse-events.c | 24 +++-- tools/perf/util/session.c | 3 + tools/perf/util/sort.c | 42 ++++++++ tools/perf/util/sort.h | 1 + tools/perf/util/symbol.h | 1 + tools/perf/util/syscalltbl.c | 33 ++++++ tools/perf/util/syscalltbl.h | 3 + 37 files changed, 368 insertions(+), 268 deletions(-)
Pulled, thanks a lot Arnaldo!
Ingo