unwind: Finish up unwind when a task exits
On do_exit() when a task is exiting, if a unwind is requested and the deferred user stacktrace is deferred via the task_work, the task_work callback is called after exit_mm() is called in do_exit(). This means that the user stack trace will not be retrieved and an empty stack is created. Instead, add a function unwind_deferred_task_exit() and call it just before exit_mm() so that the unwinder can call the requested callbacks with the user space stack. Cc: Masami Hiramatsu <mhiramat@kernel.org> Cc: Mathieu Desnoyers <mathieu.desnoyers@efficios.com> Cc: Josh Poimboeuf <jpoimboe@kernel.org> Cc: Peter Zijlstra <peterz@infradead.org> Cc: Ingo Molnar <mingo@kernel.org> Cc: Jiri Olsa <jolsa@kernel.org> Cc: Arnaldo Carvalho de Melo <acme@kernel.org> Cc: Namhyung Kim <namhyung@kernel.org> Cc: Thomas Gleixner <tglx@linutronix.de> Cc: Andrii Nakryiko <andrii@kernel.org> Cc: Indu Bhagat <indu.bhagat@oracle.com> Cc: "Jose E. Marchesi" <jemarch@gnu.org> Cc: Beau Belgrave <beaub@linux.microsoft.com> Cc: Jens Remus <jremus@linux.ibm.com> Cc: Linus Torvalds <torvalds@linux-foundation.org> Cc: Andrew Morton <akpm@linux-foundation.org> Cc: Jens Axboe <axboe@kernel.dk> Cc: Florian Weimer <fweimer@redhat.com> Cc: Sam James <sam@gentoo.org> Link: https://lore.kernel.org/20250729182406.504259474@kernel.org Signed-off-by: Steven Rostedt (Google) <rostedt@goodmis.org>
This commit is contained in:
committed by
Steven Rostedt (Google)
parent
357eda2d74
commit
b3b9cb11aa
@@ -114,7 +114,7 @@ int unwind_user_faultable(struct unwind_stacktrace *trace)
|
||||
/* Should always be called from faultable context */
|
||||
might_fault();
|
||||
|
||||
if (current->flags & PF_EXITING)
|
||||
if (!current->mm)
|
||||
return -EINVAL;
|
||||
|
||||
if (!info->cache) {
|
||||
@@ -147,9 +147,9 @@ int unwind_user_faultable(struct unwind_stacktrace *trace)
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void unwind_deferred_task_work(struct callback_head *head)
|
||||
static void process_unwind_deferred(struct task_struct *task)
|
||||
{
|
||||
struct unwind_task_info *info = container_of(head, struct unwind_task_info, work);
|
||||
struct unwind_task_info *info = &task->unwind_info;
|
||||
struct unwind_stacktrace trace;
|
||||
struct unwind_work *work;
|
||||
unsigned long bits;
|
||||
@@ -186,6 +186,23 @@ static void unwind_deferred_task_work(struct callback_head *head)
|
||||
}
|
||||
}
|
||||
|
||||
static void unwind_deferred_task_work(struct callback_head *head)
|
||||
{
|
||||
process_unwind_deferred(current);
|
||||
}
|
||||
|
||||
void unwind_deferred_task_exit(struct task_struct *task)
|
||||
{
|
||||
struct unwind_task_info *info = ¤t->unwind_info;
|
||||
|
||||
if (!unwind_pending(info))
|
||||
return;
|
||||
|
||||
process_unwind_deferred(task);
|
||||
|
||||
task_work_cancel(task, &info->work);
|
||||
}
|
||||
|
||||
/**
|
||||
* unwind_deferred_request - Request a user stacktrace on task kernel exit
|
||||
* @work: Unwind descriptor requesting the trace
|
||||
|
||||
Reference in New Issue
Block a user