aboutsummaryrefslogtreecommitdiffstats
path: root/tools
diff options
context:
space:
mode:
authorOlof Johansson <olof@lixom.net>2017-05-19 02:54:47 -0400
committerOlof Johansson <olof@lixom.net>2017-05-19 02:54:47 -0400
commit5252d73756f318f182f2316acd78a6532041414d (patch)
treeb082478fca4f00f599bb2ed1547b2652c2bea155 /tools
parente84188852a7239d7a144af12f7e5dac8fa88600b (diff)
parent2ea659a9ef488125eb46da6eb571de5eae5c43f6 (diff)
Merge tag 'v4.12-rc1' into fixes
We've received a few fixes branches with -rc1 as base, but our contents was still at pre-rc1. Merge it in expliticly to make 'git merge --log' clear on hat was actually merged. Signed-off-by: Olof Johansson <olof@lixom.net>
Diffstat (limited to 'tools')
-rw-r--r--tools/build/feature/test-sched_getcpu.c2
-rw-r--r--tools/include/linux/string.h2
-rw-r--r--tools/lib/string.c9
-rw-r--r--tools/lib/subcmd/help.c1
-rw-r--r--tools/lib/subcmd/parse-options.c1
-rw-r--r--tools/lib/subcmd/subcmd-util.h9
-rw-r--r--tools/perf/Documentation/perf-c2c.txt4
-rw-r--r--tools/perf/Documentation/perf-record.txt2
-rw-r--r--tools/perf/Documentation/perf-report.txt6
-rw-r--r--tools/perf/Documentation/perf.data-file-format.txt4
-rw-r--r--tools/perf/Documentation/tips.txt2
-rw-r--r--tools/perf/arch/arm64/annotate/instructions.c2
-rw-r--r--tools/perf/arch/powerpc/util/sym-handling.c12
-rw-r--r--tools/perf/builtin-buildid-cache.c13
-rw-r--r--tools/perf/builtin-c2c.c1
-rw-r--r--tools/perf/builtin-config.c19
-rw-r--r--tools/perf/builtin-top.c2
-rw-r--r--tools/perf/builtin-trace.c1
-rw-r--r--tools/perf/perf.c1
-rw-r--r--tools/perf/tests/hists_cumulate.c1
-rw-r--r--tools/perf/tests/hists_filter.c1
-rw-r--r--tools/perf/tests/hists_output.c1
-rw-r--r--tools/perf/tests/kmod-path.c2
-rw-r--r--tools/perf/tests/sdt.c1
-rw-r--r--tools/perf/ui/setup.c3
-rw-r--r--tools/perf/util/Build1
-rw-r--r--tools/perf/util/build-id.h4
-rw-r--r--tools/perf/util/event.c10
-rw-r--r--tools/perf/util/event.h14
-rw-r--r--tools/perf/util/evsel.c1
-rw-r--r--tools/perf/util/header.c1
-rw-r--r--tools/perf/util/intel-pt.c1
-rw-r--r--tools/perf/util/machine.c28
-rw-r--r--tools/perf/util/map.c5
-rw-r--r--tools/perf/util/map.h5
-rw-r--r--tools/perf/util/memswap.c24
-rw-r--r--tools/perf/util/memswap.h7
-rw-r--r--tools/perf/util/scripting-engines/trace-event-perl.c4
-rw-r--r--tools/perf/util/session.c1
-rw-r--r--tools/perf/util/strbuf.c9
-rw-r--r--tools/perf/util/symbol.c72
-rw-r--r--tools/perf/util/symbol.h11
-rw-r--r--tools/perf/util/units.c29
-rw-r--r--tools/perf/util/units.h7
-rw-r--r--tools/perf/util/util.c49
-rw-r--r--tools/perf/util/util.h26
-rwxr-xr-xtools/testing/selftests/rcutorture/bin/kvm-test-1-run.sh2
-rw-r--r--tools/virtio/linux/virtio.h1
-rw-r--r--tools/virtio/ringtest/main.c15
-rw-r--r--tools/virtio/ringtest/main.h2
-rw-r--r--tools/virtio/ringtest/ptr_ring.c3
-rw-r--r--tools/virtio/virtio_test.c4
-rw-r--r--tools/virtio/vringh_test.c7
53 files changed, 272 insertions, 173 deletions
diff --git a/tools/build/feature/test-sched_getcpu.c b/tools/build/feature/test-sched_getcpu.c
index c4a148dd7104..9c6b4cbffb1c 100644
--- a/tools/build/feature/test-sched_getcpu.c
+++ b/tools/build/feature/test-sched_getcpu.c
@@ -1,4 +1,6 @@
1#ifndef _GNU_SOURCE
1#define _GNU_SOURCE 2#define _GNU_SOURCE
3#endif
2#include <sched.h> 4#include <sched.h>
3 5
4int main(void) 6int main(void)
diff --git a/tools/include/linux/string.h b/tools/include/linux/string.h
index f436d2420a18..d62b56cf8c12 100644
--- a/tools/include/linux/string.h
+++ b/tools/include/linux/string.h
@@ -18,4 +18,6 @@ extern size_t strlcpy(char *dest, const char *src, size_t size);
18 18
19char *str_error_r(int errnum, char *buf, size_t buflen); 19char *str_error_r(int errnum, char *buf, size_t buflen);
20 20
21int prefixcmp(const char *str, const char *prefix);
22
21#endif /* _LINUX_STRING_H_ */ 23#endif /* _LINUX_STRING_H_ */
diff --git a/tools/lib/string.c b/tools/lib/string.c
index bd239bc1d557..8e678af1c6ee 100644
--- a/tools/lib/string.c
+++ b/tools/lib/string.c
@@ -87,3 +87,12 @@ size_t __weak strlcpy(char *dest, const char *src, size_t size)
87 } 87 }
88 return ret; 88 return ret;
89} 89}
90
91int prefixcmp(const char *str, const char *prefix)
92{
93 for (; ; str++, prefix++)
94 if (!*prefix)
95 return 0;
96 else if (*str != *prefix)
97 return (unsigned char)*prefix - (unsigned char)*str;
98}
diff --git a/tools/lib/subcmd/help.c b/tools/lib/subcmd/help.c
index e228c3cb3716..ba970a73d053 100644
--- a/tools/lib/subcmd/help.c
+++ b/tools/lib/subcmd/help.c
@@ -1,6 +1,7 @@
1#include <stdio.h> 1#include <stdio.h>
2#include <stdlib.h> 2#include <stdlib.h>
3#include <string.h> 3#include <string.h>
4#include <linux/string.h>
4#include <termios.h> 5#include <termios.h>
5#include <sys/ioctl.h> 6#include <sys/ioctl.h>
6#include <sys/types.h> 7#include <sys/types.h>
diff --git a/tools/lib/subcmd/parse-options.c b/tools/lib/subcmd/parse-options.c
index 6bc24025d054..359bfa77f39c 100644
--- a/tools/lib/subcmd/parse-options.c
+++ b/tools/lib/subcmd/parse-options.c
@@ -1,4 +1,5 @@
1#include <linux/compiler.h> 1#include <linux/compiler.h>
2#include <linux/string.h>
2#include <linux/types.h> 3#include <linux/types.h>
3#include <stdio.h> 4#include <stdio.h>
4#include <stdlib.h> 5#include <stdlib.h>
diff --git a/tools/lib/subcmd/subcmd-util.h b/tools/lib/subcmd/subcmd-util.h
index fc2e45d8aaf1..8fa5f036eff0 100644
--- a/tools/lib/subcmd/subcmd-util.h
+++ b/tools/lib/subcmd/subcmd-util.h
@@ -79,13 +79,4 @@ static inline void astrcat(char **out, const char *add)
79 free(tmp); 79 free(tmp);
80} 80}
81 81
82static inline int prefixcmp(const char *str, const char *prefix)
83{
84 for (; ; str++, prefix++)
85 if (!*prefix)
86 return 0;
87 else if (*str != *prefix)
88 return (unsigned char)*prefix - (unsigned char)*str;
89}
90
91#endif /* __SUBCMD_UTIL_H */ 82#endif /* __SUBCMD_UTIL_H */
diff --git a/tools/perf/Documentation/perf-c2c.txt b/tools/perf/Documentation/perf-c2c.txt
index 2da07e51e119..822414235170 100644
--- a/tools/perf/Documentation/perf-c2c.txt
+++ b/tools/perf/Documentation/perf-c2c.txt
@@ -76,7 +76,7 @@ REPORT OPTIONS
76 76
77-c:: 77-c::
78--coalesce:: 78--coalesce::
79 Specify sorintg fields for single cacheline display. 79 Specify sorting fields for single cacheline display.
80 Following fields are available: tid,pid,iaddr,dso 80 Following fields are available: tid,pid,iaddr,dso
81 (see COALESCE) 81 (see COALESCE)
82 82
@@ -106,7 +106,7 @@ REPORT OPTIONS
106 106
107-d:: 107-d::
108--display:: 108--display::
109 Siwtch to HITM type (rmt, lcl) to display and sort on. Total HITMs as default. 109 Switch to HITM type (rmt, lcl) to display and sort on. Total HITMs as default.
110 110
111C2C RECORD 111C2C RECORD
112---------- 112----------
diff --git a/tools/perf/Documentation/perf-record.txt b/tools/perf/Documentation/perf-record.txt
index ea3789d05e5e..b0e9e921d534 100644
--- a/tools/perf/Documentation/perf-record.txt
+++ b/tools/perf/Documentation/perf-record.txt
@@ -225,7 +225,7 @@ OPTIONS
225 the libunwind or libdw library) should be used instead. 225 the libunwind or libdw library) should be used instead.
226 Using the "lbr" method doesn't require any compiler options. It 226 Using the "lbr" method doesn't require any compiler options. It
227 will produce call graphs from the hardware LBR registers. The 227 will produce call graphs from the hardware LBR registers. The
228 main limition is that it is only available on new Intel 228 main limitation is that it is only available on new Intel
229 platforms, such as Haswell. It can only get user call chain. It 229 platforms, such as Haswell. It can only get user call chain. It
230 doesn't work with branch stack sampling at the same time. 230 doesn't work with branch stack sampling at the same time.
231 231
diff --git a/tools/perf/Documentation/perf-report.txt b/tools/perf/Documentation/perf-report.txt
index 37a175914157..9fa84617181e 100644
--- a/tools/perf/Documentation/perf-report.txt
+++ b/tools/perf/Documentation/perf-report.txt
@@ -182,7 +182,7 @@ OPTIONS
182--parent=<regex>:: 182--parent=<regex>::
183 A regex filter to identify parent. The parent is a caller of this 183 A regex filter to identify parent. The parent is a caller of this
184 function and searched through the callchain, thus it requires callchain 184 function and searched through the callchain, thus it requires callchain
185 information recorded. The pattern is in the exteneded regex format and 185 information recorded. The pattern is in the extended regex format and
186 defaults to "\^sys_|^do_page_fault", see '--sort parent'. 186 defaults to "\^sys_|^do_page_fault", see '--sort parent'.
187 187
188-x:: 188-x::
@@ -207,8 +207,8 @@ OPTIONS
207-g:: 207-g::
208--call-graph=<print_type,threshold[,print_limit],order,sort_key[,branch],value>:: 208--call-graph=<print_type,threshold[,print_limit],order,sort_key[,branch],value>::
209 Display call chains using type, min percent threshold, print limit, 209 Display call chains using type, min percent threshold, print limit,
210 call order, sort key, optional branch and value. Note that ordering of 210 call order, sort key, optional branch and value. Note that ordering
211 parameters is not fixed so any parement can be given in an arbitraty order. 211 is not fixed so any parameter can be given in an arbitrary order.
212 One exception is the print_limit which should be preceded by threshold. 212 One exception is the print_limit which should be preceded by threshold.
213 213
214 print_type can be either: 214 print_type can be either:
diff --git a/tools/perf/Documentation/perf.data-file-format.txt b/tools/perf/Documentation/perf.data-file-format.txt
index fa2a9132f0a9..de8b39dda7b8 100644
--- a/tools/perf/Documentation/perf.data-file-format.txt
+++ b/tools/perf/Documentation/perf.data-file-format.txt
@@ -270,7 +270,7 @@ When the event stream contains multiple events each event is identified
270by an ID. This can be either through the PERF_SAMPLE_ID or the 270by an ID. This can be either through the PERF_SAMPLE_ID or the
271PERF_SAMPLE_IDENTIFIER header. The PERF_SAMPLE_IDENTIFIER header is 271PERF_SAMPLE_IDENTIFIER header. The PERF_SAMPLE_IDENTIFIER header is
272at a fixed offset from the event header, which allows reliable 272at a fixed offset from the event header, which allows reliable
273parsing of the header. Relying on ID may be ambigious. 273parsing of the header. Relying on ID may be ambiguous.
274IDENTIFIER is only supported by newer Linux kernels. 274IDENTIFIER is only supported by newer Linux kernels.
275 275
276Perf record specific events: 276Perf record specific events:
@@ -288,7 +288,7 @@ struct attr_event {
288 uint64_t id[]; 288 uint64_t id[];
289}; 289};
290 290
291 PERF_RECORD_HEADER_EVENT_TYPE = 65, /* depreceated */ 291 PERF_RECORD_HEADER_EVENT_TYPE = 65, /* deprecated */
292 292
293#define MAX_EVENT_NAME 64 293#define MAX_EVENT_NAME 64
294 294
diff --git a/tools/perf/Documentation/tips.txt b/tools/perf/Documentation/tips.txt
index 170b0289a7bc..db0ca3063eae 100644
--- a/tools/perf/Documentation/tips.txt
+++ b/tools/perf/Documentation/tips.txt
@@ -23,7 +23,7 @@ For memory address profiling, try: perf mem record / perf mem report
23For tracepoint events, try: perf report -s trace_fields 23For tracepoint events, try: perf report -s trace_fields
24To record callchains for each sample: perf record -g 24To record callchains for each sample: perf record -g
25To record every process run by a user: perf record -u <user> 25To record every process run by a user: perf record -u <user>
26Skip collecing build-id when recording: perf record -B 26Skip collecting build-id when recording: perf record -B
27To change sampling frequency to 100 Hz: perf record -F 100 27To change sampling frequency to 100 Hz: perf record -F 100
28See assembly instructions with percentage: perf annotate <symbol> 28See assembly instructions with percentage: perf annotate <symbol>
29If you prefer Intel style assembly, try: perf annotate -M intel 29If you prefer Intel style assembly, try: perf annotate -M intel
diff --git a/tools/perf/arch/arm64/annotate/instructions.c b/tools/perf/arch/arm64/annotate/instructions.c
index 44eafd6f2d50..8f1908756cb6 100644
--- a/tools/perf/arch/arm64/annotate/instructions.c
+++ b/tools/perf/arch/arm64/annotate/instructions.c
@@ -50,7 +50,7 @@ static int arm64__annotate_init(struct arch *arch)
50 arch->initialized = true; 50 arch->initialized = true;
51 arch->priv = arm; 51 arch->priv = arm;
52 arch->associate_instruction_ops = arm64__associate_instruction_ops; 52 arch->associate_instruction_ops = arm64__associate_instruction_ops;
53 arch->objdump.comment_char = ';'; 53 arch->objdump.comment_char = '/';
54 arch->objdump.skip_functions_char = '+'; 54 arch->objdump.skip_functions_char = '+';
55 return 0; 55 return 0;
56 56
diff --git a/tools/perf/arch/powerpc/util/sym-handling.c b/tools/perf/arch/powerpc/util/sym-handling.c
index 39dbe512b9fc..bf9a2594572c 100644
--- a/tools/perf/arch/powerpc/util/sym-handling.c
+++ b/tools/perf/arch/powerpc/util/sym-handling.c
@@ -52,6 +52,18 @@ int arch__compare_symbol_names(const char *namea, const char *nameb)
52 52
53 return strcmp(namea, nameb); 53 return strcmp(namea, nameb);
54} 54}
55
56int arch__compare_symbol_names_n(const char *namea, const char *nameb,
57 unsigned int n)
58{
59 /* Skip over initial dot */
60 if (*namea == '.')
61 namea++;
62 if (*nameb == '.')
63 nameb++;
64
65 return strncmp(namea, nameb, n);
66}
55#endif 67#endif
56 68
57#if defined(_CALL_ELF) && _CALL_ELF == 2 69#if defined(_CALL_ELF) && _CALL_ELF == 2
diff --git a/tools/perf/builtin-buildid-cache.c b/tools/perf/builtin-buildid-cache.c
index 64b44e81c771..9eba7f1add1f 100644
--- a/tools/perf/builtin-buildid-cache.c
+++ b/tools/perf/builtin-buildid-cache.c
@@ -49,19 +49,22 @@ static bool same_kallsyms_reloc(const char *from_dir, char *to_dir)
49 char to[PATH_MAX]; 49 char to[PATH_MAX];
50 const char *name; 50 const char *name;
51 u64 addr1 = 0, addr2 = 0; 51 u64 addr1 = 0, addr2 = 0;
52 int i; 52 int i, err = -1;
53 53
54 scnprintf(from, sizeof(from), "%s/kallsyms", from_dir); 54 scnprintf(from, sizeof(from), "%s/kallsyms", from_dir);
55 scnprintf(to, sizeof(to), "%s/kallsyms", to_dir); 55 scnprintf(to, sizeof(to), "%s/kallsyms", to_dir);
56 56
57 for (i = 0; (name = ref_reloc_sym_names[i]) != NULL; i++) { 57 for (i = 0; (name = ref_reloc_sym_names[i]) != NULL; i++) {
58 addr1 = kallsyms__get_function_start(from, name); 58 err = kallsyms__get_function_start(from, name, &addr1);
59 if (addr1) 59 if (!err)
60 break; 60 break;
61 } 61 }
62 62
63 if (name) 63 if (err)
64 addr2 = kallsyms__get_function_start(to, name); 64 return false;
65
66 if (kallsyms__get_function_start(to, name, &addr2))
67 return false;
65 68
66 return addr1 == addr2; 69 return addr1 == addr2;
67} 70}
diff --git a/tools/perf/builtin-c2c.c b/tools/perf/builtin-c2c.c
index e33b4acece90..620a467ee304 100644
--- a/tools/perf/builtin-c2c.c
+++ b/tools/perf/builtin-c2c.c
@@ -27,6 +27,7 @@
27#include "tool.h" 27#include "tool.h"
28#include "data.h" 28#include "data.h"
29#include "sort.h" 29#include "sort.h"
30#include "event.h"
30#include "evlist.h" 31#include "evlist.h"
31#include "evsel.h" 32#include "evsel.h"
32#include <asm/bug.h> 33#include <asm/bug.h>
diff --git a/tools/perf/builtin-config.c b/tools/perf/builtin-config.c
index 55f04f85b049..80668fa7556e 100644
--- a/tools/perf/builtin-config.c
+++ b/tools/perf/builtin-config.c
@@ -159,6 +159,7 @@ int cmd_config(int argc, const char **argv)
159 int i, ret = 0; 159 int i, ret = 0;
160 struct perf_config_set *set; 160 struct perf_config_set *set;
161 char *user_config = mkpath("%s/.perfconfig", getenv("HOME")); 161 char *user_config = mkpath("%s/.perfconfig", getenv("HOME"));
162 const char *config_filename;
162 163
163 argc = parse_options(argc, argv, config_options, config_usage, 164 argc = parse_options(argc, argv, config_options, config_usage,
164 PARSE_OPT_STOP_AT_NON_OPTION); 165 PARSE_OPT_STOP_AT_NON_OPTION);
@@ -175,6 +176,11 @@ int cmd_config(int argc, const char **argv)
175 else if (use_user_config) 176 else if (use_user_config)
176 config_exclusive_filename = user_config; 177 config_exclusive_filename = user_config;
177 178
179 if (!config_exclusive_filename)
180 config_filename = user_config;
181 else
182 config_filename = config_exclusive_filename;
183
178 /* 184 /*
179 * At only 'config' sub-command, individually use the config set 185 * At only 'config' sub-command, individually use the config set
180 * because of reinitializing with options config file location. 186 * because of reinitializing with options config file location.
@@ -192,13 +198,9 @@ int cmd_config(int argc, const char **argv)
192 parse_options_usage(config_usage, config_options, "l", 1); 198 parse_options_usage(config_usage, config_options, "l", 1);
193 } else { 199 } else {
194 ret = show_config(set); 200 ret = show_config(set);
195 if (ret < 0) { 201 if (ret < 0)
196 const char * config_filename = config_exclusive_filename;
197 if (!config_exclusive_filename)
198 config_filename = user_config;
199 pr_err("Nothing configured, " 202 pr_err("Nothing configured, "
200 "please check your %s \n", config_filename); 203 "please check your %s \n", config_filename);
201 }
202 } 204 }
203 break; 205 break;
204 default: 206 default:
@@ -221,13 +223,8 @@ int cmd_config(int argc, const char **argv)
221 223
222 if (value == NULL) 224 if (value == NULL)
223 ret = show_spec_config(set, var); 225 ret = show_spec_config(set, var);
224 else { 226 else
225 const char *config_filename = config_exclusive_filename;
226
227 if (!config_exclusive_filename)
228 config_filename = user_config;
229 ret = set_config(set, config_filename, var, value); 227 ret = set_config(set, config_filename, var, value);
230 }
231 free(arg); 228 free(arg);
232 } 229 }
233 } else 230 } else
diff --git a/tools/perf/builtin-top.c b/tools/perf/builtin-top.c
index 7ab42b8311a1..10b6362ca0bf 100644
--- a/tools/perf/builtin-top.c
+++ b/tools/perf/builtin-top.c
@@ -27,13 +27,13 @@
27#include "util/drv_configs.h" 27#include "util/drv_configs.h"
28#include "util/evlist.h" 28#include "util/evlist.h"
29#include "util/evsel.h" 29#include "util/evsel.h"
30#include "util/event.h"
30#include "util/machine.h" 31#include "util/machine.h"
31#include "util/session.h" 32#include "util/session.h"
32#include "util/symbol.h" 33#include "util/symbol.h"
33#include "util/thread.h" 34#include "util/thread.h"
34#include "util/thread_map.h" 35#include "util/thread_map.h"
35#include "util/top.h" 36#include "util/top.h"
36#include "util/util.h"
37#include <linux/rbtree.h> 37#include <linux/rbtree.h>
38#include <subcmd/parse-options.h> 38#include <subcmd/parse-options.h>
39#include "util/parse-events.h" 39#include "util/parse-events.h"
diff --git a/tools/perf/builtin-trace.c b/tools/perf/builtin-trace.c
index eaa66fb57347..d014350adc52 100644
--- a/tools/perf/builtin-trace.c
+++ b/tools/perf/builtin-trace.c
@@ -21,6 +21,7 @@
21#include "builtin.h" 21#include "builtin.h"
22#include "util/color.h" 22#include "util/color.h"
23#include "util/debug.h" 23#include "util/debug.h"
24#include "util/event.h"
24#include "util/evlist.h" 25#include "util/evlist.h"
25#include <subcmd/exec-cmd.h> 26#include <subcmd/exec-cmd.h>
26#include "util/machine.h" 27#include "util/machine.h"
diff --git a/tools/perf/perf.c b/tools/perf/perf.c
index 4cc6960f6226..628a5e412cb1 100644
--- a/tools/perf/perf.c
+++ b/tools/perf/perf.c
@@ -17,6 +17,7 @@
17#include <subcmd/parse-options.h> 17#include <subcmd/parse-options.h>
18#include "util/bpf-loader.h" 18#include "util/bpf-loader.h"
19#include "util/debug.h" 19#include "util/debug.h"
20#include "util/event.h"
20#include <api/fs/fs.h> 21#include <api/fs/fs.h>
21#include <api/fs/tracing_path.h> 22#include <api/fs/tracing_path.h>
22#include <errno.h> 23#include <errno.h>
diff --git a/tools/perf/tests/hists_cumulate.c b/tools/perf/tests/hists_cumulate.c
index 70918b986568..d549a9f2c41b 100644
--- a/tools/perf/tests/hists_cumulate.c
+++ b/tools/perf/tests/hists_cumulate.c
@@ -1,5 +1,6 @@
1#include "perf.h" 1#include "perf.h"
2#include "util/debug.h" 2#include "util/debug.h"
3#include "util/event.h"
3#include "util/symbol.h" 4#include "util/symbol.h"
4#include "util/sort.h" 5#include "util/sort.h"
5#include "util/evsel.h" 6#include "util/evsel.h"
diff --git a/tools/perf/tests/hists_filter.c b/tools/perf/tests/hists_filter.c
index f171b2da4899..df9c91f49af1 100644
--- a/tools/perf/tests/hists_filter.c
+++ b/tools/perf/tests/hists_filter.c
@@ -3,6 +3,7 @@
3#include "util/symbol.h" 3#include "util/symbol.h"
4#include "util/sort.h" 4#include "util/sort.h"
5#include "util/evsel.h" 5#include "util/evsel.h"
6#include "util/event.h"
6#include "util/evlist.h" 7#include "util/evlist.h"
7#include "util/machine.h" 8#include "util/machine.h"
8#include "util/thread.h" 9#include "util/thread.h"
diff --git a/tools/perf/tests/hists_output.c b/tools/perf/tests/hists_output.c
index cdf0dde5fe97..06e5080182d3 100644
--- a/tools/perf/tests/hists_output.c
+++ b/tools/perf/tests/hists_output.c
@@ -1,5 +1,6 @@
1#include "perf.h" 1#include "perf.h"
2#include "util/debug.h" 2#include "util/debug.h"
3#include "util/event.h"
3#include "util/symbol.h" 4#include "util/symbol.h"
4#include "util/sort.h" 5#include "util/sort.h"
5#include "util/evsel.h" 6#include "util/evsel.h"
diff --git a/tools/perf/tests/kmod-path.c b/tools/perf/tests/kmod-path.c
index 76f41f249944..6cd9e5107f77 100644
--- a/tools/perf/tests/kmod-path.c
+++ b/tools/perf/tests/kmod-path.c
@@ -61,6 +61,7 @@ int test__kmod_path__parse(int subtest __maybe_unused)
61 M("/xxxx/xxxx/x-x.ko", PERF_RECORD_MISC_KERNEL, true); 61 M("/xxxx/xxxx/x-x.ko", PERF_RECORD_MISC_KERNEL, true);
62 M("/xxxx/xxxx/x-x.ko", PERF_RECORD_MISC_USER, false); 62 M("/xxxx/xxxx/x-x.ko", PERF_RECORD_MISC_USER, false);
63 63
64#ifdef HAVE_ZLIB_SUPPORT
64 /* path alloc_name alloc_ext kmod comp name ext */ 65 /* path alloc_name alloc_ext kmod comp name ext */
65 T("/xxxx/xxxx/x.ko.gz", true , true , true, true, "[x]", "gz"); 66 T("/xxxx/xxxx/x.ko.gz", true , true , true, true, "[x]", "gz");
66 T("/xxxx/xxxx/x.ko.gz", false , true , true, true, NULL , "gz"); 67 T("/xxxx/xxxx/x.ko.gz", false , true , true, true, NULL , "gz");
@@ -96,6 +97,7 @@ int test__kmod_path__parse(int subtest __maybe_unused)
96 M("x.ko.gz", PERF_RECORD_MISC_CPUMODE_UNKNOWN, true); 97 M("x.ko.gz", PERF_RECORD_MISC_CPUMODE_UNKNOWN, true);
97 M("x.ko.gz", PERF_RECORD_MISC_KERNEL, true); 98 M("x.ko.gz", PERF_RECORD_MISC_KERNEL, true);
98 M("x.ko.gz", PERF_RECORD_MISC_USER, false); 99 M("x.ko.gz", PERF_RECORD_MISC_USER, false);
100#endif
99 101
100 /* path alloc_name alloc_ext kmod comp name ext */ 102 /* path alloc_name alloc_ext kmod comp name ext */
101 T("[test_module]", true , true , true, false, "[test_module]", NULL); 103 T("[test_module]", true , true , true, false, "[test_module]", NULL);
diff --git a/tools/perf/tests/sdt.c b/tools/perf/tests/sdt.c
index f73b3c5e125d..06eda675ae2c 100644
--- a/tools/perf/tests/sdt.c
+++ b/tools/perf/tests/sdt.c
@@ -1,7 +1,6 @@
1#include <errno.h> 1#include <errno.h>
2#include <stdio.h> 2#include <stdio.h>
3#include <sys/epoll.h> 3#include <sys/epoll.h>
4#include <util/util.h>
5#include <util/evlist.h> 4#include <util/evlist.h>
6#include <linux/filter.h> 5#include <linux/filter.h>
7#include "tests.h" 6#include "tests.h"
diff --git a/tools/perf/ui/setup.c b/tools/perf/ui/setup.c
index 5ea0b40c4fc2..caf1ce6f5152 100644
--- a/tools/perf/ui/setup.c
+++ b/tools/perf/ui/setup.c
@@ -10,7 +10,10 @@ pthread_mutex_t ui__lock = PTHREAD_MUTEX_INITIALIZER;
10void *perf_gtk_handle; 10void *perf_gtk_handle;
11int use_browser = -1; 11int use_browser = -1;
12 12
13#define PERF_GTK_DSO "libperf-gtk.so"
14
13#ifdef HAVE_GTK2_SUPPORT 15#ifdef HAVE_GTK2_SUPPORT
16
14static int setup_gtk_browser(void) 17static int setup_gtk_browser(void)
15{ 18{
16 int (*perf_ui_init)(void); 19 int (*perf_ui_init)(void);
diff --git a/tools/perf/util/Build b/tools/perf/util/Build
index 069583bdc670..79dea95a7f68 100644
--- a/tools/perf/util/Build
+++ b/tools/perf/util/Build
@@ -13,6 +13,7 @@ libperf-y += find_bit.o
13libperf-y += kallsyms.o 13libperf-y += kallsyms.o
14libperf-y += levenshtein.o 14libperf-y += levenshtein.o
15libperf-y += llvm-utils.o 15libperf-y += llvm-utils.o
16libperf-y += memswap.o
16libperf-y += parse-events.o 17libperf-y += parse-events.o
17libperf-y += perf_regs.o 18libperf-y += perf_regs.o
18libperf-y += path.o 19libperf-y += path.o
diff --git a/tools/perf/util/build-id.h b/tools/perf/util/build-id.h
index a96081121179..8a89b195c1fc 100644
--- a/tools/perf/util/build-id.h
+++ b/tools/perf/util/build-id.h
@@ -44,6 +44,10 @@ bool build_id_cache__cached(const char *sbuild_id);
44int build_id_cache__add_s(const char *sbuild_id, 44int build_id_cache__add_s(const char *sbuild_id,
45 const char *name, bool is_kallsyms, bool is_vdso); 45 const char *name, bool is_kallsyms, bool is_vdso);
46int build_id_cache__remove_s(const char *sbuild_id); 46int build_id_cache__remove_s(const char *sbuild_id);
47
48extern char buildid_dir[];
49
50void set_buildid_dir(const char *dir);
47void disable_buildid_cache(void); 51void disable_buildid_cache(void);
48 52
49#endif 53#endif
diff --git a/tools/perf/util/event.c b/tools/perf/util/event.c
index 142835c0ca0a..dc5c3bb69d73 100644
--- a/tools/perf/util/event.c
+++ b/tools/perf/util/event.c
@@ -8,6 +8,7 @@
8#include <unistd.h> 8#include <unistd.h>
9#include <uapi/linux/mman.h> /* To get things like MAP_HUGETLB even on older libc headers */ 9#include <uapi/linux/mman.h> /* To get things like MAP_HUGETLB even on older libc headers */
10#include <api/fs/fs.h> 10#include <api/fs/fs.h>
11#include <linux/perf_event.h>
11#include "event.h" 12#include "event.h"
12#include "debug.h" 13#include "debug.h"
13#include "hist.h" 14#include "hist.h"
@@ -767,15 +768,16 @@ static int find_symbol_cb(void *arg, const char *name, char type,
767 return 1; 768 return 1;
768} 769}
769 770
770u64 kallsyms__get_function_start(const char *kallsyms_filename, 771int kallsyms__get_function_start(const char *kallsyms_filename,
771 const char *symbol_name) 772 const char *symbol_name, u64 *addr)
772{ 773{
773 struct process_symbol_args args = { .name = symbol_name, }; 774 struct process_symbol_args args = { .name = symbol_name, };
774 775
775 if (kallsyms__parse(kallsyms_filename, &args, find_symbol_cb) <= 0) 776 if (kallsyms__parse(kallsyms_filename, &args, find_symbol_cb) <= 0)
776 return 0; 777 return -1;
777 778
778 return args.start; 779 *addr = args.start;
780 return 0;
779} 781}
780 782
781int perf_event__synthesize_kernel_mmap(struct perf_tool *tool, 783int perf_event__synthesize_kernel_mmap(struct perf_tool *tool,
diff --git a/tools/perf/util/event.h b/tools/perf/util/event.h
index db2de6413518..7c3fa1c8cbcd 100644
--- a/tools/perf/util/event.h
+++ b/tools/perf/util/event.h
@@ -229,7 +229,7 @@ struct build_id_event {
229enum perf_user_event_type { /* above any possible kernel type */ 229enum perf_user_event_type { /* above any possible kernel type */
230 PERF_RECORD_USER_TYPE_START = 64, 230 PERF_RECORD_USER_TYPE_START = 64,
231 PERF_RECORD_HEADER_ATTR = 64, 231 PERF_RECORD_HEADER_ATTR = 64,
232 PERF_RECORD_HEADER_EVENT_TYPE = 65, /* depreceated */ 232 PERF_RECORD_HEADER_EVENT_TYPE = 65, /* deprecated */
233 PERF_RECORD_HEADER_TRACING_DATA = 66, 233 PERF_RECORD_HEADER_TRACING_DATA = 66,
234 PERF_RECORD_HEADER_BUILD_ID = 67, 234 PERF_RECORD_HEADER_BUILD_ID = 67,
235 PERF_RECORD_FINISHED_ROUND = 68, 235 PERF_RECORD_FINISHED_ROUND = 68,
@@ -675,10 +675,18 @@ size_t perf_event__fprintf_cpu_map(union perf_event *event, FILE *fp);
675size_t perf_event__fprintf_namespaces(union perf_event *event, FILE *fp); 675size_t perf_event__fprintf_namespaces(union perf_event *event, FILE *fp);
676size_t perf_event__fprintf(union perf_event *event, FILE *fp); 676size_t perf_event__fprintf(union perf_event *event, FILE *fp);
677 677
678u64 kallsyms__get_function_start(const char *kallsyms_filename, 678int kallsyms__get_function_start(const char *kallsyms_filename,
679 const char *symbol_name); 679 const char *symbol_name, u64 *addr);
680 680
681void *cpu_map_data__alloc(struct cpu_map *map, size_t *size, u16 *type, int *max); 681void *cpu_map_data__alloc(struct cpu_map *map, size_t *size, u16 *type, int *max);
682void cpu_map_data__synthesize(struct cpu_map_data *data, struct cpu_map *map, 682void cpu_map_data__synthesize(struct cpu_map_data *data, struct cpu_map *map,
683 u16 type, int max); 683 u16 type, int max);
684
685void event_attr_init(struct perf_event_attr *attr);
686
687int perf_event_paranoid(void);
688
689extern int sysctl_perf_event_max_stack;
690extern int sysctl_perf_event_max_contexts_per_stack;
691
684#endif /* __PERF_RECORD_H */ 692#endif /* __PERF_RECORD_H */
diff --git a/tools/perf/util/evsel.c b/tools/perf/util/evsel.c
index 0e879097adfb..e4f7902d5afa 100644
--- a/tools/perf/util/evsel.c
+++ b/tools/perf/util/evsel.c
@@ -21,6 +21,7 @@
21#include "asm/bug.h" 21#include "asm/bug.h"
22#include "callchain.h" 22#include "callchain.h"
23#include "cgroup.h" 23#include "cgroup.h"
24#include "event.h"
24#include "evsel.h" 25#include "evsel.h"
25#include "evlist.h" 26#include "evlist.h"
26#include "util.h" 27#include "util.h"
diff --git a/tools/perf/util/header.c b/tools/perf/util/header.c
index 948b2c5efb65..314a07151fb7 100644
--- a/tools/perf/util/header.c
+++ b/tools/perf/util/header.c
@@ -19,6 +19,7 @@
19#include "evlist.h" 19#include "evlist.h"
20#include "evsel.h" 20#include "evsel.h"
21#include "header.h" 21#include "header.h"
22#include "memswap.h"
22#include "../perf.h" 23#include "../perf.h"
23#include "trace-event.h" 24#include "trace-event.h"
24#include "session.h" 25#include "session.h"
diff --git a/tools/perf/util/intel-pt.c b/tools/perf/util/intel-pt.c
index bdd4a28c6cee..4c7718f87a08 100644
--- a/tools/perf/util/intel-pt.c
+++ b/tools/perf/util/intel-pt.c
@@ -23,6 +23,7 @@
23#include "../perf.h" 23#include "../perf.h"
24#include "session.h" 24#include "session.h"
25#include "machine.h" 25#include "machine.h"
26#include "memswap.h"
26#include "sort.h" 27#include "sort.h"
27#include "tool.h" 28#include "tool.h"
28#include "event.h" 29#include "event.h"
diff --git a/tools/perf/util/machine.c b/tools/perf/util/machine.c
index 7a47f52ccfcc..d97e014c3df3 100644
--- a/tools/perf/util/machine.c
+++ b/tools/perf/util/machine.c
@@ -796,11 +796,11 @@ const char *ref_reloc_sym_names[] = {"_text", "_stext", NULL};
796 * Returns the name of the start symbol in *symbol_name. Pass in NULL as 796 * Returns the name of the start symbol in *symbol_name. Pass in NULL as
797 * symbol_name if it's not that important. 797 * symbol_name if it's not that important.
798 */ 798 */
799static u64 machine__get_running_kernel_start(struct machine *machine, 799static int machine__get_running_kernel_start(struct machine *machine,
800 const char **symbol_name) 800 const char **symbol_name, u64 *start)
801{ 801{
802 char filename[PATH_MAX]; 802 char filename[PATH_MAX];
803 int i; 803 int i, err = -1;
804 const char *name; 804 const char *name;
805 u64 addr = 0; 805 u64 addr = 0;
806 806
@@ -810,21 +810,28 @@ static u64 machine__get_running_kernel_start(struct machine *machine,
810 return 0; 810 return 0;
811 811
812 for (i = 0; (name = ref_reloc_sym_names[i]) != NULL; i++) { 812 for (i = 0; (name = ref_reloc_sym_names[i]) != NULL; i++) {
813 addr = kallsyms__get_function_start(filename, name); 813 err = kallsyms__get_function_start(filename, name, &addr);
814 if (addr) 814 if (!err)
815 break; 815 break;
816 } 816 }
817 817
818 if (err)
819 return -1;
820
818 if (symbol_name) 821 if (symbol_name)
819 *symbol_name = name; 822 *symbol_name = name;
820 823
821 return addr; 824 *start = addr;
825 return 0;
822} 826}
823 827
824int __machine__create_kernel_maps(struct machine *machine, struct dso *kernel) 828int __machine__create_kernel_maps(struct machine *machine, struct dso *kernel)
825{ 829{
826 int type; 830 int type;
827 u64 start = machine__get_running_kernel_start(machine, NULL); 831 u64 start = 0;
832
833 if (machine__get_running_kernel_start(machine, NULL, &start))
834 return -1;
828 835
829 /* In case of renewal the kernel map, destroy previous one */ 836 /* In case of renewal the kernel map, destroy previous one */
830 machine__destroy_kernel_maps(machine); 837 machine__destroy_kernel_maps(machine);
@@ -1185,8 +1192,8 @@ static int machine__create_modules(struct machine *machine)
1185int machine__create_kernel_maps(struct machine *machine) 1192int machine__create_kernel_maps(struct machine *machine)
1186{ 1193{
1187 struct dso *kernel = machine__get_kernel(machine); 1194 struct dso *kernel = machine__get_kernel(machine);
1188 const char *name; 1195 const char *name = NULL;
1189 u64 addr; 1196 u64 addr = 0;
1190 int ret; 1197 int ret;
1191 1198
1192 if (kernel == NULL) 1199 if (kernel == NULL)
@@ -1211,8 +1218,7 @@ int machine__create_kernel_maps(struct machine *machine)
1211 */ 1218 */
1212 map_groups__fixup_end(&machine->kmaps); 1219 map_groups__fixup_end(&machine->kmaps);
1213 1220
1214 addr = machine__get_running_kernel_start(machine, &name); 1221 if (machine__get_running_kernel_start(machine, &name, &addr)) {
1215 if (!addr) {
1216 } else if (maps__set_kallsyms_ref_reloc_sym(machine->vmlinux_maps, name, addr)) { 1222 } else if (maps__set_kallsyms_ref_reloc_sym(machine->vmlinux_maps, name, addr)) {
1217 machine__destroy_kernel_maps(machine); 1223 machine__destroy_kernel_maps(machine);
1218 return -1; 1224 return -1;
diff --git a/tools/perf/util/map.c b/tools/perf/util/map.c
index ebfa5d92358a..2179b2deb730 100644
--- a/tools/perf/util/map.c
+++ b/tools/perf/util/map.c
@@ -325,11 +325,6 @@ int map__load(struct map *map)
325 return 0; 325 return 0;
326} 326}
327 327
328int __weak arch__compare_symbol_names(const char *namea, const char *nameb)
329{
330 return strcmp(namea, nameb);
331}
332
333struct symbol *map__find_symbol(struct map *map, u64 addr) 328struct symbol *map__find_symbol(struct map *map, u64 addr)
334{ 329{
335 if (map__load(map) < 0) 330 if (map__load(map) < 0)
diff --git a/tools/perf/util/map.h b/tools/perf/util/map.h
index c8a5a644c0a9..f9e8ac8a52cd 100644
--- a/tools/perf/util/map.h
+++ b/tools/perf/util/map.h
@@ -130,13 +130,14 @@ struct thread;
130 */ 130 */
131#define __map__for_each_symbol_by_name(map, sym_name, pos) \ 131#define __map__for_each_symbol_by_name(map, sym_name, pos) \
132 for (pos = map__find_symbol_by_name(map, sym_name); \ 132 for (pos = map__find_symbol_by_name(map, sym_name); \
133 pos && arch__compare_symbol_names(pos->name, sym_name) == 0; \ 133 pos && \
134 !symbol__match_symbol_name(pos->name, sym_name, \
135 SYMBOL_TAG_INCLUDE__DEFAULT_ONLY); \
134 pos = symbol__next_by_name(pos)) 136 pos = symbol__next_by_name(pos))
135 137
136#define map__for_each_symbol_by_name(map, sym_name, pos) \ 138#define map__for_each_symbol_by_name(map, sym_name, pos) \
137 __map__for_each_symbol_by_name(map, sym_name, (pos)) 139 __map__for_each_symbol_by_name(map, sym_name, (pos))
138 140
139int arch__compare_symbol_names(const char *namea, const char *nameb);
140void map__init(struct map *map, enum map_type type, 141void map__init(struct map *map, enum map_type type,
141 u64 start, u64 end, u64 pgoff, struct dso *dso); 142 u64 start, u64 end, u64 pgoff, struct dso *dso);
142struct map *map__new(struct machine *machine, u64 start, u64 len, 143struct map *map__new(struct machine *machine, u64 start, u64 len,
diff --git a/tools/perf/util/memswap.c b/tools/perf/util/memswap.c
new file mode 100644
index 000000000000..55f7faa8d9ec
--- /dev/null
+++ b/tools/perf/util/memswap.c
@@ -0,0 +1,24 @@
1#include <byteswap.h>
2#include "memswap.h"
3#include <linux/types.h>
4
5void mem_bswap_32(void *src, int byte_size)
6{
7 u32 *m = src;
8 while (byte_size > 0) {
9 *m = bswap_32(*m);
10 byte_size -= sizeof(u32);
11 ++m;
12 }
13}
14
15void mem_bswap_64(void *src, int byte_size)
16{
17 u64 *m = src;
18
19 while (byte_size > 0) {
20 *m = bswap_64(*m);
21 byte_size -= sizeof(u64);
22 ++m;
23 }
24}
diff --git a/tools/perf/util/memswap.h b/tools/perf/util/memswap.h
new file mode 100644
index 000000000000..7d1b1c34bb57
--- /dev/null
+++ b/tools/perf/util/memswap.h
@@ -0,0 +1,7 @@
1#ifndef PERF_MEMSWAP_H_
2#define PERF_MEMSWAP_H_
3
4void mem_bswap_64(void *src, int byte_size);
5void mem_bswap_32(void *src, int byte_size);
6
7#endif /* PERF_MEMSWAP_H_ */
diff --git a/tools/perf/util/scripting-engines/trace-event-perl.c b/tools/perf/util/scripting-engines/trace-event-perl.c
index 2b12bdb3ce33..7b79c413486b 100644
--- a/tools/perf/util/scripting-engines/trace-event-perl.c
+++ b/tools/perf/util/scripting-engines/trace-event-perl.c
@@ -28,7 +28,9 @@
28#include <linux/bitmap.h> 28#include <linux/bitmap.h>
29#include <linux/time64.h> 29#include <linux/time64.h>
30 30
31#include "../util.h" 31#include <stdbool.h>
32/* perl needs the following define, right after including stdbool.h */
33#define HAS_BOOL
32#include <EXTERN.h> 34#include <EXTERN.h>
33#include <perl.h> 35#include <perl.h>
34 36
diff --git a/tools/perf/util/session.c b/tools/perf/util/session.c
index 3041c6b98191..7dc1096264c5 100644
--- a/tools/perf/util/session.c
+++ b/tools/perf/util/session.c
@@ -11,6 +11,7 @@
11 11
12#include "evlist.h" 12#include "evlist.h"
13#include "evsel.h" 13#include "evsel.h"
14#include "memswap.h"
14#include "session.h" 15#include "session.h"
15#include "tool.h" 16#include "tool.h"
16#include "sort.h" 17#include "sort.h"
diff --git a/tools/perf/util/strbuf.c b/tools/perf/util/strbuf.c
index e91b5e86f027..aafe908b82b5 100644
--- a/tools/perf/util/strbuf.c
+++ b/tools/perf/util/strbuf.c
@@ -3,15 +3,6 @@
3#include <linux/kernel.h> 3#include <linux/kernel.h>
4#include <errno.h> 4#include <errno.h>
5 5
6int prefixcmp(const char *str, const char *prefix)
7{
8 for (; ; str++, prefix++)
9 if (!*prefix)
10 return 0;
11 else if (*str != *prefix)
12 return (unsigned char)*prefix - (unsigned char)*str;
13}
14
15/* 6/*
16 * Used as the default ->buf value, so that people can always assume 7 * Used as the default ->buf value, so that people can always assume
17 * buf is non NULL and ->buf is NUL terminated even for a freshly 8 * buf is non NULL and ->buf is NUL terminated even for a freshly
diff --git a/tools/perf/util/symbol.c b/tools/perf/util/symbol.c
index 2cb7665e9973..8f2b068ff756 100644
--- a/tools/perf/util/symbol.c
+++ b/tools/perf/util/symbol.c
@@ -90,6 +90,17 @@ static int prefix_underscores_count(const char *str)
90 return tail - str; 90 return tail - str;
91} 91}
92 92
93int __weak arch__compare_symbol_names(const char *namea, const char *nameb)
94{
95 return strcmp(namea, nameb);
96}
97
98int __weak arch__compare_symbol_names_n(const char *namea, const char *nameb,
99 unsigned int n)
100{
101 return strncmp(namea, nameb, n);
102}
103
93int __weak arch__choose_best_symbol(struct symbol *syma, 104int __weak arch__choose_best_symbol(struct symbol *syma,
94 struct symbol *symb __maybe_unused) 105 struct symbol *symb __maybe_unused)
95{ 106{
@@ -399,8 +410,26 @@ static void symbols__sort_by_name(struct rb_root *symbols,
399 } 410 }
400} 411}
401 412
413int symbol__match_symbol_name(const char *name, const char *str,
414 enum symbol_tag_include includes)
415{
416 const char *versioning;
417
418 if (includes == SYMBOL_TAG_INCLUDE__DEFAULT_ONLY &&
419 (versioning = strstr(name, "@@"))) {
420 int len = strlen(str);
421
422 if (len < versioning - name)
423 len = versioning - name;
424
425 return arch__compare_symbol_names_n(name, str, len);
426 } else
427 return arch__compare_symbol_names(name, str);
428}
429
402static struct symbol *symbols__find_by_name(struct rb_root *symbols, 430static struct symbol *symbols__find_by_name(struct rb_root *symbols,
403 const char *name) 431 const char *name,
432 enum symbol_tag_include includes)
404{ 433{
405 struct rb_node *n; 434 struct rb_node *n;
406 struct symbol_name_rb_node *s = NULL; 435 struct symbol_name_rb_node *s = NULL;
@@ -414,11 +443,11 @@ static struct symbol *symbols__find_by_name(struct rb_root *symbols,
414 int cmp; 443 int cmp;
415 444
416 s = rb_entry(n, struct symbol_name_rb_node, rb_node); 445 s = rb_entry(n, struct symbol_name_rb_node, rb_node);
417 cmp = arch__compare_symbol_names(name, s->sym.name); 446 cmp = symbol__match_symbol_name(s->sym.name, name, includes);
418 447
419 if (cmp < 0) 448 if (cmp > 0)
420 n = n->rb_left; 449 n = n->rb_left;
421 else if (cmp > 0) 450 else if (cmp < 0)
422 n = n->rb_right; 451 n = n->rb_right;
423 else 452 else
424 break; 453 break;
@@ -427,16 +456,17 @@ static struct symbol *symbols__find_by_name(struct rb_root *symbols,
427 if (n == NULL) 456 if (n == NULL)
428 return NULL; 457 return NULL;
429 458
430 /* return first symbol that has same name (if any) */ 459 if (includes != SYMBOL_TAG_INCLUDE__DEFAULT_ONLY)
431 for (n = rb_prev(n); n; n = rb_prev(n)) { 460 /* return first symbol that has same name (if any) */
432 struct symbol_name_rb_node *tmp; 461 for (n = rb_prev(n); n; n = rb_prev(n)) {
462 struct symbol_name_rb_node *tmp;
433 463
434 tmp = rb_entry(n, struct symbol_name_rb_node, rb_node); 464 tmp = rb_entry(n, struct symbol_name_rb_node, rb_node);
435 if (arch__compare_symbol_names(tmp->sym.name, s->sym.name)) 465 if (arch__compare_symbol_names(tmp->sym.name, s->sym.name))
436 break; 466 break;
437 467
438 s = tmp; 468 s = tmp;
439 } 469 }
440 470
441 return &s->sym; 471 return &s->sym;
442} 472}
@@ -466,7 +496,7 @@ void dso__insert_symbol(struct dso *dso, enum map_type type, struct symbol *sym)
466struct symbol *dso__find_symbol(struct dso *dso, 496struct symbol *dso__find_symbol(struct dso *dso,
467 enum map_type type, u64 addr) 497 enum map_type type, u64 addr)
468{ 498{
469 if (dso->last_find_result[type].addr != addr) { 499 if (dso->last_find_result[type].addr != addr || dso->last_find_result[type].symbol == NULL) {
470 dso->last_find_result[type].addr = addr; 500 dso->last_find_result[type].addr = addr;
471 dso->last_find_result[type].symbol = symbols__find(&dso->symbols[type], addr); 501 dso->last_find_result[type].symbol = symbols__find(&dso->symbols[type], addr);
472 } 502 }
@@ -503,7 +533,12 @@ struct symbol *symbol__next_by_name(struct symbol *sym)
503struct symbol *dso__find_symbol_by_name(struct dso *dso, enum map_type type, 533struct symbol *dso__find_symbol_by_name(struct dso *dso, enum map_type type,
504 const char *name) 534 const char *name)
505{ 535{
506 return symbols__find_by_name(&dso->symbol_names[type], name); 536 struct symbol *s = symbols__find_by_name(&dso->symbol_names[type], name,
537 SYMBOL_TAG_INCLUDE__NONE);
538 if (!s)
539 s = symbols__find_by_name(&dso->symbol_names[type], name,
540 SYMBOL_TAG_INCLUDE__DEFAULT_ONLY);
541 return s;
507} 542}
508 543
509void dso__sort_by_name(struct dso *dso, enum map_type type) 544void dso__sort_by_name(struct dso *dso, enum map_type type)
@@ -1075,8 +1110,9 @@ static int validate_kcore_addresses(const char *kallsyms_filename,
1075 if (kmap->ref_reloc_sym && kmap->ref_reloc_sym->name) { 1110 if (kmap->ref_reloc_sym && kmap->ref_reloc_sym->name) {
1076 u64 start; 1111 u64 start;
1077 1112
1078 start = kallsyms__get_function_start(kallsyms_filename, 1113 if (kallsyms__get_function_start(kallsyms_filename,
1079 kmap->ref_reloc_sym->name); 1114 kmap->ref_reloc_sym->name, &start))
1115 return -ENOENT;
1080 if (start != kmap->ref_reloc_sym->addr) 1116 if (start != kmap->ref_reloc_sym->addr)
1081 return -EINVAL; 1117 return -EINVAL;
1082 } 1118 }
@@ -1248,9 +1284,7 @@ static int kallsyms__delta(struct map *map, const char *filename, u64 *delta)
1248 if (!kmap->ref_reloc_sym || !kmap->ref_reloc_sym->name) 1284 if (!kmap->ref_reloc_sym || !kmap->ref_reloc_sym->name)
1249 return 0; 1285 return 0;
1250 1286
1251 addr = kallsyms__get_function_start(filename, 1287 if (kallsyms__get_function_start(filename, kmap->ref_reloc_sym->name, &addr))
1252 kmap->ref_reloc_sym->name);
1253 if (!addr)
1254 return -1; 1288 return -1;
1255 1289
1256 *delta = addr - kmap->ref_reloc_sym->addr; 1290 *delta = addr - kmap->ref_reloc_sym->addr;
diff --git a/tools/perf/util/symbol.h b/tools/perf/util/symbol.h
index 7acd70fce68e..41ebba9a2eb2 100644
--- a/tools/perf/util/symbol.h
+++ b/tools/perf/util/symbol.h
@@ -348,8 +348,19 @@ void arch__sym_update(struct symbol *s, GElf_Sym *sym);
348#define SYMBOL_A 0 348#define SYMBOL_A 0
349#define SYMBOL_B 1 349#define SYMBOL_B 1
350 350
351int arch__compare_symbol_names(const char *namea, const char *nameb);
352int arch__compare_symbol_names_n(const char *namea, const char *nameb,
353 unsigned int n);
351int arch__choose_best_symbol(struct symbol *syma, struct symbol *symb); 354int arch__choose_best_symbol(struct symbol *syma, struct symbol *symb);
352 355
356enum symbol_tag_include {
357 SYMBOL_TAG_INCLUDE__NONE = 0,
358 SYMBOL_TAG_INCLUDE__DEFAULT_ONLY
359};
360
361int symbol__match_symbol_name(const char *namea, const char *nameb,
362 enum symbol_tag_include includes);
363
353/* structure containing an SDT note's info */ 364/* structure containing an SDT note's info */
354struct sdt_note { 365struct sdt_note {
355 char *name; /* name of the note*/ 366 char *name; /* name of the note*/
diff --git a/tools/perf/util/units.c b/tools/perf/util/units.c
index f6a2a3d117d5..4767ec2c5ef6 100644
--- a/tools/perf/util/units.c
+++ b/tools/perf/util/units.c
@@ -1,8 +1,37 @@
1#include "units.h" 1#include "units.h"
2#include <inttypes.h> 2#include <inttypes.h>
3#include <limits.h>
4#include <stdlib.h>
5#include <string.h>
3#include <linux/kernel.h> 6#include <linux/kernel.h>
4#include <linux/time64.h> 7#include <linux/time64.h>
5 8
9unsigned long parse_tag_value(const char *str, struct parse_tag *tags)
10{
11 struct parse_tag *i = tags;
12
13 while (i->tag) {
14 char *s = strchr(str, i->tag);
15
16 if (s) {
17 unsigned long int value;
18 char *endptr;
19
20 value = strtoul(str, &endptr, 10);
21 if (s != endptr)
22 break;
23
24 if (value > ULONG_MAX / i->mult)
25 break;
26 value *= i->mult;
27 return value;
28 }
29 i++;
30 }
31
32 return (unsigned long) -1;
33}
34
6unsigned long convert_unit(unsigned long value, char *unit) 35unsigned long convert_unit(unsigned long value, char *unit)
7{ 36{
8 *unit = ' '; 37 *unit = ' ';
diff --git a/tools/perf/util/units.h b/tools/perf/util/units.h
index 3ed7774afaa9..f02c87317150 100644
--- a/tools/perf/util/units.h
+++ b/tools/perf/util/units.h
@@ -4,6 +4,13 @@
4#include <stddef.h> 4#include <stddef.h>
5#include <linux/types.h> 5#include <linux/types.h>
6 6
7struct parse_tag {
8 char tag;
9 int mult;
10};
11
12unsigned long parse_tag_value(const char *str, struct parse_tag *tags);
13
7unsigned long convert_unit(unsigned long value, char *unit); 14unsigned long convert_unit(unsigned long value, char *unit);
8int unit_number__scnprintf(char *buf, size_t size, u64 n); 15int unit_number__scnprintf(char *buf, size_t size, u64 n);
9 16
diff --git a/tools/perf/util/util.c b/tools/perf/util/util.c
index 6450c75a6f5b..28c9f335006c 100644
--- a/tools/perf/util/util.c
+++ b/tools/perf/util/util.c
@@ -13,7 +13,6 @@
13#include <string.h> 13#include <string.h>
14#include <errno.h> 14#include <errno.h>
15#include <limits.h> 15#include <limits.h>
16#include <byteswap.h>
17#include <linux/kernel.h> 16#include <linux/kernel.h>
18#include <linux/log2.h> 17#include <linux/log2.h>
19#include <linux/time64.h> 18#include <linux/time64.h>
@@ -335,33 +334,6 @@ int hex2u64(const char *ptr, u64 *long_val)
335 return p - ptr; 334 return p - ptr;
336} 335}
337 336
338unsigned long parse_tag_value(const char *str, struct parse_tag *tags)
339{
340 struct parse_tag *i = tags;
341
342 while (i->tag) {
343 char *s;
344
345 s = strchr(str, i->tag);
346 if (s) {
347 unsigned long int value;
348 char *endptr;
349
350 value = strtoul(str, &endptr, 10);
351 if (s != endptr)
352 break;
353
354 if (value > ULONG_MAX / i->mult)
355 break;
356 value *= i->mult;
357 return value;
358 }
359 i++;
360 }
361
362 return (unsigned long) -1;
363}
364
365int perf_event_paranoid(void) 337int perf_event_paranoid(void)
366{ 338{
367 int value; 339 int value;
@@ -372,27 +344,6 @@ int perf_event_paranoid(void)
372 return value; 344 return value;
373} 345}
374 346
375void mem_bswap_32(void *src, int byte_size)
376{
377 u32 *m = src;
378 while (byte_size > 0) {
379 *m = bswap_32(*m);
380 byte_size -= sizeof(u32);
381 ++m;
382 }
383}
384
385void mem_bswap_64(void *src, int byte_size)
386{
387 u64 *m = src;
388
389 while (byte_size > 0) {
390 *m = bswap_64(*m);
391 byte_size -= sizeof(u64);
392 ++m;
393 }
394}
395
396bool find_process(const char *name) 347bool find_process(const char *name)
397{ 348{
398 size_t len = strlen(name); 349 size_t len = strlen(name);
diff --git a/tools/perf/util/util.h b/tools/perf/util/util.h
index 3852b6d3270a..5dfb9bb6482d 100644
--- a/tools/perf/util/util.h
+++ b/tools/perf/util/util.h
@@ -5,7 +5,6 @@
5#define _BSD_SOURCE 1 5#define _BSD_SOURCE 1
6/* glibc 2.20 deprecates _BSD_SOURCE in favour of _DEFAULT_SOURCE */ 6/* glibc 2.20 deprecates _BSD_SOURCE in favour of _DEFAULT_SOURCE */
7#define _DEFAULT_SOURCE 1 7#define _DEFAULT_SOURCE 1
8#define HAS_BOOL
9 8
10#include <fcntl.h> 9#include <fcntl.h>
11#include <stdbool.h> 10#include <stdbool.h>
@@ -14,8 +13,6 @@
14#include <stdarg.h> 13#include <stdarg.h>
15#include <linux/types.h> 14#include <linux/types.h>
16 15
17extern char buildid_dir[];
18
19#ifdef __GNUC__ 16#ifdef __GNUC__
20#define NORETURN __attribute__((__noreturn__)) 17#define NORETURN __attribute__((__noreturn__))
21#else 18#else
@@ -25,8 +22,6 @@ extern char buildid_dir[];
25#endif 22#endif
26#endif 23#endif
27 24
28#define PERF_GTK_DSO "libperf-gtk.so"
29
30/* General helper functions */ 25/* General helper functions */
31void usage(const char *err) NORETURN; 26void usage(const char *err) NORETURN;
32void die(const char *err, ...) NORETURN __attribute__((format (printf, 1, 2))); 27void die(const char *err, ...) NORETURN __attribute__((format (printf, 1, 2)));
@@ -35,9 +30,6 @@ void warning(const char *err, ...) __attribute__((format (printf, 1, 2)));
35 30
36void set_warning_routine(void (*routine)(const char *err, va_list params)); 31void set_warning_routine(void (*routine)(const char *err, va_list params));
37 32
38int prefixcmp(const char *str, const char *prefix);
39void set_buildid_dir(const char *dir);
40
41static inline void *zalloc(size_t size) 33static inline void *zalloc(size_t size)
42{ 34{
43 return calloc(1, size); 35 return calloc(1, size);
@@ -59,29 +51,11 @@ int copyfile_offset(int fromfd, loff_t from_ofs, int tofd, loff_t to_ofs, u64 si
59ssize_t readn(int fd, void *buf, size_t n); 51ssize_t readn(int fd, void *buf, size_t n);
60ssize_t writen(int fd, void *buf, size_t n); 52ssize_t writen(int fd, void *buf, size_t n);
61 53
62struct perf_event_attr;
63
64void event_attr_init(struct perf_event_attr *attr);
65
66size_t hex_width(u64 v); 54size_t hex_width(u64 v);
67int hex2u64(const char *ptr, u64 *val); 55int hex2u64(const char *ptr, u64 *val);
68 56
69extern unsigned int page_size; 57extern unsigned int page_size;
70extern int cacheline_size; 58extern int cacheline_size;
71extern int sysctl_perf_event_max_stack;
72extern int sysctl_perf_event_max_contexts_per_stack;
73
74struct parse_tag {
75 char tag;
76 int mult;
77};
78
79unsigned long parse_tag_value(const char *str, struct parse_tag *tags);
80
81int perf_event_paranoid(void);
82
83void mem_bswap_64(void *src, int byte_size);
84void mem_bswap_32(void *src, int byte_size);
85 59
86bool find_process(const char *name); 60bool find_process(const char *name);
87 61
diff --git a/tools/testing/selftests/rcutorture/bin/kvm-test-1-run.sh b/tools/testing/selftests/rcutorture/bin/kvm-test-1-run.sh
index ea6e373edc27..93eede4e8fbe 100755
--- a/tools/testing/selftests/rcutorture/bin/kvm-test-1-run.sh
+++ b/tools/testing/selftests/rcutorture/bin/kvm-test-1-run.sh
@@ -170,7 +170,7 @@ qemu_append="`identify_qemu_append "$QEMU"`"
170# Pull in Kconfig-fragment boot parameters 170# Pull in Kconfig-fragment boot parameters
171boot_args="`configfrag_boot_params "$boot_args" "$config_template"`" 171boot_args="`configfrag_boot_params "$boot_args" "$config_template"`"
172# Generate kernel-version-specific boot parameters 172# Generate kernel-version-specific boot parameters
173boot_args="`per_version_boot_params "$boot_args" $builddir/.config $seconds`" 173boot_args="`per_version_boot_params "$boot_args" $resdir/.config $seconds`"
174 174
175if test -n "$TORTURE_BUILDONLY" 175if test -n "$TORTURE_BUILDONLY"
176then 176then
diff --git a/tools/virtio/linux/virtio.h b/tools/virtio/linux/virtio.h
index 9377c8b4ac16..d8f534025b7f 100644
--- a/tools/virtio/linux/virtio.h
+++ b/tools/virtio/linux/virtio.h
@@ -57,6 +57,7 @@ struct virtqueue *vring_new_virtqueue(unsigned int index,
57 unsigned int vring_align, 57 unsigned int vring_align,
58 struct virtio_device *vdev, 58 struct virtio_device *vdev,
59 bool weak_barriers, 59 bool weak_barriers,
60 bool ctx,
60 void *pages, 61 void *pages,
61 bool (*notify)(struct virtqueue *vq), 62 bool (*notify)(struct virtqueue *vq),
62 void (*callback)(struct virtqueue *vq), 63 void (*callback)(struct virtqueue *vq),
diff --git a/tools/virtio/ringtest/main.c b/tools/virtio/ringtest/main.c
index f31353fac541..453ca3c21193 100644
--- a/tools/virtio/ringtest/main.c
+++ b/tools/virtio/ringtest/main.c
@@ -20,6 +20,7 @@
20int runcycles = 10000000; 20int runcycles = 10000000;
21int max_outstanding = INT_MAX; 21int max_outstanding = INT_MAX;
22int batch = 1; 22int batch = 1;
23int param = 0;
23 24
24bool do_sleep = false; 25bool do_sleep = false;
25bool do_relax = false; 26bool do_relax = false;
@@ -86,7 +87,7 @@ void set_affinity(const char *arg)
86 cpu = strtol(arg, &endptr, 0); 87 cpu = strtol(arg, &endptr, 0);
87 assert(!*endptr); 88 assert(!*endptr);
88 89
89 assert(cpu >= 0 || cpu < CPU_SETSIZE); 90 assert(cpu >= 0 && cpu < CPU_SETSIZE);
90 91
91 self = pthread_self(); 92 self = pthread_self();
92 CPU_ZERO(&cpuset); 93 CPU_ZERO(&cpuset);
@@ -247,6 +248,11 @@ static const struct option longopts[] = {
247 .val = 'b', 248 .val = 'b',
248 }, 249 },
249 { 250 {
251 .name = "param",
252 .has_arg = required_argument,
253 .val = 'p',
254 },
255 {
250 .name = "sleep", 256 .name = "sleep",
251 .has_arg = no_argument, 257 .has_arg = no_argument,
252 .val = 's', 258 .val = 's',
@@ -274,6 +280,7 @@ static void help(void)
274 " [--run-cycles C (default: %d)]" 280 " [--run-cycles C (default: %d)]"
275 " [--batch b]" 281 " [--batch b]"
276 " [--outstanding o]" 282 " [--outstanding o]"
283 " [--param p]"
277 " [--sleep]" 284 " [--sleep]"
278 " [--relax]" 285 " [--relax]"
279 " [--exit]" 286 " [--exit]"
@@ -328,6 +335,12 @@ int main(int argc, char **argv)
328 assert(c > 0 && c < INT_MAX); 335 assert(c > 0 && c < INT_MAX);
329 max_outstanding = c; 336 max_outstanding = c;
330 break; 337 break;
338 case 'p':
339 c = strtol(optarg, &endptr, 0);
340 assert(!*endptr);
341 assert(c > 0 && c < INT_MAX);
342 param = c;
343 break;
331 case 'b': 344 case 'b':
332 c = strtol(optarg, &endptr, 0); 345 c = strtol(optarg, &endptr, 0);
333 assert(!*endptr); 346 assert(!*endptr);
diff --git a/tools/virtio/ringtest/main.h b/tools/virtio/ringtest/main.h
index 14142faf040b..90b0133004e1 100644
--- a/tools/virtio/ringtest/main.h
+++ b/tools/virtio/ringtest/main.h
@@ -10,6 +10,8 @@
10 10
11#include <stdbool.h> 11#include <stdbool.h>
12 12
13extern int param;
14
13extern bool do_exit; 15extern bool do_exit;
14 16
15#if defined(__x86_64__) || defined(__i386__) 17#if defined(__x86_64__) || defined(__i386__)
diff --git a/tools/virtio/ringtest/ptr_ring.c b/tools/virtio/ringtest/ptr_ring.c
index 635b07b4fdd3..7b22f1b20652 100644
--- a/tools/virtio/ringtest/ptr_ring.c
+++ b/tools/virtio/ringtest/ptr_ring.c
@@ -97,6 +97,9 @@ void alloc_ring(void)
97{ 97{
98 int ret = ptr_ring_init(&array, ring_size, 0); 98 int ret = ptr_ring_init(&array, ring_size, 0);
99 assert(!ret); 99 assert(!ret);
100 /* Hacky way to poke at ring internals. Useful for testing though. */
101 if (param)
102 array.batch = param;
100} 103}
101 104
102/* guest side */ 105/* guest side */
diff --git a/tools/virtio/virtio_test.c b/tools/virtio/virtio_test.c
index e0445898f08f..0fecaec90d0d 100644
--- a/tools/virtio/virtio_test.c
+++ b/tools/virtio/virtio_test.c
@@ -100,7 +100,7 @@ static void vq_info_add(struct vdev_info *dev, int num)
100 vring_init(&info->vring, num, info->ring, 4096); 100 vring_init(&info->vring, num, info->ring, 4096);
101 info->vq = vring_new_virtqueue(info->idx, 101 info->vq = vring_new_virtqueue(info->idx,
102 info->vring.num, 4096, &dev->vdev, 102 info->vring.num, 4096, &dev->vdev,
103 true, info->ring, 103 true, false, info->ring,
104 vq_notify, vq_callback, "test"); 104 vq_notify, vq_callback, "test");
105 assert(info->vq); 105 assert(info->vq);
106 info->vq->priv = info; 106 info->vq->priv = info;
@@ -202,7 +202,7 @@ static void run_test(struct vdev_info *dev, struct vq_info *vq,
202 test = 0; 202 test = 0;
203 r = ioctl(dev->control, VHOST_TEST_RUN, &test); 203 r = ioctl(dev->control, VHOST_TEST_RUN, &test);
204 assert(r >= 0); 204 assert(r >= 0);
205 fprintf(stderr, "spurious wakeus: 0x%llx\n", spurious); 205 fprintf(stderr, "spurious wakeups: 0x%llx\n", spurious);
206} 206}
207 207
208const char optstring[] = "h"; 208const char optstring[] = "h";
diff --git a/tools/virtio/vringh_test.c b/tools/virtio/vringh_test.c
index 5f94f5105678..9476c616d064 100644
--- a/tools/virtio/vringh_test.c
+++ b/tools/virtio/vringh_test.c
@@ -314,7 +314,8 @@ static int parallel_test(u64 features,
314 err(1, "Could not set affinity to cpu %u", first_cpu); 314 err(1, "Could not set affinity to cpu %u", first_cpu);
315 315
316 vq = vring_new_virtqueue(0, RINGSIZE, ALIGN, &gvdev.vdev, true, 316 vq = vring_new_virtqueue(0, RINGSIZE, ALIGN, &gvdev.vdev, true,
317 guest_map, fast_vringh ? no_notify_host 317 false, guest_map,
318 fast_vringh ? no_notify_host
318 : parallel_notify_host, 319 : parallel_notify_host,
319 never_callback_guest, "guest vq"); 320 never_callback_guest, "guest vq");
320 321
@@ -479,7 +480,7 @@ int main(int argc, char *argv[])
479 memset(__user_addr_min, 0, vring_size(RINGSIZE, ALIGN)); 480 memset(__user_addr_min, 0, vring_size(RINGSIZE, ALIGN));
480 481
481 /* Set up guest side. */ 482 /* Set up guest side. */
482 vq = vring_new_virtqueue(0, RINGSIZE, ALIGN, &vdev, true, 483 vq = vring_new_virtqueue(0, RINGSIZE, ALIGN, &vdev, true, false,
483 __user_addr_min, 484 __user_addr_min,
484 never_notify_host, never_callback_guest, 485 never_notify_host, never_callback_guest,
485 "guest vq"); 486 "guest vq");
@@ -663,7 +664,7 @@ int main(int argc, char *argv[])
663 /* Force creation of direct, which we modify. */ 664 /* Force creation of direct, which we modify. */
664 __virtio_clear_bit(&vdev, VIRTIO_RING_F_INDIRECT_DESC); 665 __virtio_clear_bit(&vdev, VIRTIO_RING_F_INDIRECT_DESC);
665 vq = vring_new_virtqueue(0, RINGSIZE, ALIGN, &vdev, true, 666 vq = vring_new_virtqueue(0, RINGSIZE, ALIGN, &vdev, true,
666 __user_addr_min, 667 false, __user_addr_min,
667 never_notify_host, 668 never_notify_host,
668 never_callback_guest, 669 never_callback_guest,
669 "guest vq"); 670 "guest vq");