From nobody Mon Jun 13 19:33:29 2022 X-Original-To: dev-commits-src-all@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id D7CB885496A; Mon, 13 Jun 2022 19:33:29 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4LMMDn5PXlz3pqZ; Mon, 13 Jun 2022 19:33:29 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1655148809; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=JIEqVNIjn08rO7AiY0qmi0pTuVWYf4Gsoop94dU1qnU=; b=t8l4a6d8FTMKELUygjgOTw5zfY9qP8l3D9ymJfWx161C5bCoZHAqxDc/+gQqNKnHwwo7Af L+1yg7hm5e4dVjlJ/VrHQ43M7MEQoxntz01NoyevIkDHc/qAGJJFdoSNEJnVL7mm/ELKH5 sehKSmwFCgep68JhFbCaOLKhxGO5QkH/wELfj2KN6yqz+z0Pby61BZj7TSTzuIJYR05Hzb TdF3qYDUs2GjcObRAwecCMTb6rG5on7GtrEfSBoRCBE/nRXATYOmtxARtM1Kkz6tPv3je3 lJWtdYOihcp10BUsb//iA81Bgqgfzv9zMXaq1oKEXEMivuKGjjV1/2e6jItR9g== Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 985BA1BA62; Mon, 13 Jun 2022 19:33:29 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 25DJXTqP023533; Mon, 13 Jun 2022 19:33:29 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 25DJXTwW023532; Mon, 13 Jun 2022 19:33:29 GMT (envelope-from git) Date: Mon, 13 Jun 2022 19:33:29 GMT Message-Id: <202206131933.25DJXTwW023532@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Konstantin Belousov Subject: git: 02a2aacbe2c8 - main - issignal(): ignore signals when process is single-threading for exit List-Id: Commit messages for all branches of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-all List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-all@freebsd.org X-BeenThere: dev-commits-src-all@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: kib X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 02a2aacbe2c81be455811fa9d4200101f70a86d2 Auto-Submitted: auto-generated ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1655148809; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=JIEqVNIjn08rO7AiY0qmi0pTuVWYf4Gsoop94dU1qnU=; b=NDjQYJ4RvsKkWAN9QaRbHuVGRnEEPJc9c6InS2+PyALRyENzHBUe2CoQsG0bceIih5liv2 jV/Ggkd2vY4Otpyq7plkalJw89kdPFTVDyyWm7LRhGqducNydEx3jxsE7FzDJAxP7w3dUD +Q2BclDc9E0dUB7l5Bs5j2qISsiOth8GDZxSd2dDh+6Fd95pIATQnIgI32kavCJgykMRVd 556vjOFapxr+NRqhLmrq1qfy9NM27rAj5xgWqQnm1vI2wQO8L859kdcxRppyBtENvZAxkk e0cvKCXlGorrrjNn6ORFN9LN9SNUp1emBb8p4XYR8OSU1yfSQtByJBnE0d9TaQ== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1655148809; a=rsa-sha256; cv=none; b=fomL6a4mCGZf6mvP6rfAJEFJwWkmrqYEkCO2gNKkBsgR5R7LihZ3b8pR/rUjbH0tG2/2qw iLRUaDocevWP1eTapwQtYBS36CePIB8pB1KjcQ/AlKFsEo4Qh93ZSPf39gKafpW0M0n/dC Z0fWKG44v8BJUYehAsrhFB1nFFMwCQVXx18UM9Zk+qCrGrDhU49F/3l6shllrk/9+iHBFh ArvTKEaQBWYs8f5uxlWDmwsdl354a6OVEz4gUmMC89b0Vo+CGYq3DX1N8aNrPEVb+hGxuG Ua118wwr1bxKlMqUj6rCjE6cqwRcEN0l1jB1VNDSK/N8j16yrmBV9o0bYMni9Q== ARC-Authentication-Results: i=1; mx1.freebsd.org; none X-ThisMailContainsUnwantedMimeParts: N The branch main has been updated by kib: URL: https://cgit.FreeBSD.org/src/commit/?id=02a2aacbe2c81be455811fa9d4200101f70a86d2 commit 02a2aacbe2c81be455811fa9d4200101f70a86d2 Author: Konstantin Belousov AuthorDate: 2022-05-26 19:18:57 +0000 Commit: Konstantin Belousov CommitDate: 2022-06-13 19:30:02 +0000 issignal(): ignore signals when process is single-threading for exit Places that will wait for curproc->p_singlethr to become zero (in the next commit, the counter of number of external single-threading is to be introduced), must wait for it interruptible, otherwise we deadlock. On the other hand, a signal delivered during this window, if directed to the waiting thread, would cause the wait loop to become a busy loop. Since we are exiting, it is safe to ignore the signals. Reviewed by: markj Tested by: pho Sponsored by: The FreeBSD Foundation MFC after: 2 weeks Differential revision: https://reviews.freebsd.org/D35310 --- sys/kern/kern_sig.c | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/sys/kern/kern_sig.c b/sys/kern/kern_sig.c index afb2fd78c231..e3bbbd23ae6c 100644 --- a/sys/kern/kern_sig.c +++ b/sys/kern/kern_sig.c @@ -2928,7 +2928,7 @@ sigprocess(struct thread *td, int sig) /* * We should allow pending but ignored signals below - * only if there is sigwait() active, or P_TRACED was + * if there is sigwait() active, or P_TRACED was * on when they were posted. */ if (SIGISMEMBER(ps->ps_sigignore, sig) && @@ -2937,6 +2937,16 @@ sigprocess(struct thread *td, int sig) return (SIGSTATUS_IGNORE); } + /* + * If the process is going to single-thread mode to prepare + * for exit, there is no sense in delivering any signal + * to usermode. Another important consequence is that + * msleep(..., PCATCH, ...) now is only interruptible by a + * suspend request. + */ + if ((p->p_flag2 & P2_WEXIT) != 0) + return (SIGSTATUS_IGNORE); + if ((p->p_flag & (P_TRACED | P_PPTRACE)) == P_TRACED) { /* * If traced, always stop.