perf/core fixes
hi Ingo,
please consider pulling.
As requested, sending only fixies for 3.15. I'll send the rest for 3.16.
thanks,
jirka
The following changes since commit 538592ff0b008237ae88f5ce5fb1247127dc3ce5:
Merge tag 'perf-core-for-mingo' of git://git.kernel.org/pub/scm/linux/kernel/git/acme/linux into perf/core (2014-03-19 08:05:47 +0100)
are available in the git repository at:
git://git.kernel.org/pub/scm/linux/kernel/git/jolsa/perf.git tags/perf-core-for-mingo
for you to fetch changes up to c12702d9bf3485d1b34c7913430b4e9271126561:
perf tools: Instead of redirecting flex output, use -o (2014-04-14 13:00:46 +0200)
----------------------------------------------------------------
perf/core fixes:
Documentation:
. Fix documentation of invalid 'perf top -s' option (Namhyung Kim)
. Change e-mail to kernel.org one in MAINTAINERS file (Arnaldo Carvalho de Melo)
. Update bench manpage to mention numa and futex (Ramkumar Ramachandra)
Developer stuff:
. Disable unwind libraries when libelf isn't found (Arnaldo Carvalho de Melo)
. Print event name when showing libtraceevent warnings if possible (Namhyung Kim)
. Pick up libdw without explicit LIBDW_DIR (Ramkumar Ramachandra)
. Fix perf bench all segfault (Ramkumar Ramachandra)
. Set more defaults in the 'numa' suite (Ramkumar Ramachandra)
. Fix double free in perf test 21 (Adrian Hunter)
. Initialize statistics correctly (Andi Kleen)
. Instead of redirecting flex output, use -o (Cody P Schafer)
User visible:
. Assorted perf probe fixies (Namhyung Kim)
. Fix perf probe segfault (Masami Hiramatsu)
. Fix metrics calculation with event qualifiers (Andi Kleen)
. Search for modules in %s/lib/modules/%s (Richard Yao)
----------------------------------------------------------------
Adrian Hunter (1):
perf tools: Fix double free in perf test 21 (code-reading.c)
Andi Kleen (2):
perf stat: Initialize statistics correctly
perf tools: Fix metrics calculation with event qualifiers
Arnaldo Carvalho de Melo (2):
perf callchains: Disable unwind libraries when libelf isn't found
MAINTAINERS: Change e-mail to kernel.org one
Cody P Schafer (1):
perf tools: Instead of redirecting flex output, use -o
Masami Hiramatsu (1):
perf probe: Fix to handle errors in line_range searching
Namhyung Kim (5):
perf top: Fix documentation of invalid -s option
tools lib traceevent: Print event name when show warning if possible tools lib traceevent: Do not call warning() directly perf probe: Fix --line option behavior
perf probe: Use dwarf_getcfi_elf() instead of dwarf_getcfi()
Ramkumar Ramachandra (4):
perf tools: Pick up libdw without explicit LIBDW_DIR perf bench: Update manpage to mention numa and futex perf bench: Fix segfault at the end of an 'all' execution perf bench: Set more defaults in the 'numa' suite
Richard Yao (1):
perf machine: Search for modules in %s/lib/modules/%s
MAINTAINERS | 2 +- tools/lib/traceevent/event-parse.c | 109 +++++++++++++++---------- tools/perf/Documentation/perf-bench.txt | 22 +++++ tools/perf/Documentation/perf-top.txt | 1 - tools/perf/Makefile.perf | 4 +- tools/perf/bench/numa.c | 4 + tools/perf/builtin-bench.c | 2 +- tools/perf/builtin-stat.c | 140 ++++++++++++++++++++------------ tools/perf/config/Makefile | 7 +- tools/perf/tests/code-reading.c | 1 + tools/perf/util/machine.c | 2 +- tools/perf/util/probe-finder.c | 15 ++-- 12 files changed, 197 insertions(+), 112 deletions(-)
PATCH 1/17 perf top: Fix documentation of invalid -s option
From: Namhyung Kim <[email protected]>
On perf top, the -s option is used for --sort, but the man page contains invalid documentation of -s option for --sym-annotate.
--- tools/perf/Documentation/perf-top.txt | 1 - 1 file changed, 1 deletion(-)
tools/perf/Documentation/perf-top.txt +0 -1
@@ -87,7 +87,6 @@ Default is to monitor all CPUS. --realtime=<priority>:: Collect data with this RT SCHED_FIFO priority. --s <symbol>:: --sym-annotate=<symbol>:: Annotate this symbol.
Signature · 1 line
1.8.3.1
PATCH 2/17 tools lib traceevent: Print event name when show warning if possible
In reply to Jiri OlsaFrom: Namhyung Kim <[email protected]>
It's sometimes useful to know where the parse failure was occurred. Add do_warning_event() macro to see the failing event.
It now shows the messages like below:
$ perf test 5
5: parse events tests : Warning: [kvmmmu:kvm_mmu_get_page] bad op token {
Warning: [kvmmmu:kvm_mmu_sync_page] bad op token {
Warning: [kvmmmu:kvm_mmu_unsync_page] bad op token {
Warning: [kvmmmu:kvm_mmu_prepare_zap_page] bad op token {
Warning: [kvmmmu:fast_page_fault] function is_writable_pte not defined
Warning: [xen:xen_mmu_ptep_modify_prot_commit] function sizeof not defined
Warning: [xen:xen_mmu_ptep_modify_prot_start] function sizeof not defined
Warning: [xen:xen_mmu_set_pgd] function sizeof not defined
Warning: [xen:xen_mmu_set_pud] function sizeof not defined
Warning: [xen:xen_mmu_set_pmd] function sizeof not defined
...--- tools/lib/traceevent/event-parse.c | 103 ++++++++++++++++++++++--------------- 1 file changed, 62 insertions(+), 41 deletions(-)
tools/lib/traceevent/event-parse.c +62 -41
@@ -50,6 +50,18 @@ static int show_warning = 1; warning(fmt, ##__VA_ARGS__); \ } while (0) +#define do_warning_event (event, fmt, ...) \ + do { \ + if (!show_warning) \ + continue; \ + \ + if (event) \ + warning("[%s:%s] " fmt, event->system, \ + event->name, ##__VA_ARGS__); \ + else \ + warning(fmt, ##__VA_ARGS__); \ + } while (0) +static void init_input_buf (const char *buf,unsigned long long size) { input_buf = buf;
@@ -1355,7 +1367,7 @@ static int event_read_fields(struct event_format *event, struct format_field **f }if (!field->type) { -do_warning ("%s: no type found" , __func__); +do_warning_event (event,"%s: no type found" , __func__); goto fail; } field->name = last_token;
@@ -1402,7 +1414,7 @@ static int event_read_fields(struct event_format *event, struct format_field **ffree_token (token); type =read_token (&token);if (type ==EVENT_NONE ) { -do_warning ("failed to find token" ); +do_warning_event (event,"failed to find token" ); goto fail; } }
@@ -1636,7 +1648,7 @@ process_cond(struct event_format *event, struct print_arg *top, char **tok) right =alloc_arg ();if (!arg || !left || !right) { -do_warning ("%s: not enough memory!" , __func__); +do_warning_event (event,"%s: not enough memory!" , __func__);/* arg will be freed at out_free */ free_arg (left);free_arg (right);
@@ -1686,7 +1698,7 @@ process_array(struct event_format *event, struct print_arg *top, char **tok) arg =alloc_arg ();if (!arg) { -do_warning ("%s: not enough memory!" , __func__); +do_warning_event (event,"%s: not enough memory!" , __func__);/* '*tok' is set to top->op.op. No need to free. */ *tok =NULL ;return EVENT_ERROR ;
@@ -1792,7 +1804,7 @@ process_op(struct event_format *event, struct print_arg *arg, char **tok)if (arg->type ==PRINT_OP && !arg->op.left) {/* handle single op */ if (token[1 ]) { -do_warning ("bad op token %s" , token); +do_warning_event (event,"bad op token %s" , token); goto out_free; }switch (token[0 ]) {
@@ -1802,7 +1814,7 @@ process_op(struct event_format *event, struct print_arg *arg, char **tok)case '-' :break ;default : -do_warning ("bad op token %s" , token); +do_warning_event (event,"bad op token %s" , token); goto out_free; }
@@ -1888,7 +1900,7 @@ process_op(struct event_format *event, struct print_arg *arg, char **tok)char *new_atom;if (left->type !=PRINT_ATOM ) { -do_warning ("bad pointer type" ); +do_warning_event (event,"bad pointer type" ); goto out_free; } new_atom = realloc(left->atom.atom,
@@ -1930,7 +1942,7 @@ process_op(struct event_format *event, struct print_arg *arg, char **tok) type =process_array (event, arg, tok); }else { -do_warning ("unknown op '%s'" , token); +do_warning_event (event,"unknown op '%s'" , token); event->flags |=EVENT_FL_FAILED ;/* the arg is now the left side */ goto out_free;
@@ -1951,7 +1963,7 @@ process_op(struct event_format *event, struct print_arg *arg, char **tok)return type; out_warn_free: -do_warning ("%s: not enough memory!" , __func__); +do_warning_event (event,"%s: not enough memory!" , __func__); out_free:free_token (token); *tok =NULL ;
@@ -2385,7 +2397,7 @@ process_flags(struct event_format *event, struct print_arg *arg, char **tok) field =alloc_arg ();if (!field) { -do_warning ("%s: not enough memory!" , __func__); +do_warning_event (event,"%s: not enough memory!" , __func__); goto out_free; }
@@ -2438,7 +2450,7 @@ process_symbols(struct event_format *event, struct print_arg *arg, char **tok) field =alloc_arg ();if (!field) { -do_warning ("%s: not enough memory!" , __func__); +do_warning_event (event,"%s: not enough memory!" , __func__); goto out_free; }
@@ -2477,7 +2489,7 @@ process_hex(struct event_format *event, struct print_arg *arg, char **tok) field =alloc_arg ();if (!field) { -do_warning ("%s: not enough memory!" , __func__); +do_warning_event (event,"%s: not enough memory!" , __func__); goto out_free; }
@@ -2492,7 +2504,7 @@ process_hex(struct event_format *event, struct print_arg *arg, char **tok) field =alloc_arg ();if (!field) { -do_warning ("%s: not enough memory!" , __func__); +do_warning_event (event,"%s: not enough memory!" , __func__); *tok =NULL ;return EVENT_ERROR ; }
@@ -2555,7 +2567,7 @@ process_dynamic_array(struct event_format *event, struct print_arg *arg, char **free_token (token); arg =alloc_arg ();if (!arg) { -do_warning ("%s: not enough memory!" , __func__); +do_warning_event (event,"%s: not enough memory!" , __func__); *tok =NULL ;return EVENT_ERROR ; }
@@ -2614,13 +2626,14 @@ process_paren(struct event_format *event, struct print_arg *arg, char **tok)/* prevous must be an atom */ if (arg->type !=PRINT_ATOM ) { -do_warning ("previous needed to be PRINT_ATOM" ); +do_warning_event (event,"previous needed to be PRINT_ATOM" ); goto out_free; } item_arg =alloc_arg ();if (!item_arg) { -do_warning ("%s: not enough memory!" , __func__); +do_warning_event (event,"%s: not enough memory!" , + __func__); goto out_free; }
@@ -2721,7 +2734,8 @@ process_func_handler(struct event_format *event, struct pevent_function_handlerfor (i =0 ; i < func->nr_args; i++) { farg =alloc_arg ();if (!farg) { -do_warning ("%s: not enough memory!" , __func__); +do_warning_event (event,"%s: not enough memory!" , + __func__);return EVENT_ERROR ; }
@@ -2792,7 +2806,7 @@ process_function(struct event_format *event, struct print_arg *arg,return process_func_handler (event, func, arg, tok); } -do_warning ("function %s not defined" , token); +do_warning_event (event,"function %s not defined" , token);free_token (token);return EVENT_ERROR ; }
@@ -2878,7 +2892,7 @@ process_arg_token(struct event_format *event, struct print_arg *arg, case EVENT_ERROR ... EVENT_NEWLINE:default : -do_warning ("unexpected type %d" , type); +do_warning_event (event,"unexpected type %d" , type);return EVENT_ERROR ; } *tok = token;
@@ -2901,7 +2915,8 @@ static int event_read_print_args(struct event_format *event, struct print_arg ** arg =alloc_arg ();if (!arg) { -do_warning ("%s: not enough memory!" , __func__); +do_warning_event (event,"%s: not enough memory!" , + __func__);return -1 ; }
@@ -3481,11 +3496,12 @@ eval_num_arg(void *data, int size, struct event_format *event, struct print_argreturn val; out_warning_op: -do_warning ("%s: unknown op '%s'" , __func__, arg->op.op); +do_warning_event (event,"%s: unknown op '%s'" , __func__, arg->op.op);return 0 ; out_warning_field: -do_warning ("%s: field %s not found" , __func__, arg->field.name); +do_warning_event (event,"%s: field %s not found" , + __func__, arg->field.name);return 0 ; }
@@ -3591,7 +3607,8 @@ static void print_str_arg(struct trace_seq *s, void *data, int size, } str =malloc (len +1 );if (!str) { -do_warning ("%s: not enough memory!" , __func__); +do_warning_event (event,"%s: not enough memory!" , + __func__);return ; }memcpy (str, data + field->offset, len);
@@ -3697,7 +3714,8 @@ static void print_str_arg(struct trace_seq *s, void *data, int size,return ; out_warning_field: -do_warning ("%s: field %s not found" , __func__, arg->field.name); +do_warning_event (event,"%s: field %s not found" , + __func__, arg->field.name); } static unsigned long long
@@ -3742,14 +3760,16 @@ process_defined_func(struct trace_seq *s, void *data, int size,trace_seq_terminate (&str); string =malloc (sizeof (*string));if (!string) { -do_warning ("%s(%d): malloc str" , __func__, __LINE__); +do_warning_event (event,"%s(%d): malloc str" , + __func__, __LINE__); goto out_free; } string->next = strings; string->str =strdup (str.buffer);if (!string->str) {free (string); -do_warning ("%s(%d): malloc str" , __func__, __LINE__); +do_warning_event (event,"%s(%d): malloc str" , + __func__, __LINE__); goto out_free; } args[i] = (uintptr_t )string->str;
@@ -3761,7 +3781,7 @@ process_defined_func(struct trace_seq *s, void *data, int size,* Something went totally wrong, this is not * an input error, something in this code broke. */ -do_warning ("Unexpected end of arguments\n" ); +do_warning_event (event,"Unexpected end of arguments\n" ); goto out_free; } farg = farg->next;
@@ -3811,12 +3831,12 @@ static struct print_arg *make_bprint_args(char *fmt, void *data, int size, strucif (!field) { field =pevent_find_field (event,"buf" );if (!field) { -do_warning ("can't find buffer field for binary printk" ); +do_warning_event (event,"can't find buffer field for binary printk" );return NULL ; } ip_field =pevent_find_field (event,"ip" );if (!ip_field) { -do_warning ("can't find ip field for binary printk" ); +do_warning_event (event,"can't find ip field for binary printk" );return NULL ; } pevent->bprint_buf_field = field;
@@ -3830,7 +3850,8 @@ static struct print_arg *make_bprint_args(char *fmt, void *data, int size, struc*/ args =alloc_arg ();if (!args) { -do_warning ("%s(%d): not enough memory!" , __func__, __LINE__); +do_warning_event (event,"%s(%d): not enough memory!" , + __func__, __LINE__);return NULL ; } arg = args;
@@ -3896,7 +3917,7 @@ static struct print_arg *make_bprint_args(char *fmt, void *data, int size, struc bptr += vsize; arg =alloc_arg ();if (!arg) { -do_warning ("%s(%d): not enough memory!" , +do_warning_event (event,"%s(%d): not enough memory!" , __func__, __LINE__); goto out_free; }
@@ -3919,7 +3940,7 @@ static struct print_arg *make_bprint_args(char *fmt, void *data, int size, struccase 's' : arg =alloc_arg ();if (!arg) { -do_warning ("%s(%d): not enough memory!" , +do_warning_event (event,"%s(%d): not enough memory!" , __func__, __LINE__); goto out_free; }
@@ -3959,7 +3980,7 @@ get_bprint_format(void *data, int size __maybe_unused,if (!field) { field =pevent_find_field (event,"fmt" );if (!field) { -do_warning ("can't find format field for binary printk" ); +do_warning_event (event,"can't find format field for binary printk" );return NULL ; } pevent->bprint_fmt_field = field;
@@ -4003,8 +4024,8 @@ static void print_mac_arg(struct trace_seq *s, int mac, void *data, int size, arg->field.field =pevent_find_any_field (event, arg->field.name);if (!arg->field.field) { -do_warning ("%s: field %s not found" , - __func__, arg->field.name); +do_warning_event (event,"%s: field %s not found" , + __func__, arg->field.name);return ; } }
@@ -4176,7 +4197,7 @@ static void pretty_print(struct trace_seq *s, void *data, int size, struct eventcase '*' :/* The argument is the length. */ if (!arg) { -do_warning ("no argument match" ); +do_warning_event (event,"no argument match" ); event->flags |=EVENT_FL_FAILED ; goto out_failed; }
@@ -4213,7 +4234,7 @@ static void pretty_print(struct trace_seq *s, void *data, int size, struct eventcase 'X' :case 'u' :if (!arg) { -do_warning ("no argument match" ); +do_warning_event (event,"no argument match" ); event->flags |=EVENT_FL_FAILED ; goto out_failed; }
@@ -4223,7 +4244,7 @@ static void pretty_print(struct trace_seq *s, void *data, int size, struct event/* should never happen */ if (len >31 ) { -do_warning ("bad format!" ); +do_warning_event (event,"bad format!" ); event->flags |=EVENT_FL_FAILED ; len =31 ; }
@@ -4290,13 +4311,13 @@ static void pretty_print(struct trace_seq *s, void *data, int size, struct eventtrace_seq_printf (s, format, (long long )val);break ;default : -do_warning ("bad count (%d)" , ls); +do_warning_event (event,"bad count (%d)" , ls); event->flags |=EVENT_FL_FAILED ; }break ;case 's' :if (!arg) { -do_warning ("no matching argument" ); +do_warning_event (event,"no matching argument" ); event->flags |=EVENT_FL_FAILED ; goto out_failed; }
@@ -4306,7 +4327,7 @@ static void pretty_print(struct trace_seq *s, void *data, int size, struct event/* should never happen */ if (len >31 ) { -do_warning ("bad format!" ); +do_warning_event (event,"bad format!" ); event->flags |=EVENT_FL_FAILED ; len =31 ; }
Signature · 1 line
1.8.3.1
PATCH 3/17 tools lib traceevent: Do not call warning() directly
In reply to Jiri OlsaFrom: Namhyung Kim <[email protected]>
The patch 3a3ffa2e82205 ("tools lib traceevent: Report better error message on bad function args") added the error message but it seems there's no reason to call warning() directly.
So change it to do_warning_event() to provide event information too.
--- tools/lib/traceevent/event-parse.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-)
tools/lib/traceevent/event-parse.c +4 -2
@@ -2742,14 +2742,16 @@ process_func_handler(struct event_format *event, struct pevent_function_handler type =process_arg (event, farg, &token);if (i < (func->nr_args -1 )) {if (type !=EVENT_DELIM ||strcmp (token,"," ) !=0 ) { -warning ("Error: function '%s()' expects %d arguments but event %s only uses %d" , +do_warning_event (event, +"Error: function '%s()' expects %d arguments but event %s only uses %d" , func->name, func->nr_args, event->name, i +1 ); goto err; } }else {if (type !=EVENT_DELIM ||strcmp (token,")" ) !=0 ) { -warning ("Error: function '%s()' only expects %d arguments but event %s has more" , +do_warning_event (event, +"Error: function '%s()' only expects %d arguments but event %s has more" , func->name, func->nr_args, event->name); goto err; }
Signature · 1 line
1.8.3.1
PATCH 4/17 perf callchains: Disable unwind libraries when libelf isn't found
In reply to Jiri OlsaFrom: Arnaldo Carvalho de Melo <[email protected]>
I.e. do the same as when NO_LIBELF is explicitely passed in the 'make' command line, fixing this:
Auto-detecting system features:
... dwarf: [ OFF ]
... glibc: [ on ]
... gtk2: [ OFF ]
... libaudit: [ OFF ]
... libbfd: [ OFF ]
... libelf: [ OFF ]
... libunwind: [ OFF ]
... libdw-dwarf-unwind: [ OFF ]
... DWARF post unwind library: libdw
<SNIP>
CC /tmp/build/perf/util/symbol-minimal.o
CC /tmp/build/perf/util/unwind-libdw.o
arch/x86/util/unwind-libdw.c:1:30: fatal error: elfutils/libdwfl.h: No such file or directory compilation terminated.
CC /tmp/build/perf/tests/keep-tracking.o
util/unwind-libdw.c:2:28: fatal error: elfutils/libdw.h: No such file or directory compilation terminated.
--- tools/perf/config/Makefile | 2 ++ 1 file changed, 2 insertions(+)
tools/perf/config/Makefile +2 -0
@@ -278,6 +278,8 @@ else NO_LIBELF := 1 NO_DWARF := 1 NO_DEMANGLE := 1 + NO_LIBUNWIND := 1 + NO_LIBDW_DWARF_UNWIND := 1 else msg := $(error No gnu/libc-version.h found, please install glibc-dev[el]/glibc-static); endif
Signature · 1 line
1.8.3.1
PATCH 5/17 MAINTAINERS: Change e-mail to kernel.org one
In reply to Jiri OlsaFrom: Arnaldo Carvalho de Melo <[email protected]>
Leaving ghostprotocols.net for old networking stuff.
--- MAINTAINERS | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
MAINTAINERS +1 -1
@@ -6678,7 +6678,7 @@ PERFORMANCE EVENTS SUBSYSTEM M: Peter Zijlstra <[email protected]> M: Paul Mackerras <[email protected]> M: Ingo Molnar <[email protected]> -M: Arnaldo Carvalho de Melo <[email protected]> +M: Arnaldo Carvalho de Melo <[email protected]> L: [email protected] T: git git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip.git perf/core S: Supported
Signature · 1 line
1.8.3.1
PATCH 6/17 perf tools: Pick up libdw without explicit LIBDW_DIR
In reply to Jiri OlsaFrom: Ramkumar Ramachandra <[email protected]>
The Makefile logic sets FEATURE_CHECKS_CFLAGS-libdw-dwarf-unwind and FEATURE_CHECKS_LDFLAGS-libdw-dwarf-unwind only if LIBDW_DIR is defined. This means that under a normal setup,
$ make NO_LIBUNWIND=1
won't automatically pick up libdw. Fix this.
--- tools/perf/config/Makefile | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-)
tools/perf/config/Makefile +2 -3
@@ -65,10 +65,9 @@ ifndef NO_LIBELF ifdef LIBDW_DIR LIBDW_CFLAGS := -I$(LIBDW_DIR)/include LIBDW_LDFLAGS := -L$(LIBDW_DIR)/lib - - FEATURE_CHECK_CFLAGS-libdw-dwarf-unwind := $(LIBDW_CFLAGS) - FEATURE_CHECK_LDFLAGS-libdw-dwarf-unwind := $(LIBDW_LDFLAGS) -ldw endif + FEATURE_CHECK_CFLAGS-libdw-dwarf-unwind := $(LIBDW_CFLAGS) + FEATURE_CHECK_LDFLAGS-libdw-dwarf-unwind := $(LIBDW_LDFLAGS) -ldw endif # include ARCH specific config
Signature · 1 line
1.8.3.1
PATCH 7/17 perf probe: Fix --line option behavior
In reply to Jiri OlsaFrom: Namhyung Kim <[email protected]>
The commit 5a62257a3ddd1 ("perf probe: Replace line_list with intlist") replaced line_list to intlist but it has a problem that if a same line was added again, it'd return -EEXIST rather than 1.
Since line_range_walk_cb() only checks the result being negative, it resulted in failure or segfault sometimes.
--- tools/perf/util/probe-finder.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-)
tools/perf/util/probe-finder.c +4 -2
@@ -1441,13 +1441,15 @@ static int line_range_walk_cb(const char *fname, int lineno, void *data) {struct line_finder *lf = data; +int err;if ((strtailcmp (fname, lf->fname) !=0 ) || (lf->lno_s > lineno || lf->lno_e < lineno))return 0 ; -if (line_range_add_line (fname, lineno, lf->lr) <0 ) -return -EINVAL ; + err =line_range_add_line (fname, lineno, lf->lr); +if (err <0 && err != -EEXIST ) +return err;return 0 ; }
Signature · 1 line
1.8.3.1
PATCH 8/17 perf probe: Fix to handle errors in line_range searching
In reply to Jiri OlsaFrom: Masami Hiramatsu <[email protected]>
As Namhyung reported(https://lkml.org/lkml/2014/4/1/89), current perf-probe -L option doesn't handle errors in line-range searching correctly. It causes a SEGV if an error occured in the line-range searching.
----
$ perf probe -x ./perf -v -L map__load Open Debuginfo file: /home/namhyung/project/linux/tools/perf/perf fname: util/map.c, lineno:153 New line range: 153 to 2147483647 path: (null) Segmentation fault (core dumped) ----
This is because line_range_inline_cb() ignores errors from find_line_range_by_line() which means that lr->path is already freed on the error path in find_line_range_by_line(). As a result, get_real_path() accesses the lr->path and it causes a NULL pointer exception.
This fixes line_range_inline_cb() to handle the error correctly, and report it to the caller.
Anyway, this just fixes a possible SEGV bug, Namhyung's patch is also required.
--- tools/perf/util/probe-finder.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-)
tools/perf/util/probe-finder.c +4 -3
@@ -1475,14 +1475,15 @@ static int find_line_range_by_line(Dwarf_Die *sp_die, struct line_finder *lf)static int line_range_inline_cb (Dwarf_Die *in_die,void *data) { -find_line_range_by_line (in_die, data); +int ret =find_line_range_by_line (in_die, data);/* * We have to check all instances of inlined function, because * some execution paths can be optimized out depends on the -* function argument of instances +* function argument of instances. However, if an error occurs, +* it should be handled by the caller. */ -return 0 ; +return ret <0 ? ret :0 ; }/* Search function definition from function name */
Signature · 1 line
1.8.3.1
PATCH 9/17 perf probe: Use dwarf_getcfi_elf() instead of dwarf_getcfi()
In reply to Jiri OlsaFrom: Namhyung Kim <[email protected]>
The dwarf_getcfi() only checks .debug_frame section for CFI, but as most binaries only have .eh_frame it'd return NULL and it makes some variables inaccessible.
Using dwarf_getcfi_elf (along with dwarf_getelf()) allows to show and add probe to more variables.
--- tools/perf/util/probe-finder.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
tools/perf/util/probe-finder.c +1 -1
@@ -985,7 +985,7 @@ static int debuginfo__find_probes(struct debuginfo *dbg,#if _ELFUTILS_PREREQ (0 ,142 )/* Get the call frame information from this dwarf */ - pf->cfi =dwarf_getcfi (dbg->dbg); + pf->cfi =dwarf_getcfi_elf (dwarf_getelf (dbg->dbg));#endif off =0 ;
Signature · 1 line
1.8.3.1
PATCH 10/17 perf bench: Update manpage to mention numa and futex
In reply to Jiri OlsaFrom: Ramkumar Ramachandra <[email protected]>
--- tools/perf/Documentation/perf-bench.txt | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+)
tools/perf/Documentation/perf-bench.txt +22 -0
@@ -48,6 +48,12 @@ SUBSYSTEM 'mem':: Memory access performance. +'numa':: + NUMA scheduling and MM benchmarks. + +'futex':: + Futex stressing benchmarks. + 'all':: All benchmark subsystems.
@@ -187,6 +193,22 @@ Show only the result with page faults before memset. --no-prefault:: Show only the result without page faults before memset. +SUITES FOR 'numa' +~~~~~~~~~~~~~~~~~ +*mem*:: +Suite for evaluating NUMA workloads. + +SUITES FOR 'futex' +~~~~~~~~~~~~~~~~~~ +*hash*:: +Suite for evaluating hash tables. + +*wake*:: +Suite for evaluating wake calls. + +*requeue*:: +Suite for evaluating requeue calls. + SEE ALSO -------- linkperf:perf[1]
Signature · 1 line
1.8.3.1
PATCH 11/17 perf bench: Fix segfault at the end of an 'all' execution
In reply to Jiri OlsaFrom: Ramkumar Ramachandra <[email protected]>
At the end of
$ perf bench all
the program segfaults because it attempts to dereference a NULL pointer. Fix this fault.
--- tools/perf/builtin-bench.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
tools/perf/builtin-bench.c +1 -1
@@ -86,7 +86,7 @@ static struct collection collections[] = {/* Iterate over all benchmarks within a collection: */ #define for_each_bench (coll, bench) \ - for (bench = coll->benchmarks; bench->name; bench++) + for (bench = coll->benchmarks; bench && bench->name; bench++)static void dump_benchmarks (struct collection *coll) {
Signature · 1 line
1.8.3.1
PATCH 12/17 perf bench: Set more defaults in the 'numa' suite
In reply to Jiri OlsaFrom: Ramkumar Ramachandra <[email protected]>
Currently,
$ perf bench numa mem
errors out with usage information. To make this more user-friendly, let us provide a minimum set of default values required for a test run. As an added bonus,
$ perf bench all
now goes all the way to completion.
--- tools/perf/bench/numa.c | 4 ++++ 1 file changed, 4 insertions(+)
tools/perf/bench/numa.c +4 -0
@@ -1593,6 +1593,10 @@ static void init_params(struct params *p, const char *name, int argc, const char p->data_rand_walk = true; p->nr_loops =-1 ; p->init_random = true; + p->mb_global_str ="1" ; + p->nr_proc =1 ; + p->nr_threads =1 ; + p->nr_secs =5 ; }static int run_bench_numa (const char *name,const char **argv)
Signature · 1 line
1.8.3.1
PATCH 13/17 perf stat: Initialize statistics correctly
In reply to Jiri OlsaFrom: Andi Kleen <[email protected]>
perf stat did initialize the stats structure used to compute stddev etc. incorrectly. It merely zeroes it. But one member (min) needs to be set to a non zero value. This causes min to be not computed at all. Call init_stats() correctly.
It doesn't matter for stat currently because it doesn't use min, but it's still better to do it correctly.
The other users of statistics are already correct.
--- tools/perf/builtin-stat.c | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-)
tools/perf/builtin-stat.c +9 -2
@@ -174,13 +174,20 @@ static inline int perf_evsel__nr_cpus(struct perf_evsel *evsel)static void perf_evsel__reset_stat_priv (struct perf_evsel *evsel) { -memset (evsel->priv,0 ,sizeof (struct perf_stat )); +int i; +struct perf_stat *ps = evsel->priv; + +for (i =0 ; i <3 ; i++) +init_stats (&ps->res_stats[i]); }static int perf_evsel__alloc_stat_priv (struct perf_evsel *evsel) { evsel->priv =zalloc (sizeof (struct perf_stat )); -return evsel->priv ==NULL ? -ENOMEM :0 ; +if (evsel ==NULL ) +return -ENOMEM ; +perf_evsel__reset_stat_priv (evsel); +return 0 ; }static void perf_evsel__free_stat_priv (struct perf_evsel *evsel)
Signature · 1 line
1.8.3.1
PATCH 14/17 perf tools: Fix metrics calculation with event qualifiers
In reply to Jiri OlsaFrom: Andi Kleen <[email protected]>
Currently in perf IPC and other metrics cannot be directly shown separately for both user and kernel in a single run. The problem was that the metrics matching code did not check event qualifiers.
With this patch the following case works correctly.
% perf stat -e cycles:k,cycles:u,instructions:k,instructions:u true
Performance counter stats for 'true':
531,718 cycles:k
203,895 cycles:u
338,151 instructions:k # 0.64 insns per cycle
105,961 instructions:u # 0.52 insns per cycle0.002989739 seconds time elapsed
Previously it would misreport the ratios because they were matching the wrong value.
The patch is fairly big, but quite mechanic as it just adds context indexes everywhere.
I didn't support Hypervisor. It's not clear it's worth it.
--- tools/perf/builtin-stat.c | 129 +++++++++++++++++++++++++++------------------- 1 file changed, 77 insertions(+), 52 deletions(-)
tools/perf/builtin-stat.c +77 -52
@@ -246,21 +246,35 @@ out_free:return -1 ; } +#define NUM_CTX 3 + +enum {CTX_USER ,CTX_KERNEL ,CTX_ALL }; +static struct stats runtime_nsecs_stats[MAX_NR_CPUS ]; -static struct stats runtime_cycles_stats[MAX_NR_CPUS ]; -static struct stats runtime_stalled_cycles_front_stats[MAX_NR_CPUS ]; -static struct stats runtime_stalled_cycles_back_stats[MAX_NR_CPUS ]; -static struct stats runtime_branches_stats[MAX_NR_CPUS ]; -static struct stats runtime_cacherefs_stats[MAX_NR_CPUS ]; -static struct stats runtime_l1_dcache_stats[MAX_NR_CPUS ]; -static struct stats runtime_l1_icache_stats[MAX_NR_CPUS ]; -static struct stats runtime_ll_cache_stats[MAX_NR_CPUS ]; -static struct stats runtime_itlb_cache_stats[MAX_NR_CPUS ]; -static struct stats runtime_dtlb_cache_stats[MAX_NR_CPUS ]; -static struct stats runtime_cycles_in_tx_stats[MAX_NR_CPUS ]; +static struct stats runtime_cycles_stats[NUM_CTX ][MAX_NR_CPUS ]; +static struct stats runtime_stalled_cycles_front_stats[NUM_CTX ][MAX_NR_CPUS ]; +static struct stats runtime_stalled_cycles_back_stats[NUM_CTX ][MAX_NR_CPUS ]; +static struct stats runtime_branches_stats[NUM_CTX ][MAX_NR_CPUS ]; +static struct stats runtime_cacherefs_stats[NUM_CTX ][MAX_NR_CPUS ]; +static struct stats runtime_l1_dcache_stats[NUM_CTX ][MAX_NR_CPUS ]; +static struct stats runtime_l1_icache_stats[NUM_CTX ][MAX_NR_CPUS ]; +static struct stats runtime_ll_cache_stats[NUM_CTX ][MAX_NR_CPUS ]; +static struct stats runtime_itlb_cache_stats[NUM_CTX ][MAX_NR_CPUS ]; +static struct stats runtime_dtlb_cache_stats[NUM_CTX ][MAX_NR_CPUS ]; +static struct stats runtime_cycles_in_tx_stats[NUM_CTX ][MAX_NR_CPUS ];static struct stats walltime_nsecs_stats; -static struct stats runtime_transaction_stats[MAX_NR_CPUS ]; -static struct stats runtime_elision_stats[MAX_NR_CPUS ]; +static struct stats runtime_transaction_stats[NUM_CTX ][MAX_NR_CPUS ]; +static struct stats runtime_elision_stats[NUM_CTX ][MAX_NR_CPUS ]; + +static int evsel_context (struct perf_evsel *evsel) +{ +if (evsel->attr.exclude_kernel) +return CTX_USER ; +if (evsel->attr.exclude_user) +return CTX_KERNEL ; +/* Handle hypervisor too? */ +return CTX_ALL ; +}static void perf_stat__reset_stats (struct perf_evlist *evlist) {
@@ -354,37 +368,39 @@ static struct perf_evsel *nth_evsel(int n)*/ static void update_shadow_stats (struct perf_evsel *counter,u64 *count) { +int ctx =evsel_context (counter); +if (perf_evsel__match (counter,SOFTWARE ,SW_TASK_CLOCK ))update_stats (&runtime_nsecs_stats[0 ], count[0 ]);else if (perf_evsel__match (counter,HARDWARE ,HW_CPU_CYCLES )) -update_stats (&runtime_cycles_stats[0 ], count[0 ]); +update_stats (&runtime_cycles_stats[ctx][0 ], count[0 ]);else if (transaction_run &&perf_evsel__cmp (counter,nth_evsel (T_CYCLES_IN_TX ))) -update_stats (&runtime_cycles_in_tx_stats[0 ], count[0 ]); +update_stats (&runtime_cycles_in_tx_stats[ctx][0 ], count[0 ]);else if (transaction_run &&perf_evsel__cmp (counter,nth_evsel (T_TRANSACTION_START ))) -update_stats (&runtime_transaction_stats[0 ], count[0 ]); +update_stats (&runtime_transaction_stats[ctx][0 ], count[0 ]);else if (transaction_run &&perf_evsel__cmp (counter,nth_evsel (T_ELISION_START ))) -update_stats (&runtime_elision_stats[0 ], count[0 ]); +update_stats (&runtime_elision_stats[ctx][0 ], count[0 ]);else if (perf_evsel__match (counter,HARDWARE ,HW_STALLED_CYCLES_FRONTEND )) -update_stats (&runtime_stalled_cycles_front_stats[0 ], count[0 ]); +update_stats (&runtime_stalled_cycles_front_stats[ctx][0 ], count[0 ]);else if (perf_evsel__match (counter,HARDWARE ,HW_STALLED_CYCLES_BACKEND )) -update_stats (&runtime_stalled_cycles_back_stats[0 ], count[0 ]); +update_stats (&runtime_stalled_cycles_back_stats[ctx][0 ], count[0 ]);else if (perf_evsel__match (counter,HARDWARE ,HW_BRANCH_INSTRUCTIONS )) -update_stats (&runtime_branches_stats[0 ], count[0 ]); +update_stats (&runtime_branches_stats[ctx][0 ], count[0 ]);else if (perf_evsel__match (counter,HARDWARE ,HW_CACHE_REFERENCES )) -update_stats (&runtime_cacherefs_stats[0 ], count[0 ]); +update_stats (&runtime_cacherefs_stats[ctx][0 ], count[0 ]);else if (perf_evsel__match (counter,HW_CACHE ,HW_CACHE_L1D )) -update_stats (&runtime_l1_dcache_stats[0 ], count[0 ]); +update_stats (&runtime_l1_dcache_stats[ctx][0 ], count[0 ]);else if (perf_evsel__match (counter,HW_CACHE ,HW_CACHE_L1I )) -update_stats (&runtime_l1_icache_stats[0 ], count[0 ]); +update_stats (&runtime_l1_icache_stats[ctx][0 ], count[0 ]);else if (perf_evsel__match (counter,HW_CACHE ,HW_CACHE_LL )) -update_stats (&runtime_ll_cache_stats[0 ], count[0 ]); +update_stats (&runtime_ll_cache_stats[ctx][0 ], count[0 ]);else if (perf_evsel__match (counter,HW_CACHE ,HW_CACHE_DTLB )) -update_stats (&runtime_dtlb_cache_stats[0 ], count[0 ]); +update_stats (&runtime_dtlb_cache_stats[ctx][0 ], count[0 ]);else if (perf_evsel__match (counter,HW_CACHE ,HW_CACHE_ITLB )) -update_stats (&runtime_itlb_cache_stats[0 ], count[0 ]); +update_stats (&runtime_itlb_cache_stats[ctx][0 ], count[0 ]); }/*
@@ -801,8 +817,9 @@ static void print_stalled_cycles_frontend(int cpu, {double total, ratio =0.0 ;const char *color; +int ctx =evsel_context (evsel); - total =avg_stats (&runtime_cycles_stats[cpu]); + total =avg_stats (&runtime_cycles_stats[ctx][cpu]);if (total) ratio = avg / total *100.0 ;
@@ -820,8 +837,9 @@ static void print_stalled_cycles_backend(int cpu, {double total, ratio =0.0 ;const char *color; +int ctx =evsel_context (evsel); - total =avg_stats (&runtime_cycles_stats[cpu]); + total =avg_stats (&runtime_cycles_stats[ctx][cpu]);if (total) ratio = avg / total *100.0 ;
@@ -839,8 +857,9 @@ static void print_branch_misses(int cpu, {double total, ratio =0.0 ;const char *color; +int ctx =evsel_context (evsel); - total =avg_stats (&runtime_branches_stats[cpu]); + total =avg_stats (&runtime_branches_stats[ctx][cpu]);if (total) ratio = avg / total *100.0 ;
@@ -858,8 +877,9 @@ static void print_l1_dcache_misses(int cpu, {double total, ratio =0.0 ;const char *color; +int ctx =evsel_context (evsel); - total =avg_stats (&runtime_l1_dcache_stats[cpu]); + total =avg_stats (&runtime_l1_dcache_stats[ctx][cpu]);if (total) ratio = avg / total *100.0 ;
@@ -877,8 +897,9 @@ static void print_l1_icache_misses(int cpu, {double total, ratio =0.0 ;const char *color; +int ctx =evsel_context (evsel); - total =avg_stats (&runtime_l1_icache_stats[cpu]); + total =avg_stats (&runtime_l1_icache_stats[ctx][cpu]);if (total) ratio = avg / total *100.0 ;
@@ -896,8 +917,9 @@ static void print_dtlb_cache_misses(int cpu, {double total, ratio =0.0 ;const char *color; +int ctx =evsel_context (evsel); - total =avg_stats (&runtime_dtlb_cache_stats[cpu]); + total =avg_stats (&runtime_dtlb_cache_stats[ctx][cpu]);if (total) ratio = avg / total *100.0 ;
@@ -915,8 +937,9 @@ static void print_itlb_cache_misses(int cpu, {double total, ratio =0.0 ;const char *color; +int ctx =evsel_context (evsel); - total =avg_stats (&runtime_itlb_cache_stats[cpu]); + total =avg_stats (&runtime_itlb_cache_stats[ctx][cpu]);if (total) ratio = avg / total *100.0 ;
@@ -934,8 +957,9 @@ static void print_ll_cache_misses(int cpu, {double total, ratio =0.0 ;const char *color; +int ctx =evsel_context (evsel); - total =avg_stats (&runtime_ll_cache_stats[cpu]); + total =avg_stats (&runtime_ll_cache_stats[ctx][cpu]);if (total) ratio = avg / total *100.0 ;
@@ -952,6 +976,7 @@ static void abs_printout(int cpu, int nr, struct perf_evsel *evsel, double avg)double total, ratio =0.0 , total2;double sc = evsel->scale;const char *fmt; +int ctx =evsel_context (evsel);if (csv_output) { fmt = sc !=1.0 ?"%.2f%s" :"%.0f%s" ;
@@ -983,13 +1008,13 @@ static void abs_printout(int cpu, int nr, struct perf_evsel *evsel, double avg)return ;if (perf_evsel__match (evsel,HARDWARE ,HW_INSTRUCTIONS )) { - total =avg_stats (&runtime_cycles_stats[cpu]); + total =avg_stats (&runtime_cycles_stats[ctx][cpu]);if (total) { ratio = avg / total;fprintf (output," # %5.2f insns per cycle " , ratio); } - total =avg_stats (&runtime_stalled_cycles_front_stats[cpu]); - total =max (total,avg_stats (&runtime_stalled_cycles_back_stats[cpu])); + total =avg_stats (&runtime_stalled_cycles_front_stats[ctx][cpu]); + total =max (total,avg_stats (&runtime_stalled_cycles_back_stats[ctx][cpu]));if (total && avg) { ratio = total / avg;
@@ -1000,46 +1025,46 @@ static void abs_printout(int cpu, int nr, struct perf_evsel *evsel, double avg) } }else if (perf_evsel__match (evsel,HARDWARE ,HW_BRANCH_MISSES ) && - runtime_branches_stats[cpu].n !=0 ) { + runtime_branches_stats[ctx][cpu].n !=0 ) {print_branch_misses (cpu, evsel, avg); }else if ( evsel->attr.type ==PERF_TYPE_HW_CACHE && evsel->attr.config == (PERF_COUNT_HW_CACHE_L1D | ((PERF_COUNT_HW_CACHE_OP_READ ) <<8 ) | ((PERF_COUNT_HW_CACHE_RESULT_MISS ) <<16 )) && - runtime_l1_dcache_stats[cpu].n !=0 ) { + runtime_l1_dcache_stats[ctx][cpu].n !=0 ) {print_l1_dcache_misses (cpu, evsel, avg); }else if ( evsel->attr.type ==PERF_TYPE_HW_CACHE && evsel->attr.config == (PERF_COUNT_HW_CACHE_L1I | ((PERF_COUNT_HW_CACHE_OP_READ ) <<8 ) | ((PERF_COUNT_HW_CACHE_RESULT_MISS ) <<16 )) && - runtime_l1_icache_stats[cpu].n !=0 ) { + runtime_l1_icache_stats[ctx][cpu].n !=0 ) {print_l1_icache_misses (cpu, evsel, avg); }else if ( evsel->attr.type ==PERF_TYPE_HW_CACHE && evsel->attr.config == (PERF_COUNT_HW_CACHE_DTLB | ((PERF_COUNT_HW_CACHE_OP_READ ) <<8 ) | ((PERF_COUNT_HW_CACHE_RESULT_MISS ) <<16 )) && - runtime_dtlb_cache_stats[cpu].n !=0 ) { + runtime_dtlb_cache_stats[ctx][cpu].n !=0 ) {print_dtlb_cache_misses (cpu, evsel, avg); }else if ( evsel->attr.type ==PERF_TYPE_HW_CACHE && evsel->attr.config == (PERF_COUNT_HW_CACHE_ITLB | ((PERF_COUNT_HW_CACHE_OP_READ ) <<8 ) | ((PERF_COUNT_HW_CACHE_RESULT_MISS ) <<16 )) && - runtime_itlb_cache_stats[cpu].n !=0 ) { + runtime_itlb_cache_stats[ctx][cpu].n !=0 ) {print_itlb_cache_misses (cpu, evsel, avg); }else if ( evsel->attr.type ==PERF_TYPE_HW_CACHE && evsel->attr.config == (PERF_COUNT_HW_CACHE_LL | ((PERF_COUNT_HW_CACHE_OP_READ ) <<8 ) | ((PERF_COUNT_HW_CACHE_RESULT_MISS ) <<16 )) && - runtime_ll_cache_stats[cpu].n !=0 ) { + runtime_ll_cache_stats[ctx][cpu].n !=0 ) {print_ll_cache_misses (cpu, evsel, avg); }else if (perf_evsel__match (evsel,HARDWARE ,HW_CACHE_MISSES ) && - runtime_cacherefs_stats[cpu].n !=0 ) { - total =avg_stats (&runtime_cacherefs_stats[cpu]); + runtime_cacherefs_stats[ctx][cpu].n !=0 ) { + total =avg_stats (&runtime_cacherefs_stats[ctx][cpu]);if (total) ratio = avg *100 / total;
@@ -1059,15 +1084,15 @@ static void abs_printout(int cpu, int nr, struct perf_evsel *evsel, double avg) } }else if (transaction_run &&perf_evsel__cmp (evsel,nth_evsel (T_CYCLES_IN_TX ))) { - total =avg_stats (&runtime_cycles_stats[cpu]); + total =avg_stats (&runtime_cycles_stats[ctx][cpu]);if (total)fprintf (output," # %5.2f%% transactional cycles " ,100.0 * (avg / total)); }else if (transaction_run &&perf_evsel__cmp (evsel,nth_evsel (T_CYCLES_IN_TX_CP ))) { - total =avg_stats (&runtime_cycles_stats[cpu]); - total2 =avg_stats (&runtime_cycles_in_tx_stats[cpu]); + total =avg_stats (&runtime_cycles_stats[ctx][cpu]); + total2 =avg_stats (&runtime_cycles_in_tx_stats[ctx][cpu]);if (total2 < avg) total2 = avg;if (total)
@@ -1077,8 +1102,8 @@ static void abs_printout(int cpu, int nr, struct perf_evsel *evsel, double avg) }else if (transaction_run &&perf_evsel__cmp (evsel,nth_evsel (T_TRANSACTION_START )) && avg >0 && - runtime_cycles_in_tx_stats[cpu].n !=0 ) { - total =avg_stats (&runtime_cycles_in_tx_stats[cpu]); + runtime_cycles_in_tx_stats[ctx][cpu].n !=0 ) { + total =avg_stats (&runtime_cycles_in_tx_stats[ctx][cpu]);if (total) ratio = total / avg;
@@ -1087,8 +1112,8 @@ static void abs_printout(int cpu, int nr, struct perf_evsel *evsel, double avg) }else if (transaction_run &&perf_evsel__cmp (evsel,nth_evsel (T_ELISION_START )) && avg >0 && - runtime_cycles_in_tx_stats[cpu].n !=0 ) { - total =avg_stats (&runtime_cycles_in_tx_stats[cpu]); + runtime_cycles_in_tx_stats[ctx][cpu].n !=0 ) { + total =avg_stats (&runtime_cycles_in_tx_stats[ctx][cpu]);if (total) ratio = total / avg;
Signature · 1 line
1.8.3.1
Re: [PATCH 14/17] perf tools: Fix metrics calculation with event qualifiers
Quoted 27 lines · Jiri Olsa
From: Andi Kleen <[email protected]>
Currently in perf IPC and other metrics cannot be directly shown separately for both user and kernel in a single run. The problem was that the metrics matching code did not check event qualifiers.
With this patch the following case works correctly.
% perf stat -e cycles:k,cycles:u,instructions:k,instructions:u true
Performance counter stats for 'true':
531,718 cycles:k 203,895 cycles:u 338,151 instructions:k # 0.64 insns per cycle 105,961 instructions:u # 0.52 insns per cycle0.002989739 seconds time elapsedPreviously it would misreport the ratios because they were matching the wrong value.
The patch is fairly big, but quite mechanic as it just adds context indexes everywhere.
I didn't support Hypervisor. It's not clear it's worth it.
tools/perf/builtin-stat.c out_free: · line 276
Quoted 8 lines
tools/perf/builtin-stat.c +8
-0+static int evsel_context (struct perf_evsel *evsel) +{ +if (evsel->attr.exclude_kernel) +return CTX_USER ; +if (evsel->attr.exclude_user) +return CTX_KERNEL ; +/* Handle hypervisor too? */ +return CTX_ALL ;
This fix is incomplete, as there are a whole lot of other cases:
exclude_user : 1, /* don't count user */
exclude_kernel : 1, /* ditto kernel */
exclude_hv : 1, /* ditto hypervisor */
exclude_idle : 1, /* don't count when idle */ exclude_host : 1, /* don't count in host */
exclude_guest : 1, /* don't count in guest */Many of which can be triggered via current event selectors.
Thanks,
Ingo
PATCH 15/17 perf tools: Fix double free in perf test 21 (code-reading.c)
In reply to Jiri OlsaFrom: Adrian Hunter <[email protected]>
perf_evlist__delete() deletes attached cpu and thread maps but the test is still using them, so remove them from the evlist before deleting it.
--- tools/perf/tests/code-reading.c | 1 + 1 file changed, 1 insertion(+)
tools/perf/tests/code-reading.c +1 -0
@@ -504,6 +504,7 @@ static int do_test_code_reading(bool try_kcore)if (ret <0 ) {if (!excl_kernel) { excl_kernel = true; +perf_evlist__set_maps (evlist,NULL ,NULL );perf_evlist__delete (evlist); evlist =NULL ;continue ;
Signature · 1 line
1.8.3.1
PATCH 16/17 perf machine: Search for modules in %s/lib/modules/%s
In reply to Jiri OlsaFrom: Richard Yao <[email protected]>
Modules installed outside of the kernel's build system should go into "%s/lib/modules/%s/extra", but at present, perf will only look at them when they are in "%s/lib/modules/%s/kernel". Lets encourage good citizenship by relaxing this requirement to "%s/lib/modules/%s". This way open source modules that are out-of-tree have no incentive to start populating a directory reserved for in-kernle modules and I can stop hex editing my system's perf binary when profiling OSS out-of-tree modules.
--- tools/perf/util/machine.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
tools/perf/util/machine.c +1 -1
@@ -786,7 +786,7 @@ static int machine__set_modules_path(struct machine *machine)if (!version)return -1 ; -snprintf (modules_path,sizeof (modules_path),"%s/lib/modules/%s/kernel" , +snprintf (modules_path,sizeof (modules_path),"%s/lib/modules/%s" , machine->root_dir, version);free (version);
Signature · 1 line
1.8.3.1
PATCH 17/17 perf tools: Instead of redirecting flex output, use -o
In reply to Jiri OlsaFrom: Cody P Schafer <[email protected]>
This gives us a real filename instead of having '<stdout>' show up all over the place when debugging.
--- tools/perf/Makefile.perf | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
tools/perf/Makefile.perf +2 -2
@@ -192,13 +192,13 @@ endif export PERL_PATH $(OUTPUT)util/parse-events-flex.c: util/parse-events.l $(OUTPUT)util/parse-events-bison.c - $(QUIET_FLEX)$(FLEX) --header-file=$(OUTPUT)util/parse-events-flex.h $(PARSER_DEBUG_FLEX) -t util/parse-events.l > $(OUTPUT)util/parse-events-flex.c + $(QUIET_FLEX)$(FLEX) -o $@ --header-file=$(OUTPUT)util/parse-events-flex.h $(PARSER_DEBUG_FLEX) util/parse-events.l $(OUTPUT)util/parse-events-bison.c: util/parse-events.y $(QUIET_BISON)$(BISON) -v util/parse-events.y -d $(PARSER_DEBUG_BISON) -o $(OUTPUT)util/parse-events-bison.c -p parse_events_ $(OUTPUT)util/pmu-flex.c: util/pmu.l $(OUTPUT)util/pmu-bison.c - $(QUIET_FLEX)$(FLEX) --header-file=$(OUTPUT)util/pmu-flex.h -t util/pmu.l > $(OUTPUT)util/pmu-flex.c + $(QUIET_FLEX)$(FLEX) -o $@ --header-file=$(OUTPUT)util/pmu-flex.h util/pmu.l $(OUTPUT)util/pmu-bison.c: util/pmu.y $(QUIET_BISON)$(BISON) -v util/pmu.y -d -o $(OUTPUT)util/pmu-bison.c -p perf_pmu_
Signature · 1 line
1.8.3.1
Quoted 97 lines · Jiri Olsa
hi Ingo,
please consider pulling.As requested, sending only fixies for 3.15. I'll send the rest for 3.16.
thanks,
jirkaThe following changes since commit
538592ff0b008237ae88f5ce5fb1247127dc3ce5:Merge tag 'perf-core-for-mingo' of
git://git.kernel.org/pub/scm/linux/kernel/git/acme/linuxinto perf/core (2014-03-19 08:05:47 +0100)are available in the git repository at:
git://git.kernel.org/pub/scm/linux/kernel/git/jolsa/perf.gittags/perf-core-for-mingofor you to fetch changes up to
c12702d9bf3485d1b34c7913430b4e9271126561:perf tools: Instead of redirecting flex output, use -o (2014-04-14 13:00:46 +0200)
----------------------------------------------------------------
perf/core fixes:Documentation:
. Fix documentation of invalid 'perf top -s' option (Namhyung Kim)
. Change e-mail to kernel.org one in
MAINTAINERSfile (Arnaldo Carvalho de Melo). Update bench manpage to mention numa and futex (Ramkumar Ramachandra)
Developer stuff:
. Disable unwind libraries when libelf isn't found (Arnaldo Carvalho de Melo)
. Print event name when showing libtraceevent warnings if possible (Namhyung Kim)
. Pick up libdw without explicit
LIBDW_DIR(Ramkumar Ramachandra). Fix perf bench all segfault (Ramkumar Ramachandra)
. Set more defaults in the 'numa' suite (Ramkumar Ramachandra)
. Fix double free in perf test 21 (Adrian Hunter)
. Initialize statistics correctly (Andi Kleen)
. Instead of redirecting flex output, use -o (Cody P Schafer)
User visible:
. Assorted perf probe fixies (Namhyung Kim)
. Fix perf probe segfault (Masami Hiramatsu)
. Fix metrics calculation with event qualifiers (Andi Kleen)
. Search for modules in %s/lib/modules/%s (Richard Yao)
Signed-off-by Jiri Olsa <[email protected]>----------------------------------------------------------------
Adrian Hunter (1):
perf tools: Fix double free in perf test 21 (code-reading.c)Andi Kleen (2):
perf stat: Initialize statistics correctly
perf tools: Fix metrics calculation with event qualifiersArnaldo Carvalho de Melo (2):
perf callchains: Disable unwind libraries when libelf isn't found
MAINTAINERS: Change e-mail to kernel.org oneCody P Schafer (1):
perf tools: Instead of redirecting flex output, use -oMasami Hiramatsu (1):
perf probe: Fix to handle errors inline_rangesearchingNamhyung Kim (5):
perf top: Fix documentation of invalid -s option
tools lib traceevent: Print event name when show warning if possible tools lib traceevent: Do not callwarning()directly perf probe: Fix --line option behavior
perf probe: Usedwarf_getcfi_elf()instead ofdwarf_getcfi()Ramkumar Ramachandra (4):
perf tools: Pick up libdw without explicitLIBDW_DIRperf bench: Update manpage to mention numa and futex perf bench: Fix segfault at the end of an 'all' execution perf bench: Set more defaults in the 'numa' suiteRichard Yao (1):
perf machine: Search for modules in %s/lib/modules/%s
Quoted 13 lines
MAINTAINERS | 2 +- tools/lib/traceevent/event-parse.c | 109 +++++++++++++++---------- tools/perf/Documentation/perf-bench.txt | 22 +++++ tools/perf/Documentation/perf-top.txt | 1 - tools/perf/Makefile.perf | 4 +- tools/perf/bench/numa.c | 4 + tools/perf/builtin-bench.c | 2 +- tools/perf/builtin-stat.c | 140 ++++++++++++++++++++------------ tools/perf/config/Makefile | 7 +- tools/perf/tests/code-reading.c | 1 + tools/perf/util/machine.c | 2 +- tools/perf/util/probe-finder.c | 15 ++-- 12 files changed, 197 insertions(+), 112 deletions(-)
I've pulled most of the patches, up to patch #13, thanks Jiri!
I left out #14 because it seems incomplete to me - see my previous mail.
You could rebase #15,16,17 on top of #13 to get the rest to me as well, until #14 is resolved.
Thanks!
Ingo
On Mon, Apr 14, 2014 at 04:42:36PM +0200, Ingo Molnar wrote:
SNIP
Quoted 16 lines
Quoted 15 lines
perf machine: Search for modules in %s/lib/modules/%s
MAINTAINERS | 2 +- tools/lib/traceevent/event-parse.c | 109 +++++++++++++++---------- tools/perf/Documentation/perf-bench.txt | 22 +++++ tools/perf/Documentation/perf-top.txt | 1 - tools/perf/Makefile.perf | 4 +- tools/perf/bench/numa.c | 4 + tools/perf/builtin-bench.c | 2 +- tools/perf/builtin-stat.c | 140 ++++++++++++++++++++------------ tools/perf/config/Makefile | 7 +- tools/perf/tests/code-reading.c | 1 + tools/perf/util/machine.c | 2 +- tools/perf/util/probe-finder.c | 15 ++-- 12 files changed, 197 insertions(+), 112 deletions(-)
Quoted 7 lines
I've pulled most of the patches, up to patch #13, thanks Jiri!
I left out #14 because it seems incomplete to me - see my previous mail.
You could rebase #15,16,17 on top of #13 to get the rest to me as well, until #14 is resolved.
ok, will do
thanks,
jirka