diff options
Diffstat (limited to 'tools')
-rw-r--r-- | tools/perf/Makefile | 8 | ||||
-rw-r--r-- | tools/perf/builtin-record.c | 25 | ||||
-rw-r--r-- | tools/perf/builtin-top.c | 44 | ||||
-rw-r--r-- | tools/perf/util/debug.c | 10 | ||||
-rw-r--r-- | tools/perf/util/debug.h | 1 | ||||
-rw-r--r-- | tools/perf/util/event.c | 2 | ||||
-rw-r--r-- | tools/perf/util/probe-event.c | 19 | ||||
-rw-r--r-- | tools/perf/util/probe-finder.c | 159 | ||||
-rw-r--r-- | tools/perf/util/setup.py | 7 | ||||
-rw-r--r-- | tools/perf/util/string.c | 2 | ||||
-rw-r--r-- | tools/perf/util/symbol.c | 5 | ||||
-rw-r--r-- | tools/power/x86/x86_energy_perf_policy/x86_energy_perf_policy.c | 2 |
12 files changed, 192 insertions, 92 deletions
diff --git a/tools/perf/Makefile b/tools/perf/Makefile index 158c30e8210c..207dee5c5b16 100644 --- a/tools/perf/Makefile +++ b/tools/perf/Makefile | |||
@@ -165,8 +165,12 @@ grep-libs = $(filter -l%,$(1)) | |||
165 | strip-libs = $(filter-out -l%,$(1)) | 165 | strip-libs = $(filter-out -l%,$(1)) |
166 | 166 | ||
167 | $(OUTPUT)python/perf.so: $(PYRF_OBJS) | 167 | $(OUTPUT)python/perf.so: $(PYRF_OBJS) |
168 | $(QUIET_GEN)python util/setup.py --quiet build_ext --build-lib='$(OUTPUT)python' \ | 168 | $(QUIET_GEN)( \ |
169 | --build-temp='$(OUTPUT)python/temp' | 169 | export CFLAGS="$(BASIC_CFLAGS)"; \ |
170 | python util/setup.py --quiet build_ext --build-lib='$(OUTPUT)python' \ | ||
171 | --build-temp='$(OUTPUT)python/temp' \ | ||
172 | ) | ||
173 | |||
170 | # | 174 | # |
171 | # No Perl scripts right now: | 175 | # No Perl scripts right now: |
172 | # | 176 | # |
diff --git a/tools/perf/builtin-record.c b/tools/perf/builtin-record.c index 6febcc168a8c..17d1dcb3c667 100644 --- a/tools/perf/builtin-record.c +++ b/tools/perf/builtin-record.c | |||
@@ -41,7 +41,7 @@ static u64 user_interval = ULLONG_MAX; | |||
41 | static u64 default_interval = 0; | 41 | static u64 default_interval = 0; |
42 | 42 | ||
43 | static unsigned int page_size; | 43 | static unsigned int page_size; |
44 | static unsigned int mmap_pages = 128; | 44 | static unsigned int mmap_pages = UINT_MAX; |
45 | static unsigned int user_freq = UINT_MAX; | 45 | static unsigned int user_freq = UINT_MAX; |
46 | static int freq = 1000; | 46 | static int freq = 1000; |
47 | static int output; | 47 | static int output; |
@@ -275,11 +275,10 @@ try_again: | |||
275 | !no_inherit) < 0) { | 275 | !no_inherit) < 0) { |
276 | int err = errno; | 276 | int err = errno; |
277 | 277 | ||
278 | if (err == EPERM || err == EACCES) | 278 | if (err == EPERM || err == EACCES) { |
279 | die("Permission error - are you root?\n" | 279 | ui__warning_paranoid(); |
280 | "\t Consider tweaking" | 280 | exit(EXIT_FAILURE); |
281 | " /proc/sys/kernel/perf_event_paranoid.\n"); | 281 | } else if (err == ENODEV && cpu_list) { |
282 | else if (err == ENODEV && cpu_list) { | ||
283 | die("No such device - did you specify" | 282 | die("No such device - did you specify" |
284 | " an out-of-range profile CPU?\n"); | 283 | " an out-of-range profile CPU?\n"); |
285 | } else if (err == EINVAL && sample_id_all_avail) { | 284 | } else if (err == EINVAL && sample_id_all_avail) { |
@@ -302,11 +301,19 @@ try_again: | |||
302 | && attr->config == PERF_COUNT_HW_CPU_CYCLES) { | 301 | && attr->config == PERF_COUNT_HW_CPU_CYCLES) { |
303 | 302 | ||
304 | if (verbose) | 303 | if (verbose) |
305 | warning(" ... trying to fall back to cpu-clock-ticks\n"); | 304 | ui__warning("The cycles event is not supported, " |
305 | "trying to fall back to cpu-clock-ticks\n"); | ||
306 | attr->type = PERF_TYPE_SOFTWARE; | 306 | attr->type = PERF_TYPE_SOFTWARE; |
307 | attr->config = PERF_COUNT_SW_CPU_CLOCK; | 307 | attr->config = PERF_COUNT_SW_CPU_CLOCK; |
308 | goto try_again; | 308 | goto try_again; |
309 | } | 309 | } |
310 | |||
311 | if (err == ENOENT) { | ||
312 | ui__warning("The %s event is not supported.\n", | ||
313 | event_name(pos)); | ||
314 | exit(EXIT_FAILURE); | ||
315 | } | ||
316 | |||
310 | printf("\n"); | 317 | printf("\n"); |
311 | error("sys_perf_event_open() syscall returned with %d (%s). /bin/dmesg may provide additional information.\n", | 318 | error("sys_perf_event_open() syscall returned with %d (%s). /bin/dmesg may provide additional information.\n", |
312 | err, strerror(err)); | 319 | err, strerror(err)); |
@@ -506,6 +513,10 @@ static int __cmd_record(int argc, const char **argv) | |||
506 | if (have_tracepoints(&evsel_list->entries)) | 513 | if (have_tracepoints(&evsel_list->entries)) |
507 | perf_header__set_feat(&session->header, HEADER_TRACE_INFO); | 514 | perf_header__set_feat(&session->header, HEADER_TRACE_INFO); |
508 | 515 | ||
516 | /* 512 kiB: default amount of unprivileged mlocked memory */ | ||
517 | if (mmap_pages == UINT_MAX) | ||
518 | mmap_pages = (512 * 1024) / page_size; | ||
519 | |||
509 | if (forks) { | 520 | if (forks) { |
510 | child_pid = fork(); | 521 | child_pid = fork(); |
511 | if (child_pid < 0) { | 522 | if (child_pid < 0) { |
diff --git a/tools/perf/builtin-top.c b/tools/perf/builtin-top.c index 676b4fb0070f..fc1273e976c5 100644 --- a/tools/perf/builtin-top.c +++ b/tools/perf/builtin-top.c | |||
@@ -850,10 +850,10 @@ try_again: | |||
850 | top.evlist->threads, group, inherit) < 0) { | 850 | top.evlist->threads, group, inherit) < 0) { |
851 | int err = errno; | 851 | int err = errno; |
852 | 852 | ||
853 | if (err == EPERM || err == EACCES) | 853 | if (err == EPERM || err == EACCES) { |
854 | die("Permission error - are you root?\n" | 854 | ui__warning_paranoid(); |
855 | "\t Consider tweaking" | 855 | goto out_err; |
856 | " /proc/sys/kernel/perf_event_paranoid.\n"); | 856 | } |
857 | /* | 857 | /* |
858 | * If it's cycles then fall back to hrtimer | 858 | * If it's cycles then fall back to hrtimer |
859 | * based cpu-clock-tick sw counter, which | 859 | * based cpu-clock-tick sw counter, which |
@@ -861,25 +861,41 @@ try_again: | |||
861 | */ | 861 | */ |
862 | if (attr->type == PERF_TYPE_HARDWARE && | 862 | if (attr->type == PERF_TYPE_HARDWARE && |
863 | attr->config == PERF_COUNT_HW_CPU_CYCLES) { | 863 | attr->config == PERF_COUNT_HW_CPU_CYCLES) { |
864 | |||
865 | if (verbose) | 864 | if (verbose) |
866 | warning(" ... trying to fall back to cpu-clock-ticks\n"); | 865 | ui__warning("Cycles event not supported,\n" |
866 | "trying to fall back to cpu-clock-ticks\n"); | ||
867 | 867 | ||
868 | attr->type = PERF_TYPE_SOFTWARE; | 868 | attr->type = PERF_TYPE_SOFTWARE; |
869 | attr->config = PERF_COUNT_SW_CPU_CLOCK; | 869 | attr->config = PERF_COUNT_SW_CPU_CLOCK; |
870 | goto try_again; | 870 | goto try_again; |
871 | } | 871 | } |
872 | printf("\n"); | 872 | |
873 | error("sys_perf_event_open() syscall returned with %d " | 873 | if (err == ENOENT) { |
874 | "(%s). /bin/dmesg may provide additional information.\n", | 874 | ui__warning("The %s event is not supported.\n", |
875 | err, strerror(err)); | 875 | event_name(counter)); |
876 | die("No CONFIG_PERF_EVENTS=y kernel support configured?\n"); | 876 | goto out_err; |
877 | exit(-1); | 877 | } |
878 | |||
879 | ui__warning("The sys_perf_event_open() syscall " | ||
880 | "returned with %d (%s). /bin/dmesg " | ||
881 | "may provide additional information.\n" | ||
882 | "No CONFIG_PERF_EVENTS=y kernel support " | ||
883 | "configured?\n", err, strerror(err)); | ||
884 | goto out_err; | ||
878 | } | 885 | } |
879 | } | 886 | } |
880 | 887 | ||
881 | if (perf_evlist__mmap(evlist, mmap_pages, false) < 0) | 888 | if (perf_evlist__mmap(evlist, mmap_pages, false) < 0) { |
882 | die("failed to mmap with %d (%s)\n", errno, strerror(errno)); | 889 | ui__warning("Failed to mmap with %d (%s)\n", |
890 | errno, strerror(errno)); | ||
891 | goto out_err; | ||
892 | } | ||
893 | |||
894 | return; | ||
895 | |||
896 | out_err: | ||
897 | exit_browser(0); | ||
898 | exit(0); | ||
883 | } | 899 | } |
884 | 900 | ||
885 | static int __cmd_top(void) | 901 | static int __cmd_top(void) |
diff --git a/tools/perf/util/debug.c b/tools/perf/util/debug.c index d4536a9e0d8c..155749d74350 100644 --- a/tools/perf/util/debug.c +++ b/tools/perf/util/debug.c | |||
@@ -57,6 +57,16 @@ void ui__warning(const char *format, ...) | |||
57 | } | 57 | } |
58 | #endif | 58 | #endif |
59 | 59 | ||
60 | void ui__warning_paranoid(void) | ||
61 | { | ||
62 | ui__warning("Permission error - are you root?\n" | ||
63 | "Consider tweaking /proc/sys/kernel/perf_event_paranoid:\n" | ||
64 | " -1 - Not paranoid at all\n" | ||
65 | " 0 - Disallow raw tracepoint access for unpriv\n" | ||
66 | " 1 - Disallow cpu events for unpriv\n" | ||
67 | " 2 - Disallow kernel profiling for unpriv\n"); | ||
68 | } | ||
69 | |||
60 | void trace_event(union perf_event *event) | 70 | void trace_event(union perf_event *event) |
61 | { | 71 | { |
62 | unsigned char *raw_event = (void *)event; | 72 | unsigned char *raw_event = (void *)event; |
diff --git a/tools/perf/util/debug.h b/tools/perf/util/debug.h index 93516cf4682c..fd53db47e3de 100644 --- a/tools/perf/util/debug.h +++ b/tools/perf/util/debug.h | |||
@@ -36,5 +36,6 @@ int ui_helpline__show_help(const char *format, va_list ap); | |||
36 | #endif | 36 | #endif |
37 | 37 | ||
38 | void ui__warning(const char *format, ...) __attribute__((format(printf, 1, 2))); | 38 | void ui__warning(const char *format, ...) __attribute__((format(printf, 1, 2))); |
39 | void ui__warning_paranoid(void); | ||
39 | 40 | ||
40 | #endif /* __PERF_DEBUG_H */ | 41 | #endif /* __PERF_DEBUG_H */ |
diff --git a/tools/perf/util/event.c b/tools/perf/util/event.c index 2b15c362ef56..1023f67633a4 100644 --- a/tools/perf/util/event.c +++ b/tools/perf/util/event.c | |||
@@ -710,7 +710,7 @@ try_again: | |||
710 | * in the whole kernel symbol list. | 710 | * in the whole kernel symbol list. |
711 | */ | 711 | */ |
712 | if ((long long)al->addr < 0 && | 712 | if ((long long)al->addr < 0 && |
713 | cpumode == PERF_RECORD_MISC_KERNEL && | 713 | cpumode == PERF_RECORD_MISC_USER && |
714 | machine && mg != &machine->kmaps) { | 714 | machine && mg != &machine->kmaps) { |
715 | mg = &machine->kmaps; | 715 | mg = &machine->kmaps; |
716 | goto try_again; | 716 | goto try_again; |
diff --git a/tools/perf/util/probe-event.c b/tools/perf/util/probe-event.c index 5ddee66020a7..f0223166e761 100644 --- a/tools/perf/util/probe-event.c +++ b/tools/perf/util/probe-event.c | |||
@@ -234,7 +234,6 @@ static int try_to_find_probe_trace_events(struct perf_probe_event *pev, | |||
234 | 234 | ||
235 | /* Searching trace events corresponding to probe event */ | 235 | /* Searching trace events corresponding to probe event */ |
236 | ntevs = find_probe_trace_events(fd, pev, tevs, max_tevs); | 236 | ntevs = find_probe_trace_events(fd, pev, tevs, max_tevs); |
237 | close(fd); | ||
238 | 237 | ||
239 | if (ntevs > 0) { /* Succeeded to find trace events */ | 238 | if (ntevs > 0) { /* Succeeded to find trace events */ |
240 | pr_debug("find %d probe_trace_events.\n", ntevs); | 239 | pr_debug("find %d probe_trace_events.\n", ntevs); |
@@ -388,7 +387,6 @@ int show_line_range(struct line_range *lr, const char *module) | |||
388 | } | 387 | } |
389 | 388 | ||
390 | ret = find_line_range(fd, lr); | 389 | ret = find_line_range(fd, lr); |
391 | close(fd); | ||
392 | if (ret == 0) { | 390 | if (ret == 0) { |
393 | pr_warning("Specified source line is not found.\n"); | 391 | pr_warning("Specified source line is not found.\n"); |
394 | return -ENOENT; | 392 | return -ENOENT; |
@@ -512,19 +510,18 @@ int show_available_vars(struct perf_probe_event *pevs, int npevs, | |||
512 | if (ret < 0) | 510 | if (ret < 0) |
513 | return ret; | 511 | return ret; |
514 | 512 | ||
515 | fd = open_vmlinux(module); | ||
516 | if (fd < 0) { | ||
517 | pr_warning("Failed to open debug information file.\n"); | ||
518 | return fd; | ||
519 | } | ||
520 | |||
521 | setup_pager(); | 513 | setup_pager(); |
522 | 514 | ||
523 | for (i = 0; i < npevs && ret >= 0; i++) | 515 | for (i = 0; i < npevs && ret >= 0; i++) { |
516 | fd = open_vmlinux(module); | ||
517 | if (fd < 0) { | ||
518 | pr_warning("Failed to open debug information file.\n"); | ||
519 | ret = fd; | ||
520 | break; | ||
521 | } | ||
524 | ret = show_available_vars_at(fd, &pevs[i], max_vls, _filter, | 522 | ret = show_available_vars_at(fd, &pevs[i], max_vls, _filter, |
525 | externs); | 523 | externs); |
526 | 524 | } | |
527 | close(fd); | ||
528 | return ret; | 525 | return ret; |
529 | } | 526 | } |
530 | 527 | ||
diff --git a/tools/perf/util/probe-finder.c b/tools/perf/util/probe-finder.c index 194f9e2a3285..b7c85ce466a1 100644 --- a/tools/perf/util/probe-finder.c +++ b/tools/perf/util/probe-finder.c | |||
@@ -273,6 +273,25 @@ static const char *cu_get_comp_dir(Dwarf_Die *cu_die) | |||
273 | return dwarf_formstring(&attr); | 273 | return dwarf_formstring(&attr); |
274 | } | 274 | } |
275 | 275 | ||
276 | /* Get a line number and file name for given address */ | ||
277 | static int cu_find_lineinfo(Dwarf_Die *cudie, unsigned long addr, | ||
278 | const char **fname, int *lineno) | ||
279 | { | ||
280 | Dwarf_Line *line; | ||
281 | Dwarf_Addr laddr; | ||
282 | |||
283 | line = dwarf_getsrc_die(cudie, (Dwarf_Addr)addr); | ||
284 | if (line && dwarf_lineaddr(line, &laddr) == 0 && | ||
285 | addr == (unsigned long)laddr && dwarf_lineno(line, lineno) == 0) { | ||
286 | *fname = dwarf_linesrc(line, NULL, NULL); | ||
287 | if (!*fname) | ||
288 | /* line number is useless without filename */ | ||
289 | *lineno = 0; | ||
290 | } | ||
291 | |||
292 | return *lineno ?: -ENOENT; | ||
293 | } | ||
294 | |||
276 | /* Compare diename and tname */ | 295 | /* Compare diename and tname */ |
277 | static bool die_compare_name(Dwarf_Die *dw_die, const char *tname) | 296 | static bool die_compare_name(Dwarf_Die *dw_die, const char *tname) |
278 | { | 297 | { |
@@ -497,7 +516,20 @@ static int __die_find_inline_cb(Dwarf_Die *die_mem, void *data) | |||
497 | static Dwarf_Die *die_find_inlinefunc(Dwarf_Die *sp_die, Dwarf_Addr addr, | 516 | static Dwarf_Die *die_find_inlinefunc(Dwarf_Die *sp_die, Dwarf_Addr addr, |
498 | Dwarf_Die *die_mem) | 517 | Dwarf_Die *die_mem) |
499 | { | 518 | { |
500 | return die_find_child(sp_die, __die_find_inline_cb, &addr, die_mem); | 519 | Dwarf_Die tmp_die; |
520 | |||
521 | sp_die = die_find_child(sp_die, __die_find_inline_cb, &addr, &tmp_die); | ||
522 | if (!sp_die) | ||
523 | return NULL; | ||
524 | |||
525 | /* Inlined function could be recursive. Trace it until fail */ | ||
526 | while (sp_die) { | ||
527 | memcpy(die_mem, sp_die, sizeof(Dwarf_Die)); | ||
528 | sp_die = die_find_child(sp_die, __die_find_inline_cb, &addr, | ||
529 | &tmp_die); | ||
530 | } | ||
531 | |||
532 | return die_mem; | ||
501 | } | 533 | } |
502 | 534 | ||
503 | /* Walker on lines (Note: line number will not be sorted) */ | 535 | /* Walker on lines (Note: line number will not be sorted) */ |
@@ -1395,6 +1427,10 @@ static int probe_point_search_cb(Dwarf_Die *sp_die, void *data) | |||
1395 | !die_compare_name(sp_die, pp->function)) | 1427 | !die_compare_name(sp_die, pp->function)) |
1396 | return DWARF_CB_OK; | 1428 | return DWARF_CB_OK; |
1397 | 1429 | ||
1430 | /* Check declared file */ | ||
1431 | if (pp->file && strtailcmp(pp->file, dwarf_decl_file(sp_die))) | ||
1432 | return DWARF_CB_OK; | ||
1433 | |||
1398 | pf->fname = dwarf_decl_file(sp_die); | 1434 | pf->fname = dwarf_decl_file(sp_die); |
1399 | if (pp->line) { /* Function relative line */ | 1435 | if (pp->line) { /* Function relative line */ |
1400 | dwarf_decl_line(sp_die, &pf->lno); | 1436 | dwarf_decl_line(sp_die, &pf->lno); |
@@ -1451,6 +1487,7 @@ static int find_probes(int fd, struct probe_finder *pf) | |||
1451 | if (!dbg) { | 1487 | if (!dbg) { |
1452 | pr_warning("No debug information found in the vmlinux - " | 1488 | pr_warning("No debug information found in the vmlinux - " |
1453 | "please rebuild with CONFIG_DEBUG_INFO=y.\n"); | 1489 | "please rebuild with CONFIG_DEBUG_INFO=y.\n"); |
1490 | close(fd); /* Without dwfl_end(), fd isn't closed. */ | ||
1454 | return -EBADF; | 1491 | return -EBADF; |
1455 | } | 1492 | } |
1456 | 1493 | ||
@@ -1686,11 +1723,9 @@ int find_perf_probe_point(unsigned long addr, struct perf_probe_point *ppt) | |||
1686 | Dwarf_Die cudie, spdie, indie; | 1723 | Dwarf_Die cudie, spdie, indie; |
1687 | Dwarf *dbg = NULL; | 1724 | Dwarf *dbg = NULL; |
1688 | Dwfl *dwfl = NULL; | 1725 | Dwfl *dwfl = NULL; |
1689 | Dwarf_Line *line; | 1726 | Dwarf_Addr _addr, baseaddr, bias = 0; |
1690 | Dwarf_Addr laddr, eaddr, bias = 0; | 1727 | const char *fname = NULL, *func = NULL, *tmp; |
1691 | const char *tmp; | 1728 | int baseline = 0, lineno = 0, ret = 0; |
1692 | int lineno, ret = 0; | ||
1693 | bool found = false; | ||
1694 | 1729 | ||
1695 | /* Open the live linux kernel */ | 1730 | /* Open the live linux kernel */ |
1696 | dbg = dwfl_init_live_kernel_dwarf(addr, &dwfl, &bias); | 1731 | dbg = dwfl_init_live_kernel_dwarf(addr, &dwfl, &bias); |
@@ -1711,68 +1746,79 @@ int find_perf_probe_point(unsigned long addr, struct perf_probe_point *ppt) | |||
1711 | goto end; | 1746 | goto end; |
1712 | } | 1747 | } |
1713 | 1748 | ||
1714 | /* Find a corresponding line */ | 1749 | /* Find a corresponding line (filename and lineno) */ |
1715 | line = dwarf_getsrc_die(&cudie, (Dwarf_Addr)addr); | 1750 | cu_find_lineinfo(&cudie, addr, &fname, &lineno); |
1716 | if (line) { | 1751 | /* Don't care whether it failed or not */ |
1717 | if (dwarf_lineaddr(line, &laddr) == 0 && | ||
1718 | (Dwarf_Addr)addr == laddr && | ||
1719 | dwarf_lineno(line, &lineno) == 0) { | ||
1720 | tmp = dwarf_linesrc(line, NULL, NULL); | ||
1721 | if (tmp) { | ||
1722 | ppt->line = lineno; | ||
1723 | ppt->file = strdup(tmp); | ||
1724 | if (ppt->file == NULL) { | ||
1725 | ret = -ENOMEM; | ||
1726 | goto end; | ||
1727 | } | ||
1728 | found = true; | ||
1729 | } | ||
1730 | } | ||
1731 | } | ||
1732 | 1752 | ||
1733 | /* Find a corresponding function */ | 1753 | /* Find a corresponding function (name, baseline and baseaddr) */ |
1734 | if (die_find_real_subprogram(&cudie, (Dwarf_Addr)addr, &spdie)) { | 1754 | if (die_find_real_subprogram(&cudie, (Dwarf_Addr)addr, &spdie)) { |
1755 | /* Get function entry information */ | ||
1735 | tmp = dwarf_diename(&spdie); | 1756 | tmp = dwarf_diename(&spdie); |
1736 | if (!tmp || dwarf_entrypc(&spdie, &eaddr) != 0) | 1757 | if (!tmp || |
1737 | goto end; | 1758 | dwarf_entrypc(&spdie, &baseaddr) != 0 || |
1738 | 1759 | dwarf_decl_line(&spdie, &baseline) != 0) | |
1739 | if (ppt->line) { | 1760 | goto post; |
1740 | if (die_find_inlinefunc(&spdie, (Dwarf_Addr)addr, | 1761 | func = tmp; |
1741 | &indie)) { | 1762 | |
1742 | /* addr in an inline function */ | 1763 | if (addr == (unsigned long)baseaddr) |
1764 | /* Function entry - Relative line number is 0 */ | ||
1765 | lineno = baseline; | ||
1766 | else if (die_find_inlinefunc(&spdie, (Dwarf_Addr)addr, | ||
1767 | &indie)) { | ||
1768 | if (dwarf_entrypc(&indie, &_addr) == 0 && | ||
1769 | _addr == addr) | ||
1770 | /* | ||
1771 | * addr is at an inline function entry. | ||
1772 | * In this case, lineno should be the call-site | ||
1773 | * line number. | ||
1774 | */ | ||
1775 | lineno = die_get_call_lineno(&indie); | ||
1776 | else { | ||
1777 | /* | ||
1778 | * addr is in an inline function body. | ||
1779 | * Since lineno points one of the lines | ||
1780 | * of the inline function, baseline should | ||
1781 | * be the entry line of the inline function. | ||
1782 | */ | ||
1743 | tmp = dwarf_diename(&indie); | 1783 | tmp = dwarf_diename(&indie); |
1744 | if (!tmp) | 1784 | if (tmp && |
1745 | goto end; | 1785 | dwarf_decl_line(&spdie, &baseline) == 0) |
1746 | ret = dwarf_decl_line(&indie, &lineno); | 1786 | func = tmp; |
1747 | } else { | ||
1748 | if (eaddr == addr) { /* Function entry */ | ||
1749 | lineno = ppt->line; | ||
1750 | ret = 0; | ||
1751 | } else | ||
1752 | ret = dwarf_decl_line(&spdie, &lineno); | ||
1753 | } | ||
1754 | if (ret == 0) { | ||
1755 | /* Make a relative line number */ | ||
1756 | ppt->line -= lineno; | ||
1757 | goto found; | ||
1758 | } | 1787 | } |
1759 | } | 1788 | } |
1760 | /* We don't have a line number, let's use offset */ | 1789 | } |
1761 | ppt->offset = addr - (unsigned long)eaddr; | 1790 | |
1762 | found: | 1791 | post: |
1763 | ppt->function = strdup(tmp); | 1792 | /* Make a relative line number or an offset */ |
1793 | if (lineno) | ||
1794 | ppt->line = lineno - baseline; | ||
1795 | else if (func) | ||
1796 | ppt->offset = addr - (unsigned long)baseaddr; | ||
1797 | |||
1798 | /* Duplicate strings */ | ||
1799 | if (func) { | ||
1800 | ppt->function = strdup(func); | ||
1764 | if (ppt->function == NULL) { | 1801 | if (ppt->function == NULL) { |
1765 | ret = -ENOMEM; | 1802 | ret = -ENOMEM; |
1766 | goto end; | 1803 | goto end; |
1767 | } | 1804 | } |
1768 | found = true; | ||
1769 | } | 1805 | } |
1770 | 1806 | if (fname) { | |
1807 | ppt->file = strdup(fname); | ||
1808 | if (ppt->file == NULL) { | ||
1809 | if (ppt->function) { | ||
1810 | free(ppt->function); | ||
1811 | ppt->function = NULL; | ||
1812 | } | ||
1813 | ret = -ENOMEM; | ||
1814 | goto end; | ||
1815 | } | ||
1816 | } | ||
1771 | end: | 1817 | end: |
1772 | if (dwfl) | 1818 | if (dwfl) |
1773 | dwfl_end(dwfl); | 1819 | dwfl_end(dwfl); |
1774 | if (ret >= 0) | 1820 | if (ret == 0 && (fname || func)) |
1775 | ret = found ? 1 : 0; | 1821 | ret = 1; /* Found a point */ |
1776 | return ret; | 1822 | return ret; |
1777 | } | 1823 | } |
1778 | 1824 | ||
@@ -1840,6 +1886,10 @@ static int line_range_search_cb(Dwarf_Die *sp_die, void *data) | |||
1840 | struct line_finder *lf = param->data; | 1886 | struct line_finder *lf = param->data; |
1841 | struct line_range *lr = lf->lr; | 1887 | struct line_range *lr = lf->lr; |
1842 | 1888 | ||
1889 | /* Check declared file */ | ||
1890 | if (lr->file && strtailcmp(lr->file, dwarf_decl_file(sp_die))) | ||
1891 | return DWARF_CB_OK; | ||
1892 | |||
1843 | if (dwarf_tag(sp_die) == DW_TAG_subprogram && | 1893 | if (dwarf_tag(sp_die) == DW_TAG_subprogram && |
1844 | die_compare_name(sp_die, lr->function)) { | 1894 | die_compare_name(sp_die, lr->function)) { |
1845 | lf->fname = dwarf_decl_file(sp_die); | 1895 | lf->fname = dwarf_decl_file(sp_die); |
@@ -1892,6 +1942,7 @@ int find_line_range(int fd, struct line_range *lr) | |||
1892 | if (!dbg) { | 1942 | if (!dbg) { |
1893 | pr_warning("No debug information found in the vmlinux - " | 1943 | pr_warning("No debug information found in the vmlinux - " |
1894 | "please rebuild with CONFIG_DEBUG_INFO=y.\n"); | 1944 | "please rebuild with CONFIG_DEBUG_INFO=y.\n"); |
1945 | close(fd); /* Without dwfl_end(), fd isn't closed. */ | ||
1895 | return -EBADF; | 1946 | return -EBADF; |
1896 | } | 1947 | } |
1897 | 1948 | ||
diff --git a/tools/perf/util/setup.py b/tools/perf/util/setup.py index e24ffadb20b2..bbc982f5dd8b 100644 --- a/tools/perf/util/setup.py +++ b/tools/perf/util/setup.py | |||
@@ -1,13 +1,18 @@ | |||
1 | #!/usr/bin/python2 | 1 | #!/usr/bin/python2 |
2 | 2 | ||
3 | from distutils.core import setup, Extension | 3 | from distutils.core import setup, Extension |
4 | from os import getenv | ||
5 | |||
6 | cflags = ['-fno-strict-aliasing', '-Wno-write-strings'] | ||
7 | cflags += getenv('CFLAGS', '').split() | ||
4 | 8 | ||
5 | perf = Extension('perf', | 9 | perf = Extension('perf', |
6 | sources = ['util/python.c', 'util/ctype.c', 'util/evlist.c', | 10 | sources = ['util/python.c', 'util/ctype.c', 'util/evlist.c', |
7 | 'util/evsel.c', 'util/cpumap.c', 'util/thread_map.c', | 11 | 'util/evsel.c', 'util/cpumap.c', 'util/thread_map.c', |
8 | 'util/util.c', 'util/xyarray.c', 'util/cgroup.c'], | 12 | 'util/util.c', 'util/xyarray.c', 'util/cgroup.c'], |
9 | include_dirs = ['util/include'], | 13 | include_dirs = ['util/include'], |
10 | extra_compile_args = ['-fno-strict-aliasing', '-Wno-write-strings']) | 14 | extra_compile_args = cflags, |
15 | ) | ||
11 | 16 | ||
12 | setup(name='perf', | 17 | setup(name='perf', |
13 | version='0.1', | 18 | version='0.1', |
diff --git a/tools/perf/util/string.c b/tools/perf/util/string.c index 8fc0bd3a3a4a..b9a985dadd08 100644 --- a/tools/perf/util/string.c +++ b/tools/perf/util/string.c | |||
@@ -85,7 +85,7 @@ out: | |||
85 | 85 | ||
86 | /* | 86 | /* |
87 | * Helper function for splitting a string into an argv-like array. | 87 | * Helper function for splitting a string into an argv-like array. |
88 | * originaly copied from lib/argv_split.c | 88 | * originally copied from lib/argv_split.c |
89 | */ | 89 | */ |
90 | static const char *skip_sep(const char *cp) | 90 | static const char *skip_sep(const char *cp) |
91 | { | 91 | { |
diff --git a/tools/perf/util/symbol.c b/tools/perf/util/symbol.c index 17df793c8924..f06c10f092ba 100644 --- a/tools/perf/util/symbol.c +++ b/tools/perf/util/symbol.c | |||
@@ -1196,6 +1196,8 @@ static int dso__load_sym(struct dso *self, struct map *map, const char *name, | |||
1196 | if (curr_dso == NULL) | 1196 | if (curr_dso == NULL) |
1197 | goto out_elf_end; | 1197 | goto out_elf_end; |
1198 | curr_dso->kernel = self->kernel; | 1198 | curr_dso->kernel = self->kernel; |
1199 | curr_dso->long_name = self->long_name; | ||
1200 | curr_dso->long_name_len = self->long_name_len; | ||
1199 | curr_map = map__new2(start, curr_dso, | 1201 | curr_map = map__new2(start, curr_dso, |
1200 | map->type); | 1202 | map->type); |
1201 | if (curr_map == NULL) { | 1203 | if (curr_map == NULL) { |
@@ -1842,6 +1844,7 @@ int dso__load_vmlinux(struct dso *self, struct map *map, | |||
1842 | if (fd < 0) | 1844 | if (fd < 0) |
1843 | return -1; | 1845 | return -1; |
1844 | 1846 | ||
1847 | dso__set_long_name(self, (char *)vmlinux); | ||
1845 | dso__set_loaded(self, map->type); | 1848 | dso__set_loaded(self, map->type); |
1846 | err = dso__load_sym(self, map, symfs_vmlinux, fd, filter, 0, 0); | 1849 | err = dso__load_sym(self, map, symfs_vmlinux, fd, filter, 0, 0); |
1847 | close(fd); | 1850 | close(fd); |
@@ -2403,6 +2406,8 @@ int symbol__init(void) | |||
2403 | if (symbol_conf.initialized) | 2406 | if (symbol_conf.initialized) |
2404 | return 0; | 2407 | return 0; |
2405 | 2408 | ||
2409 | symbol_conf.priv_size = ALIGN(symbol_conf.priv_size, sizeof(u64)); | ||
2410 | |||
2406 | elf_version(EV_CURRENT); | 2411 | elf_version(EV_CURRENT); |
2407 | if (symbol_conf.sort_by_name) | 2412 | if (symbol_conf.sort_by_name) |
2408 | symbol_conf.priv_size += (sizeof(struct symbol_name_rb_node) - | 2413 | symbol_conf.priv_size += (sizeof(struct symbol_name_rb_node) - |
diff --git a/tools/power/x86/x86_energy_perf_policy/x86_energy_perf_policy.c b/tools/power/x86/x86_energy_perf_policy/x86_energy_perf_policy.c index d9678a34dd70..2618ef2ba31f 100644 --- a/tools/power/x86/x86_energy_perf_policy/x86_energy_perf_policy.c +++ b/tools/power/x86/x86_energy_perf_policy/x86_energy_perf_policy.c | |||
@@ -46,7 +46,7 @@ int cpu = -1; | |||
46 | * | 46 | * |
47 | * performance | 47 | * performance |
48 | * Performance is paramount. | 48 | * Performance is paramount. |
49 | * Unwilling to sacrafice any performance | 49 | * Unwilling to sacrifice any performance |
50 | * for the sake of energy saving. (hardware default) | 50 | * for the sake of energy saving. (hardware default) |
51 | * | 51 | * |
52 | * normal | 52 | * normal |