aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--tools/perf/Makefile4
-rw-r--r--tools/perf/builtin-record.c152
-rw-r--r--tools/perf/builtin-stat.c368
-rw-r--r--tools/perf/builtin-test.c83
-rw-r--r--tools/perf/builtin-top.c221
-rw-r--r--tools/perf/perf.c2
-rw-r--r--tools/perf/util/cpumap.c123
-rw-r--r--tools/perf/util/cpumap.h10
-rw-r--r--tools/perf/util/evsel.c186
-rw-r--r--tools/perf/util/evsel.h115
-rw-r--r--tools/perf/util/header.c15
-rw-r--r--tools/perf/util/header.h3
-rw-r--r--tools/perf/util/parse-events.c58
-rw-r--r--tools/perf/util/parse-events.h18
-rw-r--r--tools/perf/util/session.c22
-rw-r--r--tools/perf/util/session.h1
-rw-r--r--tools/perf/util/thread.c43
-rw-r--r--tools/perf/util/thread.h15
-rw-r--r--tools/perf/util/trace-event-info.c30
-rw-r--r--tools/perf/util/trace-event.h5
-rw-r--r--tools/perf/util/util.c17
-rw-r--r--tools/perf/util/util.h1
-rw-r--r--tools/perf/util/xyarray.c20
-rw-r--r--tools/perf/util/xyarray.h20
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
396LIB_H += util/debug.h 396LIB_H += util/debug.h
397LIB_H += util/debugfs.h 397LIB_H += util/debugfs.h
398LIB_H += util/event.h 398LIB_H += util/event.h
399LIB_H += util/evsel.h
399LIB_H += util/exec_cmd.h 400LIB_H += util/exec_cmd.h
400LIB_H += util/types.h 401LIB_H += util/types.h
401LIB_H += util/levenshtein.h 402LIB_H += util/levenshtein.h
@@ -404,6 +405,7 @@ LIB_H += util/parse-options.h
404LIB_H += util/parse-events.h 405LIB_H += util/parse-events.h
405LIB_H += util/quote.h 406LIB_H += util/quote.h
406LIB_H += util/util.h 407LIB_H += util/util.h
408LIB_H += util/xyarray.h
407LIB_H += util/header.h 409LIB_H += util/header.h
408LIB_H += util/help.h 410LIB_H += util/help.h
409LIB_H += util/session.h 411LIB_H += util/session.h
@@ -433,6 +435,7 @@ LIB_OBJS += $(OUTPUT)util/ctype.o
433LIB_OBJS += $(OUTPUT)util/debugfs.o 435LIB_OBJS += $(OUTPUT)util/debugfs.o
434LIB_OBJS += $(OUTPUT)util/environment.o 436LIB_OBJS += $(OUTPUT)util/environment.o
435LIB_OBJS += $(OUTPUT)util/event.o 437LIB_OBJS += $(OUTPUT)util/event.o
438LIB_OBJS += $(OUTPUT)util/evsel.o
436LIB_OBJS += $(OUTPUT)util/exec_cmd.o 439LIB_OBJS += $(OUTPUT)util/exec_cmd.o
437LIB_OBJS += $(OUTPUT)util/help.o 440LIB_OBJS += $(OUTPUT)util/help.o
438LIB_OBJS += $(OUTPUT)util/levenshtein.o 441LIB_OBJS += $(OUTPUT)util/levenshtein.o
@@ -470,6 +473,7 @@ LIB_OBJS += $(OUTPUT)util/sort.o
470LIB_OBJS += $(OUTPUT)util/hist.o 473LIB_OBJS += $(OUTPUT)util/hist.o
471LIB_OBJS += $(OUTPUT)util/probe-event.o 474LIB_OBJS += $(OUTPUT)util/probe-event.o
472LIB_OBJS += $(OUTPUT)util/util.o 475LIB_OBJS += $(OUTPUT)util/util.o
476LIB_OBJS += $(OUTPUT)util/xyarray.o
473LIB_OBJS += $(OUTPUT)util/cpumap.o 477LIB_OBJS += $(OUTPUT)util/cpumap.o
474 478
475BUILTIN_OBJS += $(OUTPUT)builtin-annotate.o 479BUILTIN_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
30enum write_mode_t { 33enum write_mode_t {
31 WRITE_FORCE, 34 WRITE_FORCE,
32 WRITE_APPEND 35 WRITE_APPEND
33}; 36};
34 37
35static int *fd[MAX_NR_CPUS][MAX_COUNTERS];
36
37static u64 user_interval = ULLONG_MAX; 38static u64 user_interval = ULLONG_MAX;
38static u64 default_interval = 0; 39static u64 default_interval = 0;
39static u64 sample_type; 40static u64 sample_type;
40 41
41static int nr_cpus = 0; 42static struct cpu_map *cpus;
42static unsigned int page_size; 43static unsigned int page_size;
43static unsigned int mmap_pages = 128; 44static unsigned int mmap_pages = 128;
44static unsigned int user_freq = UINT_MAX; 45static unsigned int user_freq = UINT_MAX;
@@ -53,8 +54,7 @@ static bool sample_id_all_avail = true;
53static bool system_wide = false; 54static bool system_wide = false;
54static pid_t target_pid = -1; 55static pid_t target_pid = -1;
55static pid_t target_tid = -1; 56static pid_t target_tid = -1;
56static pid_t *all_tids = NULL; 57static struct thread_map *threads;
57static int thread_num = 0;
58static pid_t child_pid = -1; 58static pid_t child_pid = -1;
59static bool no_inherit = false; 59static bool no_inherit = false;
60static enum write_mode_t write_mode = WRITE_FORCE; 60static enum write_mode_t write_mode = WRITE_FORCE;
@@ -81,7 +81,6 @@ static struct perf_session *session;
81static const char *cpu_list; 81static const char *cpu_list;
82 82
83struct mmap_data { 83struct 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
232static void create_counter(int counter, int cpu) 231static 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)
318retry_sample_id: 317retry_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++) {
322try_again: 321try_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);