blob: 448a13b520150e16ce777d25a103dbcac5093254 [file] [log] [blame]
Frederic Weisbecker1b290d62009-11-23 15:42:35 +01001#include "../../../include/linux/hw_breakpoint.h"
Ingo Molnar8ad8db32009-05-26 11:10:09 +02002#include "util.h"
Ulrich Drepper6b58e7f2009-09-04 16:39:51 -03003#include "../perf.h"
Ingo Molnar8ad8db32009-05-26 11:10:09 +02004#include "parse-options.h"
5#include "parse-events.h"
6#include "exec_cmd.h"
Arnaldo Carvalho de Meloa0055ae2009-06-01 17:50:19 -03007#include "string.h"
Jason Baron5beeded2009-07-21 14:16:29 -04008#include "cache.h"
Arjan van de Ven8755a8f2009-09-12 07:52:51 +02009#include "header.h"
Clark Williams549104f2009-11-08 09:03:07 -060010#include "debugfs.h"
Ingo Molnar8ad8db32009-05-26 11:10:09 +020011
Li Zefanc171b552009-10-15 11:22:07 +080012int nr_counters;
Ingo Molnar8ad8db32009-05-26 11:10:09 +020013
Ingo Molnarcdd6c482009-09-21 12:02:48 +020014struct perf_event_attr attrs[MAX_COUNTERS];
Li Zefanc171b552009-10-15 11:22:07 +080015char *filters[MAX_COUNTERS];
Ingo Molnar8ad8db32009-05-26 11:10:09 +020016
17struct event_symbol {
Ingo Molnar83a09442009-08-15 12:26:57 +020018 u8 type;
19 u64 config;
20 const char *symbol;
21 const char *alias;
Ingo Molnar8ad8db32009-05-26 11:10:09 +020022};
23
Frederic Weisbeckerbcd32792009-09-11 23:19:45 +020024enum event_result {
25 EVT_FAILED,
26 EVT_HANDLED,
27 EVT_HANDLED_ALL
28};
29
Jason Baron5beeded2009-07-21 14:16:29 -040030char debugfs_path[MAXPATHLEN];
31
Jaswinder Singh Rajput51e26842009-06-22 16:43:14 +053032#define CHW(x) .type = PERF_TYPE_HARDWARE, .config = PERF_COUNT_HW_##x
33#define CSW(x) .type = PERF_TYPE_SOFTWARE, .config = PERF_COUNT_SW_##x
Ingo Molnar8ad8db32009-05-26 11:10:09 +020034
Ingo Molnara21ca2c2009-06-06 09:58:57 +020035static struct event_symbol event_symbols[] = {
Jaswinder Singh Rajput74d5b582009-06-22 16:44:28 +053036 { CHW(CPU_CYCLES), "cpu-cycles", "cycles" },
37 { CHW(INSTRUCTIONS), "instructions", "" },
38 { CHW(CACHE_REFERENCES), "cache-references", "" },
39 { CHW(CACHE_MISSES), "cache-misses", "" },
40 { CHW(BRANCH_INSTRUCTIONS), "branch-instructions", "branches" },
41 { CHW(BRANCH_MISSES), "branch-misses", "" },
42 { CHW(BUS_CYCLES), "bus-cycles", "" },
Ingo Molnara21ca2c2009-06-06 09:58:57 +020043
Jaswinder Singh Rajput74d5b582009-06-22 16:44:28 +053044 { CSW(CPU_CLOCK), "cpu-clock", "" },
45 { CSW(TASK_CLOCK), "task-clock", "" },
Jaswinder Singh Rajputc0c22db2009-06-22 20:47:26 +053046 { CSW(PAGE_FAULTS), "page-faults", "faults" },
Jaswinder Singh Rajput74d5b582009-06-22 16:44:28 +053047 { CSW(PAGE_FAULTS_MIN), "minor-faults", "" },
48 { CSW(PAGE_FAULTS_MAJ), "major-faults", "" },
49 { CSW(CONTEXT_SWITCHES), "context-switches", "cs" },
50 { CSW(CPU_MIGRATIONS), "cpu-migrations", "migrations" },
Anton Blanchardf7d79862009-10-18 01:09:29 +000051 { CSW(ALIGNMENT_FAULTS), "alignment-faults", "" },
52 { CSW(EMULATION_FAULTS), "emulation-faults", "" },
Ingo Molnar8ad8db32009-05-26 11:10:09 +020053};
54
Ingo Molnarcdd6c482009-09-21 12:02:48 +020055#define __PERF_EVENT_FIELD(config, name) \
56 ((config & PERF_EVENT_##name##_MASK) >> PERF_EVENT_##name##_SHIFT)
Ingo Molnar52425192009-05-26 09:17:18 +020057
Ingo Molnarcdd6c482009-09-21 12:02:48 +020058#define PERF_EVENT_RAW(config) __PERF_EVENT_FIELD(config, RAW)
59#define PERF_EVENT_CONFIG(config) __PERF_EVENT_FIELD(config, CONFIG)
60#define PERF_EVENT_TYPE(config) __PERF_EVENT_FIELD(config, TYPE)
61#define PERF_EVENT_ID(config) __PERF_EVENT_FIELD(config, EVENT)
Ingo Molnar52425192009-05-26 09:17:18 +020062
Ingo Molnar83a09442009-08-15 12:26:57 +020063static const char *hw_event_names[] = {
Ingo Molnar8faf3b52009-06-06 13:58:12 +020064 "cycles",
Ingo Molnar52425192009-05-26 09:17:18 +020065 "instructions",
Ingo Molnar8faf3b52009-06-06 13:58:12 +020066 "cache-references",
67 "cache-misses",
Ingo Molnar52425192009-05-26 09:17:18 +020068 "branches",
Ingo Molnar8faf3b52009-06-06 13:58:12 +020069 "branch-misses",
70 "bus-cycles",
Ingo Molnar52425192009-05-26 09:17:18 +020071};
72
Ingo Molnar83a09442009-08-15 12:26:57 +020073static const char *sw_event_names[] = {
Ingo Molnar44175b62009-06-13 13:35:00 +020074 "cpu-clock-msecs",
75 "task-clock-msecs",
Ingo Molnar8faf3b52009-06-06 13:58:12 +020076 "page-faults",
77 "context-switches",
78 "CPU-migrations",
79 "minor-faults",
80 "major-faults",
Anton Blanchardf7d79862009-10-18 01:09:29 +000081 "alignment-faults",
82 "emulation-faults",
Ingo Molnar52425192009-05-26 09:17:18 +020083};
84
Ingo Molnar8326f442009-06-05 20:22:46 +020085#define MAX_ALIASES 8
86
Ingo Molnar83a09442009-08-15 12:26:57 +020087static const char *hw_cache[][MAX_ALIASES] = {
Anton Blanchard9590b7b2009-07-06 22:01:31 +100088 { "L1-dcache", "l1-d", "l1d", "L1-data", },
89 { "L1-icache", "l1-i", "l1i", "L1-instruction", },
Jaswinder Singh Rajpute5c59542009-06-25 18:25:22 +053090 { "LLC", "L2" },
91 { "dTLB", "d-tlb", "Data-TLB", },
92 { "iTLB", "i-tlb", "Instruction-TLB", },
93 { "branch", "branches", "bpu", "btb", "bpc", },
Ingo Molnar8326f442009-06-05 20:22:46 +020094};
95
Ingo Molnar83a09442009-08-15 12:26:57 +020096static const char *hw_cache_op[][MAX_ALIASES] = {
Jaswinder Singh Rajpute5c59542009-06-25 18:25:22 +053097 { "load", "loads", "read", },
98 { "store", "stores", "write", },
99 { "prefetch", "prefetches", "speculative-read", "speculative-load", },
Ingo Molnar8326f442009-06-05 20:22:46 +0200100};
101
Ingo Molnar83a09442009-08-15 12:26:57 +0200102static const char *hw_cache_result[][MAX_ALIASES] = {
Jaswinder Singh Rajpute5c59542009-06-25 18:25:22 +0530103 { "refs", "Reference", "ops", "access", },
104 { "misses", "miss", },
Ingo Molnar8326f442009-06-05 20:22:46 +0200105};
106
Jaswinder Singh Rajput06813f62009-06-25 17:16:07 +0530107#define C(x) PERF_COUNT_HW_CACHE_##x
108#define CACHE_READ (1 << C(OP_READ))
109#define CACHE_WRITE (1 << C(OP_WRITE))
110#define CACHE_PREFETCH (1 << C(OP_PREFETCH))
111#define COP(x) (1 << x)
112
113/*
114 * cache operartion stat
115 * L1I : Read and prefetch only
116 * ITLB and BPU : Read-only
117 */
118static unsigned long hw_cache_stat[C(MAX)] = {
119 [C(L1D)] = (CACHE_READ | CACHE_WRITE | CACHE_PREFETCH),
120 [C(L1I)] = (CACHE_READ | CACHE_PREFETCH),
121 [C(LL)] = (CACHE_READ | CACHE_WRITE | CACHE_PREFETCH),
122 [C(DTLB)] = (CACHE_READ | CACHE_WRITE | CACHE_PREFETCH),
123 [C(ITLB)] = (CACHE_READ),
124 [C(BPU)] = (CACHE_READ),
125};
126
Ulrich Drepper6b58e7f2009-09-04 16:39:51 -0300127#define for_each_subsystem(sys_dir, sys_dirent, sys_next) \
Jason Baronf6bdafe2009-07-21 12:20:22 -0400128 while (!readdir_r(sys_dir, &sys_dirent, &sys_next) && sys_next) \
Ulrich Drepper6b58e7f2009-09-04 16:39:51 -0300129 if (sys_dirent.d_type == DT_DIR && \
Jason Baronf6bdafe2009-07-21 12:20:22 -0400130 (strcmp(sys_dirent.d_name, ".")) && \
131 (strcmp(sys_dirent.d_name, "..")))
132
Peter Zijlstraae07b632009-08-06 16:48:54 +0200133static int tp_event_has_id(struct dirent *sys_dir, struct dirent *evt_dir)
134{
135 char evt_path[MAXPATHLEN];
136 int fd;
137
138 snprintf(evt_path, MAXPATHLEN, "%s/%s/%s/id", debugfs_path,
139 sys_dir->d_name, evt_dir->d_name);
140 fd = open(evt_path, O_RDONLY);
141 if (fd < 0)
142 return -EINVAL;
143 close(fd);
144
145 return 0;
146}
147
Ulrich Drepper6b58e7f2009-09-04 16:39:51 -0300148#define for_each_event(sys_dirent, evt_dir, evt_dirent, evt_next) \
Jason Baronf6bdafe2009-07-21 12:20:22 -0400149 while (!readdir_r(evt_dir, &evt_dirent, &evt_next) && evt_next) \
Ulrich Drepper6b58e7f2009-09-04 16:39:51 -0300150 if (evt_dirent.d_type == DT_DIR && \
Jason Baronf6bdafe2009-07-21 12:20:22 -0400151 (strcmp(evt_dirent.d_name, ".")) && \
Peter Zijlstraae07b632009-08-06 16:48:54 +0200152 (strcmp(evt_dirent.d_name, "..")) && \
153 (!tp_event_has_id(&sys_dirent, &evt_dirent)))
Jason Baronf6bdafe2009-07-21 12:20:22 -0400154
Li Zefan270bbbe2009-09-17 16:34:51 +0800155#define MAX_EVENT_LENGTH 512
Jason Baronf6bdafe2009-07-21 12:20:22 -0400156
Jason Baronf6bdafe2009-07-21 12:20:22 -0400157
Frederic Weisbecker1ef2ed12009-08-28 03:09:58 +0200158struct tracepoint_path *tracepoint_id_to_path(u64 config)
Jason Baronf6bdafe2009-07-21 12:20:22 -0400159{
Frederic Weisbecker1ef2ed12009-08-28 03:09:58 +0200160 struct tracepoint_path *path = NULL;
Jason Baronf6bdafe2009-07-21 12:20:22 -0400161 DIR *sys_dir, *evt_dir;
162 struct dirent *sys_next, *evt_next, sys_dirent, evt_dirent;
Jason Baronf6bdafe2009-07-21 12:20:22 -0400163 char id_buf[4];
Eric Dumazet725b1362009-09-24 15:39:09 +0200164 int fd;
Jason Baronf6bdafe2009-07-21 12:20:22 -0400165 u64 id;
166 char evt_path[MAXPATHLEN];
Eric Dumazet725b1362009-09-24 15:39:09 +0200167 char dir_path[MAXPATHLEN];
Jason Baronf6bdafe2009-07-21 12:20:22 -0400168
Clark Williams549104f2009-11-08 09:03:07 -0600169 if (debugfs_valid_mountpoint(debugfs_path))
Frederic Weisbecker1ef2ed12009-08-28 03:09:58 +0200170 return NULL;
Jason Baronf6bdafe2009-07-21 12:20:22 -0400171
Jason Baron5beeded2009-07-21 14:16:29 -0400172 sys_dir = opendir(debugfs_path);
Jason Baronf6bdafe2009-07-21 12:20:22 -0400173 if (!sys_dir)
Eric Dumazet725b1362009-09-24 15:39:09 +0200174 return NULL;
Jason Baronf6bdafe2009-07-21 12:20:22 -0400175
Ulrich Drepper6b58e7f2009-09-04 16:39:51 -0300176 for_each_subsystem(sys_dir, sys_dirent, sys_next) {
Eric Dumazet725b1362009-09-24 15:39:09 +0200177
178 snprintf(dir_path, MAXPATHLEN, "%s/%s", debugfs_path,
179 sys_dirent.d_name);
180 evt_dir = opendir(dir_path);
181 if (!evt_dir)
Ulrich Drepper6b58e7f2009-09-04 16:39:51 -0300182 continue;
Eric Dumazet725b1362009-09-24 15:39:09 +0200183
Ulrich Drepper6b58e7f2009-09-04 16:39:51 -0300184 for_each_event(sys_dirent, evt_dir, evt_dirent, evt_next) {
Eric Dumazet725b1362009-09-24 15:39:09 +0200185
186 snprintf(evt_path, MAXPATHLEN, "%s/%s/id", dir_path,
Jason Baronf6bdafe2009-07-21 12:20:22 -0400187 evt_dirent.d_name);
Eric Dumazet725b1362009-09-24 15:39:09 +0200188 fd = open(evt_path, O_RDONLY);
Jason Baronf6bdafe2009-07-21 12:20:22 -0400189 if (fd < 0)
190 continue;
191 if (read(fd, id_buf, sizeof(id_buf)) < 0) {
192 close(fd);
193 continue;
194 }
195 close(fd);
196 id = atoll(id_buf);
197 if (id == config) {
198 closedir(evt_dir);
199 closedir(sys_dir);
Julia Lawall59b4cae2009-12-06 10:16:30 +0100200 path = zalloc(sizeof(*path));
Frederic Weisbecker1ef2ed12009-08-28 03:09:58 +0200201 path->system = malloc(MAX_EVENT_LENGTH);
202 if (!path->system) {
203 free(path);
204 return NULL;
205 }
206 path->name = malloc(MAX_EVENT_LENGTH);
207 if (!path->name) {
208 free(path->system);
209 free(path);
210 return NULL;
211 }
212 strncpy(path->system, sys_dirent.d_name,
213 MAX_EVENT_LENGTH);
214 strncpy(path->name, evt_dirent.d_name,
215 MAX_EVENT_LENGTH);
216 return path;
Jason Baronf6bdafe2009-07-21 12:20:22 -0400217 }
218 }
219 closedir(evt_dir);
220 }
221
Jason Baronf6bdafe2009-07-21 12:20:22 -0400222 closedir(sys_dir);
Frederic Weisbecker1ef2ed12009-08-28 03:09:58 +0200223 return NULL;
224}
225
226#define TP_PATH_LEN (MAX_EVENT_LENGTH * 2 + 1)
227static const char *tracepoint_id_to_name(u64 config)
228{
229 static char buf[TP_PATH_LEN];
230 struct tracepoint_path *path;
231
232 path = tracepoint_id_to_path(config);
233 if (path) {
234 snprintf(buf, TP_PATH_LEN, "%s:%s", path->system, path->name);
235 free(path->name);
236 free(path->system);
237 free(path);
238 } else
239 snprintf(buf, TP_PATH_LEN, "%s:%s", "unknown", "unknown");
240
241 return buf;
Jason Baronf6bdafe2009-07-21 12:20:22 -0400242}
243
Jaswinder Singh Rajput06813f62009-06-25 17:16:07 +0530244static int is_cache_op_valid(u8 cache_type, u8 cache_op)
245{
246 if (hw_cache_stat[cache_type] & COP(cache_op))
247 return 1; /* valid */
248 else
249 return 0; /* invalid */
250}
251
Jaswinder Singh Rajpute5c59542009-06-25 18:25:22 +0530252static char *event_cache_name(u8 cache_type, u8 cache_op, u8 cache_result)
253{
254 static char name[50];
255
256 if (cache_result) {
257 sprintf(name, "%s-%s-%s", hw_cache[cache_type][0],
258 hw_cache_op[cache_op][0],
259 hw_cache_result[cache_result][0]);
260 } else {
261 sprintf(name, "%s-%s", hw_cache[cache_type][0],
262 hw_cache_op[cache_op][1]);
263 }
264
265 return name;
266}
267
Ingo Molnar83a09442009-08-15 12:26:57 +0200268const char *event_name(int counter)
Ingo Molnar52425192009-05-26 09:17:18 +0200269{
Paul Mackerras9cffa8d2009-06-19 22:21:42 +1000270 u64 config = attrs[counter].config;
Ingo Molnara21ca2c2009-06-06 09:58:57 +0200271 int type = attrs[counter].type;
Peter Zijlstra8f18aec2009-08-06 19:40:28 +0200272
273 return __event_name(type, config);
274}
275
Ingo Molnar83a09442009-08-15 12:26:57 +0200276const char *__event_name(int type, u64 config)
Peter Zijlstra8f18aec2009-08-06 19:40:28 +0200277{
Ingo Molnar52425192009-05-26 09:17:18 +0200278 static char buf[32];
279
Peter Zijlstra8f18aec2009-08-06 19:40:28 +0200280 if (type == PERF_TYPE_RAW) {
Ingo Molnara21ca2c2009-06-06 09:58:57 +0200281 sprintf(buf, "raw 0x%llx", config);
Ingo Molnar52425192009-05-26 09:17:18 +0200282 return buf;
283 }
284
285 switch (type) {
286 case PERF_TYPE_HARDWARE:
Peter Zijlstraf4dbfa82009-06-11 14:06:28 +0200287 if (config < PERF_COUNT_HW_MAX)
Ingo Molnara21ca2c2009-06-06 09:58:57 +0200288 return hw_event_names[config];
Ingo Molnar52425192009-05-26 09:17:18 +0200289 return "unknown-hardware";
290
Ingo Molnar8326f442009-06-05 20:22:46 +0200291 case PERF_TYPE_HW_CACHE: {
Paul Mackerras9cffa8d2009-06-19 22:21:42 +1000292 u8 cache_type, cache_op, cache_result;
Ingo Molnar8326f442009-06-05 20:22:46 +0200293
294 cache_type = (config >> 0) & 0xff;
295 if (cache_type > PERF_COUNT_HW_CACHE_MAX)
296 return "unknown-ext-hardware-cache-type";
297
298 cache_op = (config >> 8) & 0xff;
Ingo Molnar8faf3b52009-06-06 13:58:12 +0200299 if (cache_op > PERF_COUNT_HW_CACHE_OP_MAX)
300 return "unknown-ext-hardware-cache-op";
Ingo Molnar8326f442009-06-05 20:22:46 +0200301
302 cache_result = (config >> 16) & 0xff;
Ingo Molnar8faf3b52009-06-06 13:58:12 +0200303 if (cache_result > PERF_COUNT_HW_CACHE_RESULT_MAX)
304 return "unknown-ext-hardware-cache-result";
Ingo Molnar8326f442009-06-05 20:22:46 +0200305
Jaswinder Singh Rajput06813f62009-06-25 17:16:07 +0530306 if (!is_cache_op_valid(cache_type, cache_op))
307 return "invalid-cache";
Ingo Molnar8326f442009-06-05 20:22:46 +0200308
Jaswinder Singh Rajpute5c59542009-06-25 18:25:22 +0530309 return event_cache_name(cache_type, cache_op, cache_result);
Ingo Molnar8326f442009-06-05 20:22:46 +0200310 }
311
Ingo Molnar52425192009-05-26 09:17:18 +0200312 case PERF_TYPE_SOFTWARE:
Peter Zijlstraf4dbfa82009-06-11 14:06:28 +0200313 if (config < PERF_COUNT_SW_MAX)
Ingo Molnara21ca2c2009-06-06 09:58:57 +0200314 return sw_event_names[config];
Ingo Molnar52425192009-05-26 09:17:18 +0200315 return "unknown-software";
316
Jason Baronf6bdafe2009-07-21 12:20:22 -0400317 case PERF_TYPE_TRACEPOINT:
318 return tracepoint_id_to_name(config);
319
Ingo Molnar52425192009-05-26 09:17:18 +0200320 default:
321 break;
322 }
323
324 return "unknown";
325}
326
Ingo Molnar83a09442009-08-15 12:26:57 +0200327static int parse_aliases(const char **str, const char *names[][MAX_ALIASES], int size)
Ingo Molnar8326f442009-06-05 20:22:46 +0200328{
329 int i, j;
Paul Mackerras61c45982009-07-01 13:04:34 +1000330 int n, longest = -1;
Ingo Molnar8326f442009-06-05 20:22:46 +0200331
332 for (i = 0; i < size; i++) {
Paul Mackerras61c45982009-07-01 13:04:34 +1000333 for (j = 0; j < MAX_ALIASES && names[i][j]; j++) {
334 n = strlen(names[i][j]);
335 if (n > longest && !strncasecmp(*str, names[i][j], n))
336 longest = n;
337 }
338 if (longest > 0) {
339 *str += longest;
340 return i;
Ingo Molnar8326f442009-06-05 20:22:46 +0200341 }
342 }
343
Ingo Molnar89536452009-06-06 21:04:17 +0200344 return -1;
Ingo Molnar8326f442009-06-05 20:22:46 +0200345}
346
Frederic Weisbeckerbcd32792009-09-11 23:19:45 +0200347static enum event_result
Ingo Molnarcdd6c482009-09-21 12:02:48 +0200348parse_generic_hw_event(const char **str, struct perf_event_attr *attr)
Ingo Molnar8326f442009-06-05 20:22:46 +0200349{
Paul Mackerras61c45982009-07-01 13:04:34 +1000350 const char *s = *str;
351 int cache_type = -1, cache_op = -1, cache_result = -1;
Ingo Molnar8326f442009-06-05 20:22:46 +0200352
Paul Mackerras61c45982009-07-01 13:04:34 +1000353 cache_type = parse_aliases(&s, hw_cache, PERF_COUNT_HW_CACHE_MAX);
Ingo Molnar8326f442009-06-05 20:22:46 +0200354 /*
355 * No fallback - if we cannot get a clear cache type
356 * then bail out:
357 */
358 if (cache_type == -1)
Frederic Weisbeckerbcd32792009-09-11 23:19:45 +0200359 return EVT_FAILED;
Ingo Molnar8326f442009-06-05 20:22:46 +0200360
Paul Mackerras61c45982009-07-01 13:04:34 +1000361 while ((cache_op == -1 || cache_result == -1) && *s == '-') {
362 ++s;
363
364 if (cache_op == -1) {
365 cache_op = parse_aliases(&s, hw_cache_op,
366 PERF_COUNT_HW_CACHE_OP_MAX);
367 if (cache_op >= 0) {
368 if (!is_cache_op_valid(cache_type, cache_op))
369 return 0;
370 continue;
371 }
372 }
373
374 if (cache_result == -1) {
375 cache_result = parse_aliases(&s, hw_cache_result,
376 PERF_COUNT_HW_CACHE_RESULT_MAX);
377 if (cache_result >= 0)
378 continue;
379 }
380
381 /*
382 * Can't parse this as a cache op or result, so back up
383 * to the '-'.
384 */
385 --s;
386 break;
387 }
388
Ingo Molnar8326f442009-06-05 20:22:46 +0200389 /*
390 * Fall back to reads:
391 */
Ingo Molnar89536452009-06-06 21:04:17 +0200392 if (cache_op == -1)
393 cache_op = PERF_COUNT_HW_CACHE_OP_READ;
Ingo Molnar8326f442009-06-05 20:22:46 +0200394
Ingo Molnar8326f442009-06-05 20:22:46 +0200395 /*
396 * Fall back to accesses:
397 */
398 if (cache_result == -1)
399 cache_result = PERF_COUNT_HW_CACHE_RESULT_ACCESS;
400
401 attr->config = cache_type | (cache_op << 8) | (cache_result << 16);
402 attr->type = PERF_TYPE_HW_CACHE;
403
Paul Mackerras61c45982009-07-01 13:04:34 +1000404 *str = s;
Frederic Weisbeckerbcd32792009-09-11 23:19:45 +0200405 return EVT_HANDLED;
Ingo Molnar8326f442009-06-05 20:22:46 +0200406}
407
Frederic Weisbeckerbcd32792009-09-11 23:19:45 +0200408static enum event_result
409parse_single_tracepoint_event(char *sys_name,
410 const char *evt_name,
411 unsigned int evt_length,
412 char *flags,
Ingo Molnarcdd6c482009-09-21 12:02:48 +0200413 struct perf_event_attr *attr,
Frederic Weisbeckerbcd32792009-09-11 23:19:45 +0200414 const char **strp)
415{
416 char evt_path[MAXPATHLEN];
417 char id_buf[4];
418 u64 id;
419 int fd;
420
421 if (flags) {
Li Zefan1281a492009-09-17 16:49:43 +0800422 if (!strncmp(flags, "record", strlen(flags))) {
Frederic Weisbeckerbcd32792009-09-11 23:19:45 +0200423 attr->sample_type |= PERF_SAMPLE_RAW;
Li Zefan1281a492009-09-17 16:49:43 +0800424 attr->sample_type |= PERF_SAMPLE_TIME;
425 attr->sample_type |= PERF_SAMPLE_CPU;
426 }
Frederic Weisbeckerbcd32792009-09-11 23:19:45 +0200427 }
428
429 snprintf(evt_path, MAXPATHLEN, "%s/%s/%s/id", debugfs_path,
430 sys_name, evt_name);
431
432 fd = open(evt_path, O_RDONLY);
433 if (fd < 0)
434 return EVT_FAILED;
435
436 if (read(fd, id_buf, sizeof(id_buf)) < 0) {
437 close(fd);
438 return EVT_FAILED;
439 }
440
441 close(fd);
442 id = atoll(id_buf);
443 attr->config = id;
444 attr->type = PERF_TYPE_TRACEPOINT;
445 *strp = evt_name + evt_length;
446
447 return EVT_HANDLED;
448}
449
450/* sys + ':' + event + ':' + flags*/
451#define MAX_EVOPT_LEN (MAX_EVENT_LENGTH * 2 + 2 + 128)
452static enum event_result
453parse_subsystem_tracepoint_event(char *sys_name, char *flags)
454{
455 char evt_path[MAXPATHLEN];
456 struct dirent *evt_ent;
457 DIR *evt_dir;
458
459 snprintf(evt_path, MAXPATHLEN, "%s/%s", debugfs_path, sys_name);
460 evt_dir = opendir(evt_path);
461
462 if (!evt_dir) {
463 perror("Can't open event dir");
464 return EVT_FAILED;
465 }
466
467 while ((evt_ent = readdir(evt_dir))) {
468 char event_opt[MAX_EVOPT_LEN + 1];
469 int len;
470 unsigned int rem = MAX_EVOPT_LEN;
471
472 if (!strcmp(evt_ent->d_name, ".")
473 || !strcmp(evt_ent->d_name, "..")
474 || !strcmp(evt_ent->d_name, "enable")
475 || !strcmp(evt_ent->d_name, "filter"))
476 continue;
477
478 len = snprintf(event_opt, MAX_EVOPT_LEN, "%s:%s", sys_name,
479 evt_ent->d_name);
480 if (len < 0)
481 return EVT_FAILED;
482
483 rem -= len;
484 if (flags) {
485 if (rem < strlen(flags) + 1)
486 return EVT_FAILED;
487
488 strcat(event_opt, ":");
489 strcat(event_opt, flags);
490 }
491
492 if (parse_events(NULL, event_opt, 0))
493 return EVT_FAILED;
494 }
495
496 return EVT_HANDLED_ALL;
497}
498
499
500static enum event_result parse_tracepoint_event(const char **strp,
Ingo Molnarcdd6c482009-09-21 12:02:48 +0200501 struct perf_event_attr *attr)
Jason Baronf6bdafe2009-07-21 12:20:22 -0400502{
503 const char *evt_name;
Frederic Weisbecker3a9f1312009-08-13 10:27:18 +0200504 char *flags;
Jason Baronf6bdafe2009-07-21 12:20:22 -0400505 char sys_name[MAX_EVENT_LENGTH];
Jason Baronf6bdafe2009-07-21 12:20:22 -0400506 unsigned int sys_length, evt_length;
Jason Baronf6bdafe2009-07-21 12:20:22 -0400507
Clark Williams549104f2009-11-08 09:03:07 -0600508 if (debugfs_valid_mountpoint(debugfs_path))
Jason Baronf6bdafe2009-07-21 12:20:22 -0400509 return 0;
510
511 evt_name = strchr(*strp, ':');
512 if (!evt_name)
Frederic Weisbeckerbcd32792009-09-11 23:19:45 +0200513 return EVT_FAILED;
Jason Baronf6bdafe2009-07-21 12:20:22 -0400514
515 sys_length = evt_name - *strp;
516 if (sys_length >= MAX_EVENT_LENGTH)
517 return 0;
518
519 strncpy(sys_name, *strp, sys_length);
520 sys_name[sys_length] = '\0';
521 evt_name = evt_name + 1;
Frederic Weisbecker3a9f1312009-08-13 10:27:18 +0200522
523 flags = strchr(evt_name, ':');
524 if (flags) {
Ingo Molnar1fc35b22009-09-13 09:44:29 +0200525 /* split it out: */
526 evt_name = strndup(evt_name, flags - evt_name);
Frederic Weisbecker3a9f1312009-08-13 10:27:18 +0200527 flags++;
Frederic Weisbecker3a9f1312009-08-13 10:27:18 +0200528 }
529
Jason Baronf6bdafe2009-07-21 12:20:22 -0400530 evt_length = strlen(evt_name);
531 if (evt_length >= MAX_EVENT_LENGTH)
Frederic Weisbeckerbcd32792009-09-11 23:19:45 +0200532 return EVT_FAILED;
Jason Baronf6bdafe2009-07-21 12:20:22 -0400533
Frederic Weisbeckerbcd32792009-09-11 23:19:45 +0200534 if (!strcmp(evt_name, "*")) {
535 *strp = evt_name + evt_length;
536 return parse_subsystem_tracepoint_event(sys_name, flags);
537 } else
538 return parse_single_tracepoint_event(sys_name, evt_name,
539 evt_length, flags,
540 attr, strp);
Jason Baronf6bdafe2009-07-21 12:20:22 -0400541}
542
Frederic Weisbecker1b290d62009-11-23 15:42:35 +0100543static enum event_result
544parse_breakpoint_type(const char *type, const char **strp,
545 struct perf_event_attr *attr)
546{
547 int i;
548
549 for (i = 0; i < 3; i++) {
550 if (!type[i])
551 break;
552
553 switch (type[i]) {
554 case 'r':
555 attr->bp_type |= HW_BREAKPOINT_R;
556 break;
557 case 'w':
558 attr->bp_type |= HW_BREAKPOINT_W;
559 break;
560 case 'x':
561 attr->bp_type |= HW_BREAKPOINT_X;
562 break;
563 default:
564 return EVT_FAILED;
565 }
566 }
567 if (!attr->bp_type) /* Default */
568 attr->bp_type = HW_BREAKPOINT_R | HW_BREAKPOINT_W;
569
570 *strp = type + i;
571
572 return EVT_HANDLED;
573}
574
575static enum event_result
576parse_breakpoint_event(const char **strp, struct perf_event_attr *attr)
577{
578 const char *target;
579 const char *type;
580 char *endaddr;
581 u64 addr;
582 enum event_result err;
583
584 target = strchr(*strp, ':');
585 if (!target)
586 return EVT_FAILED;
587
588 if (strncmp(*strp, "mem", target - *strp) != 0)
589 return EVT_FAILED;
590
591 target++;
592
593 addr = strtoull(target, &endaddr, 0);
594 if (target == endaddr)
595 return EVT_FAILED;
596
597 attr->bp_addr = addr;
598 *strp = endaddr;
599
600 type = strchr(target, ':');
601
602 /* If no type is defined, just rw as default */
603 if (!type) {
604 attr->bp_type = HW_BREAKPOINT_R | HW_BREAKPOINT_W;
605 } else {
606 err = parse_breakpoint_type(++type, strp, attr);
607 if (err == EVT_FAILED)
608 return EVT_FAILED;
609 }
610
611 /* We should find a nice way to override the access type */
612 attr->bp_len = HW_BREAKPOINT_LEN_4;
613 attr->type = PERF_TYPE_BREAKPOINT;
614
615 return EVT_HANDLED;
616}
617
Jaswinder Singh Rajput74d5b582009-06-22 16:44:28 +0530618static int check_events(const char *str, unsigned int i)
619{
Paul Mackerras61c45982009-07-01 13:04:34 +1000620 int n;
Jaswinder Singh Rajput74d5b582009-06-22 16:44:28 +0530621
Paul Mackerras61c45982009-07-01 13:04:34 +1000622 n = strlen(event_symbols[i].symbol);
623 if (!strncmp(str, event_symbols[i].symbol, n))
624 return n;
625
626 n = strlen(event_symbols[i].alias);
627 if (n)
628 if (!strncmp(str, event_symbols[i].alias, n))
629 return n;
630 return 0;
631}
632
Frederic Weisbeckerbcd32792009-09-11 23:19:45 +0200633static enum event_result
Ingo Molnarcdd6c482009-09-21 12:02:48 +0200634parse_symbolic_event(const char **strp, struct perf_event_attr *attr)
Paul Mackerras61c45982009-07-01 13:04:34 +1000635{
636 const char *str = *strp;
637 unsigned int i;
638 int n;
639
640 for (i = 0; i < ARRAY_SIZE(event_symbols); i++) {
641 n = check_events(str, i);
642 if (n > 0) {
643 attr->type = event_symbols[i].type;
644 attr->config = event_symbols[i].config;
645 *strp = str + n;
Frederic Weisbeckerbcd32792009-09-11 23:19:45 +0200646 return EVT_HANDLED;
Paul Mackerras61c45982009-07-01 13:04:34 +1000647 }
648 }
Frederic Weisbeckerbcd32792009-09-11 23:19:45 +0200649 return EVT_FAILED;
Paul Mackerras61c45982009-07-01 13:04:34 +1000650}
651
Frederic Weisbeckerbcd32792009-09-11 23:19:45 +0200652static enum event_result
Ingo Molnarcdd6c482009-09-21 12:02:48 +0200653parse_raw_event(const char **strp, struct perf_event_attr *attr)
Paul Mackerras61c45982009-07-01 13:04:34 +1000654{
655 const char *str = *strp;
656 u64 config;
657 int n;
658
659 if (*str != 'r')
Frederic Weisbeckerbcd32792009-09-11 23:19:45 +0200660 return EVT_FAILED;
Paul Mackerras61c45982009-07-01 13:04:34 +1000661 n = hex2u64(str + 1, &config);
662 if (n > 0) {
663 *strp = str + n + 1;
664 attr->type = PERF_TYPE_RAW;
665 attr->config = config;
Frederic Weisbeckerbcd32792009-09-11 23:19:45 +0200666 return EVT_HANDLED;
Paul Mackerras61c45982009-07-01 13:04:34 +1000667 }
Frederic Weisbeckerbcd32792009-09-11 23:19:45 +0200668 return EVT_FAILED;
Paul Mackerras61c45982009-07-01 13:04:34 +1000669}
670
Frederic Weisbeckerbcd32792009-09-11 23:19:45 +0200671static enum event_result
Ingo Molnarcdd6c482009-09-21 12:02:48 +0200672parse_numeric_event(const char **strp, struct perf_event_attr *attr)
Paul Mackerras61c45982009-07-01 13:04:34 +1000673{
674 const char *str = *strp;
675 char *endp;
676 unsigned long type;
677 u64 config;
678
679 type = strtoul(str, &endp, 0);
680 if (endp > str && type < PERF_TYPE_MAX && *endp == ':') {
681 str = endp + 1;
682 config = strtoul(str, &endp, 0);
683 if (endp > str) {
684 attr->type = type;
685 attr->config = config;
686 *strp = endp;
Frederic Weisbeckerbcd32792009-09-11 23:19:45 +0200687 return EVT_HANDLED;
Paul Mackerras61c45982009-07-01 13:04:34 +1000688 }
689 }
Frederic Weisbeckerbcd32792009-09-11 23:19:45 +0200690 return EVT_FAILED;
Paul Mackerras61c45982009-07-01 13:04:34 +1000691}
692
Frederic Weisbeckerbcd32792009-09-11 23:19:45 +0200693static enum event_result
Ingo Molnarcdd6c482009-09-21 12:02:48 +0200694parse_event_modifier(const char **strp, struct perf_event_attr *attr)
Paul Mackerras61c45982009-07-01 13:04:34 +1000695{
696 const char *str = *strp;
697 int eu = 1, ek = 1, eh = 1;
698
699 if (*str++ != ':')
700 return 0;
701 while (*str) {
702 if (*str == 'u')
703 eu = 0;
704 else if (*str == 'k')
705 ek = 0;
706 else if (*str == 'h')
707 eh = 0;
708 else
709 break;
710 ++str;
711 }
712 if (str >= *strp + 2) {
713 *strp = str;
714 attr->exclude_user = eu;
715 attr->exclude_kernel = ek;
716 attr->exclude_hv = eh;
717 return 1;
718 }
Jaswinder Singh Rajput74d5b582009-06-22 16:44:28 +0530719 return 0;
720}
721
Ingo Molnar8ad8db32009-05-26 11:10:09 +0200722/*
723 * Each event can have multiple symbolic names.
724 * Symbolic names are (almost) exactly matched.
725 */
Frederic Weisbeckerbcd32792009-09-11 23:19:45 +0200726static enum event_result
Ingo Molnarcdd6c482009-09-21 12:02:48 +0200727parse_event_symbols(const char **str, struct perf_event_attr *attr)
Ingo Molnar8ad8db32009-05-26 11:10:09 +0200728{
Frederic Weisbeckerbcd32792009-09-11 23:19:45 +0200729 enum event_result ret;
Ingo Molnar8ad8db32009-05-26 11:10:09 +0200730
Frederic Weisbeckerbcd32792009-09-11 23:19:45 +0200731 ret = parse_tracepoint_event(str, attr);
732 if (ret != EVT_FAILED)
733 goto modifier;
734
735 ret = parse_raw_event(str, attr);
736 if (ret != EVT_FAILED)
737 goto modifier;
738
739 ret = parse_numeric_event(str, attr);
740 if (ret != EVT_FAILED)
741 goto modifier;
742
743 ret = parse_symbolic_event(str, attr);
744 if (ret != EVT_FAILED)
745 goto modifier;
746
747 ret = parse_generic_hw_event(str, attr);
748 if (ret != EVT_FAILED)
749 goto modifier;
750
Frederic Weisbecker1b290d62009-11-23 15:42:35 +0100751 ret = parse_breakpoint_event(str, attr);
752 if (ret != EVT_FAILED)
753 goto modifier;
754
Marti Raudsepp85df6f62009-10-27 00:33:04 +0000755 fprintf(stderr, "invalid or unsupported event: '%s'\n", *str);
756 fprintf(stderr, "Run 'perf list' for a list of valid events\n");
Frederic Weisbeckerbcd32792009-09-11 23:19:45 +0200757 return EVT_FAILED;
758
759modifier:
Paul Mackerras61c45982009-07-01 13:04:34 +1000760 parse_event_modifier(str, attr);
Ingo Molnara21ca2c2009-06-06 09:58:57 +0200761
Frederic Weisbeckerbcd32792009-09-11 23:19:45 +0200762 return ret;
Ingo Molnar8ad8db32009-05-26 11:10:09 +0200763}
764
Arjan van de Ven8755a8f2009-09-12 07:52:51 +0200765static void store_event_type(const char *orgname)
766{
767 char filename[PATH_MAX], *c;
768 FILE *file;
769 int id;
770
Ashwin Chaugule63c9e012009-10-04 15:49:34 -0700771 sprintf(filename, "%s/", debugfs_path);
772 strncat(filename, orgname, strlen(orgname));
773 strcat(filename, "/id");
774
Arjan van de Ven8755a8f2009-09-12 07:52:51 +0200775 c = strchr(filename, ':');
776 if (c)
777 *c = '/';
778
779 file = fopen(filename, "r");
780 if (!file)
781 return;
782 if (fscanf(file, "%i", &id) < 1)
783 die("cannot store event ID");
784 fclose(file);
785 perf_header__push_event(id, orgname);
786}
787
Ingo Molnarf37a2912009-07-01 12:37:06 +0200788int parse_events(const struct option *opt __used, const char *str, int unset __used)
Ingo Molnar8ad8db32009-05-26 11:10:09 +0200789{
Ingo Molnarcdd6c482009-09-21 12:02:48 +0200790 struct perf_event_attr attr;
Frederic Weisbeckerbcd32792009-09-11 23:19:45 +0200791 enum event_result ret;
Ingo Molnar8ad8db32009-05-26 11:10:09 +0200792
Arjan van de Ven8755a8f2009-09-12 07:52:51 +0200793 if (strchr(str, ':'))
794 store_event_type(str);
795
Paul Mackerras61c45982009-07-01 13:04:34 +1000796 for (;;) {
797 if (nr_counters == MAX_COUNTERS)
798 return -1;
Ingo Molnar8ad8db32009-05-26 11:10:09 +0200799
Paul Mackerras61c45982009-07-01 13:04:34 +1000800 memset(&attr, 0, sizeof(attr));
Frederic Weisbeckerbcd32792009-09-11 23:19:45 +0200801 ret = parse_event_symbols(&str, &attr);
802 if (ret == EVT_FAILED)
Paul Mackerras61c45982009-07-01 13:04:34 +1000803 return -1;
Ingo Molnar8ad8db32009-05-26 11:10:09 +0200804
Paul Mackerras61c45982009-07-01 13:04:34 +1000805 if (!(*str == 0 || *str == ',' || isspace(*str)))
806 return -1;
Ingo Molnar8ad8db32009-05-26 11:10:09 +0200807
Frederic Weisbeckerbcd32792009-09-11 23:19:45 +0200808 if (ret != EVT_HANDLED_ALL) {
809 attrs[nr_counters] = attr;
810 nr_counters++;
811 }
Paul Mackerras61c45982009-07-01 13:04:34 +1000812
813 if (*str == 0)
814 break;
815 if (*str == ',')
816 ++str;
817 while (isspace(*str))
818 ++str;
Ingo Molnar8ad8db32009-05-26 11:10:09 +0200819 }
820
821 return 0;
822}
823
Li Zefanc171b552009-10-15 11:22:07 +0800824int parse_filter(const struct option *opt __used, const char *str,
825 int unset __used)
826{
827 int i = nr_counters - 1;
828 int len = strlen(str);
829
830 if (i < 0 || attrs[i].type != PERF_TYPE_TRACEPOINT) {
831 fprintf(stderr,
832 "-F option should follow a -e tracepoint option\n");
833 return -1;
834 }
835
836 filters[i] = malloc(len + 1);
837 if (!filters[i]) {
838 fprintf(stderr, "not enough memory to hold filter string\n");
839 return -1;
840 }
841 strcpy(filters[i], str);
842
843 return 0;
844}
845
Thomas Gleixner86847b62009-06-06 12:24:17 +0200846static const char * const event_type_descriptors[] = {
847 "",
848 "Hardware event",
849 "Software event",
850 "Tracepoint event",
851 "Hardware cache event",
852};
853
Ingo Molnar8ad8db32009-05-26 11:10:09 +0200854/*
Jason Baronf6bdafe2009-07-21 12:20:22 -0400855 * Print the events from <debugfs_mount_point>/tracing/events
856 */
857
858static void print_tracepoint_events(void)
859{
860 DIR *sys_dir, *evt_dir;
861 struct dirent *sys_next, *evt_next, sys_dirent, evt_dirent;
Jason Baronf6bdafe2009-07-21 12:20:22 -0400862 char evt_path[MAXPATHLEN];
Eric Dumazet725b1362009-09-24 15:39:09 +0200863 char dir_path[MAXPATHLEN];
Jason Baronf6bdafe2009-07-21 12:20:22 -0400864
Clark Williams549104f2009-11-08 09:03:07 -0600865 if (debugfs_valid_mountpoint(debugfs_path))
Jason Baronf6bdafe2009-07-21 12:20:22 -0400866 return;
867
Jason Baron5beeded2009-07-21 14:16:29 -0400868 sys_dir = opendir(debugfs_path);
Jason Baronf6bdafe2009-07-21 12:20:22 -0400869 if (!sys_dir)
Eric Dumazet725b1362009-09-24 15:39:09 +0200870 return;
Jason Baronf6bdafe2009-07-21 12:20:22 -0400871
Ulrich Drepper6b58e7f2009-09-04 16:39:51 -0300872 for_each_subsystem(sys_dir, sys_dirent, sys_next) {
Eric Dumazet725b1362009-09-24 15:39:09 +0200873
874 snprintf(dir_path, MAXPATHLEN, "%s/%s", debugfs_path,
875 sys_dirent.d_name);
876 evt_dir = opendir(dir_path);
877 if (!evt_dir)
Ulrich Drepper6b58e7f2009-09-04 16:39:51 -0300878 continue;
Eric Dumazet725b1362009-09-24 15:39:09 +0200879
Ulrich Drepper6b58e7f2009-09-04 16:39:51 -0300880 for_each_event(sys_dirent, evt_dir, evt_dirent, evt_next) {
Jason Baronf6bdafe2009-07-21 12:20:22 -0400881 snprintf(evt_path, MAXPATHLEN, "%s:%s",
882 sys_dirent.d_name, evt_dirent.d_name);
Marti Raudsepp689d3012009-10-27 00:33:05 +0000883 printf(" %-42s [%s]\n", evt_path,
Jason Baronf6bdafe2009-07-21 12:20:22 -0400884 event_type_descriptors[PERF_TYPE_TRACEPOINT+1]);
885 }
886 closedir(evt_dir);
887 }
Jason Baronf6bdafe2009-07-21 12:20:22 -0400888 closedir(sys_dir);
889}
890
891/*
Thomas Gleixner86847b62009-06-06 12:24:17 +0200892 * Print the help text for the event symbols:
Ingo Molnar8ad8db32009-05-26 11:10:09 +0200893 */
Thomas Gleixner86847b62009-06-06 12:24:17 +0200894void print_events(void)
Ingo Molnar8ad8db32009-05-26 11:10:09 +0200895{
Thomas Gleixner86847b62009-06-06 12:24:17 +0200896 struct event_symbol *syms = event_symbols;
Jaswinder Singh Rajput73c24cb2009-07-01 18:36:18 +0530897 unsigned int i, type, op, prev_type = -1;
Jaswinder Singh Rajput74d5b582009-06-22 16:44:28 +0530898 char name[40];
Ingo Molnar8ad8db32009-05-26 11:10:09 +0200899
Marti Raudsepp689d3012009-10-27 00:33:05 +0000900 printf("\n");
901 printf("List of pre-defined events (to be used in -e):\n");
Ingo Molnar8ad8db32009-05-26 11:10:09 +0200902
Thomas Gleixner86847b62009-06-06 12:24:17 +0200903 for (i = 0; i < ARRAY_SIZE(event_symbols); i++, syms++) {
904 type = syms->type + 1;
Roel Kluin23cdb5d2009-07-13 02:25:47 +0200905 if (type >= ARRAY_SIZE(event_type_descriptors))
Thomas Gleixner86847b62009-06-06 12:24:17 +0200906 type = 0;
Ingo Molnar8ad8db32009-05-26 11:10:09 +0200907
Thomas Gleixner86847b62009-06-06 12:24:17 +0200908 if (type != prev_type)
Marti Raudsepp689d3012009-10-27 00:33:05 +0000909 printf("\n");
Ingo Molnar8ad8db32009-05-26 11:10:09 +0200910
Jaswinder Singh Rajput74d5b582009-06-22 16:44:28 +0530911 if (strlen(syms->alias))
912 sprintf(name, "%s OR %s", syms->symbol, syms->alias);
913 else
914 strcpy(name, syms->symbol);
Marti Raudsepp689d3012009-10-27 00:33:05 +0000915 printf(" %-42s [%s]\n", name,
Thomas Gleixner86847b62009-06-06 12:24:17 +0200916 event_type_descriptors[type]);
Ingo Molnar8ad8db32009-05-26 11:10:09 +0200917
Thomas Gleixner86847b62009-06-06 12:24:17 +0200918 prev_type = type;
Ingo Molnar8ad8db32009-05-26 11:10:09 +0200919 }
920
Marti Raudsepp689d3012009-10-27 00:33:05 +0000921 printf("\n");
Jaswinder Singh Rajput73c24cb2009-07-01 18:36:18 +0530922 for (type = 0; type < PERF_COUNT_HW_CACHE_MAX; type++) {
923 for (op = 0; op < PERF_COUNT_HW_CACHE_OP_MAX; op++) {
924 /* skip invalid cache type */
925 if (!is_cache_op_valid(type, op))
926 continue;
927
928 for (i = 0; i < PERF_COUNT_HW_CACHE_RESULT_MAX; i++) {
Marti Raudsepp689d3012009-10-27 00:33:05 +0000929 printf(" %-42s [%s]\n",
Jaswinder Singh Rajput73c24cb2009-07-01 18:36:18 +0530930 event_cache_name(type, op, i),
931 event_type_descriptors[4]);
932 }
933 }
934 }
935
Marti Raudsepp689d3012009-10-27 00:33:05 +0000936 printf("\n");
937 printf(" %-42s [raw hardware event descriptor]\n",
Thomas Gleixner86847b62009-06-06 12:24:17 +0200938 "rNNN");
Marti Raudsepp689d3012009-10-27 00:33:05 +0000939 printf("\n");
Thomas Gleixner86847b62009-06-06 12:24:17 +0200940
Frederic Weisbecker1b290d62009-11-23 15:42:35 +0100941 printf(" %-42s [hardware breakpoint]\n", "mem:<addr>[:access]");
942 printf("\n");
943
Jason Baronf6bdafe2009-07-21 12:20:22 -0400944 print_tracepoint_events();
945
Thomas Gleixner86847b62009-06-06 12:24:17 +0200946 exit(129);
Ingo Molnar8ad8db32009-05-26 11:10:09 +0200947}