Skip to content

Commit

Permalink
perf tools: Fix buildid cache handling of kallsyms with kcore
Browse files Browse the repository at this point in the history
When kallsyms is used with kcore the dso long_name becomes the kcore
file name.  That prevents the buildid cache from caching kallsyms.
(There is no support at present for caching kcore).  Fix by changing it
so that the kallsyms name is used in that case instead.

Signed-off-by: Adrian Hunter <[email protected]>
Cc: David Ahern <[email protected]>
Cc: Frederic Weisbecker <[email protected]>
Cc: Ingo Molnar <[email protected]>
Cc: Jiri Olsa <[email protected]>
Cc: Mike Galbraith <[email protected]>
Cc: Namhyung Kim <[email protected]>
Cc: Paul Mackerras <[email protected]>
Cc: Peter Zijlstra <[email protected]>
Cc: Stephane Eranian <[email protected]>
Link: http://lkml.kernel.org/r/[email protected]
[ Kept 'struct foo' pointer as first parameter of foo__ prefixed functions ]
Signed-off-by: Arnaldo Carvalho de Melo <[email protected]>
  • Loading branch information
ahunter6 authored and acmel committed Sep 19, 2013
1 parent 886b37b commit 5b6a42f
Showing 1 changed file with 28 additions and 13 deletions.
41 changes: 28 additions & 13 deletions tools/perf/util/header.c
Original file line number Diff line number Diff line change
Expand Up @@ -199,9 +199,11 @@ static int write_buildid(char *name, size_t name_len, u8 *build_id,
return write_padded(fd, name, name_len + 1, len);
}

static int __dsos__write_buildid_table(struct list_head *head, pid_t pid,
u16 misc, int fd)
static int __dsos__write_buildid_table(struct list_head *head,
struct machine *machine,
pid_t pid, u16 misc, int fd)
{
char nm[PATH_MAX];
struct dso *pos;

dsos__for_each_with_build_id(pos, head) {
Expand All @@ -215,6 +217,10 @@ static int __dsos__write_buildid_table(struct list_head *head, pid_t pid,
if (is_vdso_map(pos->short_name)) {
name = (char *) VDSO__MAP_NAME;
name_len = sizeof(VDSO__MAP_NAME) + 1;
} else if (dso__is_kcore(pos)) {
machine__mmap_name(machine, nm, sizeof(nm));
name = nm;
name_len = strlen(nm) + 1;
} else {
name = pos->long_name;
name_len = pos->long_name_len + 1;
Expand All @@ -240,10 +246,10 @@ static int machine__write_buildid_table(struct machine *machine, int fd)
umisc = PERF_RECORD_MISC_GUEST_USER;
}

err = __dsos__write_buildid_table(&machine->kernel_dsos, machine->pid,
kmisc, fd);
err = __dsos__write_buildid_table(&machine->kernel_dsos, machine,
machine->pid, kmisc, fd);
if (err == 0)
err = __dsos__write_buildid_table(&machine->user_dsos,
err = __dsos__write_buildid_table(&machine->user_dsos, machine,
machine->pid, umisc, fd);
return err;
}
Expand Down Expand Up @@ -375,32 +381,41 @@ int build_id_cache__remove_s(const char *sbuild_id, const char *debugdir)
return err;
}

static int dso__cache_build_id(struct dso *dso, const char *debugdir)
static int dso__cache_build_id(struct dso *dso, struct machine *machine,
const char *debugdir)
{
bool is_kallsyms = dso->kernel && dso->long_name[0] != '/';
bool is_vdso = is_vdso_map(dso->short_name);
char *name = dso->long_name;
char nm[PATH_MAX];

return build_id_cache__add_b(dso->build_id, sizeof(dso->build_id),
dso->long_name, debugdir,
is_kallsyms, is_vdso);
if (dso__is_kcore(dso)) {
is_kallsyms = true;
machine__mmap_name(machine, nm, sizeof(nm));
name = nm;
}
return build_id_cache__add_b(dso->build_id, sizeof(dso->build_id), name,
debugdir, is_kallsyms, is_vdso);
}

static int __dsos__cache_build_ids(struct list_head *head, const char *debugdir)
static int __dsos__cache_build_ids(struct list_head *head,
struct machine *machine, const char *debugdir)
{
struct dso *pos;
int err = 0;

dsos__for_each_with_build_id(pos, head)
if (dso__cache_build_id(pos, debugdir))
if (dso__cache_build_id(pos, machine, debugdir))
err = -1;

return err;
}

static int machine__cache_build_ids(struct machine *machine, const char *debugdir)
{
int ret = __dsos__cache_build_ids(&machine->kernel_dsos, debugdir);
ret |= __dsos__cache_build_ids(&machine->user_dsos, debugdir);
int ret = __dsos__cache_build_ids(&machine->kernel_dsos, machine,
debugdir);
ret |= __dsos__cache_build_ids(&machine->user_dsos, machine, debugdir);
return ret;
}

Expand Down

0 comments on commit 5b6a42f

Please sign in to comment.