perf/headers: Clean up <linux/perf_event.h> a bit
authorIngo Molnar <mingo@kernel.org>
Sat, 24 May 2025 09:23:25 +0000 (11:23 +0200)
committerIngo Molnar <mingo@kernel.org>
Sun, 25 May 2025 07:51:56 +0000 (09:51 +0200)
commite7d952cc39fca34386ec9f15f68cb2eaac01b5ae
tree1c3ea29e500bd2535545359059f50b27cc9d8f06
parent44889ff67cee7b9ee2d305690ce7a5488b137a66
perf/headers: Clean up <linux/perf_event.h> a bit

Do a bit of readability spring cleaning:

 - Fix misaligned structure member in perf_addr_filter: the new
   struct perf_addr_filter::action member was too long, but when
   it was added it was not aligned properly. Align all fields to
   the customary column 41 alignment of most of the rest of the
   header.

 - Adjust the vertical alignment of the definition of other
   structures and definitions as well, so that the 'most of' in
   the previous paragraph changes to 'all of'. ;-)

 - Prettify the assignments in perf_clear_branch_entry_bitfields()

 - Move comments from CPP definitions to outside the macro

 - Move perf_guest_info_callbacks and related defines from the front
   of the header closer to where it's used within the header.

 - And more #endif markers for larger CPP blocks and standardize
   #if/#else/#endif blocks to the following nomenclature:

#ifdef CONFIG_FOO
...
#else /* !CONFIG_FOO: */
...
#endif /* !CONFIG_FOO */

 - Standardize on consistently using the 'extern' storage class where
   appropriate, we had cases where method prototypes sometimes omitted
   the storage class:

extern void perf_pmu_migrate_context(struct pmu *pmu,
int src_cpu, int dst_cpu);
int perf_event_read_local(struct perf_event *event, u64 *value,
  u64 *enabled, u64 *running);
extern u64 perf_event_read_value(struct perf_event *event,
 u64 *enabled, u64 *running);

   Which is obviously a bit confusing and adds unnecessary noise.

 - s/__u64/u64 and similar cleanups: there's no point in using __u64
   in non-UAPI headers, and doing so only adds unnecessary visual noise.

 - Harmonize all multi-parameter function prototypes along the following
   style:

extern struct perf_event *
perf_event_create_kernel_counter(struct perf_event_attr *attr,
 int cpu,
 struct task_struct *task,
 perf_overflow_handler_t callback,
 void *context);
 - etc.

Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Arnaldo Carvalho de Melo <acme@redhat.com>
Cc: Jiri Olsa <jolsa@redhat.com>
Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
Cc: Mark Rutland <mark.rutland@arm.com>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Ian Rogers <irogers@google.com>
Cc: linux-kernel@vger.kernel.org
Signed-off-by: Ingo Molnar <mingo@kernel.org>
include/linux/perf_event.h