[PATCH 05/12] unwind: Add comment to unwind_deferred_task_exit()

Peter Zijlstra posted 12 patches 4 months, 2 weeks ago
[PATCH 05/12] unwind: Add comment to unwind_deferred_task_exit()
Posted by Peter Zijlstra 4 months, 2 weeks ago
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.
+	 */
+	unwind_deferred_task_exit(tsk);
 
 	exit_mm();
Re: [PATCH 05/12] unwind: Add comment to unwind_deferred_task_exit()
Posted by Steven Rostedt 4 months, 1 week ago
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.

-- Steve


> +	 */
> +	unwind_deferred_task_exit(tsk);
>  
>  	exit_mm();
>  
>
Re: [PATCH 05/12] unwind: Add comment to unwind_deferred_task_exit()
Posted by Peter Zijlstra 3 months, 3 weeks ago
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);
Re: [PATCH 05/12] unwind: Add comment to unwind_deferred_task_exit()
Posted by Steven Rostedt 3 months, 2 weeks ago
On Mon, 20 Oct 2025 12:16:02 +0200
Peter Zijlstra <peterz@infradead.org> wrote:

> > 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);

Thanks,

Reviewed-by: Steven Rostedt (Google) <rostedt@goodmis.org>

-- Steve
[tip: perf/core] unwind: Add comment to unwind_deferred_task_exit()
Posted by tip-bot2 for Peter Zijlstra 3 months, 1 week ago
The following commit has been merged into the perf/core branch of tip:

Commit-ID:     ae577ea0bc5249c483da09670f784dbc288c80b6
Gitweb:        https://git.kernel.org/tip/ae577ea0bc5249c483da09670f784dbc288c80b6
Author:        Peter Zijlstra <peterz@infradead.org>
AuthorDate:    Mon, 22 Sep 2025 15:46:27 +02:00
Committer:     Peter Zijlstra <peterz@infradead.org>
CommitterDate: Wed, 29 Oct 2025 10:29:55 +01:00

unwind: Add comment to unwind_deferred_task_exit()

Explain why unwind_deferred_task_exit() exist and its constraints.

Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org>
Reviewed-by: Steven Rostedt (Google) <rostedt@goodmis.org>
Link: https://patch.msgid.link/20250924080118.893367437@infradead.org
---
 kernel/exit.c | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/kernel/exit.c b/kernel/exit.c
index 9f74e8f..5f6e78e 100644
--- a/kernel/exit.c
+++ b/kernel/exit.c
@@ -939,7 +939,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);
 
 	/*
@@ -950,6 +949,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. So flush any pending unwinds here.
+	 */
+	unwind_deferred_task_exit(tsk);
 
 	exit_mm();