perf evsel: Inform how to make a sysctl setting permanent
authorArnaldo Carvalho de Melo <acme@redhat.com>
Mon, 13 Feb 2017 19:45:24 +0000 (16:45 -0300)
committerArnaldo Carvalho de Melo <acme@redhat.com>
Mon, 13 Feb 2017 20:22:33 +0000 (17:22 -0300)
When a tool can't open counters due to the kernel.perf_event_paranoit
sysctl setting, we inform how to tweak it to allow the operation to
succeed, in addition to that, suggest setting /etc/sysctl.conf to
make the setting permanent.

Suggested-by: Ingo Molnar <mingo@kernel.org>
Cc: Adrian Hunter <adrian.hunter@intel.com>
Cc: David Ahern <dsahern@gmail.com>
Cc: Jiri Olsa <jolsa@kernel.org>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Wang Nan <wangnan0@huawei.com>
Link: http://lkml.kernel.org/n/tip-4gwe99k4a6p12d4u8bbyttj2@git.kernel.org
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
tools/perf/builtin-record.c
tools/perf/builtin-stat.c
tools/perf/builtin-top.c
tools/perf/util/evsel.c

index ffac8ca9fb01e3974c8e57a4b1ca248810ff4597..2ddf189968dca3039c7010db2d167499062c2dbd 100644 (file)
@@ -418,7 +418,7 @@ static int record__mmap(struct record *rec)
 
 static int record__open(struct record *rec)
 {
-       char msg[512];
+       char msg[BUFSIZ];
        struct perf_evsel *pos;
        struct perf_evlist *evlist = rec->evlist;
        struct perf_session *session = rec->session;
index a02f2e9656284fa5d5c4a4b9d45f55c28e167e89..f28719178b519b92be214b2fe0405205e6776652 100644 (file)
@@ -533,7 +533,7 @@ static int store_counter_ids(struct perf_evsel *counter)
 static int __run_perf_stat(int argc, const char **argv)
 {
        int interval = stat_config.interval;
-       char msg[512];
+       char msg[BUFSIZ];
        unsigned long long t0, t1;
        struct perf_evsel *counter;
        struct timespec ts;
index d90927f31ff6b4dba6a5ca6a26e5ec7e242c0fa7..5a7fd7af3a6de39d4a0d5c5ed5a758c92aeb88f3 100644 (file)
@@ -859,7 +859,7 @@ static void perf_top__mmap_read(struct perf_top *top)
 
 static int perf_top__start_counters(struct perf_top *top)
 {
-       char msg[512];
+       char msg[BUFSIZ];
        struct perf_evsel *counter;
        struct perf_evlist *evlist = top->evlist;
        struct record_opts *opts = &top->record_opts;
index 04e536ae4d88423e3c05a98fd1bd97ff64379b14..cd2fb42e5dd4d00efc49614e76d5f27984c22f63 100644 (file)
@@ -2469,7 +2469,9 @@ int perf_evsel__open_strerror(struct perf_evsel *evsel, struct target *target,
                 "  -1: Allow use of (almost) all events by all users\n"
                 ">= 0: Disallow raw tracepoint access by users without CAP_IOC_LOCK\n"
                 ">= 1: Disallow CPU event access by users without CAP_SYS_ADMIN\n"
-                ">= 2: Disallow kernel profiling by users without CAP_SYS_ADMIN",
+                ">= 2: Disallow kernel profiling by users without CAP_SYS_ADMIN\n\n"
+                "To make this setting permanent, edit /etc/sysctl.conf too, e.g.:\n\n"
+                "      kernel.perf_event_paranoid = -1\n" ,
                                 target->system_wide ? "system-wide " : "",
                                 perf_event_paranoid());
        case ENOENT: