Skip to contentSkip to conversation

Introduce perf check subcommand

PATCH Superseded Aditya Gupta 3 participants 9 messages Oct 3, 2023 – Oct 21, 2023 perf events

v5 of 15 Superseded Latest is v15 →

lore
Share & tools
lore
#0 lore raw

v5 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 libtraceevent

The 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-v5

Changelog
=========
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
#1 lore raw

PATCH v5 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 |  59 ++++++++++++
 tools/perf/builtin-check.c              | 122 ++++++++++++++++++++++++
 tools/perf/builtin.h                    |  18 ++++
 tools/perf/perf.c                       |   1 +
 5 files changed, 201 insertions(+)
 create mode 100644 tools/perf/Documentation/perf-check.txt
 create mode 100644 tools/perf/builtin-check.c
tools/perf/Build +1 -0
index aa7623622834..a55a797c1b5f 100644
@@ -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 +59 -0

59 lines not on this page · raw message

tools/perf/builtin-check.c new file +122 -0

122 lines not on this page · raw message

tools/perf/builtin.h +18 -0
index f2ab5bae2150..9f895981bc9e 100644
@@ -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
index d3fc8090413c..6514f4121c49 100644
@@ -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
#2 lore raw

PATCH v5 2/4 perf version: update --build-options to use 'supported_features' array

In reply to Aditya Gupta

Now 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 | 39 ++++++++----------------------------
 1 file changed, 8 insertions(+), 31 deletions(-)
tools/perf/builtin-version.c +8 -31
index e5859c70e195..e149d96c6dc5 100644
@@ -46,41 +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);
+	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
#3 lore raw

PATCH v5 3/4 perf tests task_analyzer: use perf check for libtraceevent support

In reply to Aditya Gupta

Currently 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
index 92d15154ba79..f4db68edb2e3 100755
@@ -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
#4 lore raw

PATCH v5 4/4 tools/perf/tests: Update probe_vfs_getname.sh script to use perf check --feature

In reply to Aditya Gupta

From: 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
index bf4c1fb71c4b..368a55c02134 100644
@@ -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
index 89214a6d9951..0c00e94b83ff 100755
@@ -58,7 +58,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
index 7f664f1889d9..c7416d21fc92 100755
@@ -19,7 +19,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
maintainer
#5 lore raw
In reply to Aditya Gupta

Arnaldo, Ian and others,

Are you ok with this?

Thanks,
Namhyung

Quoted 100 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 libtraceevent

The 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-v5

Changelog
=========
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

--
2.41.0

#6 lore raw

Em Wed, Oct 04, 2023 at 09:48:49PM -0700, Namhyung Kim escreveu:

Quoted 3 lines

Arnaldo, Ian and others,

Are you ok with this?

Testing/reviewing it now.

- Arnaldo

Quoted 105 lines

Thanks,
Namhyung

Quoted 100 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 libtraceevent

The 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-v5

Changelog
=========
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

--
2.41.0

Signature · 1 line
- Arnaldo
#7 lore raw
In reply to Namhyung Kim

Em Wed, Oct 04, 2023 at 09:48:49PM -0700, Namhyung Kim escreveu:

Quoted 3 lines

Arnaldo, Ian and others,

Are you ok with this?

Its not applying to the current perf-tools-next/perf-tools-next:

[acme@quaco perf-tools-next]$ git remote -v | grep -m1 ^perf-tools-next
perf-tools-next git://git.kernel.org/pub/scm/linux/kernel/git/perf/perf-tools-next.git (fetch)
[acme@quaco perf-tools-next]$

Aditya, can you please take a look, I think it needs a refresh.

- Arnaldo

[acme@quaco perf-tools-next]$ git checkout -b bla perf-tools-next/perf-tools-next
branch 'bla' set up to track 'perf-tools-next/perf-tools-next'.
Switched to a new branch 'bla'
[acme@quaco perf-tools-next]$ b4 am -ctsl --cc-trailers CAM9d7cghSKFMOCSNb0NYEAp6ts_gvxqg4_R4ppnXbzwrApuXSw@mail.gmail.com Grabbing thread from lore.kernel.org/all/CAM9d7cghSKFMOCSNb0NYEAp6ts_gvxqg4_R4ppnXbzwrApuXSw%40mail.gmail.com/t.mbox.gz Checking for newer revisions
Grabbing search results from lore.kernel.org
Analyzing 7 messages in the thread
Checking attestation on all messages, may take a moment...
---
[PATCH v5 1/4] perf check: introduce check subcommand
+ Link: https://lore.kernel.org/r/[email protected]
+ Signed-off-by: Arnaldo Carvalho de Melo <[email protected]>
[PATCH v5 2/4] perf version: update --build-options to use 'supported_features' array
+ Link: https://lore.kernel.org/r/[email protected]
+ Signed-off-by: Arnaldo Carvalho de Melo <[email protected]>
[PATCH v5 3/4] perf tests task_analyzer: use perf check for libtraceevent support
+ Link: https://lore.kernel.org/r/[email protected]
+ Signed-off-by: Arnaldo Carvalho de Melo <[email protected]>
[PATCH v5 4/4] tools/perf/tests: Update probe_vfs_getname.sh script to use perf check --feature
+ Link: https://lore.kernel.org/r/[email protected]
+ Signed-off-by: Arnaldo Carvalho de Melo <[email protected]>
---
NOTE: install dkimpy for DKIM signature verification
---
Total patches: 4
---
Cover: ./v5_20231003_adityag_introduce_perf_check_subcommand.cover

