linux-perf-users.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v3 0/6] perf tool: Build dependency tidy up
@ 2026-09-02 15:48 Ian Rogers
  2026-09-02 15:48 ` [PATCH v3 1/6] perf tool: Remove util/cache.h Ian Rogers
                   ` (5 more replies)
  0 siblings, 6 replies; 14+ messages in thread
From: Ian Rogers @ 2026-09-02 15:48 UTC (permalink / raw)
  To: Peter Zijlstra, Ingo Molnar, Arnaldo Carvalho de Melo,
	Namhyung Kim, Jiri Olsa, Ian Rogers, Adrian Hunter, James Clark,
	Tianyou Li, Jiebin Sun, Dapeng Mi, Eric Biggers, Thomas Richter,
	Stephen Brennan, Swapnil Sapkal, linux-kernel, linux-perf-users

In doing some work on bazel building of perf (bazel being stricter on
how header files are used), rather than just making the bazel BUILD
files more generous in how they accept header file issues like
transitive dependencies it felt cleaner to address them. These patches
tackle the most severe issues such as cache.h pulling in UI code,
hist.h bringing in UI code, unused header files, transitive
dependencies, etc.

While cleaning up the dependencies in perf.c, change how missing
commands are handled to give a more meaningful error message at run
time about missing build time dependencies.

v1 and v2 were previously sent just addressing the cache.h issue:
https://lore.kernel.org/linux-perf-users/20260828222045.1314766-1-irogers@google.com/

Ian Rogers (6):
  perf tool: Remove util/cache.h
  perf tool: Tidy up util/cache.h header file users
  perf tool: Remove unused includes in perf.c
  perf tool: Move usage strings and functions to perf.c
  perf tool: Add fallback stubs for missing dependencies
  perf hist: Remove keysym.h include from hist.h

 tools/perf/builtin-annotate.c      |  57 +++++++++------
 tools/perf/builtin-c2c.c           |   1 +
 tools/perf/builtin-config.c        |  18 +++--
 tools/perf/builtin-help.c          |  30 ++++----
 tools/perf/builtin-kvm.c           |   1 +
 tools/perf/builtin-report.c        |   1 +
 tools/perf/builtin-top.c           |   1 +
 tools/perf/builtin.h               |   3 +
 tools/perf/perf.c                  | 114 ++++++++++++++++++-----------
 tools/perf/ui/browsers/annotate.c  |   1 +
 tools/perf/ui/browsers/hists.c     |   1 +
 tools/perf/ui/browsers/scripts.c   |   1 +
 tools/perf/ui/libslang.h           |   2 +
 tools/perf/util/Build              |   1 -
 tools/perf/util/cache.h            |  31 --------
 tools/perf/util/config.c           |  38 ++++++----
 tools/perf/util/help-unknown-cmd.c |  15 +++-
 tools/perf/util/hist.h             |   6 --
 tools/perf/util/path.c             |  10 +--
 tools/perf/util/path.h             |   6 +-
 tools/perf/util/strbuf.c           |  14 ++--
 tools/perf/util/usage.c            |  34 ---------
 tools/perf/util/util.h             |   4 -
 23 files changed, 194 insertions(+), 196 deletions(-)
 delete mode 100644 tools/perf/util/cache.h
 delete mode 100644 tools/perf/util/usage.c

-- 
2.55.0.966.g6673acef38-goog


^ permalink raw reply	[flat|nested] 14+ messages in thread

* [PATCH v3 1/6] perf tool: Remove util/cache.h
  2026-09-02 15:48 [PATCH v3 0/6] perf tool: Build dependency tidy up Ian Rogers
@ 2026-09-02 15:48 ` Ian Rogers
  2026-09-02 15:57   ` sashiko-bot
  2026-09-02 15:48 ` [PATCH v3 2/6] perf tool: Tidy up util/cache.h header file users Ian Rogers
                   ` (4 subsequent siblings)
  5 siblings, 1 reply; 14+ messages in thread
From: Ian Rogers @ 2026-09-02 15:48 UTC (permalink / raw)
  To: Peter Zijlstra, Ingo Molnar, Arnaldo Carvalho de Melo,
	Namhyung Kim, Jiri Olsa, Ian Rogers, Adrian Hunter, James Clark,
	Tianyou Li, Jiebin Sun, Dapeng Mi, Eric Biggers, Thomas Richter,
	Stephen Brennan, Swapnil Sapkal, linux-kernel, linux-perf-users

Move definitions to places they are used, or path.h in the case of
path.c's mkpath function. Remove unused definitions. Fix transitive
include dependencies.

Signed-off-by: Ian Rogers <irogers@google.com>
---
 tools/perf/builtin-annotate.c      |  6 +++++-
 tools/perf/builtin-config.c        |  4 +++-
 tools/perf/builtin-help.c          |  3 ++-
 tools/perf/perf.c                  | 11 ++++++++++-
 tools/perf/util/cache.h            | 31 ------------------------------
 tools/perf/util/config.c           |  5 ++++-
 tools/perf/util/help-unknown-cmd.c |  6 +++++-
 tools/perf/util/path.c             |  2 +-
 tools/perf/util/path.h             |  3 +++
 tools/perf/util/strbuf.c           |  5 ++++-
 10 files changed, 37 insertions(+), 39 deletions(-)
 delete mode 100644 tools/perf/util/cache.h

diff --git a/tools/perf/builtin-annotate.c b/tools/perf/builtin-annotate.c
index 69cb72b2082a..75cbea567196 100644
--- a/tools/perf/builtin-annotate.c
+++ b/tools/perf/builtin-annotate.c
@@ -8,10 +8,10 @@
  */
 #include "builtin.h"
 #include "perf.h"
+#include <stdbool.h>
 
 #include "util/color.h"
 #include <linux/list.h>
-#include "util/cache.h"
 #include <linux/rbtree.h>
 #include "util/symbol.h"
 
@@ -38,12 +38,16 @@
 #include "util/branch.h"
 #include "util/util.h"
 #include "ui/progress.h"
