summaryrefslogtreecommitdiff
path: root/tools/lib/python/kdoc
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
commit38606d2911f7f2fe80388315da0c4a7fc98af0f8 (patch)
treef46bd7fa82b59458e413f91bd85bba676d7e04de /tools/lib/python/kdoc
parente4c5112f01816b0ac6d74724545eca1195788c38 (diff)
perf: Fix sigtrap for software events
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(). The nr_no_switch_fast bits hard rely on perf_pmu_disable() actually working. It turns out the software events do not implement the pmu::pmu_{dis,en}able() methods and generally ignore the state, making the above scenario worse in that an overflow can happen in the middle of swapping task contexts, making it impossible to reconstruct state. Ensure software and tracepoint events respect the disable state. Fixes: ca6c21327c6a ("perf: Fix missing SIGTRAPs") Fixes: c5d93d23a260 ("perf: Enqueue SIGTRAP always via task_work.") Reported-by: Tengda Wu <wutengda@huaweicloud.com> Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org> Tested-by: Tengda Wu <wutengda@huaweicloud.com> Link: https://patch.msgid.link/20261125161342.GP2669272%40noisy.programming.kicks-ass.net
Diffstat (limited to 'tools/lib/python/kdoc')
0 files changed, 0 insertions, 0 deletions