Subject: Re: [PATCH] arm64/entry: Don't disable preemption in debug_exception_enter() with RT kernel

From: "Luis Claudio R. Goncalves" <[email-masked]>
Date: Fri, 29 May 2026 21:51:06 -0300

On Thu, May 28, 2026 at 05:35:54PM +0200, Sebastian Andrzej Siewior wrote:
> On 2026-05-28 16:51:24 [+0200], To Waiman Long wrote:
> > > The kernel backtrace is produced using the latest v7.1-rc4 kernel. There are
> > > a number of changes to the debug_exception_enter() and
> > > debug_exception_exit() functions over the years, but the preemption disable
> > > code remains since its introduction in v5.3.
> > 
> > Let me look at this again.
> 
> So how do you reproduce this? The calls within debug_exception_enter()/
> exit() look harmless or I miss the big thing here.
> From your backtrace, you have brk_handler() and this is gone since
> commit 31575e11ecf7e ("arm64: debug: split brk64 exception entry") which
> is v6.17-rc1. I can use gdb with breakpoint handling.

Sebastian, in the original series Ada provided a few tests, including the
two files I list below. Running that test in a v7.1-rc5 kernel with
PREEMPT_RT and DEBUG_ATOMIC_SLEEP enabled, I get this backtrace:

[10416.818417] BUG: sleeping function called from invalid context at kernel/locking/spinlock_rt.c:48
[10416.818426] in_atomic(): 1, irqs_disabled(): 1, non_block: 0, pid: 6437, name: gdb_prog1
[10416.818428] preempt_count: 1, expected: 0
[10416.818430] RCU nest depth: 1, expected: 1
[10416.818434] CPU: 11 UID: 0 PID: 6437 Comm: gdb_prog1 Not tainted 7.1.0-rc5-rt1 #2 PREEMPT_{RT,(full)} 
[10416.818437] Hardware name: Lenovo HR330A            7X33CTO1WW    /FALCON     , BIOS hve104r-1.15 02/26/2021
[10416.818440] Call trace:
[10416.818442]  show_stack+0x20/0x40 (C)
[10416.818450]  dump_stack_lvl+0x88/0xb8
[10416.818454]  dump_stack+0x18/0x30
[10416.818457]  __might_resched+0x18c/0x1c8
[10416.818462]  rt_spin_lock+0x4c/0x1b0
[10416.818467]  force_sig_info_to_task+0x34/0x1f0
[10416.818471]  force_sig_fault+0x68/0xb0
[10416.818473]  arm64_force_sig_fault+0x44/0x70
[10416.818476]  ptrace_hbptriggered+0xd0/0x150
[10416.818479]  __perf_event_overflow+0xf4/0x300
[10416.818483]  perf_swevent_event+0x1b8/0x1f0
[10416.818486]  perf_bp_event+0xcc/0xe0
[10416.818489]  do_breakpoint+0xf4/0x238
[10416.818493]  el0_breakpt+0x7c/0x200
[10416.818497]  el0t_64_sync_handler+0xa8/0xf0
[10416.818500]  el0t_64_sync+0x1b0/0x1b8

n order to run the test, you need to create two files with the names and
content listed below and run the following commands:

    cc gdb_prog1.c -o gdb_prog1 -O0 -g
    gdb -x gdb_cmdlist ./gdb_prog1

That's it.

The files I mentioned are:

===== gdb_cmdlist 

---------- >8 cut here 8< ----------
start
hbreak 3
watch target
commands 2
continue
end
commands 3
continue
end
continue
jump 11
continue
quit
---------- >8 cut here 8< ----------

===== gdb_prog1.c

---------- >8 cut here 8< ----------
int main() {
	int add = 0xAA;
	int target = 0;

	target += add;

#ifdef COMPAT
    __asm__("BKPT");
#else
    __asm__("BRK 1");
#endif

	return target;
}
---------- >8 cut here 8< ----------

Luis