[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Date: Sun, 12 Dec 2021 21:47:19 +0800
From: Leo Yan <leo.yan@...aro.org>
To: Arnaldo Carvalho de Melo <acme@...nel.org>,
Jiri Olsa <jolsa@...hat.com>,
Peter Zijlstra <peterz@...radead.org>,
Ingo Molnar <mingo@...hat.com>,
Mark Rutland <mark.rutland@....com>,
Alexander Shishkin <alexander.shishkin@...ux.intel.com>,
Namhyung Kim <namhyung@...nel.org>,
Alexei Starovoitov <ast@...nel.org>,
Daniel Borkmann <daniel@...earbox.net>,
Andrii Nakryiko <andrii@...nel.org>,
Martin KaFai Lau <kafai@...com>,
Song Liu <songliubraving@...com>, Yonghong Song <yhs@...com>,
John Fastabend <john.fastabend@...il.com>,
KP Singh <kpsingh@...nel.org>,
Jin Yao <yao.jin@...ux.intel.com>,
John Garry <john.garry@...wei.com>,
Yonatan Goldschmidt <yonatan.goldschmidt@...nulate.io>,
linux-perf-users@...r.kernel.org, linux-kernel@...r.kernel.org,
netdev@...r.kernel.org, bpf@...r.kernel.org
Cc: Leo Yan <leo.yan@...aro.org>
Subject: [PATCH v1 0/2] perf: Fix perf in non-root PID namespace
When perf tool runs in non-root PID namespace, it fails to gather the
correct process and namespace info for the profiled (forked) program
since it wrongly uses the non-root PID number to access '/proc' nodes.
To fix this issue, this patchset adds the checking if the perf tool runs
in the non-root namespace, if it is the case, perf tool reports error to
notify users to run perf tool in root PID namespace. This can ensure
perf tool gathers correct process info for profiled program.
After applied this patchset:
# unshare --fork --pid perf record -e cs_etm//u -a -- uname
Perf runs in non-root PID namespace; please run perf tool in the root PID namespace for gathering process info.
Couldn't run the workload!
# perf record -e cs_etm//u -a -- unshare --fork --pid uname
Couldn't synthesize bpf events.
Linux
[ perf record: Woken up 1 times to write data ]
[ perf record: Captured and wrote 0.438 MB perf_test.data ]
Leo Yan (2):
perf namespaces: Add helper nsinfo__is_in_root_namespace()
perf evlist: Don't run perf in non-root PID namespace when launch
workload
tools/perf/util/evlist.c | 7 ++++
tools/perf/util/namespaces.c | 76 ++++++++++++++++++++++--------------
tools/perf/util/namespaces.h | 2 +
3 files changed, 55 insertions(+), 30 deletions(-)
--
2.25.1
Powered by blists - more mailing lists