Linux Perf Users
 help / color / mirror / Atom feed
* [PATCH v2] perf clang-format: Add a perf clang-format that overrides some kernel behaviors
       [not found] <20260407165551.3075684-1-irogers@google.com>
@ 2026-04-28  6:54 ` Ian Rogers
  2026-05-20 15:37   ` Ian Rogers
  0 siblings, 1 reply; 3+ messages in thread
From: Ian Rogers @ 2026-04-28  6:54 UTC (permalink / raw)
  To: irogers, acme, namhyung
  Cc: akpm, joe, justinstitt, linux-kernel, llvm, morbo, nathan,
	nick.desaulniers+lkml, linux-perf-users

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


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

* Re: [PATCH v2] perf clang-format: Add a perf clang-format that overrides some kernel behaviors
  2026-04-28  6:54 ` [PATCH v2] perf clang-format: Add a perf clang-format that overrides some kernel behaviors Ian Rogers
@ 2026-05-20 15:37   ` Ian Rogers
  2026-05-20 18:38     ` Arnaldo Carvalho de Melo
  0 siblings, 1 reply; 3+ messages in thread
From: Ian Rogers @ 2026-05-20 15:37 UTC (permalink / raw)
  To: irogers, acme, namhyung
  Cc: akpm, joe, justinstitt, linux-kernel, llvm, morbo, nathan,
	nick.desaulniers+lkml, linux-perf-users

On Mon, Apr 27, 2026 at 11:54 PM Ian Rogers <irogers@google.com> wrote:
>
> 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/.

This change helps format header files in tools/perf, otherwise
following the parent linux clang-format options. Could we land this in
perf-tools-next?

Thanks,
Ian

> ---
>  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
>

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

* Re: [PATCH v2] perf clang-format: Add a perf clang-format that overrides some kernel behaviors
  2026-05-20 15:37   ` Ian Rogers
@ 2026-05-20 18:38     ` Arnaldo Carvalho de Melo
  0 siblings, 0 replies; 3+ messages in thread
From: Arnaldo Carvalho de Melo @ 2026-05-20 18:38 UTC (permalink / raw)
  To: Ian Rogers
  Cc: namhyung, akpm, joe, justinstitt, linux-kernel, llvm, morbo,
	nathan, nick.desaulniers+lkml, linux-perf-users

On Wed, May 20, 2026 at 08:37:24AM -0700, Ian Rogers wrote:
> On Mon, Apr 27, 2026 at 11:54 PM Ian Rogers <irogers@google.com> wrote:
> >
> > 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/.
> 
> This change helps format header files in tools/perf, otherwise
> following the parent linux clang-format options. Could we land this in
> perf-tools-next?

Thanks, applied to perf-tools-next, for v7.2.

- Arnaldo

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

end of thread, other threads:[~2026-05-20 18:39 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
     [not found] <20260407165551.3075684-1-irogers@google.com>
2026-04-28  6:54 ` [PATCH v2] perf clang-format: Add a perf clang-format that overrides some kernel behaviors Ian Rogers
2026-05-20 15:37   ` Ian Rogers
2026-05-20 18:38     ` Arnaldo Carvalho de Melo

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox