From mboxrd@z Thu Jan 1 00:00:00 1970 From: Oleg Nesterov Subject: Re: [PATCH v2] kernel/signal: Signal-based pre-coredump notification Date: Wed, 24 Oct 2018 15:52:13 +0200 Message-ID: <20181024135212.GF30128@redhat.com> References: <458c04d8-d189-4a26-729a-bb1d1d751534@cisco.com> <20181023092348.GA14340@redhat.com> <1e68a3ce-32cd-b058-3d1d-36455ceca848@cisco.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Return-path: Content-Disposition: inline In-Reply-To: <1e68a3ce-32cd-b058-3d1d-36455ceca848@cisco.com> Sender: linux-kernel-owner@vger.kernel.org To: Enke Chen Cc: Thomas Gleixner , Ingo Molnar , Borislav Petkov , "H. Peter Anvin" , Peter Zijlstra , Arnd Bergmann , "Eric W. Biederman" , Khalid Aziz , Kate Stewart , Helge Deller , Greg Kroah-Hartman , Al Viro , Andrew Morton , Christian Brauner , Catalin Marinas , Will Deacon , Dave Martin , Mauro Carvalho Chehab , Michal Hocko , Rik van Riel List-Id: linux-arch.vger.kernel.org On 10/23, Enke Chen wrote: > > >> + /* > >> + * Send the pre-coredump signal to the parent if requested. > >> + */ > >> + read_lock(&tasklist_lock); > >> + notify = do_notify_parent_predump(current); > >> + read_unlock(&tasklist_lock); > >> + if (notify) > >> + cond_resched(); > > > > Hmm. I do not understand why do we need cond_resched(). And even if we need it, > > why we can't call it unconditionally? > > Remember the goal is to allow the parent (e.g., a process manager) to take early > action. The "yield" before doing coredump will help. I don't see how can it actually help... cond_resched() is nop if CONFIG_PREEMPT or should_resched() == 0. and the coredumping thread will certainly need to sleep/wait anyway. > > And once again, SIGCHLD/SIGUSR do not queue, this means that PR_SET_PREDUMP_SIG > > is pointless if you have 2 or more children. > > Hmm, could you point me to the code where SIGCHLD/SIGUSR is treated differently > w.r.t. queuing? That does not sound right to me. see the legacy_queue() check. Any signal < SIGRTMIN do not queue. IOW, if SIGCHLD is already pending, then next SIGCHLD is simply ignored. Oleg. From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mx1.redhat.com ([209.132.183.28]:35814 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726285AbeJXWUe (ORCPT ); Wed, 24 Oct 2018 18:20:34 -0400 Date: Wed, 24 Oct 2018 15:52:13 +0200 From: Oleg Nesterov Subject: Re: [PATCH v2] kernel/signal: Signal-based pre-coredump notification Message-ID: <20181024135212.GF30128@redhat.com> References: <458c04d8-d189-4a26-729a-bb1d1d751534@cisco.com> <20181023092348.GA14340@redhat.com> <1e68a3ce-32cd-b058-3d1d-36455ceca848@cisco.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1e68a3ce-32cd-b058-3d1d-36455ceca848@cisco.com> Sender: linux-arch-owner@vger.kernel.org List-ID: To: Enke Chen Cc: Thomas Gleixner , Ingo Molnar , Borislav Petkov , "H. Peter Anvin" , Peter Zijlstra , Arnd Bergmann , "Eric W. Biederman" , Khalid Aziz , Kate Stewart , Helge Deller , Greg Kroah-Hartman , Al Viro , Andrew Morton , Christian Brauner , Catalin Marinas , Will Deacon , Dave Martin , Mauro Carvalho Chehab , Michal Hocko , Rik van Riel , "Kirill A. Shutemov" , Roman Gushchin , Marcos Paulo de Souza , Dominik Brodowski , Cyrill Gorcunov , Yang Shi , Jann Horn , Kees Cook , x86@kernel.org, linux-kernel@vger.kernel.org, linux-arch@vger.kernel.org, "Victor Kamensky (kamensky)" , xe-linux-external@cisco.com, Stefan Strogin Message-ID: <20181024135213.4FVyfmH5ADc9eEcLxbtnTLGFlnRk56FshqHO1q9Tz4Q@z> On 10/23, Enke Chen wrote: > > >> + /* > >> + * Send the pre-coredump signal to the parent if requested. > >> + */ > >> + read_lock(&tasklist_lock); > >> + notify = do_notify_parent_predump(current); > >> + read_unlock(&tasklist_lock); > >> + if (notify) > >> + cond_resched(); > > > > Hmm. I do not understand why do we need cond_resched(). And even if we need it, > > why we can't call it unconditionally? > > Remember the goal is to allow the parent (e.g., a process manager) to take early > action. The "yield" before doing coredump will help. I don't see how can it actually help... cond_resched() is nop if CONFIG_PREEMPT or should_resched() == 0. and the coredumping thread will certainly need to sleep/wait anyway. > > And once again, SIGCHLD/SIGUSR do not queue, this means that PR_SET_PREDUMP_SIG > > is pointless if you have 2 or more children. > > Hmm, could you point me to the code where SIGCHLD/SIGUSR is treated differently > w.r.t. queuing? That does not sound right to me. see the legacy_queue() check. Any signal < SIGRTMIN do not queue. IOW, if SIGCHLD is already pending, then next SIGCHLD is simply ignored. Oleg.