diff options
author | Peter Zijlstra <a.p.zijlstra@chello.nl> | 2009-05-05 11:50:27 -0400 |
---|---|---|
committer | Ingo Molnar <mingo@elte.hu> | 2009-05-05 14:18:33 -0400 |
commit | 16c8a10932aef971292c9570eb5f60b5d4e83ed2 (patch) | |
tree | ee9f6860cad353bb7a5219468ffdc4e4fc700792 /Documentation/perf_counter/builtin-stat.c | |
parent | 2023b359214bbc5bad31571cf50d7fb83b535c0a (diff) |
perf_counter: tools: update the tools to support process and inherited counters
"perf record":
- per task counter
- inherit switch
- nmi switch
"perf report":
- userspace/kernel filter
"perf stat":
- userspace/kernel filter
Signed-off-by: Peter Zijlstra <a.p.zijlstra@chello.nl>
Cc: Paul Mackerras <paulus@samba.org>
Cc: Corey Ashford <cjashfor@linux.vnet.ibm.com>
LKML-Reference: <20090505155437.389163017@chello.nl>
Signed-off-by: Ingo Molnar <mingo@elte.hu>
Diffstat (limited to 'Documentation/perf_counter/builtin-stat.c')
-rw-r--r-- | Documentation/perf_counter/builtin-stat.c | 24 |
1 files changed, 22 insertions, 2 deletions
diff --git a/Documentation/perf_counter/builtin-stat.c b/Documentation/perf_counter/builtin-stat.c index 6de38d256883..e2fa117eab58 100644 --- a/Documentation/perf_counter/builtin-stat.c +++ b/Documentation/perf_counter/builtin-stat.c | |||
@@ -87,6 +87,9 @@ | |||
87 | 87 | ||
88 | #include "perf.h" | 88 | #include "perf.h" |
89 | 89 | ||
90 | #define EVENT_MASK_KERNEL 1 | ||
91 | #define EVENT_MASK_USER 2 | ||
92 | |||
90 | static int system_wide = 0; | 93 | static int system_wide = 0; |
91 | 94 | ||
92 | static int nr_counters = 0; | 95 | static int nr_counters = 0; |
@@ -104,6 +107,7 @@ static __u64 event_id[MAX_COUNTERS] = { | |||
104 | static int default_interval = 100000; | 107 | static int default_interval = 100000; |
105 | static int event_count[MAX_COUNTERS]; | 108 | static int event_count[MAX_COUNTERS]; |
106 | static int fd[MAX_NR_CPUS][MAX_COUNTERS]; | 109 | static int fd[MAX_NR_CPUS][MAX_COUNTERS]; |
110 | static int event_mask[MAX_COUNTERS]; | ||
107 | 111 | ||
108 | static int tid = -1; | 112 | static int tid = -1; |
109 | static int profile_cpu = -1; | 113 | static int profile_cpu = -1; |
@@ -258,12 +262,23 @@ static __u64 match_event_symbols(char *str) | |||
258 | __u64 config, id; | 262 | __u64 config, id; |
259 | int type; | 263 | int type; |
260 | unsigned int i; | 264 | unsigned int i; |
265 | char mask_str[4]; | ||
261 | 266 | ||
262 | if (sscanf(str, "r%llx", &config) == 1) | 267 | if (sscanf(str, "r%llx", &config) == 1) |
263 | return config | PERF_COUNTER_RAW_MASK; | 268 | return config | PERF_COUNTER_RAW_MASK; |
264 | 269 | ||
265 | if (sscanf(str, "%d:%llu", &type, &id) == 2) | 270 | switch (sscanf(str, "%d:%llu:%2s", &type, &id, mask_str)) { |
266 | return EID(type, id); | 271 | case 3: |
272 | if (strchr(mask_str, 'u')) | ||
273 | event_mask[nr_counters] |= EVENT_MASK_USER; | ||
274 | if (strchr(mask_str, 'k')) | ||
275 | event_mask[nr_counters] |= EVENT_MASK_KERNEL; | ||
276 | case 2: | ||
277 | return EID(type, id); | ||
278 | |||
279 | default: | ||
280 | break; | ||
281 | } | ||
267 | 282 | ||
268 | for (i = 0; i < ARRAY_SIZE(event_symbols); i++) { | 283 | for (i = 0; i < ARRAY_SIZE(event_symbols); i++) { |
269 | if (!strncmp(str, event_symbols[i].symbol, | 284 | if (!strncmp(str, event_symbols[i].symbol, |
@@ -313,6 +328,11 @@ static void create_perfstat_counter(int counter) | |||
313 | hw_event.config = event_id[counter]; | 328 | hw_event.config = event_id[counter]; |
314 | hw_event.record_type = 0; | 329 | hw_event.record_type = 0; |
315 | hw_event.nmi = 0; | 330 | hw_event.nmi = 0; |
331 | hw_event.exclude_kernel = event_mask[counter] & EVENT_MASK_KERNEL; | ||
332 | hw_event.exclude_user = event_mask[counter] & EVENT_MASK_USER; | ||
333 | |||
334 | printf("exclude: %d\n", event_mask[counter]); | ||
335 | |||
316 | if (scale) | 336 | if (scale) |
317 | hw_event.read_format = PERF_FORMAT_TOTAL_TIME_ENABLED | | 337 | hw_event.read_format = PERF_FORMAT_TOTAL_TIME_ENABLED | |
318 | PERF_FORMAT_TOTAL_TIME_RUNNING; | 338 | PERF_FORMAT_TOTAL_TIME_RUNNING; |