Base: not specified

       git am ./v5_20231003_adityag_introduce_perf_check_subcommand.mbx

[acme@quaco perf-tools-next]$ git am ./v5_20231003_adityag_introduce_perf_check_subcommand.mbx
Applying: perf check: introduce check subcommand
Applying: perf version: update --build-options to use 'supported_features' array
error: patch failed: tools/perf/builtin-version.c:46
error: tools/perf/builtin-version.c: patch does not apply
Patch failed at 0002 perf version: update --build-options to use 'supported_features' array
hint: Use 'git am --show-current-patch=diff' to see the failed patch
When you have resolved this problem, run "git am --continue".
If you prefer to skip this patch, run "git am --skip" instead.
To restore the original branch and stop patching, run "git am --abort". [acme@quaco perf-tools-next]$

Quoted 105 lines

Thanks,
Namhyung

Quoted 100 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 libtraceevent

The 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-v5

Changelog
=========
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

--
2.41.0

Signature · 1 line
- Arnaldo
#8 lore raw
Quoted 5 lines · Arnaldo Carvalho de Melo

Em Wed, Oct 04, 2023 at 09:48:49PM -0700, Namhyung Kim escreveu:

Quoted 3 lines

Arnaldo, Ian and others,

Are you ok with this?

Quoted 7 lines

Its not applying to the current perf-tools-next/perf-tools-next:

[acme@quaco perf-tools-next]$ git remote -v | grep -m1 ^perf-tools-next
perf-tools-next git://git.kernel.org/pub/scm/linux/kernel/git/perf/perf-tools-next.git (fetch)
[acme@quaco perf-tools-next]$

Aditya, can you please take a look, I think it needs a refresh.

Sure Arnaldo, I will rebase it onto current perf-tools-next, and send a v6.

Thanks,
Aditya Gupta

Quoted 155 lines

- Arnaldo

[acme@quaco perf-tools-next]$ git checkout -b bla perf-tools-next/perf-tools-next
branch 'bla' set up to track 'perf-tools-next/perf-tools-next'.
Switched to a new branch 'bla'
[acme@quaco perf-tools-next]$ b4 am -ctsl --cc-trailers CAM9d7cghSKFMOCSNb0NYEAp6ts_gvxqg4_R4ppnXbzwrApuXSw@mail.gmail.com Grabbing thread from lore.kernel.org/all/CAM9d7cghSKFMOCSNb0NYEAp6ts_gvxqg4_R4ppnXbzwrApuXSw%40mail.gmail.com/t.mbox.gz Checking for newer revisions
Grabbing search results from lore.kernel.org
Analyzing 7 messages in the thread
Checking attestation on all messages, may take a moment...
---
[PATCH v5 1/4] perf check: introduce check subcommand
+ Link: https://lore.kernel.org/r/[email protected]
+ Signed-off-by: Arnaldo Carvalho de Melo <[email protected]>
[PATCH v5 2/4] perf version: update --build-options to use 'supported_features' array
+ Link: https://lore.kernel.org/r/[email protected]
+ Signed-off-by: Arnaldo Carvalho de Melo <[email protected]>
[PATCH v5 3/4] perf tests task_analyzer: use perf check for libtraceevent support
+ Link: https://lore.kernel.org/r/[email protected]
+ Signed-off-by: Arnaldo Carvalho de Melo <[email protected]>
[PATCH v5 4/4] tools/perf/tests: Update probe_vfs_getname.sh script to use perf check --feature
+ Link: https://lore.kernel.org/r/[email protected]
+ Signed-off-by: Arnaldo Carvalho de Melo <[email protected]>
---
NOTE: install dkimpy for DKIM signature verification
---
Total patches: 4
---
Cover: ./v5_20231003_adityag_introduce_perf_check_subcommand.cover

Base: not specified

       git am ./v5_20231003_adityag_introduce_perf_check_subcommand.mbx

[acme@quaco perf-tools-next]$ git am ./v5_20231003_adityag_introduce_perf_check_subcommand.mbx
Applying: perf check: introduce check subcommand
Applying: perf version: update --build-options to use 'supported_features' array
error: patch failed: tools/perf/builtin-version.c:46
error: tools/perf/builtin-version.c: patch does not apply
Patch failed at 0002 perf version: update --build-options to use 'supported_features' array
hint: Use 'git am --show-current-patch=diff' to see the failed patch
When you have resolved this problem, run "git am --continue".
If you prefer to skip this patch, run "git am --skip" instead.
To restore the original branch and stop patching, run "git am --abort". [acme@quaco perf-tools-next]$

Quoted 105 lines

Thanks,
Namhyung

Quoted 100 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 libtraceevent

The 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-v5

Changelog
=========
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

--
2.41.0

Signature · 1 line
- Arnaldo