perf/core improvements and fixes
Subsystems (4)
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 2471cece40d61b0035360338569d338f9dea6099:
Merge tag 'perf-core-for-mingo-20161125' of git://git.kernel.org/pub/scm/linux/kernel/git/acme/linux into perf/core (2016-11-25 18:12:41 +0100)
are available in the git repository at:
git://git.kernel.org/pub/scm/linux/kernel/git/acme/linux.git tags/perf-core-for-mingo-20161201
for you to fetch changes up to 0fcb1da4aba6e6c7b32de5e0948b740b31ad822d:
perf annotate: AArch64 support (2016-12-01 13:03:19 -0300)
----------------------------------------------------------------
perf/core improvements and fixes:
New features:
- Support AArch64 in the 'annotate' code, native/local and cross-arch/remote (Kim Phillips)
- Allow considering just events in a given time interval, via the '--time start.s.ms,end.s.ms' command line, added to 'perf kmem', 'perf report', 'perf sched timehist' and 'perf script' (David Ahern)
- Add option to stop printing a callchain at one of a given group of symbol names (David Ahern)
- Handle cpu migration events in 'perf sched timehist' (David Ahern)
- Track memory freed in 'perf kmem stat' (David Ahern)
Infrastructure:
- Initial support (and perf test entry) for tooling hooks, starting with 'record_start' and 'record_end', that will have as its initial user the eBPF infrastructure, where perf_ prefixed functions will be JITed and run when such hooks are called (Wang Nan)
- Remove redundant "test" and similar strings from 'perf test' descriptions (Arnaldo Carvalho de Melo)
- libbpf assorted improvements (Wang Nan)
----------------------------------------------------------------
Arnaldo Carvalho de Melo (3):
perf ui helpline: Provide a printf variant
perf annotate: Show invalid jump offset in error message perf test: Remove "test" and similar strings from test descriptions
David Ahern (10):
perf sched timehist: Handle cpu migration events
perf trace: Update tid/pid filtering option to leverage symbol_conf perf kmem stat: Track memory freed
perf script: Add option to stop printing callchain
perf tools: Add time-based utility functions
perf tools: Move parse_nsec_time to time-utils.c
perf script: Add option to specify time window of interest perf sched timehist: Add option to specify time window of interest perf kmem: Add option to specify time window of interest perf report: Add option to specify time window of interest
Kim Phillips (2):
perf annotate: Use arch->objdump.comment_char in dec__parse() perf annotate: AArch64 support
Wang Nan (4):
tools lib bpf: Add missing BPF functions
tools lib bpf: Add private field for bpf_object tools lib bpf: Retrive bpf_map through offset of bpf_map_def perf tools: Introduce perf hooks
tools/lib/bpf/bpf.c | 56 ++++++++++ tools/lib/bpf/bpf.h | 7 ++ tools/lib/bpf/libbpf.c | 35 ++++++ tools/lib/bpf/libbpf.h | 13 +++ tools/perf/Documentation/perf-kmem.txt | 7 ++ tools/perf/Documentation/perf-report.txt | 7 ++ tools/perf/Documentation/perf-sched.txt | 12 +++ tools/perf/Documentation/perf-script.txt | 10 ++ tools/perf/arch/arm64/annotate/instructions.c | 62 +++++++++++ tools/perf/arch/x86/tests/arch-tests.c | 10 +- tools/perf/builtin-kmem.c | 36 ++++++- tools/perf/builtin-record.c | 11 ++ tools/perf/builtin-report.c | 14 ++- tools/perf/builtin-sched.c | 148 ++++++++++++++++++++++++-- tools/perf/builtin-script.c | 17 ++- tools/perf/builtin-trace.c | 49 ++------- tools/perf/tests/Build | 1 + tools/perf/tests/bpf.c | 6 +- tools/perf/tests/builtin-test.c | 96 +++++++++-------- tools/perf/tests/llvm.c | 8 +- tools/perf/tests/perf-hooks.c | 44 ++++++++ tools/perf/tests/tests.h | 1 + tools/perf/ui/browsers/annotate.c | 6 +- tools/perf/ui/helpline.c | 10 ++ tools/perf/ui/helpline.h | 1 + tools/perf/util/Build | 3 + tools/perf/util/annotate.c | 7 +- tools/perf/util/evsel_fprintf.c | 8 ++ tools/perf/util/perf-hooks-list.h | 3 + tools/perf/util/perf-hooks.c | 84 +++++++++++++++ tools/perf/util/perf-hooks.h | 37 +++++++ tools/perf/util/symbol.c | 8 ++ tools/perf/util/symbol.h | 6 +- tools/perf/util/time-utils.c | 119 +++++++++++++++++++++ tools/perf/util/time-utils.h | 14 +++ tools/perf/util/util.c | 33 ------ tools/perf/util/util.h | 2 - 37 files changed, 842 insertions(+), 149 deletions(-) create mode 100644 tools/perf/arch/arm64/annotate/instructions.c create mode 100644 tools/perf/tests/perf-hooks.c create mode 100644 tools/perf/util/perf-hooks-list.h create mode 100644 tools/perf/util/perf-hooks.c create mode 100644 tools/perf/util/perf-hooks.h create mode 100644 tools/perf/util/time-utils.c create mode 100644 tools/perf/util/time-utils.h
# uname -a
Linux jouet 4.8.8-300.fc25.x86_64 #1 SMP Tue Nov 15 18:10:06 UTC 2016 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: Parse event definition strings : Ok
6: PERF_RECORD_* events & perf_sample fields : Ok
7: Parse perf pmu format : Ok
8: DSO data read : Ok
9: DSO data cache : Ok
10: DSO data reopen : Ok
11: Roundtrip evsel->name : Ok
12: Parse sched tracepoints fields : Ok
13: syscalls:sys_enter_openat event fields : Ok
14: Setup struct perf_event_attr : Ok
15: Match and link multiple hists : Ok
16: 'import perf' in python : Ok
17: Breakpoint overflow signal handler : Ok
18: Breakpoint overflow sampling : Ok
19: Number of exit events of a simple workload : Ok
20: Software clock events period values : Ok
21: Object code reading : Ok
22: Sample parsing : Ok
23: Use a dummy software event to keep tracking: Ok
24: Parse with no sample_id_all bit set : Ok
25: Filter hist entries : Ok
26: Lookup mmap thread : Ok
27: Share thread mg : Ok
28: Sort output of hist entries : Ok
29: Cumulate child hist entries : Ok
30: Track with sched_switch : Ok
31: Filter fds with revents mask in a fdarray : Ok
32: Add fd to a fdarray, making it autogrow : Ok
33: kmod_path__parse : Ok
34: Thread map : Ok
35: LLVM search and compile :
35.1: Basic BPF llvm compile : Ok
35.2: kbuild searching : Ok
35.3: Compile source for BPF prologue generation: Ok
35.4: Compile source for BPF relocation : Ok
36: Session topology : Ok
37: BPF filter :
37.1: Basic BPF filtering : Ok
37.2: BPF prologue generation : Ok
37.3: BPF relocation checker : Ok
38: Synthesize thread map : Ok
39: Synthesize cpu map : Ok
40: Synthesize stat config : Ok
41: Synthesize stat : Ok
42: Synthesize stat round : Ok
43: Synthesize attr update : Ok
44: Event times : Ok
45: Read backward ring buffer : Ok
46: Print cpu map : Ok
47: Probe SDT events : Ok
48: is_printable_array : Ok
49: Print bitmap : Ok
50: perf hooks : Ok
51: x86 rdpmc : Ok
52: Convert perf time to TSC : Ok
53: DWARF unwind : Ok
54: x86 instruction decoder - new instructions : Ok
55: Intel cqm nmi context read : Skip
#
# uname -a
Linux zoo 4.7.3-200.fc24.x86_64 #1 SMP Wed Sep 7 17:31:21 UTC 2016 x86_64 x86_64 x86_64 GNU/Linux
# dm
1 alpine:3.4: Ok
2 android-ndk:r12b-arm: Ok
3 archlinux:latest: Ok
4 centos:5: Ok
5 centos:6: Ok
6 centos:7: Ok
7 debian:7: Ok
8 debian:8: Ok
9 debian:experimental: Ok
10 fedora:20: Ok
11 fedora:21: Ok
12 fedora:22: Ok
13 fedora:23: Ok
14 fedora:24: Ok
15 fedora:24-x-ARC-uClibc: Ok
16 fedora:rawhide: Ok
17 mageia:5: Ok
18 opensuse:13.2: Ok
19 opensuse:42.1: Ok
20 opensuse:tumbleweed: Ok
21 ubuntu:12.04.5: Ok
22 ubuntu:14.04: Ok
23 ubuntu:14.04.4: Ok
24 ubuntu:15.10: Ok
25 ubuntu:16.04: Ok
26 ubuntu:16.04-x-arm: Ok
27 ubuntu:16.04-x-arm64: Ok
28 ubuntu:16.04-x-powerpc: Ok
29 ubuntu:16.04-x-powerpc64: Ok
30 ubuntu:16.04-x-powerpc64el: Ok
31 ubuntu:16.04-x-s390: Ok
32 ubuntu:16.10: Ok
#
$ grep PRETTY_NAME /etc/os-release
PRETTY_NAME="Fedora 25 (Workstation Edition)"
$
$ perf stat make -C tools/perf build-test
make: Entering directory '/home/acme/git/linux/tools/perf'
- tarpkg: ./tests/perf-targz-src-pkg .
make_no_slang_O: make NO_SLANG=1
make_util_map_o_O: make util/map.o
make_static_O: make LDFLAGS=-static
make_no_libdw_dwarf_unwind_O: make NO_LIBDW_DWARF_UNWIND=1
make_perf_o_O: make perf.o
make_no_libunwind_O: make NO_LIBUNWIND=1
make_no_libelf_O: make NO_LIBELF=1
make_util_pmu_bison_o_O: make util/pmu-bison.o
make_no_backtrace_O: make NO_BACKTRACE=1
make_no_ui_O: make NO_NEWT=1 NO_SLANG=1 NO_GTK2=1
make_no_demangle_O: make NO_DEMANGLE=1
make_no_libperl_O: make NO_LIBPERL=1
make_tags_O: make tags
make_no_scripts_O: make NO_LIBPYTHON=1 NO_LIBPERL=1
make_install_prefix_slash_O: make install prefix=/tmp/krava/
make_no_auxtrace_O: make NO_AUXTRACE=1
make_no_libnuma_O: make NO_LIBNUMA=1
make_install_bin_O: make install-bin
make_no_newt_O: make NO_NEWT=1
make_pure_O: make
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_clean_all_O: make clean all
make_no_gtk2_O: make NO_GTK2=1
make_no_libbionic_O: make NO_LIBBIONIC=1
make_install_prefix_O: make install prefix=/tmp/krava
make_no_libbpf_O: make NO_LIBBPF=1
make_no_libaudit_O: make NO_LIBAUDIT=1
make_with_babeltrace_O: make LIBBABELTRACE=1
make_no_libpython_O: make NO_LIBPYTHON=1
make_help_O: make help
make_doc_O: make doc
make_debug_O: make DEBUG=1
make_install_O: make install
OK
make: Leaving directory '/home/acme/git/linux/tools/perf'
$ Arnaldo Carvalho de Melo
maintainerPATCH 1/19 perf ui helpline: Provide a printf variant
From: Arnaldo Carvalho de Melo <[email protected]>
To print some values, like in the annotation code with invalid jump offsets.
--- tools/perf/ui/helpline.c | 10 ++++++++++ tools/perf/ui/helpline.h | 1 + 2 files changed, 11 insertions(+)
tools/perf/ui/helpline.c +10 -0
@@ -72,3 +72,13 @@ int ui_helpline__vshow(const char *fmt, va_list ap) {return helpline_fns->show (fmt, ap); } + +void ui_helpline__printf (const char *fmt, ...) +{ +va_list ap; + +ui_helpline__pop (); +va_start (ap, fmt); +ui_helpline__vpush (fmt, ap); +va_end (ap); +}
tools/perf/ui/helpline.h +1 -0
@@ -21,6 +21,7 @@ void ui_helpline__push(const char *msg);void ui_helpline__vpush (const char *fmt,va_list ap);void ui_helpline__fpush (const char *fmt, ...);void ui_helpline__puts (const char *msg); +void ui_helpline__printf (const char *fmt, ...);int ui_helpline__vshow (const char *fmt,va_list ap);extern char ui_helpline__current[512 ];
Signature · 1 line
2.9.3
Arnaldo Carvalho de Melo
maintainerPATCH 2/19 perf annotate: Show invalid jump offset in error message
In reply to Arnaldo Carvalho de MeloFrom: Arnaldo Carvalho de Melo <[email protected]>
To help in debugging when the wrong offset is being used, like in:
│13d98: ↓ jne 13dd1 <lzma_lzma_preset@@XZ_5.0+0x28e1>
That is the full line from objdump, and it seems what should be used is 13dd1, not 28e1.
--- tools/perf/ui/browsers/annotate.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-)
tools/perf/ui/browsers/annotate.c +4 -2
@@ -543,14 +543,16 @@ struct disasm_line *annotate_browser__find_offset(struct annotate_browser *browsstatic bool annotate_browser__jump (struct annotate_browser *browser) {struct disasm_line *dl = browser->selection; +u64 offset;s64 idx;if (!ins__is_jump (&dl->ins))return false; - dl =annotate_browser__find_offset (browser, dl->ops.target.offset, &idx); + offset = dl->ops.target.offset; + dl =annotate_browser__find_offset (browser, offset, &idx);if (dl ==NULL ) { -ui_helpline__puts ("Invalid jump offset" ); +ui_helpline__printf ("Invalid jump offset: %" PRIx64, offset);return true; }
Signature · 1 line
2.9.3
Arnaldo Carvalho de Melo
maintainerPATCH 3/19 perf sched timehist: Handle cpu migration events
In reply to Arnaldo Carvalho de MeloFrom: David Ahern <[email protected]>
Add handlers for sched:sched_migrate_task event. Total number of migrations is added to summary display and -M/--migrations can be used to show migration events.
--- tools/perf/Documentation/perf-sched.txt | 4 ++ tools/perf/builtin-sched.c | 97 ++++++++++++++++++++++++++++++++- 2 files changed, 99 insertions(+), 2 deletions(-)
tools/perf/Documentation/perf-sched.txt +4 -0
@@ -128,6 +128,10 @@ OPTIONS for 'perf sched timehist' --wakeups:: Show wakeup events. +-M:: +--migrations:: + Show migration events. + SEE ALSO -------- linkperf:perf-record[1]
tools/perf/builtin-sched.c +95 -2
147 lines not on this page · raw message
Signature · 1 line
2.9.3
Arnaldo Carvalho de Melo
maintainerPATCH 4/19 perf trace: Update tid/pid filtering option to leverage symbol_conf
In reply to Arnaldo Carvalho de MeloFrom: David Ahern <[email protected]>
Leverage pid/tid filtering done by symbol_conf hooks.
--- tools/perf/builtin-trace.c | 49 +++++++++------------------------------------- 1 file changed, 9 insertions(+), 40 deletions(-)
tools/perf/builtin-trace.c +9 -40
@@ -74,8 +74,6 @@ struct trace {size_t nr;int *entries; } ev_qualifier_ids; -struct intlist *tid_list; -struct intlist *pid_list;struct {size_t nr;pid_t *entries;
@@ -1890,18 +1888,6 @@ static int trace__pgfault(struct trace *trace,return err; } -static bool skip_sample (struct trace *trace,struct perf_sample *sample) -{ -if ((trace->pid_list &&intlist__find (trace->pid_list, sample->pid)) || - (trace->tid_list &&intlist__find (trace->tid_list, sample->tid))) -return false; - -if (trace->pid_list || trace->tid_list) -return true; - -return false; -} -static void trace__set_base_time (struct trace *trace,struct perf_evsel *evsel,struct perf_sample *sample)
@@ -1926,11 +1912,13 @@ static int trace__process_sample(struct perf_tool *tool, struct machine *machine __maybe_unused) { struct trace *trace = container_of(tool, struct trace, tool); +struct thread *thread;int err =0 ;tracepoint_handler handler = evsel->handler; -if (skip_sample (trace, sample)) + thread =machine__findnew_thread (trace->host, sample->pid, sample->tid); +if (thread &&thread__is_filtered (thread))return 0 ;trace__set_base_time (trace, evsel, sample);
@@ -1943,27 +1931,6 @@ static int trace__process_sample(struct perf_tool *tool,return err; } -static int parse_target_str (struct trace *trace) -{ -if (trace->opts.target.pid) { - trace->pid_list =intlist__new (trace->opts.target.pid); -if (trace->pid_list ==NULL ) { -pr_err ("Error parsing process id string\n" ); -return -EINVAL ; - } - } - -if (trace->opts.target.tid) { - trace->tid_list =intlist__new (trace->opts.target.tid); -if (trace->tid_list ==NULL ) { -pr_err ("Error parsing thread id string\n" ); -return -EINVAL ; - } - } - -return 0 ; -} -static int trace__record (struct trace *trace,int argc,const char **argv) {unsigned int rec_argc, i, j;
@@ -2460,6 +2427,12 @@ static int trace__replay(struct trace *trace)if (session ==NULL )return -1 ; +if (trace->opts.target.pid) + symbol_conf.pid_list_str =strdup (trace->opts.target.pid); + +if (trace->opts.target.tid) + symbol_conf.tid_list_str =strdup (trace->opts.target.tid); +if (symbol__init (&session->header.env) <0 ) goto out;
@@ -2503,10 +2476,6 @@ static int trace__replay(struct trace *trace) evsel->handler = trace__pgfault; } - err =parse_target_str (trace); -if (err !=0 ) - goto out; -setup_pager (); err =perf_session__process_events (session);
Signature · 1 line
2.9.3
Arnaldo Carvalho de Melo
maintainerPATCH 5/19 tools lib bpf: Add missing BPF functions
In reply to Arnaldo Carvalho de MeloFrom: Wang Nan <[email protected]>
Add more BPF map operations to libbpf. Also add bpf_obj_{pin,get}(). They can be used on not only BPF maps but also BPF programs.
--- tools/lib/bpf/bpf.c | 56 +++++++++++++++++++++++++++++++++++++++++++++++++++++ tools/lib/bpf/bpf.h | 7 +++++++ 2 files changed, 63 insertions(+)
tools/lib/bpf/bpf.c +56 -0
@@ -110,3 +110,59 @@ int bpf_map_update_elem(int fd, void *key, void *value,return sys_bpf (BPF_MAP_UPDATE_ELEM , &attr,sizeof (attr)); } + +int bpf_map_lookup_elem (int fd,void *key,void *value) +{ +union bpf_attr attr; + +bzero (&attr,sizeof (attr)); + attr.map_fd = fd; + attr.key =ptr_to_u64 (key); + attr.value =ptr_to_u64 (value); + +return sys_bpf (BPF_MAP_LOOKUP_ELEM , &attr,sizeof (attr)); +} + +int bpf_map_delete_elem (int fd,void *key) +{ +union bpf_attr attr; + +bzero (&attr,sizeof (attr)); + attr.map_fd = fd; + attr.key =ptr_to_u64 (key); + +return sys_bpf (BPF_MAP_DELETE_ELEM , &attr,sizeof (attr)); +} + +int bpf_map_get_next_key (int fd,void *key,void *next_key) +{ +union bpf_attr attr; + +bzero (&attr,sizeof (attr)); + attr.map_fd = fd; + attr.key =ptr_to_u64 (key); + attr.next_key =ptr_to_u64 (next_key); + +return sys_bpf (BPF_MAP_GET_NEXT_KEY , &attr,sizeof (attr)); +} + +int bpf_obj_pin (int fd,const char *pathname) +{ +union bpf_attr attr; + +bzero (&attr,sizeof (attr)); + attr.pathname =ptr_to_u64 ((void *)pathname); + attr.bpf_fd = fd; + +return sys_bpf (BPF_OBJ_PIN , &attr,sizeof (attr)); +} + +int bpf_obj_get (const char *pathname) +{ +union bpf_attr attr; + +bzero (&attr,sizeof (attr)); + attr.pathname =ptr_to_u64 ((void *)pathname); + +return sys_bpf (BPF_OBJ_GET , &attr,sizeof (attr)); +}
tools/lib/bpf/bpf.h +7 -0
@@ -35,4 +35,11 @@ int bpf_load_program(enum bpf_prog_type type, struct bpf_insn *insns,int bpf_map_update_elem (int fd,void *key,void *value,u64 flags); + +int bpf_map_lookup_elem (int fd,void *key,void *value); +int bpf_map_delete_elem (int fd,void *key); +int bpf_map_get_next_key (int fd,void *key,void *next_key); +int bpf_obj_pin (int fd,const char *pathname); +int bpf_obj_get (const char *pathname); +#endif
Signature · 1 line
2.9.3
Arnaldo Carvalho de Melo
maintainerPATCH 6/19 tools lib bpf: Add private field for bpf_object
In reply to Arnaldo Carvalho de MeloFrom: Wang Nan <[email protected]>
Similar to other classes defined in libbpf.h (map and program), allow 'object' class has its own private data.
--- tools/lib/bpf/libbpf.c | 23 +++++++++++++++++++++++ tools/lib/bpf/libbpf.h | 5 +++++ 2 files changed, 28 insertions(+)
tools/lib/bpf/libbpf.c +23 -0
@@ -229,6 +229,10 @@ struct bpf_object {* all objects. */ struct list_head list; + +void *priv; +bpf_object_clear_priv_t clear_priv; +char path[]; };#define obj_elf_valid (o) ((o)->efile.elf)
@@ -1229,6 +1233,9 @@ void bpf_object__close(struct bpf_object *obj)if (!obj)return ; +if (obj->clear_priv) + obj->clear_priv (obj, obj->priv); +bpf_object__elf_finish (obj);bpf_object__unload (obj);
@@ -1282,6 +1289,22 @@ unsigned int bpf_object__kversion(struct bpf_object *obj)return obj ? obj->kern_version :0 ; } +int bpf_object__set_priv (struct bpf_object *obj,void *priv, +bpf_object_clear_priv_t clear_priv) +{ +if (obj->priv && obj->clear_priv) + obj->clear_priv (obj, obj->priv); + + obj->priv = priv; + obj->clear_priv = clear_priv; +return 0 ; +} + +void *bpf_object__priv (struct bpf_object *obj) +{ +return obj ? obj->priv :ERR_PTR (-EINVAL ); +} +struct bpf_program *bpf_program__next (struct bpf_program *prev,struct bpf_object *obj) {
tools/lib/bpf/libbpf.h +5 -0
@@ -79,6 +79,11 @@ struct bpf_object *bpf_object__next(struct bpf_object *prev); (pos) !=NULL ; \ (pos) = (tmp), (tmp) = bpf_object__next(tmp)) +typedef void (*bpf_object_clear_priv_t )(struct bpf_object *,void *); +int bpf_object__set_priv (struct bpf_object *obj,void *priv, +bpf_object_clear_priv_t clear_priv); +void *bpf_object__priv (struct bpf_object *prog); +/* Accessors of bpf_program. */ struct bpf_program ; struct bpf_program *bpf_program__next(struct bpf_program *prog,
Signature · 1 line
2.9.3
Arnaldo Carvalho de Melo
maintainerPATCH 7/19 tools lib bpf: Retrive bpf_map through offset of bpf_map_def
In reply to Arnaldo Carvalho de MeloFrom: Wang Nan <[email protected]>
Add a new API to libbpf, caller is able to get bpf_map through the offset of bpf_map_def to 'maps' section.
The API will be used to help jitted perf hook code find fd of a map.
--- tools/lib/bpf/libbpf.c | 12 ++++++++++++ tools/lib/bpf/libbpf.h | 8 ++++++++ 2 files changed, 20 insertions(+)
tools/lib/bpf/libbpf.c +12 -0
@@ -1524,3 +1524,15 @@ bpf_object__find_map_by_name(struct bpf_object *obj, const char *name) }return NULL ; } + +struct bpf_map * +bpf_object__find_map_by_offset (struct bpf_object *obj,size_t offset) +{ +int i; + +for (i =0 ; i < obj->nr_maps; i++) { +if (obj->maps[i].offset == offset) +return &obj->maps[i]; + } +return ERR_PTR (-ENOENT ); +}
tools/lib/bpf/libbpf.h +8 -0
@@ -24,6 +24,7 @@#include <stdio.h> #include <stdbool.h> #include <linux/err.h> +#include <sys/types.h> // for size_t enum libbpf_errno { __LIBBPF_ERRNO__START =4000 ,
@@ -200,6 +201,13 @@ struct bpf_map;struct bpf_map *bpf_object__find_map_by_name (struct bpf_object *obj,const char *name); +/* +* Get bpf_map through the offset of corresponding struct bpf_map_def +* in the bpf object file. +*/ +struct bpf_map * +bpf_object__find_map_by_offset (struct bpf_object *obj,size_t offset); +struct bpf_map *bpf_map__next (struct bpf_map *map,struct bpf_object *obj);#define bpf_map__for_each (pos, obj) \
Signature · 1 line
2.9.3
Arnaldo Carvalho de Melo
maintainerPATCH 8/19 perf tools: Introduce perf hooks
In reply to Arnaldo Carvalho de MeloFrom: Wang Nan <[email protected]>
Perf hooks allow hooking user code at perf events. They can be used for manipulation of BPF maps, taking snapshot and reporting results. In this patch two perf hook points are introduced: record_start and record_end.
To avoid buggy user actions, a SIGSEGV signal handler is introduced into 'perf record'. It turns off perf hook if it causes a segfault and report an error to help debugging.
A test case for perf hook is introduced.
Test result:
$ ./buildperf/perf test -v hook 50: Test perf hooks : --- start --- test child forked, pid 10311 SIGSEGV is observed as expected, try to recover. Fatal error (SEGFAULT) in perf hook 'test' test child finished with 0 ---- end ---- Test perf hooks: Ok
--- tools/perf/builtin-record.c | 11 +++++ tools/perf/tests/Build | 1 + tools/perf/tests/builtin-test.c | 4 ++ tools/perf/tests/perf-hooks.c | 44 ++++++++++++++++++++ tools/perf/tests/tests.h | 1 + tools/perf/util/Build | 2 + tools/perf/util/perf-hooks-list.h | 3 ++ tools/perf/util/perf-hooks.c | 84 +++++++++++++++++++++++++++++++++++++++ tools/perf/util/perf-hooks.h | 37 +++++++++++++++++ 9 files changed, 187 insertions(+) create mode 100644 tools/perf/tests/perf-hooks.c create mode 100644 tools/perf/util/perf-hooks-list.h create mode 100644 tools/perf/util/perf-hooks.c create mode 100644 tools/perf/util/perf-hooks.h
tools/perf/builtin-record.c +11 -0
@@ -37,6 +37,7 @@#include "util/llvm-utils.h" #include "util/bpf-loader.h" #include "util/trigger.h" +#include "util/perf-hooks.h" #include "asm/bug.h" #include <unistd.h>
@@ -206,6 +207,12 @@ static void sig_handler(int sig) done =1 ; } +static void sigsegv_handler (int sig) +{ +perf_hooks__recover (); +sighandler_dump_stack (sig); +} +static void record__sig_exit (void ) {if (signr ==-1 )
@@ -833,6 +840,7 @@ static int __cmd_record(struct record *rec, int argc, const char **argv)signal (SIGCHLD , sig_handler);signal (SIGINT , sig_handler);signal (SIGTERM , sig_handler); +signal (SIGSEGV , sigsegv_handler);if (rec->opts.auxtrace_snapshot_mode || rec->switch_output) {signal (SIGUSR2 , snapshot_sig_handler);
@@ -970,6 +978,7 @@ static int __cmd_record(struct record *rec, int argc, const char **argv)trigger_ready (&auxtrace_snapshot_trigger);trigger_ready (&switch_output_trigger); +perf_hooks__invoke_record_start ();for (;;) {unsigned long long hits = rec->samples;
@@ -1114,6 +1123,8 @@ static int __cmd_record(struct record *rec, int argc, const char **argv) } } +perf_hooks__invoke_record_end (); +if (!err && !quiet) {char samples[128 ]; const char *postfix = rec->timestamp_filename ?
tools/perf/tests/Build +1 -0
@@ -42,6 +42,7 @@ perf-y += backward-ring-buffer.o perf-y += sdt.o perf-y += is_printable_array.o perf-y += bitmap.o +perf-y += perf-hooks.o $(OUTPUT)tests/llvm-src-base.c: tests/bpf-script-example.c tests/Build $(call rule_mkdir)
tools/perf/tests/builtin-test.c +4 -0
@@ -230,6 +230,10 @@ static struct test generic_tests[] = { .func = test__bitmap_print, }, { + .desc = "Test perf hooks", + .func = test__perf_hooks, + }, + { .func = NULL, }, };
tools/perf/tests/perf-hooks.c new file +44 -0
44 lines not on this page · raw message
tools/perf/tests/tests.h +1 -0
@@ -91,6 +91,7 @@ int test__cpu_map_print(int subtest);int test__sdt_event (int subtest);int test__is_printable_array (int subtest);int test__bitmap_print (int subtest); +int test__perf_hooks (int subtest);#if defined(__arm__) || defined(__aarch64__)#ifdef HAVE_DWARF_UNWIND_SUPPORT
tools/perf/util/Build +2 -0
@@ -123,6 +123,8 @@ libperf-$(CONFIG_LIBELF) += genelf.o libperf-$(CONFIG_DWARF) += genelf_debug.o endif +libperf-y += perf-hooks.o + CFLAGS_config.o += -DETC_PERFCONFIG="BUILD_STR($(ETC_PERFCONFIG_SQ))" # avoid compiler warnings in 32-bit mode CFLAGS_genelf_debug.o += -Wno-packed
tools/perf/util/perf-hooks-list.h new file +3 -0
@@ -0,0 +1,3 @@ +PERF_HOOK(record_start) +PERF_HOOK(record_end) +PERF_HOOK(test)
tools/perf/util/perf-hooks.c new file +84 -0
84 lines not on this page · raw message
tools/perf/util/perf-hooks.h new file +37 -0
@@ -0,0 +1,37 @@ +#ifndef PERF_UTIL_PERF_HOOKS_H +#define PERF_UTIL_PERF_HOOKS_H + +#ifdef __cplusplus +extern "C" { +#endif + +typedef void (*perf_hook_func_t )(void ); +struct perf_hook_desc { +const char *const hook_name; +perf_hook_func_t *const p_hook_func; +}; + +extern void perf_hooks__invoke (const struct perf_hook_desc *); +extern void perf_hooks__recover (void ); + +#define PERF_HOOK (name) \ +extern struct perf_hook_desc __perf_hook_desc_##name; \ +static inline void perf_hooks__invoke_##name(void) \ +{ \ + perf_hooks__invoke(&__perf_hook_desc_##name); \ +} + +#include "perf-hooks-list.h" +#undef PERF_HOOK + +extern int +perf_hooks__set_hook (const char *hook_name, +perf_hook_func_t hook_func); + +extern perf_hook_func_t +perf_hooks__get_hook (const char *hook_name); + +#ifdef __cplusplus +} +#endif +#endif
Signature · 1 line
2.9.3
Arnaldo Carvalho de Melo
maintainerPATCH 9/19 perf test: Remove "test" and similar strings from test descriptions
In reply to Arnaldo Carvalho de MeloFrom: Arnaldo Carvalho de Melo <[email protected]>
Having "test" in almost all test descriptions is redundant, simplify it removing and rewriting tests with such descriptions.
End result:
# 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: Parse event definition strings : Ok 6: PERF_RECORD_* events & perf_sample fields : Ok 7: Parse perf pmu format : Ok 8: DSO data read : Ok 9: DSO data cache : Ok 10: DSO data reopen : Ok 11: Roundtrip evsel->name : Ok 12: Parse sched tracepoints fields : Ok 13: syscalls:sys_enter_openat event fields : Ok 14: Setup struct perf_event_attr : Ok 15: Match and link multiple hists : Ok 16: 'import perf' in python : Ok 17: Breakpoint overflow signal handler : Ok 18: Breakpoint overflow sampling : Ok 19: Number of exit events of a simple workload : Ok 20: Software clock events period values : Ok 21: Object code reading : Ok 22: Sample parsing : Ok 23: Use a dummy software event to keep tracking: Ok 24: Parse with no sample_id_all bit set : Ok 25: Filter hist entries : Ok 26: Lookup mmap thread : Ok 27: Share thread mg : Ok 28: Sort output of hist entries : Ok 29: Cumulate child hist entries : Ok 30: Track with sched_switch : Ok 31: Filter fds with revents mask in a fdarray : Ok 32: Add fd to a fdarray, making it autogrow : Ok 33: kmod_path__parse : Ok 34: Thread map : Ok 35: LLVM search and compile : 35.1: Basic BPF llvm compile : Ok 35.2: kbuild searching : Ok 35.3: Compile source for BPF prologue generation: Ok 35.4: Compile source for BPF relocation : Ok 36: Session topology : Ok 37: BPF filter : 37.1: Basic BPF filtering : Ok 37.2: BPF prologue generation : Ok 37.3: BPF relocation checker : Ok 38: Synthesize thread map : Ok 39: Synthesize cpu map : Ok 40: Synthesize stat config : Ok 41: Synthesize stat : Ok 42: Synthesize stat round : Ok 43: Synthesize attr update : Ok 44: Event times : Ok 45: Read backward ring buffer : Ok 46: Print cpu map : Ok 47: Probe SDT events : Ok 48: is_printable_array : Ok 49: Print bitmap : Ok 50: perf hooks : Ok 51: x86 rdpmc : Ok 52: Convert perf time to TSC : Ok 53: DWARF unwind : Ok 54: x86 instruction decoder - new instructions : Ok 55: Intel cqm nmi context read : Skip #
--- tools/perf/arch/x86/tests/arch-tests.c | 10 ++-- tools/perf/tests/bpf.c | 6 +-- tools/perf/tests/builtin-test.c | 94 +++++++++++++++++----------------- tools/perf/tests/llvm.c | 8 +-- 4 files changed, 59 insertions(+), 59 deletions(-)
tools/perf/arch/x86/tests/arch-tests.c +5 -5
@@ -4,27 +4,27 @@struct test arch_tests[] = { { - .desc ="x86 rdpmc test" , + .desc ="x86 rdpmc" , .func = test__rdpmc, }, { - .desc ="Test converting perf time to TSC" , + .desc ="Convert perf time to TSC" , .func = test__perf_time_to_tsc, }, #ifdef HAVE_DWARF_UNWIND_SUPPORT { - .desc ="Test dwarf unwind" , + .desc ="DWARF unwind" , .func = test__dwarf_unwind, }, #endif #ifdef HAVE_AUXTRACE_SUPPORT { - .desc ="Test x86 instruction decoder - new instructions" , + .desc ="x86 instruction decoder - new instructions" , .func = test__insn_x86, }, #endif { - .desc ="Test intel cqm nmi context read" , + .desc ="Intel cqm nmi context read" , .func = test__intel_cqm_count_nmi_context, }, {
tools/perf/tests/bpf.c +3 -3
@@ -57,7 +57,7 @@ static struct { } bpf_testcase_table[] = { {LLVM_TESTCASE_BASE , -"Test basic BPF filtering" , +"Basic BPF filtering" ,"[basic_bpf_test]" ,"fix 'perf test LLVM' first" , "load bpf object failed",
@@ -67,7 +67,7 @@ static struct {#ifdef HAVE_BPF_PROLOGUE {LLVM_TESTCASE_BPF_PROLOGUE , -"Test BPF prologue generation" , +"BPF prologue generation" ,"[bpf_prologue_test]" ,"fix kbuild first" , "check your vmlinux setting?",
@@ -77,7 +77,7 @@ static struct {#endif {LLVM_TESTCASE_BPF_RELOCATION , -"Test BPF relocation checker" , +"BPF relocation checker" ,"[bpf_relocation_test]" ,"fix 'perf test LLVM' first" , "libbpf error when dealing with relocation",
tools/perf/tests/builtin-test.c +47 -47
247 lines not on this page · raw message
tools/perf/tests/llvm.c +4 -4
@@ -34,19 +34,19 @@ static struct { } bpf_source_table[__LLVM_TESTCASE_MAX] = { [LLVM_TESTCASE_BASE] = { .source = test_llvm__bpf_base_prog, - .desc = "Basic BPF llvm compiling test", + .desc = "Basic BPF llvm compile", }, [LLVM_TESTCASE_KBUILD] = { .source = test_llvm__bpf_test_kbuild_prog, - .desc = "Test kbuild searching", + .desc = "kbuild searching", }, [LLVM_TESTCASE_BPF_PROLOGUE] = { .source = test_llvm__bpf_test_prologue_prog, - .desc = "Compile source for BPF prologue generation test", + .desc = "Compile source for BPF prologue generation", }, [LLVM_TESTCASE_BPF_RELOCATION] = { .source = test_llvm__bpf_test_relocation, - .desc = "Compile source for BPF relocation test", + .desc = "Compile source for BPF relocation", .should_load_fail = true, }, };
Signature · 1 line
2.9.3
Arnaldo Carvalho de Melo
maintainerPATCH 10/19 perf kmem stat: Track memory freed
In reply to Arnaldo Carvalho de MeloFrom: David Ahern <[email protected]>
Track freed memory as well as allocations and show the net in the summary.
Committer notes:
Testing it:
# perf kmem record usleep 1 [ perf record: Woken up 0 times to write data ] [ perf record: Captured and wrote 1.626 MB perf.data (4208 samples) ] [root@jouet ~]# perf kmem stat --slab
SUMMARY (SLAB allocator)
========================
Total bytes requested: 234,011
Total bytes allocated: 234,504
Total bytes freed: 213,328 <------
Net total bytes allocated: 21,176
Total bytes wasted on internal fragmentation: 493 Internal fragmentation: 0.210231%
Cross CPU allocations: 4/1,963
#
--- tools/perf/builtin-kmem.c | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-)
tools/perf/builtin-kmem.c +11 -1
@@ -49,6 +49,7 @@ struct alloc_stat {u64 ptr;u64 bytes_req;u64 bytes_alloc; +u64 last_alloc;u32 hit;u32 pingpong;
@@ -62,7 +63,7 @@ static struct rb_root root_alloc_sorted;static struct rb_root root_caller_stat;static struct rb_root root_caller_sorted; -static unsigned long total_requested, total_allocated; +static unsigned long total_requested, total_allocated, total_freed;static unsigned long nr_allocs, nr_cross_allocs; static int insert_alloc_stat(unsigned long call_site, unsigned long ptr,
@@ -105,6 +106,8 @@ static int insert_alloc_stat(unsigned long call_site, unsigned long ptr, } data->call_site = call_site; data->alloc_cpu = cpu; + data->last_alloc = bytes_alloc; +return 0 ; }
@@ -223,6 +226,8 @@ static int perf_evsel__process_free_event(struct perf_evsel *evsel,if (!s_alloc)return 0 ; + total_freed += s_alloc->last_alloc; +if ((short )sample->cpu != s_alloc->alloc_cpu) { s_alloc->pingpong++;
@@ -1128,6 +1133,11 @@ static void print_slab_summary(void)printf ("\n========================\n" );printf ("Total bytes requested: %'lu\n" , total_requested);printf ("Total bytes allocated: %'lu\n" , total_allocated); +printf ("Total bytes freed: %'lu\n" , total_freed); +if (total_allocated > total_freed) { +printf ("Net total bytes allocated: %'lu\n" , + total_allocated - total_freed); + }printf ("Total bytes wasted on internal fragmentation: %'lu\n" , total_allocated - total_requested); printf("Internal fragmentation: %f%%\n",
Signature · 1 line
2.9.3
Arnaldo Carvalho de Melo
maintainerPATCH 11/19 perf script: Add option to stop printing callchain
In reply to Arnaldo Carvalho de MeloFrom: David Ahern <[email protected]>
Allow user to specify list of symbols which cause the dump of callchains to stop at that symbol.
Committer notes:
Testing it:
# perf record -ag usleep 1
[ perf record: Woken up 1 times to write data ]
[ perf record: Captured and wrote 1.177 MB perf.data (33 samples) ]
#
# # Without it:
#
# perf script
swapper 0 [000] 9693.370039: 1 cycles:ppp:
2072ad x86_pmu_enable (/usr/lib/debug/lib/modules/4.8.8-300.fc25.x86_64/vmlinux)
3a29d7 perf_pmu_enable.part.90 (/usr/lib/debug/lib/modules/4.8.8-300.fc25.x86_64/vmlinux)
3a713a ctx_resched (/usr/lib/debug/lib/modules/4.8.8-300.fc25.x86_64/vmlinux)
3a76c1 __perf_event_enable (/usr/lib/debug/lib/modules/4.8.8-300.fc25.x86_64/vmlinux)
3a0390 event_function (/usr/lib/debug/lib/modules/4.8.8-300.fc25.x86_64/vmlinux)
3a1cff remote_function (/usr/lib/debug/lib/modules/4.8.8-300.fc25.x86_64/vmlinux)
326978 flush_smp_call_function_queue (/usr/lib/debug/lib/modules/4.8.8-300.fc25.x86_64/vmlinux)
327413 generic_smp_call_function_single_interrupt (/usr/lib/debug/lib/modules/4.8.8-300.fc25.x86_64/vmlinux)
249b37 smp_call_function_single_interrupt (/usr/lib/debug/lib/modules/4.8.8-300.fc25.x86_64/vmlinux)
a04b2c call_function_single_interrupt (/usr/lib/debug/lib/modules/4.8.8-300.fc25.x86_64/vmlinux)
889427 cpuidle_enter (/usr/lib/debug/lib/modules/4.8.8-300.fc25.x86_64/vmlinux)
2e534a call_cpuidle (/usr/lib/debug/lib/modules/4.8.8-300.fc25.x86_64/vmlinux)
2e5730 cpu_startup_entry (/usr/lib/debug/lib/modules/4.8.8-300.fc25.x86_64/vmlinux)
9f5167 rest_init (/usr/lib/debug/lib/modules/4.8.8-300.fc25.x86_64/vmlinux)
137ffeb start_kernel ([kernel.vmlinux].init.text)
137f2ca x86_64_start_reservations ([kernel.vmlinux].init.text)
137f419 x86_64_start_kernel ([kernel.vmlinux].init.text)swapper 0 [000] 9693.370044: 1 cycles:ppp:
20ca1b intel_pmu_handle_irq (/usr/lib/debug/lib/modules/4.8.8-300.fc25.x86_64/vmlinux)
205b0c perf_event_nmi_handler (/usr/lib/debug/lib/modules/4.8.8-300.fc25.x86_64/vmlinux)
22a14a nmi_handle (/usr/lib/debug/lib/modules/4.8.8-300.fc25.x86_64/vmlinux)
22a6b3 default_do_nmi (/usr/lib/debug/lib/modules/4.8.8-300.fc25.x86_64/vmlinux)
22a83c do_nmi (/usr/lib/debug/lib/modules/4.8.8-300.fc25.x86_64/vmlinux)
a03fb1 end_repeat_nmi (/usr/lib/debug/lib/modules/4.8.8-300.fc25.x86_64/vmlinux)
3a29d7 perf_pmu_enable.part.90 (/usr/lib/debug/lib/modules/4.8.8-300.fc25.x86_64/vmlinux)
3a713a ctx_resched (/usr/lib/debug/lib/modules/4.8.8-300.fc25.x86_64/vmlinux)
3a76c1 __perf_event_enable (/usr/lib/debug/lib/modules/4.8.8-300.fc25.x86_64/vmlinux)
3a0390 event_function (/usr/lib/debug/lib/modules/4.8.8-300.fc25.x86_64/vmlinux)
3a1cff remote_function (/usr/lib/debug/lib/modules/4.8.8-300.fc25.x86_64/vmlinux)
326978 flush_smp_call_function_queue (/usr/lib/debug/lib/modules/4.8.8-300.fc25.x86_64/vmlinux)
327413 generic_smp_call_function_single_interrupt (/usr/lib/debug/lib/modules/4.8.8-300.fc25.x86_64/vmlinux)
249b37 smp_call_function_single_interrupt (/usr/lib/debug/lib/modules/4.8.8-300.fc25.x86_64/vmlinux)
a04b2c call_function_single_interrupt (/usr/lib/debug/lib/modules/4.8.8-300.fc25.x86_64/vmlinux)
889427 cpuidle_enter (/usr/lib/debug/lib/modules/4.8.8-300.fc25.x86_64/vmlinux)
2e534a call_cpuidle (/usr/lib/debug/lib/modules/4.8.8-300.fc25.x86_64/vmlinux)
2e5730 cpu_startup_entry (/usr/lib/debug/lib/modules/4.8.8-300.fc25.x86_64/vmlinux)
9f5167 rest_init (/usr/lib/debug/lib/modules/4.8.8-300.fc25.x86_64/vmlinux)
137ffeb start_kernel ([kernel.vmlinux].init.text)
137f2ca x86_64_start_reservations ([kernel.vmlinux].init.text)
#
# # Using it to see just what are the calls from the 'remote_function' function:
#
# perf script --stop-bt remote_function
swapper 0 [000] 9693.370039: 1 cycles:ppp:
2072ad x86_pmu_enable (/usr/lib/debug/lib/modules/4.8.8-300.fc25.x86_64/vmlinux)
3a29d7 perf_pmu_enable.part.90 (/usr/lib/debug/lib/modules/4.8.8-300.fc25.x86_64/vmlinux)
3a713a ctx_resched (/usr/lib/debug/lib/modules/4.8.8-300.fc25.x86_64/vmlinux)
3a76c1 __perf_event_enable (/usr/lib/debug/lib/modules/4.8.8-300.fc25.x86_64/vmlinux)
3a0390 event_function (/usr/lib/debug/lib/modules/4.8.8-300.fc25.x86_64/vmlinux)
3a1cff remote_function (/usr/lib/debug/lib/modules/4.8.8-300.fc25.x86_64/vmlinux)swapper 0 [000] 9693.370044: 1 cycles:ppp:
20ca1b intel_pmu_handle_irq (/usr/lib/debug/lib/modules/4.8.8-300.fc25.x86_64/vmlinux)
205b0c perf_event_nmi_handler (/usr/lib/debug/lib/modules/4.8.8-300.fc25.x86_64/vmlinux)
22a14a nmi_handle (/usr/lib/debug/lib/modules/4.8.8-300.fc25.x86_64/vmlinux)
22a6b3 default_do_nmi (/usr/lib/debug/lib/modules/4.8.8-300.fc25.x86_64/vmlinux)
22a83c do_nmi (/usr/lib/debug/lib/modules/4.8.8-300.fc25.x86_64/vmlinux)
a03fb1 end_repeat_nmi (/usr/lib/debug/lib/modules/4.8.8-300.fc25.x86_64/vmlinux)
3a29d7 perf_pmu_enable.part.90 (/usr/lib/debug/lib/modules/4.8.8-300.fc25.x86_64/vmlinux)
3a713a ctx_resched (/usr/lib/debug/lib/modules/4.8.8-300.fc25.x86_64/vmlinux)
3a76c1 __perf_event_enable (/usr/lib/debug/lib/modules/4.8.8-300.fc25.x86_64/vmlinux)
3a0390 event_function (/usr/lib/debug/lib/modules/4.8.8-300.fc25.x86_64/vmlinux)
3a1cff remote_function (/usr/lib/debug/lib/modules/4.8.8-300.fc25.x86_64/vmlinux)--- tools/perf/Documentation/perf-script.txt | 3 +++ tools/perf/builtin-script.c | 2 ++ tools/perf/util/evsel_fprintf.c | 8 ++++++++ tools/perf/util/symbol.c | 8 ++++++++ tools/perf/util/symbol.h | 6 ++++-- 5 files changed, 25 insertions(+), 2 deletions(-)
tools/perf/Documentation/perf-script.txt +3 -0
@@ -212,6 +212,9 @@ OPTIONS --hide-call-graph:: When printing symbols do not display call chain. +--stop-bt:: + Stop display of callgraph at these symbols + -C:: --cpu:: Only report samples for the list of CPUs provided. Multiple CPUs can be provided as a comma-separated list with no space: 0,1. Ranges of
tools/perf/builtin-script.c +2 -0
@@ -2151,6 +2151,8 @@ int cmd_script(int argc, const char **argv, const char *prefix __maybe_unused) "system-wide collection from all CPUs"),OPT_STRING ('S' ,"symbols" , &symbol_conf.sym_list_str,"symbol[,symbol...]" ,"only consider these symbols" ), +OPT_STRING (0 ,"stop-bt" , &symbol_conf.bt_stop_list_str,"symbol[,symbol...]" , +"Stop display of callgraph at these symbols" ),OPT_STRING ('C' ,"cpu" , &cpu_list,"cpu" ,"list of cpus to profile" ),OPT_STRING ('c' ,"comms" , &symbol_conf.comm_list_str,"comm[,comm...]" , "only display events for these comms"),
tools/perf/util/evsel_fprintf.c +8 -0
@@ -166,6 +166,14 @@ int sample__fprintf_callchain(struct perf_sample *sample, int left_alignment,if (!print_oneline) printed +=fprintf (fp,"\n" ); +if (symbol_conf.bt_stop_list && + node->sym && + node->sym->name && +strlist__has_entry (symbol_conf.bt_stop_list, + node->sym->name)) { +break ; + } + first = false; next:callchain_cursor_advance (cursor);
tools/perf/util/symbol.c +8 -0
@@ -2032,6 +2032,10 @@ int symbol__init(struct perf_env *env) symbol_conf.sym_list_str, "symbol") < 0) goto out_free_tid_list; +if (setup_list (&symbol_conf.bt_stop_list, + symbol_conf.bt_stop_list_str,"symbol" ) <0 ) + goto out_free_sym_list; +/* * A path to symbols of "/" is identical to "" * reset here for simplicity.
@@ -2049,6 +2053,8 @@ int symbol__init(struct perf_env *env) symbol_conf.initialized = true;return 0 ; +out_free_sym_list: +strlist__delete (symbol_conf.sym_list); out_free_tid_list:intlist__delete (symbol_conf.tid_list); out_free_pid_list:
@@ -2064,6 +2070,7 @@ void symbol__exit(void) {if (!symbol_conf.initialized)return ; +strlist__delete (symbol_conf.bt_stop_list);strlist__delete (symbol_conf.sym_list);strlist__delete (symbol_conf.dso_list);strlist__delete (symbol_conf.comm_list);
@@ -2071,6 +2078,7 @@ void symbol__exit(void)intlist__delete (symbol_conf.pid_list);vmlinux_path__exit (); symbol_conf.sym_list = symbol_conf.dso_list = symbol_conf.comm_list =NULL ; + symbol_conf.bt_stop_list =NULL ; symbol_conf.initialized = false; }
tools/perf/util/symbol.h +4 -2
@@ -132,14 +132,16 @@ struct symbol_conf { *pid_list_str, *tid_list_str, *sym_list_str, - *col_width_list_str; + *col_width_list_str, + *bt_stop_list_str;struct strlist *dso_list, *comm_list, *sym_list, *dso_from_list, *dso_to_list, *sym_from_list, - *sym_to_list; + *sym_to_list, + *bt_stop_list;struct intlist *pid_list, *tid_list;const char *symfs;
Signature · 1 line
2.9.3
Arnaldo Carvalho de Melo
maintainerPATCH 12/19 perf tools: Add time-based utility functions
In reply to Arnaldo Carvalho de MeloFrom: David Ahern <[email protected]>
Add function to parse a user time string of the form <start>,<stop> where start and stop are time in sec.nsec format. Both start and stop times are optional.
Add function to determine if a sample time is within a given time time window of interest.
--- tools/perf/util/Build | 1 + tools/perf/util/time-utils.c | 85 ++++++++++++++++++++++++++++++++++++++++++++ tools/perf/util/time-utils.h | 12 +++++++ 3 files changed, 98 insertions(+) create mode 100644 tools/perf/util/time-utils.c create mode 100644 tools/perf/util/time-utils.h
tools/perf/util/Build +1 -0
@@ -87,6 +87,7 @@ libperf-y += help-unknown-cmd.o libperf-y += mem-events.o libperf-y += vsprintf.o libperf-y += drv_configs.o +libperf-y += time-utils.o libperf-$(CONFIG_LIBBPF) += bpf-loader.o libperf-$(CONFIG_BPF_PROLOGUE) += bpf-prologue.o
tools/perf/util/time-utils.c new file +85 -0
85 lines not on this page · raw message
tools/perf/util/time-utils.h new file +12 -0
@@ -0,0 +1,12 @@ +#ifndef _TIME_UTILS_H_ +#define _TIME_UTILS_H_ + +struct perf_time_interval { +u64 start, end; +}; + +int perf_time__parse_str (struct perf_time_interval *ptime,const char *ostr); + +bool perf_time__skip_sample (struct perf_time_interval *ptime,u64 timestamp); + +#endif
Signature · 1 line
2.9.3
Arnaldo Carvalho de Melo
maintainerPATCH 13/19 perf tools: Move parse_nsec_time to time-utils.c
In reply to Arnaldo Carvalho de MeloFrom: David Ahern <[email protected]>
Code move only; no functional change intended.
Committer notes:
Fix the build on Ubuntu 16.04 x86-64 cross-compiling to S/390, with this set of auto-detected features:
... dwarf: [ on ] ... dwarf_getlocations: [ on ] ... glibc: [ on ]
... gtk2: [ OFF ]
... libaudit: [ OFF ]
... libbfd: [ OFF ]
... libelf: [ on ]
... libnuma: [ OFF ]
... numa_num_possible_cpus: [ OFF ]
... libperl: [ OFF ]
... libpython: [ OFF ]
... libslang: [ OFF ]
... libcrypto: [ OFF ]
... libunwind: [ OFF ]
... libdw-dwarf-unwind: [ on ]
... zlib: [ on ]
... lzma: [ OFF ]
... get_cpuid: [ OFF ]
... bpf: [ on ]
Where it was failing with:
CC /tmp/build/perf/util/time-utils.o
util/time-utils.c: In function 'parse_nsec_time':
util/time-utils.c:17:13: error: implicit declaration of function 'strtoul' [-Werror=implicit-function-declaration]
time_sec = strtoul(str, &end, 10);
^
util/time-utils.c:17:2: error: nested extern declaration of 'strtoul' [-Werror=nested-externs]
time_sec = strtoul(str, &end, 10);
^
util/time-utils.c: In function 'perf_time__parse_str':
util/time-utils.c:93:2: error: implicit declaration of function 'free' [-Werror=implicit-function-declaration]
free(str);
^ util/time-utils.c:93:2: error: incompatible implicit declaration of built-in function 'free' [-Werror] util/time-utils.c:93:2: note: include '<stdlib.h>' or provide a declaration of 'free'
Do as suggested and add a '#include <stdlib.h>' to get the free() and strtoul() declarations and fix the build.
--- tools/perf/util/time-utils.c | 36 +++++++++++++++++++++++++++++++++++- tools/perf/util/time-utils.h | 2 ++ tools/perf/util/util.c | 33 --------------------------------- tools/perf/util/util.h | 2 -- 4 files changed, 37 insertions(+), 36 deletions(-)
tools/perf/util/time-utils.c +35 -1
@@ -1,5 +1,7 @@ +#include <stdlib.h> #include <string.h> #include <sys/time.h> +#include <linux/time64.h> #include <time.h> #include <errno.h> #include <inttypes.h>
@@ -7,7 +9,39 @@#include "perf.h" #include "debug.h" #include "time-utils.h" -#include "util.h" + +int parse_nsec_time (const char *str,u64 *ptime) +{ +u64 time_sec, time_nsec; +char *end; + + time_sec =strtoul (str, &end,10 ); +if (*end !='.' && *end !='\0' ) +return -1 ; + +if (*end =='.' ) { +int i; +char nsec_buf[10 ]; + +if (strlen (++end) >9 ) +return -1 ; + +strncpy (nsec_buf, end,9 ); + nsec_buf[9 ] ='\0' ; + +/* make it nsec precision */ +for (i =strlen (nsec_buf); i <9 ; i++) + nsec_buf[i] ='0' ; + + time_nsec =strtoul (nsec_buf, &end,10 ); +if (*end !='\0' ) +return -1 ; + }else + time_nsec =0 ; + + *ptime = time_sec *NSEC_PER_SEC + time_nsec; +return 0 ; +}static int parse_timestr_sec_nsec (struct perf_time_interval *ptime,char *start_str,char *end_str)
tools/perf/util/time-utils.h +2 -0
@@ -5,6 +5,8 @@ struct perf_time_interval {u64 start, end; }; +int parse_nsec_time (const char *str,u64 *ptime); +int perf_time__parse_str (struct perf_time_interval *ptime,const char *ostr);bool perf_time__skip_sample (struct perf_time_interval *ptime,u64 timestamp);
tools/perf/util/util.c +0 -33
@@ -400,39 +400,6 @@ void sighandler_dump_stack(int sig)raise (sig); } -int parse_nsec_time (const char *str,u64 *ptime) -{ -u64 time_sec, time_nsec; -char *end; - - time_sec =strtoul (str, &end,10 ); -if (*end !='.' && *end !='\0' ) -return -1 ; - -if (*end =='.' ) { -int i; -char nsec_buf[10 ]; - -if (strlen (++end) >9 ) -return -1 ; - -strncpy (nsec_buf, end,9 ); - nsec_buf[9 ] ='\0' ; - -/* make it nsec precision */ -for (i =strlen (nsec_buf); i <9 ; i++) - nsec_buf[i] ='0' ; - - time_nsec =strtoul (nsec_buf, &end,10 ); -if (*end !='\0' ) -return -1 ; - }else - time_nsec =0 ; - - *ptime = time_sec *NSEC_PER_SEC + time_nsec; -return 0 ; -} -int timestamp__scnprintf_usec (u64 timestamp,char *buf,size_t sz) {u64 sec = timestamp /NSEC_PER_SEC ;
tools/perf/util/util.h +0 -2
@@ -179,8 +179,6 @@ static inline void *zalloc(size_t size)#undef tolower#undef toupper -int parse_nsec_time (const char *str,u64 *ptime); -extern unsigned char sane_ctype[256 ];#define GIT_SPACE 0x01#define GIT_DIGIT 0x02
Signature · 1 line
2.9.3
Arnaldo Carvalho de Melo
maintainerPATCH 14/19 perf script: Add option to specify time window of interest
In reply to Arnaldo Carvalho de MeloFrom: David Ahern <[email protected]>
Add option to allow user to control analysis window. e.g., collect data for some amount of time and analyze a segment of interest within that window.
Committer notes:
Testing it:
# perf evlist -v
cycles:ppp: size: 112, { sample_period, sample_freq }: 4000, sample_type: IP|TID|TIME|CALLCHAIN|CPU|PERIOD, disabled: 1, inherit: 1, mmap: 1, comm: 1, freq: 1, task: 1, precise_ip: 3, sample_id_all: 1, exclude_guest: 1, mmap2: 1, comm_exec: 1
#
# perf script --hide-call-graph | head -15
swapper 0 [0] 9693.370039: 1 cycles:ppp: ffffffffb90072ad x86_pmu_enable (.../4.8.8-300.fc25.x86_64/vmlinux)
swapper 0 [0] 9693.370044: 1 cycles:ppp: ffffffffb900ca1b intel_pmu_handle_irq (.../4.8.8-300.fc25.x86_64/vmlinux)
swapper 0 [0] 9693.370046: 7 cycles:ppp: ffffffffb902fd93 native_sched_clock (.../4.8.8-300.fc25.x86_64/vmlinux)
swapper 0 [0] 9693.370048: 126 cycles:ppp: ffffffffb902fd93 native_sched_clock (.../4.8.8-300.fc25.x86_64/vmlinux)
swapper 0 [0] 9693.370049: 2701 cycles:ppp: ffffffffb902fd93 native_sched_clock (.../4.8.8-300.fc25.x86_64/vmlinux)
swapper 0 [0] 9693.370051: 58823 cycles:ppp: ffffffffb90cd2e0 idle_cpu (.../4.8.8-300.fc25.x86_64/vmlinux)
swapper 0 [1] 9693.370059: 1 cycles:ppp: ffffffffb91a713a ctx_resched (.../4.8.8-300.fc25.x86_64/vmlinux)
swapper 0 [1] 9693.370062: 1 cycles:ppp: ffffffffb900ca1b intel_pmu_handle_irq (.../4.8.8-300.fc25.x86_64/vmlinux)
swapper 0 [1] 9693.370064: 13 cycles:ppp: ffffffffb902fd93 native_sched_clock (.../4.8.8-300.fc25.x86_64/vmlinux)
swapper 0 [1] 9693.370065: 250 cycles:ppp: ffffffffb902fd93 native_sched_clock (.../4.8.8-300.fc25.x86_64/vmlinux)
swapper 0 [1] 9693.370067: 5269 cycles:ppp: ffffffffb902fe79 sched_clock (.../4.8.8-300.fc25.x86_64/vmlinux)
swapper 0 [1] 9693.370069: 114602 cycles:ppp: ffffffffb90c1c5a atomic_notifier_call_chain (.../4.8.8-300.fc25.x86_64/vmlinux)
perf 5124 [2] 9693.370076: 1 cycles:ppp: ffffffffb91a76c1 __perf_event_enable (.../4.8.8-300.fc25.x86_64/vmlinux)
perf 5124 [2] 9693.370091: 1 cycles:ppp: ffffffffb900ca1b intel_pmu_handle_irq (.../4.8.8-300.fc25.x86_64/vmlinux)
perf 5124 [2] 9693.370095: 3 cycles:ppp: ffffffffb902fd93 native_sched_clock (.../4.8.8-300.fc25.x86_64/vmlinux)
#
# perf script --hide-call-graph --time ,9693.370048
swapper 0 [0] 9693.370039: 1 cycles:ppp: ffffffffb90072ad x86_pmu_enable (.../4.8.8-300.fc25.x86_64/vmlinux)
swapper 0 [0] 9693.370044: 1 cycles:ppp: ffffffffb900ca1b intel_pmu_handle_irq (.../4.8.8-300.fc25.x86_64/vmlinux)
swapper 0 [0] 9693.370046: 7 cycles:ppp: ffffffffb902fd93 native_sched_clock (.../4.8.8-300.fc25.x86_64/vmlinux)
# perf script --hide-call-graph --time 9693.370064,9693.370076
swapper 0 [1] 9693.370064: 13 cycles:ppp: ffffffffb902fd93 native_sched_clock (.../4.8.8-300.fc25.x86_64/vmlinux)
swapper 0 [1] 9693.370065: 250 cycles:ppp: ffffffffb902fd93 native_sched_clock (.../4.8.8-300.fc25.x86_64/vmlinux)
swapper 0 [1] 9693.370067: 5269 cycles:ppp: ffffffffb902fe79 sched_clock (.../4.8.8-300.fc25.x86_64/vmlinux)
swapper 0 [1] 9693.370069: 114602 cycles:ppp: ffffffffb90c1c5a atomic_notifier_call_chain (.../4.8.8-300.fc25.x86_64/vmlinux)
#--- tools/perf/Documentation/perf-script.txt | 7 +++++++ tools/perf/builtin-script.c | 15 ++++++++++++++- 2 files changed, 21 insertions(+), 1 deletion(-)
tools/perf/Documentation/perf-script.txt +7 -0
@@ -292,6 +292,13 @@ include::itrace.txt[] --force:: Don't do ownership validation. +--time:: + Only analyze samples within given time window: <start>,<stop>. Times + have the format seconds.microseconds. If start is not given (i.e., time + string is ',x.y') then analysis starts at the beginning of the file. If + stop time is not given (i.e, time string is 'x.y,') then analysis goes + to end of file. + SEE ALSO -------- linkperf:perf-record[1], linkperf:perf-script-perl[1],
tools/perf/builtin-script.c +14 -1
@@ -22,6 +22,7 @@#include "util/thread_map.h" #include "util/stat.h" #include "util/thread-stack.h" +#include "util/time-utils.h" #include <linux/bitmap.h> #include <linux/stringify.h> #include <linux/time64.h>
@@ -833,6 +834,8 @@ struct perf_script {struct cpu_map *cpus;struct thread_map *threads;int name_width; +const char *time_str; +struct perf_time_interval ptime; };static int perf_evlist__max_name_len (struct perf_evlist *evlist)
@@ -1014,6 +1017,9 @@ static int process_sample_event(struct perf_tool *tool, struct perf_script *scr = container_of(tool, struct perf_script, tool);struct addr_location al; +if (perf_time__skip_sample (&scr->ptime, sample->time)) +return 0 ; +if (debug_mode) {if (sample->time < last_timestamp) { pr_err("Samples misordered, previous: %" PRIu64
@@ -2186,7 +2192,8 @@ int cmd_script(int argc, const char **argv, const char *prefix __maybe_unused) "Enable symbol demangling"),OPT_BOOLEAN (0 ,"demangle-kernel" , &symbol_conf.demangle_kernel,"Enable kernel symbol demangling" ), - +OPT_STRING (0 ,"time" , &script.time_str,"str" , +"Time span of interest (start,stop)" ), OPT_END() };const char *const script_subcommands[] = {"record" ,"report" ,NULL };
@@ -2465,6 +2472,12 @@ int cmd_script(int argc, const char **argv, const char *prefix __maybe_unused)if (err <0 ) goto out_delete; +/* needs to be parsed after looking up reference time */ +if (perf_time__parse_str (&script.ptime, script.time_str) !=0 ) { +pr_err ("Invalid time string\n" ); +return -EINVAL ; + } + err =__cmd_script (&script);flush_scripting ();
Signature · 1 line
2.9.3
Arnaldo Carvalho de Melo
maintainerPATCH 15/19 perf sched timehist: Add option to specify time window of interest
In reply to Arnaldo Carvalho de MeloFrom: David Ahern <[email protected]>
Add option to allow user to control analysis window. e.g., collect data for time window and analyze a segment of interest within that window.
Committer notes:
Testing it:
# perf sched record -a usleep 1
[ perf record: Woken up 1 times to write data ]
[ perf record: Captured and wrote 1.593 MB perf.data (25 samples) ]
#
# perf sched timehist | head -18
Samples do not have callchains.
time cpu task name wait time sch delay run time
[tid/pid] (msec) (msec) (msec)
------------- ------ --------------- --------- --------- --------
19818.635579 [0002] <idle> 0.000 0.000 0.000
19818.635613 [0000] perf[9116] 0.000 0.000 0.000
19818.635676 [0000] <idle> 0.000 0.000 0.063
19818.635678 [0000] rcuos/2[29] 0.000 0.002 0.001
19818.635696 [0002] perf[9117] 0.000 0.004 0.116
19818.635702 [0000] <idle> 0.001 0.000 0.024
19818.635709 [0002] migration/2[25] 0.000 0.003 0.012
19818.636263 [0000] usleep[9117] 0.005 0.000 0.560
19818.636316 [0000] <idle> 0.560 0.000 0.053
19818.636358 [0002] <idle> 0.129 0.000 0.649
19818.636358 [0000] usleep[9117] 0.053 0.002 0.042
# # perf sched timehist --time 19818.635696,
Samples do not have callchains.
time cpu task name wait time sch delay run time
[tid/pid] (msec) (msec) (msec)
------------- ------ --------------- -------- --------- ---------
19818.635696 [0002] perf[9117] 0.000 0.120 0.000
19818.635702 [0000] <idle> 0.019 0.000 0.006
19818.635709 [0002] migration/2[25] 0.000 0.003 0.012
19818.636263 [0000] usleep[9117] 0.005 0.000 0.560
19818.636316 [0000] <idle> 0.560 0.000 0.053
19818.636358 [0002] <idle> 0.129 0.000 0.649
19818.636358 [0000] usleep[9117] 0.053 0.002 0.042
#
# perf sched timehist --time 19818.635696,19818.635709
Samples do not have callchains.
time cpu task name wait time sch delay run time
[tid/pid] (msec) (msec) (msec)
------------- ------ --------------- --------- --------- ---------
19818.635696 [0002] perf[9117] 0.000 0.120 0.000
19818.635702 [0000] <idle> 0.019 0.000 0.006
19818.635709 [0002] migration/2[25] 0.000 0.003 0.012
19818.635709 [0000] usleep[9117] 0.005 0.000 0.006
#--- tools/perf/Documentation/perf-sched.txt | 8 ++++++ tools/perf/builtin-sched.c | 51 +++++++++++++++++++++++++++++---- 2 files changed, 53 insertions(+), 6 deletions(-)
tools/perf/Documentation/perf-sched.txt +8 -0
@@ -132,6 +132,14 @@ OPTIONS for 'perf sched timehist' --migrations:: Show migration events. +--time:: + Only analyze samples within given time window: <start>,<stop>. Times + have the format seconds.microseconds. If start is not given (i.e., time + string is ',x.y') then analysis starts at the beginning of the file. If + stop time is not given (i.e, time string is 'x.y,') then analysis goes + to end of file. + + SEE ALSO -------- linkperf:perf-record[1]
tools/perf/builtin-sched.c +45 -6
108 lines not on this page · raw message
Signature · 1 line
2.9.3
Arnaldo Carvalho de Melo
maintainerPATCH 16/19 perf kmem: Add option to specify time window of interest
In reply to Arnaldo Carvalho de MeloFrom: David Ahern <[email protected]>
Add option to allow user to control analysis window. e.g., collect data for time window and analyze a segment of interest within that window.
Committer notes:
Testing it:
# perf kmem record usleep 1
[ perf record: Woken up 0 times to write data ]
[ perf record: Captured and wrote 1.540 MB perf.data (2049 samples) ]
# perf evlist
kmem:kmalloc
kmem:kmalloc_node
kmem:kfree
kmem:kmem_cache_alloc
kmem:kmem_cache_alloc_node
kmem:kmem_cache_free
# Tip: use 'perf evlist --trace-fields' to show fields for tracepoint events
#
# # Use 'perf script' to get a first approach, select a chunk for then using
# # with 'perf kmem stat --time'
#
# perf script | tail -15
usleep 9889 [0] 20119.782088: kmem:kmem_cache_free: (selinux_file_free_security+0x27) call_site=ffffffffb936aa07 ptr=0xffff888a1df49fc0
perf 9888 [3] 20119.782088: kmem:kmem_cache_free: (jbd2_journal_stop+0x1a1) call_site=ffffffffb9334581 ptr=0xffff888bdf1a39c0
perf 9888 [3] 20119.782089: kmem:kmem_cache_alloc: (jbd2__journal_start+0x72) call_site=ffffffffb9333b42 ptr=0xffff888bdf1a39c0 bytes_req=48 bytes_alloc=48 gfp_flags=GFP_NOFS|__GFP_ZERO
perf 9888 [3] 20119.782090: kmem:kmem_cache_free: (jbd2_journal_stop+0x1a1) call_site=ffffffffb9334581 ptr=0xffff888bdf1a39c0
perf 9888 [3] 20119.782090: kmem:kmem_cache_alloc: (jbd2__journal_start+0x72) call_site=ffffffffb9333b42 ptr=0xffff888bdf1a39c0 bytes_req=48 bytes_alloc=48 gfp_flags=GFP_NOFS|__GFP_ZERO
usleep 9889 [0] 20119.782091: kmem:kmem_cache_alloc: (__sigqueue_alloc+0x4a) call_site=ffffffffb90ad33a ptr=0xffff8889f071f6e0 bytes_req=160 bytes_alloc=160 gfp_flags=GFP_ATOMIC|__GFP_NOTRACK
perf 9888 [3] 20119.782091: kmem:kmem_cache_free: (jbd2_journal_stop+0x1a1) call_site=ffffffffb9334581 ptr=0xffff888bdf1a39c0
perf 9888 [3] 20119.782093: kmem:kmem_cache_free: (__sigqueue_free.part.17+0x33) call_site=ffffffffb90ad3f3 ptr=0xffff8889f071f6e0
perf 9888 [3] 20119.782098: kmem:kmem_cache_alloc: (jbd2__journal_start+0x72) call_site=ffffffffb9333b42 ptr=0xffff888bdf1a39c0 bytes_req=48 bytes_alloc=48 gfp_flags=GFP_NOFS|__GFP_ZERO
perf 9888 [3] 20119.782098: kmem:kmem_cache_free: (jbd2_journal_stop+0x1a1) call_site=ffffffffb9334581 ptr=0xffff888bdf1a39c0
perf 9888 [3] 20119.782099: kmem:kmem_cache_alloc: (jbd2__journal_start+0x72) call_site=ffffffffb9333b42 ptr=0xffff888bdf1a39c0 bytes_req=48 bytes_alloc=48 gfp_flags=GFP_NOFS|__GFP_ZERO
perf 9888 [3] 20119.782100: kmem:kmem_cache_alloc: (alloc_buffer_head+0x21) call_site=ffffffffb9287cc1 ptr=0xffff8889b12722d8 bytes_req=104 bytes_alloc=104 gfp_flags=GFP_NOFS|__GFP_ZERO
perf 9888 [3] 20119.782101: kmem:kmem_cache_free: (jbd2_journal_stop+0x1a1) call_site=ffffffffb9334581 ptr=0xffff888bdf1a39c0
perf 9888 [3] 20119.782102: kmem:kmem_cache_alloc: (jbd2__journal_start+0x72) call_site=ffffffffb9333b42 ptr=0xffff888bdf1a39c0 bytes_req=48 bytes_alloc=48 gfp_flags=GFP_NOFS|__GFP_ZERO
perf 9888 [3] 20119.782103: kmem:kmem_cache_free: (jbd2_journal_stop+0x1a1) call_site=ffffffffb9334581 ptr=0xffff888bdf1a39c0
#
# # stats for the whole perf.data file, i.e. no interval specified
#
# perf kmem stat SUMMARY (SLAB allocator)
========================
Total bytes requested: 172,628
Total bytes allocated: 173,088
Total bytes freed: 161,280
Net total bytes allocated: 11,808
Total bytes wasted on internal fragmentation: 460 Internal fragmentation: 0.265761%
Cross CPU allocations: 0/851
#
# # stats for an end open interval, after a certain time:
#
# perf kmem stat --time 20119.782088,
SUMMARY (SLAB allocator)
========================
Total bytes requested: 552
Total bytes allocated: 552
Total bytes freed: 448
Net total bytes allocated: 104
Total bytes wasted on internal fragmentation: 0
Internal fragmentation: 0.000000%
Cross CPU allocations: 0/8
#
--- tools/perf/Documentation/perf-kmem.txt | 7 +++++++ tools/perf/builtin-kmem.c | 24 ++++++++++++++++++++++++ 2 files changed, 31 insertions(+)
tools/perf/Documentation/perf-kmem.txt +7 -0
@@ -61,6 +61,13 @@ OPTIONS default, but this option shows live (currently allocated) pages instead. (This option works with --page option only) +--time:: + Only analyze samples within given time window: <start>,<stop>. Times + have the format seconds.microseconds. If start is not given (i.e., time + string is ',x.y') then analysis starts at the beginning of the file. If + stop time is not given (i.e, time string is 'x.y,') then analysis goes + to end of file. + SEE ALSO -------- linkperf:perf-record[1]
tools/perf/builtin-kmem.c +24 -0
@@ -11,6 +11,7 @@#include "util/session.h" #include "util/tool.h" #include "util/callchain.h" +#include "util/time-utils.h" #include <subcmd/parse-options.h> #include "util/trace-event.h"
@@ -66,6 +67,10 @@ static struct rb_root root_caller_sorted;static unsigned long total_requested, total_allocated, total_freed;static unsigned long nr_allocs, nr_cross_allocs; +/* filters for controlling start and stop of time of analysis */ +static struct perf_time_interval ptime; +const char *time_str; +static int insert_alloc_stat (unsigned long call_site,unsigned long ptr,int bytes_req,int bytes_alloc,int cpu) {
@@ -912,6 +917,15 @@ static int perf_evsel__process_page_free_event(struct perf_evsel *evsel,return 0 ; } +static bool perf_kmem__skip_sample (struct perf_sample *sample) +{ +/* skip sample based on time? */ +if (perf_time__skip_sample (&ptime, sample->time)) +return true; + +return false; +} +typedef int (*tracepoint_handler )(struct perf_evsel *evsel,struct perf_sample *sample);
@@ -931,6 +945,9 @@ static int process_sample_event(struct perf_tool *tool __maybe_unused,return -1 ; } +if (perf_kmem__skip_sample (sample)) +return 0 ; +dump_printf (" ... thread: %s:%d\n" ,thread__comm_str (thread), thread->tid);if (evsel->handler !=NULL ) {
@@ -1894,6 +1911,8 @@ int cmd_kmem(int argc, const char **argv, const char *prefix __maybe_unused)OPT_CALLBACK_NOOPT (0 ,"page" ,NULL ,NULL ,"Analyze page allocator" , parse_page_opt),OPT_BOOLEAN (0 ,"live" , &live_page,"Show live page stat" ), +OPT_STRING (0 ,"time" , &time_str,"str" , +"Time span of interest (start,stop)" ), OPT_END() };const char *const kmem_subcommands[] = {"record" ,"stat" ,NULL };
@@ -1954,6 +1973,11 @@ int cmd_kmem(int argc, const char **argv, const char *prefix __maybe_unused)symbol__init (&session->header.env); +if (perf_time__parse_str (&ptime, time_str) !=0 ) { +pr_err ("Invalid time string\n" ); +return -EINVAL ; + } +if (!strcmp (argv[0 ],"stat" )) {setlocale (LC_ALL ,"" );
Signature · 1 line
2.9.3
Arnaldo Carvalho de Melo
maintainerPATCH 17/19 perf report: Add option to specify time window of interest
In reply to Arnaldo Carvalho de MeloFrom: David Ahern <[email protected]>
Add option to allow user to control analysis window. e.g., collect data for time window and analyze a segment of interest within that window.
Committer notes:
Testing it:
Using the perf.data file captured via 'perf kmem record':
# perf report --header-only
# ========
# captured on: Tue Nov 29 16:01:53 2016
# hostname : jouet
# os release : 4.8.8-300.fc25.x86_64
# perf version : 4.9.rc6.g5a6aca
# arch : x86_64
# nrcpus online : 4
# nrcpus avail : 4
# cpudesc : Intel(R) Core(TM) i7-5600U CPU @ 2.60GHz
# cpuid : GenuineIntel,6,61,4
# total memory : 20254660 kB
# cmdline : /home/acme/bin/perf kmem record usleep 1
# event : name = kmem:kmalloc, , id = { 931980, 931981, 931982, 931983 }, type = 2, size = 112, config = 0x1b9, { sample_period, sample_freq } = 1, sample_typ
# event : name = kmem:kmalloc_node, , id = { 931984, 931985, 931986, 931987 }, type = 2, size = 112, config = 0x1b7, { sample_period, sample_freq } = 1, sampl
# event : name = kmem:kfree, , id = { 931988, 931989, 931990, 931991 }, type = 2, size = 112, config = 0x1b5, { sample_period, sample_freq } = 1, sample_type
# event : name = kmem:kmem_cache_alloc, , id = { 931992, 931993, 931994, 931995 }, type = 2, size = 112, config = 0x1b8, { sample_period, sample_freq } = 1, s
# event : name = kmem:kmem_cache_alloc_node, , id = { 931996, 931997, 931998, 931999 }, type = 2, size = 112, config = 0x1b6, { sample_period, sample_freq } =
# event : name = kmem:kmem_cache_free, , id = { 932000, 932001, 932002, 932003 }, type = 2, size = 112, config = 0x1b4, { sample_period, sample_freq } = 1, sa
# HEADER_CPU_TOPOLOGY info available, use -I to display
# HEADER_NUMA_TOPOLOGY info available, use -I to display
# pmu mappings: cpu = 4, intel_pt = 7, intel_bts = 6, uncore_arb = 13, cstate_pkg = 15, breakpoint = 5, uncore_cbox_1 = 12, power = 9, software = 1, uncore_im
# HEADER_CACHE info available, use -I to display
# missing features: HEADER_BRANCH_STACK HEADER_GROUP_DESC HEADER_AUXTRACE HEADER_STAT
# ========
#
# # Looking at just the histogram entries for the first event:
#
# perf report | head -33
# To display the perf.data header info, please use --header/--header-only options.
#
#
# Total Lost Samples: 0
#
# Samples: 40 of event 'kmem:kmalloc'
# Event count (approx.): 40
#
# Overhead Trace output
# ........ ...............................................................................................................
#
37.50% call_site=ffffffffb91ad3c7 ptr=0xffff88895fc05000 bytes_req=4096 bytes_alloc=4096 gfp_flags=GFP_KERNEL
10.00% call_site=ffffffffb9258416 ptr=0xffff888a1dc61f00 bytes_req=240 bytes_alloc=256 gfp_flags=GFP_KERNEL|__GFP_ZERO
7.50% call_site=ffffffffb9258416 ptr=0xffff888a2640ac00 bytes_req=240 bytes_alloc=256 gfp_flags=GFP_KERNEL|__GFP_ZERO
2.50% call_site=ffffffffb92759ba ptr=0xffff888a26776000 bytes_req=4096 bytes_alloc=4096 gfp_flags=GFP_KERNEL
2.50% call_site=ffffffffb9276864 ptr=0xffff8886f6b82600 bytes_req=136 bytes_alloc=192 gfp_flags=GFP_KERNEL|__GFP_ZERO
2.50% call_site=ffffffffb9276903 ptr=0xffff888aefcf0460 bytes_req=32 bytes_alloc=32 gfp_flags=GFP_KERNEL
2.50% call_site=ffffffffb92ad0ce ptr=0xffff888756c98a00 bytes_req=392 bytes_alloc=512 gfp_flags=GFP_KERNEL
2.50% call_site=ffffffffb92ad0ce ptr=0xffff888756c9ba00 bytes_req=504 bytes_alloc=512 gfp_flags=GFP_KERNEL
2.50% call_site=ffffffffb92ad301 ptr=0xffff888a31747600 bytes_req=128 bytes_alloc=128 gfp_flags=GFP_KERNEL
2.50% call_site=ffffffffb92ad511 ptr=0xffff888a9d26a2a0 bytes_req=28 bytes_alloc=32 gfp_flags=GFP_KERNEL
2.50% call_site=ffffffffb936a7fb ptr=0xffff88873e8c11a0 bytes_req=24 bytes_alloc=32 gfp_flags=GFP_KERNEL
2.50% call_site=ffffffffb936a7fb ptr=0xffff88873e8c12c0 bytes_req=24 bytes_alloc=32 gfp_flags=GFP_KERNEL
2.50% call_site=ffffffffb936a7fb ptr=0xffff88873e8c1540 bytes_req=24 bytes_alloc=32 gfp_flags=GFP_KERNEL
2.50% call_site=ffffffffb936a7fb ptr=0xffff88873e8c15a0 bytes_req=24 bytes_alloc=32 gfp_flags=GFP_KERNEL
2.50% call_site=ffffffffb936a7fb ptr=0xffff88873e8c15e0 bytes_req=24 bytes_alloc=32 gfp_flags=GFP_KERNEL
2.50% call_site=ffffffffb936a7fb ptr=0xffff88873e8c16e0 bytes_req=24 bytes_alloc=32 gfp_flags=GFP_KERNEL
2.50% call_site=ffffffffb936a7fb ptr=0xffff88873e8c1c20 bytes_req=24 bytes_alloc=32 gfp_flags=GFP_KERNEL
2.50% call_site=ffffffffb936a7fb ptr=0xffff888a9d26a2a0 bytes_req=24 bytes_alloc=32 gfp_flags=GFP_KERNEL
2.50% call_site=ffffffffb9373e66 ptr=0xffff8889f1931240 bytes_req=64 bytes_alloc=64 gfp_flags=GFP_ATOMIC|__GFP_ZERO
2.50% call_site=ffffffffb9373e66 ptr=0xffff8889f1931980 bytes_req=64 bytes_alloc=64 gfp_flags=GFP_ATOMIC|__GFP_ZERO
2.50% call_site=ffffffffb9373e66 ptr=0xffff8889f1931a00 bytes_req=64 bytes_alloc=64 gfp_flags=GFP_ATOMIC|__GFP_ZERO #
# # And then limiting using the example for 'perf kmem stat --time' used # # in the previous changeset committer note we see that there were no # # kmem:kmalloc in that last part of the file, but there were some # # kmem:kmem_cache_alloc ones:
#
# perf report --time 20119.782088, --stdio # # Total Lost Samples: 0 # # Samples: 0 of event 'kmem:kmalloc' # Event count (approx.): 0 # # Overhead Trace output # ........ ............ #
# Samples: 0 of event 'kmem:kmalloc_node'
# Event count (approx.): 0
#
# Overhead Trace output
# ........ ............ #
# Samples: 0 of event 'kmem:kfree'
# Event count (approx.): 0
#
# Overhead Trace output
# ........ ............ #
# Samples: 8 of event 'kmem:kmem_cache_alloc'
# Event count (approx.): 8
#
# Overhead Trace output
# ........ ..................................................................................................................
#
75.00% call_site=ffffffffb9333b42 ptr=0xffff888bdf1a39c0 bytes_req=48 bytes_alloc=48 gfp_flags=GFP_NOFS|__GFP_ZERO
12.50% call_site=ffffffffb90ad33a ptr=0xffff8889f071f6e0 bytes_req=160 bytes_alloc=160 gfp_flags=GFP_ATOMIC|__GFP_NOTRACK
12.50% call_site=ffffffffb9287cc1 ptr=0xffff8889b12722d8 bytes_req=104 bytes_alloc=104 gfp_flags=GFP_NOFS|__GFP_ZERO
#--- tools/perf/Documentation/perf-report.txt | 7 +++++++ tools/perf/builtin-report.c | 14 +++++++++++++- 2 files changed, 20 insertions(+), 1 deletion(-)
tools/perf/Documentation/perf-report.txt +7 -0
@@ -382,6 +382,13 @@ OPTIONS --header-only:: Show only perf.data header (forces --stdio). +--time:: + Only analyze samples within given time window: <start>,<stop>. Times + have the format seconds.microseconds. If start is not given (i.e., time + string is ',x.y') then analysis starts at the beginning of the file. If + stop time is not given (i.e, time string is 'x.y,') then analysis goes + to end of file. + --itrace:: Options for decoding instruction tracing data. The options are:
tools/perf/builtin-report.c +13 -1
@@ -36,7 +36,7 @@#include "util/hist.h" #include "util/data.h" #include "arch/common.h" - +#include "util/time-utils.h" #include "util/auxtrace.h" #include <dlfcn.h>
@@ -59,6 +59,8 @@ struct report {const char *pretty_printing_style;const char *cpu_list;const char *symbol_filter_str; +const char *time_str; +struct perf_time_interval ptime;float min_percent;u64 nr_entries;u64 queue_size;
@@ -158,6 +160,9 @@ static int process_sample_event(struct perf_tool *tool, };int ret =0 ; +if (perf_time__skip_sample (&rep->ptime, sample->time)) +return 0 ; +if (machine__resolve (machine, &al, sample) <0 ) {pr_debug ("problem processing %d event, skipping it.\n" , event->header.type);
@@ -830,6 +835,8 @@ int cmd_report(int argc, const char **argv, const char *prefix __maybe_unused)OPT_CALLBACK_DEFAULT (0 ,"stdio-color" ,NULL ,"mode" ,"'always' (default), 'never' or 'auto' only applicable to --stdio mode" , stdio__config_color,"always" ), +OPT_STRING (0 ,"time" , &report.time_str,"str" , +"Time span of interest (start,stop)" ),OPT_END () }; struct perf_data_file file = {
@@ -1015,6 +1022,11 @@ int cmd_report(int argc, const char **argv, const char *prefix __maybe_unused)if (symbol__init (&session->header.env) <0 ) goto error; +if (perf_time__parse_str (&report.ptime, report.time_str) !=0 ) { +pr_err ("Invalid time string\n" ); +return -EINVAL ; + } +sort__setup_elide (stdout); ret =__cmd_report (&report);
Signature · 1 line
2.9.3
Arnaldo Carvalho de Melo
maintainerPATCH 18/19 perf annotate: Use arch->objdump.comment_char in dec__parse()
In reply to Arnaldo Carvalho de MeloFrom: Kim Phillips <[email protected]>
Presume neglected in commit 786c1b5 "perf annotate: Start supporting cross arch annotation". This doesn't fix a bug since none of the affected arches support parsing dec/inc instructions yet.
--- tools/perf/util/annotate.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
tools/perf/util/annotate.c +1 -1
@@ -408,7 +408,7 @@ static int dec__parse(struct arch *arch __maybe_unused, struct ins_operands *opsif (ops->target.raw ==NULL )return -1 ; - comment =strchr (s,'#' ); + comment =strchr (s, arch->objdump.comment_char);if (comment ==NULL )return 0 ;
Signature · 1 line
2.9.3
Arnaldo Carvalho de Melo
maintainerPATCH 19/19 perf annotate: AArch64 support
In reply to Arnaldo Carvalho de MeloFrom: Kim Phillips <[email protected]>
This is a regex converted version from the original:
https://lkml.org/lkml/2016/5/19/461
Add basic support to recognise AArch64 assembly. This allows perf to identify AArch64 instructions that branch to other parts within the same function, thereby properly annotating them.
Rebased onto new cross-arch annotation bits:
https://lkml.org/lkml/2016/11/25/546
Sample output:
security_file_permission vmlinux
5.80 │ ← ret ▒
│70: ldr w0, [x21,#68] ▒
4.44 │ ↓ tbnz d0 ▒
│ mov w0, #0x24 // #36 ▒
1.37 │ ands w0, w22, w0 ▒
│ ↑ b.eq 60 ▒
1.37 │ ↓ tbnz e4 ▒
│ mov w19, #0x20000 // #131072 ▒
1.02 │ ↓ tbz ec ▒
│90:┌─→ldr x3, [x21,#24] ▒
1.37 │ │ add x21, x21, #0x10 ▒
│ │ mov w2, w19 ▒
1.02 │ │ mov x0, x21 ▒
│ │ mov x1, x3 ▒
1.71 │ │ ldr x20, [x3,#48] ▒
│ │→ bl __fsnotify_parent ▒
0.68 │ │↑ cbnz 60 ▒
│ │ mov x2, x21 ▒
1.37 │ │ mov w1, w19 ▒
│ │ mov x0, x20 ▒
0.68 │ │ mov w5, #0x0 // #0 ▒
│ │ mov x4, #0x0 // #0 ▒
1.71 │ │ mov w3, #0x1 // #1 ▒
│ │→ bl fsnotify ▒
1.37 │ │↑ b 60 ▒
│d0:│ mov w0, #0x0 // #0 ▒
│ │ ldp x19, x20, [sp,#16] ▒
│ │ ldp x21, x22, [sp,#32] ▒
│ │ ldp x29, x30, [sp],#48 ▒
│ │← ret ▒
│e4:│ mov w19, #0x10000 // #65536 ▒
│ └──b 90 ◆
│ec: brk #0x800 ▒Press 'h' for help on key bindings
--- tools/perf/arch/arm64/annotate/instructions.c | 62 +++++++++++++++++++++++++++ tools/perf/util/annotate.c | 5 +++ 2 files changed, 67 insertions(+) create mode 100644 tools/perf/arch/arm64/annotate/instructions.c
tools/perf/arch/arm64/annotate/instructions.c new file +62 -0
@@ -0,0 +1,62 @@ +#include <sys/types.h> +#include <regex.h> + +struct arm64_annotate { +regex_t call_insn, + jump_insn; +}; + +static struct ins_ops *arm64__associate_instruction_ops (struct arch *arch,const char *name) +{ +struct arm64_annotate *arm = arch->priv; +struct ins_ops *ops; +regmatch_t match[2 ]; + +if (!regexec (&arm->jump_insn, name,2 , match,0 )) + ops = &jump_ops; +else if (!regexec (&arm->call_insn, name,2 , match,0 )) + ops = &call_ops; +else if (!strcmp (name,"ret" )) + ops = &ret_ops; +else +return NULL ; + +arch__associate_ins_ops (arch, name, ops); +return ops; +} + +static int arm64__annotate_init (struct arch *arch) +{ +struct arm64_annotate *arm; +int err; + +if (arch->initialized) +return 0 ; + + arm =zalloc (sizeof (*arm)); +if (!arm) +return -1 ; + +/* bl, blr */ + err =regcomp (&arm->call_insn,"^blr?$" ,REG_EXTENDED ); +if (err) + goto out_free_arm; +/* b, b.cond, br, cbz/cbnz, tbz/tbnz */ + err =regcomp (&arm->jump_insn,"^[ct]?br?\\.?(cc|cs|eq|ge|gt|hi|le|ls|lt|mi|ne|pl)?n?z?$" , +REG_EXTENDED ); +if (err) + goto out_free_call; + + arch->initialized = true; + arch->priv = arm; + arch->associate_instruction_ops = arm64__associate_instruction_ops; + arch->objdump.comment_char =';' ; + arch->objdump.skip_functions_char ='+' ; +return 0 ; + +out_free_call: +regfree (&arm->call_insn); +out_free_arm: +free (arm); +return -1 ; +}
tools/perf/util/annotate.c +5 -0
@@ -105,6 +105,7 @@ static int arch__associate_ins_ops(struct arch* arch, const char *name, struct i }#include "arch/arm/annotate/instructions.c" +#include "arch/arm64/annotate/instructions.c" #include "arch/x86/annotate/instructions.c" #include "arch/powerpc/annotate/instructions.c"
@@ -114,6 +115,10 @@ static struct arch architectures[] = { .init = arm__annotate_init, }, { + .name = "arm64", + .init = arm64__annotate_init, + }, + { .name = "x86", .instructions = x86__instructions, .nr_instructions = ARRAY_SIZE(x86__instructions),
Signature · 1 line
2.9.3
Quoted 263 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
2471cece40d61b0035360338569d338f9dea6099:Merge tag 'perf-core-for-mingo-20161125' of
git://git.kernel.org/pub/scm/linux/kernel/git/acme/linuxinto perf/core (2016-11-25 18:12:41 +0100)are available in the git repository at:
git://git.kernel.org/pub/scm/linux/kernel/git/acme/linux.gittags/perf-core-for-mingo-20161201for you to fetch changes up to
0fcb1da4aba6e6c7b32de5e0948b740b31ad822d:perf annotate: AArch64 support (2016-12-01 13:03:19 -0300)
----------------------------------------------------------------
perf/core improvements and fixes:New features:
- Support AArch64 in the 'annotate' code, native/local and cross-arch/remote (Kim Phillips)
- Allow considering just events in a given time interval, via the '--time start.s.ms,end.s.ms' command line, added to 'perf kmem', 'perf report', 'perf sched timehist' and 'perf script' (David Ahern)
- Add option to stop printing a callchain at one of a given group of symbol names (David Ahern)
- Handle cpu migration events in 'perf sched timehist' (David Ahern)
- Track memory freed in 'perf kmem stat' (David Ahern)
Infrastructure:
- Initial support (and perf test entry) for tooling hooks, starting with '
record_start' and 'record_end', that will have as its initial user the eBPF infrastructure, whereperf_prefixed functions will be JITed and run when such hooks are called (Wang Nan)- Remove redundant "test" and similar strings from 'perf test' descriptions (Arnaldo Carvalho de Melo)
- libbpf assorted improvements (Wang Nan)
Signed-off-by Arnaldo Carvalho de Melo <[email protected]>----------------------------------------------------------------
Arnaldo Carvalho de Melo (3):
perf ui helpline: Provide a printf variant
perf annotate: Show invalid jump offset in error message perf test: Remove "test" and similar strings from test descriptionsDavid Ahern (10):
perf sched timehist: Handle cpu migration events
perf trace: Update tid/pid filtering option to leveragesymbol_confperf kmem stat: Track memory freed
perf script: Add option to stop printing callchain
perf tools: Add time-based utility functions
perf tools: Moveparse_nsec_timetotime-utils.c
perf script: Add option to specify time window of interest perf sched timehist: Add option to specify time window of interest perf kmem: Add option to specify time window of interest perf report: Add option to specify time window of interestKim Phillips (2):
perf annotate: Usearch->objdump.comment_charindec__parse()perf annotate: AArch64 supportWang Nan (4):
tools lib bpf: Add missing BPF functions
tools lib bpf: Add private field forbpf_objecttools lib bpf: Retrivebpf_mapthrough offset ofbpf_map_defperf tools: Introduce perf hookstools/lib/bpf/bpf.c | 56 ++++++++++ tools/lib/bpf/bpf.h | 7 ++ tools/lib/bpf/libbpf.c | 35 ++++++ tools/lib/bpf/libbpf.h | 13 +++ tools/perf/Documentation/perf-kmem.txt | 7 ++ tools/perf/Documentation/perf-report.txt | 7 ++ tools/perf/Documentation/perf-sched.txt | 12 +++ tools/perf/Documentation/perf-script.txt | 10 ++ tools/perf/arch/arm64/annotate/instructions.c | 62 +++++++++++ tools/perf/arch/x86/tests/arch-tests.c | 10 +- tools/perf/builtin-kmem.c | 36 ++++++- tools/perf/builtin-record.c | 11 ++ tools/perf/builtin-report.c | 14 ++- tools/perf/builtin-sched.c | 148 ++++++++++++++++++++++++-- tools/perf/builtin-script.c | 17 ++- tools/perf/builtin-trace.c | 49 ++------- tools/perf/tests/Build | 1 + tools/perf/tests/bpf.c | 6 +- tools/perf/tests/builtin-test.c | 96 +++++++++-------- tools/perf/tests/llvm.c | 8 +- tools/perf/tests/perf-hooks.c | 44 ++++++++ tools/perf/tests/tests.h | 1 + tools/perf/ui/browsers/annotate.c | 6 +- tools/perf/ui/helpline.c | 10 ++ tools/perf/ui/helpline.h | 1 + tools/perf/util/Build | 3 + tools/perf/util/annotate.c | 7 +- tools/perf/util/evsel_fprintf.c | 8 ++ tools/perf/util/perf-hooks-list.h | 3 + tools/perf/util/perf-hooks.c | 84 +++++++++++++++ tools/perf/util/perf-hooks.h | 37 +++++++ tools/perf/util/symbol.c | 8 ++ tools/perf/util/symbol.h | 6 +- tools/perf/util/time-utils.c | 119 +++++++++++++++++++++ tools/perf/util/time-utils.h | 14 +++ tools/perf/util/util.c | 33 ------ tools/perf/util/util.h | 2 - 37 files changed, 842 insertions(+), 149 deletions(-) create mode 100644 tools/perf/arch/arm64/annotate/instructions.c create mode 100644 tools/perf/tests/perf-hooks.c create mode 100644 tools/perf/util/perf-hooks-list.h create mode 100644 tools/perf/util/perf-hooks.c create mode 100644 tools/perf/util/perf-hooks.h create mode 100644 tools/perf/util/time-utils.c create mode 100644 tools/perf/util/time-utils.h# uname -a Linux jouet 4.8.8-300.fc25.x86_64 #1 SMP Tue Nov 15 18:10:06 UTC 2016 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: Parse event definition strings : Ok 6: PERF_RECORD_* events & perf_sample fields : Ok 7: Parse perf pmu format : Ok 8: DSO data read : Ok 9: DSO data cache : Ok 10: DSO data reopen : Ok 11: Roundtrip evsel->name : Ok 12: Parse sched tracepoints fields : Ok 13: syscalls:sys_enter_openat event fields : Ok 14: Setup struct perf_event_attr : Ok 15: Match and link multiple hists : Ok 16: 'import perf' in python : Ok 17: Breakpoint overflow signal handler : Ok 18: Breakpoint overflow sampling : Ok 19: Number of exit events of a simple workload : Ok 20: Software clock events period values : Ok 21: Object code reading : Ok 22: Sample parsing : Ok 23: Use a dummy software event to keep tracking: Ok 24: Parse with no sample_id_all bit set : Ok 25: Filter hist entries : Ok 26: Lookup mmap thread : Ok 27: Share thread mg : Ok 28: Sort output of hist entries : Ok 29: Cumulate child hist entries : Ok 30: Track with sched_switch : Ok 31: Filter fds with revents mask in a fdarray : Ok 32: Add fd to a fdarray, making it autogrow : Ok 33: kmod_path__parse : Ok 34: Thread map : Ok 35: LLVM search and compile : 35.1: Basic BPF llvm compile : Ok 35.2: kbuild searching : Ok 35.3: Compile source for BPF prologue generation: Ok 35.4: Compile source for BPF relocation : Ok 36: Session topology : Ok 37: BPF filter : 37.1: Basic BPF filtering : Ok 37.2: BPF prologue generation : Ok 37.3: BPF relocation checker : Ok 38: Synthesize thread map : Ok 39: Synthesize cpu map : Ok 40: Synthesize stat config : Ok 41: Synthesize stat : Ok 42: Synthesize stat round : Ok 43: Synthesize attr update : Ok 44: Event times : Ok 45: Read backward ring buffer : Ok 46: Print cpu map : Ok 47: Probe SDT events : Ok 48: is_printable_array : Ok 49: Print bitmap : Ok 50: perf hooks : Ok 51: x86 rdpmc : Ok 52: Convert perf time to TSC : Ok 53: DWARF unwind : Ok 54: x86 instruction decoder - new instructions : Ok 55: Intel cqm nmi context read : Skip # # uname -a Linux zoo 4.7.3-200.fc24.x86_64 #1 SMP Wed Sep 7 17:31:21 UTC 2016 x86_64 x86_64 x86_64 GNU/Linux # dm 1 alpine:3.4: Ok 2 android-ndk:r12b-arm: Ok 3 archlinux:latest: Ok 4 centos:5: Ok 5 centos:6: Ok 6 centos:7: Ok 7 debian:7: Ok 8 debian:8: Ok 9 debian:experimental: Ok 10 fedora:20: Ok 11 fedora:21: Ok 12 fedora:22: Ok 13 fedora:23: Ok 14 fedora:24: Ok 15 fedora:24-x-ARC-uClibc: Ok 16 fedora:rawhide: Ok 17 mageia:5: Ok 18 opensuse:13.2: Ok 19 opensuse:42.1: Ok 20 opensuse:tumbleweed: Ok 21 ubuntu:12.04.5: Ok 22 ubuntu:14.04: Ok 23 ubuntu:14.04.4: Ok 24 ubuntu:15.10: Ok 25 ubuntu:16.04: Ok 26 ubuntu:16.04-x-arm: Ok 27 ubuntu:16.04-x-arm64: Ok 28 ubuntu:16.04-x-powerpc: Ok 29 ubuntu:16.04-x-powerpc64: Ok 30 ubuntu:16.04-x-powerpc64el: Ok 31 ubuntu:16.04-x-s390: Ok 32 ubuntu:16.10: Ok # $ grep PRETTY_NAME /etc/os-release PRETTY_NAME="Fedora 25 (Workstation Edition)" $ $ perf stat make -C tools/perf build-test make: Entering directory '/home/acme/git/linux/tools/perf' - tarpkg: ./tests/perf-targz-src-pkg . make_no_slang_O: make NO_SLANG=1 make_util_map_o_O: make util/map.o make_static_O: make LDFLAGS=-static make_no_libdw_dwarf_unwind_O: make NO_LIBDW_DWARF_UNWIND=1 make_perf_o_O: make perf.o make_no_libunwind_O: make NO_LIBUNWIND=1 make_no_libelf_O: make NO_LIBELF=1 make_util_pmu_bison_o_O: make util/pmu-bison.o make_no_backtrace_O: make NO_BACKTRACE=1 make_no_ui_O: make NO_NEWT=1 NO_SLANG=1 NO_GTK2=1 make_no_demangle_O: make NO_DEMANGLE=1 make_no_libperl_O: make NO_LIBPERL=1 make_tags_O: make tags make_no_scripts_O: make NO_LIBPYTHON=1 NO_LIBPERL=1 make_install_prefix_slash_O: make install prefix=/tmp/krava/ make_no_auxtrace_O: make NO_AUXTRACE=1 make_no_libnuma_O: make NO_LIBNUMA=1 make_install_bin_O: make install-bin make_no_newt_O: make NO_NEWT=1 make_pure_O: make 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_clean_all_O: make clean all make_no_gtk2_O: make NO_GTK2=1 make_no_libbionic_O: make NO_LIBBIONIC=1 make_install_prefix_O: make install prefix=/tmp/krava make_no_libbpf_O: make NO_LIBBPF=1 make_no_libaudit_O: make NO_LIBAUDIT=1 make_with_babeltrace_O: make LIBBABELTRACE=1
Quoted 9 lines
make_no_libpython_O: make NO_LIBPYTHON=1
make_help_O: make help
make_doc_O: make doc
make_debug_O: make DEBUG=1
make_install_O: make install
OK
make: Leaving directory '/home/acme/git/linux/tools/perf'
$ Pulled, thanks a lot Arnaldo!
Ingo