Re: [PATCH v4] ARM, ARM64, LONGARCH, XTENSA: Delay HW BP notification to task_work()

From: Sebastian Andrzej Siewior

Date: Mon Oct 12 2026 - 05:38:11 EST


On 2026-10-12 09:18:30 [+0000], sashiko-bot@xxxxxxxxxx wrote:
> > diff --git a/include/linux/perf_event.h b/include/linux/perf_event.h
> > --- a/include/linux/perf_event.h
> > +++ b/include/linux/perf_event.h
> > @@ -215,6 +215,10 @@ struct hw_perf_event {
> >
> > /* Last sync'ed generation of filters */
> > unsigned long addr_filters_gen;
> > +#ifdef ARCH_NEED_PERF_HW_NOTIFY
> > + struct callback_head arch_hw_notif;
> > + int arch_hw_notif_busy;
> > +#endif
>
> [Severity: Critical]
> Does this cause an ABI mismatch and One Definition Rule violation across
> the kernel?

So you learned a new thing.

> The ARCH_NEED_PERF_HW_NOTIFY macro is defined in architecture-specific
> headers like arch/arm64/include/asm/hw_breakpoint.h, but it is used here
> in the generic include/linux/perf_event.h header.
>
> Because linux/perf_event.h does not universally include asm/hw_breakpoint.h,
> translation units that include linux/perf_event.h without previously
> including the architecture hardware breakpoint header will evaluate
> struct hw_perf_event without these fields. Since struct hw_perf_event
> is embedded in struct perf_event, this alters the size and member offsets
> of struct perf_event across different subsystems.
>
> Can this lead to memory corruption when perf_event objects are passed
> between translation units with mismatched struct definitions? Should these
> conditional fields be driven by a globally visible Kconfig symbol instead?

This header file includes the mentioned header files defining
ARCH_NEED_PERF_HW_NOTIFY. The condition upon which the header file is
included does not change while the kernel is built. This could be moved
to Kconfig but I don't see the need for this.

Sebastian