diff options
| -rw-r--r-- | tools/perf/Makefile | 4 | ||||
| -rw-r--r-- | tools/perf/builtin-record.c | 152 | ||||
| -rw-r--r-- | tools/perf/builtin-stat.c | 368 | ||||
| -rw-r--r-- | tools/perf/builtin-test.c | 83 | ||||
| -rw-r--r-- | tools/perf/builtin-top.c | 221 | ||||
| -rw-r--r-- | tools/perf/perf.c | 2 | ||||
| -rw-r--r-- | tools/perf/util/cpumap.c | 123 | ||||
| -rw-r--r-- | tools/perf/util/cpumap.h | 10 | ||||
| -rw-r--r-- | tools/perf/util/evsel.c | 186 | ||||
| -rw-r--r-- | tools/perf/util/evsel.h | 115 | ||||
| -rw-r--r-- | tools/perf/util/header.c | 15 | ||||
| -rw-r--r-- | tools/perf/util/header.h | 3 | ||||
| -rw-r--r-- | tools/perf/util/parse-events.c | 58 | ||||
| -rw-r--r-- | tools/perf/util/parse-events.h | 18 | ||||
| -rw-r--r-- | tools/perf/util/session.c | 22 | ||||
| -rw-r--r-- | tools/perf/util/session.h | 1 | ||||
| -rw-r--r-- | tools/perf/util/thread.c | 43 | ||||
| -rw-r--r-- | tools/perf/util/thread.h | 15 | ||||
| -rw-r--r-- | tools/perf/util/trace-event-info.c | 30 | ||||
| -rw-r--r-- | tools/perf/util/trace-event.h | 5 | ||||
| -rw-r--r-- | tools/perf/util/util.c | 17 | ||||
| -rw-r--r-- | tools/perf/util/util.h | 1 | ||||
| -rw-r--r-- | tools/perf/util/xyarray.c | 20 | ||||
| -rw-r--r-- | tools/perf/util/xyarray.h | 20 |
24 files changed, 1013 insertions, 519 deletions
diff --git a/tools/perf/Makefile b/tools/perf/Makefile index ac6692cf5508..1b9b13ee2a72 100644 --- a/tools/perf/Makefile +++ b/tools/perf/Makefile | |||
| @@ -396,6 +396,7 @@ LIB_H += util/build-id.h | |||
| 396 | LIB_H += util/debug.h | 396 | LIB_H += util/debug.h |
| 397 | LIB_H += util/debugfs.h | 397 | LIB_H += util/debugfs.h |
| 398 | LIB_H += util/event.h | 398 | LIB_H += util/event.h |
| 399 | LIB_H += util/evsel.h | ||
| 399 | LIB_H += util/exec_cmd.h | 400 | LIB_H += util/exec_cmd.h |
| 400 | LIB_H += util/types.h | 401 | LIB_H += util/types.h |
| 401 | LIB_H += util/levenshtein.h | 402 | LIB_H += util/levenshtein.h |
| @@ -404,6 +405,7 @@ LIB_H += util/parse-options.h | |||
| 404 | LIB_H += util/parse-events.h | 405 | LIB_H += util/parse-events.h |
| 405 | LIB_H += util/quote.h | 406 | LIB_H += util/quote.h |
| 406 | LIB_H += util/util.h | 407 | LIB_H += util/util.h |
| 408 | LIB_H += util/xyarray.h | ||
| 407 | LIB_H += util/header.h | 409 | LIB_H += util/header.h |
| 408 | LIB_H += util/help.h | 410 | LIB_H += util/help.h |
| 409 | LIB_H += util/session.h | 411 | LIB_H += util/session.h |
| @@ -433,6 +435,7 @@ LIB_OBJS += $(OUTPUT)util/ctype.o | |||
| 433 | LIB_OBJS += $(OUTPUT)util/debugfs.o | 435 | LIB_OBJS += $(OUTPUT)util/debugfs.o |
| 434 | LIB_OBJS += $(OUTPUT)util/environment.o | 436 | LIB_OBJS += $(OUTPUT)util/environment.o |
| 435 | LIB_OBJS += $(OUTPUT)util/event.o | 437 | LIB_OBJS += $(OUTPUT)util/event.o |
| 438 | LIB_OBJS += $(OUTPUT)util/evsel.o | ||
| 436 | LIB_OBJS += $(OUTPUT)util/exec_cmd.o | 439 | LIB_OBJS += $(OUTPUT)util/exec_cmd.o |
| 437 | LIB_OBJS += $(OUTPUT)util/help.o | 440 | LIB_OBJS += $(OUTPUT)util/help.o |
| 438 | LIB_OBJS += $(OUTPUT)util/levenshtein.o | 441 | LIB_OBJS += $(OUTPUT)util/levenshtein.o |
| @@ -470,6 +473,7 @@ LIB_OBJS += $(OUTPUT)util/sort.o | |||
| 470 | LIB_OBJS += $(OUTPUT)util/hist.o | 473 | LIB_OBJS += $(OUTPUT)util/hist.o |
| 471 | LIB_OBJS += $(OUTPUT)util/probe-event.o | 474 | LIB_OBJS += $(OUTPUT)util/probe-event.o |
| 472 | LIB_OBJS += $(OUTPUT)util/util.o | 475 | LIB_OBJS += $(OUTPUT)util/util.o |
| 476 | LIB_OBJS += $(OUTPUT)util/xyarray.o | ||
| 473 | LIB_OBJS += $(OUTPUT)util/cpumap.o | 477 | LIB_OBJS += $(OUTPUT)util/cpumap.o |
| 474 | 478 | ||
| 475 | BUILTIN_OBJS += $(OUTPUT)builtin-annotate.o | 479 | BUILTIN_OBJS += $(OUTPUT)builtin-annotate.o |
diff --git a/tools/perf/builtin-record.c b/tools/perf/builtin-record.c index 50efbd509b8f..7bc049035484 100644 --- a/tools/perf/builtin-record.c +++ b/tools/perf/builtin-record.c | |||
| @@ -18,6 +18,7 @@ | |||
| 18 | 18 | ||
| 19 | #include "util/header.h" | 19 | #include "util/header.h" |
| 20 | #include "util/event.h" | 20 | #include "util/event.h" |
| 21 | #include "util/evsel.h" | ||
| 21 | #include "util/debug.h" | 22 | #include "util/debug.h" |
| 22 | #include "util/session.h" | 23 | #include "util/session.h" |
| 23 | #include "util/symbol.h" | 24 | #include "util/symbol.h" |
| @@ -27,18 +28,18 @@ | |||
| 27 | #include <sched.h> | 28 | #include <sched.h> |
| 28 | #include <sys/mman.h> | 29 | #include <sys/mman.h> |
| 29 | 30 | ||
| 31 | #define FD(e, x, y) (*(int *)xyarray__entry(e->fd, x, y)) | ||
| 32 | |||
| 30 | enum write_mode_t { | 33 | enum write_mode_t { |
| 31 | WRITE_FORCE, | 34 | WRITE_FORCE, |
| 32 | WRITE_APPEND | 35 | WRITE_APPEND |
| 33 | }; | 36 | }; |
| 34 | 37 | ||
| 35 | static int *fd[MAX_NR_CPUS][MAX_COUNTERS]; | ||
| 36 | |||
| 37 | static u64 user_interval = ULLONG_MAX; | 38 | static u64 user_interval = ULLONG_MAX; |
| 38 | static u64 default_interval = 0; | 39 | static u64 default_interval = 0; |
| 39 | static u64 sample_type; | 40 | static u64 sample_type; |
| 40 | 41 | ||
| 41 | static int nr_cpus = 0; | 42 | static struct cpu_map *cpus; |
| 42 | static unsigned int page_size; | 43 | static unsigned int page_size; |
| 43 | static unsigned int mmap_pages = 128; | 44 | static unsigned int mmap_pages = 128; |
| 44 | static unsigned int user_freq = UINT_MAX; | 45 | static unsigned int user_freq = UINT_MAX; |
| @@ -53,8 +54,7 @@ static bool sample_id_all_avail = true; | |||
| 53 | static bool system_wide = false; | 54 | static bool system_wide = false; |
| 54 | static pid_t target_pid = -1; | 55 | static pid_t target_pid = -1; |
| 55 | static pid_t target_tid = -1; | 56 | static pid_t target_tid = -1; |
| 56 | static pid_t *all_tids = NULL; | 57 | static struct thread_map *threads; |
| 57 | static int thread_num = 0; | ||
| 58 | static pid_t child_pid = -1; | 58 | static pid_t child_pid = -1; |
| 59 | static bool no_inherit = false; | 59 | static bool no_inherit = false; |
| 60 | static enum write_mode_t write_mode = WRITE_FORCE; | 60 | static enum write_mode_t write_mode = WRITE_FORCE; |
| @@ -81,7 +81,6 @@ static struct perf_session *session; | |||
| 81 | static const char *cpu_list; | 81 | static const char *cpu_list; |
| 82 | 82 | ||
| 83 | struct mmap_data { | 83 | struct mmap_data { |
| 84 | int counter; | ||
| 85 | void *base; | 84 | void *base; |
| 86 | unsigned int mask; | 85 | unsigned int mask; |
| 87 | unsigned int prev; | 86 | unsigned int prev; |
| @@ -229,12 +228,12 @@ static struct perf_header_attr *get_header_attr(struct perf_event_attr *a, int n | |||
| 229 | return h_attr; | 228 | return h_attr; |
| 230 | } | 229 | } |
| 231 | 230 | ||
| 232 | static void create_counter(int counter, int cpu) | 231 | static void create_counter(struct perf_evsel *evsel, int cpu) |
| 233 | { | 232 | { |
| 234 | char *filter = filters[counter]; | 233 | char *filter = evsel->filter; |
| 235 | struct perf_event_attr *attr = attrs + counter; | 234 | struct perf_event_attr *attr = &evsel->attr; |
| 236 | struct perf_header_attr *h_attr; | 235 | struct perf_header_attr *h_attr; |
| 237 | int track = !counter; /* only the first counter needs these */ | 236 | int track = !evsel->idx; /* only the first counter needs these */ |
| 238 | int thread_index; | 237 | int thread_index; |
| 239 | int ret; | 238 | int ret; |
| 240 | struct { | 239 | struct { |
| @@ -318,12 +317,11 @@ static void create_counter(int counter, int cpu) | |||
| 318 | retry_sample_id: | 317 | retry_sample_id: |
| 319 | attr->sample_id_all = sample_id_all_avail ? 1 : 0; | 318 | attr->sample_id_all = sample_id_all_avail ? 1 : 0; |
| 320 | 319 | ||
| 321 | for (thread_index = 0; thread_index < thread_num; thread_index++) { | 320 | for (thread_index = 0; thread_index < threads->nr; thread_index++) { |
| 322 | try_again: | 321 | try_again: |
| 323 | fd[nr_cpu][counter][thread_index] = sys_perf_event_open(attr, | 322 | FD(evsel, nr_cpu, thread_index) = sys_perf_event_open(attr, threads->map[thread_index], cpu, group_fd, 0); |
| 324 | all_tids[thread_index], cpu, group_fd, 0); | ||
| 325 | 323 | ||
| 326 | if (fd[nr_cpu][counter][thread_index] < 0) { | 324 | if (FD(evsel, nr_cpu, thread_index) < 0) { |
| 327 | int err = errno; | 325 | int err = errno; |
| 328 | 326 | ||
| 329 | if (err == EPERM || err == EACCES) | 327 | if (err == EPERM || err == EACCES) |
| @@ -360,7 +358,7 @@ try_again: | |||
| 360 | } | 358 | } |
| 361 | printf("\n"); | 359 | printf("\n"); |
| 362 | error("sys_perf_event_open() syscall returned with %d (%s). /bin/dmesg may provide additional information.\n", | 360 | error("sys_perf_event_open() syscall returned with %d (%s). /bin/dmesg may provide additional information.\n", |
| 363 | fd[nr_cpu][counter][thread_index], strerror(err)); | 361 | FD(evsel, nr_cpu, thread_index), strerror(err)); |
| 364 | 362 | ||
| 365 | #if defined(__i386__) || defined(__x86_64__) | 363 | #if defined(__i386__) || defined(__x86_64__) |
| 366 | if (attr->type == PERF_TYPE_HARDWARE && err == EOPNOTSUPP) | 364 | if (attr->type == PERF_TYPE_HARDWARE && err == EOPNOTSUPP) |
| @@ -374,7 +372,7 @@ try_again: | |||
| 374 | exit(-1); | 372 | exit(-1); |
