Skip to contentSkip to conversation

perf record: Change error message on failure

PATCH In review Robert Richter 2 participants 4 messages Sep 13, 2012 perf events

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 perf record: Change error message on failure

Only report

No CONFIG_PERF_EVENTS=y kernel support configured?

if the syscall fails with ENOSYS. In other cases CONFIG_PERF_EVENTS is set and might confuse users. The default message is now:

Not all events could be opened.

---
 tools/perf/builtin-record.c |   12 ++++++------
 1 files changed, 6 insertions(+), 6 deletions(-)
tools/perf/builtin-record.c +6 -6
index ae7c1c9..0290c91 100644
@@ -305,19 +305,19 @@ try_again:
 			error("sys_perf_event_open() syscall returned with %d (%s).  /bin/dmesg may provide additional information.\n",
 			      err, strerror(err));
 
+			if (err == ENOSYS)
+				pr_err("No CONFIG_PERF_EVENTS=y kernel support configured?\n");
 #if defined(__i386__) || defined(__x86_64__)
-			if (attr->type == PERF_TYPE_HARDWARE &&
-			    err == EOPNOTSUPP) {
+			else if (attr->type == PERF_TYPE_HARDWARE &&
+				 err == EOPNOTSUPP)
 				pr_err("No hardware sampling interrupt available."
 				       " No APIC? If so then you can boot the kernel"
 				       " with the \"lapic\" boot parameter to"
 				       " force-enable it.\n");
-				rc = -err;
-				goto out;
-			}
 #endif
+			else
+				pr_err("Not all events could be opened.\n");
 
-			pr_err("No CONFIG_PERF_EVENTS=y kernel support configured?\n");
 			rc = -err;
 			goto out;
 		}
Signature · 1 line
1.7.8.6
#1 lore raw
Quoted 8 lines · Robert Richter

Only report

No CONFIG_PERF_EVENTS=y kernel support configured?

if the syscall fails with ENOSYS. In other cases CONFIG_PERF_EVENTS is set and might confuse users. The default message is now:

Not all events could be opened.

Indeed, and it would be nice to be even less passive-aggressive and figure out and display the exact error condition?

Thanks,

Ingo

#2 lore raw
Quoted 7 lines · Ingo Molnar
Quoted 4 lines · Robert Richter

Only report

No CONFIG_PERF_EVENTS=y kernel support configured?

Quoted 7 lines
Quoted 4 lines

if the syscall fails with ENOSYS. In other cases CONFIG_PERF_EVENTS is set and might confuse users. The default message is now:

Not all events could be opened.

Indeed, and it would be nice to be even less passive-aggressive and figure out and display the exact error condition?

The complete error message shows the error condition and is like the following:

 # perf record -e cycles:ppk sleep 1

Error: sys_perf_event_open() syscall returned with 22 (Invalid argument). /bin/dmesg may provide additional information.

Not all events could be opened.
sleep: Terminated

-Robert

Signature · 2 lines
Advanced Micro Devices, Inc.
Operating System Research Center
#3 lore raw
Quoted 19 lines · Robert Richter
Quoted 7 lines · Ingo Molnar
Quoted 4 lines · Robert Richter

Only report

No CONFIG_PERF_EVENTS=y kernel support configured?

Quoted 7 lines
Quoted 4 lines

if the syscall fails with ENOSYS. In other cases CONFIG_PERF_EVENTS is set and might confuse users. The default message is now:

Not all events could be opened.

Indeed, and it would be nice to be even less passive-aggressive and figure out and display the exact error condition?

The complete error message shows the error condition and is like the following:

Quoted 6 lines
 # perf record -e cycles:ppk sleep 1

Error: sys_perf_event_open() syscall returned with 22 (Invalid argument). /bin/dmesg may provide additional information.

Not all events could be opened.
sleep: Terminated

So in this case a better message would be something like:

Error: sys_perf_event_open() syscall failed because the 'cycles:ppk' event could not be opened
sleep: Terminated

The user is not interested in the dmesg details, nor in that the error code is 22 -EINVAL.

Thanks,

Ingo