Skip to content

Commit 999e4ea

Browse files
namhyungacmel
authored andcommitted
perf tools: Honor namespace when synthesizing build-ids
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 <namhyung@kernel.org> Cc: Adrian Hunter <adrian.hunter@intel.com> Cc: Ian Rogers <irogers@google.com> Cc: Jiri Olsa <jolsa@kernel.org> Cc: Peter Zijlstra <peterz@infradead.org> Link: http://lore.kernel.org/lkml/20220920222822.2171056-1-namhyung@kernel.org Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
1 parent 356edec commit 999e4ea

1 file changed

Lines changed: 14 additions & 3 deletions

File tree

tools/perf/util/synthetic-events.c

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -367,13 +367,24 @@ static void perf_record_mmap2__read_build_id(struct perf_record_mmap2 *event,
367367
bool is_kernel)
368368
{
369369
struct build_id bid;
370+
struct nsinfo *nsi;
371+
struct nscookie nc;
370372
int rc;
371373

372-
if (is_kernel)
374+
if (is_kernel) {
373375
rc = sysfs__read_build_id("/sys/kernel/notes", &bid);
374-
else
375-
rc = filename__read_build_id(event->filename, &bid) > 0 ? 0 : -1;
376+
goto out;
377+
}
378+
379+
nsi = nsinfo__new(event->pid);
380+
nsinfo__mountns_enter(nsi, &nc);
376381

382+
rc = filename__read_build_id(event->filename, &bid) > 0 ? 0 : -1;
383+
384+
nsinfo__mountns_exit(&nc);
385+
nsinfo__put(nsi);
386+
387+
out:
377388
if (rc == 0) {
378389
memcpy(event->build_id, bid.data, sizeof(bid.data));
379390
event->build_id_size = (u8) bid.size;

0 commit comments

Comments
 (0)