diff options
author | Frederic Weisbecker <fweisbec@gmail.com> | 2009-08-27 21:09:58 -0400 |
---|---|---|
committer | Ingo Molnar <mingo@elte.hu> | 2009-08-28 01:58:11 -0400 |
commit | 1ef2ed1066ae9f8080cd96cba11c2d41118b8792 (patch) | |
tree | 44c9e7216610bdca195f21d4934ece4d339df456 /tools/perf/util/trace-event-info.c | |
parent | 1909629fb1ec9800cf2cb0091870d6a1c1ca665f (diff) |
perf tools: Only save the event formats we need
While opening a trace event counter, every events are saved in
the trace.info file. But we only want to save the
specifications of the events we are using.
Signed-off-by: Frederic Weisbecker <fweisbec@gmail.com>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Arnaldo Carvalho de Melo <acme@redhat.com>
Cc: Steven Rostedt <rostedt@goodmis.org>
LKML-Reference: <1251421798-9101-1-git-send-email-fweisbec@gmail.com>
Signed-off-by: Ingo Molnar <mingo@elte.hu>
Diffstat (limited to 'tools/perf/util/trace-event-info.c')
-rw-r--r-- | tools/perf/util/trace-event-info.c | 72 |
1 files changed, 60 insertions, 12 deletions
diff --git a/tools/perf/util/trace-event-info.c b/tools/perf/util/trace-event-info.c index 78adff189bba..81615279b876 100644 --- a/tools/perf/util/trace-event-info.c +++ b/tools/perf/util/trace-event-info.c | |||
@@ -32,7 +32,9 @@ | |||
32 | #include <unistd.h> | 32 | #include <unistd.h> |
33 | #include <ctype.h> | 33 | #include <ctype.h> |
34 | #include <errno.h> | 34 | #include <errno.h> |
35 | #include <stdbool.h> | ||
35 | 36 | ||
37 | #include "../perf.h" | ||
36 | #include "trace-event.h" | 38 | #include "trace-event.h" |
37 | 39 | ||
38 | 40 | ||
@@ -289,7 +291,18 @@ static void read_header_files(void) | |||
289 | put_tracing_file(path); | 291 | put_tracing_file(path); |
290 | } | 292 | } |
291 | 293 | ||
292 | static void copy_event_system(const char *sys) | 294 | static bool name_in_tp_list(char *sys, struct tracepoint_path *tps) |
295 | { | ||
296 | while (tps) { | ||
297 | if (!strcmp(sys, tps->name)) | ||
298 | return true; | ||
299 | tps = tps->next; | ||
300 | } | ||
301 | |||
302 | return false; | ||
303 | } | ||
304 | |||
305 | static void copy_event_system(const char *sys, struct tracepoint_path *tps) | ||
293 | { | 306 | { |
294 | unsigned long long size, check_size; | 307 | unsigned long long size, check_size; |
295 | struct dirent *dent; | 308 | struct dirent *dent; |
@@ -305,7 +318,8 @@ static void copy_event_system(const char *sys) | |||
305 | 318 | ||
306 | while ((dent = readdir(dir))) { | 319 | while ((dent = readdir(dir))) { |
307 | if (strcmp(dent->d_name, ".") == 0 || | 320 | if (strcmp(dent->d_name, ".") == 0 || |
308 | strcmp(dent->d_name, "..") == 0) | 321 | strcmp(dent->d_name, "..") == 0 || |
322 | !name_in_tp_list(dent->d_name, tps)) | ||
309 | continue; | 323 | continue; |
310 | format = malloc_or_die(strlen(sys) + strlen(dent->d_name) + 10); | 324 | format = malloc_or_die(strlen(sys) + strlen(dent->d_name) + 10); |
311 | sprintf(format, "%s/%s/format", sys, dent->d_name); | 325 | sprintf(format, "%s/%s/format", sys, dent->d_name); |
@@ -321,7 +335,8 @@ static void copy_event_system(const char *sys) | |||
321 | rewinddir(dir); | 335 | rewinddir(dir); |
322 | while ((dent = readdir(dir))) { | 336 | while ((dent = readdir(dir))) { |
323 | if (strcmp(dent->d_name, ".") == 0 || | 337 | if (strcmp(dent->d_name, ".") == 0 || |
324 | strcmp(dent->d_name, "..") == 0) | 338 | strcmp(dent->d_name, "..") == 0 || |
339 | !name_in_tp_list(dent->d_name, tps)) | ||
325 | continue; | 340 | continue; |
326 | format = malloc_or_die(strlen(sys) + strlen(dent->d_name) + 10); | 341 | format = malloc_or_die(strlen(sys) + strlen(dent->d_name) + 10); |
327 | sprintf(format, "%s/%s/format", sys, dent->d_name); | 342 | sprintf(format, "%s/%s/format", sys, dent->d_name); |
@@ -340,18 +355,29 @@ static void copy_event_system(const char *sys) | |||
340 | } | 355 | } |
341 | } | 356 | } |
342 | 357 | ||
343 | static void read_ftrace_files(void) | 358 | static void read_ftrace_files(struct tracepoint_path *tps) |
344 | { | 359 | { |
345 | char *path; | 360 | char *path; |
346 | 361 | ||
347 | path = get_tracing_file("events/ftrace"); | 362 | path = get_tracing_file("events/ftrace"); |
348 | 363 | ||
349 | copy_event_system(path); | 364 | copy_event_system(path, tps); |
350 | 365 | ||
351 | put_tracing_file(path); | 366 | put_tracing_file(path); |
352 | } | 367 | } |
353 | 368 | ||
354 | static void read_event_files(void) | 369 | static bool system_in_tp_list(char *sys, struct tracepoint_path *tps) |
370 | { | ||
371 | while (tps) { | ||
372 | if (!strcmp(sys, tps->system)) | ||
373 | return true; | ||
374 | tps = tps->next; | ||
375 | } | ||
376 | |||
377 | return false; | ||
378 | } | ||
379 | |||
380 | static void read_event_files(struct tracepoint_path *tps) | ||
355 | { | 381 | { |
356 | struct dirent *dent; | 382 | struct dirent *dent; |
357 | struct stat st; | 383 | struct stat st; |
@@ -370,7 +396,8 @@ static void read_event_files(void) | |||
370 | while ((dent = readdir(dir))) { | 396 | while ((dent = readdir(dir))) { |
371 | if (strcmp(dent->d_name, ".") == 0 || | 397 | if (strcmp(dent->d_name, ".") == 0 || |
372 | strcmp(dent->d_name, "..") == 0 || | 398 | strcmp(dent->d_name, "..") == 0 || |
373 | strcmp(dent->d_name, "ftrace") == 0) | 399 | strcmp(dent->d_name, "ftrace") == 0 || |
400 | !system_in_tp_list(dent->d_name, tps)) | ||
374 | continue; | 401 | continue; |
375 | sys = malloc_or_die(strlen(path) + strlen(dent->d_name) + 2); | 402 | sys = malloc_or_die(strlen(path) + strlen(dent->d_name) + 2); |
376 | sprintf(sys, "%s/%s", path, dent->d_name); | 403 | sprintf(sys, "%s/%s", path, dent->d_name); |
@@ -388,7 +415,8 @@ static void read_event_files(void) | |||
388 | while ((dent = readdir(dir))) { | 415 | while ((dent = readdir(dir))) { |
389 | if (strcmp(dent->d_name, ".") == 0 || | 416 | if (strcmp(dent->d_name, ".") == 0 || |
390 | strcmp(dent->d_name, "..") == 0 || | 417 | strcmp(dent->d_name, "..") == 0 || |
391 | strcmp(dent->d_name, "ftrace") == 0) | 418 | strcmp(dent->d_name, "ftrace") == 0 || |
419 | !system_in_tp_list(dent->d_name, tps)) | ||
392 | continue; | 420 | continue; |
393 | sys = malloc_or_die(strlen(path) + strlen(dent->d_name) + 2); | 421 | sys = malloc_or_die(strlen(path) + strlen(dent->d_name) + 2); |
394 | sprintf(sys, "%s/%s", path, dent->d_name); | 422 | sprintf(sys, "%s/%s", path, dent->d_name); |
@@ -396,7 +424,7 @@ static void read_event_files(void) | |||
396 | if (ret >= 0) { | 424 | if (ret >= 0) { |
397 | if (S_ISDIR(st.st_mode)) { | 425 | if (S_ISDIR(st.st_mode)) { |
398 | write_or_die(dent->d_name, strlen(dent->d_name) + 1); | 426 | write_or_die(dent->d_name, strlen(dent->d_name) + 1); |
399 | copy_event_system(sys); | 427 | copy_event_system(sys, tps); |
400 | } | 428 | } |
401 | } | 429 | } |
402 | free(sys); | 430 | free(sys); |
@@ -450,9 +478,27 @@ static void read_ftrace_printk(void) | |||
450 | 478 | ||
451 | } | 479 | } |
452 | 480 | ||
453 | void read_tracing_data(void) | 481 | static struct tracepoint_path * |
482 | get_tracepoints_path(struct perf_counter_attr *pattrs, int nb_counters) | ||
483 | { | ||
484 | struct tracepoint_path path, *ppath = &path; | ||
485 | int i; | ||
486 | |||
487 | for (i = 0; i < nb_counters; i++) { | ||
488 | if (pattrs[i].type != PERF_TYPE_TRACEPOINT) | ||
489 | continue; | ||
490 | ppath->next = tracepoint_id_to_path(pattrs[i].config); | ||
491 | if (!ppath->next) | ||
492 | die("%s\n", "No memory to alloc tracepoints list"); | ||
493 | ppath = ppath->next; | ||
494 | } | ||
495 | |||
496 | return path.next; | ||
497 | } | ||
498 | void read_tracing_data(struct perf_counter_attr *pattrs, int nb_counters) | ||
454 | { | 499 | { |
455 | char buf[BUFSIZ]; | 500 | char buf[BUFSIZ]; |
501 | struct tracepoint_path *tps; | ||
456 | 502 | ||
457 | output_fd = open(output_file, O_WRONLY | O_CREAT | O_TRUNC | O_LARGEFILE, 0644); | 503 | output_fd = open(output_file, O_WRONLY | O_CREAT | O_TRUNC | O_LARGEFILE, 0644); |
458 | if (output_fd < 0) | 504 | if (output_fd < 0) |
@@ -483,9 +529,11 @@ void read_tracing_data(void) | |||
483 | page_size = getpagesize(); | 529 | page_size = getpagesize(); |
484 | write_or_die(&page_size, 4); | 530 | write_or_die(&page_size, 4); |
485 | 531 | ||
532 | tps = get_tracepoints_path(pattrs, nb_counters); | ||
533 | |||
486 | read_header_files(); | 534 | read_header_files(); |
487 | read_ftrace_files(); | 535 | read_ftrace_files(tps); |
488 | read_event_files(); | 536 | read_event_files(tps); |
489 | read_proc_kallsyms(); | 537 | read_proc_kallsyms(); |
490 | read_ftrace_printk(); | 538 | read_ftrace_printk(); |
491 | } | 539 | } |