mirror of
https://github.com/torvalds/linux.git
synced 2024-11-28 15:11:31 +00:00
98ad0b7732
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. Multiple features can also be passed as a comma-separated list, in which case the exit status will be 1 only if all of the passed features are built-in. For example, with below command, it will have exit status of 0 only if both libtraceevent and bpf are enabled, else 1 in all other cases perf check feature libtraceevent,bpf The arguments are case-insensitive. 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 Committer testing: $ perf check feature libtraceevent,bpf libtraceevent: [ on ] # HAVE_LIBTRACEEVENT bpf: [ on ] # HAVE_LIBBPF_SUPPORT $ perf check feature libtraceevent libtraceevent: [ on ] # HAVE_LIBTRACEEVENT $ perf check feature bpf bpf: [ on ] # HAVE_LIBBPF_SUPPORT $ perf check -q feature bpf && echo "BPF support is present" BPF support is present $ perf check -q feature Bogus && echo "Bogus support is present" $ Reviewed-by: Athira Rajeev <atrajeev@linux.vnet.ibm.com> Signed-off-by: Aditya Gupta <adityag@linux.ibm.com> Tested-by: Arnaldo Carvalho de Melo <acme@redhat.com> Cc: Athira Rajeev <atrajeev@linux.vnet.ibm.com> Cc: Disha Goel <disgoel@linux.vnet.ibm.com> Cc: Ian Rogers <irogers@google.com> Cc: Jiri Olsa <jolsa@kernel.org> Cc: Kajol Jain <kjain@linux.ibm.com> Cc: Madhavan Srinivasan <maddy@linux.ibm.com> Cc: Namhyung Kim <namhyung@kernel.org> Link: https://lore.kernel.org/r/20240904061836.55873-3-adityag@linux.ibm.com Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
62 lines
2.0 KiB
C
62 lines
2.0 KiB
C
/* SPDX-License-Identifier: GPL-2.0 */
|
|
#ifndef BUILTIN_H
|
|
#define BUILTIN_H
|
|
|
|
#include <stddef.h>
|
|
#include <linux/compiler.h>
|
|
#include <tools/config.h>
|
|
|
|
struct feature_status {
|
|
const char *name;
|
|
const char *macro;
|
|
int is_builtin;
|
|
};
|
|
|
|
#define FEATURE_STATUS(name_, macro_) { \
|
|
.name = name_, \
|
|
.macro = #macro_, \
|
|
.is_builtin = IS_BUILTIN(macro_) }
|
|
|
|
extern struct feature_status supported_features[];
|
|
struct cmdnames;
|
|
|
|
void list_common_cmds_help(void);
|
|
const char *help_unknown_cmd(const char *cmd, struct cmdnames *main_cmds);
|
|
|
|
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);
|
|
int cmd_evlist(int argc, const char **argv);
|
|
int cmd_help(int argc, const char **argv);
|
|
int cmd_sched(int argc, const char **argv);
|
|
int cmd_kallsyms(int argc, const char **argv);
|
|
int cmd_list(int argc, const char **argv);
|
|
int cmd_record(int argc, const char **argv);
|
|
int cmd_report(int argc, const char **argv);
|
|
int cmd_stat(int argc, const char **argv);
|
|
int cmd_timechart(int argc, const char **argv);
|
|
int cmd_top(int argc, const char **argv);
|
|
int cmd_script(int argc, const char **argv);
|
|
int cmd_version(int argc, const char **argv);
|
|
int cmd_probe(int argc, const char **argv);
|
|
int cmd_kmem(int argc, const char **argv);
|
|
int cmd_lock(int argc, const char **argv);
|
|
int cmd_kvm(int argc, const char **argv);
|
|
int cmd_test(int argc, const char **argv);
|
|
int cmd_trace(int argc, const char **argv);
|
|
int cmd_inject(int argc, const char **argv);
|
|
int cmd_mem(int argc, const char **argv);
|
|
int cmd_data(int argc, const char **argv);
|
|
int cmd_ftrace(int argc, const char **argv);
|
|
int cmd_daemon(int argc, const char **argv);
|
|
int cmd_kwork(int argc, const char **argv);
|
|
|
|
int find_scripts(char **scripts_array, char **scripts_path_array, int num,
|
|
int pathlen);
|
|
#endif
|