diff options
author | Arnaldo Carvalho de Melo <acme@redhat.com> | 2013-12-28 13:45:08 -0500 |
---|---|---|
committer | Arnaldo Carvalho de Melo <acme@redhat.com> | 2014-01-13 08:06:21 -0500 |
commit | 6af206fd911c825b83dd4efb2534a3a34ce77072 (patch) | |
tree | 58824fb1c602e6e8eeecfa3f7da0b81f563b19a6 | |
parent | 1341f3e4c0276aae3de6d902c9202265d89fe438 (diff) |
perf stat: Don't show counter information when workload fails
When starting a workload 'stat' wasn't using prepare_workload evlist
method's signal based exec() error reporting mechanism.
Use it so that the we don't report 'not counted' counters.
Before:
[acme@zoo linux]$ perf stat dfadsfa
dfadsfa: No such file or directory
Performance counter stats for 'dfadsfa':
<not counted> task-clock
<not counted> context-switches
<not counted> cpu-migrations
<not counted> page-faults
<not counted> cycles
<not counted> stalled-cycles-frontend
<not supported> stalled-cycles-backend
<not counted> instructions
<not counted> branches
<not counted> branch-misses
0.001831462 seconds time elapsed
[acme@zoo linux]$
After:
[acme@zoo linux]$ perf stat dfadsfa
dfadsfa: No such file or directory
[acme@zoo linux]$
Reported-by: David Ahern <dsahern@gmail.com>
Cc: Adrian Hunter <adrian.hunter@intel.com>
Cc: David Ahern <dsahern@gmail.com>
Cc: Frederic Weisbecker <fweisbec@gmail.com>
Cc: Jiri Olsa <jolsa@redhat.com>
Cc: Mike Galbraith <efault@gmx.de>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Paul Mackerras <paulus@samba.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Stephane Eranian <eranian@google.com>
Link: http://lkml.kernel.org/n/tip-5yui3bv7e3hitxucnjsn6z8q@git.kernel.org
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
-rw-r--r-- | tools/perf/builtin-stat.c | 26 |
1 files changed, 25 insertions, 1 deletions
diff --git a/tools/perf/builtin-stat.c b/tools/perf/builtin-stat.c index 106a5e5b7842..1c76c7a66f78 100644 --- a/tools/perf/builtin-stat.c +++ b/tools/perf/builtin-stat.c | |||
@@ -509,6 +509,18 @@ static void handle_initial_delay(void) | |||
509 | } | 509 | } |
510 | } | 510 | } |
511 | 511 | ||
512 | static volatile bool workload_exec_failed; | ||
513 | |||
514 | /* | ||
515 | * perf_evlist__prepare_workload will send a SIGUSR1 | ||
516 | * if the fork fails, since we asked by setting its | ||
517 | * want_signal to true. | ||
518 | */ | ||
519 | static void workload_exec_failed_signal(int signo __maybe_unused) | ||
520 | { | ||
521 | workload_exec_failed = true; | ||
522 | } | ||
523 | |||
512 | static int __run_perf_stat(int argc, const char **argv) | 524 | static int __run_perf_stat(int argc, const char **argv) |
513 | { | 525 | { |
514 | char msg[512]; | 526 | char msg[512]; |
@@ -529,7 +541,7 @@ static int __run_perf_stat(int argc, const char **argv) | |||
529 | 541 | ||
530 | if (forks) { | 542 | if (forks) { |
531 | if (perf_evlist__prepare_workload(evsel_list, &target, argv, | 543 | if (perf_evlist__prepare_workload(evsel_list, &target, argv, |
532 | false, false) < 0) { | 544 | false, true) < 0) { |
533 | perror("failed to prepare workload"); | 545 | perror("failed to prepare workload"); |
534 | return -1; | 546 | return -1; |
535 | } | 547 | } |
@@ -584,6 +596,14 @@ static int __run_perf_stat(int argc, const char **argv) | |||
584 | clock_gettime(CLOCK_MONOTONIC, &ref_time); | 596 | clock_gettime(CLOCK_MONOTONIC, &ref_time); |
585 | 597 | ||
586 | if (forks) { | 598 | if (forks) { |
599 | /* | ||
600 | * perf_evlist__prepare_workload will, after we call | ||
601 | * perf_evlist__start_Workload, send a SIGUSR1 if the exec call | ||
602 | * fails, that we will catch in workload_signal to flip | ||
603 | * workload_exec_failed. | ||
604 | */ | ||
605 | signal(SIGUSR1, workload_exec_failed_signal); | ||
606 | |||
587 | perf_evlist__start_workload(evsel_list); | 607 | perf_evlist__start_workload(evsel_list); |
588 | handle_initial_delay(); | 608 | handle_initial_delay(); |
589 | 609 | ||
@@ -594,6 +614,10 @@ static int __run_perf_stat(int argc, const char **argv) | |||
594 | } | 614 | } |
595 | } | 615 | } |
596 | wait(&status); | 616 | wait(&status); |
617 | |||
618 | if (workload_exec_failed) | ||
619 | return -1; | ||
620 | |||
597 | if (WIFSIGNALED(status)) | 621 | if (WIFSIGNALED(status)) |
598 | psignal(WTERMSIG(status), argv[0]); | 622 | psignal(WTERMSIG(status), argv[0]); |
599 | } else { | 623 | } else { |