[<prev] [next>] [day] [month] [year] [list]
Message-Id: <1290637178-389-1-git-send-email-cjashfor@linux.vnet.ibm.com>
Date: Wed, 24 Nov 2010 14:19:38 -0800
From: Corey Ashford <cjashfor@...ux.vnet.ibm.com>
To: Arnaldo Carvalho de Melo <acme@...stprotocols.net>,
Ingo Molnar <mingo@...e.hu>, linux-kernel@...r.kernel.org,
Paul Mackerras <paulus@...ba.org>,
Peter Zijlstra <a.p.zijlstra@...llo.nl>
Cc: Corey Ashford <cjashfor@...ux.vnet.ibm.com>
Subject: [PATCH] perf tools: fix regression in "perf stat" when no events are given on the command line
My recent patch changed the behavior "perf stat" so that it does not
run the load program if any of the given events cannot be opened.
Unfortunately, this broke the behavior of the "perf stat <load program>"
use case where no events are provided. In this case, perf stat opens a set
of default events, and if it encounters errors when opening one or more
events, perf stat exits with an error. It shouldn't do this because not
all of the default hardware events are implemented for all architectures.
What is desireable in this case is for perf stat to tolerate errors when
opening the default events. This patch accomplishes that.
Signed-off-by: Corey Ashford <cjashfor@...ux.vnet.ibm.com>
---
tools/perf/builtin-stat.c | 25 ++++++++++++++++---------
1 files changed, 16 insertions(+), 9 deletions(-)
diff --git a/tools/perf/builtin-stat.c b/tools/perf/builtin-stat.c
index 970a7f2..8b5edd9 100644
--- a/tools/perf/builtin-stat.c
+++ b/tools/perf/builtin-stat.c
@@ -83,6 +83,7 @@ static int thread_num = 0;
static pid_t child_pid = -1;
static bool null_run = false;
static bool big_num = false;
+static bool tolerate_open_errors = false;
static const char *cpu_list;
@@ -174,8 +175,10 @@ static int create_perf_stat_counter(int counter, bool *perm_err)
if (fd[cpu][counter][0] < 0) {
if (errno == EPERM || errno == EACCES)
*perm_err = true;
- error(ERR_PERF_OPEN, counter,
- fd[cpu][counter][0], strerror(errno));
+ if (!tolerate_open_errors)
+ error(ERR_PERF_OPEN, counter,
+ fd[cpu][counter][0],
+ strerror(errno));
} else {
++ncreated;
}
@@ -192,9 +195,10 @@ static int create_perf_stat_counter(int counter, bool *perm_err)
if (fd[0][counter][thread] < 0) {
if (errno == EPERM || errno == EACCES)
*perm_err = true;
- error(ERR_PERF_OPEN, counter,
- fd[0][counter][thread],
- strerror(errno));
+ if (!tolerate_open_errors)
+ error(ERR_PERF_OPEN, counter,
+ fd[0][counter][thread],
+ strerror(errno));
} else {
++ncreated;
}
@@ -405,10 +409,12 @@ static int run_perf_stat(int argc __used, const char **argv)
"\t Consider tweaking"
" /proc/sys/kernel/perf_event_paranoid or running as root.",
system_wide ? "system-wide " : "");
- die("Not all events could be opened.\n");
- if (child_pid != -1)
- kill(child_pid, SIGTERM);
- return -1;
+ if (!tolerate_open_errors) {
+ die("Not all events could be opened.\n");
+ if (child_pid != -1)
+ kill(child_pid, SIGTERM);
+ return -1;
+ }
}
/*
@@ -693,6 +699,7 @@ int cmd_stat(int argc, const char **argv, const char *prefix __used)
/* Set attrs and nr_counters if no event is selected and !null_run */
if (!null_run && !nr_counters) {
+ tolerate_open_errors = true;
memcpy(attrs, default_attrs, sizeof(default_attrs));
nr_counters = ARRAY_SIZE(default_attrs);
}
--
1.7.0.4
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Powered by blists - more mailing lists