Thread (25 messages) flat view 25 messages, 4 authors, 2025-10-03

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

From: Peter Zijlstra <peterz@infradead.org>
Date: 2025-09-22 07:23:24
Also in: bpf, lkml

On Fri, Sep 19, 2025 at 04:34:02PM -0700, Josh Poimboeuf wrote:
On Thu, Sep 18, 2025 at 03:10:18PM -0400, Steven Rostedt wrote:
quoted
On Thu, 18 Sep 2025 19:32:20 +0200
Peter Zijlstra [off-list ref] wrote:
quoted
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.
BTW, I remember Peter had a fix for TWA_NMI_CURRENT, I guess it got lost
in the shuffle or did something else happen in the meantime?

  https://lore.kernel.org/20250122124228.GO7145@noisy.programming.kicks-ass.net (local)
Oh, yeah, I had completely forgotten about all that :-)

I'll go stick it in the pile. Thanks!
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help