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