summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAdrian Hunter <adrian.hunter@intel.com>2018-11-06 16:07:10 -0500
committerArnaldo Carvalho de Melo <acme@redhat.com>2018-12-17 12:54:07 -0500
commitec1891afae740be581ecf5abc8bda74c4549203f (patch)
treec149a4b9797127900933cab6b20b09841660e510
parent804234f27180dcf9a25cb98a88d5212f65b7f3fd (diff)
perf machine: Record if a arch has a single user/kernel address space
Some architectures have a single address space for kernel and user addresses, which makes it possible to determine if an address is in kernel space or user space. Some don't, e.g.: sparc. Cache that info in perf_env so that, for instance, code needing to fallback failed symbol lookups at the kernel space in single address space arches can lookup at userspace. Signed-off-by: Adrian Hunter <adrian.hunter@intel.com> Cc: Andi Kleen <ak@linux.intel.com> Cc: David S. Miller <davem@davemloft.net> Cc: Jiri Olsa <jolsa@redhat.com> Cc: Leo Yan <leo.yan@linaro.org> Cc: Mathieu Poirier <mathieu.poirier@linaro.org> Cc: stable@vger.kernel.org # 4.19 Link: http://lkml.kernel.org/r/20181106210712.12098-2-adrian.hunter@intel.com [ split from a larger patch ] Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
-rw-r--r--tools/perf/arch/common.c10
-rw-r--r--tools/perf/arch/common.h1
-rw-r--r--tools/perf/util/machine.h1
-rw-r--r--tools/perf/util/session.c4
4 files changed, 16 insertions, 0 deletions
diff --git a/tools/perf/arch/common.c b/tools/perf/arch/common.c
index 82657c01a3b8..5f69fd0b745a 100644
--- a/tools/perf/arch/common.c
+++ b/tools/perf/arch/common.c
@@ -200,3 +200,13 @@ int perf_env__lookup_objdump(struct perf_env *env, const char **path)
200 200
201 return perf_env__lookup_binutils_path(env, "objdump", path); 201 return perf_env__lookup_binutils_path(env, "objdump", path);
202} 202}
203
204/*
205 * Some architectures have a single address space for kernel and user addresses,
206 * which makes it possible to determine if an address is in kernel space or user
207 * space.
208 */
209bool perf_env__single_address_space(struct perf_env *env)
210{
211 return strcmp(perf_env__arch(env), "sparc");
212}
diff --git a/tools/perf/arch/common.h b/tools/perf/arch/common.h
index 2167001b18c5..c298a446d1f6 100644
--- a/tools/perf/arch/common.h
+++ b/tools/perf/arch/common.h
@@ -5,5 +5,6 @@
5#include "../util/env.h" 5#include "../util/env.h"
6 6
7int perf_env__lookup_objdump(struct perf_env *env, const char **path); 7int perf_env__lookup_objdump(struct perf_env *env, const char **path);
8bool perf_env__single_address_space(struct perf_env *env);
8 9
9#endif /* ARCH_PERF_COMMON_H */ 10#endif /* ARCH_PERF_COMMON_H */
diff --git a/tools/perf/util/machine.h b/tools/perf/util/machine.h
index d856b85862e2..ca897a73014c 100644
--- a/tools/perf/util/machine.h
+++ b/tools/perf/util/machine.h
@@ -42,6 +42,7 @@ struct machine {
42 u16 id_hdr_size; 42 u16 id_hdr_size;
43 bool comm_exec; 43 bool comm_exec;
44 bool kptr_restrict_warned; 44 bool kptr_restrict_warned;
45 bool single_address_space;
45 char *root_dir; 46 char *root_dir;
46 char *mmap_name; 47 char *mmap_name;
47 struct threads threads[THREADS__TABLE_SIZE]; 48 struct threads threads[THREADS__TABLE_SIZE];
diff --git a/tools/perf/util/session.c b/tools/perf/util/session.c
index 7d2c8ce6cfad..f8eab197f35c 100644
--- a/tools/perf/util/session.c
+++ b/tools/perf/util/session.c
@@ -24,6 +24,7 @@
24#include "thread.h" 24#include "thread.h"
25#include "thread-stack.h" 25#include "thread-stack.h"
26#include "stat.h" 26#include "stat.h"
27#include "arch/common.h"
27 28
28static int perf_session__deliver_event(struct perf_session *session, 29static int perf_session__deliver_event(struct perf_session *session,
29 union perf_event *event, 30 union perf_event *event,
@@ -150,6 +151,9 @@ struct perf_session *perf_session__new(struct perf_data *data,
150 session->machines.host.env = &perf_env; 151 session->machines.host.env = &perf_env;
151 } 152 }
152 153
154 session->machines.host.single_address_space =
155 perf_env__single_address_space(session->machines.host.env);
156
153 if (!data || perf_data__is_write(data)) { 157 if (!data || perf_data__is_write(data)) {
154 /* 158 /*
155 * In O_RDONLY mode this will be performed when reading the 159 * In O_RDONLY mode this will be performed when reading the