* [PATCH v1] perf help: Move common_cmds into builtin-help
@ 2025-12-04 21:11 Ian Rogers
2026-01-08 19:37 ` Ian Rogers
2026-01-10 1:31 ` Namhyung Kim
0 siblings, 2 replies; 4+ messages in thread
From: Ian Rogers @ 2025-12-04 21:11 UTC (permalink / raw)
To: Peter Zijlstra, Ingo Molnar, Arnaldo Carvalho de Melo,
Namhyung Kim, Alexander Shishkin, Jiri Olsa, Ian Rogers,
Adrian Hunter, James Clark, Howard Chu, Charlie Jenkins,
linux-kernel, linux-perf-users
There's a lot of infrastructure for generating a relatively simple
array used by one function. Move the array into the function and
remove the supporting build logic. At the same time opportunistically
const-ify the array.
Signed-off-by: Ian Rogers <irogers@google.com>
---
tools/perf/Makefile.perf | 11 ++---
tools/perf/builtin-help.c | 51 ++++++++++++++++++---
tools/perf/command-list.txt | 36 ---------------
tools/perf/util/Build | 14 ------
tools/perf/util/generate-cmdlist.sh | 70 -----------------------------
5 files changed, 49 insertions(+), 133 deletions(-)
delete mode 100644 tools/perf/command-list.txt
delete mode 100755 tools/perf/util/generate-cmdlist.sh
diff --git a/tools/perf/Makefile.perf b/tools/perf/Makefile.perf
index 80decc7ce13c..a91c5d01f3b4 100644
--- a/tools/perf/Makefile.perf
+++ b/tools/perf/Makefile.perf
@@ -807,11 +807,6 @@ $(GTK_IN): FORCE prepare
$(OUTPUT)libperf-gtk.so: $(GTK_IN) $(PERFLIBS)
$(QUIET_LINK)$(CC) -o $@ -shared $(LDFLAGS) $(filter %.o,$^) $(GTK_LIBS)
-$(OUTPUT)common-cmds.h: util/generate-cmdlist.sh command-list.txt
-
-$(OUTPUT)common-cmds.h: $(wildcard Documentation/perf-*.txt)
- $(QUIET_GEN). util/generate-cmdlist.sh > $@+ && mv $@+ $@
-
$(SCRIPTS) : % : %.sh
$(QUIET_GEN)$(INSTALL) '$@.sh' '$(OUTPUT)$@'
@@ -849,7 +844,7 @@ endif
__build-dir = $(subst $(OUTPUT),,$(dir $@))
build-dir = $(or $(__build-dir),.)
-prepare: $(OUTPUT)PERF-VERSION-FILE $(OUTPUT)common-cmds.h archheaders \
+prepare: $(OUTPUT)PERF-VERSION-FILE archheaders \
arm64-sysreg-defs \
$(syscall_array) \
$(fs_at_flags_array) \
@@ -1053,7 +1048,7 @@ cscope:
# However, the environment gets quite big, and some programs have problems
# with that.
-check: $(OUTPUT)common-cmds.h
+check: prepare
if sparse; \
then \
for i in *.c */*.c; \
@@ -1296,7 +1291,7 @@ clean:: $(LIBAPI)-clean $(LIBBPF)-clean $(LIBSUBCMD)-clean $(LIBSYMBOL)-clean $(
$(call QUIET_CLEAN, core-progs) $(RM) $(ALL_PROGRAMS) perf perf-read-vdso32 \
perf-read-vdsox32 $(OUTPUT)$(LIBJVMTI).so
$(call QUIET_CLEAN, core-gen) $(RM) *.spec *.pyc *.pyo */*.pyc */*.pyo \
- $(OUTPUT)common-cmds.h TAGS tags cscope* $(OUTPUT)PERF-VERSION-FILE \
+ TAGS tags cscope* $(OUTPUT)PERF-VERSION-FILE \
$(OUTPUT)FEATURE-DUMP $(OUTPUT)util/*-bison* $(OUTPUT)util/*-flex* \
$(OUTPUT)util/intel-pt-decoder/inat-tables.c \
$(OUTPUT)tests/llvm-src-{base,kbuild,prologue,relocation}.c \
diff --git a/tools/perf/builtin-help.c b/tools/perf/builtin-help.c
index 7be6fb6df595..2692b2e40a23 100644
--- a/tools/perf/builtin-help.c
+++ b/tools/perf/builtin-help.c
@@ -9,7 +9,6 @@
#include "util/strbuf.h"
#include "builtin.h"
#include <subcmd/exec-cmd.h>
-#include "common-cmds.h"
#include <subcmd/parse-options.h>
#include <subcmd/run-command.h>
#include <subcmd/help.h>
@@ -301,16 +300,58 @@ static struct cmdnames main_cmds, other_cmds;
void list_common_cmds_help(void)
{
- unsigned int i, longest = 0;
+ const struct cmdname_help {
+ const char *name;
+ const char *help;
+ } common_cmds[] = {
+ {"annotate", "Read perf.data (created by perf record) and display annotated code"},
+ {"archive",
+ "Create archive with object files with build-ids found in perf.data file"},
+ {"bench", "General framework for benchmark suites"},
+ {"buildid-cache", "Manage build-id cache."},
+ {"buildid-list", "List the buildids in a perf.data file"},
+ {"c2c", "Shared Data C2C/HITM Analyzer."},
+ {"config", "Get and set variables in a configuration file."},
+ {"daemon", "Run record sessions on background"},
+ {"data", "Data file related processing"},
+ {"diff", "Read perf.data files and display the differential profile"},
+ {"evlist", "List the event names in a perf.data file"},
+ {"ftrace", "simple wrapper for kernel's ftrace functionality"},
+ {"inject", "Filter to augment the events stream with additional information"},
+ {"iostat", "Show I/O performance metrics"},
+ {"kallsyms", "Searches running kernel for symbols"},
+ {"kvm", "Tool to trace/measure kvm guest os"},
+ {"list", "List all symbolic event types"},
+ {"mem", "Profile memory accesses"},
+ {"record", "Run a command and record its profile into perf.data"},
+ {"report", "Read perf.data (created by perf record) and display the profile"},
+ {"script", "Read perf.data (created by perf record) and display trace output"},
+ {"stat", "Run a command and gather performance counter statistics"},
+ {"test", "Runs sanity tests."},
+ {"top", "System profiling tool."},
+ {"version", "display the version of perf binary"},
+ #ifdef HAVE_LIBELF_SUPPORT
+ {"probe", "Define new dynamic tracepoints"},
+ #endif /* HAVE_LIBELF_SUPPORT */
+ #ifdef HAVE_LIBTRACEEVENT
+ {"trace", "strace inspired tool"},
+ {"kmem", "Tool to trace/measure kernel memory properties"},
+ {"kwork", "Tool to trace/measure kernel work properties (latencies)"},
+ {"lock", "Analyze lock events"},
+ {"sched", "Tool to trace/measure scheduler properties (latencies)"},
+ {"timechart", "Tool to visualize total system behavior during a workload"},
+ #endif /* HAVE_LIBTRACEEVENT */
+ };
+ size_t longest = 0;
- for (i = 0; i < ARRAY_SIZE(common_cmds); i++) {
+ for (size_t i = 0; i < ARRAY_SIZE(common_cmds); i++) {
if (longest < strlen(common_cmds[i].name))
longest = strlen(common_cmds[i].name);
}
puts(" The most commonly used perf commands are:");
- for (i = 0; i < ARRAY_SIZE(common_cmds); i++) {
- printf(" %-*s ", longest, common_cmds[i].name);
+ for (size_t i = 0; i < ARRAY_SIZE(common_cmds); i++) {
+ printf(" %-*s ", (int)longest, common_cmds[i].name);
puts(common_cmds[i].help);
}
}
diff --git a/tools/perf/command-list.txt b/tools/perf/command-list.txt
deleted file mode 100644
index e8d2762adade..000000000000
--- a/tools/perf/command-list.txt
+++ /dev/null
@@ -1,36 +0,0 @@
-#
-# List of known perf commands.
-# command name category [deprecated] [common]
-#
-perf-annotate mainporcelain common
-perf-archive mainporcelain common
-perf-bench mainporcelain common
-perf-buildid-cache mainporcelain common
-perf-buildid-list mainporcelain common
-perf-data mainporcelain common
-perf-diff mainporcelain common
-perf-c2c mainporcelain common
-perf-config mainporcelain common
-perf-evlist mainporcelain common
-perf-ftrace mainporcelain common
-perf-inject mainporcelain common
-perf-iostat mainporcelain common
-perf-kallsyms mainporcelain common
-perf-kmem mainporcelain traceevent
-perf-kvm mainporcelain common
-perf-kwork mainporcelain traceevent
-perf-list mainporcelain common
-perf-lock mainporcelain traceevent
-perf-mem mainporcelain common
-perf-probe mainporcelain full
-perf-record mainporcelain common
-perf-report mainporcelain common
-perf-sched mainporcelain traceevent
-perf-script mainporcelain common
-perf-stat mainporcelain common
-perf-test mainporcelain common
-perf-timechart mainporcelain traceevent
-perf-top mainporcelain common
-perf-trace mainporcelain audit
-perf-version mainporcelain common
-perf-daemon mainporcelain common
diff --git a/tools/perf/util/Build b/tools/perf/util/Build
index 1c2a43e1dc68..eb77d85a9683 100644
--- a/tools/perf/util/Build
+++ b/tools/perf/util/Build
@@ -418,20 +418,6 @@ $(OUTPUT)util/list_sort.o: ../lib/list_sort.c FORCE
$(call rule_mkdir)
$(call if_changed_dep,cc_o_c)
-ifdef SHELLCHECK
- SHELL_TESTS := generate-cmdlist.sh
- SHELL_TEST_LOGS := $(SHELL_TESTS:%=%.shellcheck_log)
-else
- SHELL_TESTS :=
- SHELL_TEST_LOGS :=
-endif
-
-$(OUTPUT)%.shellcheck_log: %
- $(call rule_mkdir)
- $(Q)$(call echo-cmd,test)$(SHELLCHECK) "$<" > $@ || (cat $@ && rm $@ && false)
-
-perf-util-y += $(SHELL_TEST_LOGS)
-
PY_TESTS := setup.py
ifdef MYPY
MYPY_TEST_LOGS := $(PY_TESTS:%=%.mypy_log)
diff --git a/tools/perf/util/generate-cmdlist.sh b/tools/perf/util/generate-cmdlist.sh
deleted file mode 100755
index 6a73c903d690..000000000000
--- a/tools/perf/util/generate-cmdlist.sh
+++ /dev/null
@@ -1,70 +0,0 @@
-#!/bin/sh
-# SPDX-License-Identifier: GPL-2.0
-
-echo "/* Automatically generated by $0 */
-struct cmdname_help
-{
- char name[16];
- char help[80];
-};
-
-static struct cmdname_help common_cmds[] = {"
-
-sed -n -e 's/^perf-\([^ ]*\)[ ].* common.*/\1/p' command-list.txt |
-sort |
-while read cmd
-do
- sed -n '
- /^NAME/,/perf-'"$cmd"'/H
- ${
- x
- s/.*perf-'"$cmd"' - \(.*\)/ {"'"$cmd"'", "\1"},/
- p
- }' "Documentation/perf-$cmd.txt"
-done
-
-echo "#ifdef HAVE_LIBELF_SUPPORT"
-sed -n -e 's/^perf-\([^ ]*\)[ ].* full.*/\1/p' command-list.txt |
-sort |
-while read cmd
-do
- sed -n '
- /^NAME/,/perf-'"$cmd"'/H
- ${
- x
- s/.*perf-'"$cmd"' - \(.*\)/ {"'"$cmd"'", "\1"},/
- p
- }' "Documentation/perf-$cmd.txt"
-done
-echo "#endif /* HAVE_LIBELF_SUPPORT */"
-
-echo "#if defined(HAVE_LIBTRACEEVENT)"
-sed -n -e 's/^perf-\([^ ]*\)[ ].* audit*/\1/p' command-list.txt |
-sort |
-while read cmd
-do
- sed -n '
- /^NAME/,/perf-'"$cmd"'/H
- ${
- x
- s/.*perf-'"$cmd"' - \(.*\)/ {"'"$cmd"'", "\1"},/
- p
- }' "Documentation/perf-$cmd.txt"
-done
-echo "#endif /* HAVE_LIBTRACEEVENT */"
-
-echo "#ifdef HAVE_LIBTRACEEVENT"
-sed -n -e 's/^perf-\([^ ]*\)[ ].* traceevent.*/\1/p' command-list.txt |
-sort |
-while read cmd
-do
- sed -n '
- /^NAME/,/perf-'"$cmd"'/H
- ${
- x
- s/.*perf-'"$cmd"' - \(.*\)/ {"'"$cmd"'", "\1"},/
- p
- }' "Documentation/perf-$cmd.txt"
-done
-echo "#endif /* HAVE_LIBTRACEEVENT */"
-echo "};"
--
2.52.0.223.gf5cc29aaa4-goog
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH v1] perf help: Move common_cmds into builtin-help
2025-12-04 21:11 [PATCH v1] perf help: Move common_cmds into builtin-help Ian Rogers
@ 2026-01-08 19:37 ` Ian Rogers
2026-01-10 1:31 ` Namhyung Kim
1 sibling, 0 replies; 4+ messages in thread
From: Ian Rogers @ 2026-01-08 19:37 UTC (permalink / raw)
To: Peter Zijlstra, Ingo Molnar, Arnaldo Carvalho de Melo,
Namhyung Kim, Alexander Shishkin, Jiri Olsa, Ian Rogers,
Adrian Hunter, James Clark, Howard Chu, Charlie Jenkins,
linux-kernel, linux-perf-users
On Thu, Dec 4, 2025 at 1:13 PM Ian Rogers <irogers@google.com> wrote:
>
> There's a lot of infrastructure for generating a relatively simple
> array used by one function. Move the array into the function and
> remove the supporting build logic. At the same time opportunistically
> const-ify the array.
>
> Signed-off-by: Ian Rogers <irogers@google.com>
Ping.
Thanks,
Ian
> ---
> tools/perf/Makefile.perf | 11 ++---
> tools/perf/builtin-help.c | 51 ++++++++++++++++++---
> tools/perf/command-list.txt | 36 ---------------
> tools/perf/util/Build | 14 ------
> tools/perf/util/generate-cmdlist.sh | 70 -----------------------------
> 5 files changed, 49 insertions(+), 133 deletions(-)
> delete mode 100644 tools/perf/command-list.txt
> delete mode 100755 tools/perf/util/generate-cmdlist.sh
>
> diff --git a/tools/perf/Makefile.perf b/tools/perf/Makefile.perf
> index 80decc7ce13c..a91c5d01f3b4 100644
> --- a/tools/perf/Makefile.perf
> +++ b/tools/perf/Makefile.perf
> @@ -807,11 +807,6 @@ $(GTK_IN): FORCE prepare
> $(OUTPUT)libperf-gtk.so: $(GTK_IN) $(PERFLIBS)
> $(QUIET_LINK)$(CC) -o $@ -shared $(LDFLAGS) $(filter %.o,$^) $(GTK_LIBS)
>
> -$(OUTPUT)common-cmds.h: util/generate-cmdlist.sh command-list.txt
> -
> -$(OUTPUT)common-cmds.h: $(wildcard Documentation/perf-*.txt)
> - $(QUIET_GEN). util/generate-cmdlist.sh > $@+ && mv $@+ $@
> -
> $(SCRIPTS) : % : %.sh
> $(QUIET_GEN)$(INSTALL) '$@.sh' '$(OUTPUT)$@'
>
> @@ -849,7 +844,7 @@ endif
> __build-dir = $(subst $(OUTPUT),,$(dir $@))
> build-dir = $(or $(__build-dir),.)
>
> -prepare: $(OUTPUT)PERF-VERSION-FILE $(OUTPUT)common-cmds.h archheaders \
> +prepare: $(OUTPUT)PERF-VERSION-FILE archheaders \
> arm64-sysreg-defs \
> $(syscall_array) \
> $(fs_at_flags_array) \
> @@ -1053,7 +1048,7 @@ cscope:
> # However, the environment gets quite big, and some programs have problems
> # with that.
>
> -check: $(OUTPUT)common-cmds.h
> +check: prepare
> if sparse; \
> then \
> for i in *.c */*.c; \
> @@ -1296,7 +1291,7 @@ clean:: $(LIBAPI)-clean $(LIBBPF)-clean $(LIBSUBCMD)-clean $(LIBSYMBOL)-clean $(
> $(call QUIET_CLEAN, core-progs) $(RM) $(ALL_PROGRAMS) perf perf-read-vdso32 \
> perf-read-vdsox32 $(OUTPUT)$(LIBJVMTI).so
> $(call QUIET_CLEAN, core-gen) $(RM) *.spec *.pyc *.pyo */*.pyc */*.pyo \
> - $(OUTPUT)common-cmds.h TAGS tags cscope* $(OUTPUT)PERF-VERSION-FILE \
> + TAGS tags cscope* $(OUTPUT)PERF-VERSION-FILE \
> $(OUTPUT)FEATURE-DUMP $(OUTPUT)util/*-bison* $(OUTPUT)util/*-flex* \
> $(OUTPUT)util/intel-pt-decoder/inat-tables.c \
> $(OUTPUT)tests/llvm-src-{base,kbuild,prologue,relocation}.c \
> diff --git a/tools/perf/builtin-help.c b/tools/perf/builtin-help.c
> index 7be6fb6df595..2692b2e40a23 100644
> --- a/tools/perf/builtin-help.c
> +++ b/tools/perf/builtin-help.c
> @@ -9,7 +9,6 @@
> #include "util/strbuf.h"
> #include "builtin.h"
> #include <subcmd/exec-cmd.h>
> -#include "common-cmds.h"
> #include <subcmd/parse-options.h>
> #include <subcmd/run-command.h>
> #include <subcmd/help.h>
> @@ -301,16 +300,58 @@ static struct cmdnames main_cmds, other_cmds;
>
> void list_common_cmds_help(void)
> {
> - unsigned int i, longest = 0;
> + const struct cmdname_help {
> + const char *name;
> + const char *help;
> + } common_cmds[] = {
> + {"annotate", "Read perf.data (created by perf record) and display annotated code"},
> + {"archive",
> + "Create archive with object files with build-ids found in perf.data file"},
> + {"bench", "General framework for benchmark suites"},
> + {"buildid-cache", "Manage build-id cache."},
> + {"buildid-list", "List the buildids in a perf.data file"},
> + {"c2c", "Shared Data C2C/HITM Analyzer."},
> + {"config", "Get and set variables in a configuration file."},
> + {"daemon", "Run record sessions on background"},
> + {"data", "Data file related processing"},
> + {"diff", "Read perf.data files and display the differential profile"},
> + {"evlist", "List the event names in a perf.data file"},
> + {"ftrace", "simple wrapper for kernel's ftrace functionality"},
> + {"inject", "Filter to augment the events stream with additional information"},
> + {"iostat", "Show I/O performance metrics"},
> + {"kallsyms", "Searches running kernel for symbols"},
> + {"kvm", "Tool to trace/measure kvm guest os"},
> + {"list", "List all symbolic event types"},
> + {"mem", "Profile memory accesses"},
> + {"record", "Run a command and record its profile into perf.data"},
> + {"report", "Read perf.data (created by perf record) and display the profile"},
> + {"script", "Read perf.data (created by perf record) and display trace output"},
> + {"stat", "Run a command and gather performance counter statistics"},
> + {"test", "Runs sanity tests."},
> + {"top", "System profiling tool."},
> + {"version", "display the version of perf binary"},
> + #ifdef HAVE_LIBELF_SUPPORT
> + {"probe", "Define new dynamic tracepoints"},
> + #endif /* HAVE_LIBELF_SUPPORT */
> + #ifdef HAVE_LIBTRACEEVENT
> + {"trace", "strace inspired tool"},
> + {"kmem", "Tool to trace/measure kernel memory properties"},
> + {"kwork", "Tool to trace/measure kernel work properties (latencies)"},
> + {"lock", "Analyze lock events"},
> + {"sched", "Tool to trace/measure scheduler properties (latencies)"},
> + {"timechart", "Tool to visualize total system behavior during a workload"},
> + #endif /* HAVE_LIBTRACEEVENT */
> + };
> + size_t longest = 0;
>
> - for (i = 0; i < ARRAY_SIZE(common_cmds); i++) {
> + for (size_t i = 0; i < ARRAY_SIZE(common_cmds); i++) {
> if (longest < strlen(common_cmds[i].name))
> longest = strlen(common_cmds[i].name);
> }
>
> puts(" The most commonly used perf commands are:");
> - for (i = 0; i < ARRAY_SIZE(common_cmds); i++) {
> - printf(" %-*s ", longest, common_cmds[i].name);
> + for (size_t i = 0; i < ARRAY_SIZE(common_cmds); i++) {
> + printf(" %-*s ", (int)longest, common_cmds[i].name);
> puts(common_cmds[i].help);
> }
> }
> diff --git a/tools/perf/command-list.txt b/tools/perf/command-list.txt
> deleted file mode 100644
> index e8d2762adade..000000000000
> --- a/tools/perf/command-list.txt
> +++ /dev/null
> @@ -1,36 +0,0 @@
> -#
> -# List of known perf commands.
> -# command name category [deprecated] [common]
> -#
> -perf-annotate mainporcelain common
> -perf-archive mainporcelain common
> -perf-bench mainporcelain common
> -perf-buildid-cache mainporcelain common
> -perf-buildid-list mainporcelain common
> -perf-data mainporcelain common
> -perf-diff mainporcelain common
> -perf-c2c mainporcelain common
> -perf-config mainporcelain common
> -perf-evlist mainporcelain common
> -perf-ftrace mainporcelain common
> -perf-inject mainporcelain common
> -perf-iostat mainporcelain common
> -perf-kallsyms mainporcelain common
> -perf-kmem mainporcelain traceevent
> -perf-kvm mainporcelain common
> -perf-kwork mainporcelain traceevent
> -perf-list mainporcelain common
> -perf-lock mainporcelain traceevent
> -perf-mem mainporcelain common
> -perf-probe mainporcelain full
> -perf-record mainporcelain common
> -perf-report mainporcelain common
> -perf-sched mainporcelain traceevent
> -perf-script mainporcelain common
> -perf-stat mainporcelain common
> -perf-test mainporcelain common
> -perf-timechart mainporcelain traceevent
> -perf-top mainporcelain common
> -perf-trace mainporcelain audit
> -perf-version mainporcelain common
> -perf-daemon mainporcelain common
> diff --git a/tools/perf/util/Build b/tools/perf/util/Build
> index 1c2a43e1dc68..eb77d85a9683 100644
> --- a/tools/perf/util/Build
> +++ b/tools/perf/util/Build
> @@ -418,20 +418,6 @@ $(OUTPUT)util/list_sort.o: ../lib/list_sort.c FORCE
> $(call rule_mkdir)
> $(call if_changed_dep,cc_o_c)
>
> -ifdef SHELLCHECK
> - SHELL_TESTS := generate-cmdlist.sh
> - SHELL_TEST_LOGS := $(SHELL_TESTS:%=%.shellcheck_log)
> -else
> - SHELL_TESTS :=
> - SHELL_TEST_LOGS :=
> -endif
> -
> -$(OUTPUT)%.shellcheck_log: %
> - $(call rule_mkdir)
> - $(Q)$(call echo-cmd,test)$(SHELLCHECK) "$<" > $@ || (cat $@ && rm $@ && false)
> -
> -perf-util-y += $(SHELL_TEST_LOGS)
> -
> PY_TESTS := setup.py
> ifdef MYPY
> MYPY_TEST_LOGS := $(PY_TESTS:%=%.mypy_log)
> diff --git a/tools/perf/util/generate-cmdlist.sh b/tools/perf/util/generate-cmdlist.sh
> deleted file mode 100755
> index 6a73c903d690..000000000000
> --- a/tools/perf/util/generate-cmdlist.sh
> +++ /dev/null
> @@ -1,70 +0,0 @@
> -#!/bin/sh
> -# SPDX-License-Identifier: GPL-2.0
> -
> -echo "/* Automatically generated by $0 */
> -struct cmdname_help
> -{
> - char name[16];
> - char help[80];
> -};
> -
> -static struct cmdname_help common_cmds[] = {"
> -
> -sed -n -e 's/^perf-\([^ ]*\)[ ].* common.*/\1/p' command-list.txt |
> -sort |
> -while read cmd
> -do
> - sed -n '
> - /^NAME/,/perf-'"$cmd"'/H
> - ${
> - x
> - s/.*perf-'"$cmd"' - \(.*\)/ {"'"$cmd"'", "\1"},/
> - p
> - }' "Documentation/perf-$cmd.txt"
> -done
> -
> -echo "#ifdef HAVE_LIBELF_SUPPORT"
> -sed -n -e 's/^perf-\([^ ]*\)[ ].* full.*/\1/p' command-list.txt |
> -sort |
> -while read cmd
> -do
> - sed -n '
> - /^NAME/,/perf-'"$cmd"'/H
> - ${
> - x
> - s/.*perf-'"$cmd"' - \(.*\)/ {"'"$cmd"'", "\1"},/
> - p
> - }' "Documentation/perf-$cmd.txt"
> -done
> -echo "#endif /* HAVE_LIBELF_SUPPORT */"
> -
> -echo "#if defined(HAVE_LIBTRACEEVENT)"
> -sed -n -e 's/^perf-\([^ ]*\)[ ].* audit*/\1/p' command-list.txt |
> -sort |
> -while read cmd
> -do
> - sed -n '
> - /^NAME/,/perf-'"$cmd"'/H
> - ${
> - x
> - s/.*perf-'"$cmd"' - \(.*\)/ {"'"$cmd"'", "\1"},/
> - p
> - }' "Documentation/perf-$cmd.txt"
> -done
> -echo "#endif /* HAVE_LIBTRACEEVENT */"
> -
> -echo "#ifdef HAVE_LIBTRACEEVENT"
> -sed -n -e 's/^perf-\([^ ]*\)[ ].* traceevent.*/\1/p' command-list.txt |
> -sort |
> -while read cmd
> -do
> - sed -n '
> - /^NAME/,/perf-'"$cmd"'/H
> - ${
> - x
> - s/.*perf-'"$cmd"' - \(.*\)/ {"'"$cmd"'", "\1"},/
> - p
> - }' "Documentation/perf-$cmd.txt"
> -done
> -echo "#endif /* HAVE_LIBTRACEEVENT */"
> -echo "};"
> --
> 2.52.0.223.gf5cc29aaa4-goog
>
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH v1] perf help: Move common_cmds into builtin-help
2025-12-04 21:11 [PATCH v1] perf help: Move common_cmds into builtin-help Ian Rogers
2026-01-08 19:37 ` Ian Rogers
@ 2026-01-10 1:31 ` Namhyung Kim
2026-01-13 21:42 ` Arnaldo Carvalho de Melo
1 sibling, 1 reply; 4+ messages in thread
From: Namhyung Kim @ 2026-01-10 1:31 UTC (permalink / raw)
To: Ian Rogers
Cc: Peter Zijlstra, Ingo Molnar, Arnaldo Carvalho de Melo,
Alexander Shishkin, Jiri Olsa, Adrian Hunter, James Clark,
Howard Chu, Charlie Jenkins, linux-kernel, linux-perf-users
On Thu, Dec 04, 2025 at 01:11:43PM -0800, Ian Rogers wrote:
> There's a lot of infrastructure for generating a relatively simple
> array used by one function. Move the array into the function and
> remove the supporting build logic. At the same time opportunistically
> const-ify the array.
>
> Signed-off-by: Ian Rogers <irogers@google.com>
Acked-by: Namhyung Kim <namhyung@kernel.org>
Thanks,
Namhyung
> ---
> tools/perf/Makefile.perf | 11 ++---
> tools/perf/builtin-help.c | 51 ++++++++++++++++++---
> tools/perf/command-list.txt | 36 ---------------
> tools/perf/util/Build | 14 ------
> tools/perf/util/generate-cmdlist.sh | 70 -----------------------------
> 5 files changed, 49 insertions(+), 133 deletions(-)
> delete mode 100644 tools/perf/command-list.txt
> delete mode 100755 tools/perf/util/generate-cmdlist.sh
>
> diff --git a/tools/perf/Makefile.perf b/tools/perf/Makefile.perf
> index 80decc7ce13c..a91c5d01f3b4 100644
> --- a/tools/perf/Makefile.perf
> +++ b/tools/perf/Makefile.perf
> @@ -807,11 +807,6 @@ $(GTK_IN): FORCE prepare
> $(OUTPUT)libperf-gtk.so: $(GTK_IN) $(PERFLIBS)
> $(QUIET_LINK)$(CC) -o $@ -shared $(LDFLAGS) $(filter %.o,$^) $(GTK_LIBS)
>
> -$(OUTPUT)common-cmds.h: util/generate-cmdlist.sh command-list.txt
> -
> -$(OUTPUT)common-cmds.h: $(wildcard Documentation/perf-*.txt)
> - $(QUIET_GEN). util/generate-cmdlist.sh > $@+ && mv $@+ $@
> -
> $(SCRIPTS) : % : %.sh
> $(QUIET_GEN)$(INSTALL) '$@.sh' '$(OUTPUT)$@'
>
> @@ -849,7 +844,7 @@ endif
> __build-dir = $(subst $(OUTPUT),,$(dir $@))
> build-dir = $(or $(__build-dir),.)
>
> -prepare: $(OUTPUT)PERF-VERSION-FILE $(OUTPUT)common-cmds.h archheaders \
> +prepare: $(OUTPUT)PERF-VERSION-FILE archheaders \
> arm64-sysreg-defs \
> $(syscall_array) \
> $(fs_at_flags_array) \
> @@ -1053,7 +1048,7 @@ cscope:
> # However, the environment gets quite big, and some programs have problems
> # with that.
>
> -check: $(OUTPUT)common-cmds.h
> +check: prepare
> if sparse; \
> then \
> for i in *.c */*.c; \
> @@ -1296,7 +1291,7 @@ clean:: $(LIBAPI)-clean $(LIBBPF)-clean $(LIBSUBCMD)-clean $(LIBSYMBOL)-clean $(
> $(call QUIET_CLEAN, core-progs) $(RM) $(ALL_PROGRAMS) perf perf-read-vdso32 \
> perf-read-vdsox32 $(OUTPUT)$(LIBJVMTI).so
> $(call QUIET_CLEAN, core-gen) $(RM) *.spec *.pyc *.pyo */*.pyc */*.pyo \
> - $(OUTPUT)common-cmds.h TAGS tags cscope* $(OUTPUT)PERF-VERSION-FILE \
> + TAGS tags cscope* $(OUTPUT)PERF-VERSION-FILE \
> $(OUTPUT)FEATURE-DUMP $(OUTPUT)util/*-bison* $(OUTPUT)util/*-flex* \
> $(OUTPUT)util/intel-pt-decoder/inat-tables.c \
> $(OUTPUT)tests/llvm-src-{base,kbuild,prologue,relocation}.c \
> diff --git a/tools/perf/builtin-help.c b/tools/perf/builtin-help.c
> index 7be6fb6df595..2692b2e40a23 100644
> --- a/tools/perf/builtin-help.c
> +++ b/tools/perf/builtin-help.c
> @@ -9,7 +9,6 @@
> #include "util/strbuf.h"
> #include "builtin.h"
> #include <subcmd/exec-cmd.h>
> -#include "common-cmds.h"
> #include <subcmd/parse-options.h>
> #include <subcmd/run-command.h>
> #include <subcmd/help.h>
> @@ -301,16 +300,58 @@ static struct cmdnames main_cmds, other_cmds;
>
> void list_common_cmds_help(void)
> {
> - unsigned int i, longest = 0;
> + const struct cmdname_help {
> + const char *name;
> + const char *help;
> + } common_cmds[] = {
> + {"annotate", "Read perf.data (created by perf record) and display annotated code"},
> + {"archive",
> + "Create archive with object files with build-ids found in perf.data file"},
> + {"bench", "General framework for benchmark suites"},
> + {"buildid-cache", "Manage build-id cache."},
> + {"buildid-list", "List the buildids in a perf.data file"},
> + {"c2c", "Shared Data C2C/HITM Analyzer."},
> + {"config", "Get and set variables in a configuration file."},
> + {"daemon", "Run record sessions on background"},
> + {"data", "Data file related processing"},
> + {"diff", "Read perf.data files and display the differential profile"},
> + {"evlist", "List the event names in a perf.data file"},
> + {"ftrace", "simple wrapper for kernel's ftrace functionality"},
> + {"inject", "Filter to augment the events stream with additional information"},
> + {"iostat", "Show I/O performance metrics"},
> + {"kallsyms", "Searches running kernel for symbols"},
> + {"kvm", "Tool to trace/measure kvm guest os"},
> + {"list", "List all symbolic event types"},
> + {"mem", "Profile memory accesses"},
> + {"record", "Run a command and record its profile into perf.data"},
> + {"report", "Read perf.data (created by perf record) and display the profile"},
> + {"script", "Read perf.data (created by perf record) and display trace output"},
> + {"stat", "Run a command and gather performance counter statistics"},
> + {"test", "Runs sanity tests."},
> + {"top", "System profiling tool."},
> + {"version", "display the version of perf binary"},
> + #ifdef HAVE_LIBELF_SUPPORT
> + {"probe", "Define new dynamic tracepoints"},
> + #endif /* HAVE_LIBELF_SUPPORT */
> + #ifdef HAVE_LIBTRACEEVENT
> + {"trace", "strace inspired tool"},
> + {"kmem", "Tool to trace/measure kernel memory properties"},
> + {"kwork", "Tool to trace/measure kernel work properties (latencies)"},
> + {"lock", "Analyze lock events"},
> + {"sched", "Tool to trace/measure scheduler properties (latencies)"},
> + {"timechart", "Tool to visualize total system behavior during a workload"},
> + #endif /* HAVE_LIBTRACEEVENT */
> + };
> + size_t longest = 0;
>
> - for (i = 0; i < ARRAY_SIZE(common_cmds); i++) {
> + for (size_t i = 0; i < ARRAY_SIZE(common_cmds); i++) {
> if (longest < strlen(common_cmds[i].name))
> longest = strlen(common_cmds[i].name);
> }
>
> puts(" The most commonly used perf commands are:");
> - for (i = 0; i < ARRAY_SIZE(common_cmds); i++) {
> - printf(" %-*s ", longest, common_cmds[i].name);
> + for (size_t i = 0; i < ARRAY_SIZE(common_cmds); i++) {
> + printf(" %-*s ", (int)longest, common_cmds[i].name);
> puts(common_cmds[i].help);
> }
> }
> diff --git a/tools/perf/command-list.txt b/tools/perf/command-list.txt
> deleted file mode 100644
> index e8d2762adade..000000000000
> --- a/tools/perf/command-list.txt
> +++ /dev/null
> @@ -1,36 +0,0 @@
> -#
> -# List of known perf commands.
> -# command name category [deprecated] [common]
> -#
> -perf-annotate mainporcelain common
> -perf-archive mainporcelain common
> -perf-bench mainporcelain common
> -perf-buildid-cache mainporcelain common
> -perf-buildid-list mainporcelain common
> -perf-data mainporcelain common
> -perf-diff mainporcelain common
> -perf-c2c mainporcelain common
> -perf-config mainporcelain common
> -perf-evlist mainporcelain common
> -perf-ftrace mainporcelain common
> -perf-inject mainporcelain common
> -perf-iostat mainporcelain common
> -perf-kallsyms mainporcelain common
> -perf-kmem mainporcelain traceevent
> -perf-kvm mainporcelain common
> -perf-kwork mainporcelain traceevent
> -perf-list mainporcelain common
> -perf-lock mainporcelain traceevent
> -perf-mem mainporcelain common
> -perf-probe mainporcelain full
> -perf-record mainporcelain common
> -perf-report mainporcelain common
> -perf-sched mainporcelain traceevent
> -perf-script mainporcelain common
> -perf-stat mainporcelain common
> -perf-test mainporcelain common
> -perf-timechart mainporcelain traceevent
> -perf-top mainporcelain common
> -perf-trace mainporcelain audit
> -perf-version mainporcelain common
> -perf-daemon mainporcelain common
> diff --git a/tools/perf/util/Build b/tools/perf/util/Build
> index 1c2a43e1dc68..eb77d85a9683 100644
> --- a/tools/perf/util/Build
> +++ b/tools/perf/util/Build
> @@ -418,20 +418,6 @@ $(OUTPUT)util/list_sort.o: ../lib/list_sort.c FORCE
> $(call rule_mkdir)
> $(call if_changed_dep,cc_o_c)
>
> -ifdef SHELLCHECK
> - SHELL_TESTS := generate-cmdlist.sh
> - SHELL_TEST_LOGS := $(SHELL_TESTS:%=%.shellcheck_log)
> -else
> - SHELL_TESTS :=
> - SHELL_TEST_LOGS :=
> -endif
> -
> -$(OUTPUT)%.shellcheck_log: %
> - $(call rule_mkdir)
> - $(Q)$(call echo-cmd,test)$(SHELLCHECK) "$<" > $@ || (cat $@ && rm $@ && false)
> -
> -perf-util-y += $(SHELL_TEST_LOGS)
> -
> PY_TESTS := setup.py
> ifdef MYPY
> MYPY_TEST_LOGS := $(PY_TESTS:%=%.mypy_log)
> diff --git a/tools/perf/util/generate-cmdlist.sh b/tools/perf/util/generate-cmdlist.sh
> deleted file mode 100755
> index 6a73c903d690..000000000000
> --- a/tools/perf/util/generate-cmdlist.sh
> +++ /dev/null
> @@ -1,70 +0,0 @@
> -#!/bin/sh
> -# SPDX-License-Identifier: GPL-2.0
> -
> -echo "/* Automatically generated by $0 */
> -struct cmdname_help
> -{
> - char name[16];
> - char help[80];
> -};
> -
> -static struct cmdname_help common_cmds[] = {"
> -
> -sed -n -e 's/^perf-\([^ ]*\)[ ].* common.*/\1/p' command-list.txt |
> -sort |
> -while read cmd
> -do
> - sed -n '
> - /^NAME/,/perf-'"$cmd"'/H
> - ${
> - x
> - s/.*perf-'"$cmd"' - \(.*\)/ {"'"$cmd"'", "\1"},/
> - p
> - }' "Documentation/perf-$cmd.txt"
> -done
> -
> -echo "#ifdef HAVE_LIBELF_SUPPORT"
> -sed -n -e 's/^perf-\([^ ]*\)[ ].* full.*/\1/p' command-list.txt |
> -sort |
> -while read cmd
> -do
> - sed -n '
> - /^NAME/,/perf-'"$cmd"'/H
> - ${
> - x
> - s/.*perf-'"$cmd"' - \(.*\)/ {"'"$cmd"'", "\1"},/
> - p
> - }' "Documentation/perf-$cmd.txt"
> -done
> -echo "#endif /* HAVE_LIBELF_SUPPORT */"
> -
> -echo "#if defined(HAVE_LIBTRACEEVENT)"
> -sed -n -e 's/^perf-\([^ ]*\)[ ].* audit*/\1/p' command-list.txt |
> -sort |
> -while read cmd
> -do
> - sed -n '
> - /^NAME/,/perf-'"$cmd"'/H
> - ${
> - x
> - s/.*perf-'"$cmd"' - \(.*\)/ {"'"$cmd"'", "\1"},/
> - p
> - }' "Documentation/perf-$cmd.txt"
> -done
> -echo "#endif /* HAVE_LIBTRACEEVENT */"
> -
> -echo "#ifdef HAVE_LIBTRACEEVENT"
> -sed -n -e 's/^perf-\([^ ]*\)[ ].* traceevent.*/\1/p' command-list.txt |
> -sort |
> -while read cmd
> -do
> - sed -n '
> - /^NAME/,/perf-'"$cmd"'/H
> - ${
> - x
> - s/.*perf-'"$cmd"' - \(.*\)/ {"'"$cmd"'", "\1"},/
> - p
> - }' "Documentation/perf-$cmd.txt"
> -done
> -echo "#endif /* HAVE_LIBTRACEEVENT */"
> -echo "};"
> --
> 2.52.0.223.gf5cc29aaa4-goog
>
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH v1] perf help: Move common_cmds into builtin-help
2026-01-10 1:31 ` Namhyung Kim
@ 2026-01-13 21:42 ` Arnaldo Carvalho de Melo
0 siblings, 0 replies; 4+ messages in thread
From: Arnaldo Carvalho de Melo @ 2026-01-13 21:42 UTC (permalink / raw)
To: Namhyung Kim
Cc: Ian Rogers, Peter Zijlstra, Ingo Molnar, Alexander Shishkin,
Jiri Olsa, Adrian Hunter, James Clark, Howard Chu,
Charlie Jenkins, linux-kernel, linux-perf-users
On Fri, Jan 09, 2026 at 05:31:36PM -0800, Namhyung Kim wrote:
> On Thu, Dec 04, 2025 at 01:11:43PM -0800, Ian Rogers wrote:
> > There's a lot of infrastructure for generating a relatively simple
> > array used by one function. Move the array into the function and
> > remove the supporting build logic. At the same time opportunistically
> > const-ify the array.
> >
> > Signed-off-by: Ian Rogers <irogers@google.com>
>
> Acked-by: Namhyung Kim <namhyung@kernel.org>
Thanks, applied to perf-tools-next,
- Arnaldo
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2026-01-13 21:42 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-12-04 21:11 [PATCH v1] perf help: Move common_cmds into builtin-help Ian Rogers
2026-01-08 19:37 ` Ian Rogers
2026-01-10 1:31 ` Namhyung Kim
2026-01-13 21:42 ` Arnaldo Carvalho de Melo
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.