+#include "ui/ui.h"
 
 #include <dlfcn.h>
 #include <errno.h>
 #include <linux/bitmap.h>
 #include <linux/err.h>
 #include <inttypes.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
 
 struct perf_annotate {
 	struct perf_tool tool;
diff --git a/tools/perf/builtin-config.c b/tools/perf/builtin-config.c
index 237600643bbd..845a8af67fc5 100644
--- a/tools/perf/builtin-config.c
+++ b/tools/perf/builtin-config.c
@@ -7,14 +7,16 @@
  */
 #include "builtin.h"
 
-#include "util/cache.h"
 #include <subcmd/parse-options.h>
 #include "util/debug.h"
 #include "util/config.h"
+#include "util/path.h"
 #include <linux/string.h>
 #include <limits.h>
 #include <stdio.h>
 #include <stdlib.h>
+#include <stdbool.h>
+#include <string.h>
 
 static bool use_system_config, use_user_config;
 
diff --git a/tools/perf/builtin-help.c b/tools/perf/builtin-help.c
index 2692b2e40a23..f0e95d741892 100644
--- a/tools/perf/builtin-help.c
+++ b/tools/perf/builtin-help.c
@@ -4,8 +4,8 @@
  *
  * Builtin help command
  */
-#include "util/cache.h"
 #include "util/config.h"
+#include "util/path.h"
 #include "util/strbuf.h"
 #include "builtin.h"
 #include <subcmd/exec-cmd.h>
@@ -21,6 +21,7 @@
 #include <limits.h>
 #include <stdio.h>
 #include <stdlib.h>
+#include <stdbool.h>
 #include <string.h>
 #include <sys/types.h>
 #include <sys/stat.h>
diff --git a/tools/perf/perf.c b/tools/perf/perf.c
index 1f51e8de6b1b..8ad01a78fdd5 100644
--- a/tools/perf/perf.c
+++ b/tools/perf/perf.c
@@ -10,13 +10,13 @@
 #include "perf.h"
 
 #include "util/build-id.h"
-#include "util/cache.h"
 #include "util/env.h"
 #include <internal/lib.h> // page_size
 #include <subcmd/exec-cmd.h>
 #include "util/config.h"
 #include <subcmd/run-command.h>
 #include "util/parse-events.h"
+#include <subcmd/pager.h>
 #include <subcmd/parse-options.h>
 #include <subcmd/help.h>
 #include "util/debug.h"
@@ -30,7 +30,10 @@
 #include <errno.h>
 #include <pthread.h>
 #include <signal.h>
+#include <stdio.h>
 #include <stdlib.h>
+#include <string.h>
+#include <stdbool.h>
 #include <time.h>
 #include <sys/types.h>
 #include <sys/stat.h>
@@ -39,6 +42,12 @@
 #include <linux/string.h>
 #include <linux/zalloc.h>
 
+#define CMD_EXEC_PATH "--exec-path"
+#define CMD_DEBUGFS_DIR "--debugfs-dir="
+
+#define EXEC_PATH_ENVIRONMENT "PERF_EXEC_PATH"
+#define PERF_PAGER_ENVIRONMENT "PERF_PAGER"
+
 static int use_pager = -1;
 static FILE *debug_fp = NULL;
 
diff --git a/tools/perf/util/cache.h b/tools/perf/util/cache.h
deleted file mode 100644
index 0b61840d4226..000000000000
--- a/tools/perf/util/cache.h
+++ /dev/null
@@ -1,31 +0,0 @@
-/* SPDX-License-Identifier: GPL-2.0 */
-#ifndef __PERF_CACHE_H
-#define __PERF_CACHE_H
-
-#include "strbuf.h"
-#include <subcmd/pager.h>
-#include "../ui/ui.h"
-
-#include <linux/compiler.h>
-#include <linux/string.h>
-
-#define CMD_EXEC_PATH "--exec-path"
-#define CMD_DEBUGFS_DIR "--debugfs-dir="
-
-#define EXEC_PATH_ENVIRONMENT "PERF_EXEC_PATH"
-#define PERF_DEBUGFS_ENVIRONMENT "PERF_DEBUGFS_DIR"
-#define PERF_TRACEFS_ENVIRONMENT "PERF_TRACEFS_DIR"
-#define PERF_PAGER_ENVIRONMENT "PERF_PAGER"
-
-int split_cmdline(char *cmdline, const char ***argv);
-
-#define alloc_nr(x) (((x)+16)*3/2)
-
-static inline int is_absolute_path(const char *path)
-{
-	return path[0] == '/';
-}
-
-char *mkpath(char *path_buf, size_t sz, const char *fmt, ...) __printf(3, 4);
-
-#endif /* __PERF_CACHE_H */
diff --git a/tools/perf/util/config.c b/tools/perf/util/config.c
index 7988149dc7ed..5b696139f655 100644
--- a/tools/perf/util/config.c
+++ b/tools/perf/util/config.c
@@ -11,7 +11,6 @@
  */
 #include <errno.h>
 #include <sys/param.h>
-#include "cache.h"
 #include "callchain.h"
 #include "header.h"
 #include <subcmd/exec-cmd.h>
@@ -19,6 +18,7 @@
 #include "util/hist.h"  /* perf_hist_config */
 #include "util/stat.h"  /* perf_stat__set_big_num */
 #include "util/evsel.h"  /* evsel__hw_names, evsel__use_bpf_counters */
+#include "path.h"
 #include "srcline.h"
 #include "build-id.h"
 #include "debug.h"
@@ -26,7 +26,10 @@
 #include "unwind.h"
 #include <sys/types.h>
 #include <sys/stat.h>
+#include <stdio.h>
 #include <stdlib.h>
+#include <stdbool.h>
+#include <string.h>
 #include <unistd.h>
 #include <linux/string.h>
 #include <linux/zalloc.h>
diff --git a/tools/perf/util/help-unknown-cmd.c b/tools/perf/util/help-unknown-cmd.c
index a0a46e34f8d1..f1cd9d4746f3 100644
--- a/tools/perf/util/help-unknown-cmd.c
+++ b/tools/perf/util/help-unknown-cmd.c
@@ -1,9 +1,9 @@
 // SPDX-License-Identifier: GPL-2.0
-#include "cache.h"
 #include "config.h"
 #include <poll.h>
 #include <stdio.h>
 #include <stdlib.h>
+#include <string.h>
 #include <subcmd/help.h>
 #include "../builtin.h"
 #include "levenshtein.h"
@@ -36,10 +36,14 @@ static int add_cmd_list(struct cmdnames *cmds, struct cmdnames *old)
 
 	if (nr > cmds->alloc) {
 		/* Choose bigger one to alloc */
+#define alloc_nr(x) (((x) + 16) * 3 / 2)
+
 		if (alloc_nr(cmds->alloc) < nr)
 			cmds->alloc = nr;
 		else
 			cmds->alloc = alloc_nr(cmds->alloc);
+
+#undef alloc_nr
 		tmp = realloc(cmds->names, cmds->alloc * sizeof(*cmds->names));
 		if (!tmp)
 			return -1;
diff --git a/tools/perf/util/path.c b/tools/perf/util/path.c
index 2e62f272fda8..5ba7861a3e65 100644
--- a/tools/perf/util/path.c
+++ b/tools/perf/util/path.c
@@ -1,8 +1,8 @@
 // SPDX-License-Identifier: GPL-2.0
 #include "path.h"
-#include "cache.h"
 #include <linux/kernel.h>
 #include <limits.h>
+#include <stdarg.h>
 #include <stdio.h>
 #include <string.h>
 #include <sys/types.h>
diff --git a/tools/perf/util/path.h b/tools/perf/util/path.h
index fb850fb55c60..e7cdb0cb1097 100644
--- a/tools/perf/util/path.h
+++ b/tools/perf/util/path.h
@@ -4,9 +4,12 @@
 
 #include <stddef.h>
 #include <stdbool.h>
+#include <linux/compiler.h>
 
 struct dirent;
 
+char *mkpath(char *path_buf, size_t sz, const char *fmt, ...) __printf(3, 4);
+
 int path__join(char *bf, size_t size, const char *path1, const char *path2);
 int path__join3(char *bf, size_t size, const char *path1, const char *path2, const char *path3);
 
diff --git a/tools/perf/util/strbuf.c b/tools/perf/util/strbuf.c
index a64a37628f12..df3f9c4123fd 100644
--- a/tools/perf/util/strbuf.c
+++ b/tools/perf/util/strbuf.c
@@ -1,5 +1,4 @@
 // SPDX-License-Identifier: GPL-2.0
-#include "cache.h"
 #include "debug.h"
 #include "strbuf.h"
 #include <linux/kernel.h>
@@ -8,6 +7,7 @@
 #include <errno.h>
 #include <stdio.h>
 #include <stdlib.h>
+#include <string.h>
 #include <unistd.h>
 
 /*
@@ -54,9 +54,12 @@ int strbuf_grow(struct strbuf *sb, size_t extra)
 	if (nr <= sb->len)
 		return -E2BIG;
 
+#define alloc_nr(x) (((x) + 16) * 3 / 2)
+
 	if (alloc_nr(sb->alloc) > nr)
 		nr = alloc_nr(sb->alloc);
 
+#undef alloc_nr
 	/*
 	 * Note that sb->buf == strbuf_slopbuf if sb->alloc == 0, and it is
 	 * a static variable. Thus we have to avoid passing it to realloc.
-- 
2.55.0.966.g6673acef38-goog


^ permalink raw reply related	[flat|nested] 14+ messages in thread

* [PATCH v3 2/6] perf tool: Tidy up util/cache.h header file users
  2026-09-02 15:48 [PATCH v3 0/6] perf tool: Build dependency tidy up Ian Rogers
  2026-09-02 15:48 ` [PATCH v3 1/6] perf tool: Remove util/cache.h Ian Rogers
@ 2026-09-02 15:48 ` Ian Rogers
  2026-09-02 16:01   ` sashiko-bot
  2026-09-02 15:48 ` [PATCH v3 3/6] perf tool: Remove unused includes in perf.c Ian Rogers
                   ` (3 subsequent siblings)
  5 siblings, 1 reply; 14+ messages in thread
From: Ian Rogers @ 2026-09-02 15:48 UTC (permalink / raw)
  To: Peter Zijlstra, Ingo Molnar, Arnaldo Carvalho de Melo,
	Namhyung Kim, Jiri Olsa, Ian Rogers, Adrian Hunter, James Clark,
	Tianyou Li, Jiebin Sun, Dapeng Mi, Eric Biggers, Thomas Richter,
	Stephen Brennan, Swapnil Sapkal, linux-kernel, linux-perf-users

Use git clang-format to sort header files. Review header file includes
removing those that were unnecessary or adding explicit includes in
cases where transitive dependencies were be using.

Signed-off-by: Ian Rogers <irogers@google.com>
Assisted-by: Antigravity:gemini-3.1-pro
---
 tools/perf/builtin-annotate.c      | 53 ++++++++++++++----------------
 tools/perf/builtin-config.c        | 18 +++++-----
 tools/perf/builtin-help.c          | 31 ++++++++---------
 tools/perf/perf.c                  | 45 +++++++++++--------------
 tools/perf/util/config.c           | 39 ++++++++++++----------
 tools/perf/util/help-unknown-cmd.c |  9 +++--
 tools/perf/util/path.c             |  8 ++---
 tools/perf/util/path.h             |  3 +-
 tools/perf/util/strbuf.c           |  9 ++---
 9 files changed, 109 insertions(+), 106 deletions(-)

diff --git a/tools/perf/builtin-annotate.c b/tools/perf/builtin-annotate.c
index 75cbea567196..f208ff513238 100644
--- a/tools/perf/builtin-annotate.c
+++ b/tools/perf/builtin-annotate.c
@@ -6,48 +6,45 @@
  * look up and read DSOs and symbol information and display
  * a histogram of results, along various sorting keys.
  */
-#include "builtin.h"
-#include "perf.h"
+#include <errno.h>
+#include <inttypes.h>
 #include <stdbool.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
 
-#include "util/color.h"
+#include <dlfcn.h>
+#include <linux/bitmap.h>
+#include <linux/err.h>
 #include <linux/list.h>
 #include <linux/rbtree.h>
-#include "util/symbol.h"
 
-#include "util/debug.h"
+#include <subcmd/parse-options.h>
 
-#include "util/evlist.h"
-#include "util/evsel.h"
-#include "util/annotate.h"
+#include "arch/common.h"
+#include "builtin.h"
+#include "perf.h"
+#include "ui/progress.h"
+#include "ui/ui.h"
 #include "util/annotate-data.h"
+#include "util/annotate.h"
+#include "util/block-range.h"
+#include "util/branch.h"
+#include "util/data.h"
+#include "util/debug.h"
+#include "util/dso.h"
 #include "util/event.h"
-#include <subcmd/parse-options.h>
-#include "util/parse-events.h"
-#include "util/sort.h"
+#include "util/evlist.h"
+#include "util/evsel.h"
 #include "util/hist.h"
-#include "util/dso.h"
 #include "util/machine.h"
 #include "util/map.h"
+#include "util/map_symbol.h"
 #include "util/session.h"
+#include "util/sort.h"
+#include "util/symbol.h"
 #include "util/tool.h"
-#include "util/data.h"
-#include "arch/common.h"
-#include "util/block-range.h"
-#include "util/map_symbol.h"
-#include "util/branch.h"
 #include "util/util.h"
-#include "ui/progress.h"
-#include "ui/ui.h"
-
-#include <dlfcn.h>
-#include <errno.h>
-#include <linux/bitmap.h>
-#include <linux/err.h>
-#include <inttypes.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
 
 struct perf_annotate {
 	struct perf_tool tool;
diff --git a/tools/perf/builtin-config.c b/tools/perf/builtin-config.c
index 845a8af67fc5..cefd042e4f85 100644
--- a/tools/perf/builtin-config.c
+++ b/tools/perf/builtin-config.c
@@ -5,19 +5,21 @@
  * Copyright (C) 2015, Taeung Song <treeze.taeung@gmail.com>
  *
  */
-#include "builtin.h"
-
-#include <subcmd/parse-options.h>
-#include "util/debug.h"
-#include "util/config.h"
-#include "util/path.h"
-#include <linux/string.h>
 #include <limits.h>
+#include <stdbool.h>
 #include <stdio.h>
 #include <stdlib.h>
-#include <stdbool.h>
 #include <string.h>
 
+#include <linux/string.h>
+
+#include <subcmd/parse-options.h>
+
+#include "builtin.h"
+#include "util/config.h"
+#include "util/debug.h"
+#include "util/path.h"
+
 static bool use_system_config, use_user_config;
 
 static const char * const config_usage[] = {
diff --git a/tools/perf/builtin-help.c b/tools/perf/builtin-help.c
index f0e95d741892..5bbdb4d9b9c0 100644
--- a/tools/perf/builtin-help.c
+++ b/tools/perf/builtin-help.c
@@ -4,29 +4,30 @@
  *
  * Builtin help command
  */
-#include "util/config.h"
-#include "util/path.h"
-#include "util/strbuf.h"
-#include "builtin.h"
-#include <subcmd/exec-cmd.h>
-#include <subcmd/parse-options.h>
-#include <subcmd/run-command.h>
-#include <subcmd/help.h>
-#include "util/debug.h"
-#include "util/util.h"
-#include <linux/kernel.h>
-#include <linux/string.h>
-#include <linux/zalloc.h>
 #include <errno.h>
 #include <limits.h>
+#include <stdbool.h>
 #include <stdio.h>
 #include <stdlib.h>
-#include <stdbool.h>
 #include <string.h>
-#include <sys/types.h>
+
+#include <linux/string.h>
+#include <linux/zalloc.h>
 #include <sys/stat.h>
 #include <unistd.h>
 
+#include <subcmd/exec-cmd.h>
+#include <subcmd/help.h>
+#include <subcmd/parse-options.h>
+#include <subcmd/run-command.h>
+
+#include "builtin.h"
+#include "util/config.h"
+#include "util/debug.h"
+#include "util/path.h"
+#include "util/strbuf.h"
+#include "util/util.h"
+
 static struct man_viewer_list {
 	struct man_viewer_list *next;
 	char name[0];
diff --git a/tools/perf/perf.c b/tools/perf/perf.c
index 8ad01a78fdd5..53c50cfd92d6 100644
--- a/tools/perf/perf.c
+++ b/tools/perf/perf.c
@@ -6,41 +6,36 @@
  * This is the main hub from which the sub-commands (perf stat,
  * perf top, perf record, perf report, etc.) are started.
  */
-#include "builtin.h"
 #include "perf.h"
 
-#include "util/build-id.h"
-#include "util/env.h"
-#include <internal/lib.h> // page_size
-#include <subcmd/exec-cmd.h>
-#include "util/config.h"
-#include <subcmd/run-command.h>
-#include "util/parse-events.h"
-#include <subcmd/pager.h>
-#include <subcmd/parse-options.h>
-#include <subcmd/help.h>
-#include "util/debug.h"
-#include "util/event.h"
-#include "util/util.h" // usage()
-#include "ui/ui.h"
-#include "perf-sys.h"
-#include <api/fs/fs.h>
-#include <api/fs/tracing_path.h>
-#include <perf/core.h>
 #include <errno.h>
-#include <pthread.h>
 #include <signal.h>
+#include <stdbool.h>
 #include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
-#include <stdbool.h>
 #include <time.h>
-#include <sys/types.h>
-#include <sys/stat.h>
-#include <unistd.h>
-#include <linux/kernel.h>
+
 #include <linux/string.h>
 #include <linux/zalloc.h>
+#include <sys/stat.h>
+
+#include <api/fs/tracing_path.h>
+#include <internal/lib.h> // page_size
+#include <perf/core.h>
+#include <subcmd/exec-cmd.h>
+#include <subcmd/help.h>
+#include <subcmd/pager.h>
+#include <subcmd/parse-options.h>
+#include <subcmd/run-command.h>
+
+#include "builtin.h"
+#include "perf-sys.h"
+#include "ui/ui.h"
+#include "util/build-id.h"
+#include "util/config.h"
+#include "util/debug.h"
+#include "util/util.h" // usage()
 
 #define CMD_EXEC_PATH "--exec-path"
 #define CMD_DEBUGFS_DIR "--debugfs-dir="
diff --git a/tools/perf/util/config.c b/tools/perf/util/config.c
index 5b696139f655..b2972c35c1ec 100644
--- a/tools/perf/util/config.c
+++ b/tools/perf/util/config.c
@@ -9,31 +9,34 @@
  * Copyright (C) Johannes Schindelin, 2005
  *
  */
+#include "config.h"
+
 #include <errno.h>
+#include <stdbool.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+
+#include <linux/ctype.h>
+#include <linux/string.h>
+#include <linux/zalloc.h>
 #include <sys/param.h>
+#include <sys/stat.h>
+#include <unistd.h>
+
+#include <subcmd/exec-cmd.h>
+
+#include "build-id.h"
 #include "callchain.h"
+#include "debug.h"
 #include "header.h"
-#include <subcmd/exec-cmd.h>
-#include "util/event.h"  /* proc_map_timeout */
-#include "util/hist.h"  /* perf_hist_config */
-#include "util/stat.h"  /* perf_stat__set_big_num */
-#include "util/evsel.h"  /* evsel__hw_names, evsel__use_bpf_counters */
 #include "path.h"
 #include "srcline.h"
-#include "build-id.h"
-#include "debug.h"
-#include "config.h"
 #include "unwind.h"
-#include <sys/types.h>
-#include <sys/stat.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <stdbool.h>
-#include <string.h>
-#include <unistd.h>
-#include <linux/string.h>
-#include <linux/zalloc.h>
-#include <linux/ctype.h>
+#include "util/event.h" /* proc_map_timeout */
+#include "util/evsel.h" /* evsel__hw_names, evsel__use_bpf_counters */
+#include "util/hist.h" /* perf_hist_config */
+#include "util/stat.h" /* perf_stat__set_big_num */
 
 #define MAXNAME (256)
 
diff --git a/tools/perf/util/help-unknown-cmd.c b/tools/perf/util/help-unknown-cmd.c
index f1cd9d4746f3..64dbe6e514f5 100644
--- a/tools/perf/util/help-unknown-cmd.c
+++ b/tools/perf/util/help-unknown-cmd.c
@@ -1,13 +1,16 @@
 // SPDX-License-Identifier: GPL-2.0
-#include "config.h"
-#include <poll.h>
 #include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
+
+#include <linux/zalloc.h>
+#include <poll.h>
+
 #include <subcmd/help.h>
+
 #include "../builtin.h"
+#include "config.h"
 #include "levenshtein.h"
-#include <linux/zalloc.h>
 
 static int autocorrect;
 
diff --git a/tools/perf/util/path.c b/tools/perf/util/path.c
index 5ba7861a3e65..b7592e16718d 100644
--- a/tools/perf/util/path.c
+++ b/tools/perf/util/path.c
@@ -1,14 +1,14 @@
 // SPDX-License-Identifier: GPL-2.0
 #include "path.h"
-#include <linux/kernel.h>
+
 #include <limits.h>
 #include <stdarg.h>
 #include <stdio.h>
 #include <string.h>
-#include <sys/types.h>
-#include <sys/stat.h>
+
 #include <dirent.h>
-#include <unistd.h>
+#include <linux/kernel.h>
+#include <sys/stat.h>
 
 static char *cleanup_path(char *path)
 {
diff --git a/tools/perf/util/path.h b/tools/perf/util/path.h
index e7cdb0cb1097..62e86d390589 100644
--- a/tools/perf/util/path.h
+++ b/tools/perf/util/path.h
@@ -2,8 +2,9 @@
 #ifndef _PERF_PATH_H
 #define _PERF_PATH_H
 
-#include <stddef.h>
 #include <stdbool.h>
+#include <stddef.h>
+
 #include <linux/compiler.h>
 
 struct dirent;
diff --git a/tools/perf/util/strbuf.c b/tools/perf/util/strbuf.c
index df3f9c4123fd..4080bc02a533 100644
--- a/tools/perf/util/strbuf.c
+++ b/tools/perf/util/strbuf.c
@@ -1,15 +1,16 @@
 // SPDX-License-Identifier: GPL-2.0
-#include "debug.h"
 #include "strbuf.h"
-#include <linux/kernel.h>
-#include <linux/string.h>
-#include <linux/zalloc.h>
+
 #include <errno.h>
 #include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
+
+#include <linux/zalloc.h>
 #include <unistd.h>
 
+#include "debug.h"
+
 /*
  * Used as the default ->buf value, so that people can always assume
  * buf is non NULL and ->buf is NUL terminated even for a freshly
-- 
2.55.0.966.g6673acef38-goog


^ permalink raw reply related	[flat|nested] 14+ messages in thread

* [PATCH v3 3/6] perf tool: Remove unused includes in perf.c
  2026-09-02 15:48 [PATCH v3 0/6] perf tool: Build dependency tidy up Ian Rogers
  2026-09-02 15:48 ` [PATCH v3 1/6] perf tool: Remove util/cache.h Ian Rogers
  2026-09-02 15:48 ` [PATCH v3 2/6] perf tool: Tidy up util/cache.h header file users Ian Rogers
@ 2026-09-02 15:48 ` Ian Rogers
  2026-09-02 15:57   ` sashiko-bot
  2026-09-02 15:48 ` [PATCH v3 4/6] perf tool: Move usage strings and functions to perf.c Ian Rogers
                   ` (2 subsequent siblings)
  5 siblings, 1 reply; 14+ messages in thread
From: Ian Rogers @ 2026-09-02 15:48 UTC (permalink / raw)
  To: Peter Zijlstra, Ingo Molnar, Arnaldo Carvalho de Melo,
	Namhyung Kim, Jiri Olsa, Ian Rogers, Adrian Hunter, James Clark,
	Tianyou Li, Jiebin Sun, Dapeng Mi, Eric Biggers, Thomas Richter,
	Stephen Brennan, Swapnil Sapkal, linux-kernel, linux-perf-users

Remove perf-sys.h, internal/lib.h (page_size), signal.h, and perf.h
since their exports are not used directly in perf.c.

Signed-off-by: Ian Rogers <irogers@google.com>
Assisted-by: Antigravity:gemini-3.1-pro
---
 tools/perf/perf.c | 4 ----
 1 file changed, 4 deletions(-)

diff --git a/tools/perf/perf.c b/tools/perf/perf.c
index 53c50cfd92d6..7e2e667b011f 100644
--- a/tools/perf/perf.c
+++ b/tools/perf/perf.c
@@ -6,10 +6,8 @@
  * This is the main hub from which the sub-commands (perf stat,
  * perf top, perf record, perf report, etc.) are started.
  */
-#include "perf.h"
 
 #include <errno.h>
-#include <signal.h>
 #include <stdbool.h>
 #include <stdio.h>
 #include <stdlib.h>
@@ -21,7 +19,6 @@
 #include <sys/stat.h>
 
 #include <api/fs/tracing_path.h>
-#include <internal/lib.h> // page_size
 #include <perf/core.h>
 #include <subcmd/exec-cmd.h>
 #include <subcmd/help.h>
@@ -30,7 +27,6 @@
 #include <subcmd/run-command.h>
 
 #include "builtin.h"
-#include "perf-sys.h"
 #include "ui/ui.h"
 #include "util/build-id.h"
 #include "util/config.h"
-- 
2.55.0.966.g6673acef38-goog


^ permalink raw reply related	[flat|nested] 14+ messages in thread

* [PATCH v3 4/6] perf tool: Move usage strings and functions to perf.c
  2026-09-02 15:48 [PATCH v3 0/6] perf tool: Build dependency tidy up Ian Rogers
                   ` (2 preceding siblings ...)
  2026-09-02 15:48 ` [PATCH v3 3/6] perf tool: Remove unused includes in perf.c Ian Rogers
@ 2026-09-02 15:48 ` Ian Rogers
  2026-09-02 15:56   ` sashiko-bot
  2026-09-02 15:48 ` [PATCH v3 5/6] perf tool: Add fallback stubs for missing dependencies Ian Rogers
  2026-09-02 15:48 ` [PATCH v3 6/6] perf hist: Remove keysym.h include from hist.h Ian Rogers
  5 siblings, 1 reply; 14+ messages in thread
From: Ian Rogers @ 2026-09-02 15:48 UTC (permalink / raw)
  To: Peter Zijlstra, Ingo Molnar, Arnaldo Carvalho de Melo,
	Namhyung Kim, Jiri Olsa, Ian Rogers, Adrian Hunter, James Clark,
	Tianyou Li, Jiebin Sun, Dapeng Mi, Eric Biggers, Thomas Richter,
	Stephen Brennan, Swapnil Sapkal, linux-kernel, linux-perf-users

The code is mostly used by perf.c with additional unused functionality
such as function pointers derived from early git code. Moving it into
perf.c directly reduces the code footprint, drops the util/util.h
dependence from perf.c, and allows us to remove util/usage.c entirely.

The string constants are exposed in builtin.h, as they are used
in builtin-help.c.

Signed-off-by: Ian Rogers <irogers@google.com>
Assisted-by: Antigravity:gemini-3.1-pro
---
 tools/perf/builtin.h    |  3 +++
 tools/perf/perf.c       | 13 ++++++++++++-
 tools/perf/util/Build   |  1 -
 tools/perf/util/usage.c | 34 ----------------------------------
 tools/perf/util/util.h  |  4 ----
 5 files changed, 15 insertions(+), 40 deletions(-)
 delete mode 100644 tools/perf/util/usage.c

diff --git a/tools/perf/builtin.h b/tools/perf/builtin.h
index 40c4078c295f..e0b430821abc 100644
--- a/tools/perf/builtin.h
+++ b/tools/perf/builtin.h
@@ -2,6 +2,9 @@
 #ifndef BUILTIN_H
 #define BUILTIN_H
 
+extern const char perf_usage_string[];
+extern const char perf_more_info_string[];
+
 struct feature_status {
 	const char *name;
 	const char *macro;
diff --git a/tools/perf/perf.c b/tools/perf/perf.c
index 7e2e667b011f..65bdfd71f626 100644
--- a/tools/perf/perf.c
+++ b/tools/perf/perf.c
@@ -31,7 +31,18 @@
 #include "util/build-id.h"
 #include "util/config.h"
 #include "util/debug.h"
-#include "util/util.h" // usage()
+
+const char perf_usage_string[] =
+	"perf [--version] [--help] [OPTIONS] COMMAND [ARGS]";
+
+const char perf_more_info_string[] =
+	"See 'perf help COMMAND' for more information on a specific command.";
+
+static void __noreturn usage(const char *err)
+{
+	fprintf(stderr, "\n Usage: %s\n", err);
+	exit(129);
+}
 
 #define CMD_EXEC_PATH "--exec-path"
 #define CMD_DEBUGFS_DIR "--debugfs-dir="
diff --git a/tools/perf/util/Build b/tools/perf/util/Build
index b26a0b1ddfa3..d08f2af7d970 100644
--- a/tools/perf/util/Build
+++ b/tools/perf/util/Build
@@ -54,7 +54,6 @@ perf-util-y += string.o
 perf-util-y += strlist.o
 perf-util-y += strfilter.o
 perf-util-y += top.o
-perf-util-y += usage.o
 perf-util-y += dso.o
 perf-util-y += dsos.o
 perf-util-y += symbol.o
diff --git a/tools/perf/util/usage.c b/tools/perf/util/usage.c
deleted file mode 100644
index 4c8ffbad2323..000000000000
--- a/tools/perf/util/usage.c
+++ /dev/null
@@ -1,34 +0,0 @@
-// SPDX-License-Identifier: GPL-2.0
-/*
- * usage.c
- *
- * Various reporting routines.
- * Originally copied from GIT source.
- *
- * Copyright (C) Linus Torvalds, 2005
- */
-#include "util.h"
-#include <stdio.h>
-#include <stdlib.h>
-#include <linux/compiler.h>
-
-const char perf_usage_string[] =
-	"perf [--version] [--help] [OPTIONS] COMMAND [ARGS]";
-
-const char perf_more_info_string[] =
-	"See 'perf help COMMAND' for more information on a specific command.";
-
-static __noreturn void usage_builtin(const char *err)
-{
-	fprintf(stderr, "\n Usage: %s\n", err);
-	exit(129);
-}
-
-/* If we are in a dlopen()ed .so write to a global variable would segfault
- * (ugh), so keep things static. */
-static void (*usage_routine)(const char *err) __noreturn = usage_builtin;
-
-void usage(const char *err)
-{
-	usage_routine(err);
-}
diff --git a/tools/perf/util/util.h b/tools/perf/util/util.h
index 87a0818a8c76..f8f1ff603c72 100644
--- a/tools/perf/util/util.h
+++ b/tools/perf/util/util.h
@@ -17,9 +17,6 @@
 #include <internal/cpumap.h>
 #endif
 
-extern const char perf_usage_string[];
-extern const char perf_more_info_string[];
-
 extern const char *input_name;
 
 /* This will control if perf_{host,guest} will set attr.exclude_{host,guest}. */
@@ -29,7 +26,6 @@ extern bool perf_host;
 extern bool perf_guest;
 
 /* General helper functions */
-void usage(const char *err) __noreturn;
 
 struct dirent;
 struct strlist;
-- 
2.55.0.966.g6673acef38-goog


^ permalink raw reply related	[flat|nested] 14+ messages in thread

* [PATCH v3 5/6] perf tool: Add fallback stubs for missing dependencies
  2026-09-02 15:48 [PATCH v3 0/6] perf tool: Build dependency tidy up Ian Rogers
                   ` (3 preceding siblings ...)
  2026-09-02 15:48 ` [PATCH v3 4/6] perf tool: Move usage strings and functions to perf.c Ian Rogers
@ 2026-09-02 15:48 ` Ian Rogers
  2026-09-02 15:58   ` sashiko-bot
  2026-09-02 15:48 ` [PATCH v3 6/6] perf hist: Remove keysym.h include from hist.h Ian Rogers
  5 siblings, 1 reply; 14+ messages in thread
From: Ian Rogers @ 2026-09-02 15:48 UTC (permalink / raw)
  To: Peter Zijlstra, Ingo Molnar, Arnaldo Carvalho de Melo,
	Namhyung Kim, Jiri Olsa, Ian Rogers, Adrian Hunter, James Clark,
	Tianyou Li, Jiebin Sun, Dapeng Mi, Eric Biggers, Thomas Richter,
	Stephen Brennan, Swapnil Sapkal, linux-kernel, linux-perf-users

Declare stubs directly inside perf.c for commands that have library
dependencies sometimes omitted at build time, such as libtraceevent
(timechart, sched, kmem, lock, trace, kwork) and libelf (probe).

By unconditionally including these commands in the commands[] array,
users will receive a clear, unified warning indicating the missing
dependency instead of the command silently being absent.

Running `perf trace` with libtraceevent missing. Before:
```
perf: 'trace' is not a perf-command. See 'perf --help'.

Did you mean this?
        ftrace
```

After:
```
'trace' command not available: missing libtraceevent devel package at build time.
```

Signed-off-by: Ian Rogers <irogers@google.com>
Assisted-by: Antigravity:gemini-3.1-pro
---
 tools/perf/perf.c | 51 ++++++++++++++++++++++++++++++-----------------
 1 file changed, 33 insertions(+), 18 deletions(-)

diff --git a/tools/perf/perf.c b/tools/perf/perf.c
index 65bdfd71f626..6c5baa285b13 100644
--- a/tools/perf/perf.c
+++ b/tools/perf/perf.c
@@ -7,6 +7,7 @@
  * perf top, perf record, perf report, etc.) are started.
  */
 
+#include <linux/compiler.h>
 #include <errno.h>
 #include <stdbool.h>
 #include <stdio.h>
@@ -53,6 +54,38 @@ static void __noreturn usage(const char *err)
 static int use_pager = -1;
 static FILE *debug_fp = NULL;
 
+
+#ifndef HAVE_LIBTRACEEVENT
+#define DECLARE_LIBTRACEEVENT_STUB(_cmd) \
+	int cmd_##_cmd(int argc __always_unused, const char **argv __always_unused) \
+	{ \
+		fprintf(stderr, \
+			"'" #_cmd "' command not available: missing libtraceevent " \
+			"devel package at build time.\n"); \
+		return -1; \
+	}
+
+DECLARE_LIBTRACEEVENT_STUB(timechart)
+DECLARE_LIBTRACEEVENT_STUB(sched)
+DECLARE_LIBTRACEEVENT_STUB(kmem)
+DECLARE_LIBTRACEEVENT_STUB(lock)
+DECLARE_LIBTRACEEVENT_STUB(trace)
+DECLARE_LIBTRACEEVENT_STUB(kwork)
+#endif
+
+#ifndef HAVE_LIBELF_SUPPORT
+#define DECLARE_LIBELF_SUPPORT_STUB(_cmd) \
+	int cmd_##_cmd(int argc __always_unused, const char **argv __always_unused) \
+	{ \
+		fprintf(stderr, \
+			"'" #_cmd "' command not available: missing libelf " \
+			"devel package at build time.\n"); \
+		return -1; \
+	}
+
+DECLARE_LIBELF_SUPPORT_STUB(probe)
+#endif
+
 struct cmd_struct {
 	const char *cmd;
 	int (*fn)(int, const char **);
@@ -76,36 +109,24 @@ static const struct cmd_struct commands[] = {
 	{ "report",	cmd_report,	0 },
 	{ "bench",	cmd_bench,	0 },
 	{ "stat",	cmd_stat,	0 },
-#ifdef HAVE_LIBTRACEEVENT
 	{ "timechart",	cmd_timechart,	0 },
-#endif
 	{ "top",	cmd_top,	0 },
 	{ "annotate",	cmd_annotate,	0 },
 	{ "version",	cmd_version,	0 },
 	{ "script",	cmd_script,	0 },
-#ifdef HAVE_LIBTRACEEVENT
 	{ "sched",	cmd_sched,	0 },
-#endif
-#ifdef HAVE_LIBELF_SUPPORT
 	{ "probe",	cmd_probe,	0 },
-#endif
-#ifdef HAVE_LIBTRACEEVENT
 	{ "kmem",	cmd_kmem,	0 },
 	{ "lock",	cmd_lock,	0 },
-#endif
 	{ "kvm",	cmd_kvm,	0 },
 	{ "test",	cmd_test,	0 },
-#if defined(HAVE_LIBTRACEEVENT)
 	{ "trace",	cmd_trace,	0 },
-#endif
 	{ "inject",	cmd_inject,	0 },
 	{ "mem",	cmd_mem,	0 },
 	{ "data",	cmd_data,	0 },
 	{ "ftrace",	cmd_ftrace,	0 },
 	{ "daemon",	cmd_daemon,	0 },
-#ifdef HAVE_LIBTRACEEVENT
 	{ "kwork",	cmd_kwork,	0 },
-#endif
 };
 
 struct pager_config {
@@ -514,15 +535,9 @@ int main(int argc, const char **argv)
 		argv[0] = cmd;
 	}
 	if (strstarts(cmd, "trace")) {
-#ifndef HAVE_LIBTRACEEVENT
-		fprintf(stderr,
-			"trace command not available: missing libtraceevent devel package at build time.\n");
-		goto out;
-#else
 		setup_path();
 		argv[0] = "trace";
 		return cmd_trace(argc, argv);
-#endif
 	}
 	/* Look for flags.. */
 	argv++;
-- 
2.55.0.966.g6673acef38-goog


^ permalink raw reply related	[flat|nested] 14+ messages in thread

* [PATCH v3 6/6] perf hist: Remove keysym.h include from hist.h
  2026-09-02 15:48 [PATCH v3 0/6] perf tool: Build dependency tidy up Ian Rogers
                   ` (4 preceding siblings ...)
  2026-09-02 15:48 ` [PATCH v3 5/6] perf tool: Add fallback stubs for missing dependencies Ian Rogers
@ 2026-09-02 15:48 ` Ian Rogers
  2026-09-02 16:07   ` sashiko-bot
  5 siblings, 1 reply; 14+ messages in thread
From: Ian Rogers @ 2026-09-02 15:48 UTC (permalink / raw)
  To: Peter Zijlstra, Ingo Molnar, Arnaldo Carvalho de Melo,
	Namhyung Kim, Jiri Olsa, Ian Rogers, Adrian Hunter, James Clark,
	Tianyou Li, Jiebin Sun, Dapeng Mi, Eric Biggers, Thomas Richter,
	Stephen Brennan, Swapnil Sapkal, linux-kernel, linux-perf-users

hist.h isn't related to UI and so remove the UI inclusion. Fix the
transitive dependency issues this exposes.

Signed-off-by: Ian Rogers <irogers@google.com>
---
 tools/perf/builtin-annotate.c     | 8 ++++++++
 tools/perf/builtin-c2c.c          | 1 +
 tools/perf/builtin-kvm.c          | 1 +
 tools/perf/builtin-report.c       | 1 +
 tools/perf/builtin-top.c          | 1 +
 tools/perf/ui/browsers/annotate.c | 1 +
 tools/perf/ui/browsers/hists.c    | 1 +
 tools/perf/ui/browsers/scripts.c  | 1 +
 tools/perf/ui/libslang.h          | 2 ++
 tools/perf/util/hist.h            | 6 ------
 10 files changed, 17 insertions(+), 6 deletions(-)

diff --git a/tools/perf/builtin-annotate.c b/tools/perf/builtin-annotate.c
index f208ff513238..a4c014a1d28f 100644
--- a/tools/perf/builtin-annotate.c
+++ b/tools/perf/builtin-annotate.c
@@ -24,6 +24,7 @@
 #include "arch/common.h"
 #include "builtin.h"
 #include "perf.h"
+#include "ui/keysyms.h"
 #include "ui/progress.h"
 #include "ui/ui.h"
 #include "util/annotate-data.h"
@@ -46,6 +47,13 @@
 #include "util/tool.h"
 #include "util/util.h"
 
+#ifndef HAVE_SLANG_SUPPORT
+#undef K_LEFT
+#define K_LEFT  -1000
+#undef K_RIGHT
+#define K_RIGHT -2000
+#endif
+
 struct perf_annotate {
 	struct perf_tool tool;
 	struct perf_session *session;
diff --git a/tools/perf/builtin-c2c.c b/tools/perf/builtin-c2c.c
index 715b75d42f2a..6b64c0d6b24f 100644
--- a/tools/perf/builtin-c2c.c
+++ b/tools/perf/builtin-c2c.c
@@ -49,6 +49,7 @@
 #include "thread.h"
 #include "tool.h"
 #include "ui/browsers/hists.h"
+#include "ui/keysyms.h"
 #include "ui/progress.h"
 #include "ui/ui.h"
 #include "util/annotate.h"
diff --git a/tools/perf/builtin-kvm.c b/tools/perf/builtin-kvm.c
index b9f6cb71c0a0..c5e82c078848 100644
--- a/tools/perf/builtin-kvm.c
+++ b/tools/perf/builtin-kvm.c
@@ -27,6 +27,7 @@
 #include "util/kvm-stat.h"
 #include "util/util.h"
 #include "ui/browsers/hists.h"
+#include "ui/keysyms.h"
 #include "ui/progress.h"
 #include "ui/ui.h"
 #include "util/string2.h"
diff --git a/tools/perf/builtin-report.c b/tools/perf/builtin-report.c
index 60d1f166629e..6f4ad5fa536d 100644
--- a/tools/perf/builtin-report.c
+++ b/tools/perf/builtin-report.c
@@ -51,6 +51,7 @@
 #include "util/units.h"
 #include "util/unwind.h"
 #include "util/util.h" // perf_tip()
+#include "ui/keysyms.h"
 #include "ui/ui.h"
 #include "ui/progress.h"
 #include "util/block-info.h"
diff --git a/tools/perf/builtin-top.c b/tools/perf/builtin-top.c
index 570410599f1b..44ba67e53cf1 100644
--- a/tools/perf/builtin-top.c
+++ b/tools/perf/builtin-top.c
@@ -51,6 +51,7 @@
 #include "util/intlist.h"
 #include "util/parse-branch-options.h"
 #include "arch/common.h"
+#include "ui/keysyms.h"
 #include "ui/ui.h"
 
 #include "util/debug.h"
diff --git a/tools/perf/ui/browsers/annotate.c b/tools/perf/ui/browsers/annotate.c
index e47a46775089..61ffdc52933d 100644
--- a/tools/perf/ui/browsers/annotate.c
+++ b/tools/perf/ui/browsers/annotate.c
@@ -1,6 +1,7 @@
 // SPDX-License-Identifier: GPL-2.0
 #include "../browser.h"
 #include "../helpline.h"
+#include "../keysyms.h"
 #include "../ui.h"
 #include "../../util/annotate.h"
 #include "../../util/debug.h"
diff --git a/tools/perf/ui/browsers/hists.c b/tools/perf/ui/browsers/hists.c
index c15874a491b4..f62cb2d534ed 100644
--- a/tools/perf/ui/browsers/hists.c
+++ b/tools/perf/ui/browsers/hists.c
@@ -35,6 +35,7 @@
 
 #include "../browsers/hists.h"
 #include "../helpline.h"
+#include "../keysyms.h"
 #include "../util.h"
 #include "../ui.h"
 #include "map.h"
diff --git a/tools/perf/ui/browsers/scripts.c b/tools/perf/ui/browsers/scripts.c
index 1e8c2c2f952d..94cc1f427c96 100644
--- a/tools/perf/ui/browsers/scripts.c
+++ b/tools/perf/ui/browsers/scripts.c
@@ -7,6 +7,7 @@
 #include "../../util/session.h"
 #include "../../util/symbol.h"
 #include "../browser.h"
+#include "../keysyms.h"
 #include "../libslang.h"
 #include "config.h"
 #include <linux/err.h>
diff --git a/tools/perf/ui/libslang.h b/tools/perf/ui/libslang.h
index 6722561e0458..dd6b9f192155 100644
--- a/tools/perf/ui/libslang.h
+++ b/tools/perf/ui/libslang.h
@@ -15,7 +15,9 @@
 #define ENABLE_SLFUTURE_CONST 1
 #define ENABLE_SLFUTURE_VOID 1
 
+#ifdef HAVE_SLANG_SUPPORT
 #include <slang.h>
+#endif
 
 #define SL_KEY_UNTAB 0x1000
 
diff --git a/tools/perf/util/hist.h b/tools/perf/util/hist.h
index b830cbe7f95b..b30375a203e7 100644
--- a/tools/perf/util/hist.h
+++ b/tools/perf/util/hist.h
@@ -714,7 +714,6 @@ struct block_hist {
 #define NO_ADDR 0
 
 #ifdef HAVE_SLANG_SUPPORT
-#include "../ui/keysyms.h"
 void attr_to_script(char *buf, struct perf_event_attr *attr);
 
 int __hist_entry__tui_annotate(struct hist_entry *he, struct map_symbol *ms,
@@ -787,11 +786,6 @@ static inline int block_hists_tui_browse(struct block_hist *bh __maybe_unused,
 {
 	return 0;
 }
-
-#define K_LEFT  -1000
-#define K_RIGHT -2000
-#define K_SWITCH_INPUT_DATA -3000
-#define K_RELOAD -4000
 #endif
 
 unsigned int hists__sort_list_width(struct hists *hists);
-- 
2.55.0.966.g6673acef38-goog


^ permalink raw reply related	[flat|nested] 14+ messages in thread

* Re: [PATCH v3 4/6] perf tool: Move usage strings and functions to perf.c
  2026-09-02 15:48 ` [PATCH v3 4/6] perf tool: Move usage strings and functions to perf.c Ian Rogers
@ 2026-09-02 15:56   ` sashiko-bot
  0 siblings, 0 replies; 14+ messages in thread
From: sashiko-bot @ 2026-09-02 15:56 UTC (permalink / raw)
  To: Ian Rogers; +Cc: linux-perf-users

> The code is mostly used by perf.c with additional unused functionality
> such as function pointers derived from early git code. Moving it into
> perf.c directly reduces the code footprint, drops the util/util.h
> dependence from perf.c, and allows us to remove util/usage.c entirely.
> 
> The string constants are exposed in builtin.h, as they are used
> in builtin-help.c.
> 
> Signed-off-by: Ian Rogers <irogers@google.com>

Sashiko has reviewed this patch and found no issues. It looks great!

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20260902154858.2078885-1-irogers@google.com?part=4


^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: [PATCH v3 3/6] perf tool: Remove unused includes in perf.c
  2026-09-02 15:48 ` [PATCH v3 3/6] perf tool: Remove unused includes in perf.c Ian Rogers
@ 2026-09-02 15:57   ` sashiko-bot
  0 siblings, 0 replies; 14+ messages in thread
From: sashiko-bot @ 2026-09-02 15:57 UTC (permalink / raw)
  To: Ian Rogers; +Cc: linux-perf-users

> Remove perf-sys.h, internal/lib.h (page_size), signal.h, and perf.h
> since their exports are not used directly in perf.c.
> 
> Signed-off-by: Ian Rogers <irogers@google.com>

Sashiko has reviewed this patch and found no issues. It looks great!

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20260902154858.2078885-1-irogers@google.com?part=3


^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: [PATCH v3 1/6] perf tool: Remove util/cache.h
  2026-09-02 15:48 ` [PATCH v3 1/6] perf tool: Remove util/cache.h Ian Rogers
@ 2026-09-02 15:57   ` sashiko-bot
  0 siblings, 0 replies; 14+ messages in thread
From: sashiko-bot @ 2026-09-02 15:57 UTC (permalink / raw)
  To: Ian Rogers; +Cc: linux-perf-users

> Move definitions to places they are used, or path.h in the case of
> path.c's mkpath function. Remove unused definitions. Fix transitive
> include dependencies.
> 
> Signed-off-by: Ian Rogers <irogers@google.com>

Sashiko has reviewed this patch and found no issues. It looks great!

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20260902154858.2078885-1-irogers@google.com?part=1


^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: [PATCH v3 5/6] perf tool: Add fallback stubs for missing dependencies
  2026-09-02 15:48 ` [PATCH v3 5/6] perf tool: Add fallback stubs for missing dependencies Ian Rogers
@ 2026-09-02 15:58   ` sashiko-bot
  2026-09-02 16:03     ` Ian Rogers
  0 siblings, 1 reply; 14+ messages in thread
From: sashiko-bot @ 2026-09-02 15:58 UTC (permalink / raw)
  To: Ian Rogers; +Cc: linux-perf-users

Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [Medium] Feature fallback stubs are generated in the C source file instead of providing dummy inline stubs in the header file.
--

commit f19b5b661c978968c83e8af505c2279ba5f83167
Author: Ian Rogers <irogers@google.com>

perf tool: Add fallback stubs for missing dependencies

This commit adds fallback stubs directly in perf.c for commands that have
optional library dependencies, such as libtraceevent and libelf. This ensures
a unified warning is shown when users try to run these commands, rather than
silently omitting them from the commands array.

> diff --git a/tools/perf/perf.c b/tools/perf/perf.c
> index 65bdfd71f6262..6c5baa285b13f 100644
> --- a/tools/perf/perf.c
> +++ b/tools/perf/perf.c
[ ... ]
> @@ -53,6 +54,38 @@ static void __noreturn usage(const char *err)
>  static int use_pager = -1;
>  static FILE *debug_fp = NULL;
>  
> +
> +#ifndef HAVE_LIBTRACEEVENT
> +#define DECLARE_LIBTRACEEVENT_STUB(_cmd) \
> +	int cmd_##_cmd(int argc __always_unused, const char **argv __always_unused) \
> +	{ \
> +		fprintf(stderr, \
> +			"'" #_cmd "' command not available: missing libtraceevent " \
> +			"devel package at build time.\n"); \
> +		return -1; \
> +	}

[Severity: Medium]
Does defining these fallback stubs directly in the C source file violate the
subsystem guidelines for optional features? 

The perf subsystem guide expects that header files provide compatible dummy
inline stubs when a feature define is absent, rather than generating them via
macros directly in the C source file.

> +
> +DECLARE_LIBTRACEEVENT_STUB(timechart)
> +DECLARE_LIBTRACEEVENT_STUB(sched)
> +DECLARE_LIBTRACEEVENT_STUB(kmem)
> +DECLARE_LIBTRACEEVENT_STUB(lock)
> +DECLARE_LIBTRACEEVENT_STUB(trace)
> +DECLARE_LIBTRACEEVENT_STUB(kwork)
> +#endif
[ ... ]

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20260902154858.2078885-1-irogers@google.com?part=5

^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: [PATCH v3 2/6] perf tool: Tidy up util/cache.h header file users
  2026-09-02 15:48 ` [PATCH v3 2/6] perf tool: Tidy up util/cache.h header file users Ian Rogers
@ 2026-09-02 16:01   ` sashiko-bot
  0 siblings, 0 replies; 14+ messages in thread
From: sashiko-bot @ 2026-09-02 16:01 UTC (permalink / raw)
  To: Ian Rogers; +Cc: linux-perf-users

> Use git clang-format to sort header files. Review header file includes
> removing those that were unnecessary or adding explicit includes in
> cases where transitive dependencies were be using.
> 
> Signed-off-by: Ian Rogers <irogers@google.com>

Sashiko has reviewed this patch and found no issues. It looks great!

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20260902154858.2078885-1-irogers@google.com?part=2


^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: [PATCH v3 5/6] perf tool: Add fallback stubs for missing dependencies
  2026-09-02 15:58   ` sashiko-bot
@ 2026-09-02 16:03     ` Ian Rogers
  0 siblings, 0 replies; 14+ messages in thread
From: Ian Rogers @ 2026-09-02 16:03 UTC (permalink / raw)
  To: linux-perf-users

On Wed, Sep 2, 2026 at 8:58 AM <sashiko-bot@kernel.org> wrote:
>
> Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
> - [Medium] Feature fallback stubs are generated in the C source file instead of providing dummy inline stubs in the header file.
> --
>
> commit f19b5b661c978968c83e8af505c2279ba5f83167
> Author: Ian Rogers <irogers@google.com>
>
> perf tool: Add fallback stubs for missing dependencies
>
> This commit adds fallback stubs directly in perf.c for commands that have
> optional library dependencies, such as libtraceevent and libelf. This ensures
> a unified warning is shown when users try to run these commands, rather than
> silently omitting them from the commands array.
>
> > diff --git a/tools/perf/perf.c b/tools/perf/perf.c
> > index 65bdfd71f6262..6c5baa285b13f 100644
> > --- a/tools/perf/perf.c
> > +++ b/tools/perf/perf.c
> [ ... ]
> > @@ -53,6 +54,38 @@ static void __noreturn usage(const char *err)
> >  static int use_pager = -1;
> >  static FILE *debug_fp = NULL;
> >
> > +
> > +#ifndef HAVE_LIBTRACEEVENT
> > +#define DECLARE_LIBTRACEEVENT_STUB(_cmd) \
> > +     int cmd_##_cmd(int argc __always_unused, const char **argv __always_unused) \
> > +     { \
> > +             fprintf(stderr, \
> > +                     "'" #_cmd "' command not available: missing libtraceevent " \
> > +                     "devel package at build time.\n"); \
> > +             return -1; \
> > +     }
>
> [Severity: Medium]
> Does defining these fallback stubs directly in the C source file violate the
> subsystem guidelines for optional features?
>
> The perf subsystem guide expects that header files provide compatible dummy
> inline stubs when a feature define is absent, rather than generating them via
> macros directly in the C source file.

I saw this feedback on the internal Sashiko review, but I believed
this change was legitimate. To put the fallback stubs into the
affected file would mean not using the Build file config options and
having a large #ifdef in each of the builtin files. This looked uglier
than the change here, and the change here mirrors the previous #ifdef
usage. This change also minimizes the scope of the necessary changes.
I'm not sure it makes sense to update the subsystem guidance based on
this feedback.

Thanks,
Ian

> > +
> > +DECLARE_LIBTRACEEVENT_STUB(timechart)
> > +DECLARE_LIBTRACEEVENT_STUB(sched)
> > +DECLARE_LIBTRACEEVENT_STUB(kmem)
> > +DECLARE_LIBTRACEEVENT_STUB(lock)
> > +DECLARE_LIBTRACEEVENT_STUB(trace)
> > +DECLARE_LIBTRACEEVENT_STUB(kwork)
> > +#endif
> [ ... ]
>
> --
> Sashiko AI review · https://sashiko.dev/#/patchset/20260902154858.2078885-1-irogers@google.com?part=5

^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: [PATCH v3 6/6] perf hist: Remove keysym.h include from hist.h
  2026-09-02 15:48 ` [PATCH v3 6/6] perf hist: Remove keysym.h include from hist.h Ian Rogers
@ 2026-09-02 16:07   ` sashiko-bot
  0 siblings, 0 replies; 14+ messages in thread
From: sashiko-bot @ 2026-09-02 16:07 UTC (permalink / raw)
  To: Ian Rogers; +Cc: linux-perf-users

Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [Low] Unconditional inclusion of glibc-specific `<features.h>` breaks musl builds.
--

commit 7fe3edc4f61ded07ac7e2f802a9ada49f3daa101
Author: Ian Rogers <irogers@google.com>

perf hist: Remove keysym.h include from hist.h

This commit removes the keysym.h inclusion from hist.h since it isn't
related to the UI. It also addresses the transitive dependency issues by
directly including ui/keysyms.h in several core and UI files.

> diff --git a/tools/perf/builtin-annotate.c b/tools/perf/builtin-annotate.c
> index f208ff5132388..a4c014a1d28fe 100644
> --- a/tools/perf/builtin-annotate.c
> +++ b/tools/perf/builtin-annotate.c
> @@ -24,6 +24,7 @@
>  #include "arch/common.h"
>  #include "builtin.h"
>  #include "perf.h"
> +#include "ui/keysyms.h"

[Severity: Low]
Does this unconditional inclusion of "ui/keysyms.h" introduce a build
regression on musl libc systems when slang support is disabled?

Previously, "ui/keysyms.h" was guarded by #ifdef HAVE_SLANG_SUPPORT inside
hist.h. By including it unconditionally here, it pulls in
tools/perf/ui/libslang.h for all builds.

That header contains an unconditional inclusion of the glibc-specific
<features.h> header:

tools/perf/ui/libslang.h:
...
#include <features.h>
#ifndef HAVE_LONG_LONG
#define HAVE_LONG_LONG __GLIBC_HAVE_LONG_LONG
#endif
...

Since musl libc systems do not provide <features.h>, can this cause the build
to fail if slang is disabled?

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20260902154858.2078885-1-irogers@google.com?part=6

^ permalink raw reply	[flat|nested] 14+ messages in thread

end of thread, other threads:[~2026-09-02 16:07 UTC | newest]

Thread overview: 14+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-09-02 15:48 [PATCH v3 0/6] perf tool: Build dependency tidy up Ian Rogers
2026-09-02 15:48 ` [PATCH v3 1/6] perf tool: Remove util/cache.h Ian Rogers
2026-09-02 15:57   ` sashiko-bot
2026-09-02 15:48 ` [PATCH v3 2/6] perf tool: Tidy up util/cache.h header file users Ian Rogers
2026-09-02 16:01   ` sashiko-bot
2026-09-02 15:48 ` [PATCH v3 3/6] perf tool: Remove unused includes in perf.c Ian Rogers
2026-09-02 15:57   ` sashiko-bot
2026-09-02 15:48 ` [PATCH v3 4/6] perf tool: Move usage strings and functions to perf.c Ian Rogers
2026-09-02 15:56   ` sashiko-bot
2026-09-02 15:48 ` [PATCH v3 5/6] perf tool: Add fallback stubs for missing dependencies Ian Rogers
2026-09-02 15:58   ` sashiko-bot
2026-09-02 16:03     ` Ian Rogers
2026-09-02 15:48 ` [PATCH v3 6/6] perf hist: Remove keysym.h include from hist.h Ian Rogers
2026-09-02 16:07   ` sashiko-bot

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).