diff options
author | David S. Miller <davem@davemloft.net> | 2017-06-15 11:31:37 -0400 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2017-06-15 11:59:32 -0400 |
commit | 0ddead90b223faae475f3296a50bf574b7f7c69a (patch) | |
tree | e729c7fcdc7e3697f7fae2f3028ed0d11931c425 /tools | |
parent | f7aec129a356ad049edddcb7e77b04a474fcf41f (diff) | |
parent | a090bd4ff8387c409732a8e059fbf264ea0bdd56 (diff) |
Merge git://git.kernel.org/pub/scm/linux/kernel/git/davem/net
The conflicts were two cases of overlapping changes in
batman-adv and the qed driver.
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'tools')
-rw-r--r-- | tools/perf/Documentation/perf-probe.txt | 8 | ||||
-rw-r--r-- | tools/perf/Documentation/perf-script-perl.txt | 2 | ||||
-rw-r--r-- | tools/perf/Documentation/perf-script-python.txt | 23 | ||||
-rw-r--r-- | tools/perf/arch/common.c | 1 | ||||
-rw-r--r-- | tools/perf/builtin-stat.c | 5 | ||||
-rw-r--r-- | tools/perf/builtin-trace.c | 4 | ||||
-rw-r--r-- | tools/perf/tests/bp_signal.c | 14 | ||||
-rw-r--r-- | tools/perf/tests/builtin-test.c | 7 | ||||
-rw-r--r-- | tools/perf/tests/code-reading.c | 20 | ||||
-rw-r--r-- | tools/perf/tests/tests.h | 3 | ||||
-rw-r--r-- | tools/perf/util/annotate.c | 72 | ||||
-rw-r--r-- | tools/perf/util/build-id.c | 45 | ||||
-rw-r--r-- | tools/perf/util/build-id.h | 1 | ||||
-rw-r--r-- | tools/perf/util/dso.c | 100 | ||||
-rw-r--r-- | tools/perf/util/dso.h | 9 | ||||
-rw-r--r-- | tools/perf/util/header.c | 12 | ||||
-rw-r--r-- | tools/perf/util/machine.c | 11 | ||||
-rw-r--r-- | tools/perf/util/scripting-engines/trace-event-python.c | 2 | ||||
-rw-r--r-- | tools/perf/util/symbol-elf.c | 41 | ||||
-rw-r--r-- | tools/perf/util/symbol.c | 4 | ||||
-rw-r--r-- | tools/perf/util/unwind-libdw.c | 10 | ||||
-rw-r--r-- | tools/testing/selftests/bpf/bpf_endian.h | 41 |
22 files changed, 268 insertions, 167 deletions
diff --git a/tools/perf/Documentation/perf-probe.txt b/tools/perf/Documentation/perf-probe.txt index e6c9902c6d82..165c2b1d4317 100644 --- a/tools/perf/Documentation/perf-probe.txt +++ b/tools/perf/Documentation/perf-probe.txt | |||
@@ -240,9 +240,13 @@ Add a probe on schedule() function 12th line with recording cpu local variable: | |||
240 | or | 240 | or |
241 | ./perf probe --add='schedule:12 cpu' | 241 | ./perf probe --add='schedule:12 cpu' |
242 | 242 | ||
243 | this will add one or more probes which has the name start with "schedule". | 243 | Add one or more probes which has the name start with "schedule". |
244 | 244 | ||
245 | Add probes on lines in schedule() function which calls update_rq_clock(). | 245 | ./perf probe schedule* |
246 | or | ||
247 | ./perf probe --add='schedule*' | ||
248 | |||
249 | Add probes on lines in schedule() function which calls update_rq_clock(). | ||
246 | 250 | ||
247 | ./perf probe 'schedule;update_rq_clock*' | 251 | ./perf probe 'schedule;update_rq_clock*' |
248 | or | 252 | or |
diff --git a/tools/perf/Documentation/perf-script-perl.txt b/tools/perf/Documentation/perf-script-perl.txt index dfbb506d2c34..142606c0ec9c 100644 --- a/tools/perf/Documentation/perf-script-perl.txt +++ b/tools/perf/Documentation/perf-script-perl.txt | |||
@@ -39,7 +39,7 @@ EVENT HANDLERS | |||
39 | When perf script is invoked using a trace script, a user-defined | 39 | When perf script is invoked using a trace script, a user-defined |
40 | 'handler function' is called for each event in the trace. If there's | 40 | 'handler function' is called for each event in the trace. If there's |
41 | no handler function defined for a given event type, the event is | 41 | no handler function defined for a given event type, the event is |
42 | ignored (or passed to a 'trace_handled' function, see below) and the | 42 | ignored (or passed to a 'trace_unhandled' function, see below) and the |
43 | next event is processed. | 43 | next event is processed. |
44 | 44 | ||
45 | Most of the event's field values are passed as arguments to the | 45 | Most of the event's field values are passed as arguments to the |
diff --git a/tools/perf/Documentation/perf-script-python.txt b/tools/perf/Documentation/perf-script-python.txt index 54acba221558..51ec2d20068a 100644 --- a/tools/perf/Documentation/perf-script-python.txt +++ b/tools/perf/Documentation/perf-script-python.txt | |||
@@ -149,10 +149,8 @@ def raw_syscalls__sys_enter(event_name, context, common_cpu, | |||
149 | print "id=%d, args=%s\n" % \ | 149 | print "id=%d, args=%s\n" % \ |
150 | (id, args), | 150 | (id, args), |
151 | 151 | ||
152 | def trace_unhandled(event_name, context, common_cpu, common_secs, common_nsecs, | 152 | def trace_unhandled(event_name, context, event_fields_dict): |
153 | common_pid, common_comm): | 153 | print ' '.join(['%s=%s'%(k,str(v))for k,v in sorted(event_fields_dict.items())]) |
154 | print_header(event_name, common_cpu, common_secs, common_nsecs, | ||
155 | common_pid, common_comm) | ||
156 | 154 | ||
157 | def print_header(event_name, cpu, secs, nsecs, pid, comm): | 155 | def print_header(event_name, cpu, secs, nsecs, pid, comm): |
158 | print "%-20s %5u %05u.%09u %8u %-20s " % \ | 156 | print "%-20s %5u %05u.%09u %8u %-20s " % \ |
@@ -321,7 +319,7 @@ So those are the essential steps in writing and running a script. The | |||
321 | process can be generalized to any tracepoint or set of tracepoints | 319 | process can be generalized to any tracepoint or set of tracepoints |
322 | you're interested in - basically find the tracepoint(s) you're | 320 | you're interested in - basically find the tracepoint(s) you're |
323 | interested in by looking at the list of available events shown by | 321 | interested in by looking at the list of available events shown by |
324 | 'perf list' and/or look in /sys/kernel/debug/tracing events for | 322 | 'perf list' and/or look in /sys/kernel/debug/tracing/events/ for |
325 | detailed event and field info, record the corresponding trace data | 323 | detailed event and field info, record the corresponding trace data |
326 | using 'perf record', passing it the list of interesting events, | 324 | using 'perf record', passing it the list of interesting events, |
327 | generate a skeleton script using 'perf script -g python' and modify the | 325 | generate a skeleton script using 'perf script -g python' and modify the |
@@ -334,7 +332,7 @@ right place, you can have your script listed alongside the other | |||
334 | scripts listed by the 'perf script -l' command e.g.: | 332 | scripts listed by the 'perf script -l' command e.g.: |
335 | 333 | ||
336 | ---- | 334 | ---- |
337 | root@tropicana:~# perf script -l | 335 | # perf script -l |
338 | List of available trace scripts: | 336 | List of available trace scripts: |
339 | wakeup-latency system-wide min/max/avg wakeup latency | 337 | wakeup-latency system-wide min/max/avg wakeup latency |
340 | rw-by-file <comm> r/w activity for a program, by file | 338 | rw-by-file <comm> r/w activity for a program, by file |
@@ -383,8 +381,6 @@ source tree: | |||
383 | 381 | ||
384 | ---- | 382 | ---- |
385 | # ls -al kernel-source/tools/perf/scripts/python | 383 | # ls -al kernel-source/tools/perf/scripts/python |
386 | |||
387 | root@tropicana:/home/trz/src/tip# ls -al tools/perf/scripts/python | ||
388 | total 32 | 384 | total 32 |
389 | drwxr-xr-x 4 trz trz 4096 2010-01-26 22:30 . | 385 | drwxr-xr-x 4 trz trz 4096 2010-01-26 22:30 . |
390 | drwxr-xr-x 4 trz trz 4096 2010-01-26 22:29 .. | 386 | drwxr-xr-x 4 trz trz 4096 2010-01-26 22:29 .. |
@@ -399,7 +395,7 @@ otherwise your script won't show up at run-time), 'perf script -l' | |||
399 | should show a new entry for your script: | 395 | should show a new entry for your script: |
400 | 396 | ||
401 | ---- | 397 | ---- |
402 | root@tropicana:~# perf script -l | 398 | # perf script -l |
403 | List of available trace scripts: | 399 | List of available trace scripts: |
404 | wakeup-latency system-wide min/max/avg wakeup latency | 400 | wakeup-latency system-wide min/max/avg wakeup latency |
405 | rw-by-file <comm> r/w activity for a program, by file | 401 | rw-by-file <comm> r/w activity for a program, by file |
@@ -437,7 +433,7 @@ EVENT HANDLERS | |||
437 | When perf script is invoked using a trace script, a user-defined | 433 | When perf script is invoked using a trace script, a user-defined |
438 | 'handler function' is called for each event in the trace. If there's | 434 | 'handler function' is called for each event in the trace. If there's |
439 | no handler function defined for a given event type, the event is | 435 | no handler function defined for a given event type, the event is |
440 | ignored (or passed to a 'trace_handled' function, see below) and the | 436 | ignored (or passed to a 'trace_unhandled' function, see below) and the |
441 | next event is processed. | 437 | next event is processed. |
442 | 438 | ||
443 | Most of the event's field values are passed as arguments to the | 439 | Most of the event's field values are passed as arguments to the |
@@ -532,7 +528,7 @@ can implement a set of optional functions: | |||
532 | gives scripts a chance to do setup tasks: | 528 | gives scripts a chance to do setup tasks: |
533 | 529 | ||
534 | ---- | 530 | ---- |
535 | def trace_begin: | 531 | def trace_begin(): |
536 | pass | 532 | pass |
537 | ---- | 533 | ---- |
538 | 534 | ||
@@ -541,7 +537,7 @@ def trace_begin: | |||
541 | as display results: | 537 | as display results: |
542 | 538 | ||
543 | ---- | 539 | ---- |
544 | def trace_end: | 540 | def trace_end(): |
545 | pass | 541 | pass |
546 | ---- | 542 | ---- |
547 | 543 | ||
@@ -550,8 +546,7 @@ def trace_end: | |||
550 | of common arguments are passed into it: | 546 | of common arguments are passed into it: |
551 | 547 | ||
552 | ---- | 548 | ---- |
553 | def trace_unhandled(event_name, context, common_cpu, common_secs, | 549 | def trace_unhandled(event_name, context, event_fields_dict): |
554 | common_nsecs, common_pid, common_comm): | ||
555 | pass | 550 | pass |
556 | ---- | 551 | ---- |
557 | 552 | ||
diff --git a/tools/perf/arch/common.c b/tools/perf/arch/common.c index 837067f48a4c..6b40e9f01740 100644 --- a/tools/perf/arch/common.c +++ b/tools/perf/arch/common.c | |||
@@ -26,6 +26,7 @@ const char *const arm64_triplets[] = { | |||
26 | 26 | ||
27 | const char *const powerpc_triplets[] = { | 27 | const char *const powerpc_triplets[] = { |
28 | "powerpc-unknown-linux-gnu-", | 28 | "powerpc-unknown-linux-gnu-", |
29 | "powerpc-linux-gnu-", | ||
29 | "powerpc64-unknown-linux-gnu-", | 30 | "powerpc64-unknown-linux-gnu-", |
30 | "powerpc64-linux-gnu-", | 31 | "powerpc64-linux-gnu-", |
31 | "powerpc64le-linux-gnu-", | 32 | "powerpc64le-linux-gnu-", |
diff --git a/tools/perf/builtin-stat.c b/tools/perf/builtin-stat.c index a935b5023732..ad9324d1daf9 100644 --- a/tools/perf/builtin-stat.c +++ b/tools/perf/builtin-stat.c | |||
@@ -1578,6 +1578,7 @@ static void print_header(int argc, const char **argv) | |||
1578 | static void print_footer(void) | 1578 | static void print_footer(void) |
1579 | { | 1579 | { |
1580 | FILE *output = stat_config.output; | 1580 | FILE *output = stat_config.output; |
1581 | int n; | ||
1581 | 1582 | ||
1582 | if (!null_run) | 1583 | if (!null_run) |
1583 | fprintf(output, "\n"); | 1584 | fprintf(output, "\n"); |
@@ -1590,7 +1591,9 @@ static void print_footer(void) | |||
1590 | } | 1591 | } |
1591 | fprintf(output, "\n\n"); | 1592 | fprintf(output, "\n\n"); |
1592 | 1593 | ||
1593 | if (print_free_counters_hint) | 1594 | if (print_free_counters_hint && |
1595 | sysctl__read_int("kernel/nmi_watchdog", &n) >= 0 && | ||
1596 | n > 0) | ||
1594 | fprintf(output, | 1597 | fprintf(output, |
1595 | "Some events weren't counted. Try disabling the NMI watchdog:\n" | 1598 | "Some events weren't counted. Try disabling the NMI watchdog:\n" |
1596 | " echo 0 > /proc/sys/kernel/nmi_watchdog\n" | 1599 | " echo 0 > /proc/sys/kernel/nmi_watchdog\n" |
diff --git a/tools/perf/builtin-trace.c b/tools/perf/builtin-trace.c index d014350adc52..4b2a5d298197 100644 --- a/tools/perf/builtin-trace.c +++ b/tools/perf/builtin-trace.c | |||
@@ -681,6 +681,10 @@ static struct syscall_fmt { | |||
681 | { .name = "mlockall", .errmsg = true, | 681 | { .name = "mlockall", .errmsg = true, |
682 | .arg_scnprintf = { [0] = SCA_HEX, /* addr */ }, }, | 682 | .arg_scnprintf = { [0] = SCA_HEX, /* addr */ }, }, |
683 | { .name = "mmap", .hexret = true, | 683 | { .name = "mmap", .hexret = true, |
684 | /* The standard mmap maps to old_mmap on s390x */ | ||
685 | #if defined(__s390x__) | ||
686 | .alias = "old_mmap", | ||
687 | #endif | ||
684 | .arg_scnprintf = { [0] = SCA_HEX, /* addr */ | 688 | .arg_scnprintf = { [0] = SCA_HEX, /* addr */ |
685 | [2] = SCA_MMAP_PROT, /* prot */ | 689 | [2] = SCA_MMAP_PROT, /* prot */ |
686 | [3] = SCA_MMAP_FLAGS, /* flags */ }, }, | 690 | [3] = SCA_MMAP_FLAGS, /* flags */ }, }, |
diff --git a/tools/perf/tests/bp_signal.c b/tools/perf/tests/bp_signal.c index e7664fe3bd33..8ba2c4618fe9 100644 --- a/tools/perf/tests/bp_signal.c +++ b/tools/perf/tests/bp_signal.c | |||
@@ -288,3 +288,17 @@ int test__bp_signal(int subtest __maybe_unused) | |||
288 | return count1 == 1 && overflows == 3 && count2 == 3 && overflows_2 == 3 && count3 == 2 ? | 288 | return count1 == 1 && overflows == 3 && count2 == 3 && overflows_2 == 3 && count3 == 2 ? |
289 | TEST_OK : TEST_FAIL; | 289 | TEST_OK : TEST_FAIL; |
290 | } | 290 | } |
291 | |||
292 | bool test__bp_signal_is_supported(void) | ||
293 | { | ||
294 | /* | ||
295 | * The powerpc so far does not have support to even create | ||
296 | * instruction breakpoint using the perf event interface. | ||
297 | * Once it's there we can release this. | ||
298 | */ | ||
299 | #ifdef __powerpc__ | ||
300 | return false; | ||
301 | #else | ||
302 | return true; | ||
303 | #endif | ||
304 | } | ||
diff --git a/tools/perf/tests/builtin-test.c b/tools/perf/tests/builtin-test.c index 9e08d297f1a9..3ccfd58a8c3c 100644 --- a/tools/perf/tests/builtin-test.c +++ b/tools/perf/tests/builtin-test.c | |||
@@ -97,10 +97,12 @@ static struct test generic_tests[] = { | |||
97 | { | 97 | { |
98 | .desc = "Breakpoint overflow signal handler", | 98 | .desc = "Breakpoint overflow signal handler", |
99 | .func = test__bp_signal, | 99 | .func = test__bp_signal, |
100 | .is_supported = test__bp_signal_is_supported, | ||
100 | }, | 101 | }, |
101 | { | 102 | { |
102 | .desc = "Breakpoint overflow sampling", | 103 | .desc = "Breakpoint overflow sampling", |
103 | .func = test__bp_signal_overflow, | 104 | .func = test__bp_signal_overflow, |
105 | .is_supported = test__bp_signal_is_supported, | ||
104 | }, | 106 | }, |
105 | { | 107 | { |
106 | .desc = "Number of exit events of a simple workload", | 108 | .desc = "Number of exit events of a simple workload", |
@@ -401,6 +403,11 @@ static int __cmd_test(int argc, const char *argv[], struct intlist *skiplist) | |||
401 | if (!perf_test__matches(t, curr, argc, argv)) | 403 | if (!perf_test__matches(t, curr, argc, argv)) |
402 | continue; | 404 | continue; |
403 | 405 | ||
406 | if (t->is_supported && !t->is_supported()) { | ||
407 | pr_debug("%2d: %-*s: Disabled\n", i, width, t->desc); | ||
408 | continue; | ||
409 | } | ||
410 | |||
404 | pr_info("%2d: %-*s:", i, width, t->desc); | 411 | pr_info("%2d: %-*s:", i, width, t->desc); |
405 | 412 | ||
406 | if (intlist__find(skiplist, i)) { | 413 | if (intlist__find(skiplist, i)) { |
diff --git a/tools/perf/tests/code-reading.c b/tools/perf/tests/code-reading.c index 1f14e7612cbb..94b7c7b02bde 100644 --- a/tools/perf/tests/code-reading.c +++ b/tools/perf/tests/code-reading.c | |||
@@ -229,6 +229,8 @@ static int read_object_code(u64 addr, size_t len, u8 cpumode, | |||
229 | unsigned char buf2[BUFSZ]; | 229 | unsigned char buf2[BUFSZ]; |
230 | size_t ret_len; | 230 | size_t ret_len; |
231 | u64 objdump_addr; | 231 | u64 objdump_addr; |
232 | const char *objdump_name; | ||
233 | char decomp_name[KMOD_DECOMP_LEN]; | ||
232 | int ret; | 234 | int ret; |
233 | 235 | ||
234 | pr_debug("Reading object code for memory address: %#"PRIx64"\n", addr); | 236 | pr_debug("Reading object code for memory address: %#"PRIx64"\n", addr); |
@@ -289,9 +291,25 @@ static int read_object_code(u64 addr, size_t len, u8 cpumode, | |||
289 | state->done[state->done_cnt++] = al.map->start; | 291 | state->done[state->done_cnt++] = al.map->start; |
290 | } | 292 | } |
291 | 293 | ||
294 | objdump_name = al.map->dso->long_name; | ||
295 | if (dso__needs_decompress(al.map->dso)) { | ||
296 | if (dso__decompress_kmodule_path(al.map->dso, objdump_name, | ||
297 | decomp_name, | ||
298 | sizeof(decomp_name)) < 0) { | ||
299 | pr_debug("decompression failed\n"); | ||
300 | return -1; | ||
301 | } | ||
302 | |||
303 | objdump_name = decomp_name; | ||
304 | } | ||
305 | |||
292 | /* Read the object code using objdump */ | 306 | /* Read the object code using objdump */ |
293 | objdump_addr = map__rip_2objdump(al.map, al.addr); | 307 | objdump_addr = map__rip_2objdump(al.map, al.addr); |
294 | ret = read_via_objdump(al.map->dso->long_name, objdump_addr, buf2, len); | 308 | ret = read_via_objdump(objdump_name, objdump_addr, buf2, len); |
309 | |||
310 | if (dso__needs_decompress(al.map->dso)) | ||
311 | unlink(objdump_name); | ||
312 | |||
295 | if (ret > 0) { | 313 | if (ret > 0) { |
296 | /* | 314 | /* |
297 | * The kernel maps are inaccurate - assume objdump is right in | 315 | * The kernel maps are inaccurate - assume objdump is right in |
diff --git a/tools/perf/tests/tests.h b/tools/perf/tests/tests.h index 631859629403..577363809c9b 100644 --- a/tools/perf/tests/tests.h +++ b/tools/perf/tests/tests.h | |||
@@ -34,6 +34,7 @@ struct test { | |||
34 | int (*get_nr)(void); | 34 | int (*get_nr)(void); |
35 | const char *(*get_desc)(int subtest); | 35 | const char *(*get_desc)(int subtest); |
36 | } subtest; | 36 | } subtest; |
37 | bool (*is_supported)(void); | ||
37 | }; | 38 | }; |
38 | 39 | ||
39 | /* Tests */ | 40 | /* Tests */ |
@@ -99,6 +100,8 @@ const char *test__clang_subtest_get_desc(int subtest); | |||
99 | int test__clang_subtest_get_nr(void); | 100 | int test__clang_subtest_get_nr(void); |
100 | int test__unit_number__scnprint(int subtest); | 101 | int test__unit_number__scnprint(int subtest); |
101 | 102 | ||
103 | bool test__bp_signal_is_supported(void); | ||
104 | |||
102 | #if defined(__arm__) || defined(__aarch64__) | 105 | #if defined(__arm__) || defined(__aarch64__) |
103 | #ifdef HAVE_DWARF_UNWIND_SUPPORT | 106 | #ifdef HAVE_DWARF_UNWIND_SUPPORT |
104 | struct thread; | 107 | struct thread; |
diff --git a/tools/perf/util/annotate.c b/tools/perf/util/annotate.c index 683f8340460c..ddbd56df9187 100644 --- a/tools/perf/util/annotate.c +++ b/tools/perf/util/annotate.c | |||
@@ -239,10 +239,20 @@ static int jump__parse(struct arch *arch __maybe_unused, struct ins_operands *op | |||
239 | const char *s = strchr(ops->raw, '+'); | 239 | const char *s = strchr(ops->raw, '+'); |
240 | const char *c = strchr(ops->raw, ','); | 240 | const char *c = strchr(ops->raw, ','); |
241 | 241 | ||
242 | if (c++ != NULL) | 242 | /* |
243 | * skip over possible up to 2 operands to get to address, e.g.: | ||
244 | * tbnz w0, #26, ffff0000083cd190 <security_file_permission+0xd0> | ||
245 | */ | ||
246 | if (c++ != NULL) { | ||
243 | ops->target.addr = strtoull(c, NULL, 16); | 247 | ops->target.addr = strtoull(c, NULL, 16); |
244 | else | 248 | if (!ops->target.addr) { |
249 | c = strchr(c, ','); | ||
250 | if (c++ != NULL) | ||
251 | ops->target.addr = strtoull(c, NULL, 16); | ||
252 | } | ||
253 | } else { | ||
245 | ops->target.addr = strtoull(ops->raw, NULL, 16); | 254 | ops->target.addr = strtoull(ops->raw, NULL, 16); |
255 | } | ||
246 | 256 | ||
247 | if (s++ != NULL) { | 257 | if (s++ != NULL) { |
248 | ops->target.offset = strtoull(s, NULL, 16); | 258 | ops->target.offset = strtoull(s, NULL, 16); |
@@ -257,10 +267,27 @@ static int jump__parse(struct arch *arch __maybe_unused, struct ins_operands *op | |||
257 | static int jump__scnprintf(struct ins *ins, char *bf, size_t size, | 267 | static int jump__scnprintf(struct ins *ins, char *bf, size_t size, |
258 | struct ins_operands *ops) | 268 | struct ins_operands *ops) |
259 | { | 269 | { |
270 | const char *c = strchr(ops->raw, ','); | ||
271 | |||
260 | if (!ops->target.addr || ops->target.offset < 0) | 272 | if (!ops->target.addr || ops->target.offset < 0) |
261 | return ins__raw_scnprintf(ins, bf, size, ops); | 273 | return ins__raw_scnprintf(ins, bf, size, ops); |
262 | 274 | ||
263 | return scnprintf(bf, size, "%-6.6s %" PRIx64, ins->name, ops->target.offset); | 275 | if (c != NULL) { |
276 | const char *c2 = strchr(c + 1, ','); | ||
277 | |||
278 | /* check for 3-op insn */ | ||
279 | if (c2 != NULL) | ||
280 | c = c2; | ||
281 | c++; | ||
282 | |||
283 | /* mirror arch objdump's space-after-comma style */ | ||
284 | if (*c == ' ') | ||
285 | c++; | ||
286 | } | ||
287 | |||
288 | return scnprintf(bf, size, "%-6.6s %.*s%" PRIx64, | ||
289 | ins->name, c ? c - ops->raw : 0, ops->raw, | ||
290 | ops->target.offset); | ||
264 | } | 291 | } |
265 | 292 | ||
266 | static struct ins_ops jump_ops = { | 293 | static struct ins_ops jump_ops = { |
@@ -1294,6 +1321,7 @@ static int dso__disassemble_filename(struct dso *dso, char *filename, size_t fil | |||
1294 | char linkname[PATH_MAX]; | 1321 | char linkname[PATH_MAX]; |
1295 | char *build_id_filename; | 1322 | char *build_id_filename; |
1296 | char *build_id_path = NULL; | 1323 | char *build_id_path = NULL; |
1324 | char *pos; | ||
1297 | 1325 | ||
1298 | if (dso->symtab_type == DSO_BINARY_TYPE__KALLSYMS && | 1326 | if (dso->symtab_type == DSO_BINARY_TYPE__KALLSYMS && |
1299 | !dso__is_kcore(dso)) | 1327 | !dso__is_kcore(dso)) |
@@ -1313,7 +1341,14 @@ static int dso__disassemble_filename(struct dso *dso, char *filename, size_t fil | |||
1313 | if (!build_id_path) | 1341 | if (!build_id_path) |
1314 | return -1; | 1342 | return -1; |
1315 | 1343 | ||
1316 | dirname(build_id_path); | 1344 | /* |
1345 | * old style build-id cache has name of XX/XXXXXXX.. while | ||
1346 | * new style has XX/XXXXXXX../{elf,kallsyms,vdso}. | ||
1347 | * extract the build-id part of dirname in the new style only. | ||
1348 | */ | ||
1349 | pos = strrchr(build_id_path, '/'); | ||
1350 | if (pos && strlen(pos) < SBUILD_ID_SIZE - 2) | ||
1351 | dirname(build_id_path); | ||
1317 | 1352 | ||
1318 | if (dso__is_kcore(dso) || | 1353 | if (dso__is_kcore(dso) || |
1319 | readlink(build_id_path, linkname, sizeof(linkname)) < 0 || | 1354 | readlink(build_id_path, linkname, sizeof(linkname)) < 0 || |
@@ -1396,31 +1431,10 @@ int symbol__disassemble(struct symbol *sym, struct map *map, const char *arch_na | |||
1396 | sizeof(symfs_filename)); | 1431 | sizeof(symfs_filename)); |
1397 | } | 1432 | } |
1398 | } else if (dso__needs_decompress(dso)) { | 1433 | } else if (dso__needs_decompress(dso)) { |
1399 | char tmp[PATH_MAX]; | 1434 | char tmp[KMOD_DECOMP_LEN]; |
1400 | struct kmod_path m; | ||
1401 | int fd; | ||
1402 | bool ret; | ||
1403 | |||
1404 | if (kmod_path__parse_ext(&m, symfs_filename)) | ||
1405 | goto out; | ||
1406 | |||
1407 | snprintf(tmp, PATH_MAX, "/tmp/perf-kmod-XXXXXX"); | ||
1408 | |||
1409 | fd = mkstemp(tmp); | ||
1410 | if (fd < 0) { | ||
1411 | free(m.ext); | ||
1412 | goto out; | ||
1413 | } | ||
1414 | |||
1415 | ret = decompress_to_file(m.ext, symfs_filename, fd); | ||
1416 | |||
1417 | if (ret) | ||
1418 | pr_err("Cannot decompress %s %s\n", m.ext, symfs_filename); | ||
1419 | |||
1420 | free(m.ext); | ||
1421 | close(fd); | ||
1422 | 1435 | ||
1423 | if (!ret) | 1436 | if (dso__decompress_kmodule_path(dso, symfs_filename, |
1437 | tmp, sizeof(tmp)) < 0) | ||
1424 | goto out; | 1438 | goto out; |
1425 | 1439 | ||
1426 | strcpy(symfs_filename, tmp); | 1440 | strcpy(symfs_filename, tmp); |
@@ -1429,7 +1443,7 @@ int symbol__disassemble(struct symbol *sym, struct map *map, const char *arch_na | |||
1429 | snprintf(command, sizeof(command), | 1443 | snprintf(command, sizeof(command), |
1430 | "%s %s%s --start-address=0x%016" PRIx64 | 1444 | "%s %s%s --start-address=0x%016" PRIx64 |
1431 | " --stop-address=0x%016" PRIx64 | 1445 | " --stop-address=0x%016" PRIx64 |
1432 | " -l -d %s %s -C %s 2>/dev/null|grep -v %s:|expand", | 1446 | " -l -d %s %s -C \"%s\" 2>/dev/null|grep -v \"%s:\"|expand", |
1433 | objdump_path ? objdump_path : "objdump", | 1447 | objdump_path ? objdump_path : "objdump", |
1434 | disassembler_style ? "-M " : "", | 1448 | disassembler_style ? "-M " : "", |
1435 | disassembler_style ? disassembler_style : "", | 1449 | disassembler_style ? disassembler_style : "", |
diff --git a/tools/perf/util/build-id.c b/tools/perf/util/build-id.c index 168cc49654e7..e0148b081bdf 100644 --- a/tools/perf/util/build-id.c +++ b/tools/perf/util/build-id.c | |||
@@ -278,51 +278,6 @@ char *dso__build_id_filename(const struct dso *dso, char *bf, size_t size) | |||
278 | return bf; | 278 | return bf; |
279 | } | 279 | } |
280 | 280 | ||
281 | bool dso__build_id_is_kmod(const struct dso *dso, char *bf, size_t size) | ||
282 | { | ||
283 | char *id_name = NULL, *ch; | ||
284 | struct stat sb; | ||
285 | char sbuild_id[SBUILD_ID_SIZE]; | ||
286 | |||
287 | if (!dso->has_build_id) | ||
288 | goto err; | ||
289 | |||
290 | build_id__sprintf(dso->build_id, sizeof(dso->build_id), sbuild_id); | ||
291 | id_name = build_id_cache__linkname(sbuild_id, NULL, 0); | ||
292 | if (!id_name) | ||
293 | goto err; | ||
294 | if (access(id_name, F_OK)) | ||
295 | goto err; | ||
296 | if (lstat(id_name, &sb) == -1) | ||
297 | goto err; | ||
298 | if ((size_t)sb.st_size > size - 1) | ||
299 | goto err; | ||
300 | if (readlink(id_name, bf, size - 1) < 0) | ||
301 | goto err; | ||
302 | |||
303 | bf[sb.st_size] = '\0'; | ||
304 | |||
305 | /* | ||
306 | * link should be: | ||
307 | * ../../lib/modules/4.4.0-rc4/kernel/net/ipv4/netfilter/nf_nat_ipv4.ko/a09fe3eb3147dafa4e3b31dbd6257e4d696bdc92 | ||
308 | */ | ||
309 | ch = strrchr(bf, '/'); | ||
310 | if (!ch) | ||
311 | goto err; | ||
312 | if (ch - 3 < bf) | ||
313 | goto err; | ||
314 | |||
315 | free(id_name); | ||
316 | return strncmp(".ko", ch - 3, 3) == 0; | ||
317 | err: | ||
318 | pr_err("Invalid build id: %s\n", id_name ? : | ||
319 | dso->long_name ? : | ||
320 | dso->short_name ? : | ||
321 | "[unknown]"); | ||
322 | free(id_name); | ||
323 | return false; | ||
324 | } | ||
325 | |||
326 | #define dsos__for_each_with_build_id(pos, head) \ | 281 | #define dsos__for_each_with_build_id(pos, head) \ |
327 | list_for_each_entry(pos, head, node) \ | 282 | list_for_each_entry(pos, head, node) \ |
328 | if (!pos->has_build_id) \ | 283 | if (!pos->has_build_id) \ |
diff --git a/tools/perf/util/build-id.h b/tools/perf/util/build-id.h index 8a89b195c1fc..96690a55c62c 100644 --- a/tools/perf/util/build-id.h +++ b/tools/perf/util/build-id.h | |||
@@ -17,7 +17,6 @@ char *build_id_cache__kallsyms_path(const char *sbuild_id, char *bf, | |||
17 | size_t size); | 17 | size_t size); |
18 | 18 | ||
19 | char *dso__build_id_filename(const struct dso *dso, char *bf, size_t size); | 19 | char *dso__build_id_filename(const struct dso *dso, char *bf, size_t size); |
20 | bool dso__build_id_is_kmod(const struct dso *dso, char *bf, size_t size); | ||
21 | 20 | ||
22 | int build_id__mark_dso_hit(struct perf_tool *tool, union perf_event *event, | 21 | int build_id__mark_dso_hit(struct perf_tool *tool, union perf_event *event, |
23 | struct perf_sample *sample, struct perf_evsel *evsel, | 22 | struct perf_sample *sample, struct perf_evsel *evsel, |
diff --git a/tools/perf/util/dso.c b/tools/perf/util/dso.c index a96a99d2369f..4e7ab611377a 100644 --- a/tools/perf/util/dso.c +++ b/tools/perf/util/dso.c | |||
@@ -248,6 +248,64 @@ bool dso__needs_decompress(struct dso *dso) | |||
248 | dso->symtab_type == DSO_BINARY_TYPE__GUEST_KMODULE_COMP; | 248 | dso->symtab_type == DSO_BINARY_TYPE__GUEST_KMODULE_COMP; |
249 | } | 249 | } |
250 | 250 | ||
251 | static int decompress_kmodule(struct dso *dso, const char *name, char *tmpbuf) | ||
252 | { | ||
253 | int fd = -1; | ||
254 | struct kmod_path m; | ||
255 | |||
256 | if (!dso__needs_decompress(dso)) | ||
257 | return -1; | ||
258 | |||
259 | if (kmod_path__parse_ext(&m, dso->long_name)) | ||
260 | return -1; | ||
261 | |||
262 | if (!m.comp) | ||
263 | goto out; | ||
264 | |||
265 | fd = mkstemp(tmpbuf); | ||
266 | if (fd < 0) { | ||
267 | dso->load_errno = errno; | ||
268 | goto out; | ||
269 | } | ||
270 | |||
271 | if (!decompress_to_file(m.ext, name, fd)) { | ||
272 | dso->load_errno = DSO_LOAD_ERRNO__DECOMPRESSION_FAILURE; | ||
273 | close(fd); | ||
274 | fd = -1; | ||
275 | } | ||
276 | |||
277 | out: | ||
278 | free(m.ext); | ||
279 | return fd; | ||
280 | } | ||
281 | |||
282 | int dso__decompress_kmodule_fd(struct dso *dso, const char *name) | ||
283 | { | ||
284 | char tmpbuf[] = KMOD_DECOMP_NAME; | ||
285 | int fd; | ||
286 | |||
287 | fd = decompress_kmodule(dso, name, tmpbuf); | ||
288 | unlink(tmpbuf); | ||
289 | return fd; | ||
290 | } | ||
291 | |||
292 | int dso__decompress_kmodule_path(struct dso *dso, const char *name, | ||
293 | char *pathname, size_t len) | ||
294 | { | ||
295 | char tmpbuf[] = KMOD_DECOMP_NAME; | ||
296 | int fd; | ||
297 | |||
298 | fd = decompress_kmodule(dso, name, tmpbuf); | ||
299 | if (fd < 0) { | ||
300 | unlink(tmpbuf); | ||
301 | return -1; | ||
302 | } | ||
303 | |||
304 | strncpy(pathname, tmpbuf, len); | ||
305 | close(fd); | ||
306 | return 0; | ||
307 | } | ||
308 | |||
251 | /* | 309 | /* |
252 | * Parses kernel module specified in @path and updates | 310 | * Parses kernel module specified in @path and updates |
253 | * @m argument like: | 311 | * @m argument like: |
@@ -335,6 +393,21 @@ int __kmod_path__parse(struct kmod_path *m, const char *path, | |||
335 | return 0; | 393 | return 0; |
336 | } | 394 | } |
337 | 395 | ||
396 | void dso__set_module_info(struct dso *dso, struct kmod_path *m, | ||
397 | struct machine *machine) | ||
398 | { | ||
399 | if (machine__is_host(machine)) | ||
400 | dso->symtab_type = DSO_BINARY_TYPE__SYSTEM_PATH_KMODULE; | ||
401 | else | ||
402 | dso->symtab_type = DSO_BINARY_TYPE__GUEST_KMODULE; | ||
403 | |||
404 | /* _KMODULE_COMP should be next to _KMODULE */ | ||
405 | if (m->kmod && m->comp) | ||
406 | dso->symtab_type++; | ||
407 | |||
408 | dso__set_short_name(dso, strdup(m->name), true); | ||
409 | } | ||
410 | |||
338 | /* | 411 | /* |
339 | * Global list of open DSOs and the counter. | 412 | * Global list of open DSOs and the counter. |
340 | */ | 413 | */ |
@@ -381,7 +454,7 @@ static int do_open(char *name) | |||
381 | 454 | ||
382 | static int __open_dso(struct dso *dso, struct machine *machine) | 455 | static int __open_dso(struct dso *dso, struct machine *machine) |
383 | { | 456 | { |
384 | int fd; | 457 | int fd = -EINVAL; |
385 | char *root_dir = (char *)""; | 458 | char *root_dir = (char *)""; |
386 | char *name = malloc(PATH_MAX); | 459 | char *name = malloc(PATH_MAX); |
387 | 460 | ||
@@ -392,15 +465,30 @@ static int __open_dso(struct dso *dso, struct machine *machine) | |||
392 | root_dir = machine->root_dir; | 465 | root_dir = machine->root_dir; |
393 | 466 | ||
394 | if (dso__read_binary_type_filename(dso, dso->binary_type, | 467 | if (dso__read_binary_type_filename(dso, dso->binary_type, |
395 | root_dir, name, PATH_MAX)) { | 468 | root_dir, name, PATH_MAX)) |
396 | free(name); | 469 | goto out; |
397 | return -EINVAL; | ||
398 | } | ||
399 | 470 | ||
400 | if (!is_regular_file(name)) | 471 | if (!is_regular_file(name)) |
401 | return -EINVAL; | 472 | goto out; |
473 | |||
474 | if (dso__needs_decompress(dso)) { | ||
475 | char newpath[KMOD_DECOMP_LEN]; | ||
476 | size_t len = sizeof(newpath); | ||
477 | |||
478 | if (dso__decompress_kmodule_path(dso, name, newpath, len) < 0) { | ||
479 | fd = -dso->load_errno; | ||
480 | goto out; | ||
481 | } | ||
482 | |||
483 | strcpy(name, newpath); | ||
484 | } | ||
402 | 485 | ||
403 | fd = do_open(name); | 486 | fd = do_open(name); |
487 | |||
488 | if (dso__needs_decompress(dso)) | ||
489 | unlink(name); | ||
490 | |||
491 | out: | ||
404 | free(name); | 492 | free(name); |
405 | return fd; | 493 | return fd; |
406 | } | 494 | } |
diff --git a/tools/perf/util/dso.h b/tools/perf/util/dso.h index 12350b171727..bd061ba7b47c 100644 --- a/tools/perf/util/dso.h +++ b/tools/perf/util/dso.h | |||
@@ -244,6 +244,12 @@ bool is_supported_compression(const char *ext); | |||
244 | bool is_kernel_module(const char *pathname, int cpumode); | 244 | bool is_kernel_module(const char *pathname, int cpumode); |
245 | bool decompress_to_file(const char *ext, const char *filename, int output_fd); | 245 | bool decompress_to_file(const char *ext, const char *filename, int output_fd); |
246 | bool dso__needs_decompress(struct dso *dso); | 246 | bool dso__needs_decompress(struct dso *dso); |
247 | int dso__decompress_kmodule_fd(struct dso *dso, const char *name); | ||
248 | int dso__decompress_kmodule_path(struct dso *dso, const char *name, | ||
249 | char *pathname, size_t len); | ||
250 | |||
251 | #define KMOD_DECOMP_NAME "/tmp/perf-kmod-XXXXXX" | ||
252 | #define KMOD_DECOMP_LEN sizeof(KMOD_DECOMP_NAME) | ||
247 | 253 | ||
248 | struct kmod_path { | 254 | struct kmod_path { |
249 | char *name; | 255 | char *name; |
@@ -259,6 +265,9 @@ int __kmod_path__parse(struct kmod_path *m, const char *path, | |||
259 | #define kmod_path__parse_name(__m, __p) __kmod_path__parse(__m, __p, true , false) | 265 | #define kmod_path__parse_name(__m, __p) __kmod_path__parse(__m, __p, true , false) |
260 | #define kmod_path__parse_ext(__m, __p) __kmod_path__parse(__m, __p, false, true) | 266 | #define kmod_path__parse_ext(__m, __p) __kmod_path__parse(__m, __p, false, true) |
261 | 267 | ||
268 | void dso__set_module_info(struct dso *dso, struct kmod_path *m, | ||
269 | struct machine *machine); | ||
270 | |||
262 | /* | 271 | /* |
263 | * The dso__data_* external interface provides following functions: | 272 | * The dso__data_* external interface provides following functions: |
264 | * dso__data_get_fd | 273 | * dso__data_get_fd |
diff --git a/tools/perf/util/header.c b/tools/perf/util/header.c index 314a07151fb7..5cac8d5e009a 100644 --- a/tools/perf/util/header.c +++ b/tools/perf/util/header.c | |||
@@ -1469,8 +1469,16 @@ static int __event_process_build_id(struct build_id_event *bev, | |||
1469 | 1469 | ||
1470 | dso__set_build_id(dso, &bev->build_id); | 1470 | dso__set_build_id(dso, &bev->build_id); |
1471 | 1471 | ||
1472 | if (!is_kernel_module(filename, cpumode)) | 1472 | if (dso_type != DSO_TYPE_USER) { |
1473 | dso->kernel = dso_type; | 1473 | struct kmod_path m = { .name = NULL, }; |
1474 | |||
1475 | if (!kmod_path__parse_name(&m, filename) && m.kmod) | ||
1476 | dso__set_module_info(dso, &m, machine); | ||
1477 | else | ||
1478 | dso->kernel = dso_type; | ||
1479 | |||
1480 | free(m.name); | ||
1481 | } | ||
1474 | 1482 | ||
1475 | build_id__sprintf(dso->build_id, sizeof(dso->build_id), | 1483 | build_id__sprintf(dso->build_id, sizeof(dso->build_id), |
1476 | sbuild_id); | 1484 | sbuild_id); |
diff --git a/tools/perf/util/machine.c b/tools/perf/util/machine.c index d97e014c3df3..d7f31cb0a4cb 100644 --- a/tools/perf/util/machine.c +++ b/tools/perf/util/machine.c | |||
@@ -572,16 +572,7 @@ static struct dso *machine__findnew_module_dso(struct machine *machine, | |||
572 | if (dso == NULL) | 572 | if (dso == NULL) |
573 | goto out_unlock; | 573 | goto out_unlock; |
574 | 574 | ||
575 | if (machine__is_host(machine)) | 575 | dso__set_module_info(dso, m, machine); |
576 | dso->symtab_type = DSO_BINARY_TYPE__SYSTEM_PATH_KMODULE; | ||
577 | else | ||
578 | dso->symtab_type = DSO_BINARY_TYPE__GUEST_KMODULE; | ||
579 | |||
580 | /* _KMODULE_COMP should be next to _KMODULE */ | ||
581 | if (m->kmod && m->comp) | ||
582 | dso->symtab_type++; | ||
583 | |||
584 | dso__set_short_name(dso, strdup(m->name), true); | ||
585 | dso__set_long_name(dso, strdup(filename), true); | 576 | dso__set_long_name(dso, strdup(filename), true); |
586 | } | 577 | } |
587 | 578 | ||
diff --git a/tools/perf/util/scripting-engines/trace-event-python.c b/tools/perf/util/scripting-engines/trace-event-python.c index 9d92af7d0718..40de3cb40d21 100644 --- a/tools/perf/util/scripting-engines/trace-event-python.c +++ b/tools/perf/util/scripting-engines/trace-event-python.c | |||
@@ -1219,7 +1219,7 @@ static int python_generate_script(struct pevent *pevent, const char *outfile) | |||
1219 | fprintf(ofp, "# be retrieved using Python functions of the form " | 1219 | fprintf(ofp, "# be retrieved using Python functions of the form " |
1220 | "common_*(context).\n"); | 1220 | "common_*(context).\n"); |
1221 | 1221 | ||
1222 | fprintf(ofp, "# See the perf-trace-python Documentation for the list " | 1222 | fprintf(ofp, "# See the perf-script-python Documentation for the list " |
1223 | "of available functions.\n\n"); | 1223 | "of available functions.\n\n"); |
1224 | 1224 | ||
1225 | fprintf(ofp, "import os\n"); | 1225 | fprintf(ofp, "import os\n"); |
diff --git a/tools/perf/util/symbol-elf.c b/tools/perf/util/symbol-elf.c index e7ee47f7377a..502505cf236a 100644 --- a/tools/perf/util/symbol-elf.c +++ b/tools/perf/util/symbol-elf.c | |||
@@ -637,43 +637,6 @@ static int dso__swap_init(struct dso *dso, unsigned char eidata) | |||
637 | return 0; | 637 | return 0; |
638 | } | 638 | } |
639 | 639 | ||
640 | static int decompress_kmodule(struct dso *dso, const char *name, | ||
641 | enum dso_binary_type type) | ||
642 | { | ||
643 | int fd = -1; | ||
644 | char tmpbuf[] = "/tmp/perf-kmod-XXXXXX"; | ||
645 | struct kmod_path m; | ||
646 | |||
647 | if (type != DSO_BINARY_TYPE__SYSTEM_PATH_KMODULE_COMP && | ||
648 | type != DSO_BINARY_TYPE__GUEST_KMODULE_COMP && | ||
649 | type != DSO_BINARY_TYPE__BUILD_ID_CACHE) | ||
650 | return -1; | ||
651 | |||
652 | if (type == DSO_BINARY_TYPE__BUILD_ID_CACHE) | ||
653 | name = dso->long_name; | ||
654 | |||
655 | if (kmod_path__parse_ext(&m, name) || !m.comp) | ||
656 | return -1; | ||
657 | |||
658 | fd = mkstemp(tmpbuf); | ||
659 | if (fd < 0) { | ||
660 | dso->load_errno = errno; | ||
661 | goto out; | ||
662 | } | ||
663 | |||
664 | if (!decompress_to_file(m.ext, name, fd)) { | ||
665 | dso->load_errno = DSO_LOAD_ERRNO__DECOMPRESSION_FAILURE; | ||
666 | close(fd); | ||
667 | fd = -1; | ||
668 | } | ||
669 | |||
670 | unlink(tmpbuf); | ||
671 | |||
672 | out: | ||
673 | free(m.ext); | ||
674 | return fd; | ||
675 | } | ||
676 | |||
677 | bool symsrc__possibly_runtime(struct symsrc *ss) | 640 | bool symsrc__possibly_runtime(struct symsrc *ss) |
678 | { | 641 | { |
679 | return ss->dynsym || ss->opdsec; | 642 | return ss->dynsym || ss->opdsec; |
@@ -705,9 +668,11 @@ int symsrc__init(struct symsrc *ss, struct dso *dso, const char *name, | |||
705 | int fd; | 668 | int fd; |
706 | 669 | ||
707 | if (dso__needs_decompress(dso)) { | 670 | if (dso__needs_decompress(dso)) { |
708 | fd = decompress_kmodule(dso, name, type); | 671 | fd = dso__decompress_kmodule_fd(dso, name); |
709 | if (fd < 0) | 672 | if (fd < 0) |
710 | return -1; | 673 | return -1; |
674 | |||
675 | type = dso->symtab_type; | ||
711 | } else { | 676 | } else { |
712 | fd = open(name, O_RDONLY); | 677 | fd = open(name, O_RDONLY); |
713 | if (fd < 0) { | 678 | if (fd < 0) { |
diff --git a/tools/perf/util/symbol.c b/tools/perf/util/symbol.c index 8f2b068ff756..e7a98dbd2aed 100644 --- a/tools/perf/util/symbol.c +++ b/tools/perf/util/symbol.c | |||
@@ -1562,10 +1562,6 @@ int dso__load(struct dso *dso, struct map *map) | |||
1562 | if (!runtime_ss && syms_ss) | 1562 | if (!runtime_ss && syms_ss) |
1563 | runtime_ss = syms_ss; | 1563 | runtime_ss = syms_ss; |
1564 | 1564 | ||
1565 | if (syms_ss && syms_ss->type == DSO_BINARY_TYPE__BUILD_ID_CACHE) | ||
1566 | if (dso__build_id_is_kmod(dso, name, PATH_MAX)) | ||
1567 | kmod = true; | ||
1568 | |||
1569 | if (syms_ss) | 1565 | if (syms_ss) |
1570 | ret = dso__load_sym(dso, map, syms_ss, runtime_ss, kmod); | 1566 | ret = dso__load_sym(dso, map, syms_ss, runtime_ss, kmod); |
1571 | else | 1567 | else |
diff --git a/tools/perf/util/unwind-libdw.c b/tools/perf/util/unwind-libdw.c index 943a06291587..da45c4be5fb3 100644 --- a/tools/perf/util/unwind-libdw.c +++ b/tools/perf/util/unwind-libdw.c | |||
@@ -39,6 +39,14 @@ static int __report_module(struct addr_location *al, u64 ip, | |||
39 | return 0; | 39 | return 0; |
40 | 40 | ||
41 | mod = dwfl_addrmodule(ui->dwfl, ip); | 41 | mod = dwfl_addrmodule(ui->dwfl, ip); |
42 | if (mod) { | ||
43 | Dwarf_Addr s; | ||
44 | |||
45 | dwfl_module_info(mod, NULL, &s, NULL, NULL, NULL, NULL, NULL); | ||
46 | if (s != al->map->start) | ||
47 | mod = 0; | ||
48 | } | ||
49 | |||
42 | if (!mod) | 50 | if (!mod) |
43 | mod = dwfl_report_elf(ui->dwfl, dso->short_name, | 51 | mod = dwfl_report_elf(ui->dwfl, dso->short_name, |
44 | dso->long_name, -1, al->map->start, | 52 | dso->long_name, -1, al->map->start, |
@@ -224,7 +232,7 @@ int unwind__get_entries(unwind_entry_cb_t cb, void *arg, | |||
224 | 232 | ||
225 | err = dwfl_getthread_frames(ui->dwfl, thread->tid, frame_callback, ui); | 233 | err = dwfl_getthread_frames(ui->dwfl, thread->tid, frame_callback, ui); |
226 | 234 | ||
227 | if (err && !ui->max_stack) | 235 | if (err && ui->max_stack != max_stack) |
228 | err = 0; | 236 | err = 0; |
229 | 237 | ||
230 | /* | 238 | /* |
diff --git a/tools/testing/selftests/bpf/bpf_endian.h b/tools/testing/selftests/bpf/bpf_endian.h index 19d0604f8694..487cbfb89beb 100644 --- a/tools/testing/selftests/bpf/bpf_endian.h +++ b/tools/testing/selftests/bpf/bpf_endian.h | |||
@@ -1,23 +1,42 @@ | |||
1 | #ifndef __BPF_ENDIAN__ | 1 | #ifndef __BPF_ENDIAN__ |
2 | #define __BPF_ENDIAN__ | 2 | #define __BPF_ENDIAN__ |
3 | 3 | ||
4 | #include <asm/byteorder.h> | 4 | #include <linux/swab.h> |
5 | 5 | ||
6 | #if __BYTE_ORDER == __LITTLE_ENDIAN | 6 | /* LLVM's BPF target selects the endianness of the CPU |
7 | # define __bpf_ntohs(x) __builtin_bswap16(x) | 7 | * it compiles on, or the user specifies (bpfel/bpfeb), |
8 | # define __bpf_htons(x) __builtin_bswap16(x) | 8 | * respectively. The used __BYTE_ORDER__ is defined by |
9 | #elif __BYTE_ORDER == __BIG_ENDIAN | 9 | * the compiler, we cannot rely on __BYTE_ORDER from |
10 | # define __bpf_ntohs(x) (x) | 10 | * libc headers, since it doesn't reflect the actual |
11 | # define __bpf_htons(x) (x) | 11 | * requested byte order. |
12 | * | ||
13 | * Note, LLVM's BPF target has different __builtin_bswapX() | ||
14 | * semantics. It does map to BPF_ALU | BPF_END | BPF_TO_BE | ||
15 | * in bpfel and bpfeb case, which means below, that we map | ||
16 | * to cpu_to_be16(). We could use it unconditionally in BPF | ||
17 | * case, but better not rely on it, so that this header here | ||
18 | * can be used from application and BPF program side, which | ||
19 | * use different targets. | ||
20 | */ | ||
21 | #if __BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__ | ||
22 | # define __bpf_ntohs(x) __builtin_bswap16(x) | ||
23 | # define __bpf_htons(x) __builtin_bswap16(x) | ||
24 | # define __bpf_constant_ntohs(x) ___constant_swab16(x) | ||
25 | # define __bpf_constant_htons(x) ___constant_swab16(x) | ||
26 | #elif __BYTE_ORDER__ == __ORDER_BIG_ENDIAN__ | ||
27 | # define __bpf_ntohs(x) (x) | ||
28 | # define __bpf_htons(x) (x) | ||
29 | # define __bpf_constant_ntohs(x) (x) | ||
30 | # define __bpf_constant_htons(x) (x) | ||
12 | #else | 31 | #else |
13 | # error "Fix your __BYTE_ORDER?!" | 32 | # error "Fix your compiler's __BYTE_ORDER__?!" |
14 | #endif | 33 | #endif |
15 | 34 | ||
16 | #define bpf_htons(x) \ | 35 | #define bpf_htons(x) \ |
17 | (__builtin_constant_p(x) ? \ | 36 | (__builtin_constant_p(x) ? \ |
18 | __constant_htons(x) : __bpf_htons(x)) | 37 | __bpf_constant_htons(x) : __bpf_htons(x)) |
19 | #define bpf_ntohs(x) \ | 38 | #define bpf_ntohs(x) \ |
20 | (__builtin_constant_p(x) ? \ | 39 | (__builtin_constant_p(x) ? \ |
21 | __constant_ntohs(x) : __bpf_ntohs(x)) | 40 | __bpf_constant_ntohs(x) : __bpf_ntohs(x)) |
22 | 41 | ||
23 | #endif | 42 | #endif /* __BPF_ENDIAN__ */ |