On Wed, Oct 01, 2025 at 11:35:05AM -0400, Steven Rostedt wrote:
> On Wed, 24 Sep 2025 09:59:53 +0200
> Peter Zijlstra <peterz@infradead.org> wrote:
>
> > Explain why unwind_deferred_task_exit() exist and its constraints.
> >
> > Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org>
> > ---
> > kernel/exit.c | 7 ++++++-
> > 1 file changed, 6 insertions(+), 1 deletion(-)
> >
> > --- a/kernel/exit.c
> > +++ b/kernel/exit.c
> > @@ -934,7 +934,6 @@ void __noreturn do_exit(long code)
> >
> > tsk->exit_code = code;
> > taskstats_exit(tsk, group_dead);
> > - unwind_deferred_task_exit(tsk);
> > trace_sched_process_exit(tsk, group_dead);
> >
> > /*
> > @@ -945,6 +944,12 @@ void __noreturn do_exit(long code)
> > * gets woken up by child-exit notifications.
> > */
> > perf_event_exit_task(tsk);
> > + /*
> > + * PF_EXITING (above) ensures unwind_deferred_request() will no
> > + * longer add new unwinds. While exit_mm() (below) will destroy the
> > + * abaility to do unwinds.
>
>
> I would state that it also flushes any unwind that is currently pending, as
> exit_mm() will prevent it from happening.
It now reads:
+ /*
+ * PF_EXITING (above) ensures unwind_deferred_request() will no
+ * longer add new unwinds. While exit_mm() (below) will destroy the
+ * abaility to do unwinds. So flush any pending unwinds here.
+ */
+ unwind_deferred_task_exit(tsk);