aboutsummaryrefslogtreecommitdiffstats
path: root/tools
diff options
context:
space:
mode:
authorIngo Molnar <mingo@kernel.org>2013-07-23 03:37:33 -0400
committerIngo Molnar <mingo@kernel.org>2013-07-23 03:37:33 -0400
commit4f16d61f80d77a7c44bdf0b9ceccdb304e4c890f (patch)
treec01080efc6f4c25114e3e9183de8fcce241da9d6 /tools
parentea8596bb2d8d37957f3e92db9511c50801689180 (diff)
parentf9ea55d0ddf66ed030b2a478625cd5792d30df16 (diff)
Merge tag 'perf-core-for-mingo' of git://git.kernel.org/pub/scm/linux/kernel/git/acme/linux into perf/core
Pull perf/core improvements and fixes from Arnaldo Carvalho de Melo: * Fix memcpy benchmark for large sizes, from Andi Kleen. * Support callchain sorting based on addresses, from Andi Kleen * Move weight back to common sort keys, From Andi Kleen. * Fix named threads support in 'perf script', from David Ahern. * Handle ENODEV on default cycles event, fix from David Ahern. * More install tests, from Jiri Olsa. * Fix build with perl 5.18, from Kirill A. Shutemov. Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com> Signed-off-by: Ingo Molnar <mingo@kernel.org>
Diffstat (limited to 'tools')
-rw-r--r--tools/perf/Documentation/perf-report.txt8
-rw-r--r--tools/perf/Makefile4
-rw-r--r--tools/perf/bench/mem-memcpy.c2
-rw-r--r--tools/perf/builtin-report.c19
-rw-r--r--tools/perf/builtin-script.c6
-rw-r--r--tools/perf/tests/make67
-rw-r--r--tools/perf/util/callchain.c7
-rw-r--r--tools/perf/util/callchain.h6
-rw-r--r--tools/perf/util/evsel.c2
-rw-r--r--tools/perf/util/hist.c3
-rw-r--r--tools/perf/util/scripting-engines/trace-event-perl.c14
-rw-r--r--tools/perf/util/scripting-engines/trace-event-python.c9
-rw-r--r--tools/perf/util/sort.c4
-rw-r--r--tools/perf/util/sort.h6
-rw-r--r--tools/perf/util/trace-event-scripting.c3
-rw-r--r--tools/perf/util/trace-event.h4
16 files changed, 124 insertions, 40 deletions
diff --git a/tools/perf/Documentation/perf-report.txt b/tools/perf/Documentation/perf-report.txt
index 747ff50284b7..2b8097ee39d8 100644
--- a/tools/perf/Documentation/perf-report.txt
+++ b/tools/perf/Documentation/perf-report.txt
@@ -115,7 +115,7 @@ OPTIONS
115--dump-raw-trace:: 115--dump-raw-trace::
116 Dump raw trace in ASCII. 116 Dump raw trace in ASCII.
117 117
118-g [type,min[,limit],order]:: 118-g [type,min[,limit],order[,key]]::
119--call-graph:: 119--call-graph::
120 Display call chains using type, min percent threshold, optional print 120 Display call chains using type, min percent threshold, optional print
121 limit and order. 121 limit and order.
@@ -129,7 +129,11 @@ OPTIONS
129 - callee: callee based call graph. 129 - callee: callee based call graph.
130 - caller: inverted caller based call graph. 130 - caller: inverted caller based call graph.
131 131
132 Default: fractal,0.5,callee. 132 key can be:
133 - function: compare on functions
134 - address: compare on individual code addresses
135
136 Default: fractal,0.5,callee,function.
133 137
134-G:: 138-G::
135--inverted:: 139--inverted::
diff --git a/tools/perf/Makefile b/tools/perf/Makefile
index 2a6902677141..024680b23ddc 100644
--- a/tools/perf/Makefile
+++ b/tools/perf/Makefile
@@ -631,10 +631,10 @@ $(OUTPUT)util/parse-events.o: util/parse-events.c $(OUTPUT)PERF-CFLAGS
631 $(QUIET_CC)$(CC) -o $@ -c $(CFLAGS) -Wno-redundant-decls $< 631 $(QUIET_CC)$(CC) -o $@ -c $(CFLAGS) -Wno-redundant-decls $<
632 632
633$(OUTPUT)util/scripting-engines/trace-event-perl.o: util/scripting-engines/trace-event-perl.c $(OUTPUT)PERF-CFLAGS 633$(OUTPUT)util/scripting-engines/trace-event-perl.o: util/scripting-engines/trace-event-perl.c $(OUTPUT)PERF-CFLAGS
634 $(QUIET_CC)$(CC) -o $@ -c $(CFLAGS) $(PERL_EMBED_CCOPTS) -Wno-redundant-decls -Wno-strict-prototypes -Wno-unused-parameter -Wno-shadow $< 634 $(QUIET_CC)$(CC) -o $@ -c $(CFLAGS) $(PERL_EMBED_CCOPTS) -Wno-redundant-decls -Wno-strict-prototypes -Wno-unused-parameter -Wno-shadow -Wno-undef -Wno-switch-default $<
635 635
636$(OUTPUT)scripts/perl/Perf-Trace-Util/Context.o: scripts/perl/Perf-Trace-Util/Context.c $(OUTPUT)PERF-CFLAGS 636$(OUTPUT)scripts/perl/Perf-Trace-Util/Context.o: scripts/perl/Perf-Trace-Util/Context.c $(OUTPUT)PERF-CFLAGS
637 $(QUIET_CC)$(CC) -o $@ -c $(CFLAGS) $(PERL_EMBED_CCOPTS) -Wno-redundant-decls -Wno-strict-prototypes -Wno-unused-parameter -Wno-nested-externs $< 637 $(QUIET_CC)$(CC) -o $@ -c $(CFLAGS) $(PERL_EMBED_CCOPTS) -Wno-redundant-decls -Wno-strict-prototypes -Wno-unused-parameter -Wno-nested-externs -Wno-undef -Wno-switch-default $<
638 638
639$(OUTPUT)util/scripting-engines/trace-event-python.o: util/scripting-engines/trace-event-python.c $(OUTPUT)PERF-CFLAGS 639$(OUTPUT)util/scripting-engines/trace-event-python.o: util/scripting-engines/trace-event-python.c $(OUTPUT)PERF-CFLAGS
640 $(QUIET_CC)$(CC) -o $@ -c $(CFLAGS) $(PYTHON_EMBED_CCOPTS) -Wno-redundant-decls -Wno-strict-prototypes -Wno-unused-parameter -Wno-shadow $< 640 $(QUIET_CC)$(CC) -o $@ -c $(CFLAGS) $(PYTHON_EMBED_CCOPTS) -Wno-redundant-decls -Wno-strict-prototypes -Wno-unused-parameter -Wno-shadow $<
diff --git a/tools/perf/bench/mem-memcpy.c b/tools/perf/bench/mem-memcpy.c
index 25fd3f1966f1..8cdca43016b2 100644
--- a/tools/perf/bench/mem-memcpy.c
+++ b/tools/perf/bench/mem-memcpy.c
@@ -117,6 +117,8 @@ static void alloc_mem(void **dst, void **src, size_t length)
117 *src = zalloc(length); 117 *src = zalloc(length);
118 if (!*src) 118 if (!*src)
119 die("memory allocation failed - maybe length is too large?\n"); 119 die("memory allocation failed - maybe length is too large?\n");
120 /* Make sure to always replace the zero pages even if MMAP_THRESH is crossed */
121 memset(*src, 0, length);
120} 122}
121 123
122static u64 do_memcpy_cycle(memcpy_t fn, size_t len, bool prefault) 124static u64 do_memcpy_cycle(memcpy_t fn, size_t len, bool prefault)
diff --git a/tools/perf/builtin-report.c b/tools/perf/builtin-report.c
index a34c587900c7..d785d89ed226 100644
--- a/tools/perf/builtin-report.c
+++ b/tools/perf/builtin-report.c
@@ -667,12 +667,23 @@ parse_callchain_opt(const struct option *opt, const char *arg, int unset)
667 } 667 }
668 668
669 /* get the call chain order */ 669 /* get the call chain order */
670 if (!strcmp(tok2, "caller")) 670 if (!strncmp(tok2, "caller", strlen("caller")))
671 callchain_param.order = ORDER_CALLER; 671 callchain_param.order = ORDER_CALLER;
672 else if (!strcmp(tok2, "callee")) 672 else if (!strncmp(tok2, "callee", strlen("callee")))
673 callchain_param.order = ORDER_CALLEE; 673 callchain_param.order = ORDER_CALLEE;
674 else 674 else
675 return -1; 675 return -1;
676
677 /* Get the sort key */
678 tok2 = strtok(NULL, ",");
679 if (!tok2)
680 goto setup;
681 if (!strncmp(tok2, "function", strlen("function")))
682 callchain_param.key = CCKEY_FUNCTION;
683 else if (!strncmp(tok2, "address", strlen("address")))
684 callchain_param.key = CCKEY_ADDRESS;
685 else
686 return -1;
676setup: 687setup:
677 if (callchain_register_param(&callchain_param) < 0) { 688 if (callchain_register_param(&callchain_param) < 0) {
678 fprintf(stderr, "Can't register callchain params\n"); 689 fprintf(stderr, "Can't register callchain params\n");
@@ -784,8 +795,8 @@ int cmd_report(int argc, const char **argv, const char *prefix __maybe_unused)
784 OPT_BOOLEAN('x', "exclude-other", &symbol_conf.exclude_other, 795 OPT_BOOLEAN('x', "exclude-other", &symbol_conf.exclude_other,
785 "Only display entries with parent-match"), 796 "Only display entries with parent-match"),
786 OPT_CALLBACK_DEFAULT('g', "call-graph", &report, "output_type,min_percent[,print_limit],call_order", 797 OPT_CALLBACK_DEFAULT('g', "call-graph", &report, "output_type,min_percent[,print_limit],call_order",
787 "Display callchains using output_type (graph, flat, fractal, or none) , min percent threshold, optional print limit and callchain order. " 798 "Display callchains using output_type (graph, flat, fractal, or none) , min percent threshold, optional print limit, callchain order, key (function or address). "
788 "Default: fractal,0.5,callee", &parse_callchain_opt, callchain_default_opt), 799 "Default: fractal,0.5,callee,function", &parse_callchain_opt, callchain_default_opt),
789 OPT_BOOLEAN('G', "inverted", &report.inverted_callchain, 800 OPT_BOOLEAN('G', "inverted", &report.inverted_callchain,
790 "alias for inverted call graph"), 801 "alias for inverted call graph"),
791 OPT_CALLBACK(0, "ignore-callees", NULL, "regex", 802 OPT_CALLBACK(0, "ignore-callees", NULL, "regex",
diff --git a/tools/perf/builtin-script.c b/tools/perf/builtin-script.c
index ecb697998d3b..1cad37014673 100644
--- a/tools/perf/builtin-script.c
+++ b/tools/perf/builtin-script.c
@@ -397,10 +397,10 @@ static void print_sample_bts(union perf_event *event,
397 397
398static void process_event(union perf_event *event, struct perf_sample *sample, 398static void process_event(union perf_event *event, struct perf_sample *sample,
399 struct perf_evsel *evsel, struct machine *machine, 399 struct perf_evsel *evsel, struct machine *machine,
400 struct addr_location *al) 400 struct thread *thread,
401 struct addr_location *al __maybe_unused)
401{ 402{
402 struct perf_event_attr *attr = &evsel->attr; 403 struct perf_event_attr *attr = &evsel->attr;
403 struct thread *thread = al->thread;
404 404
405 if (output[attr->type].fields == 0) 405 if (output[attr->type].fields == 0)
406 return; 406 return;
@@ -511,7 +511,7 @@ static int process_sample_event(struct perf_tool *tool __maybe_unused,
511 if (cpu_list && !test_bit(sample->cpu, cpu_bitmap)) 511 if (cpu_list && !test_bit(sample->cpu, cpu_bitmap))
512 return 0; 512 return 0;
513 513
514 scripting_ops->process_event(event, sample, evsel, machine, &al); 514 scripting_ops->process_event(event, sample, evsel, machine, thread, &al);
515 515
516 evsel->hists.stats.total_period += sample->period; 516 evsel->hists.stats.total_period += sample->period;
517 return 0; 517 return 0;
diff --git a/tools/perf/tests/make b/tools/perf/tests/make
index c441a2875128..2ca0abf1b2b6 100644
--- a/tools/perf/tests/make
+++ b/tools/perf/tests/make
@@ -1,6 +1,8 @@
1PERF := . 1PERF := .
2MK := Makefile 2MK := Makefile
3 3
4has = $(shell which $1 2>/dev/null)
5
4# standard single make variable specified 6# standard single make variable specified
5make_clean_all := clean all 7make_clean_all := clean all
6make_python_perf_so := python/perf.so 8make_python_perf_so := python/perf.so
@@ -25,6 +27,13 @@ make_help := help
25make_doc := doc 27make_doc := doc
26make_perf_o := perf.o 28make_perf_o := perf.o
27make_util_map_o := util/map.o 29make_util_map_o := util/map.o
30make_install := install
31make_install_bin := install-bin
32make_install_doc := install-doc
33make_install_man := install-man
34make_install_html := install-html
35make_install_info := install-info
36make_install_pdf := install-pdf
28 37
29# all the NO_* variable combined 38# all the NO_* variable combined
30make_minimal := NO_LIBPERL=1 NO_LIBPYTHON=1 NO_NEWT=1 NO_GTK2=1 39make_minimal := NO_LIBPERL=1 NO_LIBPYTHON=1 NO_NEWT=1 NO_GTK2=1
@@ -50,14 +59,27 @@ run += make_no_backtrace
50run += make_no_libnuma 59run += make_no_libnuma
51run += make_no_libaudit 60run += make_no_libaudit
52run += make_no_libbionic 61run += make_no_libbionic
53run += make_tags
54run += make_cscope
55run += make_help 62run += make_help
56run += make_doc 63run += make_doc
57run += make_perf_o 64run += make_perf_o
58run += make_util_map_o 65run += make_util_map_o
66run += make_install
67run += make_install_bin
68# FIXME 'install-*' commented out till they're fixed
69# run += make_install_doc
70# run += make_install_man
71# run += make_install_html
72# run += make_install_info
73# run += make_install_pdf
59run += make_minimal 74run += make_minimal
60 75
76ifneq ($(call has,ctags),)
77run += make_tags
78endif
79ifneq ($(call has,cscope),)
80run += make_cscope
81endif
82
61# $(run_O) contains same portion of $(run) tests with '_O' attached 83# $(run_O) contains same portion of $(run) tests with '_O' attached
62# to distinguish O=... tests 84# to distinguish O=... tests
63run_O := $(addsuffix _O,$(run)) 85run_O := $(addsuffix _O,$(run))
@@ -84,6 +106,31 @@ test_make_python_perf_so := test -f $(PERF)/python/perf.so
84test_make_perf_o := test -f $(PERF)/perf.o 106test_make_perf_o := test -f $(PERF)/perf.o
85test_make_util_map_o := test -f $(PERF)/util/map.o 107test_make_util_map_o := test -f $(PERF)/util/map.o
86 108
109test_make_install := test -x $$TMP_DEST/bin/perf
110test_make_install_O := $(test_make_install)
111test_make_install_bin := $(test_make_install)
112test_make_install_bin_O := $(test_make_install)
113
114# FIXME nothing gets installed
115test_make_install_man := test -f $$TMP_DEST/share/man/man1/perf.1
116test_make_install_man_O := $(test_make_install_man)
117
118# FIXME nothing gets installed
119test_make_install_doc := $(test_ok)
120test_make_install_doc_O := $(test_ok)
121
122# FIXME nothing gets installed
123test_make_install_html := $(test_ok)
124test_make_install_html_O := $(test_ok)
125
126# FIXME nothing gets installed
127test_make_install_info := $(test_ok)
128test_make_install_info_O := $(test_ok)
129
130# FIXME nothing gets installed
131test_make_install_pdf := $(test_ok)
132test_make_install_pdf_O := $(test_ok)
133
87# Kbuild tests only 134# Kbuild tests only
88#test_make_python_perf_so_O := test -f $$TMP/tools/perf/python/perf.so 135#test_make_python_perf_so_O := test -f $$TMP/tools/perf/python/perf.so
89#test_make_perf_o_O := test -f $$TMP/tools/perf/perf.o 136#test_make_perf_o_O := test -f $$TMP/tools/perf/perf.o
@@ -95,7 +142,7 @@ test_make_util_map_o_O := true
95test_default = test -x $(PERF)/perf 142test_default = test -x $(PERF)/perf
96test = $(if $(test_$1),$(test_$1),$(test_default)) 143test = $(if $(test_$1),$(test_$1),$(test_default))
97 144
98test_default_O = test -x $$TMP/perf 145test_default_O = test -x $$TMP_O/perf
99test_O = $(if $(test_$1),$(test_$1),$(test_default_O)) 146test_O = $(if $(test_$1),$(test_$1),$(test_default_O))
100 147
101all: 148all:
@@ -111,23 +158,27 @@ clean := @(cd $(PERF); make -s -f $(MK) clean >/dev/null)
111 158
112$(run): 159$(run):
113 $(call clean) 160 $(call clean)
114 @cmd="cd $(PERF) && make -f $(MK) $($@)"; \ 161 @TMP_DEST=$$(mktemp -d); \
162 cmd="cd $(PERF) && make -f $(MK) DESTDIR=$$TMP_DEST $($@)"; \
115 echo "- $@: $$cmd" && echo $$cmd > $@ && \ 163 echo "- $@: $$cmd" && echo $$cmd > $@ && \
116 ( eval $$cmd ) >> $@ 2>&1; \ 164 ( eval $$cmd ) >> $@ 2>&1; \
117 echo " test: $(call test,$@)"; \ 165 echo " test: $(call test,$@)"; \
118 $(call test,$@) && \ 166 $(call test,$@) && \
119 rm -f $@ 167 rm -f $@ \
168 rm -rf $$TMP_DEST
120 169
121$(run_O): 170$(run_O):
122 $(call clean) 171 $(call clean)
123 @TMP=$$(mktemp -d); \ 172 @TMP_O=$$(mktemp -d); \
124 cmd="cd $(PERF) && make -f $(MK) $($(patsubst %_O,%,$@)) O=$$TMP"; \ 173 TMP_DEST=$$(mktemp -d); \
174 cmd="cd $(PERF) && make -f $(MK) O=$$TMP_O DESTDIR=$$TMP_DEST $($(patsubst %_O,%,$@))"; \
125 echo "- $@: $$cmd" && echo $$cmd > $@ && \ 175 echo "- $@: $$cmd" && echo $$cmd > $@ && \
126 ( eval $$cmd ) >> $@ 2>&1 && \ 176 ( eval $$cmd ) >> $@ 2>&1 && \
127 echo " test: $(call test_O,$@)"; \ 177 echo " test: $(call test_O,$@)"; \
128 $(call test_O,$@) && \ 178 $(call test_O,$@) && \
129 rm -f $@ && \ 179 rm -f $@ && \
130 rm -rf $$TMP 180 rm -rf $$TMP_O \
181 rm -rf $$TMP_DEST
131 182
132all: $(run) $(run_O) 183all: $(run) $(run_O)
133 @echo OK 184 @echo OK
diff --git a/tools/perf/util/callchain.c b/tools/perf/util/callchain.c
index 42b6a632fe7b..4fee33b229b0 100644
--- a/tools/perf/util/callchain.c
+++ b/tools/perf/util/callchain.c
@@ -15,6 +15,7 @@
15#include <errno.h> 15#include <errno.h>
16#include <math.h> 16#include <math.h>
17 17
18#include "hist.h"
18#include "util.h" 19#include "util.h"
19#include "callchain.h" 20#include "callchain.h"
20 21
@@ -327,7 +328,8 @@ append_chain(struct callchain_node *root,
327 /* 328 /*
328 * Lookup in the current node 329 * Lookup in the current node
329 * If we have a symbol, then compare the start to match 330 * If we have a symbol, then compare the start to match
330 * anywhere inside a function. 331 * anywhere inside a function, unless function
332 * mode is disabled.
331 */ 333 */
332 list_for_each_entry(cnode, &root->val, list) { 334 list_for_each_entry(cnode, &root->val, list) {
333 struct callchain_cursor_node *node; 335 struct callchain_cursor_node *node;
@@ -339,7 +341,8 @@ append_chain(struct callchain_node *root,
339 341
340 sym = node->sym; 342 sym = node->sym;
341 343
342 if (cnode->ms.sym && sym) { 344 if (cnode->ms.sym && sym &&
345 callchain_param.key == CCKEY_FUNCTION) {
343 if (cnode->ms.sym->start != sym->start) 346 if (cnode->ms.sym->start != sym->start)
344 break; 347 break;
345 } else if (cnode->ip != node->ip) 348 } else if (cnode->ip != node->ip)
diff --git a/tools/perf/util/callchain.h b/tools/perf/util/callchain.h
index 3ee9f67d5af0..812d5a0ff2bc 100644
--- a/tools/perf/util/callchain.h
+++ b/tools/perf/util/callchain.h
@@ -41,12 +41,18 @@ struct callchain_param;
41typedef void (*sort_chain_func_t)(struct rb_root *, struct callchain_root *, 41typedef void (*sort_chain_func_t)(struct rb_root *, struct callchain_root *,
42 u64, struct callchain_param *); 42 u64, struct callchain_param *);
43 43
44enum chain_key {
45 CCKEY_FUNCTION,
46 CCKEY_ADDRESS
47};
48
44struct callchain_param { 49struct callchain_param {
45 enum chain_mode mode; 50 enum chain_mode mode;
46 u32 print_limit; 51 u32 print_limit;
47 double min_percent; 52 double min_percent;
48 sort_chain_func_t sort; 53 sort_chain_func_t sort;
49 enum chain_order order; 54 enum chain_order order;
55 enum chain_key key;
50}; 56};
51 57
52struct callchain_list { 58struct callchain_list {
diff --git a/tools/perf/util/evsel.c b/tools/perf/util/evsel.c
index a6354619fa5d..8bed0c1a1399 100644
--- a/tools/perf/util/evsel.c
+++ b/tools/perf/util/evsel.c
@@ -1482,7 +1482,7 @@ out:
1482bool perf_evsel__fallback(struct perf_evsel *evsel, int err, 1482bool perf_evsel__fallback(struct perf_evsel *evsel, int err,
1483 char *msg, size_t msgsize) 1483 char *msg, size_t msgsize)
1484{ 1484{
1485 if ((err == ENOENT || err == ENXIO) && 1485 if ((err == ENOENT || err == ENXIO || err == ENODEV) &&
1486 evsel->attr.type == PERF_TYPE_HARDWARE && 1486 evsel->attr.type == PERF_TYPE_HARDWARE &&
1487 evsel->attr.config == PERF_COUNT_HW_CPU_CYCLES) { 1487 evsel->attr.config == PERF_COUNT_HW_CPU_CYCLES) {
1488 /* 1488 /*
diff --git a/tools/perf/util/hist.c b/tools/perf/util/hist.c
index a9dd1b9d8907..46a0d35a05e1 100644
--- a/tools/perf/util/hist.c
+++ b/tools/perf/util/hist.c
@@ -24,7 +24,8 @@ enum hist_filter {
24struct callchain_param callchain_param = { 24struct callchain_param callchain_param = {
25 .mode = CHAIN_GRAPH_REL, 25 .mode = CHAIN_GRAPH_REL,
26 .min_percent = 0.5, 26 .min_percent = 0.5,
27 .order = ORDER_CALLEE 27 .order = ORDER_CALLEE,
28 .key = CCKEY_FUNCTION
28}; 29};
29 30
30u16 hists__col_len(struct hists *hists, enum hist_column col) 31u16 hists__col_len(struct hists *hists, enum hist_column col)
diff --git a/tools/perf/util/scripting-engines/trace-event-perl.c b/tools/perf/util/scripting-engines/trace-event-perl.c
index eacec859f299..a85e4ae5f3ac 100644
--- a/tools/perf/util/scripting-engines/trace-event-perl.c
+++ b/tools/perf/util/scripting-engines/trace-event-perl.c
@@ -261,7 +261,8 @@ static void perl_process_tracepoint(union perf_event *perf_event __maybe_unused,
261 struct perf_sample *sample, 261 struct perf_sample *sample,
262 struct perf_evsel *evsel, 262 struct perf_evsel *evsel,
263 struct machine *machine __maybe_unused, 263 struct machine *machine __maybe_unused,
264 struct addr_location *al) 264 struct thread *thread,
265 struct addr_location *al)
265{ 266{
266 struct format_field *field; 267 struct format_field *field;
267 static char handler[256]; 268 static char handler[256];
@@ -272,7 +273,6 @@ static void perl_process_tracepoint(union perf_event *perf_event __maybe_unused,
272 int cpu = sample->cpu; 273 int cpu = sample->cpu;
273 void *data = sample->raw_data; 274 void *data = sample->raw_data;
274 unsigned long long nsecs = sample->time; 275 unsigned long long nsecs = sample->time;
275 struct thread *thread = al->thread;
276 char *comm = thread->comm; 276 char *comm = thread->comm;
277 277
278 dSP; 278 dSP;
@@ -351,7 +351,8 @@ static void perl_process_event_generic(union perf_event *event,
351 struct perf_sample *sample, 351 struct perf_sample *sample,
352 struct perf_evsel *evsel, 352 struct perf_evsel *evsel,
353 struct machine *machine __maybe_unused, 353 struct machine *machine __maybe_unused,
354 struct addr_location *al __maybe_unused) 354 struct thread *thread __maybe_unused,
355 struct addr_location *al __maybe_unused)
355{ 356{
356 dSP; 357 dSP;
357 358
@@ -377,10 +378,11 @@ static void perl_process_event(union perf_event *event,
377 struct perf_sample *sample, 378 struct perf_sample *sample,
378 struct perf_evsel *evsel, 379 struct perf_evsel *evsel,
379 struct machine *machine, 380 struct machine *machine,
380 struct addr_location *al) 381 struct thread *thread,
382 struct addr_location *al)
381{ 383{
382 perl_process_tracepoint(event, sample, evsel, machine, al); 384 perl_process_tracepoint(event, sample, evsel, machine, thread, al);
383 perl_process_event_generic(event, sample, evsel, machine, al); 385 perl_process_event_generic(event, sample, evsel, machine, thread, al);
384} 386}
385 387
386static void run_start_sub(void) 388static void run_start_sub(void)
diff --git a/tools/perf/util/scripting-engines/trace-event-python.c b/tools/perf/util/scripting-engines/trace-event-python.c
index e87aa5d9696b..cc75a3cef388 100644
--- a/tools/perf/util/scripting-engines/trace-event-python.c
+++ b/tools/perf/util/scripting-engines/trace-event-python.c
@@ -225,6 +225,7 @@ static void python_process_tracepoint(union perf_event *perf_event
225 struct perf_sample *sample, 225 struct perf_sample *sample,
226 struct perf_evsel *evsel, 226 struct perf_evsel *evsel,
227 struct machine *machine __maybe_unused, 227 struct machine *machine __maybe_unused,
228 struct thread *thread,
228 struct addr_location *al) 229 struct addr_location *al)
229{ 230{
230 PyObject *handler, *retval, *context, *t, *obj, *dict = NULL; 231 PyObject *handler, *retval, *context, *t, *obj, *dict = NULL;
@@ -238,7 +239,6 @@ static void python_process_tracepoint(union perf_event *perf_event
238 int cpu = sample->cpu; 239 int cpu = sample->cpu;
239 void *data = sample->raw_data; 240 void *data = sample->raw_data;
240 unsigned long long nsecs = sample->time; 241 unsigned long long nsecs = sample->time;
241 struct thread *thread = al->thread;
242 char *comm = thread->comm; 242 char *comm = thread->comm;
243 243
244 t = PyTuple_New(MAX_FIELDS); 244 t = PyTuple_New(MAX_FIELDS);
@@ -345,12 +345,12 @@ static void python_process_general_event(union perf_event *perf_event
345 struct perf_sample *sample, 345 struct perf_sample *sample,
346 struct perf_evsel *evsel, 346 struct perf_evsel *evsel,
347 struct machine *machine __maybe_unused, 347 struct machine *machine __maybe_unused,
348 struct thread *thread,
348 struct addr_location *al) 349 struct addr_location *al)
349{ 350{
350 PyObject *handler, *retval, *t, *dict; 351 PyObject *handler, *retval, *t, *dict;
351 static char handler_name[64]; 352 static char handler_name[64];
352 unsigned n = 0; 353 unsigned n = 0;
353 struct thread *thread = al->thread;
354 354
355 /* 355 /*
356 * Use the MAX_FIELDS to make the function expandable, though 356 * Use the MAX_FIELDS to make the function expandable, though
@@ -404,17 +404,18 @@ static void python_process_event(union perf_event *perf_event,
404 struct perf_sample *sample, 404 struct perf_sample *sample,
405 struct perf_evsel *evsel, 405 struct perf_evsel *evsel,
406 struct machine *machine, 406 struct machine *machine,
407 struct thread *thread,
407 struct addr_location *al) 408 struct addr_location *al)
408{ 409{
409 switch (evsel->attr.type) { 410 switch (evsel->attr.type) {
410 case PERF_TYPE_TRACEPOINT: 411 case PERF_TYPE_TRACEPOINT:
411 python_process_tracepoint(perf_event, sample, evsel, 412 python_process_tracepoint(perf_event, sample, evsel,
412 machine, al); 413 machine, thread, al);
413 break; 414 break;
414 /* Reserve for future process_hw/sw/raw APIs */ 415 /* Reserve for future process_hw/sw/raw APIs */
415 default: 416 default:
416 python_process_general_event(perf_event, sample, evsel, 417 python_process_general_event(perf_event, sample, evsel,
417 machine, al); 418 machine, thread, al);
418 } 419 }
419} 420}
420 421
diff --git a/tools/perf/util/sort.c b/tools/perf/util/sort.c
index cb2b108635ee..5f118a089519 100644
--- a/tools/perf/util/sort.c
+++ b/tools/perf/util/sort.c
@@ -874,6 +874,8 @@ static struct sort_dimension common_sort_dimensions[] = {
874 DIM(SORT_PARENT, "parent", sort_parent), 874 DIM(SORT_PARENT, "parent", sort_parent),
875 DIM(SORT_CPU, "cpu", sort_cpu), 875 DIM(SORT_CPU, "cpu", sort_cpu),
876 DIM(SORT_SRCLINE, "srcline", sort_srcline), 876 DIM(SORT_SRCLINE, "srcline", sort_srcline),
877 DIM(SORT_LOCAL_WEIGHT, "local_weight", sort_local_weight),
878 DIM(SORT_GLOBAL_WEIGHT, "weight", sort_global_weight),
877}; 879};
878 880
879#undef DIM 881#undef DIM
@@ -893,8 +895,6 @@ static struct sort_dimension bstack_sort_dimensions[] = {
893#define DIM(d, n, func) [d - __SORT_MEMORY_MODE] = { .name = n, .entry = &(func) } 895#define DIM(d, n, func) [d - __SORT_MEMORY_MODE] = { .name = n, .entry = &(func) }
894 896
895static struct sort_dimension memory_sort_dimensions[] = { 897static struct sort_dimension memory_sort_dimensions[] = {
896 DIM(SORT_LOCAL_WEIGHT, "local_weight", sort_local_weight),
897 DIM(SORT_GLOBAL_WEIGHT, "weight", sort_global_weight),
898 DIM(SORT_MEM_DADDR_SYMBOL, "symbol_daddr", sort_mem_daddr_sym), 898 DIM(SORT_MEM_DADDR_SYMBOL, "symbol_daddr", sort_mem_daddr_sym),
899 DIM(SORT_MEM_DADDR_DSO, "dso_daddr", sort_mem_daddr_dso), 899 DIM(SORT_MEM_DADDR_DSO, "dso_daddr", sort_mem_daddr_dso),
900 DIM(SORT_MEM_LOCKED, "locked", sort_mem_locked), 900 DIM(SORT_MEM_LOCKED, "locked", sort_mem_locked),
diff --git a/tools/perf/util/sort.h b/tools/perf/util/sort.h
index 586022dc3264..4e80dbd271e7 100644
--- a/tools/perf/util/sort.h
+++ b/tools/perf/util/sort.h
@@ -143,6 +143,8 @@ enum sort_type {
143 SORT_PARENT, 143 SORT_PARENT,
144 SORT_CPU, 144 SORT_CPU,
145 SORT_SRCLINE, 145 SORT_SRCLINE,
146 SORT_LOCAL_WEIGHT,
147 SORT_GLOBAL_WEIGHT,
146 148
147 /* branch stack specific sort keys */ 149 /* branch stack specific sort keys */
148 __SORT_BRANCH_STACK, 150 __SORT_BRANCH_STACK,
@@ -154,9 +156,7 @@ enum sort_type {
154 156
155 /* memory mode specific sort keys */ 157 /* memory mode specific sort keys */
156 __SORT_MEMORY_MODE, 158 __SORT_MEMORY_MODE,
157 SORT_LOCAL_WEIGHT = __SORT_MEMORY_MODE, 159 SORT_MEM_DADDR_SYMBOL = __SORT_MEMORY_MODE,
158 SORT_GLOBAL_WEIGHT,
159 SORT_MEM_DADDR_SYMBOL,
160 SORT_MEM_DADDR_DSO, 160 SORT_MEM_DADDR_DSO,
161 SORT_MEM_LOCKED, 161 SORT_MEM_LOCKED,
162 SORT_MEM_TLB, 162 SORT_MEM_TLB,
diff --git a/tools/perf/util/trace-event-scripting.c b/tools/perf/util/trace-event-scripting.c
index 8715a1006d00..95199e4eea97 100644
--- a/tools/perf/util/trace-event-scripting.c
+++ b/tools/perf/util/trace-event-scripting.c
@@ -39,7 +39,8 @@ static void process_event_unsupported(union perf_event *event __maybe_unused,
39 struct perf_sample *sample __maybe_unused, 39 struct perf_sample *sample __maybe_unused,
40 struct perf_evsel *evsel __maybe_unused, 40 struct perf_evsel *evsel __maybe_unused,
41 struct machine *machine __maybe_unused, 41 struct machine *machine __maybe_unused,
42 struct addr_location *al __maybe_unused) 42 struct thread *thread __maybe_unused,
43 struct addr_location *al __maybe_unused)
43{ 44{
44} 45}
45 46
diff --git a/tools/perf/util/trace-event.h b/tools/perf/util/trace-event.h
index 669a64a660d7..fafe1a40444a 100644
--- a/tools/perf/util/trace-event.h
+++ b/tools/perf/util/trace-event.h
@@ -9,6 +9,7 @@ struct machine;
9struct perf_sample; 9struct perf_sample;
10union perf_event; 10union perf_event;
11struct perf_tool; 11struct perf_tool;
12struct thread;
12 13
13extern struct pevent *perf_pevent; 14extern struct pevent *perf_pevent;
14 15
@@ -68,7 +69,8 @@ struct scripting_ops {
68 struct perf_sample *sample, 69 struct perf_sample *sample,
69 struct perf_evsel *evsel, 70 struct perf_evsel *evsel,
70 struct machine *machine, 71 struct machine *machine,
71 struct addr_location *al); 72 struct thread *thread,
73 struct addr_location *al);
72 int (*generate_script) (struct pevent *pevent, const char *outfile); 74 int (*generate_script) (struct pevent *pevent, const char *outfile);
73}; 75};
74 76