diff options
author | Igor Lubashev <ilubashe@akamai.com> | 2019-08-07 10:44:14 -0400 |
---|---|---|
committer | Arnaldo Carvalho de Melo <acme@redhat.com> | 2019-08-14 10:48:39 -0300 |
commit | c22e150e3afa6f8db2300bd510e4ac26bbee1bf3 (patch) | |
tree | 62da5a7e092c75a43660d2075d626663d3aa3767 /tools/perf/util/setup.py | |
parent | 74d5f3d06f707eb5f7e1908ad88954bde02000ce (diff) | |
download | linux-c22e150e3afa6f8db2300bd510e4ac26bbee1bf3.tar.bz2 |
perf tools: Add helpers to use capabilities if present
Add utilities to help checking capabilities of the running procss. Make
perf link with libcap, if it is available. If no libcap-dev[el],
fallback to the geteuid() == 0 test used before.
Committer notes:
$ perf test python
18: 'import perf' in python : FAILED!
$ perf test -v python
Couldn't bump rlimit(MEMLOCK), failures may take place when creating BPF maps, etc
18: 'import perf' in python :
--- start ---
test child forked, pid 23288
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ImportError: /tmp/build/perf/python/perf.so: undefined symbol: cap_get_flag
test child finished with -1
---- end ----
'import perf' in python: FAILED!
$
This happens because differently from the perf binary generated with
this patch applied:
$ ldd /tmp/build/perf/perf | grep libcap
libcap.so.2 => /lib64/libcap.so.2 (0x00007f724a4ef000)
$
The python binding isn't linking with libcap:
$ ldd /tmp/build/perf/python/perf.so | grep libcap
$
So add 'cap' to the 'extra_libraries' variable in
tools/perf/util/setup.py, and rebuild:
$ perf test python
18: 'import perf' in python : Ok
$
If we explicitely disable libcap it also continues to work:
$ make NO_LIBCAP=1 -C tools/perf O=/tmp/build/perf install-bin
$ ldd /tmp/build/perf/perf | grep libcap
$ ldd /tmp/build/perf/python/perf.so | grep libcap
$ perf test python
18: 'import perf' in python : Ok
$
Signed-off-by: Igor Lubashev <ilubashe@akamai.com>
Acked-by: Jiri Olsa <jolsa@kernel.org>
Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
Cc: Alexey Budankov <alexey.budankov@linux.intel.com>
Cc: James Morris <jmorris@namei.org>
Cc: Mathieu Poirier <mathieu.poirier@linaro.org>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Suzuki Poulouse <suzuki.poulose@arm.com>
Cc: linux-arm-kernel@lists.infradead.org
[ split from a larger patch ]
Link: http://lkml.kernel.org/r/8a1e76cf5c7c9796d0d4d240fbaa85305298aafa.1565188228.git.ilubashe@akamai.com
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Diffstat (limited to 'tools/perf/util/setup.py')
-rw-r--r-- | tools/perf/util/setup.py | 2 |
1 files changed, 2 insertions, 0 deletions
diff --git a/tools/perf/util/setup.py b/tools/perf/util/setup.py index d48f9cd58964..aa344a163eaf 100644 --- a/tools/perf/util/setup.py +++ b/tools/perf/util/setup.py @@ -59,6 +59,8 @@ ext_sources = list(map(lambda x: '%s/%s' % (src_perf, x) , ext_sources)) extra_libraries = [] if '-DHAVE_LIBNUMA_SUPPORT' in cflags: extra_libraries = [ 'numa' ] +if '-DHAVE_LIBCAP_SUPPORT' in cflags: + extra_libraries += [ 'cap' ] perf = Extension('perf', sources = ext_sources, |