summaryrefslogtreecommitdiff
path: root/tools/lib/python
diff options
context:
space:
mode:
authorPeter Zijlstra <peterz@infradead.org>2026-11-19 09:51:01 +0000
committerPeter Zijlstra <peterz@infradead.org>2026-11-26 13:41:02 +0100
commit34dc983cc1628dea5054baa8687477cbb8683e28 (patch)
tree2afd20562b2db3e66d6cbb6646ee22cc2f6eb32b /tools/lib/python
parent38606d2911f7f2fe80388315da0c4a7fc98af0f8 (diff)
perf: Fix sigtrap vs fast-switch
perf_sigtrap() contains: WARN_ON_ONCE(event->ctx->task != current) The warning assumes that an event's ctx->task always matches the task that ends up running the pending task_work. That assumption can be broken by the context fast-swap path. The failure sequence is: 1. A -> B switch, perf_event_context_sched_out() takes the fast path and does WRITE_ONCE(ctx->task, next) / WRITE_ONCE(next_ctx->task, task). An NMI then hits while the context is swapped, and __perf_event_overflow() queues pending task_work on the *current* task (A), even though the event now belongs to B's swapped-in context view. 2. B -> A switch. Because A now has pending task_work, nr_no_switch_fast is non-zero, so the slow path is taken and ctx->task is *not* swapped back. 3. A returns to user mode, task_work runs perf_pending_task() -> perf_sigtrap(), and event->ctx->task no longer equals current, tripping the WARN_ON_ONCE(). Therefore; the task_work_add() should in fact use event->ctx->task, rather than current. They are always the same, except in this narrow window between perf_event_task_sched_out() and switch_to(). Fixes: c5d93d23a260 ("perf: Enqueue SIGTRAP always via task_work.") Reported-by: Tengda Wu <wutengda@huaweicloud.com> Tested-by: Tengda Wu <wutengda@huaweicloud.com> Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org> Link: https://patch.msgid.link/20261125161342.GP2669272%40noisy.programming.kicks-ass.net
Diffstat (limited to 'tools/lib/python')
0 files changed, 0 insertions, 0 deletions