Skip to contentSkip to conversation

perf stat: handle ENXIO error for perf_event_open

PATCH In review David Ahern 1 participant 3 messages May 8, 2012 – May 11, 2012 perf events

lore
Share & tools
lore
#0 lore raw

PATCH 2/2 perf stat: handle ENXIO error for perf_event_open

perf stat on PPC currently fails to run:

$ perf stat -- sleep 1
  Error: open_counter returned with 6 (No such device or address). /bin/dmesg may provide additional information.

Fatal: Not all events could be opened.

The problem is that until 2.6.37 (behavior changed with commit b0a873e) perf on PPC returns ENXIO when hw_perf_event_init() fails. With this patch we get the expected behavior:

$ perf stat -v -- sleep 1
cycles event is not supported by the kernel.
stalled-cycles-frontend event is not supported by the kernel.
stalled-cycles-backend event is not supported by the kernel.
instructions event is not supported by the kernel.
branches event is not supported by the kernel.
branch-misses event is not supported by the kernel.

...

---
 tools/perf/builtin-stat.c |    7 ++++++-
 1 files changed, 6 insertions(+), 1 deletions(-)
tools/perf/builtin-stat.c +6 -1
index e720ba7..bd42189 100644
@@ -462,8 +462,13 @@ static int run_perf_stat(int argc __used, const char **argv)
 
 	list_for_each_entry(counter, &evsel_list->entries, node) {
 		if (create_perf_stat_counter(counter, first) < 0) {
+			/* 
+			 * PPC returns ENXIO for HW counters until 2.6.37
+			 * (behavior changed with commit b0a873e).
+			 */
 			if (errno == EINVAL || errno == ENOSYS ||
-			    errno == ENOENT || errno == EOPNOTSUPP) {
+			    errno == ENOENT || errno == EOPNOTSUPP ||
+			    errno == ENXIO) {
 				if (verbose)
 					ui__warning("%s event is not supported by the kernel.\n",
 						    event_name(counter));
Signature · 1 line
1.7.5.4
#1 lore raw
Commit-ID:  20d23aaa31da295378abff4272716e3dfc72baf0
Gitweb:     http://git.kernel.org/tip/20d23aaa31da295378abff4272716e3dfc72baf0
Author:     David Ahern <[email protected]>
AuthorDate: Tue, 8 May 2012 09:29:16 -0600
Committer:  Arnaldo Carvalho de Melo <[email protected]>
CommitDate: Wed, 9 May 2012 14:14:41 -0300

perf stat: handle ENXIO error for perf_event_open

perf stat on PPC currently fails to run:

$ perf stat -- sleep 1
  Error: open_counter returned with 6 (No such device or address). /bin/dmesg may provide additional information.

Fatal: Not all events could be opened.

The problem is that until 2.6.37 (behavior changed with commit b0a873e) perf on PPC returns ENXIO when hw_perf_event_init() fails. With this patch we get the expected behavior:

$ perf stat -v -- sleep 1
cycles event is not supported by the kernel.
stalled-cycles-frontend event is not supported by the kernel.
stalled-cycles-backend event is not supported by the kernel.
instructions event is not supported by the kernel.
branches event is not supported by the kernel.
branch-misses event is not supported by the kernel.

...

---
 tools/perf/builtin-stat.c |    7 ++++++-
 1 files changed, 6 insertions(+), 1 deletions(-)
tools/perf/builtin-stat.c +6 -1
index 4532a78..1e5e9b2 100644
@@ -488,8 +488,13 @@ static int run_perf_stat(int argc __used, const char **argv)
 
 	list_for_each_entry(counter, &evsel_list->entries, node) {
 		if (create_perf_stat_counter(counter, first) < 0) {
+			/*
+			 * PPC returns ENXIO for HW counters until 2.6.37
+			 * (behavior changed with commit b0a873e).
+			 */
 			if (errno == EINVAL || errno == ENOSYS ||
-			    errno == ENOENT || errno == EOPNOTSUPP) {
+			    errno == ENOENT || errno == EOPNOTSUPP ||
+			    errno == ENXIO) {
 				if (verbose)
 					ui__warning("%s event is not supported by the kernel.\n",
 						    event_name(counter));
#2 lore raw
In reply to David Ahern
Commit-ID:  979987a567d9e666fe719f337409b2fbb6418f5f
Gitweb:     http://git.kernel.org/tip/979987a567d9e666fe719f337409b2fbb6418f5f
Author:     David Ahern <[email protected]>
AuthorDate: Tue, 8 May 2012 09:29:16 -0600
Committer:  Arnaldo Carvalho de Melo <[email protected]>
CommitDate: Wed, 9 May 2012 11:58:48 -0300

perf stat: handle ENXIO error for perf_event_open

perf stat on PPC currently fails to run:

$ perf stat -- sleep 1
  Error: open_counter returned with 6 (No such device or address). /bin/dmesg may provide additional information.

Fatal: Not all events could be opened.

The problem is that until 2.6.37 (behavior changed with commit b0a873e) perf on PPC returns ENXIO when hw_perf_event_init() fails. With this patch we get the expected behavior:

$ perf stat -v -- sleep 1
cycles event is not supported by the kernel.
stalled-cycles-frontend event is not supported by the kernel.
stalled-cycles-backend event is not supported by the kernel.
instructions event is not supported by the kernel.
branches event is not supported by the kernel.
branch-misses event is not supported by the kernel.

...

---
 tools/perf/builtin-stat.c |    7 ++++++-
 1 files changed, 6 insertions(+), 1 deletions(-)
tools/perf/builtin-stat.c +6 -1
index e720ba7..d060568 100644
@@ -462,8 +462,13 @@ static int run_perf_stat(int argc __used, const char **argv)
 
 	list_for_each_entry(counter, &evsel_list->entries, node) {
 		if (create_perf_stat_counter(counter, first) < 0) {
+			/*
+			 * PPC returns ENXIO for HW counters until 2.6.37
+			 * (behavior changed with commit b0a873e).
+			 */
 			if (errno == EINVAL || errno == ENOSYS ||
-			    errno == ENOENT || errno == EOPNOTSUPP) {
+			    errno == ENOENT || errno == EOPNOTSUPP ||
+			    errno == ENXIO) {
 				if (verbose)
 					ui__warning("%s event is not supported by the kernel.\n",
 						    event_name(counter));