aboutsummaryrefslogtreecommitdiffstats
path: root/tools/perf
diff options
context:
space:
mode:
Diffstat (limited to 'tools/perf')
-rw-r--r--tools/perf/Makefile8
-rw-r--r--tools/perf/builtin-report.c17
-rw-r--r--tools/perf/builtin-stat.c35
-rw-r--r--tools/perf/builtin-test.c30
-rw-r--r--tools/perf/util/header.c2
-rw-r--r--tools/perf/util/parse-events.l2
-rw-r--r--tools/perf/util/symbol.c13
7 files changed, 84 insertions, 23 deletions
diff --git a/tools/perf/Makefile b/tools/perf/Makefile
index 4734f41f801d..398094c3d3c9 100644
--- a/tools/perf/Makefile
+++ b/tools/perf/Makefile
@@ -201,8 +201,8 @@ endif
201 201
202export PERL_PATH 202export PERL_PATH
203 203
204FLEX = $(CROSS_COMPILE)flex 204FLEX = flex
205BISON= $(CROSS_COMPILE)bison 205BISON= bison
206 206
207$(OUTPUT)util/parse-events-flex.c: util/parse-events.l 207$(OUTPUT)util/parse-events-flex.c: util/parse-events.l
208 $(QUIET_FLEX)$(FLEX) --header-file=$(OUTPUT)util/parse-events-flex.h -t util/parse-events.l > $(OUTPUT)util/parse-events-flex.c 208 $(QUIET_FLEX)$(FLEX) --header-file=$(OUTPUT)util/parse-events-flex.h -t util/parse-events.l > $(OUTPUT)util/parse-events-flex.c
@@ -737,10 +737,10 @@ $(OUTPUT)perf.o perf.spec \
737# over the general rule for .o 737# over the general rule for .o
738 738
739$(OUTPUT)util/%-flex.o: $(OUTPUT)util/%-flex.c $(OUTPUT)PERF-CFLAGS 739$(OUTPUT)util/%-flex.o: $(OUTPUT)util/%-flex.c $(OUTPUT)PERF-CFLAGS
740 $(QUIET_CC)$(CC) -o $@ -c $(ALL_CFLAGS) -Iutil/ -Wno-redundant-decls -Wno-switch-default -Wno-unused-function $< 740 $(QUIET_CC)$(CC) -o $@ -c $(ALL_CFLAGS) -Iutil/ -w $<
741 741
742$(OUTPUT)util/%-bison.o: $(OUTPUT)util/%-bison.c $(OUTPUT)PERF-CFLAGS 742$(OUTPUT)util/%-bison.o: $(OUTPUT)util/%-bison.c $(OUTPUT)PERF-CFLAGS
743 $(QUIET_CC)$(CC) -o $@ -c $(ALL_CFLAGS) -DYYENABLE_NLS=0 -DYYLTYPE_IS_TRIVIAL=0 -Iutil/ -Wno-redundant-decls -Wno-switch-default -Wno-unused-function $< 743 $(QUIET_CC)$(CC) -o $@ -c $(ALL_CFLAGS) -DYYENABLE_NLS=0 -DYYLTYPE_IS_TRIVIAL=0 -Iutil/ -w $<
744 744
745$(OUTPUT)%.o: %.c $(OUTPUT)PERF-CFLAGS 745$(OUTPUT)%.o: %.c $(OUTPUT)PERF-CFLAGS
746 $(QUIET_CC)$(CC) -o $@ -c $(ALL_CFLAGS) $< 746 $(QUIET_CC)$(CC) -o $@ -c $(ALL_CFLAGS) $<
diff --git a/tools/perf/builtin-report.c b/tools/perf/builtin-report.c
index 74776558ddfb..d58e41445d0d 100644
--- a/tools/perf/builtin-report.c
+++ b/tools/perf/builtin-report.c
@@ -377,16 +377,23 @@ static int __cmd_report(struct perf_report *rep)
377 (kernel_map->dso->hit && 377 (kernel_map->dso->hit &&
378 (kernel_kmap->ref_reloc_sym == NULL || 378 (kernel_kmap->ref_reloc_sym == NULL ||
379 kernel_kmap->ref_reloc_sym->addr == 0))) { 379 kernel_kmap->ref_reloc_sym->addr == 0))) {
380 const struct dso *kdso = kernel_map->dso; 380 const char *desc =
381 "As no suitable kallsyms nor vmlinux was found, kernel samples\n"
382 "can't be resolved.";
383
384 if (kernel_map) {
385 const struct dso *kdso = kernel_map->dso;
386 if (!RB_EMPTY_ROOT(&kdso->symbols[MAP__FUNCTION])) {
387 desc = "If some relocation was applied (e.g. "
388 "kexec) symbols may be misresolved.";
389 }
390 }
381 391
382 ui__warning( 392 ui__warning(
383"Kernel address maps (/proc/{kallsyms,modules}) were restricted.\n\n" 393"Kernel address maps (/proc/{kallsyms,modules}) were restricted.\n\n"
384"Check /proc/sys/kernel/kptr_restrict before running 'perf record'.\n\n%s\n\n" 394"Check /proc/sys/kernel/kptr_restrict before running 'perf record'.\n\n%s\n\n"
385"Samples in kernel modules can't be resolved as well.\n\n", 395"Samples in kernel modules can't be resolved as well.\n\n",
386 RB_EMPTY_ROOT(&kdso->symbols[MAP__FUNCTION]) ? 396 desc);
387"As no suitable kallsyms nor vmlinux was found, kernel samples\n"
388"can't be resolved." :
389"If some relocation was applied (e.g. kexec) symbols may be misresolved.");
390 } 397 }
391 398
392 if (dump_trace) { 399 if (dump_trace) {
diff --git a/tools/perf/builtin-stat.c b/tools/perf/builtin-stat.c
index 0f4b51ae4be7..62ae30d34fa6 100644
--- a/tools/perf/builtin-stat.c
+++ b/tools/perf/builtin-stat.c
@@ -282,6 +282,8 @@ static int create_perf_stat_counter(struct perf_evsel *evsel,
282{ 282{
283 struct perf_event_attr *attr = &evsel->attr; 283 struct perf_event_attr *attr = &evsel->attr;
284 struct xyarray *group_fd = NULL; 284 struct xyarray *group_fd = NULL;
285 bool exclude_guest_missing = false;
286 int ret;
285 287
286 if (group && evsel != first) 288 if (group && evsel != first)
287 group_fd = first->fd; 289 group_fd = first->fd;
@@ -292,16 +294,39 @@ static int create_perf_stat_counter(struct perf_evsel *evsel,
292 294
293 attr->inherit = !no_inherit; 295 attr->inherit = !no_inherit;
294 296
295 if (perf_target__has_cpu(&target)) 297retry:
296 return perf_evsel__open_per_cpu(evsel, evsel_list->cpus, 298 if (exclude_guest_missing)
297 group, group_fd); 299 evsel->attr.exclude_guest = evsel->attr.exclude_host = 0;
300
301 if (perf_target__has_cpu(&target)) {
302 ret = perf_evsel__open_per_cpu(evsel, evsel_list->cpus,
303 group, group_fd);
304 if (ret)
305 goto check_ret;
306 return 0;
307 }
308
298 if (!perf_target__has_task(&target) && (!group || evsel == first)) { 309 if (!perf_target__has_task(&target) && (!group || evsel == first)) {
299 attr->disabled = 1; 310 attr->disabled = 1;
300 attr->enable_on_exec = 1; 311 attr->enable_on_exec = 1;
301 } 312 }
302 313
303 return perf_evsel__open_per_thread(evsel, evsel_list->threads, 314 ret = perf_evsel__open_per_thread(evsel, evsel_list->threads,
304 group, group_fd); 315 group, group_fd);
316 if (!ret)
317 return 0;
318 /* fall through */
319check_ret:
320 if (ret && errno == EINVAL) {
321 if (!exclude_guest_missing &&
322 (evsel->attr.exclude_guest || evsel->attr.exclude_host)) {
323 pr_debug("Old kernel, cannot exclude "
324 "guest or host samples.\n");
325 exclude_guest_missing = true;
326 goto retry;
327 }
328 }
329 return ret;
305} 330}
306 331
307/* 332/*
diff --git a/tools/perf/builtin-test.c b/tools/perf/builtin-test.c
index 4eaa665fd32b..6c47376e29d8 100644
--- a/tools/perf/builtin-test.c
+++ b/tools/perf/builtin-test.c
@@ -851,6 +851,28 @@ static int test__checkevent_symbolic_name_modifier(struct perf_evlist *evlist)
851 return test__checkevent_symbolic_name(evlist); 851 return test__checkevent_symbolic_name(evlist);
852} 852}
853 853
854static int test__checkevent_exclude_host_modifier(struct perf_evlist *evlist)
855{
856 struct perf_evsel *evsel = list_entry(evlist->entries.next,
857 struct perf_evsel, node);
858
859 TEST_ASSERT_VAL("wrong exclude guest", !evsel->attr.exclude_guest);
860 TEST_ASSERT_VAL("wrong exclude host", evsel->attr.exclude_host);
861
862 return test__checkevent_symbolic_name(evlist);
863}
864
865static int test__checkevent_exclude_guest_modifier(struct perf_evlist *evlist)
866{
867 struct perf_evsel *evsel = list_entry(evlist->entries.next,
868 struct perf_evsel, node);
869
870 TEST_ASSERT_VAL("wrong exclude guest", evsel->attr.exclude_guest);
871 TEST_ASSERT_VAL("wrong exclude host", !evsel->attr.exclude_host);
872
873 return test__checkevent_symbolic_name(evlist);
874}
875
854static int test__checkevent_symbolic_alias_modifier(struct perf_evlist *evlist) 876static int test__checkevent_symbolic_alias_modifier(struct perf_evlist *evlist)
855{ 877{
856 struct perf_evsel *evsel = list_entry(evlist->entries.next, 878 struct perf_evsel *evsel = list_entry(evlist->entries.next,
@@ -1091,6 +1113,14 @@ static struct test__event_st {
1091 .name = "r1,syscalls:sys_enter_open:k,1:1:hp", 1113 .name = "r1,syscalls:sys_enter_open:k,1:1:hp",
1092 .check = test__checkevent_list, 1114 .check = test__checkevent_list,
1093 }, 1115 },
1116 {
1117 .name = "instructions:G",
1118 .check = test__checkevent_exclude_host_modifier,
1119 },
1120 {
1121 .name = "instructions:H",
1122 .check = test__checkevent_exclude_guest_modifier,
1123 },
1094}; 1124};
1095 1125
1096#define TEST__EVENTS_CNT (sizeof(test__events) / sizeof(struct test__event_st)) 1126#define TEST__EVENTS_CNT (sizeof(test__events) / sizeof(struct test__event_st))
diff --git a/tools/perf/util/header.c b/tools/perf/util/header.c
index 6e618ba21382..538598012139 100644
--- a/tools/perf/util/header.c
+++ b/tools/perf/util/header.c
@@ -291,7 +291,7 @@ int build_id_cache__add_s(const char *sbuild_id, const char *debugdir,
291 if (mkdir_p(filename, 0755)) 291 if (mkdir_p(filename, 0755))
292 goto out_free; 292 goto out_free;
293 293
294 snprintf(filename + len, sizeof(filename) - len, "/%s", sbuild_id); 294 snprintf(filename + len, size - len, "/%s", sbuild_id);
295 295
296 if (access(filename, F_OK)) { 296 if (access(filename, F_OK)) {
297 if (is_kallsyms) { 297 if (is_kallsyms) {
diff --git a/tools/perf/util/parse-events.l b/tools/perf/util/parse-events.l
index 05d766e3ecb5..1fcf1bbc5458 100644
--- a/tools/perf/util/parse-events.l
+++ b/tools/perf/util/parse-events.l
@@ -54,7 +54,7 @@ num_dec [0-9]+
54num_hex 0x[a-fA-F0-9]+ 54num_hex 0x[a-fA-F0-9]+
55num_raw_hex [a-fA-F0-9]+ 55num_raw_hex [a-fA-F0-9]+
56name [a-zA-Z_*?][a-zA-Z0-9_*?]* 56name [a-zA-Z_*?][a-zA-Z0-9_*?]*
57modifier_event [ukhp]{1,5} 57modifier_event [ukhpGH]{1,8}
58modifier_bp [rwx] 58modifier_bp [rwx]
59 59
60%% 60%%
diff --git a/tools/perf/util/symbol.c b/tools/perf/util/symbol.c
index c0a028c3ebaf..ab9867b2b433 100644
--- a/tools/perf/util/symbol.c
+++ b/tools/perf/util/symbol.c
@@ -977,8 +977,9 @@ static Elf_Scn *elf_section_by_name(Elf *elf, GElf_Ehdr *ep,
977 * And always look at the original dso, not at debuginfo packages, that 977 * And always look at the original dso, not at debuginfo packages, that
978 * have the PLT data stripped out (shdr_rel_plt.sh_type == SHT_NOBITS). 978 * have the PLT data stripped out (shdr_rel_plt.sh_type == SHT_NOBITS).
979 */ 979 */
980static int dso__synthesize_plt_symbols(struct dso *dso, struct map *map, 980static int
981 symbol_filter_t filter) 981dso__synthesize_plt_symbols(struct dso *dso, char *name, struct map *map,
982 symbol_filter_t filter)
982{ 983{
983 uint32_t nr_rel_entries, idx; 984 uint32_t nr_rel_entries, idx;
984 GElf_Sym sym; 985 GElf_Sym sym;
@@ -993,10 +994,7 @@ static int dso__synthesize_plt_symbols(struct dso *dso, struct map *map,
993 char sympltname[1024]; 994 char sympltname[1024];
994 Elf *elf; 995 Elf *elf;
995 int nr = 0, symidx, fd, err = 0; 996 int nr = 0, symidx, fd, err = 0;
996 char name[PATH_MAX];
997 997
998 snprintf(name, sizeof(name), "%s%s",
999 symbol_conf.symfs, dso->long_name);
1000 fd = open(name, O_RDONLY); 998 fd = open(name, O_RDONLY);
1001 if (fd < 0) 999 if (fd < 0)
1002 goto out; 1000 goto out;
@@ -1703,8 +1701,9 @@ restart:
1703 continue; 1701 continue;
1704 1702
1705 if (ret > 0) { 1703 if (ret > 0) {
1706 int nr_plt = dso__synthesize_plt_symbols(dso, map, 1704 int nr_plt;
1707 filter); 1705
1706 nr_plt = dso__synthesize_plt_symbols(dso, name, map, filter);
1708 if (nr_plt > 0) 1707 if (nr_plt > 0)
1709 ret += nr_plt; 1708 ret += nr_plt;
1710 break; 1709 break;