From: Leo Yan <leo.yan@linaro.org>
To: Arnaldo Carvalho de Melo <acme@kernel.org>,
Jiri Olsa <jolsa@redhat.com>,
Peter Zijlstra <peterz@infradead.org>,
Ingo Molnar <mingo@redhat.com>,
Mark Rutland <mark.rutland@arm.com>,
Alexander Shishkin <alexander.shishkin@linux.intel.com>,
Namhyung Kim <namhyung@kernel.org>,
Alexei Starovoitov <ast@kernel.org>,
Daniel Borkmann <daniel@iogearbox.net>,
Andrii Nakryiko <andrii@kernel.org>,
Martin KaFai Lau <kafai@fb.com>, Song Liu <songliubraving@fb.com>,
Yonghong Song <yhs@fb.com>,
John Fastabend <john.fastabend@gmail.com>,
KP Singh <kpsingh@kernel.org>, Jin Yao <yao.jin@linux.intel.com>,
John Garry <john.garry@huawei.com>,
Yonatan Goldschmidt <yonatan.goldschmidt@granulate.io>,
linux-perf-users@vger.kernel.org, linux-kernel@vger.kernel.org,
netdev@vger.kernel.org, bpf@vger.kernel.org
Cc: Leo Yan <leo.yan@linaro.org>
Subject: [PATCH v1 0/2] perf: Fix perf in non-root PID namespace
Date: Sun, 12 Dec 2021 21:47:19 +0800 [thread overview]
Message-ID: <20211212134721.1721245-1-leo.yan@linaro.org> (raw)
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
next reply other threads:[~2021-12-12 13:47 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-12-12 13:47 Leo Yan [this message]
2021-12-12 13:47 ` [PATCH v1 1/2] perf namespaces: Add helper nsinfo__is_in_root_namespace() Leo Yan
2021-12-13 18:20 ` Arnaldo Carvalho de Melo
2021-12-12 13:47 ` [PATCH v1 2/2] perf evlist: Don't run perf in non-root PID namespace when launch workload Leo Yan
2021-12-13 13:54 ` James Clark
2021-12-14 3:24 ` Leo Yan
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20211212134721.1721245-1-leo.yan@linaro.org \
--to=leo.yan@linaro.org \
--cc=acme@kernel.org \
--cc=alexander.shishkin@linux.intel.com \
--cc=andrii@kernel.org \
--cc=ast@kernel.org \
--cc=bpf@vger.kernel.org \
--cc=daniel@iogearbox.net \
--cc=john.fastabend@gmail.com \
--cc=john.garry@huawei.com \
--cc=jolsa@redhat.com \
--cc=kafai@fb.com \
--cc=kpsingh@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-perf-users@vger.kernel.org \
--cc=mark.rutland@arm.com \
--cc=mingo@redhat.com \
--cc=namhyung@kernel.org \
--cc=netdev@vger.kernel.org \
--cc=peterz@infradead.org \
--cc=songliubraving@fb.com \
--cc=yao.jin@linux.intel.com \
--cc=yhs@fb.com \
--cc=yonatan.goldschmidt@granulate.io \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).