mirror of
https://github.com/Fishwaldo/Star64_linux.git
synced 2025-07-23 23:32:14 +00:00
perf maps: Lookup maps in both intitial mountns and inner mountns.
If a process is in a mountns and has symbols in /tmp/perf-<pid>.map, look first in the namespace using the tgid for the pidns that the process might be in. If the map isn't found there, try looking in the mountns where perf is running, and use the tgid that's appropriate for perf's pid namespace. If all else fails, use the original pid. This allows us to locate a symbol map file in the mount namespace, if it was generated there. However, we also try the tool's /tmp in case it's there instead. Signed-off-by: Krister Johansen <kjlx@templeofstupid.com> Tested-by: Brendan Gregg <brendan.d.gregg@gmail.com> Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com> Cc: Peter Zijlstra <peterz@infradead.org> Cc: Thomas-Mich Richter <tmricht@linux.vnet.ibm.com> Link: http://lkml.kernel.org/r/1499305693-1599-3-git-send-email-kjlx@templeofstupid.com Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
This commit is contained in:
parent
843ff37bb5
commit
bf2e710b3c
6 changed files with 160 additions and 27 deletions
|
@ -146,11 +146,13 @@ void map__init(struct map *map, enum map_type type,
|
|||
}
|
||||
|
||||
struct map *map__new(struct machine *machine, u64 start, u64 len,
|
||||
u64 pgoff, u32 pid, u32 d_maj, u32 d_min, u64 ino,
|
||||
u64 pgoff, u32 d_maj, u32 d_min, u64 ino,
|
||||
u64 ino_gen, u32 prot, u32 flags, char *filename,
|
||||
enum map_type type, struct thread *thread)
|
||||
{
|
||||
struct map *map = malloc(sizeof(*map));
|
||||
struct nsinfo *nsi = NULL;
|
||||
struct nsinfo *nnsi;
|
||||
|
||||
if (map != NULL) {
|
||||
char newfilename[PATH_MAX];
|
||||
|
@ -168,9 +170,11 @@ struct map *map__new(struct machine *machine, u64 start, u64 len,
|
|||
map->ino_generation = ino_gen;
|
||||
map->prot = prot;
|
||||
map->flags = flags;
|
||||
nsi = nsinfo__get(thread->nsinfo);
|
||||
|
||||
if ((anon || no_dso) && type == MAP__FUNCTION) {
|
||||
snprintf(newfilename, sizeof(newfilename), "/tmp/perf-%d.map", pid);
|
||||
if ((anon || no_dso) && nsi && type == MAP__FUNCTION) {
|
||||
snprintf(newfilename, sizeof(newfilename),
|
||||
"/tmp/perf-%d.map", nsi->pid);
|
||||
filename = newfilename;
|
||||
}
|
||||
|
||||
|
@ -180,6 +184,16 @@ struct map *map__new(struct machine *machine, u64 start, u64 len,
|
|||
}
|
||||
|
||||
if (vdso) {
|
||||
/* The vdso maps are always on the host and not the
|
||||
* container. Ensure that we don't use setns to look
|
||||
* them up.
|
||||
*/
|
||||
nnsi = nsinfo__copy(nsi);
|
||||
if (nnsi) {
|
||||
nsinfo__put(nsi);
|
||||
nnsi->need_setns = false;
|
||||
nsi = nnsi;
|
||||
}
|
||||
pgoff = 0;
|
||||
dso = machine__findnew_vdso(machine, thread);
|
||||
} else
|
||||
|
@ -201,11 +215,12 @@ struct map *map__new(struct machine *machine, u64 start, u64 len,
|
|||
if (type != MAP__FUNCTION)
|
||||
dso__set_loaded(dso, map->type);
|
||||
}
|
||||
dso->nsinfo = nsinfo__get(thread->nsinfo);
|
||||
dso->nsinfo = nsi;
|
||||
dso__put(dso);
|
||||
}
|
||||
return map;
|
||||
out_delete:
|
||||
nsinfo__put(nsi);
|
||||
free(map);
|
||||
return NULL;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue