Introduce perf check subcommand
v6 cover Introduce perf check subcommand
The Problem
===========
Currently the presence of a feature is checked with a combination of perf version --build-options and greps, such as:
perf version --build-options | grep " on .* HAVE_FEATURE"
Proposed solution
=================
As suggested by contributors in:
https://lore.kernel.org/linux-perf-users/[email protected]/
Introduce a subcommand "perf check --feature", with which scripts can test for presence of a feature, such as:
perf check --feature HAVE_LIBTRACEEVENT
or
perf check --feature libtraceeventThe usage of "perf version --build-options | grep" has been replaced in two tests, with "perf check --feature" command
Also, to not duplicate the same feature list at multiple places, a new global 'supported_features' array has been introduced in builtin.h, so both commands 'perf check --feature' and 'perf version --build-options' use the same array
'supported_features' feature is an array of 'struct feature_support', which also has the name of the feature, macro used to test it's presence, and a is_builtin member, which will be 0 if feature not built-in, and 1 if built-in
Architectures Tested
====================
* x86_64
* ppc64le
Git tree
========
Git tree with this patch series applied for testing:
https://github.com/adi-g15-ibm/linux/tree/perf-check-feature-v6
Changelog
=========
V6
+ rebased to perf-tools-next/perf-tools-next
+ modified patch #1 to include FEATURE_SUPPORT("bpf_skeletons", HAVE_BPF_SKEL)
V5
+ invert return value of 'has_support', but return value of perf check --feature according to shell convention
V4
+ invert return value of perf check --feature
V3
+ simplified has_support code in builtin-check.c (patch #1)
+ modified patch #3 and patch #4 according to change in return value in patch #1
V2
+ improved the patch series with suggestions from Namhyung
+ fix incorrect return value, added -q option, and moved array definition to perf-check.c
V1
+ changed subcommand name to 'perf check --feature'
+ added documentation for perf check
+ support both macro (eg. HAVE_LIBTRACEEVENT), and name (eg. libtraceevent) as input to 'perf check --feature'
+ change subject and descriptions of all patch mentioning perf check instead of perf build
V0: Previous patch series: https://lore.kernel.org/linux-perf-users/[email protected]/
Aditya Gupta (3):
perf check: introduce check subcommand
perf version: update --build-options to use 'supported_features' array perf tests task_analyzer: use perf check for libtraceevent support
Athira Rajeev (1):
tools/perf/tests: Update probe_vfs_getname.sh script to use perf check
--feature
tools/perf/Build | 1 + tools/perf/Documentation/perf-check.txt | 59 +++++++++ tools/perf/builtin-check.c | 122 ++++++++++++++++++ tools/perf/builtin-version.c | 39 ++---- tools/perf/builtin.h | 18 +++ tools/perf/perf.c | 1 + .../perf/tests/shell/lib/probe_vfs_getname.sh | 4 +- .../shell/record+probe_libc_inet_pton.sh | 5 +- .../shell/record+script_probe_vfs_getname.sh | 5 +- tools/perf/tests/shell/test_task_analyzer.sh | 4 +- 10 files changed, 221 insertions(+), 37 deletions(-) create mode 100644 tools/perf/Documentation/perf-check.txt create mode 100644 tools/perf/builtin-check.c
Signature · 1 line
2.41.0
PATCH v6 1/4 perf check: introduce check subcommand
Currently the presence of a feature is checked with a combination of perf version --build-options and greps, such as:
perf version --build-options | grep " on .* HAVE_FEATURE"
Instead of this, introduce a subcommand "perf check --feature", with which scripts can test for presence of a feature, such as:
perf check --feature HAVE_FEATURE
'perf check --feature' command is expected to have exit status of 0 if feature is built-in, and 1 if it's not built-in or if feature is not known.
An array 'supported_features' has also been introduced that can be used by other commands like 'perf version --build-options', so that new features can be added in one place, with the array
--- tools/perf/Build | 1 + tools/perf/Documentation/perf-check.txt | 60 ++++++++++++ tools/perf/builtin-check.c | 123 ++++++++++++++++++++++++ tools/perf/builtin.h | 18 ++++ tools/perf/perf.c | 1 + 5 files changed, 203 insertions(+) create mode 100644 tools/perf/Documentation/perf-check.txt create mode 100644 tools/perf/builtin-check.c
tools/perf/Build +1 -0
@@ -1,5 +1,6 @@ perf-y += builtin-bench.o perf-y += builtin-annotate.o +perf-y += builtin-check.o perf-y += builtin-config.o perf-y += builtin-diff.o perf-y += builtin-evlist.o
tools/perf/Documentation/perf-check.txt new file +60 -0
60 lines not on this page · raw message
tools/perf/builtin-check.c new file +123 -0
123 lines not on this page · raw message
tools/perf/builtin.h +18 -0
@@ -2,6 +2,23 @@#ifndef BUILTIN_H #define BUILTIN_H +#include <stddef.h> +#include <linux/compiler.h> +#include <tools/config.h> + +struct feature_support { +const char *name; +const char *macro; +int is_builtin; +}; + +#define FEATURE_SUPPORT (name_, macro_) { \ + .name = name_, \ + .macro = #macro_, \ + .is_builtin = IS_BUILTIN(macro_) } + +extern struct feature_support supported_features[]; +void list_common_cmds_help (void );const char *help_unknown_cmd (const char *cmd);
@@ -9,6 +26,7 @@ int cmd_annotate(int argc, const char **argv);int cmd_bench (int argc,const char **argv);int cmd_buildid_cache (int argc,const char **argv);int cmd_buildid_list (int argc,const char **argv); +int cmd_check (int argc,const char **argv);int cmd_config (int argc,const char **argv);int cmd_c2c (int argc,const char **argv);int cmd_diff (int argc,const char **argv);
tools/perf/perf.c +1 -0
@@ -50,6 +50,7 @@ static struct cmd_struct commands[] = { { "archive", NULL, 0 }, { "buildid-cache", cmd_buildid_cache, 0 }, { "buildid-list", cmd_buildid_list, 0 }, + { "check", cmd_check, 0 }, { "config", cmd_config, 0 }, { "c2c", cmd_c2c, 0 }, { "diff", cmd_diff, 0 },
Signature · 1 line
2.41.0
Arnaldo Carvalho de Melo
maintainerRe: [PATCH v6 1/4] perf check: introduce check subcommand
Em Sat, Oct 21, 2023 at 08:35:23PM +0530, Aditya Gupta escreveu:
Quoted 13 lines
Currently the presence of a feature is checked with a combination of perf version --build-options and greps, such as:
perf version --build-options | grep " on .* HAVE_FEATURE"Instead of this, introduce a subcommand "perf check --feature", with which scripts can test for presence of a feature, such as:
perf check --feature HAVE_FEATURE'perf check --feature' command is expected to have exit status of 0 if feature is built-in, and 1 if it's not built-in or if feature is not known.
Quoted 6 lines
An array '
supported_features' has also been introduced that can be used by other commands like 'perf version --build-options', so that new features can be added in one place, with the arrayAcked-by Namhyung Kim <[email protected]>Signed-off-by Aditya Gupta <[email protected]>
Right after applying this first patch:
[acme@quaco perf-tools-next]$ m
make: Entering directory '/home/acme/git/perf-tools-next/tools/perf'
BUILD: Doing 'make -j8' parallel build
Warning: Kernel ABI header differences:
diff -u tools/include/uapi/linux/kvm.h include/uapi/linux/kvm.h
diff -u tools/include/uapi/linux/mount.h include/uapi/linux/mount.h
diff -u tools/include/uapi/linux/perf_event.h include/uapi/linux/perf_event.h
diff -u tools/arch/x86/include/asm/disabled-features.h arch/x86/include/asm/disabled-features.h
diff -u tools/arch/x86/include/asm/cpufeatures.h arch/x86/include/asm/cpufeatures.h
diff -u tools/arch/x86/include/uapi/asm/prctl.h arch/x86/include/uapi/asm/prctl.h
diff -u tools/arch/arm64/include/uapi/asm/perf_regs.h arch/arm64/include/uapi/asm/perf_regs.h
diff -u tools/arch/s390/include/uapi/asm/kvm.h arch/s390/include/uapi/asm/kvm.h
Makefile.config:1145: No openjdk development package found, please install JDK package, e.g. openjdk-8-jdk, java-1.8.0-openjdk-devel
INSTALL libsubcmd_headers
INSTALL libperf_headers
INSTALL libsymbol_headers
INSTALL libapi_headers
INSTALL libbpf_headers
CC /tmp/build/perf-tools-next/builtin-check.o CC /tmp/build/perf-tools-next/builtin-buildid-list.o CC /tmp/build/perf-tools-next/builtin-buildid-cache.o CC /tmp/build/perf-tools-next/builtin-kallsyms.o CC /tmp/build/perf-tools-next/builtin-list.o CC /tmp/build/perf-tools-next/builtin-record.o CC /tmp/build/perf-tools-next/builtin-report.o CC /tmp/build/perf-tools-next/builtin-stat.o
builtin-check.c:53:56: error: expected ‘}’ before ‘;’ token
53 | FEATURE_SUPPORT("bpf_skeletons", HAVE_BPF_SKEL);
| ^
builtin-check.c:29:47: note: to match this ‘{’
29 | struct feature_support supported_features[] = {
| ^
make[3]: *** [/home/acme/git/perf-tools-next/tools/build/Makefile.build:106: /tmp/build/perf-tools-next/builtin-check.o] Error 1 make[3]: *** Waiting for unfinished jobs....
make[2]: *** [Makefile.perf:669: /tmp/build/perf-tools-next/perf-in.o] Error 2
make[1]: *** [Makefile.perf:242: sub-make] Error 2
make: *** [Makefile:113: install-bin] Error 2
make: Leaving directory '/home/acme/git/perf-tools-next/tools/perf'
Performance counter stats for 'make -k EXTRA_CFLAGS=-fsanitize=address BUILD_BPF_SKEL=1 CORESIGHT=1 O=/tmp/build/perf-tools-next -C tools/perf install-bin':
26,249,850,723 cycles:u
34,380,184,715 instructions:u # 1.31 insn per cycle
4.021721145 seconds time elapsed
7.780017000 seconds user
1.793663000 seconds sys[ perf record: Woken up 1 times to write data ]
[ perf record: Captured and wrote 0.002 MB perf.data (9 samples) ]
Performance counter stats for 'sleep 0.01':
0.012377637 seconds time elapsed
0.000000000 seconds user
0.002203000 seconds sys[acme@quaco perf-tools-next]$
Arnaldo Carvalho de Melo
maintainerRe: [PATCH v6 1/4] perf check: introduce check subcommand
Em Fri, Nov 10, 2023 at 11:27:42AM -0300, Arnaldo Carvalho de Melo escreveu:
Quoted 6 lines
Em Sat, Oct 21, 2023 at 08:35:23PM +0530, Aditya Gupta escreveu:
Quoted 2 lines
Acked-by Namhyung Kim <[email protected]>Signed-off-by Aditya Gupta <[email protected]>Right after applying this first patch:
Quoted 14 lines
[acme@quaco perf-tools-next]$ m
make: Entering directory '/home/acme/git/perf-tools-next/tools/perf'
builtin-check.c:53:56: error: expected ‘}’ before ‘;’ token
53 |FEATURE_SUPPORT("bpf_skeletons", HAVE_BPF_SKEL);
| ^
builtin-check.c:29:47: note: to match this ‘{’
29 | structfeature_supportsupported_features[] = {
| ^
make[3]: *** [/home/acme/git/perf-tools-next/tools/build/Makefile.build:106:/tmp/build/perf-tools-next/builtin-check.o] Error 1 make[3]: *** Waiting for unfinished jobs....
make[2]: *** [Makefile.perf:669:/tmp/build/perf-tools-next/perf-in.o] Error 2
make[1]: *** [Makefile.perf:242: sub-make] Error 2
make: *** [Makefile:113: install-bin] Error 2
make: Leaving directory '/home/acme/git/perf-tools-next/tools/perf'
It was a simple error, please be more careful next time.
I'm testing the rest of the patchset now.
- Arnaldo
tools/perf/builtin-check.c +1 -1
@@ -50,7 +50,7 @@ struct feature_support supported_features[] = {FEATURE_SUPPORT ("zstd" ,HAVE_ZSTD_SUPPORT ),FEATURE_SUPPORT ("libpfm4" ,HAVE_LIBPFM ),FEATURE_SUPPORT ("libtraceevent" ,HAVE_LIBTRACEEVENT ), -FEATURE_SUPPORT ("bpf_skeletons" ,HAVE_BPF_SKEL ); +FEATURE_SUPPORT ("bpf_skeletons" ,HAVE_BPF_SKEL ),/* this should remain at end, to know the array end */ FEATURE_SUPPORT (NULL , _)
Arnaldo Carvalho de Melo
maintainerRe: [PATCH v6 1/4] perf check: introduce check subcommand
Em Fri, Nov 10, 2023 at 11:31:57AM -0300, Arnaldo Carvalho de Melo escreveu:
Quoted 22 lines
Em Fri, Nov 10, 2023 at 11:27:42AM -0300, Arnaldo Carvalho de Melo escreveu:
Quoted 6 lines
Em Sat, Oct 21, 2023 at 08:35:23PM +0530, Aditya Gupta escreveu:
Quoted 2 lines
Acked-by Namhyung Kim <[email protected]>Signed-off-by Aditya Gupta <[email protected]>Right after applying this first patch:
Quoted 14 lines
[acme@quaco perf-tools-next]$ m
make: Entering directory '/home/acme/git/perf-tools-next/tools/perf'
builtin-check.c:53:56: error: expected ‘}’ before ‘;’ token
53 |FEATURE_SUPPORT("bpf_skeletons", HAVE_BPF_SKEL);
| ^
builtin-check.c:29:47: note: to match this ‘{’
29 | structfeature_supportsupported_features[] = {
| ^
make[3]: *** [/home/acme/git/perf-tools-next/tools/build/Makefile.build:106:/tmp/build/perf-tools-next/builtin-check.o] Error 1 make[3]: *** Waiting for unfinished jobs....
make[2]: *** [Makefile.perf:669:/tmp/build/perf-tools-next/perf-in.o] Error 2
make[1]: *** [Makefile.perf:242: sub-make] Error 2
make: *** [Makefile:113: install-bin] Error 2
make: Leaving directory '/home/acme/git/perf-tools-next/tools/perf'
Quoted 3 lines
It was a simple error, please be more careful next time.
I'm testing the rest of the patchset now.
Please resubmit when you address the problem fixed with this patch and:
Mussing newline, why print the version again? What is that "perf check " prefix for?
[acme@quaco perf-tools-next]$ perf check --feature traceevent perf check 6.6.rc1.g78fa196349bc
Feature not known: traceevent[acme@quaco perf-tools-next]$
Why should we require "--feature"? The following format is descriptive enough:
[acme@quaco perf-tools-next]$
[acme@quaco perf-tools-next]$ perf check traceevent perf check 6.6.rc1.g78fa196349bc [acme@quaco perf-tools-next]$
So I had to go back and use:
[acme@quaco perf-tools-next]$ perf -vv
perf version 6.6.rc1.g78fa196349bc
dwarf: [ on ] # HAVE_DWARF_SUPPORT
dwarf_getlocations: [ on ] # HAVE_DWARF_GETLOCATIONS_SUPPORT
syscall_table: [ on ] # HAVE_SYSCALL_TABLE_SUPPORT
libbfd: [ OFF ] # HAVE_LIBBFD_SUPPORT
debuginfod: [ on ] # HAVE_DEBUGINFOD_SUPPORT
libelf: [ on ] # HAVE_LIBELF_SUPPORT
libnuma: [ on ] # HAVE_LIBNUMA_SUPPORT
numa_num_possible_cpus: [ on ] # HAVE_LIBNUMA_SUPPORT
libperl: [ on ] # HAVE_LIBPERL_SUPPORT
libpython: [ on ] # HAVE_LIBPYTHON_SUPPORT
libslang: [ on ] # HAVE_SLANG_SUPPORT
libcrypto: [ on ] # HAVE_LIBCRYPTO_SUPPORT
libunwind: [ on ] # HAVE_LIBUNWIND_SUPPORT
libdw-dwarf-unwind: [ on ] # HAVE_DWARF_SUPPORT
zlib: [ on ] # HAVE_ZLIB_SUPPORT
lzma: [ on ] # HAVE_LZMA_SUPPORT
get_cpuid: [ on ] # HAVE_AUXTRACE_SUPPORT
bpf: [ on ] # HAVE_LIBBPF_SUPPORT
aio: [ on ] # HAVE_AIO_SUPPORT
zstd: [ on ] # HAVE_ZSTD_SUPPORT
libpfm4: [ on ] # HAVE_LIBPFM
libtraceevent: [ on ] # HAVE_LIBTRACEEVENT
bpf_skeletons: [ on ] # HAVE_BPF_SKEL[acme@quaco perf-tools-next]$
To see (some) of the features, please add a:
# perf check --list-features
So that we can get that features array printed.
Some other feature requests:
[acme@quaco perf-tools-next]$ perf check --feature libtraceevent,libbpf_support perf check 6.6.rc1.g78fa196349bc
Feature not known: libtraceevent,libbpf_support[acme@quaco perf-tools-next]$
This should return true if both are available.
Also, shouldn't be --quiet be the default since this is being designed for use in scripts?
- Arnaldo
Quoted 15 lines
- Arnaldo
tools/perf/builtin-check.c +1
-1@@ -50,7 +50,7 @@ struct feature_support supported_features[] = {FEATURE_SUPPORT ("zstd" ,HAVE_ZSTD_SUPPORT ),FEATURE_SUPPORT ("libpfm4" ,HAVE_LIBPFM ),FEATURE_SUPPORT ("libtraceevent" ,HAVE_LIBTRACEEVENT ), -FEATURE_SUPPORT ("bpf_skeletons" ,HAVE_BPF_SKEL ); +FEATURE_SUPPORT ("bpf_skeletons" ,HAVE_BPF_SKEL ),/* this should remain at end, to know the array end */ FEATURE_SUPPORT (NULL , _)
Signature · 1 line
- Arnaldo
Namhyung Kim
maintainerRe: [PATCH v6 1/4] perf check: introduce check subcommand
Quoted 33 lines · Arnaldo Carvalho de Melo
Em Fri, Nov 10, 2023 at 11:31:57AM -0300, Arnaldo Carvalho de Melo escreveu:
Quoted 22 lines
Em Fri, Nov 10, 2023 at 11:27:42AM -0300, Arnaldo Carvalho de Melo escreveu:
Quoted 6 lines
Em Sat, Oct 21, 2023 at 08:35:23PM +0530, Aditya Gupta escreveu:
Quoted 2 lines
Acked-by Namhyung Kim <[email protected]>Signed-off-by Aditya Gupta <[email protected]>Right after applying this first patch:
Quoted 14 lines
[acme@quaco perf-tools-next]$ m
make: Entering directory '/home/acme/git/perf-tools-next/tools/perf'
builtin-check.c:53:56: error: expected ‘}’ before ‘;’ token
53 |FEATURE_SUPPORT("bpf_skeletons", HAVE_BPF_SKEL);
| ^
builtin-check.c:29:47: note: to match this ‘{’
29 | structfeature_supportsupported_features[] = {
| ^
make[3]: *** [/home/acme/git/perf-tools-next/tools/build/Makefile.build:106:/tmp/build/perf-tools-next/builtin-check.o] Error 1 make[3]: *** Waiting for unfinished jobs....
make[2]: *** [Makefile.perf:669:/tmp/build/perf-tools-next/perf-in.o] Error 2
make[1]: *** [Makefile.perf:242: sub-make] Error 2
make: *** [Makefile:113: install-bin] Error 2
make: Leaving directory '/home/acme/git/perf-tools-next/tools/perf'Quoted 3 lines
It was a simple error, please be more careful next time.
I'm testing the rest of the patchset now.
Please resubmit when you address the problem fixed with this patch and:
Mussing newline, why print the version again? What is that "perf check " prefix for?
Quoted 6 lines
[acme@quaco perf-tools-next]$ perf check --feature traceevent perf check 6.6.rc1.g78fa196349bc
Feature not known: traceevent[acme@quaco perf-tools-next]$Why should we require "--feature"? The following format is descriptive enough:
I thought we might want to extend the functionality of the check command later. Maybe we can check how many perf counters are supported or which sysctl settings are affected and so on.
Maybe we need to make '--feature' option to a sub-command like perf check feature xxx. So it cannot be mixed with others later.
Quoted 41 lines
[acme@quaco perf-tools-next]$
[acme@quaco perf-tools-next]$ perf check traceevent perf check 6.6.rc1.g78fa196349bc [acme@quaco perf-tools-next]$So I had to go back and use:
[acme@quaco perf-tools-next]$ perf -vv
perf version 6.6.rc1.g78fa196349bcdwarf: [ on ] # HAVE_DWARF_SUPPORT dwarf_getlocations: [ on ] # HAVE_DWARF_GETLOCATIONS_SUPPORT syscall_table: [ on ] # HAVE_SYSCALL_TABLE_SUPPORT libbfd: [ OFF ] # HAVE_LIBBFD_SUPPORT debuginfod: [ on ] # HAVE_DEBUGINFOD_SUPPORT libelf: [ on ] # HAVE_LIBELF_SUPPORT libnuma: [ on ] # HAVE_LIBNUMA_SUPPORT numa_num_possible_cpus: [ on ] # HAVE_LIBNUMA_SUPPORT libperl: [ on ] # HAVE_LIBPERL_SUPPORT libpython: [ on ] # HAVE_LIBPYTHON_SUPPORT libslang: [ on ] # HAVE_SLANG_SUPPORT libcrypto: [ on ] # HAVE_LIBCRYPTO_SUPPORT libunwind: [ on ] # HAVE_LIBUNWIND_SUPPORT libdw-dwarf-unwind: [ on ] # HAVE_DWARF_SUPPORT zlib: [ on ] # HAVE_ZLIB_SUPPORT lzma: [ on ] # HAVE_LZMA_SUPPORT get_cpuid: [ on ] # HAVE_AUXTRACE_SUPPORT bpf: [ on ] # HAVE_LIBBPF_SUPPORT aio: [ on ] # HAVE_AIO_SUPPORT zstd: [ on ] # HAVE_ZSTD_SUPPORT libpfm4: [ on ] # HAVE_LIBPFM libtraceevent: [ on ] # HAVE_LIBTRACEEVENT bpf_skeletons: [ on ] # HAVE_BPF_SKEL[acme@quaco perf-tools-next]$
To see (some) of the features, please add a:
# perf check --list-featuresSo that we can get that features array printed.
Quoted 7 lines
Some other feature requests:
[acme@quaco perf-tools-next]$ perf check --feature libtraceevent,libbpf_support perf check 6.6.rc1.g78fa196349bc
Feature not known: libtraceevent,libbpf_support[acme@quaco perf-tools-next]$This should return true if both are available.
Sounds good.
Quoted 3 lines
Also, shouldn't be --quiet be the default since this is being designed for use in scripts?
I don't know.. users might want to see the result instead of checking the return value.
libtraceevent: [ on ]
libbpf_support: [ OFF ]
Thanks,
Namhyung
Re: [PATCH v6 1/4] perf check: introduce check subcommand
Quoted 42 lines · Namhyung Kim
Quoted 33 lines · Arnaldo Carvalho de Melo
Em Fri, Nov 10, 2023 at 11:31:57AM -0300, Arnaldo Carvalho de Melo escreveu:
Quoted 22 lines
Em Fri, Nov 10, 2023 at 11:27:42AM -0300, Arnaldo Carvalho de Melo escreveu:
Quoted 6 lines
Em Sat, Oct 21, 2023 at 08:35:23PM +0530, Aditya Gupta escreveu:
Quoted 2 lines
Acked-by Namhyung Kim <[email protected]>Signed-off-by Aditya Gupta <[email protected]>Right after applying this first patch:
Quoted 14 lines
[acme@quaco perf-tools-next]$ m
make: Entering directory '/home/acme/git/perf-tools-next/tools/perf'
builtin-check.c:53:56: error: expected ‘}’ before ‘;’ token
53 |FEATURE_SUPPORT("bpf_skeletons", HAVE_BPF_SKEL);
| ^
builtin-check.c:29:47: note: to match this ‘{’
29 | structfeature_supportsupported_features[] = {
| ^
make[3]: *** [/home/acme/git/perf-tools-next/tools/build/Makefile.build:106:/tmp/build/perf-tools-next/builtin-check.o] Error 1 make[3]: *** Waiting for unfinished jobs....
make[2]: *** [Makefile.perf:669:/tmp/build/perf-tools-next/perf-in.o] Error 2
make[1]: *** [Makefile.perf:242: sub-make] Error 2
make: *** [Makefile:113: install-bin] Error 2
make: Leaving directory '/home/acme/git/perf-tools-next/tools/perf'Quoted 3 lines
It was a simple error, please be more careful next time.
I'm testing the rest of the patchset now.
Please resubmit when you address the problem fixed with this patch and:
Mussing newline, why print the version again? What is that "perf check " prefix for?
Quoted 6 lines
[acme@quaco perf-tools-next]$ perf check --feature traceevent perf check 6.6.rc1.g78fa196349bc
Feature not known: traceevent[acme@quaco perf-tools-next]$Why should we require "--feature"? The following format is descriptive enough:
Quoted 7 lines
I thought we might want to extend the functionality of the check command later. Maybe we can check how many perf counters are supported or which sysctl settings are affected and so on.
Maybe we need to make '--feature' option to a sub-command like
perf check feature xxx. So it cannot be mixed with others later.
True, 'perf check' is intended to be extended.
We can make it 'perf check feature libtraceevent', but any extra flags etc to 'perf check feature' can be equally verbose of what was intended to be a replacement for 'perf version --build-options | grep "libtraceevent.*on"'
Quoted 44 lines
Quoted 44 lines
[acme@quaco perf-tools-next]$
[acme@quaco perf-tools-next]$ perf check traceevent perf check 6.6.rc1.g78fa196349bc [acme@quaco perf-tools-next]$So I had to go back and use:
[acme@quaco perf-tools-next]$ perf -vv
perf version 6.6.rc1.g78fa196349bcdwarf: [ on ] # HAVE_DWARF_SUPPORT dwarf_getlocations: [ on ] # HAVE_DWARF_GETLOCATIONS_SUPPORT syscall_table: [ on ] # HAVE_SYSCALL_TABLE_SUPPORT libbfd: [ OFF ] # HAVE_LIBBFD_SUPPORT debuginfod: [ on ] # HAVE_DEBUGINFOD_SUPPORT libelf: [ on ] # HAVE_LIBELF_SUPPORT libnuma: [ on ] # HAVE_LIBNUMA_SUPPORT numa_num_possible_cpus: [ on ] # HAVE_LIBNUMA_SUPPORT libperl: [ on ] # HAVE_LIBPERL_SUPPORT libpython: [ on ] # HAVE_LIBPYTHON_SUPPORT libslang: [ on ] # HAVE_SLANG_SUPPORT libcrypto: [ on ] # HAVE_LIBCRYPTO_SUPPORT libunwind: [ on ] # HAVE_LIBUNWIND_SUPPORT libdw-dwarf-unwind: [ on ] # HAVE_DWARF_SUPPORT zlib: [ on ] # HAVE_ZLIB_SUPPORT lzma: [ on ] # HAVE_LZMA_SUPPORT get_cpuid: [ on ] # HAVE_AUXTRACE_SUPPORT bpf: [ on ] # HAVE_LIBBPF_SUPPORT aio: [ on ] # HAVE_AIO_SUPPORT zstd: [ on ] # HAVE_ZSTD_SUPPORT libpfm4: [ on ] # HAVE_LIBPFM libtraceevent: [ on ] # HAVE_LIBTRACEEVENT bpf_skeletons: [ on ] # HAVE_BPF_SKEL[acme@quaco perf-tools-next]$
To see (some) of the features, please add a:
# perf check --list-featuresSo that we can get that features array printed.
Some other feature requests:
Quoted 7 lines
Quoted 5 lines
[acme@quaco perf-tools-next]$ perf check --feature libtraceevent,libbpf_support perf check 6.6.rc1.g78fa196349bc
Feature not known: libtraceevent,libbpf_support[acme@quaco perf-tools-next]$This should return true if both are available.
Sounds good.
Sure, I will do it next version.
Quoted 11 lines
Quoted 4 lines
Also, shouldn't be --quiet be the default since this is being designed for use in scripts?
I don't know.. users might want to see the result instead of checking the return value.
libtraceevent: [ on ]
libbpf_support: [ OFF ]
Thanks Namhyung for answering the questions while I was not active.
Thanks,
- Aditya
Quoted 2 lines
Thanks,
Namhyung
Re: [PATCH v6 1/4] perf check: introduce check subcommand
In reply to Arnaldo Carvalho de MeloQuoted 23 lines · Arnaldo Carvalho de Melo
Em Fri, Nov 10, 2023 at 11:31:57AM -0300, Arnaldo Carvalho de Melo escreveu:
Quoted 21 lines
Em Fri, Nov 10, 2023 at 11:27:42AM -0300, Arnaldo Carvalho de Melo escreveu:
Quoted 20 lines
Em Sat, Oct 21, 2023 at 08:35:23PM +0530, Aditya Gupta escreveu:
Quoted 2 lines
Acked-by Namhyung Kim <[email protected]>Signed-off-by Aditya Gupta <[email protected]>Right after applying this first patch:
[acme@quaco perf-tools-next]$ m
make: Entering directory '/home/acme/git/perf-tools-next/tools/perf'
builtin-check.c:53:56: error: expected ‘}’ before ‘;’ token
53 |FEATURE_SUPPORT("bpf_skeletons", HAVE_BPF_SKEL);
| ^
builtin-check.c:29:47: note: to match this ‘{’
29 | structfeature_supportsupported_features[] = {
| ^
make[3]: *** [/home/acme/git/perf-tools-next/tools/build/Makefile.build:106:/tmp/build/perf-tools-next/builtin-check.o] Error 1 make[3]: *** Waiting for unfinished jobs....
make[2]: *** [Makefile.perf:669:/tmp/build/perf-tools-next/perf-in.o] Error 2
make[1]: *** [Makefile.perf:242: sub-make] Error 2
make: *** [Makefile:113: install-bin] Error 2
make: Leaving directory '/home/acme/git/perf-tools-next/tools/perf'
Quoted 8 lines
Quoted 3 lines
It was a simple error, please be more careful next time.
I'm testing the rest of the patchset now.
Please resubmit when you address the problem fixed with this patch and:
Mussing newline, why print the version again? What is that "perf check " prefix for?
Sure, I will send a V7 with the problems fixed.
Quoted 5 lines
[acme@quaco perf-tools-next]$ perf check --feature traceevent perf check 6.6.rc1.g78fa196349bc
Feature not known: traceevent[acme@quaco perf-tools-next]$
Quoted 7 lines
Why should we require "--feature"? The following format is descriptive enough:
[acme@quaco perf-tools-next]$
[acme@quaco perf-tools-next]$ perf check traceevent perf check 6.6.rc1.g78fa196349bc [acme@quaco perf-tools-next]$
This was done, so that the proposed 'perf check' command could be extended in future for other usage also, and not just for checking if a feature is available or not
In initial versions of this patch series, it was implemented also 'perf build --has libtraceevent', though with discussions, we arrived at a new sucommand 'perf check', and checking if a feature is enabled is done just with a flag 'perf check --feature', so that 'perf check' can be extended in future.
Quoted 28 lines
So I had to go back and use:
[acme@quaco perf-tools-next]$ perf -vv
perf version 6.6.rc1.g78fa196349bcdwarf: [ on ] # HAVE_DWARF_SUPPORT dwarf_getlocations: [ on ] # HAVE_DWARF_GETLOCATIONS_SUPPORT syscall_table: [ on ] # HAVE_SYSCALL_TABLE_SUPPORT libbfd: [ OFF ] # HAVE_LIBBFD_SUPPORT debuginfod: [ on ] # HAVE_DEBUGINFOD_SUPPORT libelf: [ on ] # HAVE_LIBELF_SUPPORT libnuma: [ on ] # HAVE_LIBNUMA_SUPPORT numa_num_possible_cpus: [ on ] # HAVE_LIBNUMA_SUPPORT libperl: [ on ] # HAVE_LIBPERL_SUPPORT libpython: [ on ] # HAVE_LIBPYTHON_SUPPORT libslang: [ on ] # HAVE_SLANG_SUPPORT libcrypto: [ on ] # HAVE_LIBCRYPTO_SUPPORT libunwind: [ on ] # HAVE_LIBUNWIND_SUPPORT libdw-dwarf-unwind: [ on ] # HAVE_DWARF_SUPPORT zlib: [ on ] # HAVE_ZLIB_SUPPORT lzma: [ on ] # HAVE_LZMA_SUPPORT get_cpuid: [ on ] # HAVE_AUXTRACE_SUPPORT bpf: [ on ] # HAVE_LIBBPF_SUPPORT aio: [ on ] # HAVE_AIO_SUPPORT zstd: [ on ] # HAVE_ZSTD_SUPPORT libpfm4: [ on ] # HAVE_LIBPFM libtraceevent: [ on ] # HAVE_LIBTRACEEVENT bpf_skeletons: [ on ] # HAVE_BPF_SKEL
Quoted 7 lines
[acme@quaco perf-tools-next]$
To see (some) of the features, please add a:
# perf check --list-featuresSo that we can get that features array printed.
This is already there in 'perf version --build-options' command. And that is the command which was being used by scripts to check if a feature is enabled or not.
Quoted 8 lines
Some other feature requests:
[acme@quaco perf-tools-next]$ perf check --feature libtraceevent,libbpf_support perf check 6.6.rc1.g78fa196349bc
Feature not known: libtraceevent,libbpf_support[acme@quaco perf-tools-next]$This should return true if both are available.
This can be done. Sure.
Quoted 4 lines
Also, shouldn't be --quiet be the default since this is being designed for use in scripts?
It will mostly be used by scripts only, but still if used as a command by any user, it's intended that they also see whether feature was enabled or not, instead of relying on the exit code.
Thanks for your reviews, and fixing the mistake I made.
Thanks,
- Aditya Gupta
Quoted 21 lines
- Arnaldo
Quoted 15 lines
- Arnaldo
tools/perf/builtin-check.c +1
-1@@ -50,7 +50,7 @@ struct feature_support supported_features[] = {FEATURE_SUPPORT ("zstd" ,HAVE_ZSTD_SUPPORT ),FEATURE_SUPPORT ("libpfm4" ,HAVE_LIBPFM ),FEATURE_SUPPORT ("libtraceevent" ,HAVE_LIBTRACEEVENT ), -FEATURE_SUPPORT ("bpf_skeletons" ,HAVE_BPF_SKEL ); +FEATURE_SUPPORT ("bpf_skeletons" ,HAVE_BPF_SKEL ),/* this should remain at end, to know the array end */ FEATURE_SUPPORT (NULL , _)Signature · 1 line
- Arnaldo
Re: [PATCH v6 1/4] perf check: introduce check subcommand
In reply to Arnaldo Carvalho de MeloExtremely sorry for the delayed reply, I was on leave. Around this time, we have a major festival in India, so was on a long leave.
Quoted 22 lines · Arnaldo Carvalho de Melo
Em Fri, Nov 10, 2023 at 11:27:42AM -0300, Arnaldo Carvalho de Melo escreveu:
Quoted 6 lines
Em Sat, Oct 21, 2023 at 08:35:23PM +0530, Aditya Gupta escreveu:
Quoted 2 lines
Acked-by Namhyung Kim <[email protected]>Signed-off-by Aditya Gupta <[email protected]>Right after applying this first patch:
Quoted 14 lines
[acme@quaco perf-tools-next]$ m
make: Entering directory '/home/acme/git/perf-tools-next/tools/perf'
builtin-check.c:53:56: error: expected ‘}’ before ‘;’ token
53 |FEATURE_SUPPORT("bpf_skeletons", HAVE_BPF_SKEL);
| ^
builtin-check.c:29:47: note: to match this ‘{’
29 | structfeature_supportsupported_features[] = {
| ^
make[3]: *** [/home/acme/git/perf-tools-next/tools/build/Makefile.build:106:/tmp/build/perf-tools-next/builtin-check.o] Error 1 make[3]: *** Waiting for unfinished jobs....
make[2]: *** [Makefile.perf:669:/tmp/build/perf-tools-next/perf-in.o] Error 2
make[1]: *** [Makefile.perf:242: sub-make] Error 2
make: *** [Makefile:113: install-bin] Error 2
make: Leaving directory '/home/acme/git/perf-tools-next/tools/perf'
Quoted 3 lines
It was a simple error, please be more careful next time.
I'm testing the rest of the patchset now.
Thank you. I will be more careful next time.
Quoted 16 lines
- Arnaldo
tools/perf/builtin-check.c +1
-1@@ -50,7 +50,7 @@ struct feature_support supported_features[] = {FEATURE_SUPPORT ("zstd" ,HAVE_ZSTD_SUPPORT ),FEATURE_SUPPORT ("libpfm4" ,HAVE_LIBPFM ),FEATURE_SUPPORT ("libtraceevent" ,HAVE_LIBTRACEEVENT ), -FEATURE_SUPPORT ("bpf_skeletons" ,HAVE_BPF_SKEL ); +FEATURE_SUPPORT ("bpf_skeletons" ,HAVE_BPF_SKEL ),/* this should remain at end, to know the array end */ FEATURE_SUPPORT (NULL , _)
PATCH v6 2/4 perf version: update --build-options to use 'supported_features' array
In reply to Aditya GuptaNow that the feature list has been duplicated in a global 'supported_features' array, use that array instead of manually checking status of built-in features.
This helps in being consistent with commands such as 'perf check --feature', so commands can use the same array, and any new feature can be added at one place, in the 'supported_features' array
--- tools/perf/builtin-version.c | 40 ++++++++---------------------------- 1 file changed, 8 insertions(+), 32 deletions(-)
tools/perf/builtin-version.c +8 -32
@@ -46,42 +46,18 @@ static void status_print(const char *name, const char *macro,printf (" # %s\n" , macro); } -#define STATUS (__d, __m) \ -do { \ - if (IS_BUILTIN(__d)) \ - status_print(#__m, #__d, "on"); \ - else \ - status_print(#__m, #__d, "OFF"); \ +#define STATUS (feature) \ +do { \ + if (feature.is_builtin) \ + status_print(feature.name, feature.macro, "on"); \ + else \ + status_print(feature.name, feature.macro, "OFF"); \ } while (0)static void library_status (void ) { -STATUS (HAVE_DWARF_SUPPORT , dwarf); -STATUS (HAVE_DWARF_GETLOCATIONS_SUPPORT , dwarf_getlocations); -#ifndef HAVE_SYSCALL_TABLE_SUPPORT -STATUS (HAVE_LIBAUDIT_SUPPORT , libaudit); -#endif -STATUS (HAVE_SYSCALL_TABLE_SUPPORT , syscall_table); -STATUS (HAVE_LIBBFD_SUPPORT , libbfd); -STATUS (HAVE_DEBUGINFOD_SUPPORT , debuginfod); -STATUS (HAVE_LIBELF_SUPPORT , libelf); -STATUS (HAVE_LIBNUMA_SUPPORT , libnuma); -STATUS (HAVE_LIBNUMA_SUPPORT , numa_num_possible_cpus); -STATUS (HAVE_LIBPERL_SUPPORT , libperl); -STATUS (HAVE_LIBPYTHON_SUPPORT , libpython); -STATUS (HAVE_SLANG_SUPPORT , libslang); -STATUS (HAVE_LIBCRYPTO_SUPPORT , libcrypto); -STATUS (HAVE_LIBUNWIND_SUPPORT , libunwind); -STATUS (HAVE_DWARF_SUPPORT , libdw-dwarf-unwind); -STATUS (HAVE_ZLIB_SUPPORT , zlib); -STATUS (HAVE_LZMA_SUPPORT , lzma); -STATUS (HAVE_AUXTRACE_SUPPORT , get_cpuid); -STATUS (HAVE_LIBBPF_SUPPORT , bpf); -STATUS (HAVE_AIO_SUPPORT , aio); -STATUS (HAVE_ZSTD_SUPPORT , zstd); -STATUS (HAVE_LIBPFM , libpfm4); -STATUS (HAVE_LIBTRACEEVENT , libtraceevent); -STATUS (HAVE_BPF_SKEL , bpf_skeletons); +for (int i =0 ; supported_features[i].name; ++i) +STATUS (supported_features[i]); }int cmd_version (int argc,const char **argv)
Signature · 1 line
2.41.0
PATCH v6 3/4 perf tests task_analyzer: use perf check for libtraceevent support
In reply to Aditya GuptaCurrently we use output of 'perf version --build-options', to check whether perf was built with libtraceevent support.
Instead, use 'perf check --feature libtraceevent' to check for libtraceevent support.
--- tools/perf/tests/shell/test_task_analyzer.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
tools/perf/tests/shell/test_task_analyzer.sh +2 -2
@@ -52,8 +52,8 @@ find_str_or_fail() { # check if perf is compiled with libtraceevent support skip_no_probe_record_support() { - perf version --build-options | grep -q " OFF .* HAVE_LIBTRACEEVENT" && return 2 - return 0 + perf check -q --feature libtraceevent && return 0 + return 2 } prepare_perf_data() {
Signature · 1 line
2.41.0
PATCH v6 4/4 tools/perf/tests: Update probe_vfs_getname.sh script to use perf check --feature
In reply to Aditya GuptaFrom: Athira Rajeev <[email protected]>
In probe_vfs_getname.sh, current we use "perf record --dry-run" to check for libtraceevent and skip the test if perf is not build with libtraceevent. Change the check to use "perf check --feature" option
--- tools/perf/tests/shell/lib/probe_vfs_getname.sh | 4 ++-- tools/perf/tests/shell/record+probe_libc_inet_pton.sh | 5 ++++- tools/perf/tests/shell/record+script_probe_vfs_getname.sh | 5 ++++- 3 files changed, 10 insertions(+), 4 deletions(-)
tools/perf/tests/shell/lib/probe_vfs_getname.sh +2 -2
@@ -27,7 +27,7 @@ skip_if_no_debuginfo() { # check if perf is compiled with libtraceevent support skip_no_probe_record_support() { if [ $had_vfs_getname -eq 1 ] ; then - perf record --dry-run -e $1 2>&1 | grep "libtraceevent is necessary for tracepoint support" && return 2 - return 1 + perf check -q --feature libtraceevent && return 1 + return 2 fi }
tools/perf/tests/shell/record+probe_libc_inet_pton.sh +4 -1
@@ -60,7 +60,10 @@ trace_libc_inet_pton_backtrace() { # Check presence of libtraceevent support to run perf record skip_no_probe_record_support "$event_name/$eventattr/" - [ $? -eq 2 ] && return 2 + if [ $? -eq 2 ]; then + echo "WARN: Skipping test trace_libc_inet_pton_backtrace. No libtraceevent support." + return 2 + fi perf record -e $event_name/$eventattr/ -o $perf_data ping -6 -c 1 ::1 > /dev/null 2>&1 # check if perf data file got created in above step.
tools/perf/tests/shell/record+script_probe_vfs_getname.sh +4 -1
@@ -21,7 +21,10 @@ record_open_file() { echo "Recording open file:" # Check presence of libtraceevent support to run perf record skip_no_probe_record_support "probe:vfs_getname*" - [ $? -eq 2 ] && return 2 + if [ $? -eq 2 ]; then + echo "WARN: Skipping test record_open_file. No libtraceevent support" + return 2 + fi perf record -o ${perfdata} -e probe:vfs_getname\* touch $file }
Signature · 1 line
2.41.0
Hello,
Just a ping. Any comments on this series ?
Thanks,
Aditya Gupta
Quoted 103 lines · Aditya Gupta
The Problem
===========Currently the presence of a feature is checked with a combination of perf version --build-options and greps, such as:
perf version --build-options | grep " on .* HAVE_FEATURE"Proposed solution
=================As suggested by contributors in:
https://lore.kernel.org/linux-perf-users/[email protected]/Introduce a subcommand "perf check --feature", with which scripts can test for presence of a feature, such as:
perf check --feature HAVE_LIBTRACEEVENT or perf check --feature libtraceeventThe usage of "perf version --build-options | grep" has been replaced in two tests, with "perf check --feature" command
Also, to not duplicate the same feature list at multiple places, a new global '
supported_features' array has been introduced inbuiltin.h, so both commands 'perf check --feature' and 'perf version --build-options' use the same array'
supported_features' feature is an array of 'structfeature_support', which also has the name of the feature, macro used to test it's presence, and ais_builtinmember, which will be 0 if feature not built-in, and 1 if built-inArchitectures Tested
====================
*x86_64
* ppc64leGit tree
========Git tree with this patch series applied for testing:
https://github.com/adi-g15-ibm/linux/tree/perf-check-feature-v6Changelog
=========
V6
+ rebased to perf-tools-next/perf-tools-next
+ modified patch #1 to includeFEATURE_SUPPORT("bpf_skeletons", HAVE_BPF_SKEL)V5
+ invert return value of 'has_support', but return value of perf check --feature according to shell conventionV4
+ invert return value of perf check --featureV3
+ simplifiedhas_supportcode inbuiltin-check.c(patch #1)
+ modified patch #3 and patch #4 according to change in return value in patch #1V2
+ improved the patch series with suggestions from Namhyung
+ fix incorrect return value, added -q option, and moved array definition toperf-check.cV1
+ changed subcommand name to 'perf check --feature'
+ added documentation for perf check
+ support both macro (eg.HAVE_LIBTRACEEVENT), and name (eg. libtraceevent) as input to 'perf check --feature'
+ change subject and descriptions of all patch mentioning perf check instead of perf buildV0: Previous patch series: https://lore.kernel.org/linux-perf-users/[email protected]/
Aditya Gupta (3):
perf check: introduce check subcommand
perf version: update --build-options to use 'supported_features' array perf teststask_analyzer: use perf check for libtraceevent supportAthira Rajeev (1):
tools/perf/tests: Updateprobe_vfs_getname.shscript to use perf check
--featuretools/perf/Build | 1 + tools/perf/Documentation/perf-check.txt | 59 +++++++++ tools/perf/builtin-check.c | 122 ++++++++++++++++++ tools/perf/builtin-version.c | 39 ++---- tools/perf/builtin.h | 18 +++ tools/perf/perf.c | 1 + .../perf/tests/shell/lib/probe_vfs_getname.sh | 4 +- .../shell/record+probe_libc_inet_pton.sh | 5 +- .../shell/record+script_probe_vfs_getname.sh | 5 +- tools/perf/tests/shell/test_task_analyzer.sh | 4 +- 10 files changed, 221 insertions(+), 37 deletions(-) create mode 100644 tools/perf/Documentation/perf-check.txt create mode 100644 tools/perf/builtin-check.cSignature · 1 line
2.41.0