Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S965750AbcJYM5v (ORCPT ); Tue, 25 Oct 2016 08:57:51 -0400 Received: from mx1.redhat.com ([209.132.183.28]:57350 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932241AbcJYM5u (ORCPT ); Tue, 25 Oct 2016 08:57:50 -0400 Date: Tue, 25 Oct 2016 14:56:16 +0200 From: Oleg Nesterov To: Roman Pen Cc: Andy Lutomirski , Peter Zijlstra , Thomas Gleixner , Ingo Molnar , Tejun Heo , linux-kernel@vger.kernel.org Subject: Re: [PATCH v3 1/1] workqueue: ignore dead tasks in a workqueue sleep hook Message-ID: <20161025125615.GA4326@redhat.com> References: <20161025110357.8821-1-roman.penyaev@profitbricks.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20161025110357.8821-1-roman.penyaev@profitbricks.com> User-Agent: Mutt/1.5.18 (2008-05-17) X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.25]); Tue, 25 Oct 2016 12:57:48 +0000 (UTC) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1017 Lines: 34 On 10/25, Roman Pen wrote: > > struct task_struct *wq_worker_sleeping(struct task_struct *task) > { > - struct worker *worker = kthread_data(task), *to_wakeup = NULL; > + struct worker *worker, *to_wakeup = NULL; > struct worker_pool *pool; > > + > + if (task->state == TASK_DEAD) { > + /* > + * Here we try to catch the following path before > + * accessing NULL kthread->vfork_done ptr thru > + * kthread_data(): > + * > + * oops_end() > + * do_exit() > + * schedule() > + * > + * If panic_on_oops is not set and oops happens on > + * a workqueue execution path, thread will be killed. > + * That is definitly sad, but not to make the situation > + * even worse we have to ignore dead tasks in order not > + * to step on zeroed out members (e.g. t->vfork_done is > + * already NULL on that path, since we were called by > + * do_exit())). > + */ > + return NULL; > + } I still think that PF_EXITING check makes more sense than TASK_DEAD, but I won't insist. Oleg.