linux-perf-users.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v2 1/2] perf tools: Honor namespace when synthesizing build-id
@ 2022-09-20 22:28 Namhyung Kim
  2022-09-20 22:28 ` [PATCH v2 2/2] perf record: Save DSO build-ID for synthesizing Namhyung Kim
  2022-09-21 13:49 ` [PATCH v2 1/2] perf tools: Honor namespace when synthesizing build-id Arnaldo Carvalho de Melo
  0 siblings, 2 replies; 7+ messages in thread
From: Namhyung Kim @ 2022-09-20 22:28 UTC (permalink / raw)
  To: Arnaldo Carvalho de Melo, Jiri Olsa
  Cc: Ingo Molnar, Peter Zijlstra, LKML, Ian Rogers, Adrian Hunter,
	linux-perf-users

It needs to go into a namespace before reading a file.

Fixes: 4183a8d70a28 ("perf tools: Allow synthesizing the build id for kernel/modules/tasks in PERF_RECORD_MMAP2")
Signed-off-by: Namhyung Kim <namhyung@kernel.org>
---
 tools/perf/util/synthetic-events.c | 17 ++++++++++++++---
 1 file changed, 14 insertions(+), 3 deletions(-)

diff --git a/tools/perf/util/synthetic-events.c b/tools/perf/util/synthetic-events.c
index 0ff57ca24577..289ea17ac5f7 100644
--- a/tools/perf/util/synthetic-events.c
+++ b/tools/perf/util/synthetic-events.c
@@ -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;
-- 
2.37.3.968.ga6b4b080e4-goog


^ permalink raw reply related	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2022-10-05 18:24 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-09-20 22:28 [PATCH v2 1/2] perf tools: Honor namespace when synthesizing build-id Namhyung Kim
2022-09-20 22:28 ` [PATCH v2 2/2] perf record: Save DSO build-ID for synthesizing Namhyung Kim
2022-09-21 13:50   ` Arnaldo Carvalho de Melo
2022-09-21 17:55     ` Namhyung Kim
2022-10-05 17:50       ` Namhyung Kim
2022-10-05 18:24         ` Arnaldo Carvalho de Melo
2022-09-21 13:49 ` [PATCH v2 1/2] perf tools: Honor namespace when synthesizing build-id Arnaldo Carvalho de Melo

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).