Skip to content

Commit

Permalink
perf tools: Honor namespace when synthesizing build-ids
Browse files Browse the repository at this point in the history
It needs to enter the namespace before reading a file.

Fixes: 4183a8d ("perf tools: Allow synthesizing the build id for kernel/modules/tasks in PERF_RECORD_MMAP2")
Signed-off-by: Namhyung Kim <[email protected]>
Cc: Adrian Hunter <[email protected]>
Cc: Ian Rogers <[email protected]>
Cc: Jiri Olsa <[email protected]>
Cc: Peter Zijlstra <[email protected]>
Link: http://lore.kernel.org/lkml/[email protected]
Signed-off-by: Arnaldo Carvalho de Melo <[email protected]>
  • Loading branch information
namhyung authored and acmel committed Sep 21, 2022
1 parent 356edec commit 999e4ea
Showing 1 changed file with 14 additions and 3 deletions.
17 changes: 14 additions & 3 deletions tools/perf/util/synthetic-events.c
Original file line number Diff line number Diff line change
Expand Up @@ -367,13 +367,24 @@ static void perf_record_mmap2__read_build_id(struct perf_record_mmap2 *event,
bool is_kernel)
{
struct build_id bid;
struct nsinfo *nsi;
struct nscookie nc;
int rc;

if (is_kernel)
if (is_kernel) {
rc = sysfs__read_build_id("/sys/kernel/notes", &bid);
else
rc = filename__read_build_id(event->filename, &bid) > 0 ? 0 : -1;
goto out;
}

nsi = nsinfo__new(event->pid);
nsinfo__mountns_enter(nsi, &nc);

rc = filename__read_build_id(event->filename, &bid) > 0 ? 0 : -1;

nsinfo__mountns_exit(&nc);
nsinfo__put(nsi);

out:
if (rc == 0) {
memcpy(event->build_id, bid.data, sizeof(bid.data));
event->build_id_size = (u8) bid.size;
Expand Down

0 comments on commit 999e4ea

Please sign in to comment.