diff options
-rw-r--r-- | tools/perf/builtin-trace.c | 20 | ||||
-rw-r--r-- | tools/perf/util/machine.c | 1 | ||||
-rw-r--r-- | tools/perf/util/machine.h | 1 |
3 files changed, 21 insertions, 1 deletions
diff --git a/tools/perf/builtin-trace.c b/tools/perf/builtin-trace.c index 6e5c325148e4..e488ac756f39 100644 --- a/tools/perf/builtin-trace.c +++ b/tools/perf/builtin-trace.c | |||
@@ -1160,6 +1160,24 @@ static int trace__tool_process(struct perf_tool *tool, | |||
1160 | return trace__process_event(trace, machine, event, sample); | 1160 | return trace__process_event(trace, machine, event, sample); |
1161 | } | 1161 | } |
1162 | 1162 | ||
1163 | static char *trace__machine__resolve_kernel_addr(void *vmachine, unsigned long long *addrp, char **modp) | ||
1164 | { | ||
1165 | struct machine *machine = vmachine; | ||
1166 | |||
1167 | if (machine->kptr_restrict_warned) | ||
1168 | return NULL; | ||
1169 | |||
1170 | if (symbol_conf.kptr_restrict) { | ||
1171 | pr_warning("Kernel address maps (/proc/{kallsyms,modules}) are restricted.\n\n" | ||
1172 | "Check /proc/sys/kernel/kptr_restrict.\n\n" | ||
1173 | "Kernel samples will not be resolved.\n"); | ||
1174 | machine->kptr_restrict_warned = true; | ||
1175 | return NULL; | ||
1176 | } | ||
1177 | |||
1178 | return machine__resolve_kernel_addr(vmachine, addrp, modp); | ||
1179 | } | ||
1180 | |||
1163 | static int trace__symbols_init(struct trace *trace, struct perf_evlist *evlist) | 1181 | static int trace__symbols_init(struct trace *trace, struct perf_evlist *evlist) |
1164 | { | 1182 | { |
1165 | int err = symbol__init(NULL); | 1183 | int err = symbol__init(NULL); |
@@ -1171,7 +1189,7 @@ static int trace__symbols_init(struct trace *trace, struct perf_evlist *evlist) | |||
1171 | if (trace->host == NULL) | 1189 | if (trace->host == NULL) |
1172 | return -ENOMEM; | 1190 | return -ENOMEM; |
1173 | 1191 | ||
1174 | if (trace_event__register_resolver(trace->host, machine__resolve_kernel_addr) < 0) | 1192 | if (trace_event__register_resolver(trace->host, trace__machine__resolve_kernel_addr) < 0) |
1175 | return -errno; | 1193 | return -errno; |
1176 | 1194 | ||
1177 | err = __machine__synthesize_threads(trace->host, &trace->tool, &trace->opts.target, | 1195 | err = __machine__synthesize_threads(trace->host, &trace->tool, &trace->opts.target, |
diff --git a/tools/perf/util/machine.c b/tools/perf/util/machine.c index b277984aaa93..bdc33ce40bdc 100644 --- a/tools/perf/util/machine.c +++ b/tools/perf/util/machine.c | |||
@@ -43,6 +43,7 @@ int machine__init(struct machine *machine, const char *root_dir, pid_t pid) | |||
43 | 43 | ||
44 | machine->symbol_filter = NULL; | 44 | machine->symbol_filter = NULL; |
45 | machine->id_hdr_size = 0; | 45 | machine->id_hdr_size = 0; |
46 | machine->kptr_restrict_warned = false; | ||
46 | machine->comm_exec = false; | 47 | machine->comm_exec = false; |
47 | machine->kernel_start = 0; | 48 | machine->kernel_start = 0; |
48 | 49 | ||
diff --git a/tools/perf/util/machine.h b/tools/perf/util/machine.h index 83f46790c52f..41ac9cfd416b 100644 --- a/tools/perf/util/machine.h +++ b/tools/perf/util/machine.h | |||
@@ -28,6 +28,7 @@ struct machine { | |||
28 | pid_t pid; | 28 | pid_t pid; |
29 | u16 id_hdr_size; | 29 | u16 id_hdr_size; |
30 | bool comm_exec; | 30 | bool comm_exec; |
31 | bool kptr_restrict_warned; | ||
31 | char *root_dir; | 32 | char *root_dir; |
32 | struct rb_root threads; | 33 | struct rb_root threads; |
33 | pthread_rwlock_t threads_lock; | 34 | pthread_rwlock_t threads_lock; |