From: Ian Rogers <irogers@google.com>
To: Peter Zijlstra <peterz@infradead.org>,
Ingo Molnar <mingo@redhat.com>,
Arnaldo Carvalho de Melo <acme@kernel.org>,
Namhyung Kim <namhyung@kernel.org>, Jiri Olsa <jolsa@kernel.org>,
Ian Rogers <irogers@google.com>,
Adrian Hunter <adrian.hunter@intel.com>,
James Clark <james.clark@linaro.org>,
Tianyou Li <tianyou.li@intel.com>,
Jiebin Sun <jiebin.sun@intel.com>,
Dapeng Mi <dapeng1.mi@linux.intel.com>,
Eric Biggers <ebiggers@kernel.org>,
Thomas Richter <tmricht@linux.ibm.com>,
Stephen Brennan <stephen.s.brennan@oracle.com>,
Swapnil Sapkal <swapnil.sapkal@amd.com>,
linux-kernel@vger.kernel.org, linux-perf-users@vger.kernel.org
Subject: [PATCH v3 2/6] perf tool: Tidy up util/cache.h header file users
Date: Wed, 2 Sep 2026 08:48:54 -0700 [thread overview]
Message-ID: <20260902154858.2078885-3-irogers@google.com> (raw)
In-Reply-To: <20260902154858.2078885-1-irogers@google.com>
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
next prev parent reply other threads:[~2026-09-02 15:49 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
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 ` Ian Rogers [this message]
2026-09-02 16:01 ` [PATCH v3 2/6] perf tool: Tidy up util/cache.h header file users 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
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20260902154858.2078885-3-irogers@google.com \
--to=irogers@google.com \
--cc=acme@kernel.org \
--cc=adrian.hunter@intel.com \
--cc=dapeng1.mi@linux.intel.com \
--cc=ebiggers@kernel.org \
--cc=james.clark@linaro.org \
--cc=jiebin.sun@intel.com \
--cc=jolsa@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-perf-users@vger.kernel.org \
--cc=mingo@redhat.com \
--cc=namhyung@kernel.org \
--cc=peterz@infradead.org \
--cc=stephen.s.brennan@oracle.com \
--cc=swapnil.sapkal@amd.com \
--cc=tianyou.li@intel.com \
--cc=tmricht@linux.ibm.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox