Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S941316AbcJXTKK (ORCPT ); Mon, 24 Oct 2016 15:10:10 -0400 Received: from mail-yb0-f182.google.com ([209.85.213.182]:39154 "EHLO mail-yb0-f182.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S941198AbcJXTJz (ORCPT ); Mon, 24 Oct 2016 15:09:55 -0400 MIME-Version: 1.0 In-Reply-To: <20161024164043.GS3102@twins.programming.kicks-ass.net> References: <20161024160814.3126-1-roman.penyaev@profitbricks.com> <20161024160814.3126-2-roman.penyaev@profitbricks.com> <20161024164043.GS3102@twins.programming.kicks-ass.net> From: Roman Penyaev Date: Mon, 24 Oct 2016 21:09:33 +0200 Message-ID: Subject: Re: [PATCH v2 2/2] workqueue: ignore dead tasks in a workqueue sleep hook To: Peter Zijlstra Cc: Andy Lutomirski , Oleg Nesterov , Thomas Gleixner , Ingo Molnar , Tejun Heo , linux-kernel@vger.kernel.org Content-Type: text/plain; charset=UTF-8 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1569 Lines: 43 On Mon, Oct 24, 2016 at 6:40 PM, Peter Zijlstra wrote: > On Mon, Oct 24, 2016 at 06:08:14PM +0200, Roman Pen wrote: > >> --- a/kernel/workqueue.c >> +++ b/kernel/workqueue.c >> @@ -875,9 +875,31 @@ void wq_worker_waking_up(struct task_struct *task, int cpu) >> */ >> 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; > > https://lkml.kernel.org/r/CA+55aFyQYJerovMsSoSKS7PessZBr4vNp-3QUUwhqk4A4_jcbg@mail.gmail.com Ha, explicit comment from Linus :) Ok. > Also, that misses { }. Ok. -- Roman