From: Ian Rogers <irogers@google.com>
To: irogers@google.com, acme@kernel.org, namhyung@kernel.org
Cc: akpm@linux-foundation.org, joe@perches.com,
justinstitt@google.com, linux-kernel@vger.kernel.org,
llvm@lists.linux.dev, morbo@google.com, nathan@kernel.org,
nick.desaulniers+lkml@gmail.com,
linux-perf-users@vger.kernel.org
Subject: [PATCH v2] perf clang-format: Add a perf clang-format that overrides some kernel behaviors
Date: Mon, 27 Apr 2026 23:54:32 -0700 [thread overview]
Message-ID: <20260428065432.1877423-1-irogers@google.com> (raw)
In-Reply-To: <20260407165551.3075684-1-irogers@google.com>
In particular, header file ordering is an issue in the tools/perf
directory given the larger number of depended upon libraries.
The order of header file includes was proposed in:
https://lore.kernel.org/linux-perf-users/CAP-5=fUitzKwJONTngiW17XkS7kVr2cDS4cDL_HccJKcnR2EgQ@mail.gmail.com/
Sorting headers is desirable to avoid issues like duplicate includes.
Signed-off-by: Ian Rogers <irogers@google.com>
---
v2: Move the .clang-format file under tools/perf rather than tools/.
---
tools/perf/.clang-format | 20 ++++++++++++++++++++
1 file changed, 20 insertions(+)
create mode 100644 tools/perf/.clang-format
diff --git a/tools/perf/.clang-format b/tools/perf/.clang-format
new file mode 100644
index 000000000000..902b2f7456f6
--- /dev/null
+++ b/tools/perf/.clang-format
@@ -0,0 +1,20 @@
+BasedOnStyle: InheritParentConfig
+SortIncludes: true
+IncludeBlocks: Regroup
+IncludeCategories:
+ # Implicitly the corresponding header for the C file has Priority 0
+ # C Standard Library Headers
+ - Regex: '^<(assert|complex|ctype|errno|fenv|float|inttypes|iso646|limits|locale|math|setjmp|signal|stdalign|stdarg|stdatomic|stdbool|stddef|stdint|stdio|stdlib|stdnoreturn|string|tgmath|threads|time|uchar|wchar|wctype)\.h>'
+ Priority: 1
+ # OS/System-Specific Headers (directories)
+ - Regex: '^<(sys|linux|asm|arpa|net|netinet|x86_64|machine)/.*>'
+ Priority: 2
+ # OS/System-Specific Headers (POSIX/System flat headers)
+ - Regex: '^<(unistd|pthread|fcntl|dirent|dlfcn|poll|sched|semaphore|spawn|syslog|termios|pwd|grp|netdb|sysexits|err|paths|pty|utmp|resolv|ifaddrs|elf|libelf|gelf)\.h>'
+ Priority: 2
+ # Third-Party Library Headers
+ - Regex: '^<.*>'
+ Priority: 3
+ # Your Project's Other Headers
+ - Regex: '^".*"'
+ Priority: 4
--
2.54.0.545.g6539524ca2-goog
prev parent reply other threads:[~2026-04-28 6:54 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-04-07 16:55 [PATCH v1] tools clang-format: Add a tools clang-format that overrides some kernel behaviors Ian Rogers
2026-04-07 17:11 ` Joe Perches
2026-04-13 15:39 ` Ian Rogers
2026-04-13 15:45 ` Joe Perches
2026-04-13 16:19 ` Ian Rogers
2026-04-13 16:54 ` Joe Perches
2026-04-13 17:50 ` Ian Rogers
2026-04-14 6:34 ` Namhyung Kim
2026-04-13 16:21 ` Miguel Ojeda
2026-04-28 6:54 ` Ian Rogers [this message]
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=20260428065432.1877423-1-irogers@google.com \
--to=irogers@google.com \
--cc=acme@kernel.org \
--cc=akpm@linux-foundation.org \
--cc=joe@perches.com \
--cc=justinstitt@google.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-perf-users@vger.kernel.org \
--cc=llvm@lists.linux.dev \
--cc=morbo@google.com \
--cc=namhyung@kernel.org \
--cc=nathan@kernel.org \
--cc=nick.desaulniers+lkml@gmail.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