perf symbols: Introduce thread__find_cpumode_addr_location

Its one level up thread__find_addr_location, where it will look in
different domains for a sample: user, kernel, hypervisor, etc.

Will soon be used by a patchkit by Andi Kleen.

Cc: Adrian Hunter <adrian.hunter@intel.com>
Cc: Andi Kleen <andi@firstfloor.org>
Cc: David Ahern <dsahern@gmail.com>
Cc: Frederic Weisbecker <fweisbec@gmail.com>
Cc: Jiri Olsa <jolsa@redhat.com>
Cc: Mike Galbraith <efault@gmx.de>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Paul Mackerras <paulus@samba.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Stephane Eranian <eranian@google.com>
Link: http://lkml.kernel.org/n/tip-so6nxkh7xj48bc5kq4jpj991@git.kernel.orgSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
parent 0ea590ae
...@@ -1184,26 +1184,13 @@ static bool symbol__match_regex(struct symbol *sym, regex_t *regex) ...@@ -1184,26 +1184,13 @@ static bool symbol__match_regex(struct symbol *sym, regex_t *regex)
return 0; return 0;
} }
static const u8 cpumodes[] = {
PERF_RECORD_MISC_USER,
PERF_RECORD_MISC_KERNEL,
PERF_RECORD_MISC_GUEST_USER,
PERF_RECORD_MISC_GUEST_KERNEL
};
#define NCPUMODES (sizeof(cpumodes)/sizeof(u8))
static void ip__resolve_ams(struct machine *machine, struct thread *thread, static void ip__resolve_ams(struct machine *machine, struct thread *thread,
struct addr_map_symbol *ams, struct addr_map_symbol *ams,
u64 ip) u64 ip)
{ {
struct addr_location al; struct addr_location al;
size_t i;
u8 m;
memset(&al, 0, sizeof(al)); memset(&al, 0, sizeof(al));
for (i = 0; i < NCPUMODES; i++) {
m = cpumodes[i];
/* /*
* We cannot use the header.misc hint to determine whether a * We cannot use the header.misc hint to determine whether a
* branch stack address is user, kernel, guest, hypervisor. * branch stack address is user, kernel, guest, hypervisor.
...@@ -1211,12 +1198,8 @@ static void ip__resolve_ams(struct machine *machine, struct thread *thread, ...@@ -1211,12 +1198,8 @@ static void ip__resolve_ams(struct machine *machine, struct thread *thread,
* Thus, we have to try consecutively until we find a match * Thus, we have to try consecutively until we find a match
* or else, the symbol is unknown * or else, the symbol is unknown
*/ */
thread__find_addr_location(thread, machine, m, MAP__FUNCTION, thread__find_cpumode_addr_location(thread, machine, MAP__FUNCTION, ip, &al);
ip, &al);
if (al.map)
goto found;
}
found:
ams->addr = ip; ams->addr = ip;
ams->al_addr = al.addr; ams->al_addr = al.addr;
ams->sym = al.sym; ams->sym = al.sym;
......
...@@ -142,3 +142,24 @@ int thread__fork(struct thread *thread, struct thread *parent, u64 timestamp) ...@@ -142,3 +142,24 @@ int thread__fork(struct thread *thread, struct thread *parent, u64 timestamp)
return 0; return 0;
} }
void thread__find_cpumode_addr_location(struct thread *thread,
struct machine *machine,
enum map_type type, u64 addr,
struct addr_location *al)
{
size_t i;
const u8 const cpumodes[] = {
PERF_RECORD_MISC_USER,
PERF_RECORD_MISC_KERNEL,
PERF_RECORD_MISC_GUEST_USER,
PERF_RECORD_MISC_GUEST_KERNEL
};
for (i = 0; i < ARRAY_SIZE(cpumodes); i++) {
thread__find_addr_location(thread, machine, cpumodes[i], type,
addr, al);
if (al->map)
break;
}
}
...@@ -58,6 +58,11 @@ void thread__find_addr_location(struct thread *thread, struct machine *machine, ...@@ -58,6 +58,11 @@ void thread__find_addr_location(struct thread *thread, struct machine *machine,
u8 cpumode, enum map_type type, u64 addr, u8 cpumode, enum map_type type, u64 addr,
struct addr_location *al); struct addr_location *al);
void thread__find_cpumode_addr_location(struct thread *thread,
struct machine *machine,
enum map_type type, u64 addr,
struct addr_location *al);
static inline void *thread__priv(struct thread *thread) static inline void *thread__priv(struct thread *thread)
{ {
return thread->priv; return thread->priv;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment