From: Ian Rogers Date: Tue, 28 Apr 2026 06:54:32 +0000 (-0700) Subject: perf clang-format: Add a perf clang-format that overrides some kernel behaviors X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=b5050b133e7ab3f49ac391f9e812a227ae09e01e;p=thirdparty%2Fkernel%2Fstable.git perf clang-format: Add a perf clang-format that overrides some kernel behaviors 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 Cc: Andrew Morton Cc: Bill Wendling Cc: Joe Perches Cc: Justin Stitt Cc: Namhyung Kim Cc: Nathan Chancellor Cc: Nick Desaulniers Signed-off-by: Arnaldo Carvalho de Melo --- 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