aboutsummaryrefslogtreecommitdiffstats
path: root/tools/perf/builtin-inject.c
diff options
context:
space:
mode:
authorNamhyung Kim <namhyung@kernel.org>2020-10-12 16:02:11 +0900
committerArnaldo Carvalho de Melo <acme@redhat.com>2020-10-13 10:59:42 -0300
commit336c95b297e8127705e590bbd25f5c627bfcb782 (patch)
tree2c0e54c8ab0990ec152317c10403456860ad43b5 /tools/perf/builtin-inject.c
parentperf inject: Add missing callbacks in perf_tool (diff)
downloadlinux-dev-336c95b297e8127705e590bbd25f5c627bfcb782.tar.xz
linux-dev-336c95b297e8127705e590bbd25f5c627bfcb782.zip
perf inject: Enter namespace when reading build-id
It should be in a proper mnt namespace when accessing the file. I think this had no problem since the build-id was actually read from map__load() -> dso__load() already. But I'd like to change it in the following commit. Acked-by: Jiri Olsa <jolsa@redhat.com> Signed-off-by: Namhyung Kim <namhyung@kernel.org> Link: https://lore.kernel.org/r/20201012070214.2074921-4-namhyung@kernel.org Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Diffstat (limited to 'tools/perf/builtin-inject.c')
-rw-r--r--tools/perf/builtin-inject.c8
1 files changed, 6 insertions, 2 deletions
diff --git a/tools/perf/builtin-inject.c b/tools/perf/builtin-inject.c
index 2c5e23d73a8a..670157db2502 100644
--- a/tools/perf/builtin-inject.c
+++ b/tools/perf/builtin-inject.c
@@ -23,6 +23,7 @@
#include "util/symbol.h"
#include "util/synthetic-events.h"
#include "util/thread.h"
+#include "util/namespaces.h"
#include <linux/err.h>
#include <subcmd/parse-options.h>
@@ -419,16 +420,19 @@ static int perf_event__repipe_tracing_data(struct perf_session *session,
static int dso__read_build_id(struct dso *dso)
{
+ struct nscookie nsc;
+
if (dso->has_build_id)
return 0;
+ nsinfo__mountns_enter(dso->nsinfo, &nsc);
if (filename__read_build_id(dso->long_name, dso->build_id,
sizeof(dso->build_id)) > 0) {
dso->has_build_id = true;
- return 0;
}
+ nsinfo__mountns_exit(&nsc);
- return -1;
+ return dso->has_build_id ? 0 : -1;
}
static int dso__inject_build_id(struct dso *dso, struct perf_tool *tool,