Re: [RESEND][PATCH v15 0/4] perf: Support the deferred unwinding infrastructure

From
Steven Rostedt <rostedt@goodmis.org>
Date
2025-09-18 19:10:33
Also in
bpf, lkml
Reply to
Peter Zijlstra, 2025-09-18
On Thu, 18 Sep 2025 19:32:20 +0200
Peter Zijlstra [off-list ref] wrote:
quoted
Now, task_work_run() is in the exit_to_user_mode_loop() which is notably
*before* exit_to_user_mode() which does the unwind_reset_info().

What happens if we get an NMI requesting an unwind after
unwind_reset_info() while still very much being in the kernel on the way
out?  
AFAICT it will try and do a task_work_add(TWA_RESUME) from NMI context,
and this will fail horribly.

If you do something like:

	twa_mode = in_nmi() ? TWA_NMI_CURRENT : TWA_RESUME;
	task_work_add(foo, twa_mode);

it might actually work.
Ah, the comment for TWA_RESUME didn't express this restriction.

That does look like that would work as the way I expected task_work to
handle this case.

-- Steve
Thread (25 messages) 25 messages, 4 authors, last reply 2025-10-03
Keyboard shortcuts
hback out one level
jnext message in thread / next series-diff position
kprevious message in thread / previous series-diff position
ldrill in
Escclose help / fold thread tree
?toggle this help