diff options
-rw-r--r-- | tools/perf/util/evlist.c | 3 | ||||
-rw-r--r-- | tools/perf/util/util.c | 19 | ||||
-rw-r--r-- | tools/perf/util/util.h | 1 |
3 files changed, 21 insertions, 2 deletions
diff --git a/tools/perf/util/evlist.c b/tools/perf/util/evlist.c index af250556b33f..2eb7378e4c40 100644 --- a/tools/perf/util/evlist.c +++ b/tools/perf/util/evlist.c | |||
@@ -1191,8 +1191,7 @@ int perf_evlist__strerror_open(struct perf_evlist *evlist __maybe_unused, | |||
1191 | "Error:\t%s.\n" | 1191 | "Error:\t%s.\n" |
1192 | "Hint:\tCheck /proc/sys/kernel/perf_event_paranoid setting.", emsg); | 1192 | "Hint:\tCheck /proc/sys/kernel/perf_event_paranoid setting.", emsg); |
1193 | 1193 | ||
1194 | if (filename__read_int("/proc/sys/kernel/perf_event_paranoid", &value)) | 1194 | value = perf_event_paranoid(); |
1195 | break; | ||
1196 | 1195 | ||
1197 | printed += scnprintf(buf + printed, size - printed, "\nHint:\t"); | 1196 | printed += scnprintf(buf + printed, size - printed, "\nHint:\t"); |
1198 | 1197 | ||
diff --git a/tools/perf/util/util.c b/tools/perf/util/util.c index 4a57609c0b43..8f63dba212d7 100644 --- a/tools/perf/util/util.c +++ b/tools/perf/util/util.c | |||
@@ -1,5 +1,6 @@ | |||
1 | #include "../perf.h" | 1 | #include "../perf.h" |
2 | #include "util.h" | 2 | #include "util.h" |
3 | #include "fs.h" | ||
3 | #include <sys/mman.h> | 4 | #include <sys/mman.h> |
4 | #ifdef HAVE_BACKTRACE_SUPPORT | 5 | #ifdef HAVE_BACKTRACE_SUPPORT |
5 | #include <execinfo.h> | 6 | #include <execinfo.h> |
@@ -8,6 +9,7 @@ | |||
8 | #include <stdlib.h> | 9 | #include <stdlib.h> |
9 | #include <string.h> | 10 | #include <string.h> |
10 | #include <errno.h> | 11 | #include <errno.h> |
12 | #include <limits.h> | ||
11 | #include <linux/kernel.h> | 13 | #include <linux/kernel.h> |
12 | 14 | ||
13 | /* | 15 | /* |
@@ -496,3 +498,20 @@ const char *get_filename_for_perf_kvm(void) | |||
496 | 498 | ||
497 | return filename; | 499 | return filename; |
498 | } | 500 | } |
501 | |||
502 | int perf_event_paranoid(void) | ||
503 | { | ||
504 | char path[PATH_MAX]; | ||
505 | const char *procfs = procfs__mountpoint(); | ||
506 | int value; | ||
507 | |||
508 | if (!procfs) | ||
509 | return INT_MAX; | ||
510 | |||
511 | scnprintf(path, PATH_MAX, "%s/sys/kernel/perf_event_paranoid", procfs); | ||
512 | |||
513 | if (filename__read_int(path, &value)) | ||
514 | return INT_MAX; | ||
515 | |||
516 | return value; | ||
517 | } | ||
diff --git a/tools/perf/util/util.h b/tools/perf/util/util.h index 0171213d1d4d..1e7d4136cc82 100644 --- a/tools/perf/util/util.h +++ b/tools/perf/util/util.h | |||
@@ -321,6 +321,7 @@ void free_srcline(char *srcline); | |||
321 | 321 | ||
322 | int filename__read_int(const char *filename, int *value); | 322 | int filename__read_int(const char *filename, int *value); |
323 | int filename__read_str(const char *filename, char **buf, size_t *sizep); | 323 | int filename__read_str(const char *filename, char **buf, size_t *sizep); |
324 | int perf_event_paranoid(void); | ||
324 | 325 | ||
325 | const char *get_filename_for_perf_kvm(void); | 326 | const char *get_filename_for_perf_kvm(void); |
326 | #endif /* GIT_COMPAT_UTIL_H */ | 327 | #endif /* GIT_COMPAT_UTIL_H */ |