[PATCH 06/11] coredump: In zap_threads complete startup if there is no need to wait
From: Eric W. Biederman
Date: Fri Jun 26 2026 - 13:01:31 EST
Remove the need to test the value of core_waiters in coredump_wait by
completing core_state->startup when there is an error or there are no
other tasks to wait for.
This slightly simplifies the logic and prepares for moving zap_threads
out of coredump_wait.
Signed-off-by: "Eric W. Biederman" <ebiederm@xxxxxxxxxxxx>
---
fs/coredump.c | 30 +++++++++++++++---------------
1 file changed, 15 insertions(+), 15 deletions(-)
diff --git a/fs/coredump.c b/fs/coredump.c
index 14ec61c8d982..0aa235429cfa 100644
--- a/fs/coredump.c
+++ b/fs/coredump.c
@@ -517,6 +517,8 @@ static int zap_threads(struct task_struct *tsk,
tsk->flags |= PF_DUMPCORE;
atomic_set(&core_state->nr_threads, nr);
}
+ if (nr <= 0)
+ complete(&core_state->startup);
spin_unlock_irq(&tsk->sighand->siglock);
return nr;
}
@@ -547,28 +549,26 @@ void coredump_join(struct core_state *core_state)
static int coredump_wait(int exit_code, struct core_state *core_state)
{
struct task_struct *tsk = current;
- int core_waiters = -EBUSY;
+ struct core_thread *ptr;
+ int core_waiters;
init_completion(&core_state->startup);
core_state->dumper.task = tsk;
core_state->dumper.next = NULL;
core_waiters = zap_threads(tsk, core_state, exit_code);
- if (core_waiters > 0) {
- struct core_thread *ptr;
- wait_for_completion_state(&core_state->startup,
- TASK_UNINTERRUPTIBLE|TASK_FREEZABLE);
- /*
- * Wait for all the threads to become inactive, so that
- * all the thread context (extended register state, like
- * fpu etc) gets copied to the memory.
- */
- ptr = core_state->dumper.next;
- while (ptr != NULL) {
- wait_task_inactive(ptr->task, TASK_ANY);
- ptr = ptr->next;
- }
+ wait_for_completion_state(&core_state->startup,
+ TASK_UNINTERRUPTIBLE|TASK_FREEZABLE);
+ /*
+ * Wait for all the threads to become inactive, so that
+ * all the thread context (extended register state, like
+ * fpu etc) gets copied to the memory.
+ */
+ ptr = core_state->dumper.next;
+ while (ptr != NULL) {
+ wait_task_inactive(ptr->task, TASK_ANY);
+ ptr = ptr->next;
}
return core_waiters;
--
2.41.0