[PATCH 3/3] perf tool: give user better message if precise is not supported

From: David Ahern
Date: Mon Sep 10 2012 - 12:40:33 EST


Platforms (e.g., VM's) without support for precise mode get a confusing
error message. e.g.,
$ perf record -e cycles:p -a -- sleep 1

Error: sys_perf_event_open() syscall returned with 95 (Operation not
supported). /bin/dmesg may provide additional information.

No hardware sampling interrupt available. No APIC? If so then you can
boot the kernel with the "lapic" boot parameter to force-enable it.
sleep: Terminated

which is not clear that precise mode might be the root problem. With this
patch:

$ perf record -e cycles:p -fo /tmp/perf.data -- sleep 1
Error:
'precise' request not supported. Try removing 'p' modifier
sleep: Terminated

Signed-off-by: David Ahern <dsahern@xxxxxxxxx>
Cc: Ingo Molnar <mingo@xxxxxxxxxx>
Cc: Peter Zijlstra <peterz@xxxxxxxxxxxxx>
Cc: Robert Richter <robert.richter@xxxxxxx>
---
tools/perf/builtin-record.c | 5 +++++
tools/perf/builtin-top.c | 4 ++++
2 files changed, 9 insertions(+)

diff --git a/tools/perf/builtin-record.c b/tools/perf/builtin-record.c
index 7b8b891..ccf529b 100644
--- a/tools/perf/builtin-record.c
+++ b/tools/perf/builtin-record.c
@@ -294,6 +294,11 @@ try_again:
perf_evsel__name(pos));
rc = -err;
goto out;
+ } else if ((err == ENOTSUP) && (attr->precise_ip)) {
+ ui__error("\'precise\' request not supported. "
+ "Try removing 'p' modifier\n");
+ rc = -err;
+ goto out;
}

printf("\n");
diff --git a/tools/perf/builtin-top.c b/tools/perf/builtin-top.c
index 0513aaa..0d3653b 100644
--- a/tools/perf/builtin-top.c
+++ b/tools/perf/builtin-top.c
@@ -975,6 +975,10 @@ try_again:
ui__error("Too many events are opened.\n"
"Try again after reducing the number of events\n");
goto out_err;
+ } else if ((err == ENOTSUP) && (attr->precise_ip)) {
+ ui__error("\'precise\' request not supported. "
+ "Try removing 'p' modifier\n");
+ goto out_err;
}

ui__error("The sys_perf_event_open() syscall "
--
1.7.10.1

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/