All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] perf stat: Do not show stats if workload fails
@ 2013-12-20  5:52 David Ahern
  2013-12-20  7:57 ` Ingo Molnar
  0 siblings, 1 reply; 12+ messages in thread
From: David Ahern @ 2013-12-20  5:52 UTC (permalink / raw)
  To: acme, linux-kernel; +Cc: David Ahern, Ingo Molnar, Stephane Eranian

Currently perf-stat attempts to show counter stats even if the workload
is bogus:

$ perf stat -- foo
foo: No such file or directory

 Performance counter stats for 'foo':

     <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 counted>      stalled-cycles-backend
     <not counted>      instructions
     <not counted>      branches
     <not counted>      branch-misses

       0.009769943 seconds time elapsed

It is impossible to differentiate all the failure modes, but it seems
reasonable that if the workload handling fails, perf-stat should not try
to print stats.

With this change:

$ perf stat  -v -- foo
Failed to start workload

Signed-off-by: David Ahern <dsahern@gmail.com>
Cc: Ingo Molnar <mingo@kernel.org>
Cc: Stephane Eranian <eranian@google.com>
---
 tools/perf/builtin-stat.c | 11 +++++++++--
 1 file changed, 9 insertions(+), 2 deletions(-)

diff --git a/tools/perf/builtin-stat.c b/tools/perf/builtin-stat.c
index dab98b50c9fe..d6e6a0b031d9 100644
--- a/tools/perf/builtin-stat.c
+++ b/tools/perf/builtin-stat.c
@@ -586,7 +586,11 @@ static int __run_perf_stat(int argc, const char **argv)
 	clock_gettime(CLOCK_MONOTONIC, &ref_time);
 
 	if (forks) {
-		perf_evlist__start_workload(evsel_list);
+		if (perf_evlist__start_workload(evsel_list) != 0) {
+			pr_err("Failed to start workload\n");
+			return -1;
+		}
+
 		handle_initial_delay();
 
 		if (interval) {
@@ -1793,7 +1797,10 @@ int cmd_stat(int argc, const char **argv, const char *prefix __maybe_unused)
 				run_idx + 1);
 
 		status = run_perf_stat(argc, argv);
-		if (forever && status != -1) {
+		if (status < 0)
+			break;
+
+		if (forever) {
 			print_stat(argc, argv);
 			perf_stat__reset_stats(evsel_list);
 		}
-- 
1.8.3.4 (Apple Git-47)


^ permalink raw reply related	[flat|nested] 12+ messages in thread

end of thread, other threads:[~2014-01-02 14:44 UTC | newest]

Thread overview: 12+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-12-20  5:52 [PATCH] perf stat: Do not show stats if workload fails David Ahern
2013-12-20  7:57 ` Ingo Molnar
2013-12-23 19:37   ` Arnaldo Carvalho de Melo
2013-12-24  0:29     ` David Ahern
2013-12-24 12:53       ` Arnaldo Carvalho de Melo
2013-12-24 13:30         ` Arnaldo Carvalho de Melo
2013-12-26 14:11           ` David Ahern
2013-12-26 14:15             ` Arnaldo Carvalho de Melo
2013-12-26 14:18               ` David Ahern
2013-12-26 14:26                 ` Arnaldo Carvalho de Melo
2013-12-26 14:55                 ` Arnaldo Carvalho de Melo
2014-01-02 14:44             ` Arnaldo Carvalho de Melo

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.