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

Catalin Marinas catalin.marinas at arm.com
Fri Nov 27 10:37:55 PST 2026


On Fri, Nov 20, 2026 at 04:58:06PM +0100, Peter Zijlstra wrote:
> On Fri, Nov 20, 2026 at 04:03:20PM +0100, Peter Zijlstra wrote:
> > On Fri, Nov 20, 2026 at 03:45:53PM +0100, Sebastian Andrzej Siewior wrote:
> > > Waiman, Luis, Ada reported that HW breakpoints on ARM64 trigger
> > > "sleeping while atomic" warnings on PREEMPT_RT. The hardware event is
> > > delivered with disabled interrupts and perf intrastrucure expects
> > > disabled interrupts while the overflow callback is invoked.
> > > 
> > > The callback then sends a SIGTRAP signal for which it acquires
> > > sighand_struct::siglock, a spinlock_t which becomes a sleeping lock and
> > > must not be acquired in atomic context.
> > > 
> > > Delay the event callback until the return to userland.
> > > Add perf_hwbp_notify(), a generic perf callback which delayes the
> > > actual callback invocation to task_work_add() callback. This callback
> > > invokes the architecture defined callback perf_arch_hwbp_send_sig().
> > > This requires struct callback_head and the functions require
> > > ARCH_NEED_PERF_HW_NOTIFY to be defined.
> > > 
> > > This was reported against ARM64. ARM, LongARCH and Xtensa follow the
> > > same pattern are also converted. Xtensa is the only not supporting
> > > PREEMPT_RT but now we have all architectures using the same pattern.
> > > 
> > > Fixes: d8fccd9ca5f90 ("arm64: Allow to enable PREEMPT_RT.")
> > > Reported-by: Luis Claudio R. Goncalves <lgoncalv at redhat.com>
> > > Reported-by: Waiman Long <longman at redhat.com>
> > > Closes: https://lore.kernel.org/all/aho0eqjMESuHxECr@redhat.com/
> > > Reviewed-by: Ada Couprie Diaz <ada.coupriediaz at arm.com>
> > > Tested-by: Ada Couprie Diaz <ada.coupriediaz at arm.com>
> > > Reviewed-by: Huacai Chen <chenhuacai at loongson.cn>
> > > Signed-off-by: Sebastian Andrzej Siewior <bigeasy at linutronix.de>
> > > ---
> > 
> > Mark; you was going to stare at this :-)
> > 
> > I'm thinking the archs are doing it wrong and should be sending the
> > signal elsewhere.
> 
> Notably, I'm thinking arm64 should be sending the signal from either
> do_watchpoint()/do_breakpoint(), after it has done perf_bp_event(),
> or from el0_watchpt()/el0_breakpt().
> 
> Perf overflow handlers are not the place to send signals from.
> 
> That is very much what x86 also does, we send the signal from
> exc_debug_user(); which is roughly equivalent to the above mentioned
> functions.

(Mark and Will are the experts here but they are busy)

I think we can do something similar for arm64, send the signal in
el0_breakpt()/el0_watchpt() after local_daif_restore(). We do this with
el0_brk64(). ptrace_hbptriggered() can just record the perf_event and
defer the sending (we may need a new field in thread_struct::debug). No
core code changes needed.

I think Russell also objected to this patch for arm and Sashiko
complains about loongarch issues (I haven't parsed them).

-- 
Catalin



More information about the linux-arm-kernel mailing list