diff options
author | Ingo Molnar <mingo@kernel.org> | 2013-11-06 00:28:23 -0500 |
---|---|---|
committer | Ingo Molnar <mingo@kernel.org> | 2013-11-06 00:28:23 -0500 |
commit | 83bf9702c876a54e4e4d1735f9c8680a72421fbe (patch) | |
tree | ba664f98d92563544aa63dfb63ae4b49c27929c6 /tools/perf | |
parent | 87968f94fbea47df334502a0db645833ce8a848b (diff) | |
parent | 316c7136f8bad924609163b9b115f68d59a68c82 (diff) |
Merge tag 'perf-core-for-mingo' of git://git.kernel.org/pub/scm/linux/kernel/git/acme/linux into perf/core
Pull perf/core improvements and fixes from Arnaldo Carvalho de Melo:
* Check maximum frequency rate for record/top, emitting better error
messages, from Jiri Olsa.
* Disable live kvm command if timerfd is not supported, from David Ahern.
* Add usage to 'perf list', from David Ahern.
* Fix detection of non-core features, from David Ahern.
* Consolidate __hists__add_*entry(), cleanup from Namhyung Kim.
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Signed-off-by: Ingo Molnar <mingo@kernel.org>
Diffstat (limited to 'tools/perf')
45 files changed, 591 insertions, 497 deletions
diff --git a/tools/perf/Makefile.perf b/tools/perf/Makefile.perf index 5b8639025aae..7fc8f179cae7 100644 --- a/tools/perf/Makefile.perf +++ b/tools/perf/Makefile.perf | |||
@@ -242,7 +242,7 @@ LIB_H += util/cache.h | |||
242 | LIB_H += util/callchain.h | 242 | LIB_H += util/callchain.h |
243 | LIB_H += util/build-id.h | 243 | LIB_H += util/build-id.h |
244 | LIB_H += util/debug.h | 244 | LIB_H += util/debug.h |
245 | LIB_H += util/sysfs.h | 245 | LIB_H += util/fs.h |
246 | LIB_H += util/pmu.h | 246 | LIB_H += util/pmu.h |
247 | LIB_H += util/event.h | 247 | LIB_H += util/event.h |
248 | LIB_H += util/evsel.h | 248 | LIB_H += util/evsel.h |
@@ -304,7 +304,7 @@ LIB_OBJS += $(OUTPUT)util/annotate.o | |||
304 | LIB_OBJS += $(OUTPUT)util/build-id.o | 304 | LIB_OBJS += $(OUTPUT)util/build-id.o |
305 | LIB_OBJS += $(OUTPUT)util/config.o | 305 | LIB_OBJS += $(OUTPUT)util/config.o |
306 | LIB_OBJS += $(OUTPUT)util/ctype.o | 306 | LIB_OBJS += $(OUTPUT)util/ctype.o |
307 | LIB_OBJS += $(OUTPUT)util/sysfs.o | 307 | LIB_OBJS += $(OUTPUT)util/fs.o |
308 | LIB_OBJS += $(OUTPUT)util/pmu.o | 308 | LIB_OBJS += $(OUTPUT)util/pmu.o |
309 | LIB_OBJS += $(OUTPUT)util/environment.o | 309 | LIB_OBJS += $(OUTPUT)util/environment.o |
310 | LIB_OBJS += $(OUTPUT)util/event.o | 310 | LIB_OBJS += $(OUTPUT)util/event.o |
diff --git a/tools/perf/builtin-annotate.c b/tools/perf/builtin-annotate.c index 6c5ae57831f6..4087ab19823c 100644 --- a/tools/perf/builtin-annotate.c +++ b/tools/perf/builtin-annotate.c | |||
@@ -65,7 +65,7 @@ static int perf_evsel__add_sample(struct perf_evsel *evsel, | |||
65 | return 0; | 65 | return 0; |
66 | } | 66 | } |
67 | 67 | ||
68 | he = __hists__add_entry(&evsel->hists, al, NULL, 1, 1, 0); | 68 | he = __hists__add_entry(&evsel->hists, al, NULL, NULL, NULL, 1, 1, 0); |
69 | if (he == NULL) | 69 | if (he == NULL) |
70 | return -ENOMEM; | 70 | return -ENOMEM; |
71 | 71 | ||
diff --git a/tools/perf/builtin-diff.c b/tools/perf/builtin-diff.c index b605009e803f..3b67ea2444bd 100644 --- a/tools/perf/builtin-diff.c +++ b/tools/perf/builtin-diff.c | |||
@@ -307,7 +307,8 @@ static int hists__add_entry(struct hists *hists, | |||
307 | struct addr_location *al, u64 period, | 307 | struct addr_location *al, u64 period, |
308 | u64 weight, u64 transaction) | 308 | u64 weight, u64 transaction) |
309 | { | 309 | { |
310 | if (__hists__add_entry(hists, al, NULL, period, weight, transaction) != NULL) | 310 | if (__hists__add_entry(hists, al, NULL, NULL, NULL, period, weight, |
311 | transaction) != NULL) | ||
311 | return 0; | 312 | return 0; |
312 | return -ENOMEM; | 313 | return -ENOMEM; |
313 | } | 314 | } |
diff --git a/tools/perf/builtin-kvm.c b/tools/perf/builtin-kvm.c index cb05f39d8a77..cd9f92078aba 100644 --- a/tools/perf/builtin-kvm.c +++ b/tools/perf/builtin-kvm.c | |||
@@ -20,7 +20,9 @@ | |||
20 | #include "util/data.h" | 20 | #include "util/data.h" |
21 | 21 | ||
22 | #include <sys/prctl.h> | 22 | #include <sys/prctl.h> |
23 | #ifdef HAVE_TIMERFD_SUPPORT | ||
23 | #include <sys/timerfd.h> | 24 | #include <sys/timerfd.h> |
25 | #endif | ||
24 | 26 | ||
25 | #include <termios.h> | 27 | #include <termios.h> |
26 | #include <semaphore.h> | 28 | #include <semaphore.h> |
@@ -337,6 +339,7 @@ static void init_kvm_event_record(struct perf_kvm_stat *kvm) | |||
337 | INIT_LIST_HEAD(&kvm->kvm_events_cache[i]); | 339 | INIT_LIST_HEAD(&kvm->kvm_events_cache[i]); |
338 | } | 340 | } |
339 | 341 | ||
342 | #ifdef HAVE_TIMERFD_SUPPORT | ||
340 | static void clear_events_cache_stats(struct list_head *kvm_events_cache) | 343 | static void clear_events_cache_stats(struct list_head *kvm_events_cache) |
341 | { | 344 | { |
342 | struct list_head *head; | 345 | struct list_head *head; |
@@ -358,6 +361,7 @@ static void clear_events_cache_stats(struct list_head *kvm_events_cache) | |||
358 | } | 361 | } |
359 | } | 362 | } |
360 | } | 363 | } |
364 | #endif | ||
361 | 365 | ||
362 | static int kvm_events_hash_fn(u64 key) | 366 | static int kvm_events_hash_fn(u64 key) |
363 | { | 367 | { |
@@ -783,6 +787,7 @@ static void print_result(struct perf_kvm_stat *kvm) | |||
783 | pr_info("\nLost events: %" PRIu64 "\n\n", kvm->lost_events); | 787 | pr_info("\nLost events: %" PRIu64 "\n\n", kvm->lost_events); |
784 | } | 788 | } |
785 | 789 | ||
790 | #ifdef HAVE_TIMERFD_SUPPORT | ||
786 | static int process_lost_event(struct perf_tool *tool, | 791 | static int process_lost_event(struct perf_tool *tool, |
787 | union perf_event *event __maybe_unused, | 792 | union perf_event *event __maybe_unused, |
788 | struct perf_sample *sample __maybe_unused, | 793 | struct perf_sample *sample __maybe_unused, |
@@ -793,6 +798,7 @@ static int process_lost_event(struct perf_tool *tool, | |||
793 | kvm->lost_events++; | 798 | kvm->lost_events++; |
794 | return 0; | 799 | return 0; |
795 | } | 800 | } |
801 | #endif | ||
796 | 802 | ||
797 | static bool skip_sample(struct perf_kvm_stat *kvm, | 803 | static bool skip_sample(struct perf_kvm_stat *kvm, |
798 | struct perf_sample *sample) | 804 | struct perf_sample *sample) |
@@ -872,6 +878,7 @@ static bool verify_vcpu(int vcpu) | |||
872 | return true; | 878 | return true; |
873 | } | 879 | } |
874 | 880 | ||
881 | #ifdef HAVE_TIMERFD_SUPPORT | ||
875 | /* keeping the max events to a modest level to keep | 882 | /* keeping the max events to a modest level to keep |
876 | * the processing of samples per mmap smooth. | 883 | * the processing of samples per mmap smooth. |
877 | */ | 884 | */ |
@@ -1213,6 +1220,7 @@ static int kvm_live_open_events(struct perf_kvm_stat *kvm) | |||
1213 | out: | 1220 | out: |
1214 | return rc; | 1221 | return rc; |
1215 | } | 1222 | } |
1223 | #endif | ||
1216 | 1224 | ||
1217 | static int read_events(struct perf_kvm_stat *kvm) | 1225 | static int read_events(struct perf_kvm_stat *kvm) |
1218 | { | 1226 | { |
@@ -1379,6 +1387,7 @@ kvm_events_report(struct perf_kvm_stat *kvm, int argc, const char **argv) | |||
1379 | return kvm_events_report_vcpu(kvm); | 1387 | return kvm_events_report_vcpu(kvm); |
1380 | } | 1388 | } |
1381 | 1389 | ||
1390 | #ifdef HAVE_TIMERFD_SUPPORT | ||
1382 | static struct perf_evlist *kvm_live_event_list(void) | 1391 | static struct perf_evlist *kvm_live_event_list(void) |
1383 | { | 1392 | { |
1384 | struct perf_evlist *evlist; | 1393 | struct perf_evlist *evlist; |
@@ -1566,6 +1575,7 @@ out: | |||
1566 | 1575 | ||
1567 | return err; | 1576 | return err; |
1568 | } | 1577 | } |
1578 | #endif | ||
1569 | 1579 | ||
1570 | static void print_kvm_stat_usage(void) | 1580 | static void print_kvm_stat_usage(void) |
1571 | { | 1581 | { |
@@ -1604,8 +1614,10 @@ static int kvm_cmd_stat(const char *file_name, int argc, const char **argv) | |||
1604 | if (!strncmp(argv[1], "rep", 3)) | 1614 | if (!strncmp(argv[1], "rep", 3)) |
1605 | return kvm_events_report(&kvm, argc - 1 , argv + 1); | 1615 | return kvm_events_report(&kvm, argc - 1 , argv + 1); |
1606 | 1616 | ||
1617 | #ifdef HAVE_TIMERFD_SUPPORT | ||
1607 | if (!strncmp(argv[1], "live", 4)) | 1618 | if (!strncmp(argv[1], "live", 4)) |
1608 | return kvm_events_live(&kvm, argc - 1 , argv + 1); | 1619 | return kvm_events_live(&kvm, argc - 1 , argv + 1); |
1620 | #endif | ||
1609 | 1621 | ||
1610 | perf_stat: | 1622 | perf_stat: |
1611 | return cmd_stat(argc, argv, NULL); | 1623 | return cmd_stat(argc, argv, NULL); |
diff --git a/tools/perf/builtin-list.c b/tools/perf/builtin-list.c index e79f423cc302..011195e38f21 100644 --- a/tools/perf/builtin-list.c +++ b/tools/perf/builtin-list.c | |||
@@ -14,51 +14,63 @@ | |||
14 | #include "util/parse-events.h" | 14 | #include "util/parse-events.h" |
15 | #include "util/cache.h" | 15 | #include "util/cache.h" |
16 | #include "util/pmu.h" | 16 | #include "util/pmu.h" |
17 | #include "util/parse-options.h" | ||
17 | 18 | ||
18 | int cmd_list(int argc, const char **argv, const char *prefix __maybe_unused) | 19 | int cmd_list(int argc, const char **argv, const char *prefix __maybe_unused) |
19 | { | 20 | { |
21 | int i; | ||
22 | const struct option list_options[] = { | ||
23 | OPT_END() | ||
24 | }; | ||
25 | const char * const list_usage[] = { | ||
26 | "perf list [hw|sw|cache|tracepoint|pmu|event_glob]", | ||
27 | NULL | ||
28 | }; | ||
29 | |||
30 | argc = parse_options(argc, argv, list_options, list_usage, | ||
31 | PARSE_OPT_STOP_AT_NON_OPTION); | ||
32 | |||
20 | setup_pager(); | 33 | setup_pager(); |
21 | 34 | ||
22 | if (argc == 1) | 35 | if (argc == 0) { |
23 | print_events(NULL, false); | 36 | print_events(NULL, false); |
24 | else { | 37 | return 0; |
25 | int i; | 38 | } |
26 | |||
27 | for (i = 1; i < argc; ++i) { | ||
28 | if (i > 2) | ||
29 | putchar('\n'); | ||
30 | if (strncmp(argv[i], "tracepoint", 10) == 0) | ||
31 | print_tracepoint_events(NULL, NULL, false); | ||
32 | else if (strcmp(argv[i], "hw") == 0 || | ||
33 | strcmp(argv[i], "hardware") == 0) | ||
34 | print_events_type(PERF_TYPE_HARDWARE); | ||
35 | else if (strcmp(argv[i], "sw") == 0 || | ||
36 | strcmp(argv[i], "software") == 0) | ||
37 | print_events_type(PERF_TYPE_SOFTWARE); | ||
38 | else if (strcmp(argv[i], "cache") == 0 || | ||
39 | strcmp(argv[i], "hwcache") == 0) | ||
40 | print_hwcache_events(NULL, false); | ||
41 | else if (strcmp(argv[i], "pmu") == 0) | ||
42 | print_pmu_events(NULL, false); | ||
43 | else if (strcmp(argv[i], "--raw-dump") == 0) | ||
44 | print_events(NULL, true); | ||
45 | else { | ||
46 | char *sep = strchr(argv[i], ':'), *s; | ||
47 | int sep_idx; | ||
48 | 39 | ||
49 | if (sep == NULL) { | 40 | for (i = 0; i < argc; ++i) { |
50 | print_events(argv[i], false); | 41 | if (i) |
51 | continue; | 42 | putchar('\n'); |
52 | } | 43 | if (strncmp(argv[i], "tracepoint", 10) == 0) |
53 | sep_idx = sep - argv[i]; | 44 | print_tracepoint_events(NULL, NULL, false); |
54 | s = strdup(argv[i]); | 45 | else if (strcmp(argv[i], "hw") == 0 || |
55 | if (s == NULL) | 46 | strcmp(argv[i], "hardware") == 0) |
56 | return -1; | 47 | print_events_type(PERF_TYPE_HARDWARE); |
48 | else if (strcmp(argv[i], "sw") == 0 || | ||
49 | strcmp(argv[i], "software") == 0) | ||
50 | print_events_type(PERF_TYPE_SOFTWARE); | ||
51 | else if (strcmp(argv[i], "cache") == 0 || | ||
52 | strcmp(argv[i], "hwcache") == 0) | ||
53 | print_hwcache_events(NULL, false); | ||
54 | else if (strcmp(argv[i], "pmu") == 0) | ||
55 | print_pmu_events(NULL, false); | ||
56 | else if (strcmp(argv[i], "--raw-dump") == 0) | ||
57 | print_events(NULL, true); | ||
58 | else { | ||
59 | char *sep = strchr(argv[i], ':'), *s; | ||
60 | int sep_idx; | ||
57 | 61 | ||
58 | s[sep_idx] = '\0'; | 62 | if (sep == NULL) { |
59 | print_tracepoint_events(s, s + sep_idx + 1, false); | 63 | print_events(argv[i], false); |
60 | free(s); | 64 | continue; |
61 | } | 65 | } |
66 | sep_idx = sep - argv[i]; | ||
67 | s = strdup(argv[i]); | ||
68 | if (s == NULL) | ||
69 | return -1; | ||
70 | |||
71 | s[sep_idx] = '\0'; | ||
72 | print_tracepoint_events(s, s + sep_idx + 1, false); | ||
73 | free(s); | ||
62 | } | 74 | } |
63 | } | 75 | } |
64 | return 0; | 76 | return 0; |
diff --git a/tools/perf/builtin-record.c b/tools/perf/builtin-record.c index 8b45fcead5f6..ea4c04f7437e 100644 --- a/tools/perf/builtin-record.c +++ b/tools/perf/builtin-record.c | |||
@@ -958,20 +958,7 @@ int cmd_record(int argc, const char **argv, const char *prefix __maybe_unused) | |||
958 | if (perf_evlist__create_maps(evsel_list, &rec->opts.target) < 0) | 958 | if (perf_evlist__create_maps(evsel_list, &rec->opts.target) < 0) |
959 | usage_with_options(record_usage, record_options); | 959 | usage_with_options(record_usage, record_options); |
960 | 960 | ||
961 | if (rec->opts.user_interval != ULLONG_MAX) | 961 | if (perf_record_opts__config(&rec->opts)) { |
962 | rec->opts.default_interval = rec->opts.user_interval; | ||
963 | if (rec->opts.user_freq != UINT_MAX) | ||
964 | rec->opts.freq = rec->opts.user_freq; | ||
965 | |||
966 | /* | ||
967 | * User specified count overrides default frequency. | ||
968 | */ | ||
969 | if (rec->opts.default_interval) | ||
970 | rec->opts.freq = 0; | ||
971 | else if (rec->opts.freq) { | ||
972 | rec->opts.default_interval = rec->opts.freq; | ||
973 | } else { | ||
974 | ui__error("frequency and count are zero, aborting\n"); | ||
975 | err = -EINVAL; | 962 | err = -EINVAL; |
976 | goto out_free_fd; | 963 | goto out_free_fd; |
977 | } | 964 | } |
diff --git a/tools/perf/builtin-report.c b/tools/perf/builtin-report.c index 25f83d5d66fd..8cf8e66ba594 100644 --- a/tools/perf/builtin-report.c +++ b/tools/perf/builtin-report.c | |||
@@ -115,7 +115,8 @@ static int perf_report__add_mem_hist_entry(struct perf_tool *tool, | |||
115 | * and this is indirectly achieved by passing period=weight here | 115 | * and this is indirectly achieved by passing period=weight here |
116 | * and the he_stat__add_period() function. | 116 | * and the he_stat__add_period() function. |
117 | */ | 117 | */ |
118 | he = __hists__add_mem_entry(&evsel->hists, al, parent, mi, cost, cost); | 118 | he = __hists__add_entry(&evsel->hists, al, parent, NULL, mi, |
119 | cost, cost, 0); | ||
119 | if (!he) | 120 | if (!he) |
120 | return -ENOMEM; | 121 | return -ENOMEM; |
121 | 122 | ||
@@ -200,12 +201,16 @@ static int perf_report__add_branch_hist_entry(struct perf_tool *tool, | |||
200 | 201 | ||
201 | err = -ENOMEM; | 202 | err = -ENOMEM; |
202 | 203 | ||
204 | /* overwrite the 'al' to branch-to info */ | ||
205 | al->map = bi[i].to.map; | ||
206 | al->sym = bi[i].to.sym; | ||
207 | al->addr = bi[i].to.addr; | ||
203 | /* | 208 | /* |
204 | * The report shows the percentage of total branches captured | 209 | * The report shows the percentage of total branches captured |
205 | * and not events sampled. Thus we use a pseudo period of 1. | 210 | * and not events sampled. Thus we use a pseudo period of 1. |
206 | */ | 211 | */ |
207 | he = __hists__add_branch_entry(&evsel->hists, al, parent, | 212 | he = __hists__add_entry(&evsel->hists, al, parent, &bi[i], NULL, |
208 | &bi[i], 1, 1); | 213 | 1, 1, 0); |
209 | if (he) { | 214 | if (he) { |
210 | struct annotation *notes; | 215 | struct annotation *notes; |
211 | bx = he->branch_info; | 216 | bx = he->branch_info; |
@@ -266,8 +271,9 @@ static int perf_evsel__add_hist_entry(struct perf_tool *tool, | |||
266 | return err; | 271 | return err; |
267 | } | 272 | } |
268 | 273 | ||
269 | he = __hists__add_entry(&evsel->hists, al, parent, sample->period, | 274 | he = __hists__add_entry(&evsel->hists, al, parent, NULL, NULL, |
270 | sample->weight, sample->transaction); | 275 | sample->period, sample->weight, |
276 | sample->transaction); | ||
271 | if (he == NULL) | 277 | if (he == NULL) |
272 | return -ENOMEM; | 278 | return -ENOMEM; |
273 | 279 | ||
diff --git a/tools/perf/builtin-top.c b/tools/perf/builtin-top.c index ca5ca37980fb..9acca8856ccb 100644 --- a/tools/perf/builtin-top.c +++ b/tools/perf/builtin-top.c | |||
@@ -246,8 +246,9 @@ static struct hist_entry *perf_evsel__add_hist_entry(struct perf_evsel *evsel, | |||
246 | struct hist_entry *he; | 246 | struct hist_entry *he; |
247 | 247 | ||
248 | pthread_mutex_lock(&evsel->hists.lock); | 248 | pthread_mutex_lock(&evsel->hists.lock); |
249 | he = __hists__add_entry(&evsel->hists, al, NULL, sample->period, | 249 | he = __hists__add_entry(&evsel->hists, al, NULL, NULL, NULL, |
250 | sample->weight, sample->transaction); | 250 | sample->period, sample->weight, |
251 | sample->transaction); | ||
251 | pthread_mutex_unlock(&evsel->hists.lock); | 252 | pthread_mutex_unlock(&evsel->hists.lock); |
252 | if (he == NULL) | 253 | if (he == NULL) |
253 | return NULL; | 254 | return NULL; |
@@ -1208,20 +1209,7 @@ int cmd_top(int argc, const char **argv, const char *prefix __maybe_unused) | |||
1208 | if (top.delay_secs < 1) | 1209 | if (top.delay_secs < 1) |
1209 | top.delay_secs = 1; | 1210 | top.delay_secs = 1; |
1210 | 1211 | ||
1211 | if (opts->user_interval != ULLONG_MAX) | 1212 | if (perf_record_opts__config(opts)) { |
1212 | opts->default_interval = opts->user_interval; | ||
1213 | if (opts->user_freq != UINT_MAX) | ||
1214 | opts->freq = opts->user_freq; | ||
1215 | |||
1216 | /* | ||
1217 | * User specified count overrides default frequency. | ||
1218 | */ | ||
1219 | if (opts->default_interval) | ||
1220 | opts->freq = 0; | ||
1221 | else if (opts->freq) { | ||
1222 | opts->default_interval = opts->freq; | ||
1223 | } else { | ||
1224 | ui__error("frequency and count are zero, aborting\n"); | ||
1225 | status = -EINVAL; | 1213 | status = -EINVAL; |
1226 | goto out_delete_maps; | 1214 | goto out_delete_maps; |
1227 | } | 1215 | } |
diff --git a/tools/perf/config/Makefile b/tools/perf/config/Makefile index ffb5f55c8fba..58b2d37ae23a 100644 --- a/tools/perf/config/Makefile +++ b/tools/perf/config/Makefile | |||
@@ -98,7 +98,7 @@ endif | |||
98 | 98 | ||
99 | feature_check = $(eval $(feature_check_code)) | 99 | feature_check = $(eval $(feature_check_code)) |
100 | define feature_check_code | 100 | define feature_check_code |
101 | feature-$(1) := $(shell $(MAKE) OUTPUT=$(OUTPUT_FEATURES) CFLAGS="$(EXTRA_CFLAGS)" LDFLAGS=$(LDFLAGS) LIBUNWIND_LIBS="$(LIBUNWIND_LIBS)" -C config/feature-checks test-$1 >/dev/null 2>/dev/null && echo 1 || echo 0) | 101 | feature-$(1) := $(shell $(MAKE) OUTPUT=$(OUTPUT_FEATURES) CFLAGS="$(EXTRA_CFLAGS)" LDFLAGS="$(LDFLAGS)" LIBUNWIND_LIBS="$(LIBUNWIND_LIBS)" -C config/feature-checks test-$1 >/dev/null 2>/dev/null && echo 1 || echo 0) |
102 | endef | 102 | endef |
103 | 103 | ||
104 | feature_set = $(eval $(feature_set_code)) | 104 | feature_set = $(eval $(feature_set_code)) |
@@ -235,7 +235,7 @@ CFLAGS += -I$(LIB_INCLUDE) | |||
235 | CFLAGS += -D_LARGEFILE64_SOURCE -D_FILE_OFFSET_BITS=64 -D_GNU_SOURCE | 235 | CFLAGS += -D_LARGEFILE64_SOURCE -D_FILE_OFFSET_BITS=64 -D_GNU_SOURCE |
236 | 236 | ||
237 | ifndef NO_BIONIC | 237 | ifndef NO_BIONIC |
238 | $(feature_check,bionic) | 238 | $(call feature_check,bionic) |
239 | ifeq ($(feature-bionic), 1) | 239 | ifeq ($(feature-bionic), 1) |
240 | BIONIC := 1 | 240 | BIONIC := 1 |
241 | EXTLIBS := $(filter-out -lrt,$(EXTLIBS)) | 241 | EXTLIBS := $(filter-out -lrt,$(EXTLIBS)) |
@@ -397,6 +397,13 @@ else | |||
397 | endif | 397 | endif |
398 | endif | 398 | endif |
399 | 399 | ||
400 | $(call feature_check,timerfd) | ||
401 | ifeq ($(feature-timerfd), 1) | ||
402 | CFLAGS += -DHAVE_TIMERFD_SUPPORT | ||
403 | else | ||
404 | msg := $(warning No timerfd support. Disables 'perf kvm stat live'); | ||
405 | endif | ||
406 | |||
400 | disable-python = $(eval $(disable-python_code)) | 407 | disable-python = $(eval $(disable-python_code)) |
401 | define disable-python_code | 408 | define disable-python_code |
402 | CFLAGS += -DNO_LIBPYTHON | 409 | CFLAGS += -DNO_LIBPYTHON |
@@ -472,15 +479,15 @@ else | |||
472 | CFLAGS += -DHAVE_CPLUS_DEMANGLE_SUPPORT | 479 | CFLAGS += -DHAVE_CPLUS_DEMANGLE_SUPPORT |
473 | else | 480 | else |
474 | ifneq ($(feature-libbfd), 1) | 481 | ifneq ($(feature-libbfd), 1) |
475 | $(feature_check,liberty) | 482 | $(call feature_check,liberty) |
476 | ifeq ($(feature-liberty), 1) | 483 | ifeq ($(feature-liberty), 1) |
477 | EXTLIBS += -lbfd -liberty | 484 | EXTLIBS += -lbfd -liberty |
478 | else | 485 | else |
479 | $(feature_check,liberty-z) | 486 | $(call feature_check,liberty-z) |
480 | ifeq ($(feature-liberty-z), 1) | 487 | ifeq ($(feature-liberty-z), 1) |
481 | EXTLIBS += -lbfd -liberty -lz | 488 | EXTLIBS += -lbfd -liberty -lz |
482 | else | 489 | else |
483 | $(feature_check,cplus-demangle) | 490 | $(call feature_check,cplus-demangle) |
484 | ifeq ($(feature-cplus-demangle), 1) | 491 | ifeq ($(feature-cplus-demangle), 1) |
485 | EXTLIBS += -liberty | 492 | EXTLIBS += -liberty |
486 | CFLAGS += -DHAVE_CPLUS_DEMANGLE_SUPPORT | 493 | CFLAGS += -DHAVE_CPLUS_DEMANGLE_SUPPORT |
diff --git a/tools/perf/config/feature-checks/Makefile b/tools/perf/config/feature-checks/Makefile index d37d58d273fe..c803f17fb986 100644 --- a/tools/perf/config/feature-checks/Makefile +++ b/tools/perf/config/feature-checks/Makefile | |||
@@ -25,7 +25,8 @@ FILES= \ | |||
25 | test-libunwind \ | 25 | test-libunwind \ |
26 | test-on-exit \ | 26 | test-on-exit \ |
27 | test-stackprotector-all \ | 27 | test-stackprotector-all \ |
28 | test-stackprotector | 28 | test-stackprotector \ |
29 | test-timerfd | ||
29 | 30 | ||
30 | CC := $(CC) -MD | 31 | CC := $(CC) -MD |
31 | 32 | ||
@@ -136,6 +137,9 @@ test-on-exit: | |||
136 | test-backtrace: | 137 | test-backtrace: |
137 | $(BUILD) | 138 | $(BUILD) |
138 | 139 | ||
140 | test-timerfd: | ||
141 | $(BUILD) | ||
142 | |||
139 | -include *.d | 143 | -include *.d |
140 | 144 | ||
141 | ############################### | 145 | ############################### |
diff --git a/tools/perf/config/feature-checks/test-all.c b/tools/perf/config/feature-checks/test-all.c index 50d431892a0c..59e7a705e146 100644 --- a/tools/perf/config/feature-checks/test-all.c +++ b/tools/perf/config/feature-checks/test-all.c | |||
@@ -81,6 +81,10 @@ | |||
81 | # include "test-libnuma.c" | 81 | # include "test-libnuma.c" |
82 | #undef main | 82 | #undef main |
83 | 83 | ||
84 | #define main main_test_timerfd | ||
85 | # include "test-timerfd.c" | ||
86 | #undef main | ||
87 | |||
84 | int main(int argc, char *argv[]) | 88 | int main(int argc, char *argv[]) |
85 | { | 89 | { |
86 | main_test_libpython(); | 90 | main_test_libpython(); |
@@ -101,6 +105,7 @@ int main(int argc, char *argv[]) | |||
101 | main_test_on_exit(); | 105 | main_test_on_exit(); |
102 | main_test_backtrace(); | 106 | main_test_backtrace(); |
103 | main_test_libnuma(); | 107 | main_test_libnuma(); |
108 | main_test_timerfd(); | ||
104 | 109 | ||
105 | return 0; | 110 | return 0; |
106 | } | 111 | } |
diff --git a/tools/perf/config/feature-checks/test-timerfd.c b/tools/perf/config/feature-checks/test-timerfd.c new file mode 100644 index 000000000000..8c5c083b4d3c --- /dev/null +++ b/tools/perf/config/feature-checks/test-timerfd.c | |||
@@ -0,0 +1,18 @@ | |||
1 | /* | ||
2 | * test for timerfd functions used by perf-kvm-stat-live | ||
3 | */ | ||
4 | #include <sys/timerfd.h> | ||
5 | |||
6 | int main(void) | ||
7 | { | ||
8 | struct itimerspec new_value; | ||
9 | |||
10 | int fd = timerfd_create(CLOCK_MONOTONIC, TFD_NONBLOCK); | ||
11 | if (fd < 0) | ||
12 | return 1; | ||
13 | |||
14 | if (timerfd_settime(fd, 0, &new_value, NULL) != 0) | ||
15 | return 1; | ||
16 | |||
17 | return 0; | ||
18 | } | ||
diff --git a/tools/perf/scripts/python/Perf-Trace-Util/Context.c b/tools/perf/scripts/python/Perf-Trace-Util/Context.c index 315067b8f552..fcd1dd667906 100644 --- a/tools/perf/scripts/python/Perf-Trace-Util/Context.c +++ b/tools/perf/scripts/python/Perf-Trace-Util/Context.c | |||
@@ -25,7 +25,7 @@ | |||
25 | 25 | ||
26 | PyMODINIT_FUNC initperf_trace_context(void); | 26 | PyMODINIT_FUNC initperf_trace_context(void); |
27 | 27 | ||
28 | static PyObject *perf_trace_context_common_pc(PyObject *self, PyObject *args) | 28 | static PyObject *perf_trace_context_common_pc(PyObject *obj, PyObject *args) |
29 | { | 29 | { |
30 | static struct scripting_context *scripting_context; | 30 | static struct scripting_context *scripting_context; |
31 | PyObject *context; | 31 | PyObject *context; |
@@ -40,7 +40,7 @@ static PyObject *perf_trace_context_common_pc(PyObject *self, PyObject *args) | |||
40 | return Py_BuildValue("i", retval); | 40 | return Py_BuildValue("i", retval); |
41 | } | 41 | } |
42 | 42 | ||
43 | static PyObject *perf_trace_context_common_flags(PyObject *self, | 43 | static PyObject *perf_trace_context_common_flags(PyObject *obj, |
44 | PyObject *args) | 44 | PyObject *args) |
45 | { | 45 | { |
46 | static struct scripting_context *scripting_context; | 46 | static struct scripting_context *scripting_context; |
@@ -56,7 +56,7 @@ static PyObject *perf_trace_context_common_flags(PyObject *self, | |||
56 | return Py_BuildValue("i", retval); | 56 | return Py_BuildValue("i", retval); |
57 | } | 57 | } |
58 | 58 | ||
59 | static PyObject *perf_trace_context_common_lock_depth(PyObject *self, | 59 | static PyObject *perf_trace_context_common_lock_depth(PyObject *obj, |
60 | PyObject *args) | 60 | PyObject *args) |
61 | { | 61 | { |
62 | static struct scripting_context *scripting_context; | 62 | static struct scripting_context *scripting_context; |
diff --git a/tools/perf/tests/hists_link.c b/tools/perf/tests/hists_link.c index 6c337e653540..173bf42cc03e 100644 --- a/tools/perf/tests/hists_link.c +++ b/tools/perf/tests/hists_link.c | |||
@@ -223,7 +223,7 @@ static int add_hist_entries(struct perf_evlist *evlist, struct machine *machine) | |||
223 | goto out; | 223 | goto out; |
224 | 224 | ||
225 | he = __hists__add_entry(&evsel->hists, &al, NULL, | 225 | he = __hists__add_entry(&evsel->hists, &al, NULL, |
226 | 1, 1, 0); | 226 | NULL, NULL, 1, 1, 0); |
227 | if (he == NULL) | 227 | if (he == NULL) |
228 | goto out; | 228 | goto out; |
229 | 229 | ||
@@ -245,8 +245,8 @@ static int add_hist_entries(struct perf_evlist *evlist, struct machine *machine) | |||
245 | &sample) < 0) | 245 | &sample) < 0) |
246 | goto out; | 246 | goto out; |
247 | 247 | ||
248 | he = __hists__add_entry(&evsel->hists, &al, NULL, 1, 1, | 248 | he = __hists__add_entry(&evsel->hists, &al, NULL, |
249 | 0); | 249 | NULL, NULL, 1, 1, 0); |
250 | if (he == NULL) | 250 | if (he == NULL) |
251 | goto out; | 251 | goto out; |
252 | 252 | ||
diff --git a/tools/perf/tests/parse-events.c b/tools/perf/tests/parse-events.c index 48114d164e9f..ef671cd41bb3 100644 --- a/tools/perf/tests/parse-events.c +++ b/tools/perf/tests/parse-events.c | |||
@@ -2,7 +2,7 @@ | |||
2 | #include "parse-events.h" | 2 | #include "parse-events.h" |
3 | #include "evsel.h" | 3 | #include "evsel.h" |
4 | #include "evlist.h" | 4 | #include "evlist.h" |
5 | #include "sysfs.h" | 5 | #include "fs.h" |
6 | #include <lk/debugfs.h> | 6 | #include <lk/debugfs.h> |
7 | #include "tests.h" | 7 | #include "tests.h" |
8 | #include <linux/hw_breakpoint.h> | 8 | #include <linux/hw_breakpoint.h> |
@@ -1456,7 +1456,7 @@ static int test_pmu(void) | |||
1456 | int ret; | 1456 | int ret; |
1457 | 1457 | ||
1458 | snprintf(path, PATH_MAX, "%s/bus/event_source/devices/cpu/format/", | 1458 | snprintf(path, PATH_MAX, "%s/bus/event_source/devices/cpu/format/", |
1459 | sysfs_find_mountpoint()); | 1459 | sysfs__mountpoint()); |
1460 | 1460 | ||
1461 | ret = stat(path, &st); | 1461 | ret = stat(path, &st); |
1462 | if (ret) | 1462 | if (ret) |
@@ -1473,7 +1473,7 @@ static int test_pmu_events(void) | |||
1473 | int ret; | 1473 | int ret; |
1474 | 1474 | ||
1475 | snprintf(path, PATH_MAX, "%s/bus/event_source/devices/cpu/events/", | 1475 | snprintf(path, PATH_MAX, "%s/bus/event_source/devices/cpu/events/", |
1476 | sysfs_find_mountpoint()); | 1476 | sysfs__mountpoint()); |
1477 | 1477 | ||
1478 | ret = stat(path, &st); | 1478 | ret = stat(path, &st); |
1479 | if (ret) { | 1479 | if (ret) { |
diff --git a/tools/perf/ui/browser.h b/tools/perf/ui/browser.h index 404ff66a3e36..7d45d2f53601 100644 --- a/tools/perf/ui/browser.h +++ b/tools/perf/ui/browser.h | |||
@@ -21,32 +21,32 @@ struct ui_browser { | |||
21 | void *priv; | 21 | void *priv; |
22 | const char *title; | 22 | const char *title; |
23 | char *helpline; | 23 | char *helpline; |
24 | unsigned int (*refresh)(struct ui_browser *self); | 24 | unsigned int (*refresh)(struct ui_browser *browser); |
25 | void (*write)(struct ui_browser *self, void *entry, int row); | 25 | void (*write)(struct ui_browser *browser, void *entry, int row); |
26 | void (*seek)(struct ui_browser *self, off_t offset, int whence); | 26 | void (*seek)(struct ui_browser *browser, off_t offset, int whence); |
27 | bool (*filter)(struct ui_browser *self, void *entry); | 27 | bool (*filter)(struct ui_browser *browser, void *entry); |
28 | u32 nr_entries; | 28 | u32 nr_entries; |
29 | bool navkeypressed; | 29 | bool navkeypressed; |
30 | bool use_navkeypressed; | 30 | bool use_navkeypressed; |
31 | }; | 31 | }; |
32 | 32 | ||
33 | int ui_browser__set_color(struct ui_browser *browser, int color); | 33 | int ui_browser__set_color(struct ui_browser *browser, int color); |
34 | void ui_browser__set_percent_color(struct ui_browser *self, | 34 | void ui_browser__set_percent_color(struct ui_browser *browser, |
35 | double percent, bool current); | 35 | double percent, bool current); |
36 | bool ui_browser__is_current_entry(struct ui_browser *self, unsigned row); | 36 | bool ui_browser__is_current_entry(struct ui_browser *browser, unsigned row); |
37 | void ui_browser__refresh_dimensions(struct ui_browser *self); | 37 | void ui_browser__refresh_dimensions(struct ui_browser *browser); |
38 | void ui_browser__reset_index(struct ui_browser *self); | 38 | void ui_browser__reset_index(struct ui_browser *browser); |
39 | 39 | ||
40 | void ui_browser__gotorc(struct ui_browser *self, int y, int x); | 40 | void ui_browser__gotorc(struct ui_browser *browser, int y, int x); |
41 | void ui_browser__write_graph(struct ui_browser *browser, int graph); | 41 | void ui_browser__write_graph(struct ui_browser *browser, int graph); |
42 | void __ui_browser__line_arrow(struct ui_browser *browser, unsigned int column, | 42 | void __ui_browser__line_arrow(struct ui_browser *browser, unsigned int column, |
43 | u64 start, u64 end); | 43 | u64 start, u64 end); |
44 | void __ui_browser__show_title(struct ui_browser *browser, const char *title); | 44 | void __ui_browser__show_title(struct ui_browser *browser, const char *title); |
45 | void ui_browser__show_title(struct ui_browser *browser, const char *title); | 45 | void ui_browser__show_title(struct ui_browser *browser, const char *title); |
46 | int ui_browser__show(struct ui_browser *self, const char *title, | 46 | int ui_browser__show(struct ui_browser *browser, const char *title, |
47 | const char *helpline, ...); | 47 | const char *helpline, ...); |
48 | void ui_browser__hide(struct ui_browser *self); | 48 | void ui_browser__hide(struct ui_browser *browser); |
49 | int ui_browser__refresh(struct ui_browser *self); | 49 | int ui_browser__refresh(struct ui_browser *browser); |
50 | int ui_browser__run(struct ui_browser *browser, int delay_secs); | 50 | int ui_browser__run(struct ui_browser *browser, int delay_secs); |
51 | void ui_browser__update_nr_entries(struct ui_browser *browser, u32 nr_entries); | 51 | void ui_browser__update_nr_entries(struct ui_browser *browser, u32 nr_entries); |
52 | void ui_browser__handle_resize(struct ui_browser *browser); | 52 | void ui_browser__handle_resize(struct ui_browser *browser); |
@@ -63,11 +63,11 @@ int ui_browser__input_window(const char *title, const char *text, char *input, | |||
63 | void ui_browser__argv_seek(struct ui_browser *browser, off_t offset, int whence); | 63 | void ui_browser__argv_seek(struct ui_browser *browser, off_t offset, int whence); |
64 | unsigned int ui_browser__argv_refresh(struct ui_browser *browser); | 64 | unsigned int ui_browser__argv_refresh(struct ui_browser *browser); |
65 | 65 | ||
66 | void ui_browser__rb_tree_seek(struct ui_browser *self, off_t offset, int whence); | 66 | void ui_browser__rb_tree_seek(struct ui_browser *browser, off_t offset, int whence); |
67 | unsigned int ui_browser__rb_tree_refresh(struct ui_browser *self); | 67 | unsigned int ui_browser__rb_tree_refresh(struct ui_browser *browser); |
68 | 68 | ||
69 | void ui_browser__list_head_seek(struct ui_browser *self, off_t offset, int whence); | 69 | void ui_browser__list_head_seek(struct ui_browser *browser, off_t offset, int whence); |
70 | unsigned int ui_browser__list_head_refresh(struct ui_browser *self); | 70 | unsigned int ui_browser__list_head_refresh(struct ui_browser *browser); |
71 | 71 | ||
72 | void ui_browser__init(void); | 72 | void ui_browser__init(void); |
73 | void annotate_browser__init(void); | 73 | void annotate_browser__init(void); |
diff --git a/tools/perf/ui/browsers/hists.c b/tools/perf/ui/browsers/hists.c index a91b6b219412..16848bb4c418 100644 --- a/tools/perf/ui/browsers/hists.c +++ b/tools/perf/ui/browsers/hists.c | |||
@@ -1889,7 +1889,7 @@ out: | |||
1889 | return key; | 1889 | return key; |
1890 | } | 1890 | } |
1891 | 1891 | ||
1892 | static bool filter_group_entries(struct ui_browser *self __maybe_unused, | 1892 | static bool filter_group_entries(struct ui_browser *browser __maybe_unused, |
1893 | void *entry) | 1893 | void *entry) |
1894 | { | 1894 | { |
1895 | struct perf_evsel *evsel = list_entry(entry, struct perf_evsel, node); | 1895 | struct perf_evsel *evsel = list_entry(entry, struct perf_evsel, node); |
diff --git a/tools/perf/ui/browsers/map.c b/tools/perf/ui/browsers/map.c index 95c7cfb8f2c6..b11639f33682 100644 --- a/tools/perf/ui/browsers/map.c +++ b/tools/perf/ui/browsers/map.c | |||
@@ -18,30 +18,30 @@ struct map_browser { | |||
18 | u8 addrlen; | 18 | u8 addrlen; |
19 | }; | 19 | }; |
20 | 20 | ||
21 | static void map_browser__write(struct ui_browser *self, void *nd, int row) | 21 | static void map_browser__write(struct ui_browser *browser, void *nd, int row) |
22 | { | 22 | { |
23 | struct symbol *sym = rb_entry(nd, struct symbol, rb_node); | 23 | struct symbol *sym = rb_entry(nd, struct symbol, rb_node); |
24 | struct map_browser *mb = container_of(self, struct map_browser, b); | 24 | struct map_browser *mb = container_of(browser, struct map_browser, b); |
25 | bool current_entry = ui_browser__is_current_entry(self, row); | 25 | bool current_entry = ui_browser__is_current_entry(browser, row); |
26 | int width; | 26 | int width; |
27 | 27 | ||
28 | ui_browser__set_percent_color(self, 0, current_entry); | 28 | ui_browser__set_percent_color(browser, 0, current_entry); |
29 | slsmg_printf("%*" PRIx64 " %*" PRIx64 " %c ", | 29 | slsmg_printf("%*" PRIx64 " %*" PRIx64 " %c ", |
30 | mb->addrlen, sym->start, mb->addrlen, sym->end, | 30 | mb->addrlen, sym->start, mb->addrlen, sym->end, |
31 | sym->binding == STB_GLOBAL ? 'g' : | 31 | sym->binding == STB_GLOBAL ? 'g' : |
32 | sym->binding == STB_LOCAL ? 'l' : 'w'); | 32 | sym->binding == STB_LOCAL ? 'l' : 'w'); |
33 | width = self->width - ((mb->addrlen * 2) + 4); | 33 | width = browser->width - ((mb->addrlen * 2) + 4); |
34 | if (width > 0) | 34 | if (width > 0) |
35 | slsmg_write_nstring(sym->name, width); | 35 | slsmg_write_nstring(sym->name, width); |
36 | } | 36 | } |
37 | 37 | ||
38 | /* FIXME uber-kludgy, see comment on cmd_report... */ | 38 | /* FIXME uber-kludgy, see comment on cmd_report... */ |
39 | static u32 *symbol__browser_index(struct symbol *self) | 39 | static u32 *symbol__browser_index(struct symbol *browser) |
40 | { | 40 | { |
41 | return ((void *)self) - sizeof(struct rb_node) - sizeof(u32); | 41 | return ((void *)browser) - sizeof(struct rb_node) - sizeof(u32); |
42 | } | 42 | } |
43 | 43 | ||
44 | static int map_browser__search(struct map_browser *self) | 44 | static int map_browser__search(struct map_browser *browser) |
45 | { | 45 | { |
46 | char target[512]; | 46 | char target[512]; |
47 | struct symbol *sym; | 47 | struct symbol *sym; |
@@ -53,37 +53,37 @@ static int map_browser__search(struct map_browser *self) | |||
53 | 53 | ||
54 | if (target[0] == '0' && tolower(target[1]) == 'x') { | 54 | if (target[0] == '0' && tolower(target[1]) == 'x') { |
55 | u64 addr = strtoull(target, NULL, 16); | 55 | u64 addr = strtoull(target, NULL, 16); |
56 | sym = map__find_symbol(self->map, addr, NULL); | 56 | sym = map__find_symbol(browser->map, addr, NULL); |
57 | } else | 57 | } else |
58 | sym = map__find_symbol_by_name(self->map, target, NULL); | 58 | sym = map__find_symbol_by_name(browser->map, target, NULL); |
59 | 59 | ||
60 | if (sym != NULL) { | 60 | if (sym != NULL) { |
61 | u32 *idx = symbol__browser_index(sym); | 61 | u32 *idx = symbol__browser_index(sym); |
62 | 62 | ||
63 | self->b.top = &sym->rb_node; | 63 | browser->b.top = &sym->rb_node; |
64 | self->b.index = self->b.top_idx = *idx; | 64 | browser->b.index = browser->b.top_idx = *idx; |
65 | } else | 65 | } else |
66 | ui_helpline__fpush("%s not found!", target); | 66 | ui_helpline__fpush("%s not found!", target); |
67 | 67 | ||
68 | return 0; | 68 | return 0; |
69 | } | 69 | } |
70 | 70 | ||
71 | static int map_browser__run(struct map_browser *self) | 71 | static int map_browser__run(struct map_browser *browser) |
72 | { | 72 | { |
73 | int key; | 73 | int key; |
74 | 74 | ||
75 | if (ui_browser__show(&self->b, self->map->dso->long_name, | 75 | if (ui_browser__show(&browser->b, browser->map->dso->long_name, |
76 | "Press <- or ESC to exit, %s / to search", | 76 | "Press <- or ESC to exit, %s / to search", |
77 | verbose ? "" : "restart with -v to use") < 0) | 77 | verbose ? "" : "restart with -v to use") < 0) |
78 | return -1; | 78 | return -1; |
79 | 79 | ||
80 | while (1) { | 80 | while (1) { |
81 | key = ui_browser__run(&self->b, 0); | 81 | key = ui_browser__run(&browser->b, 0); |
82 | 82 | ||
83 | switch (key) { | 83 | switch (key) { |
84 | case '/': | 84 | case '/': |
85 | if (verbose) | 85 | if (verbose) |
86 | map_browser__search(self); | 86 | map_browser__search(browser); |
87 | default: | 87 | default: |
88 | break; | 88 | break; |
89 | case K_LEFT: | 89 | case K_LEFT: |
@@ -94,20 +94,20 @@ static int map_browser__run(struct map_browser *self) | |||
94 | } | 94 | } |
95 | } | 95 | } |
96 | out: | 96 | out: |
97 | ui_browser__hide(&self->b); | 97 | ui_browser__hide(&browser->b); |
98 | return key; | 98 | return key; |
99 | } | 99 | } |
100 | 100 | ||
101 | int map__browse(struct map *self) | 101 | int map__browse(struct map *map) |
102 | { | 102 | { |
103 | struct map_browser mb = { | 103 | struct map_browser mb = { |
104 | .b = { | 104 | .b = { |
105 | .entries = &self->dso->symbols[self->type], | 105 | .entries = &map->dso->symbols[map->type], |
106 | .refresh = ui_browser__rb_tree_refresh, | 106 | .refresh = ui_browser__rb_tree_refresh, |
107 | .seek = ui_browser__rb_tree_seek, | 107 | .seek = ui_browser__rb_tree_seek, |
108 | .write = map_browser__write, | 108 | .write = map_browser__write, |
109 | }, | 109 | }, |
110 | .map = self, | 110 | .map = map, |
111 | }; | 111 | }; |
112 | struct rb_node *nd; | 112 | struct rb_node *nd; |
113 | char tmp[BITS_PER_LONG / 4]; | 113 | char tmp[BITS_PER_LONG / 4]; |
diff --git a/tools/perf/ui/browsers/map.h b/tools/perf/ui/browsers/map.h index df8581a43e17..2d58e4b3eb6f 100644 --- a/tools/perf/ui/browsers/map.h +++ b/tools/perf/ui/browsers/map.h | |||
@@ -2,5 +2,5 @@ | |||
2 | #define _PERF_UI_MAP_BROWSER_H_ 1 | 2 | #define _PERF_UI_MAP_BROWSER_H_ 1 |
3 | struct map; | 3 | struct map; |
4 | 4 | ||
5 | int map__browse(struct map *self); | 5 | int map__browse(struct map *map); |
6 | #endif /* _PERF_UI_MAP_BROWSER_H_ */ | 6 | #endif /* _PERF_UI_MAP_BROWSER_H_ */ |
diff --git a/tools/perf/ui/browsers/scripts.c b/tools/perf/ui/browsers/scripts.c index 12f009e61e94..d63c68ea02a8 100644 --- a/tools/perf/ui/browsers/scripts.c +++ b/tools/perf/ui/browsers/scripts.c | |||
@@ -84,22 +84,22 @@ static void script_browser__write(struct ui_browser *browser, | |||
84 | slsmg_write_nstring(sline->line, browser->width); | 84 | slsmg_write_nstring(sline->line, browser->width); |
85 | } | 85 | } |
86 | 86 | ||
87 | static int script_browser__run(struct perf_script_browser *self) | 87 | static int script_browser__run(struct perf_script_browser *browser) |
88 | { | 88 | { |
89 | int key; | 89 | int key; |
90 | 90 | ||
91 | if (ui_browser__show(&self->b, self->script_name, | 91 | if (ui_browser__show(&browser->b, browser->script_name, |
92 | "Press <- or ESC to exit") < 0) | 92 | "Press <- or ESC to exit") < 0) |
93 | return -1; | 93 | return -1; |
94 | 94 | ||
95 | while (1) { | 95 | while (1) { |
96 | key = ui_browser__run(&self->b, 0); | 96 | key = ui_browser__run(&browser->b, 0); |
97 | 97 | ||
98 | /* We can add some special key handling here if needed */ | 98 | /* We can add some special key handling here if needed */ |
99 | break; | 99 | break; |
100 | } | 100 | } |
101 | 101 | ||
102 | ui_browser__hide(&self->b); | 102 | ui_browser__hide(&browser->b); |
103 | return key; | 103 | return key; |
104 | } | 104 | } |
105 | 105 | ||
diff --git a/tools/perf/ui/stdio/hist.c b/tools/perf/ui/stdio/hist.c index 6c152686e837..c244cb524ef2 100644 --- a/tools/perf/ui/stdio/hist.c +++ b/tools/perf/ui/stdio/hist.c | |||
@@ -213,20 +213,19 @@ static size_t callchain__fprintf_graph(FILE *fp, struct rb_root *root, | |||
213 | return ret; | 213 | return ret; |
214 | } | 214 | } |
215 | 215 | ||
216 | static size_t __callchain__fprintf_flat(FILE *fp, | 216 | static size_t __callchain__fprintf_flat(FILE *fp, struct callchain_node *node, |
217 | struct callchain_node *self, | ||
218 | u64 total_samples) | 217 | u64 total_samples) |
219 | { | 218 | { |
220 | struct callchain_list *chain; | 219 | struct callchain_list *chain; |
221 | size_t ret = 0; | 220 | size_t ret = 0; |
222 | 221 | ||
223 | if (!self) | 222 | if (!node) |
224 | return 0; | 223 | return 0; |
225 | 224 | ||
226 | ret += __callchain__fprintf_flat(fp, self->parent, total_samples); | 225 | ret += __callchain__fprintf_flat(fp, node->parent, total_samples); |
227 | 226 | ||
228 | 227 | ||
229 | list_for_each_entry(chain, &self->val, list) { | 228 | list_for_each_entry(chain, &node->val, list) { |
230 | if (chain->ip >= PERF_CONTEXT_MAX) | 229 | if (chain->ip >= PERF_CONTEXT_MAX) |
231 | continue; | 230 | continue; |
232 | if (chain->ms.sym) | 231 | if (chain->ms.sym) |
@@ -239,15 +238,14 @@ static size_t __callchain__fprintf_flat(FILE *fp, | |||
239 | return ret; | 238 | return ret; |
240 | } | 239 | } |
241 | 240 | ||
242 | static size_t callchain__fprintf_flat(FILE *fp, struct rb_root *self, | 241 | static size_t callchain__fprintf_flat(FILE *fp, struct rb_root *tree, |
243 | u64 total_samples) | 242 | u64 total_samples) |
244 | { | 243 | { |
245 | size_t ret = 0; | 244 | size_t ret = 0; |
246 | u32 entries_printed = 0; | 245 | u32 entries_printed = 0; |
247 | struct rb_node *rb_node; | ||
248 | struct callchain_node *chain; | 246 | struct callchain_node *chain; |
247 | struct rb_node *rb_node = rb_first(tree); | ||
249 | 248 | ||
250 | rb_node = rb_first(self); | ||
251 | while (rb_node) { | 249 | while (rb_node) { |
252 | double percent; | 250 | double percent; |
253 | 251 | ||
diff --git a/tools/perf/util/build-id.h b/tools/perf/util/build-id.h index a811f5c62e18..929f28a7c14d 100644 --- a/tools/perf/util/build-id.h +++ b/tools/perf/util/build-id.h | |||
@@ -10,10 +10,9 @@ extern struct perf_tool build_id__mark_dso_hit_ops; | |||
10 | struct dso; | 10 | struct dso; |
11 | 11 | ||
12 | int build_id__sprintf(const u8 *build_id, int len, char *bf); | 12 | int build_id__sprintf(const u8 *build_id, int len, char *bf); |
13 | char *dso__build_id_filename(struct dso *self, char *bf, size_t size); | 13 | char *dso__build_id_filename(struct dso *dso, char *bf, size_t size); |
14 | 14 | ||
15 | int build_id__mark_dso_hit(struct perf_tool *tool, union perf_event *event, | 15 | int build_id__mark_dso_hit(struct perf_tool *tool, union perf_event *event, |
16 | struct perf_sample *sample, struct perf_evsel *evsel, | 16 | struct perf_sample *sample, struct perf_evsel *evsel, |
17 | struct machine *machine); | 17 | struct machine *machine); |
18 | |||
19 | #endif | 18 | #endif |
diff --git a/tools/perf/util/cpumap.c b/tools/perf/util/cpumap.c index beb8cf9f9976..a9b48c42e81e 100644 --- a/tools/perf/util/cpumap.c +++ b/tools/perf/util/cpumap.c | |||
@@ -1,5 +1,5 @@ | |||
1 | #include "util.h" | 1 | #include "util.h" |
2 | #include "sysfs.h" | 2 | #include "fs.h" |
3 | #include "../perf.h" | 3 | #include "../perf.h" |
4 | #include "cpumap.h" | 4 | #include "cpumap.h" |
5 | #include <assert.h> | 5 | #include <assert.h> |
@@ -216,7 +216,7 @@ int cpu_map__get_socket(struct cpu_map *map, int idx) | |||
216 | 216 | ||
217 | cpu = map->map[idx]; | 217 | cpu = map->map[idx]; |
218 | 218 | ||
219 | mnt = sysfs_find_mountpoint(); | 219 | mnt = sysfs__mountpoint(); |
220 | if (!mnt) | 220 | if (!mnt) |
221 | return -1; | 221 | return -1; |
222 | 222 | ||
@@ -279,7 +279,7 @@ int cpu_map__get_core(struct cpu_map *map, int idx) | |||
279 | 279 | ||
280 | cpu = map->map[idx]; | 280 | cpu = map->map[idx]; |
281 | 281 | ||
282 | mnt = sysfs_find_mountpoint(); | 282 | mnt = sysfs__mountpoint(); |
283 | if (!mnt) | 283 | if (!mnt) |
284 | return -1; | 284 | return -1; |
285 | 285 | ||
diff --git a/tools/perf/util/event.c b/tools/perf/util/event.c index c26b3539187b..ec9ae1114ed4 100644 --- a/tools/perf/util/event.c +++ b/tools/perf/util/event.c | |||
@@ -617,15 +617,15 @@ int perf_event__process(struct perf_tool *tool __maybe_unused, | |||
617 | return machine__process_event(machine, event, sample); | 617 | return machine__process_event(machine, event, sample); |
618 | } | 618 | } |
619 | 619 | ||
620 | void thread__find_addr_map(struct thread *self, | 620 | void thread__find_addr_map(struct thread *thread, |
621 | struct machine *machine, u8 cpumode, | 621 | struct machine *machine, u8 cpumode, |
622 | enum map_type type, u64 addr, | 622 | enum map_type type, u64 addr, |
623 | struct addr_location *al) | 623 | struct addr_location *al) |
624 | { | 624 | { |
625 | struct map_groups *mg = &self->mg; | 625 | struct map_groups *mg = &thread->mg; |
626 | bool load_map = false; | 626 | bool load_map = false; |
627 | 627 | ||
628 | al->thread = self; | 628 | al->thread = thread; |
629 | al->addr = addr; | 629 | al->addr = addr; |
630 | al->cpumode = cpumode; | 630 | al->cpumode = cpumode; |
631 | al->filtered = false; | 631 | al->filtered = false; |
diff --git a/tools/perf/util/event.h b/tools/perf/util/event.h index 752709ccfb00..f8d70f3003ab 100644 --- a/tools/perf/util/event.h +++ b/tools/perf/util/event.h | |||
@@ -251,7 +251,8 @@ int perf_event__process(struct perf_tool *tool, | |||
251 | struct machine *machine); | 251 | struct machine *machine); |
252 | 252 | ||
253 | struct addr_location; | 253 | struct addr_location; |
254 | int perf_event__preprocess_sample(const union perf_event *self, | 254 | |
255 | int perf_event__preprocess_sample(const union perf_event *event, | ||
255 | struct machine *machine, | 256 | struct machine *machine, |
256 | struct addr_location *al, | 257 | struct addr_location *al, |
257 | struct perf_sample *sample); | 258 | struct perf_sample *sample); |
diff --git a/tools/perf/util/evlist.h b/tools/perf/util/evlist.h index 6e8acc9abe38..e99eaed92682 100644 --- a/tools/perf/util/evlist.h +++ b/tools/perf/util/evlist.h | |||
@@ -88,7 +88,7 @@ struct perf_evsel *perf_evlist__id2evsel(struct perf_evlist *evlist, u64 id); | |||
88 | 88 | ||
89 | struct perf_sample_id *perf_evlist__id2sid(struct perf_evlist *evlist, u64 id); | 89 | struct perf_sample_id *perf_evlist__id2sid(struct perf_evlist *evlist, u64 id); |
90 | 90 | ||
91 | union perf_event *perf_evlist__mmap_read(struct perf_evlist *self, int idx); | 91 | union perf_event *perf_evlist__mmap_read(struct perf_evlist *evlist, int idx); |
92 | 92 | ||
93 | void perf_evlist__mmap_consume(struct perf_evlist *evlist, int idx); | 93 | void perf_evlist__mmap_consume(struct perf_evlist *evlist, int idx); |
94 | 94 | ||
@@ -99,6 +99,7 @@ void perf_evlist__set_id_pos(struct perf_evlist *evlist); | |||
99 | bool perf_can_sample_identifier(void); | 99 | bool perf_can_sample_identifier(void); |
100 | void perf_evlist__config(struct perf_evlist *evlist, | 100 | void perf_evlist__config(struct perf_evlist *evlist, |
101 | struct perf_record_opts *opts); | 101 | struct perf_record_opts *opts); |
102 | int perf_record_opts__config(struct perf_record_opts *opts); | ||
102 | 103 | ||
103 | int perf_evlist__prepare_workload(struct perf_evlist *evlist, | 104 | int perf_evlist__prepare_workload(struct perf_evlist *evlist, |
104 | struct perf_target *target, | 105 | struct perf_target *target, |
diff --git a/tools/perf/util/fs.c b/tools/perf/util/fs.c new file mode 100644 index 000000000000..f5be1f26e724 --- /dev/null +++ b/tools/perf/util/fs.c | |||
@@ -0,0 +1,119 @@ | |||
1 | |||
2 | /* TODO merge/factor into tools/lib/lk/debugfs.c */ | ||
3 | |||
4 | #include "util.h" | ||
5 | #include "util/fs.h" | ||
6 | |||
7 | static const char * const sysfs__fs_known_mountpoints[] = { | ||
8 | "/sys", | ||
9 | 0, | ||
10 | }; | ||
11 | |||
12 | static const char * const procfs__known_mountpoints[] = { | ||
13 | "/proc", | ||
14 | 0, | ||
15 | }; | ||
16 | |||
17 | struct fs { | ||
18 | const char *name; | ||
19 | const char * const *mounts; | ||
20 | char path[PATH_MAX + 1]; | ||
21 | bool found; | ||
22 | long magic; | ||
23 | }; | ||
24 | |||
25 | enum { | ||
26 | FS__SYSFS = 0, | ||
27 | FS__PROCFS = 1, | ||
28 | }; | ||
29 | |||
30 | static struct fs fs__entries[] = { | ||
31 | [FS__SYSFS] = { | ||
32 | .name = "sysfs", | ||
33 | .mounts = sysfs__fs_known_mountpoints, | ||
34 | .magic = SYSFS_MAGIC, | ||
35 | }, | ||
36 | [FS__PROCFS] = { | ||
37 | .name = "proc", | ||
38 | .mounts = procfs__known_mountpoints, | ||
39 | .magic = PROC_SUPER_MAGIC, | ||
40 | }, | ||
41 | }; | ||
42 | |||
43 | static bool fs__read_mounts(struct fs *fs) | ||
44 | { | ||
45 | bool found = false; | ||
46 | char type[100]; | ||
47 | FILE *fp; | ||
48 | |||
49 | fp = fopen("/proc/mounts", "r"); | ||
50 | if (fp == NULL) | ||
51 | return NULL; | ||
52 | |||
53 | while (!found && | ||
54 | fscanf(fp, "%*s %" STR(PATH_MAX) "s %99s %*s %*d %*d\n", | ||
55 | fs->path, type) == 2) { | ||
56 | |||
57 | if (strcmp(type, fs->name) == 0) | ||
58 | found = true; | ||
59 | } | ||
60 | |||
61 | fclose(fp); | ||
62 | return fs->found = found; | ||
63 | } | ||
64 | |||
65 | static int fs__valid_mount(const char *fs, long magic) | ||
66 | { | ||
67 | struct statfs st_fs; | ||
68 | |||
69 | if (statfs(fs, &st_fs) < 0) | ||
70 | return -ENOENT; | ||
71 | else if (st_fs.f_type != magic) | ||
72 | return -ENOENT; | ||
73 | |||
74 | return 0; | ||
75 | } | ||
76 | |||
77 | static bool fs__check_mounts(struct fs *fs) | ||
78 | { | ||
79 | const char * const *ptr; | ||
80 | |||
81 | ptr = fs->mounts; | ||
82 | while (*ptr) { | ||
83 | if (fs__valid_mount(*ptr, fs->magic) == 0) { | ||
84 | fs->found = true; | ||
85 | strcpy(fs->path, *ptr); | ||
86 | return true; | ||
87 | } | ||
88 | ptr++; | ||
89 | } | ||
90 | |||
91 | return false; | ||
92 | } | ||
93 | |||
94 | static const char *fs__get_mountpoint(struct fs *fs) | ||
95 | { | ||
96 | if (fs__check_mounts(fs)) | ||
97 | return fs->path; | ||
98 | |||
99 | return fs__read_mounts(fs) ? fs->path : NULL; | ||
100 | } | ||
101 | |||
102 | static const char *fs__mountpoint(int idx) | ||
103 | { | ||
104 | struct fs *fs = &fs__entries[idx]; | ||
105 | |||
106 | if (fs->found) | ||
107 | return (const char *)fs->path; | ||
108 | |||
109 | return fs__get_mountpoint(fs); | ||
110 | } | ||
111 | |||
112 | #define FS__MOUNTPOINT(name, idx) \ | ||
113 | const char *name##__mountpoint(void) \ | ||
114 | { \ | ||
115 | return fs__mountpoint(idx); \ | ||
116 | } | ||
117 | |||
118 | FS__MOUNTPOINT(sysfs, FS__SYSFS); | ||
119 | FS__MOUNTPOINT(procfs, FS__PROCFS); | ||
diff --git a/tools/perf/util/fs.h b/tools/perf/util/fs.h new file mode 100644 index 000000000000..5e09ce1bab0e --- /dev/null +++ b/tools/perf/util/fs.h | |||
@@ -0,0 +1,7 @@ | |||
1 | #ifndef __PERF_FS | ||
2 | #define __PERF_FS | ||
3 | |||
4 | const char *sysfs__mountpoint(void); | ||
5 | const char *procfs__mountpoint(void); | ||
6 | |||
7 | #endif /* __PERF_FS */ | ||
diff --git a/tools/perf/util/hist.c b/tools/perf/util/hist.c index 30793f98c8bb..822903eaa201 100644 --- a/tools/perf/util/hist.c +++ b/tools/perf/util/hist.c | |||
@@ -407,73 +407,12 @@ out: | |||
407 | return he; | 407 | return he; |
408 | } | 408 | } |
409 | 409 | ||
410 | struct hist_entry *__hists__add_mem_entry(struct hists *hists, | ||
411 | struct addr_location *al, | ||
412 | struct symbol *sym_parent, | ||
413 | struct mem_info *mi, | ||
414 | u64 period, | ||
415 | u64 weight) | ||
416 | { | ||
417 | struct hist_entry entry = { | ||
418 | .thread = al->thread, | ||
419 | .comm = thread__comm(al->thread), | ||
420 | .ms = { | ||
421 | .map = al->map, | ||
422 | .sym = al->sym, | ||
423 | }, | ||
424 | .stat = { | ||
425 | .period = period, | ||
426 | .weight = weight, | ||
427 | .nr_events = 1, | ||
428 | }, | ||
429 | .cpu = al->cpu, | ||
430 | .ip = al->addr, | ||
431 | .level = al->level, | ||
432 | .parent = sym_parent, | ||
433 | .filtered = symbol__parent_filter(sym_parent), | ||
434 | .hists = hists, | ||
435 | .mem_info = mi, | ||
436 | .branch_info = NULL, | ||
437 | }; | ||
438 | return add_hist_entry(hists, &entry, al, period, weight); | ||
439 | } | ||
440 | |||
441 | struct hist_entry *__hists__add_branch_entry(struct hists *hists, | ||
442 | struct addr_location *al, | ||
443 | struct symbol *sym_parent, | ||
444 | struct branch_info *bi, | ||
445 | u64 period, | ||
446 | u64 weight) | ||
447 | { | ||
448 | struct hist_entry entry = { | ||
449 | .thread = al->thread, | ||
450 | .comm = thread__comm(al->thread), | ||
451 | .ms = { | ||
452 | .map = bi->to.map, | ||
453 | .sym = bi->to.sym, | ||
454 | }, | ||
455 | .cpu = al->cpu, | ||
456 | .ip = bi->to.addr, | ||
457 | .level = al->level, | ||
458 | .stat = { | ||
459 | .period = period, | ||
460 | .nr_events = 1, | ||
461 | .weight = weight, | ||
462 | }, | ||
463 | .parent = sym_parent, | ||
464 | .filtered = symbol__parent_filter(sym_parent), | ||
465 | .branch_info = bi, | ||
466 | .hists = hists, | ||
467 | .mem_info = NULL, | ||
468 | }; | ||
469 | |||
470 | return add_hist_entry(hists, &entry, al, period, weight); | ||
471 | } | ||
472 | |||
473 | struct hist_entry *__hists__add_entry(struct hists *hists, | 410 | struct hist_entry *__hists__add_entry(struct hists *hists, |
474 | struct addr_location *al, | 411 | struct addr_location *al, |
475 | struct symbol *sym_parent, u64 period, | 412 | struct symbol *sym_parent, |
476 | u64 weight, u64 transaction) | 413 | struct branch_info *bi, |
414 | struct mem_info *mi, | ||
415 | u64 period, u64 weight, u64 transaction) | ||
477 | { | 416 | { |
478 | struct hist_entry entry = { | 417 | struct hist_entry entry = { |
479 | .thread = al->thread, | 418 | .thread = al->thread, |
@@ -486,15 +425,15 @@ struct hist_entry *__hists__add_entry(struct hists *hists, | |||
486 | .ip = al->addr, | 425 | .ip = al->addr, |
487 | .level = al->level, | 426 | .level = al->level, |
488 | .stat = { | 427 | .stat = { |
489 | .period = period, | ||
490 | .nr_events = 1, | 428 | .nr_events = 1, |
429 | .period = period, | ||
491 | .weight = weight, | 430 | .weight = weight, |
492 | }, | 431 | }, |
493 | .parent = sym_parent, | 432 | .parent = sym_parent, |
494 | .filtered = symbol__parent_filter(sym_parent), | 433 | .filtered = symbol__parent_filter(sym_parent), |
495 | .hists = hists, | 434 | .hists = hists, |
496 | .branch_info = NULL, | 435 | .branch_info = bi, |
497 | .mem_info = NULL, | 436 | .mem_info = mi, |
498 | .transaction = transaction, | 437 | .transaction = transaction, |
499 | }; | 438 | }; |
500 | 439 | ||
diff --git a/tools/perf/util/hist.h b/tools/perf/util/hist.h index 9d2d022cdb79..b621347a1585 100644 --- a/tools/perf/util/hist.h +++ b/tools/perf/util/hist.h | |||
@@ -84,55 +84,43 @@ struct hists { | |||
84 | u16 col_len[HISTC_NR_COLS]; | 84 | u16 col_len[HISTC_NR_COLS]; |
85 | }; | 85 | }; |
86 | 86 | ||
87 | struct hist_entry *__hists__add_entry(struct hists *self, | 87 | struct hist_entry *__hists__add_entry(struct hists *hists, |
88 | struct addr_location *al, | 88 | struct addr_location *al, |
89 | struct symbol *parent, u64 period, | 89 | struct symbol *parent, |
90 | struct branch_info *bi, | ||
91 | struct mem_info *mi, u64 period, | ||
90 | u64 weight, u64 transaction); | 92 | u64 weight, u64 transaction); |
91 | int64_t hist_entry__cmp(struct hist_entry *left, struct hist_entry *right); | 93 | int64_t hist_entry__cmp(struct hist_entry *left, struct hist_entry *right); |
92 | int64_t hist_entry__collapse(struct hist_entry *left, struct hist_entry *right); | 94 | int64_t hist_entry__collapse(struct hist_entry *left, struct hist_entry *right); |
93 | int hist_entry__transaction_len(void); | 95 | int hist_entry__transaction_len(void); |
94 | int hist_entry__sort_snprintf(struct hist_entry *self, char *bf, size_t size, | 96 | int hist_entry__sort_snprintf(struct hist_entry *he, char *bf, size_t size, |
95 | struct hists *hists); | 97 | struct hists *hists); |
96 | void hist_entry__free(struct hist_entry *); | 98 | void hist_entry__free(struct hist_entry *); |
97 | 99 | ||
98 | struct hist_entry *__hists__add_branch_entry(struct hists *self, | 100 | void hists__output_resort(struct hists *hists); |
99 | struct addr_location *al, | 101 | void hists__collapse_resort(struct hists *hists, struct ui_progress *prog); |
100 | struct symbol *sym_parent, | ||
101 | struct branch_info *bi, | ||
102 | u64 period, | ||
103 | u64 weight); | ||
104 | |||
105 | struct hist_entry *__hists__add_mem_entry(struct hists *self, | ||
106 | struct addr_location *al, | ||
107 | struct symbol *sym_parent, | ||
108 | struct mem_info *mi, | ||
109 | u64 period, | ||
110 | u64 weight); | ||
111 | |||
112 | void hists__output_resort(struct hists *self); | ||
113 | void hists__collapse_resort(struct hists *self, struct ui_progress *prog); | ||
114 | 102 | ||
115 | void hists__decay_entries(struct hists *hists, bool zap_user, bool zap_kernel); | 103 | void hists__decay_entries(struct hists *hists, bool zap_user, bool zap_kernel); |
116 | void hists__output_recalc_col_len(struct hists *hists, int max_rows); | 104 | void hists__output_recalc_col_len(struct hists *hists, int max_rows); |
117 | 105 | ||
118 | void hists__inc_nr_entries(struct hists *hists, struct hist_entry *h); | 106 | void hists__inc_nr_entries(struct hists *hists, struct hist_entry *h); |
119 | void hists__inc_nr_events(struct hists *self, u32 type); | 107 | void hists__inc_nr_events(struct hists *hists, u32 type); |
120 | void events_stats__inc(struct events_stats *stats, u32 type); | 108 | void events_stats__inc(struct events_stats *stats, u32 type); |
121 | size_t events_stats__fprintf(struct events_stats *stats, FILE *fp); | 109 | size_t events_stats__fprintf(struct events_stats *stats, FILE *fp); |
122 | 110 | ||
123 | size_t hists__fprintf(struct hists *self, bool show_header, int max_rows, | 111 | size_t hists__fprintf(struct hists *hists, bool show_header, int max_rows, |
124 | int max_cols, float min_pcnt, FILE *fp); | 112 | int max_cols, float min_pcnt, FILE *fp); |
125 | 113 | ||
126 | int hist_entry__inc_addr_samples(struct hist_entry *self, int evidx, u64 addr); | 114 | int hist_entry__inc_addr_samples(struct hist_entry *he, int evidx, u64 addr); |
127 | int hist_entry__annotate(struct hist_entry *self, size_t privsize); | 115 | int hist_entry__annotate(struct hist_entry *he, size_t privsize); |
128 | 116 | ||
129 | void hists__filter_by_dso(struct hists *hists); | 117 | void hists__filter_by_dso(struct hists *hists); |
130 | void hists__filter_by_thread(struct hists *hists); | 118 | void hists__filter_by_thread(struct hists *hists); |
131 | void hists__filter_by_symbol(struct hists *hists); | 119 | void hists__filter_by_symbol(struct hists *hists); |
132 | 120 | ||
133 | u16 hists__col_len(struct hists *self, enum hist_column col); | 121 | u16 hists__col_len(struct hists *hists, enum hist_column col); |
134 | void hists__set_col_len(struct hists *self, enum hist_column col, u16 len); | 122 | void hists__set_col_len(struct hists *hists, enum hist_column col, u16 len); |
135 | bool hists__new_col_len(struct hists *self, enum hist_column col, u16 len); | 123 | bool hists__new_col_len(struct hists *hists, enum hist_column col, u16 len); |
136 | void hists__reset_col_len(struct hists *hists); | 124 | void hists__reset_col_len(struct hists *hists); |
137 | void hists__calc_col_len(struct hists *hists, struct hist_entry *he); | 125 | void hists__calc_col_len(struct hists *hists, struct hist_entry *he); |
138 | 126 | ||
@@ -222,12 +210,9 @@ int perf_evlist__tui_browse_hists(struct perf_evlist *evlist __maybe_unused, | |||
222 | return 0; | 210 | return 0; |
223 | } | 211 | } |
224 | 212 | ||
225 | static inline int hist_entry__tui_annotate(struct hist_entry *self | 213 | static inline int hist_entry__tui_annotate(struct hist_entry *he __maybe_unused, |
226 | __maybe_unused, | 214 | struct perf_evsel *evsel __maybe_unused, |
227 | struct perf_evsel *evsel | 215 | struct hist_browser_timer *hbt __maybe_unused) |
228 | __maybe_unused, | ||
229 | struct hist_browser_timer *hbt | ||
230 | __maybe_unused) | ||
231 | { | 216 | { |
232 | return 0; | 217 | return 0; |
233 | } | 218 | } |
@@ -242,5 +227,5 @@ static inline int script_browse(const char *script_opt __maybe_unused) | |||
242 | #define K_SWITCH_INPUT_DATA -3000 | 227 | #define K_SWITCH_INPUT_DATA -3000 |
243 | #endif | 228 | #endif |
244 | 229 | ||
245 | unsigned int hists__sort_list_width(struct hists *self); | 230 | unsigned int hists__sort_list_width(struct hists *hists); |
246 | #endif /* __PERF_HIST_H */ | 231 | #endif /* __PERF_HIST_H */ |
diff --git a/tools/perf/util/include/linux/magic.h b/tools/perf/util/include/linux/magic.h index 58b64ed4da12..07d63cf3e0f6 100644 --- a/tools/perf/util/include/linux/magic.h +++ b/tools/perf/util/include/linux/magic.h | |||
@@ -9,4 +9,8 @@ | |||
9 | #define SYSFS_MAGIC 0x62656572 | 9 | #define SYSFS_MAGIC 0x62656572 |
10 | #endif | 10 | #endif |
11 | 11 | ||
12 | #ifndef PROC_SUPER_MAGIC | ||
13 | #define PROC_SUPER_MAGIC 0x9fa0 | ||
14 | #endif | ||
15 | |||
12 | #endif | 16 | #endif |
diff --git a/tools/perf/util/pmu.c b/tools/perf/util/pmu.c index 64362fe45b71..c232d8dd410b 100644 --- a/tools/perf/util/pmu.c +++ b/tools/perf/util/pmu.c | |||
@@ -4,7 +4,7 @@ | |||
4 | #include <unistd.h> | 4 | #include <unistd.h> |
5 | #include <stdio.h> | 5 | #include <stdio.h> |
6 | #include <dirent.h> | 6 | #include <dirent.h> |
7 | #include "sysfs.h" | 7 | #include "fs.h" |
8 | #include "util.h" | 8 | #include "util.h" |
9 | #include "pmu.h" | 9 | #include "pmu.h" |
10 | #include "parse-events.h" | 10 | #include "parse-events.h" |
@@ -77,9 +77,8 @@ static int pmu_format(const char *name, struct list_head *format) | |||
77 | { | 77 | { |
78 | struct stat st; | 78 | struct stat st; |
79 | char path[PATH_MAX]; | 79 | char path[PATH_MAX]; |
80 | const char *sysfs; | 80 | const char *sysfs = sysfs__mountpoint(); |
81 | 81 | ||
82 | sysfs = sysfs_find_mountpoint(); | ||
83 | if (!sysfs) | 82 | if (!sysfs) |
84 | return -1; | 83 | return -1; |
85 | 84 | ||
@@ -166,9 +165,8 @@ static int pmu_aliases(const char *name, struct list_head *head) | |||
166 | { | 165 | { |
167 | struct stat st; | 166 | struct stat st; |
168 | char path[PATH_MAX]; | 167 | char path[PATH_MAX]; |
169 | const char *sysfs; | 168 | const char *sysfs = sysfs__mountpoint(); |
170 | 169 | ||
171 | sysfs = sysfs_find_mountpoint(); | ||
172 | if (!sysfs) | 170 | if (!sysfs) |
173 | return -1; | 171 | return -1; |
174 | 172 | ||
@@ -212,11 +210,10 @@ static int pmu_type(const char *name, __u32 *type) | |||
212 | { | 210 | { |
213 | struct stat st; | 211 | struct stat st; |
214 | char path[PATH_MAX]; | 212 | char path[PATH_MAX]; |
215 | const char *sysfs; | ||
216 | FILE *file; | 213 | FILE *file; |
217 | int ret = 0; | 214 | int ret = 0; |
215 | const char *sysfs = sysfs__mountpoint(); | ||
218 | 216 | ||
219 | sysfs = sysfs_find_mountpoint(); | ||
220 | if (!sysfs) | 217 | if (!sysfs) |
221 | return -1; | 218 | return -1; |
222 | 219 | ||
@@ -241,11 +238,10 @@ static int pmu_type(const char *name, __u32 *type) | |||
241 | static void pmu_read_sysfs(void) | 238 | static void pmu_read_sysfs(void) |
242 | { | 239 | { |
243 | char path[PATH_MAX]; | 240 | char path[PATH_MAX]; |
244 | const char *sysfs; | ||
245 | DIR *dir; | 241 | DIR *dir; |
246 | struct dirent *dent; | 242 | struct dirent *dent; |
243 | const char *sysfs = sysfs__mountpoint(); | ||
247 | 244 | ||
248 | sysfs = sysfs_find_mountpoint(); | ||
249 | if (!sysfs) | 245 | if (!sysfs) |
250 | return; | 246 | return; |
251 | 247 | ||
@@ -270,11 +266,10 @@ static struct cpu_map *pmu_cpumask(const char *name) | |||
270 | { | 266 | { |
271 | struct stat st; | 267 | struct stat st; |
272 | char path[PATH_MAX]; | 268 | char path[PATH_MAX]; |
273 | const char *sysfs; | ||
274 | FILE *file; | 269 | FILE *file; |
275 | struct cpu_map *cpus; | 270 | struct cpu_map *cpus; |
271 | const char *sysfs = sysfs__mountpoint(); | ||
276 | 272 | ||
277 | sysfs = sysfs_find_mountpoint(); | ||
278 | if (!sysfs) | 273 | if (!sysfs) |
279 | return NULL; | 274 | return NULL; |
280 | 275 | ||
diff --git a/tools/perf/util/probe-finder.c b/tools/perf/util/probe-finder.c index 2200dad4c3f4..ffb657ffd327 100644 --- a/tools/perf/util/probe-finder.c +++ b/tools/perf/util/probe-finder.c | |||
@@ -115,7 +115,7 @@ static const Dwfl_Callbacks offline_callbacks = { | |||
115 | }; | 115 | }; |
116 | 116 | ||
117 | /* Get a Dwarf from offline image */ | 117 | /* Get a Dwarf from offline image */ |
118 | static int debuginfo__init_offline_dwarf(struct debuginfo *self, | 118 | static int debuginfo__init_offline_dwarf(struct debuginfo *dbg, |
119 | const char *path) | 119 | const char *path) |
120 | { | 120 | { |
121 | int fd; | 121 | int fd; |
@@ -124,25 +124,25 @@ static int debuginfo__init_offline_dwarf(struct debuginfo *self, | |||
124 | if (fd < 0) | 124 | if (fd < 0) |
125 | return fd; | 125 | return fd; |
126 | 126 | ||
127 | self->dwfl = dwfl_begin(&offline_callbacks); | 127 | dbg->dwfl = dwfl_begin(&offline_callbacks); |
128 | if (!self->dwfl) | 128 | if (!dbg->dwfl) |
129 | goto error; | 129 | goto error; |
130 | 130 | ||
131 | self->mod = dwfl_report_offline(self->dwfl, "", "", fd); | 131 | dbg->mod = dwfl_report_offline(dbg->dwfl, "", "", fd); |
132 | if (!self->mod) | 132 | if (!dbg->mod) |
133 | goto error; | 133 | goto error; |
134 | 134 | ||
135 | self->dbg = dwfl_module_getdwarf(self->mod, &self->bias); | 135 | dbg->dbg = dwfl_module_getdwarf(dbg->mod, &dbg->bias); |
136 | if (!self->dbg) | 136 | if (!dbg->dbg) |
137 | goto error; | 137 | goto error; |
138 | 138 | ||
139 | return 0; | 139 | return 0; |
140 | error: | 140 | error: |
141 | if (self->dwfl) | 141 | if (dbg->dwfl) |
142 | dwfl_end(self->dwfl); | 142 | dwfl_end(dbg->dwfl); |
143 | else | 143 | else |
144 | close(fd); | 144 | close(fd); |
145 | memset(self, 0, sizeof(*self)); | 145 | memset(dbg, 0, sizeof(*dbg)); |
146 | 146 | ||
147 | return -ENOENT; | 147 | return -ENOENT; |
148 | } | 148 | } |
@@ -180,24 +180,24 @@ static const Dwfl_Callbacks kernel_callbacks = { | |||
180 | }; | 180 | }; |
181 | 181 | ||
182 | /* Get a Dwarf from live kernel image */ | 182 | /* Get a Dwarf from live kernel image */ |
183 | static int debuginfo__init_online_kernel_dwarf(struct debuginfo *self, | 183 | static int debuginfo__init_online_kernel_dwarf(struct debuginfo *dbg, |
184 | Dwarf_Addr addr) | 184 | Dwarf_Addr addr) |
185 | { | 185 | { |
186 | self->dwfl = dwfl_begin(&kernel_callbacks); | 186 | dbg->dwfl = dwfl_begin(&kernel_callbacks); |
187 | if (!self->dwfl) | 187 | if (!dbg->dwfl) |
188 | return -EINVAL; | 188 | return -EINVAL; |
189 | 189 | ||
190 | /* Load the kernel dwarves: Don't care the result here */ | 190 | /* Load the kernel dwarves: Don't care the result here */ |
191 | dwfl_linux_kernel_report_kernel(self->dwfl); | 191 | dwfl_linux_kernel_report_kernel(dbg->dwfl); |
192 | dwfl_linux_kernel_report_modules(self->dwfl); | 192 | dwfl_linux_kernel_report_modules(dbg->dwfl); |
193 | 193 | ||
194 | self->dbg = dwfl_addrdwarf(self->dwfl, addr, &self->bias); | 194 | dbg->dbg = dwfl_addrdwarf(dbg->dwfl, addr, &dbg->bias); |
195 | /* Here, check whether we could get a real dwarf */ | 195 | /* Here, check whether we could get a real dwarf */ |
196 | if (!self->dbg) { | 196 | if (!dbg->dbg) { |
197 | pr_debug("Failed to find kernel dwarf at %lx\n", | 197 | pr_debug("Failed to find kernel dwarf at %lx\n", |
198 | (unsigned long)addr); | 198 | (unsigned long)addr); |
199 | dwfl_end(self->dwfl); | 199 | dwfl_end(dbg->dwfl); |
200 | memset(self, 0, sizeof(*self)); | 200 | memset(dbg, 0, sizeof(*dbg)); |
201 | return -ENOENT; | 201 | return -ENOENT; |
202 | } | 202 | } |
203 | 203 | ||
@@ -205,7 +205,7 @@ static int debuginfo__init_online_kernel_dwarf(struct debuginfo *self, | |||
205 | } | 205 | } |
206 | #else | 206 | #else |
207 | /* With older elfutils, this just support kernel module... */ | 207 | /* With older elfutils, this just support kernel module... */ |
208 | static int debuginfo__init_online_kernel_dwarf(struct debuginfo *self, | 208 | static int debuginfo__init_online_kernel_dwarf(struct debuginfo *dbg, |
209 | Dwarf_Addr addr __maybe_unused) | 209 | Dwarf_Addr addr __maybe_unused) |
210 | { | 210 | { |
211 | const char *path = kernel_get_module_path("kernel"); | 211 | const char *path = kernel_get_module_path("kernel"); |
@@ -216,44 +216,45 @@ static int debuginfo__init_online_kernel_dwarf(struct debuginfo *self, | |||
216 | } | 216 | } |
217 | 217 | ||
218 | pr_debug2("Use file %s for debuginfo\n", path); | 218 | pr_debug2("Use file %s for debuginfo\n", path); |
219 | return debuginfo__init_offline_dwarf(self, path); | 219 | return debuginfo__init_offline_dwarf(dbg, path); |
220 | } | 220 | } |
221 | #endif | 221 | #endif |
222 | 222 | ||
223 | struct debuginfo *debuginfo__new(const char *path) | 223 | struct debuginfo *debuginfo__new(const char *path) |
224 | { | 224 | { |
225 | struct debuginfo *self = zalloc(sizeof(struct debuginfo)); | 225 | struct debuginfo *dbg = zalloc(sizeof(*dbg)); |
226 | if (!self) | 226 | if (!dbg) |
227 | return NULL; | 227 | return NULL; |
228 | 228 | ||
229 | if (debuginfo__init_offline_dwarf(self, path) < 0) { | 229 | if (debuginfo__init_offline_dwarf(dbg, path) < 0) { |
230 | free(self); | 230 | free(dbg); |
231 | self = NULL; | 231 | dbg = NULL; |
232 | } | 232 | } |
233 | 233 | ||
234 | return self; | 234 | return dbg; |
235 | } | 235 | } |
236 | 236 | ||
237 | struct debuginfo *debuginfo__new_online_kernel(unsigned long addr) | 237 | struct debuginfo *debuginfo__new_online_kernel(unsigned long addr) |
238 | { | 238 | { |
239 | struct debuginfo *self = zalloc(sizeof(struct debuginfo)); | 239 | struct debuginfo *dbg = zalloc(sizeof(*dbg)); |
240 | if (!self) | 240 | |
241 | if (!dbg) | ||
241 | return NULL; | 242 | return NULL; |
242 | 243 | ||
243 | if (debuginfo__init_online_kernel_dwarf(self, (Dwarf_Addr)addr) < 0) { | 244 | if (debuginfo__init_online_kernel_dwarf(dbg, (Dwarf_Addr)addr) < 0) { |
244 | free(self); | 245 | free(dbg); |
245 | self = NULL; | 246 | dbg = NULL; |
246 | } | 247 | } |
247 | 248 | ||
248 | return self; | 249 | return dbg; |
249 | } | 250 | } |
250 | 251 | ||
251 | void debuginfo__delete(struct debuginfo *self) | 252 | void debuginfo__delete(struct debuginfo *dbg) |
252 | { | 253 | { |
253 | if (self) { | 254 | if (dbg) { |
254 | if (self->dwfl) | 255 | if (dbg->dwfl) |
255 | dwfl_end(self->dwfl); | 256 | dwfl_end(dbg->dwfl); |
256 | free(self); | 257 | free(dbg); |
257 | } | 258 | } |
258 | } | 259 | } |
259 | 260 | ||
@@ -1083,7 +1084,7 @@ static int pubname_search_cb(Dwarf *dbg, Dwarf_Global *gl, void *data) | |||
1083 | } | 1084 | } |
1084 | 1085 | ||
1085 | /* Find probe points from debuginfo */ | 1086 | /* Find probe points from debuginfo */ |
1086 | static int debuginfo__find_probes(struct debuginfo *self, | 1087 | static int debuginfo__find_probes(struct debuginfo *dbg, |
1087 | struct probe_finder *pf) | 1088 | struct probe_finder *pf) |
1088 | { | 1089 | { |
1089 | struct perf_probe_point *pp = &pf->pev->point; | 1090 | struct perf_probe_point *pp = &pf->pev->point; |
@@ -1094,7 +1095,7 @@ static int debuginfo__find_probes(struct debuginfo *self, | |||
1094 | 1095 | ||
1095 | #if _ELFUTILS_PREREQ(0, 142) | 1096 | #if _ELFUTILS_PREREQ(0, 142) |
1096 | /* Get the call frame information from this dwarf */ | 1097 | /* Get the call frame information from this dwarf */ |
1097 | pf->cfi = dwarf_getcfi(self->dbg); | 1098 | pf->cfi = dwarf_getcfi(dbg->dbg); |
1098 | #endif | 1099 | #endif |
1099 | 1100 | ||
1100 | off = 0; | 1101 | off = 0; |
@@ -1113,7 +1114,7 @@ static int debuginfo__find_probes(struct debuginfo *self, | |||
1113 | .data = pf, | 1114 | .data = pf, |
1114 | }; | 1115 | }; |
1115 | 1116 | ||
1116 | dwarf_getpubnames(self->dbg, pubname_search_cb, | 1117 | dwarf_getpubnames(dbg->dbg, pubname_search_cb, |
1117 | &pubname_param, 0); | 1118 | &pubname_param, 0); |
1118 | if (pubname_param.found) { | 1119 | if (pubname_param.found) { |
1119 | ret = probe_point_search_cb(&pf->sp_die, &probe_param); | 1120 | ret = probe_point_search_cb(&pf->sp_die, &probe_param); |
@@ -1123,9 +1124,9 @@ static int debuginfo__find_probes(struct debuginfo *self, | |||
1123 | } | 1124 | } |
1124 | 1125 | ||
1125 | /* Loop on CUs (Compilation Unit) */ | 1126 | /* Loop on CUs (Compilation Unit) */ |
1126 | while (!dwarf_nextcu(self->dbg, off, &noff, &cuhl, NULL, NULL, NULL)) { | 1127 | while (!dwarf_nextcu(dbg->dbg, off, &noff, &cuhl, NULL, NULL, NULL)) { |
1127 | /* Get the DIE(Debugging Information Entry) of this CU */ | 1128 | /* Get the DIE(Debugging Information Entry) of this CU */ |
1128 | diep = dwarf_offdie(self->dbg, off + cuhl, &pf->cu_die); | 1129 | diep = dwarf_offdie(dbg->dbg, off + cuhl, &pf->cu_die); |
1129 | if (!diep) | 1130 | if (!diep) |
1130 | continue; | 1131 | continue; |
1131 | 1132 | ||
@@ -1281,13 +1282,13 @@ end: | |||
1281 | } | 1282 | } |
1282 | 1283 | ||
1283 | /* Find probe_trace_events specified by perf_probe_event from debuginfo */ | 1284 | /* Find probe_trace_events specified by perf_probe_event from debuginfo */ |
1284 | int debuginfo__find_trace_events(struct debuginfo *self, | 1285 | int debuginfo__find_trace_events(struct debuginfo *dbg, |
1285 | struct perf_probe_event *pev, | 1286 | struct perf_probe_event *pev, |
1286 | struct probe_trace_event **tevs, int max_tevs) | 1287 | struct probe_trace_event **tevs, int max_tevs) |
1287 | { | 1288 | { |
1288 | struct trace_event_finder tf = { | 1289 | struct trace_event_finder tf = { |
1289 | .pf = {.pev = pev, .callback = add_probe_trace_event}, | 1290 | .pf = {.pev = pev, .callback = add_probe_trace_event}, |
1290 | .mod = self->mod, .max_tevs = max_tevs}; | 1291 | .mod = dbg->mod, .max_tevs = max_tevs}; |
1291 | int ret; | 1292 | int ret; |
1292 | 1293 | ||
1293 | /* Allocate result tevs array */ | 1294 | /* Allocate result tevs array */ |
@@ -1298,7 +1299,7 @@ int debuginfo__find_trace_events(struct debuginfo *self, | |||
1298 | tf.tevs = *tevs; | 1299 | tf.tevs = *tevs; |
1299 | tf.ntevs = 0; | 1300 | tf.ntevs = 0; |
1300 | 1301 | ||
1301 | ret = debuginfo__find_probes(self, &tf.pf); | 1302 | ret = debuginfo__find_probes(dbg, &tf.pf); |
1302 | if (ret < 0) { | 1303 | if (ret < 0) { |
1303 | free(*tevs); | 1304 | free(*tevs); |
1304 | *tevs = NULL; | 1305 | *tevs = NULL; |
@@ -1389,14 +1390,14 @@ out: | |||
1389 | } | 1390 | } |
1390 | 1391 | ||
1391 | /* Find available variables at given probe point */ | 1392 | /* Find available variables at given probe point */ |
1392 | int debuginfo__find_available_vars_at(struct debuginfo *self, | 1393 | int debuginfo__find_available_vars_at(struct debuginfo *dbg, |
1393 | struct perf_probe_event *pev, | 1394 | struct perf_probe_event *pev, |
1394 | struct variable_list **vls, | 1395 | struct variable_list **vls, |
1395 | int max_vls, bool externs) | 1396 | int max_vls, bool externs) |
1396 | { | 1397 | { |
1397 | struct available_var_finder af = { | 1398 | struct available_var_finder af = { |
1398 | .pf = {.pev = pev, .callback = add_available_vars}, | 1399 | .pf = {.pev = pev, .callback = add_available_vars}, |
1399 | .mod = self->mod, | 1400 | .mod = dbg->mod, |
1400 | .max_vls = max_vls, .externs = externs}; | 1401 | .max_vls = max_vls, .externs = externs}; |
1401 | int ret; | 1402 | int ret; |
1402 | 1403 | ||
@@ -1408,7 +1409,7 @@ int debuginfo__find_available_vars_at(struct debuginfo *self, | |||
1408 | af.vls = *vls; | 1409 | af.vls = *vls; |
1409 | af.nvls = 0; | 1410 | af.nvls = 0; |
1410 | 1411 | ||
1411 | ret = debuginfo__find_probes(self, &af.pf); | 1412 | ret = debuginfo__find_probes(dbg, &af.pf); |
1412 | if (ret < 0) { | 1413 | if (ret < 0) { |
1413 | /* Free vlist for error */ | 1414 | /* Free vlist for error */ |
1414 | while (af.nvls--) { | 1415 | while (af.nvls--) { |
@@ -1426,7 +1427,7 @@ int debuginfo__find_available_vars_at(struct debuginfo *self, | |||
1426 | } | 1427 | } |
1427 | 1428 | ||
1428 | /* Reverse search */ | 1429 | /* Reverse search */ |
1429 | int debuginfo__find_probe_point(struct debuginfo *self, unsigned long addr, | 1430 | int debuginfo__find_probe_point(struct debuginfo *dbg, unsigned long addr, |
1430 | struct perf_probe_point *ppt) | 1431 | struct perf_probe_point *ppt) |
1431 | { | 1432 | { |
1432 | Dwarf_Die cudie, spdie, indie; | 1433 | Dwarf_Die cudie, spdie, indie; |
@@ -1435,10 +1436,10 @@ int debuginfo__find_probe_point(struct debuginfo *self, unsigned long addr, | |||
1435 | int baseline = 0, lineno = 0, ret = 0; | 1436 | int baseline = 0, lineno = 0, ret = 0; |
1436 | 1437 | ||
1437 | /* Adjust address with bias */ | 1438 | /* Adjust address with bias */ |
1438 | addr += self->bias; | 1439 | addr += dbg->bias; |
1439 | 1440 | ||
1440 | /* Find cu die */ | 1441 | /* Find cu die */ |
1441 | if (!dwarf_addrdie(self->dbg, (Dwarf_Addr)addr - self->bias, &cudie)) { | 1442 | if (!dwarf_addrdie(dbg->dbg, (Dwarf_Addr)addr - dbg->bias, &cudie)) { |
1442 | pr_warning("Failed to find debug information for address %lx\n", | 1443 | pr_warning("Failed to find debug information for address %lx\n", |
1443 | addr); | 1444 | addr); |
1444 | ret = -EINVAL; | 1445 | ret = -EINVAL; |
@@ -1639,7 +1640,7 @@ static int find_line_range_by_func(struct line_finder *lf) | |||
1639 | return param.retval; | 1640 | return param.retval; |
1640 | } | 1641 | } |
1641 | 1642 | ||
1642 | int debuginfo__find_line_range(struct debuginfo *self, struct line_range *lr) | 1643 | int debuginfo__find_line_range(struct debuginfo *dbg, struct line_range *lr) |
1643 | { | 1644 | { |
1644 | struct line_finder lf = {.lr = lr, .found = 0}; | 1645 | struct line_finder lf = {.lr = lr, .found = 0}; |
1645 | int ret = 0; | 1646 | int ret = 0; |
@@ -1656,7 +1657,7 @@ int debuginfo__find_line_range(struct debuginfo *self, struct line_range *lr) | |||
1656 | struct dwarf_callback_param line_range_param = { | 1657 | struct dwarf_callback_param line_range_param = { |
1657 | .data = (void *)&lf, .retval = 0}; | 1658 | .data = (void *)&lf, .retval = 0}; |
1658 | 1659 | ||
1659 | dwarf_getpubnames(self->dbg, pubname_search_cb, | 1660 | dwarf_getpubnames(dbg->dbg, pubname_search_cb, |
1660 | &pubname_param, 0); | 1661 | &pubname_param, 0); |
1661 | if (pubname_param.found) { | 1662 | if (pubname_param.found) { |
1662 | line_range_search_cb(&lf.sp_die, &line_range_param); | 1663 | line_range_search_cb(&lf.sp_die, &line_range_param); |
@@ -1667,12 +1668,12 @@ int debuginfo__find_line_range(struct debuginfo *self, struct line_range *lr) | |||
1667 | 1668 | ||
1668 | /* Loop on CUs (Compilation Unit) */ | 1669 | /* Loop on CUs (Compilation Unit) */ |
1669 | while (!lf.found && ret >= 0) { | 1670 | while (!lf.found && ret >= 0) { |
1670 | if (dwarf_nextcu(self->dbg, off, &noff, &cuhl, | 1671 | if (dwarf_nextcu(dbg->dbg, off, &noff, &cuhl, |
1671 | NULL, NULL, NULL) != 0) | 1672 | NULL, NULL, NULL) != 0) |
1672 | break; | 1673 | break; |
1673 | 1674 | ||
1674 | /* Get the DIE(Debugging Information Entry) of this CU */ | 1675 | /* Get the DIE(Debugging Information Entry) of this CU */ |
1675 | diep = dwarf_offdie(self->dbg, off + cuhl, &lf.cu_die); | 1676 | diep = dwarf_offdie(dbg->dbg, off + cuhl, &lf.cu_die); |
1676 | if (!diep) | 1677 | if (!diep) |
1677 | continue; | 1678 | continue; |
1678 | 1679 | ||
diff --git a/tools/perf/util/probe-finder.h b/tools/perf/util/probe-finder.h index d6dab0e0a937..ffc33cdd25cc 100644 --- a/tools/perf/util/probe-finder.h +++ b/tools/perf/util/probe-finder.h | |||
@@ -31,25 +31,25 @@ struct debuginfo { | |||
31 | 31 | ||
32 | extern struct debuginfo *debuginfo__new(const char *path); | 32 | extern struct debuginfo *debuginfo__new(const char *path); |
33 | extern struct debuginfo *debuginfo__new_online_kernel(unsigned long addr); | 33 | extern struct debuginfo *debuginfo__new_online_kernel(unsigned long addr); |
34 | extern void debuginfo__delete(struct debuginfo *self); | 34 | extern void debuginfo__delete(struct debuginfo *dbg); |
35 | 35 | ||
36 | /* Find probe_trace_events specified by perf_probe_event from debuginfo */ | 36 | /* Find probe_trace_events specified by perf_probe_event from debuginfo */ |
37 | extern int debuginfo__find_trace_events(struct debuginfo *self, | 37 | extern int debuginfo__find_trace_events(struct debuginfo *dbg, |
38 | struct perf_probe_event *pev, | 38 | struct perf_probe_event *pev, |
39 | struct probe_trace_event **tevs, | 39 | struct probe_trace_event **tevs, |
40 | int max_tevs); | 40 | int max_tevs); |
41 | 41 | ||
42 | /* Find a perf_probe_point from debuginfo */ | 42 | /* Find a perf_probe_point from debuginfo */ |
43 | extern int debuginfo__find_probe_point(struct debuginfo *self, | 43 | extern int debuginfo__find_probe_point(struct debuginfo *dbg, |
44 | unsigned long addr, | 44 | unsigned long addr, |
45 | struct perf_probe_point *ppt); | 45 | struct perf_probe_point *ppt); |
46 | 46 | ||
47 | /* Find a line range */ | 47 | /* Find a line range */ |
48 | extern int debuginfo__find_line_range(struct debuginfo *self, | 48 | extern int debuginfo__find_line_range(struct debuginfo *dbg, |
49 | struct line_range *lr); | 49 | struct line_range *lr); |
50 | 50 | ||
51 | /* Find available variables */ | 51 | /* Find available variables */ |
52 | extern int debuginfo__find_available_vars_at(struct debuginfo *self, | 52 | extern int debuginfo__find_available_vars_at(struct debuginfo *dbg, |
53 | struct perf_probe_event *pev, | 53 | struct perf_probe_event *pev, |
54 | struct variable_list **vls, | 54 | struct variable_list **vls, |
55 | int max_points, bool externs); | 55 | int max_points, bool externs); |
diff --git a/tools/perf/util/pstack.h b/tools/perf/util/pstack.h index 4cedea59f518..c3cb6584d527 100644 --- a/tools/perf/util/pstack.h +++ b/tools/perf/util/pstack.h | |||
@@ -5,10 +5,10 @@ | |||
5 | 5 | ||
6 | struct pstack; | 6 | struct pstack; |
7 | struct pstack *pstack__new(unsigned short max_nr_entries); | 7 | struct pstack *pstack__new(unsigned short max_nr_entries); |
8 | void pstack__delete(struct pstack *self); | 8 | void pstack__delete(struct pstack *pstack); |
9 | bool pstack__empty(const struct pstack *self); | 9 | bool pstack__empty(const struct pstack *pstack); |
10 | void pstack__remove(struct pstack *self, void *key); | 10 | void pstack__remove(struct pstack *pstack, void *key); |
11 | void pstack__push(struct pstack *self, void *key); | 11 | void pstack__push(struct pstack *pstack, void *key); |
12 | void *pstack__pop(struct pstack *self); | 12 | void *pstack__pop(struct pstack *pstack); |
13 | 13 | ||
14 | #endif /* _PERF_PSTACK_ */ | 14 | #endif /* _PERF_PSTACK_ */ |
diff --git a/tools/perf/util/python-ext-sources b/tools/perf/util/python-ext-sources index f75ae1b9900c..239036fb2b2c 100644 --- a/tools/perf/util/python-ext-sources +++ b/tools/perf/util/python-ext-sources | |||
@@ -17,5 +17,5 @@ util/xyarray.c | |||
17 | util/cgroup.c | 17 | util/cgroup.c |
18 | util/rblist.c | 18 | util/rblist.c |
19 | util/strlist.c | 19 | util/strlist.c |
20 | util/sysfs.c | 20 | util/fs.c |
21 | ../../lib/rbtree.c | 21 | ../../lib/rbtree.c |
diff --git a/tools/perf/util/record.c b/tools/perf/util/record.c index 18d73aa2f0f8..c8845b107f60 100644 --- a/tools/perf/util/record.c +++ b/tools/perf/util/record.c | |||
@@ -2,6 +2,8 @@ | |||
2 | #include "evsel.h" | 2 | #include "evsel.h" |
3 | #include "cpumap.h" | 3 | #include "cpumap.h" |
4 | #include "parse-events.h" | 4 | #include "parse-events.h" |
5 | #include "fs.h" | ||
6 | #include "util.h" | ||
5 | 7 | ||
6 | typedef void (*setup_probe_fn_t)(struct perf_evsel *evsel); | 8 | typedef void (*setup_probe_fn_t)(struct perf_evsel *evsel); |
7 | 9 | ||
@@ -106,3 +108,72 @@ void perf_evlist__config(struct perf_evlist *evlist, | |||
106 | 108 | ||
107 | perf_evlist__set_id_pos(evlist); | 109 | perf_evlist__set_id_pos(evlist); |
108 | } | 110 | } |
111 | |||
112 | static int get_max_rate(unsigned int *rate) | ||
113 | { | ||
114 | char path[PATH_MAX]; | ||
115 | const char *procfs = procfs__mountpoint(); | ||
116 | |||
117 | if (!procfs) | ||
118 | return -1; | ||
119 | |||
120 | snprintf(path, PATH_MAX, | ||
121 | "%s/sys/kernel/perf_event_max_sample_rate", procfs); | ||
122 | |||
123 | return filename__read_int(path, (int *) rate); | ||
124 | } | ||
125 | |||
126 | static int perf_record_opts__config_freq(struct perf_record_opts *opts) | ||
127 | { | ||
128 | bool user_freq = opts->user_freq != UINT_MAX; | ||
129 | unsigned int max_rate; | ||
130 | |||
131 | if (opts->user_interval != ULLONG_MAX) | ||
132 | opts->default_interval = opts->user_interval; | ||
133 | if (user_freq) | ||
134 | opts->freq = opts->user_freq; | ||
135 | |||
136 | /* | ||
137 | * User specified count overrides default frequency. | ||
138 | */ | ||
139 | if (opts->default_interval) | ||
140 | opts->freq = 0; | ||
141 | else if (opts->freq) { | ||
142 | opts->default_interval = opts->freq; | ||
143 | } else { | ||
144 | pr_err("frequency and count are zero, aborting\n"); | ||
145 | return -1; | ||
146 | } | ||
147 | |||
148 | if (get_max_rate(&max_rate)) | ||
149 | return 0; | ||
150 | |||
151 | /* | ||
152 | * User specified frequency is over current maximum. | ||
153 | */ | ||
154 | if (user_freq && (max_rate < opts->freq)) { | ||
155 | pr_err("Maximum frequency rate (%u) reached.\n" | ||
156 | "Please use -F freq option with lower value or consider\n" | ||
157 | "tweaking /proc/sys/kernel/perf_event_max_sample_rate.\n", | ||
158 | max_rate); | ||
159 | return -1; | ||
160 | } | ||
161 | |||
162 | /* | ||
163 | * Default frequency is over current maximum. | ||
164 | */ | ||
165 | if (max_rate < opts->freq) { | ||
166 | pr_warning("Lowering default frequency rate to %u.\n" | ||
167 | "Please consider tweaking " | ||
168 | "/proc/sys/kernel/perf_event_max_sample_rate.\n", | ||
169 | max_rate); | ||
170 | opts->freq = max_rate; | ||
171 | } | ||
172 | |||
173 | return 0; | ||
174 | } | ||
175 | |||
176 | int perf_record_opts__config(struct perf_record_opts *opts) | ||
177 | { | ||
178 | return perf_record_opts__config_freq(opts); | ||
179 | } | ||
diff --git a/tools/perf/util/session.c b/tools/perf/util/session.c index 3c1b30103d54..0ce46943d627 100644 --- a/tools/perf/util/session.c +++ b/tools/perf/util/session.c | |||
@@ -16,11 +16,11 @@ | |||
16 | #include "perf_regs.h" | 16 | #include "perf_regs.h" |
17 | #include "vdso.h" | 17 | #include "vdso.h" |
18 | 18 | ||
19 | static int perf_session__open(struct perf_session *self) | 19 | static int perf_session__open(struct perf_session *session) |
20 | { | 20 | { |
21 | struct perf_data_file *file = self->file; | 21 | struct perf_data_file *file = session->file; |
22 | 22 | ||
23 | if (perf_session__read_header(self) < 0) { | 23 | if (perf_session__read_header(session) < 0) { |
24 | pr_err("incompatible file format (rerun with -v to learn more)"); | 24 | pr_err("incompatible file format (rerun with -v to learn more)"); |
25 | return -1; | 25 | return -1; |
26 | } | 26 | } |
@@ -28,17 +28,17 @@ static int perf_session__open(struct perf_session *self) | |||
28 | if (perf_data_file__is_pipe(file)) | 28 | if (perf_data_file__is_pipe(file)) |
29 | return 0; | 29 | return 0; |
30 | 30 | ||
31 | if (!perf_evlist__valid_sample_type(self->evlist)) { | 31 | if (!perf_evlist__valid_sample_type(session->evlist)) { |
32 | pr_err("non matching sample_type"); | 32 | pr_err("non matching sample_type"); |
33 | return -1; | 33 | return -1; |
34 | } | 34 | } |
35 | 35 | ||
36 | if (!perf_evlist__valid_sample_id_all(self->evlist)) { | 36 | if (!perf_evlist__valid_sample_id_all(session->evlist)) { |
37 | pr_err("non matching sample_id_all"); | 37 | pr_err("non matching sample_id_all"); |
38 | return -1; | 38 | return -1; |
39 | } | 39 | } |
40 | 40 | ||
41 | if (!perf_evlist__valid_read_format(self->evlist)) { | 41 | if (!perf_evlist__valid_read_format(session->evlist)) { |
42 | pr_err("non matching read_format"); | 42 | pr_err("non matching read_format"); |
43 | return -1; | 43 | return -1; |
44 | } | 44 | } |
@@ -53,46 +53,45 @@ void perf_session__set_id_hdr_size(struct perf_session *session) | |||
53 | machines__set_id_hdr_size(&session->machines, id_hdr_size); | 53 | machines__set_id_hdr_size(&session->machines, id_hdr_size); |
54 | } | 54 | } |
55 | 55 | ||
56 | int perf_session__create_kernel_maps(struct perf_session *self) | 56 | int perf_session__create_kernel_maps(struct perf_session *session) |
57 | { | 57 | { |
58 | int ret = machine__create_kernel_maps(&self->machines.host); | 58 | int ret = machine__create_kernel_maps(&session->machines.host); |
59 | 59 | ||
60 | if (ret >= 0) | 60 | if (ret >= 0) |
61 | ret = machines__create_guest_kernel_maps(&self->machines); | 61 | ret = machines__create_guest_kernel_maps(&session->machines); |
62 | return ret; | 62 | return ret; |
63 | } | 63 | } |
64 | 64 | ||
65 | static void perf_session__destroy_kernel_maps(struct perf_session *self) | 65 | static void perf_session__destroy_kernel_maps(struct perf_session *session) |
66 | { | 66 | { |
67 | machines__destroy_kernel_maps(&self->machines); | 67 | machines__destroy_kernel_maps(&session->machines); |
68 | } | 68 | } |
69 | 69 | ||
70 | struct perf_session *perf_session__new(struct perf_data_file *file, | 70 | struct perf_session *perf_session__new(struct perf_data_file *file, |
71 | bool repipe, struct perf_tool *tool) | 71 | bool repipe, struct perf_tool *tool) |
72 | { | 72 | { |
73 | struct perf_session *self; | 73 | struct perf_session *session = zalloc(sizeof(*session)); |
74 | 74 | ||
75 | self = zalloc(sizeof(*self)); | 75 | if (!session) |
76 | if (!self) | ||
77 | goto out; | 76 | goto out; |
78 | 77 | ||
79 | self->repipe = repipe; | 78 | session->repipe = repipe; |
80 | INIT_LIST_HEAD(&self->ordered_samples.samples); | 79 | INIT_LIST_HEAD(&session->ordered_samples.samples); |
81 | INIT_LIST_HEAD(&self->ordered_samples.sample_cache); | 80 | INIT_LIST_HEAD(&session->ordered_samples.sample_cache); |
82 | INIT_LIST_HEAD(&self->ordered_samples.to_free); | 81 | INIT_LIST_HEAD(&session->ordered_samples.to_free); |
83 | machines__init(&self->machines); | 82 | machines__init(&session->machines); |
84 | 83 | ||
85 | if (file) { | 84 | if (file) { |
86 | if (perf_data_file__open(file)) | 85 | if (perf_data_file__open(file)) |
87 | goto out_delete; | 86 | goto out_delete; |
88 | 87 | ||
89 | self->file = file; | 88 | session->file = file; |
90 | 89 | ||
91 | if (perf_data_file__is_read(file)) { | 90 | if (perf_data_file__is_read(file)) { |
92 | if (perf_session__open(self) < 0) | 91 | if (perf_session__open(session) < 0) |
93 | goto out_close; | 92 | goto out_close; |
94 | 93 | ||
95 | perf_session__set_id_hdr_size(self); | 94 | perf_session__set_id_hdr_size(session); |
96 | } | 95 | } |
97 | } | 96 | } |
98 | 97 | ||
@@ -101,22 +100,22 @@ struct perf_session *perf_session__new(struct perf_data_file *file, | |||
101 | * In O_RDONLY mode this will be performed when reading the | 100 | * In O_RDONLY mode this will be performed when reading the |
102 | * kernel MMAP event, in perf_event__process_mmap(). | 101 | * kernel MMAP event, in perf_event__process_mmap(). |
103 | */ | 102 | */ |
104 | if (perf_session__create_kernel_maps(self) < 0) | 103 | if (perf_session__create_kernel_maps(session) < 0) |
105 | goto out_delete; | 104 | goto out_delete; |
106 | } | 105 | } |
107 | 106 | ||
108 | if (tool && tool->ordering_requires_timestamps && | 107 | if (tool && tool->ordering_requires_timestamps && |
109 | tool->ordered_samples && !perf_evlist__sample_id_all(self->evlist)) { | 108 | tool->ordered_samples && !perf_evlist__sample_id_all(session->evlist)) { |
110 | dump_printf("WARNING: No sample_id_all support, falling back to unordered processing\n"); | 109 | dump_printf("WARNING: No sample_id_all support, falling back to unordered processing\n"); |
111 | tool->ordered_samples = false; | 110 | tool->ordered_samples = false; |
112 | } | 111 | } |
113 | 112 | ||
114 | return self; | 113 | return session; |
115 | 114 | ||
116 | out_close: | 115 | out_close: |
117 | perf_data_file__close(file); | 116 | perf_data_file__close(file); |
118 | out_delete: | 117 | out_delete: |
119 | perf_session__delete(self); | 118 | perf_session__delete(session); |
120 | out: | 119 | out: |
121 | return NULL; | 120 | return NULL; |
122 | } | 121 | } |
@@ -147,16 +146,16 @@ static void perf_session_env__delete(struct perf_session_env *env) | |||
147 | free(env->pmu_mappings); | 146 | free(env->pmu_mappings); |
148 | } | 147 | } |
149 | 148 | ||
150 | void perf_session__delete(struct perf_session *self) | 149 | void perf_session__delete(struct perf_session *session) |
151 | { | 150 | { |
152 | perf_session__destroy_kernel_maps(self); | 151 | perf_session__destroy_kernel_maps(session); |
153 | perf_session__delete_dead_threads(self); | 152 | perf_session__delete_dead_threads(session); |
154 | perf_session__delete_threads(self); | 153 | perf_session__delete_threads(session); |
155 | perf_session_env__delete(&self->header.env); | 154 | perf_session_env__delete(&session->header.env); |
156 | machines__exit(&self->machines); | 155 | machines__exit(&session->machines); |
157 | if (self->file) | 156 | if (session->file) |
158 | perf_data_file__close(self->file); | 157 | perf_data_file__close(session->file); |
159 | free(self); | 158 | free(session); |
160 | vdso__exit(); | 159 | vdso__exit(); |
161 | } | 160 | } |
162 | 161 | ||
@@ -1084,11 +1083,11 @@ static int perf_session__process_event(struct perf_session *session, | |||
1084 | file_offset); | 1083 | file_offset); |
1085 | } | 1084 | } |
1086 | 1085 | ||
1087 | void perf_event_header__bswap(struct perf_event_header *self) | 1086 | void perf_event_header__bswap(struct perf_event_header *hdr) |
1088 | { | 1087 | { |
1089 | self->type = bswap_32(self->type); | 1088 | hdr->type = bswap_32(hdr->type); |
1090 | self->misc = bswap_16(self->misc); | 1089 | hdr->misc = bswap_16(hdr->misc); |
1091 | self->size = bswap_16(self->size); | 1090 | hdr->size = bswap_16(hdr->size); |
1092 | } | 1091 | } |
1093 | 1092 | ||
1094 | struct thread *perf_session__findnew(struct perf_session *session, pid_t pid) | 1093 | struct thread *perf_session__findnew(struct perf_session *session, pid_t pid) |
@@ -1096,9 +1095,9 @@ struct thread *perf_session__findnew(struct perf_session *session, pid_t pid) | |||
1096 | return machine__findnew_thread(&session->machines.host, 0, pid); | 1095 | return machine__findnew_thread(&session->machines.host, 0, pid); |
1097 | } | 1096 | } |
1098 | 1097 | ||
1099 | static struct thread *perf_session__register_idle_thread(struct perf_session *self) | 1098 | static struct thread *perf_session__register_idle_thread(struct perf_session *session) |
1100 | { | 1099 | { |
1101 | struct thread *thread = perf_session__findnew(self, 0); | 1100 | struct thread *thread = perf_session__findnew(session, 0); |
1102 | 1101 | ||
1103 | if (thread == NULL || thread__set_comm(thread, "swapper", 0)) { | 1102 | if (thread == NULL || thread__set_comm(thread, "swapper", 0)) { |
1104 | pr_err("problem inserting idle task.\n"); | 1103 | pr_err("problem inserting idle task.\n"); |
@@ -1150,10 +1149,10 @@ static void perf_session__warn_about_errors(const struct perf_session *session, | |||
1150 | 1149 | ||
1151 | volatile int session_done; | 1150 | volatile int session_done; |
1152 | 1151 | ||
1153 | static int __perf_session__process_pipe_events(struct perf_session *self, | 1152 | static int __perf_session__process_pipe_events(struct perf_session *session, |
1154 | struct perf_tool *tool) | 1153 | struct perf_tool *tool) |
1155 | { | 1154 | { |
1156 | int fd = perf_data_file__fd(self->file); | 1155 | int fd = perf_data_file__fd(session->file); |
1157 | union perf_event *event; | 1156 | union perf_event *event; |
1158 | uint32_t size, cur_size = 0; | 1157 | uint32_t size, cur_size = 0; |
1159 | void *buf = NULL; | 1158 | void *buf = NULL; |
@@ -1181,7 +1180,7 @@ more: | |||
1181 | goto out_err; | 1180 | goto out_err; |
1182 | } | 1181 | } |
1183 | 1182 | ||
1184 | if (self->header.needs_swap) | 1183 | if (session->header.needs_swap) |
1185 | perf_event_header__bswap(&event->header); | 1184 | perf_event_header__bswap(&event->header); |
1186 | 1185 | ||
1187 | size = event->header.size; | 1186 | size = event->header.size; |
@@ -1216,7 +1215,7 @@ more: | |||
1216 | } | 1215 | } |
1217 | } | 1216 | } |
1218 | 1217 | ||
1219 | if ((skip = perf_session__process_event(self, event, tool, head)) < 0) { | 1218 | if ((skip = perf_session__process_event(session, event, tool, head)) < 0) { |
1220 | pr_err("%#" PRIx64 " [%#x]: failed to process type: %d\n", | 1219 | pr_err("%#" PRIx64 " [%#x]: failed to process type: %d\n", |
1221 | head, event->header.size, event->header.type); | 1220 | head, event->header.size, event->header.type); |
1222 | err = -EINVAL; | 1221 | err = -EINVAL; |
@@ -1232,12 +1231,12 @@ more: | |||
1232 | goto more; | 1231 | goto more; |
1233 | done: | 1232 | done: |
1234 | /* do the final flush for ordered samples */ | 1233 | /* do the final flush for ordered samples */ |
1235 | self->ordered_samples.next_flush = ULLONG_MAX; | 1234 | session->ordered_samples.next_flush = ULLONG_MAX; |
1236 | err = flush_sample_queue(self, tool); | 1235 | err = flush_sample_queue(session, tool); |
1237 | out_err: | 1236 | out_err: |
1238 | free(buf); | 1237 | free(buf); |
1239 | perf_session__warn_about_errors(self, tool); | 1238 | perf_session__warn_about_errors(session, tool); |
1240 | perf_session_free_sample_buffers(self); | 1239 | perf_session_free_sample_buffers(session); |
1241 | return err; | 1240 | return err; |
1242 | } | 1241 | } |
1243 | 1242 | ||
@@ -1377,22 +1376,22 @@ out_err: | |||
1377 | return err; | 1376 | return err; |
1378 | } | 1377 | } |
1379 | 1378 | ||
1380 | int perf_session__process_events(struct perf_session *self, | 1379 | int perf_session__process_events(struct perf_session *session, |
1381 | struct perf_tool *tool) | 1380 | struct perf_tool *tool) |
1382 | { | 1381 | { |
1383 | u64 size = perf_data_file__size(self->file); | 1382 | u64 size = perf_data_file__size(session->file); |
1384 | int err; | 1383 | int err; |
1385 | 1384 | ||
1386 | if (perf_session__register_idle_thread(self) == NULL) | 1385 | if (perf_session__register_idle_thread(session) == NULL) |
1387 | return -ENOMEM; | 1386 | return -ENOMEM; |
1388 | 1387 | ||
1389 | if (!perf_data_file__is_pipe(self->file)) | 1388 | if (!perf_data_file__is_pipe(session->file)) |
1390 | err = __perf_session__process_events(self, | 1389 | err = __perf_session__process_events(session, |
1391 | self->header.data_offset, | 1390 | session->header.data_offset, |
1392 | self->header.data_size, | 1391 | session->header.data_size, |
1393 | size, tool); | 1392 | size, tool); |
1394 | else | 1393 | else |
1395 | err = __perf_session__process_pipe_events(self, tool); | 1394 | err = __perf_session__process_pipe_events(session, tool); |
1396 | 1395 | ||
1397 | return err; | 1396 | return err; |
1398 | } | 1397 | } |
@@ -1441,15 +1440,15 @@ int maps__set_kallsyms_ref_reloc_sym(struct map **maps, | |||
1441 | return 0; | 1440 | return 0; |
1442 | } | 1441 | } |
1443 | 1442 | ||
1444 | size_t perf_session__fprintf_dsos(struct perf_session *self, FILE *fp) | 1443 | size_t perf_session__fprintf_dsos(struct perf_session *session, FILE *fp) |
1445 | { | 1444 | { |
1446 | return machines__fprintf_dsos(&self->machines, fp); | 1445 | return machines__fprintf_dsos(&session->machines, fp); |
1447 | } | 1446 | } |
1448 | 1447 | ||
1449 | size_t perf_session__fprintf_dsos_buildid(struct perf_session *self, FILE *fp, | 1448 | size_t perf_session__fprintf_dsos_buildid(struct perf_session *session, FILE *fp, |
1450 | bool (skip)(struct dso *dso, int parm), int parm) | 1449 | bool (skip)(struct dso *dso, int parm), int parm) |
1451 | { | 1450 | { |
1452 | return machines__fprintf_dsos_buildid(&self->machines, fp, skip, parm); | 1451 | return machines__fprintf_dsos_buildid(&session->machines, fp, skip, parm); |
1453 | } | 1452 | } |
1454 | 1453 | ||
1455 | size_t perf_session__fprintf_nr_events(struct perf_session *session, FILE *fp) | 1454 | size_t perf_session__fprintf_nr_events(struct perf_session *session, FILE *fp) |
diff --git a/tools/perf/util/session.h b/tools/perf/util/session.h index 27c74d38b868..50f640958f0f 100644 --- a/tools/perf/util/session.h +++ b/tools/perf/util/session.h | |||
@@ -51,12 +51,12 @@ struct perf_session *perf_session__new(struct perf_data_file *file, | |||
51 | bool repipe, struct perf_tool *tool); | 51 | bool repipe, struct perf_tool *tool); |
52 | void perf_session__delete(struct perf_session *session); | 52 | void perf_session__delete(struct perf_session *session); |
53 | 53 | ||
54 | void perf_event_header__bswap(struct perf_event_header *self); | 54 | void perf_event_header__bswap(struct perf_event_header *hdr); |
55 | 55 | ||
56 | int __perf_session__process_events(struct perf_session *self, | 56 | int __perf_session__process_events(struct perf_session *session, |
57 | u64 data_offset, u64 data_size, u64 size, | 57 | u64 data_offset, u64 data_size, u64 size, |
58 | struct perf_tool *tool); | 58 | struct perf_tool *tool); |
59 | int perf_session__process_events(struct perf_session *self, | 59 | int perf_session__process_events(struct perf_session *session, |
60 | struct perf_tool *tool); | 60 | struct perf_tool *tool); |
61 | 61 | ||
62 | int perf_session_queue_event(struct perf_session *s, union perf_event *event, | 62 | int perf_session_queue_event(struct perf_session *s, union perf_event *event, |
@@ -64,37 +64,38 @@ int perf_session_queue_event(struct perf_session *s, union perf_event *event, | |||
64 | 64 | ||
65 | void perf_tool__fill_defaults(struct perf_tool *tool); | 65 | void perf_tool__fill_defaults(struct perf_tool *tool); |
66 | 66 | ||
67 | int perf_session__resolve_callchain(struct perf_session *self, struct perf_evsel *evsel, | 67 | int perf_session__resolve_callchain(struct perf_session *session, |
68 | struct perf_evsel *evsel, | ||
68 | struct thread *thread, | 69 | struct thread *thread, |
69 | struct ip_callchain *chain, | 70 | struct ip_callchain *chain, |
70 | struct symbol **parent); | 71 | struct symbol **parent); |
71 | 72 | ||
72 | bool perf_session__has_traces(struct perf_session *self, const char *msg); | 73 | bool perf_session__has_traces(struct perf_session *session, const char *msg); |
73 | 74 | ||
74 | void mem_bswap_64(void *src, int byte_size); | 75 | void mem_bswap_64(void *src, int byte_size); |
75 | void mem_bswap_32(void *src, int byte_size); | 76 | void mem_bswap_32(void *src, int byte_size); |
76 | void perf_event__attr_swap(struct perf_event_attr *attr); | 77 | void perf_event__attr_swap(struct perf_event_attr *attr); |
77 | 78 | ||
78 | int perf_session__create_kernel_maps(struct perf_session *self); | 79 | int perf_session__create_kernel_maps(struct perf_session *session); |
79 | 80 | ||
80 | void perf_session__set_id_hdr_size(struct perf_session *session); | 81 | void perf_session__set_id_hdr_size(struct perf_session *session); |
81 | 82 | ||
82 | static inline | 83 | static inline |
83 | struct machine *perf_session__find_machine(struct perf_session *self, pid_t pid) | 84 | struct machine *perf_session__find_machine(struct perf_session *session, pid_t pid) |
84 | { | 85 | { |
85 | return machines__find(&self->machines, pid); | 86 | return machines__find(&session->machines, pid); |
86 | } | 87 | } |
87 | 88 | ||
88 | static inline | 89 | static inline |
89 | struct machine *perf_session__findnew_machine(struct perf_session *self, pid_t pid) | 90 | struct machine *perf_session__findnew_machine(struct perf_session *session, pid_t pid) |
90 | { | 91 | { |
91 | return machines__findnew(&self->machines, pid); | 92 | return machines__findnew(&session->machines, pid); |
92 | } | 93 | } |
93 | 94 | ||
94 | struct thread *perf_session__findnew(struct perf_session *self, pid_t pid); | 95 | struct thread *perf_session__findnew(struct perf_session *session, pid_t pid); |
95 | size_t perf_session__fprintf(struct perf_session *self, FILE *fp); | 96 | size_t perf_session__fprintf(struct perf_session *session, FILE *fp); |
96 | 97 | ||
97 | size_t perf_session__fprintf_dsos(struct perf_session *self, FILE *fp); | 98 | size_t perf_session__fprintf_dsos(struct perf_session *session, FILE *fp); |
98 | 99 | ||
99 | size_t perf_session__fprintf_dsos_buildid(struct perf_session *session, FILE *fp, | 100 | size_t perf_session__fprintf_dsos_buildid(struct perf_session *session, FILE *fp, |
100 | bool (fn)(struct dso *dso, int parm), int parm); | 101 | bool (fn)(struct dso *dso, int parm), int parm); |
diff --git a/tools/perf/util/sort.h b/tools/perf/util/sort.h index f4e16f359d64..f4cc147e0220 100644 --- a/tools/perf/util/sort.h +++ b/tools/perf/util/sort.h | |||
@@ -180,7 +180,7 @@ struct sort_entry { | |||
180 | 180 | ||
181 | int64_t (*se_cmp)(struct hist_entry *, struct hist_entry *); | 181 | int64_t (*se_cmp)(struct hist_entry *, struct hist_entry *); |
182 | int64_t (*se_collapse)(struct hist_entry *, struct hist_entry *); | 182 | int64_t (*se_collapse)(struct hist_entry *, struct hist_entry *); |
183 | int (*se_snprintf)(struct hist_entry *self, char *bf, size_t size, | 183 | int (*se_snprintf)(struct hist_entry *he, char *bf, size_t size, |
184 | unsigned int width); | 184 | unsigned int width); |
185 | u8 se_width_idx; | 185 | u8 se_width_idx; |
186 | bool elide; | 186 | bool elide; |
diff --git a/tools/perf/util/strfilter.c b/tools/perf/util/strfilter.c index 67e4a0082822..3edd0538161f 100644 --- a/tools/perf/util/strfilter.c +++ b/tools/perf/util/strfilter.c | |||
@@ -62,15 +62,15 @@ static struct strfilter_node *strfilter_node__alloc(const char *op, | |||
62 | struct strfilter_node *l, | 62 | struct strfilter_node *l, |
63 | struct strfilter_node *r) | 63 | struct strfilter_node *r) |
64 | { | 64 | { |
65 | struct strfilter_node *ret = zalloc(sizeof(struct strfilter_node)); | 65 | struct strfilter_node *node = zalloc(sizeof(*node)); |
66 | 66 | ||
67 | if (ret) { | 67 | if (node) { |
68 | ret->p = op; | 68 | node->p = op; |
69 | ret->l = l; | 69 | node->l = l; |
70 | ret->r = r; | 70 | node->r = r; |
71 | } | 71 | } |
72 | 72 | ||
73 | return ret; | 73 | return node; |
74 | } | 74 | } |
75 | 75 | ||
76 | static struct strfilter_node *strfilter_node__new(const char *s, | 76 | static struct strfilter_node *strfilter_node__new(const char *s, |
@@ -154,20 +154,20 @@ error: | |||
154 | */ | 154 | */ |
155 | struct strfilter *strfilter__new(const char *rules, const char **err) | 155 | struct strfilter *strfilter__new(const char *rules, const char **err) |
156 | { | 156 | { |
157 | struct strfilter *ret = zalloc(sizeof(struct strfilter)); | 157 | struct strfilter *filter = zalloc(sizeof(*filter)); |
158 | const char *ep = NULL; | 158 | const char *ep = NULL; |
159 | 159 | ||
160 | if (ret) | 160 | if (filter) |
161 | ret->root = strfilter_node__new(rules, &ep); | 161 | filter->root = strfilter_node__new(rules, &ep); |
162 | 162 | ||
163 | if (!ret || !ret->root || *ep != '\0') { | 163 | if (!filter || !filter->root || *ep != '\0') { |
164 | if (err) | 164 | if (err) |
165 | *err = ep; | 165 | *err = ep; |
166 | strfilter__delete(ret); | 166 | strfilter__delete(filter); |
167 | ret = NULL; | 167 | filter = NULL; |
168 | } | 168 | } |
169 | 169 | ||
170 | return ret; | 170 | return filter; |
171 | } | 171 | } |
172 | 172 | ||
173 | static bool strfilter_node__compare(struct strfilter_node *node, | 173 | static bool strfilter_node__compare(struct strfilter_node *node, |
@@ -191,9 +191,9 @@ static bool strfilter_node__compare(struct strfilter_node *node, | |||
191 | } | 191 | } |
192 | 192 | ||
193 | /* Return true if STR matches the filter rules */ | 193 | /* Return true if STR matches the filter rules */ |
194 | bool strfilter__compare(struct strfilter *node, const char *str) | 194 | bool strfilter__compare(struct strfilter *filter, const char *str) |
195 | { | 195 | { |
196 | if (!node) | 196 | if (!filter) |
197 | return false; | 197 | return false; |
198 | return strfilter_node__compare(node->root, str); | 198 | return strfilter_node__compare(filter->root, str); |
199 | } | 199 | } |
diff --git a/tools/perf/util/strfilter.h b/tools/perf/util/strfilter.h index 00f58a7506de..fe611f3c9e39 100644 --- a/tools/perf/util/strfilter.h +++ b/tools/perf/util/strfilter.h | |||
@@ -30,19 +30,19 @@ struct strfilter *strfilter__new(const char *rules, const char **err); | |||
30 | 30 | ||
31 | /** | 31 | /** |
32 | * strfilter__compare - compare given string and a string filter | 32 | * strfilter__compare - compare given string and a string filter |
33 | * @self: String filter | 33 | * @filter: String filter |
34 | * @str: target string | 34 | * @str: target string |
35 | * | 35 | * |
36 | * Compare @str and @self. Return true if the str match the rule | 36 | * Compare @str and @filter. Return true if the str match the rule |
37 | */ | 37 | */ |
38 | bool strfilter__compare(struct strfilter *self, const char *str); | 38 | bool strfilter__compare(struct strfilter *filter, const char *str); |
39 | 39 | ||
40 | /** | 40 | /** |
41 | * strfilter__delete - delete a string filter | 41 | * strfilter__delete - delete a string filter |
42 | * @self: String filter to delete | 42 | * @filter: String filter to delete |
43 | * | 43 | * |
44 | * Delete @self. | 44 | * Delete @filter. |
45 | */ | 45 | */ |
46 | void strfilter__delete(struct strfilter *self); | 46 | void strfilter__delete(struct strfilter *filter); |
47 | 47 | ||
48 | #endif | 48 | #endif |
diff --git a/tools/perf/util/sysfs.c b/tools/perf/util/sysfs.c deleted file mode 100644 index f71e9eafe15a..000000000000 --- a/tools/perf/util/sysfs.c +++ /dev/null | |||
@@ -1,60 +0,0 @@ | |||
1 | |||
2 | #include "util.h" | ||
3 | #include "sysfs.h" | ||
4 | |||
5 | static const char * const sysfs_known_mountpoints[] = { | ||
6 | "/sys", | ||
7 | 0, | ||
8 | }; | ||
9 | |||
10 | static int sysfs_found; | ||
11 | char sysfs_mountpoint[PATH_MAX + 1]; | ||
12 | |||
13 | static int sysfs_valid_mountpoint(const char *sysfs) | ||
14 | { | ||
15 | struct statfs st_fs; | ||
16 | |||
17 | if (statfs(sysfs, &st_fs) < 0) | ||
18 | return -ENOENT; | ||
19 | else if (st_fs.f_type != (long) SYSFS_MAGIC) | ||
20 | return -ENOENT; | ||
21 | |||
22 | return 0; | ||
23 | } | ||
24 | |||
25 | const char *sysfs_find_mountpoint(void) | ||
26 | { | ||
27 | const char * const *ptr; | ||
28 | char type[100]; | ||
29 | FILE *fp; | ||
30 | |||
31 | if (sysfs_found) | ||
32 | return (const char *) sysfs_mountpoint; | ||
33 | |||
34 | ptr = sysfs_known_mountpoints; | ||
35 | while (*ptr) { | ||
36 | if (sysfs_valid_mountpoint(*ptr) == 0) { | ||
37 | sysfs_found = 1; | ||
38 | strcpy(sysfs_mountpoint, *ptr); | ||
39 | return sysfs_mountpoint; | ||
40 | } | ||
41 | ptr++; | ||
42 | } | ||
43 | |||
44 | /* give up and parse /proc/mounts */ | ||
45 | fp = fopen("/proc/mounts", "r"); | ||
46 | if (fp == NULL) | ||
47 | return NULL; | ||
48 | |||
49 | while (!sysfs_found && | ||
50 | fscanf(fp, "%*s %" STR(PATH_MAX) "s %99s %*s %*d %*d\n", | ||
51 | sysfs_mountpoint, type) == 2) { | ||
52 | |||
53 | if (strcmp(type, "sysfs") == 0) | ||
54 | sysfs_found = 1; | ||
55 | } | ||
56 | |||
57 | fclose(fp); | ||
58 | |||
59 | return sysfs_found ? sysfs_mountpoint : NULL; | ||
60 | } | ||
diff --git a/tools/perf/util/sysfs.h b/tools/perf/util/sysfs.h deleted file mode 100644 index a813b7203938..000000000000 --- a/tools/perf/util/sysfs.h +++ /dev/null | |||
@@ -1,6 +0,0 @@ | |||
1 | #ifndef __SYSFS_H__ | ||
2 | #define __SYSFS_H__ | ||
3 | |||
4 | const char *sysfs_find_mountpoint(void); | ||
5 | |||
6 | #endif /* __DEBUGFS_H__ */ | ||
diff --git a/tools/perf/util/thread.h b/tools/perf/util/thread.h index 373c055989ed..897c1b2a750a 100644 --- a/tools/perf/util/thread.h +++ b/tools/perf/util/thread.h | |||
@@ -29,24 +29,24 @@ struct machine; | |||
29 | struct comm; | 29 | struct comm; |
30 | 30 | ||
31 | struct thread *thread__new(pid_t pid, pid_t tid); | 31 | struct thread *thread__new(pid_t pid, pid_t tid); |
32 | void thread__delete(struct thread *self); | 32 | void thread__delete(struct thread *thread); |
33 | static inline void thread__exited(struct thread *thread) | 33 | static inline void thread__exited(struct thread *thread) |
34 | { | 34 | { |
35 | thread->dead = true; | 35 | thread->dead = true; |
36 | } | 36 | } |
37 | 37 | ||
38 | int thread__set_comm(struct thread *thread, const char *comm, u64 timestamp); | 38 | int thread__set_comm(struct thread *thread, const char *comm, u64 timestamp); |
39 | int thread__comm_len(struct thread *self); | 39 | int thread__comm_len(struct thread *thread); |
40 | struct comm *thread__comm(const struct thread *thread); | 40 | struct comm *thread__comm(const struct thread *thread); |
41 | const char *thread__comm_str(const struct thread *thread); | 41 | const char *thread__comm_str(const struct thread *thread); |
42 | void thread__insert_map(struct thread *self, struct map *map); | 42 | void thread__insert_map(struct thread *thread, struct map *map); |
43 | int thread__fork(struct thread *thread, struct thread *parent, u64 timestamp); | 43 | int thread__fork(struct thread *thread, struct thread *parent, u64 timestamp); |
44 | size_t thread__fprintf(struct thread *thread, FILE *fp); | 44 | size_t thread__fprintf(struct thread *thread, FILE *fp); |
45 | 45 | ||
46 | static inline struct map *thread__find_map(struct thread *self, | 46 | static inline struct map *thread__find_map(struct thread *thread, |
47 | enum map_type type, u64 addr) | 47 | enum map_type type, u64 addr) |
48 | { | 48 | { |
49 | return self ? map_groups__find(&self->mg, type, addr) : NULL; | 49 | return thread ? map_groups__find(&thread->mg, type, addr) : NULL; |
50 | } | 50 | } |
51 | 51 | ||
52 | void thread__find_addr_map(struct thread *thread, struct machine *machine, | 52 | void thread__find_addr_map(struct thread *thread, struct machine *machine, |