From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from out01.mta.xmission.com (out01.mta.xmission.com [166.70.13.231]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 96D7F331EA9 for ; Fri, 3 Jul 2026 21:42:31 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=166.70.13.231 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1783114953; cv=none; b=B0CkpK+JfLiVOCYAXyDcZeT08SseUe0rmpij4Wy1syooVVdpBZycDWe6NDuELOhrOJnt8E9JKzIvx2WXLcs59yZiQvVgDpFuar5/tsSlRRXd/RsoTyAmW/CT8bVSEumY9yZIz6nsJvodqGVM/klMftA9RVlBocZ8gzLt2hNk4N4= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1783114953; c=relaxed/simple; bh=95e2stPJa/nlJfTMggcrQL4NyGdkhcs32RkBeKk5DdI=; h=From:To:Cc:In-Reply-To:References:Date:Message-ID:MIME-Version: Content-Type:Subject; b=aiDX4UxLS1SutZNhAlBFBOoYT/mcMKDIjgHSJzMemj7fs3OkdluDaQ6fzKyNcoR79+/jRSaIQMUBHtoJbOXq2zTwHSbWtn8e1F0d75DcM9EEuO35ZBOjYsNOO+lTzjg95hRY9uYgJsLiYN2zKS2MhOroMpsbl9XzNBSKsaJj+l0= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=xmission.com; spf=pass smtp.mailfrom=xmission.com; dkim=pass (1024-bit key) header.d=xmission.com header.i=@xmission.com header.b=aWvA4DIf; arc=none smtp.client-ip=166.70.13.231 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=xmission.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=xmission.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=xmission.com header.i=@xmission.com header.b="aWvA4DIf" DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=simple/simple; d=xmission.com; s=xmission; h=Subject:Content-Type:MIME-Version:Message-ID:Date:References: In-Reply-To:Cc:To:From:Sender:Reply-To:Content-Transfer-Encoding:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Id:List-Help:List-Unsubscribe:List-Subscribe: List-Post:List-Owner:List-Archive; bh=95e2stPJa/nlJfTMggcrQL4NyGdkhcs32RkBeKk5DdI=; b=aWvA4DIfCAyz/HtGsjYbhf+TEk MT1hqveujyKsFBpupPZs1vTF3nmUj+6sQQaw0TMbYAasI2R0pc5DAqd+/SJcKBjJIgg0JrJCtVFGS Uz4ijoDRGRuzKs/5d47Ev4+TlASvUZOYdvYuhejHrWVedhRjOBadeEkV28SYDONN2U1M=; Received: from in01.mta.xmission.com ([166.70.13.51]:49344) by out01.mta.xmission.com with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.93) (envelope-from ) id 1wfleY-00HEQt-Ql; Fri, 03 Jul 2026 15:42:30 -0600 Received: from ip72-198-198-28.om.om.cox.net ([72.198.198.28]:48194 helo=email.froward.int.ebiederm.org.xmission.com) by in01.mta.xmission.com with esmtpsa (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.93) (envelope-from ) id 1wfleX-00DmXx-Us; Fri, 03 Jul 2026 15:42:30 -0600 From: "Eric W. Biederman" To: Oleg Nesterov Cc: Andrew Morton , Andy Lutomirski , Kees Cook , Kusaram Devineni , Peter Zijlstra , Thomas Gleixner , Will Drewry , linux-kernel@vger.kernel.org, Linus Torvalds , Christian Brauner In-Reply-To: <877bnb4uyw.fsf_-_@email.froward.int.ebiederm.org> (Eric W. Biederman's message of "Fri, 03 Jul 2026 16:35:51 -0500") References: <87o6gx9rc4.fsf@email.froward.int.ebiederm.org> <877bnh7tnf.fsf@email.froward.int.ebiederm.org> <877bnb4uyw.fsf_-_@email.froward.int.ebiederm.org> Date: Fri, 03 Jul 2026 16:42:24 -0500 Message-ID: <87fr1z21j3.fsf_-_@email.froward.int.ebiederm.org> User-Agent: Gnus/5.13 (Gnus v5.13) Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain X-XM-SPF: eid=1wfleX-00DmXx-Us;;;mid=<87fr1z21j3.fsf_-_@email.froward.int.ebiederm.org>;;;hst=in01.mta.xmission.com;;;ip=72.198.198.28;;;frm=ebiederm@xmission.com;;;sPfnum=0;;;sPf=pass X-XM-AID: U2FsdGVkX19QNuSAIQzfXPto3bG0FvItKLFdl9OL+dM= X-Spam-Level: * X-Spam-Virus: No X-Spam-Report: * -1.0 ALL_TRUSTED Passed through trusted hosts only via SMTP * 0.1 BAYES_50 BODY: Bayes spam probability is 40 to 60% * [score: 0.5001] * 0.7 XMSubLong Long Subject * 1.5 XMNoVowels Alpha-numberic number with no vowels * -0.0 DCC_CHECK_NEGATIVE Not listed in DCC * [sa02 1397; Body=1 Fuz1=1 Fuz2=48] * 0.0 T_TooManySym_01 4+ unique symbols in subject X-Spam-DCC: XMission; sa02 1397; Body=1 Fuz1=1 Fuz2=48 X-Spam-Combo: *;Oleg Nesterov X-Spam-Relay-Country: X-Spam-Timing: total 413 ms - load_scoreonly_sql: 0.03 (0.0%), signal_user_changed: 3.8 (0.9%), b_tie_ro: 2.5 (0.6%), parse: 0.65 (0.2%), extract_message_metadata: 7 (1.8%), get_uri_detail_list: 0.91 (0.2%), tests_pri_-2000: 10 (2.4%), tests_pri_-1000: 2.5 (0.6%), tests_pri_-950: 1.00 (0.2%), tests_pri_-900: 0.74 (0.2%), tests_pri_-90: 131 (31.7%), check_bayes: 130 (31.4%), b_tokenize: 5.0 (1.2%), b_tok_get_all: 6 (1.3%), b_comp_prob: 1.11 (0.3%), b_tok_touch_all: 116 (28.0%), b_finish: 0.55 (0.1%), tests_pri_0: 246 (59.6%), check_dkim_signature: 0.36 (0.1%), check_dkim_adsp: 2.6 (0.6%), poll_dns_idle: 1.40 (0.3%), tests_pri_10: 1.58 (0.4%), tests_pri_500: 7 (1.6%), rewrite_mail: 0.00 (0.0%) Subject: [PATCH 10/14] coredump: In zap_threads complete startup if there is no need to wait X-SA-Exim-Connect-IP: 166.70.13.51 X-SA-Exim-Rcpt-To: brauner@kernel.org, torvalds@linux-foundation.org, linux-kernel@vger.kernel.org, wad@chromium.org, tglx@kernel.org, peterz@infradead.org, kusaram@devineni.in, kees@kernel.org, luto@kernel.org, akpm@linux-foundation.org, oleg@redhat.com X-SA-Exim-Mail-From: ebiederm@xmission.com X-SA-Exim-Scanned: No (on out01.mta.xmission.com); SAEximRunCond expanded to false 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" --- fs/coredump.c | 30 +++++++++++++++--------------- 1 file changed, 15 insertions(+), 15 deletions(-) diff --git a/fs/coredump.c b/fs/coredump.c index 700814fc2ff6..4e0e9407704c 100644 --- a/fs/coredump.c +++ b/fs/coredump.c @@ -516,6 +516,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; } @@ -546,28 +548,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