Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 44487C433F5 for ; Fri, 17 Dec 2021 18:43:47 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S240426AbhLQSnq (ORCPT ); Fri, 17 Dec 2021 13:43:46 -0500 Received: from out02.mta.xmission.com ([166.70.13.232]:59004 "EHLO out02.mta.xmission.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239513AbhLQSnp (ORCPT ); Fri, 17 Dec 2021 13:43:45 -0500 Received: from in02.mta.xmission.com ([166.70.13.52]:58040) by out02.mta.xmission.com with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.93) (envelope-from ) id 1myICk-00FEae-88; Fri, 17 Dec 2021 11:43:42 -0700 Received: from ip68-227-161-49.om.om.cox.net ([68.227.161.49]:42298 helo=email.froward.int.ebiederm.org.xmission.com) by in02.mta.xmission.com with esmtpsa (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.93) (envelope-from ) id 1myICi-008ieW-3a; Fri, 17 Dec 2021 11:43:41 -0700 From: ebiederm@xmission.com (Eric W. Biederman) To: Mike Christie Cc: geert@linux-m68k.org, vverma@digitalocean.com, hdanton@sina.com, hch@infradead.org, stefanha@redhat.com, jasowang@redhat.com, mst@redhat.com, sgarzare@redhat.com, virtualization@lists.linux-foundation.org, christian.brauner@ubuntu.com, axboe@kernel.dk, linux-kernel@vger.kernel.org References: <20211129194707.5863-1-michael.christie@oracle.com> <20211129194707.5863-6-michael.christie@oracle.com> Date: Fri, 17 Dec 2021 12:42:54 -0600 In-Reply-To: <20211129194707.5863-6-michael.christie@oracle.com> (Mike Christie's message of "Mon, 29 Nov 2021 13:47:02 -0600") Message-ID: <87lf0jdqdt.fsf@email.froward.int.ebiederm.org> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/26.1 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain X-XM-SPF: eid=1myICi-008ieW-3a;;;mid=<87lf0jdqdt.fsf@email.froward.int.ebiederm.org>;;;hst=in02.mta.xmission.com;;;ip=68.227.161.49;;;frm=ebiederm@xmission.com;;;spf=neutral X-XM-AID: U2FsdGVkX1/iGnaVviMxtTKijQlJhSfLXrjW2CoE4/w= X-SA-Exim-Connect-IP: 68.227.161.49 X-SA-Exim-Mail-From: ebiederm@xmission.com Subject: Re: [PATCH V6 05/10] signal: Perfom autoreap for PF_USER_WORKER X-SA-Exim-Version: 4.2.1 (built Sat, 08 Feb 2020 21:53:50 +0000) X-SA-Exim-Scanned: Yes (on in02.mta.xmission.com) Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Mike Christie writes: > Userspace doesn't know about PF_USER_WORKER threads, so it can't do wait > to clean them up. For cases like where qemu will do dynamic/hot add/remove > of vhost devices, then we need to auto reap the thread like was done for > the kthread case, because qemu does not know what API the kernel/vhost > layer is using. > > This has us do autoreaping for these threads similar to when the parent > ignores SIGCHLD and for kthreads. There is a lot wrong with this change. 1) you can just set "task->signal = SIGCHLD" to get this behavior so it is unnecessary. 2) This is not the autoreaping you want. This autoreaping just kicks in when the parents signal handler is SIG_IGN. Since I presume you are not controlling the parent this is just plain nonsense. The autoreap you want is the autoreap in exit_notify, and you don't want to call do_notify_parent at all. Eric > Signed-off-by: Mike Christie > --- > kernel/signal.c | 4 ++-- > 1 file changed, 2 insertions(+), 2 deletions(-) > > diff --git a/kernel/signal.c b/kernel/signal.c > index a629b11bf3e0..4ce2cc195269 100644 > --- a/kernel/signal.c > +++ b/kernel/signal.c > @@ -2071,9 +2071,9 @@ bool do_notify_parent(struct task_struct *tsk, int sig) > > psig = tsk->parent->sighand; > spin_lock_irqsave(&psig->siglock, flags); > - if (!tsk->ptrace && sig == SIGCHLD && > + if (!tsk->ptrace && (tsk->flags & PF_USER_WORKER || (sig == SIGCHLD && > (psig->action[SIGCHLD-1].sa.sa_handler == SIG_IGN || > - (psig->action[SIGCHLD-1].sa.sa_flags & SA_NOCLDWAIT))) { > + (psig->action[SIGCHLD-1].sa.sa_flags & SA_NOCLDWAIT))))) { > /* > * We are exiting and our parent doesn't care. POSIX.1 > * defines special semantics for setting SIGCHLD to SIG_IGN