Adding internal error (PERF_EVLIST__ERRNO_IOCTL_ID_GROUP) for
cases when ioctl syscall fails during perf_evlist__mmap call.

Signed-off-by: Jiri Olsa <[email protected]>
Cc: Corey Ashford <[email protected]>
Cc: Frederic Weisbecker <[email protected]>
Cc: Ingo Molnar <[email protected]>
Cc: Namhyung Kim <[email protected]>
Cc: Paul Mackerras <[email protected]>
Cc: Peter Zijlstra <[email protected]>
Cc: Arnaldo Carvalho de Melo <[email protected]>
Cc: David Ahern <[email protected]>
Cc: Andi Kleen <[email protected]>
---
 tools/perf/util/evlist.c | 9 ++++++++-
 tools/perf/util/evlist.h | 1 +
 2 files changed, 9 insertions(+), 1 deletion(-)

diff --git a/tools/perf/util/evlist.c b/tools/perf/util/evlist.c
index 4af0cca..f9c5abd 100644
--- a/tools/perf/util/evlist.c
+++ b/tools/perf/util/evlist.c
@@ -399,8 +399,10 @@ static int perf_evlist__id_add_fd(struct perf_evlist 
*evlist,
         * This way does not work with group format read, so bail
         * out in that case.
         */
-       if (perf_evlist__read_format(evlist) & PERF_FORMAT_GROUP)
+       if (perf_evlist__read_format(evlist) & PERF_FORMAT_GROUP) {
+               SET_ERR(IOCTL_ID_GROUP);
                return -1;
+       }
 
        if (!(evsel->attr.read_format & PERF_FORMAT_ID) ||
            read(fd, &read_data, sizeof(read_data)) == -1)
@@ -676,6 +678,11 @@ static void __perf_evlist__strerror(struct perf_evlist 
*evlist,
        case PERF_EVLIST__ERRNO_OPEN:
                strerror_open(evlist, buf, size);
                return;
+       case PERF_EVLIST__ERRNO_IOCTL_ID_GROUP:
+               scnprintf(buf, size,
+                       "Cannot read event group on this kernel.\n"
+                       "Please consider kernel update (v3.12+).\n");
+               return;
        default:
                scnprintf(buf, size, "Unknown error\n");
                return;
diff --git a/tools/perf/util/evlist.h b/tools/perf/util/evlist.h
index 48ac4c5..e5ce8c7 100644
--- a/tools/perf/util/evlist.h
+++ b/tools/perf/util/evlist.h
@@ -21,6 +21,7 @@ enum {
        PERF_EVLIST__ERRNO_SUCCESS              = 0,
        PERF_EVLIST__ERRNO_MMAP                 = 1,
        PERF_EVLIST__ERRNO_OPEN                 = 2,
+       PERF_EVLIST__ERRNO_IOCTL_ID_GROUP       = 3,
 };
 
 struct perf_mmap {
-- 
1.8.3.1

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

Reply via email to