linux-perf-users.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v1 0/2] perf: Fix perf in non-root PID namespace
@ 2021-12-12 13:47 Leo Yan
  2021-12-12 13:47 ` [PATCH v1 1/2] perf namespaces: Add helper nsinfo__is_in_root_namespace() Leo Yan
  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
  0 siblings, 2 replies; 6+ messages in thread
From: Leo Yan @ 2021-12-12 13:47 UTC (permalink / raw)
  To: Arnaldo Carvalho de Melo, Jiri Olsa, Peter Zijlstra, Ingo Molnar,
	Mark Rutland, Alexander Shishkin, Namhyung Kim,
	Alexei Starovoitov, Daniel Borkmann, Andrii Nakryiko,
	Martin KaFai Lau, Song Liu, Yonghong Song, John Fastabend,
	KP Singh, Jin Yao, John Garry, Yonatan Goldschmidt,
	linux-perf-users, linux-kernel, netdev, bpf
  Cc: Leo Yan

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


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

end of thread, other threads:[~2021-12-14  3:24 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2021-12-12 13:47 [PATCH v1 0/2] perf: Fix perf in non-root PID namespace Leo Yan
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

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).