Re: [PATCH v1] LoongArch: Only send SIGTRAP for ptrace in do_watch()
From: Tiezhu Yang
Date: Fri Dec 04 2026 - 01:46:34 EST
On 12/4/26 1:01 PM, Huacai Chen wrote:
Hi, Tiezhu,
On Fri, Dec 4, 2026 at 11:55 AM Tiezhu Yang <yangtiezhu@xxxxxxxxxxx> wrote:
A previous fix introduced attr.sigtrap checks in breakpoint_handler()
and watchpoint_handler(). At that time, the aim was to avoid forcing
SIGTRAP when attr.sigtrap is 0, but this caused do_watch() to force
SIGTRAP when attr.sigtrap is 1.
...
This exactly reverts f087903018e3 ("LoongArch: Only send SIGTRAP
signal if necessary in do_watch()"), if f087903018e3 is unnecessary,
why does it exist?
This partially reverts commit f087903018e3 ("LoongArch: Only send
SIGTRAP signal if necessary in do_watch()"), simplifying the logic
to:
if (current->ptrace)
force_sig(SIGTRAP);
In commit f087903018e3, the aim was to avoid forcing SIGTRAP signal
when attr.sigtrap is 0 so that standard perf test cases could run
properly. However, it mistakenly assumed that perf_bp_event() would
not send a signal when attr.sigtrap is 1, which led to adding the
redundant checks in breakpoint_handler() and watchpoint_handler().
Given that the generic perf subsystem already handles attr.sigtrap
via perf_bp_event() and send_sig_perf(), the extra SIGTRAP signal
in do_watch() breaks perf_event semantics by delivering SI_KERNEL
instead of TRAP_PERF, causing the BPF selftest "perf_skip" to fail.
Just preserve the necessary current->ptrace check, and remove the
redundant attr.sigtrap handling.
I will update the commit message in v2 to make this clearer.
Thanks,
Tiezhu