Received: by 2002:a25:ab43:0:0:0:0:0 with SMTP id u61csp3374857ybi; Mon, 10 Jun 2019 09:10:33 -0700 (PDT) X-Google-Smtp-Source: APXvYqzVJHu2Hho6/SCU5LUwGwHEJHgVqgErY8SD2OOGoF2tsGjLLu/gUDOiwe6iE0k2rBOmXXjV X-Received: by 2002:a63:545a:: with SMTP id e26mr16115351pgm.162.1560183032946; Mon, 10 Jun 2019 09:10:32 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1560183032; cv=none; d=google.com; s=arc-20160816; b=XwfbjzDr5udECDg6el5USATB5SecKDko3nNr3cl1nbrhRxkMT85VV/NdQtDHvPFaDX 0Y6Bg8uw3ql2dkyUkO3MlyYP3wJgN6eApY3UwPAR99Umbsk+CJOFjucnIVO794+bpSib MBWX0h9zimszTKEMC7gti/eUTyOCsn9ffHEBxlVR775NxnO3ABGRWuHfFNRlbA4hqxKF GkYqw5dVwVPVr5gQH5yRUoTSjqsq5hokicekljHbdU922jmnagtJlCw7zp4MlExv6Pjm PzHeTUB3NERV/XGEKfoSktHm84aGh5GBd+tuV31jC3hX8PyR8AECFiXGSn1hf4yk5jZu /RJw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date; bh=6Rivltd3iQp6h6PX6R3TLyxDppckQbVvcajOcBycdtc=; b=Xxg+Yl6q3aDVhPsf9qNlBC2sTD6gdFGQ5gLJugOKbVNzd/qwo/7EEUJ8IZpnCStAbn RF00hKCXqDJ3f4a7OmJfXlhdFzsAAN/EpilAPMWTbMl9jCnAnhhfnQKmtNY7Hl3/QoQm DRr5tBRVUVyL1mkfKJR/rSMNmEWYWTgIhML3BYWKUGCX3dDEAbA9g7T99vM4VZjtcnOD I3jFUto4P/IntgqciXFxLezMmRywSen0T+f4E8WIUlrmqftWFXb5QP8o0geiqtqfF5Tn TeQx3kqEAgtnDFtNAbajleQ0RZh7T6qZbc+ugwtzVC4GNyX/x1sfLYBHt57JtcfFiX9A l7lA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id a17si10011010pjq.31.2019.06.10.09.10.18; Mon, 10 Jun 2019 09:10:32 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2390201AbfFJOrD (ORCPT + 99 others); Mon, 10 Jun 2019 10:47:03 -0400 Received: from mx1.redhat.com ([209.132.183.28]:58804 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2388373AbfFJOrD (ORCPT ); Mon, 10 Jun 2019 10:47:03 -0400 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 1C59AD56EF; Mon, 10 Jun 2019 14:46:47 +0000 (UTC) Received: from dhcp-27-174.brq.redhat.com (unknown [10.43.17.159]) by smtp.corp.redhat.com (Postfix) with SMTP id EB5FD5DD63; Mon, 10 Jun 2019 14:46:44 +0000 (UTC) Received: by dhcp-27-174.brq.redhat.com (nbSMTP-1.00) for uid 1000 oleg@redhat.com; Mon, 10 Jun 2019 16:46:44 +0200 (CEST) Date: Mon, 10 Jun 2019 16:46:42 +0200 From: Oleg Nesterov To: Gaurav Kohli Cc: Peter Zijlstra , Jens Axboe , Qian Cai , akpm@linux-foundation.org, hch@lst.de, mingo@redhat.com, linux-mm@kvack.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH] block: fix a crash in do_task_dead() Message-ID: <20190610144641.GA8127@redhat.com> References: <1559161526-618-1-git-send-email-cai@lca.pw> <20190530080358.GG2623@hirez.programming.kicks-ass.net> <82e88482-1b53-9423-baad-484312957e48@kernel.dk> <20190603123705.GB3419@hirez.programming.kicks-ass.net> <20190607133541.GJ3436@hirez.programming.kicks-ass.net> <20190607142332.GF3463@hirez.programming.kicks-ass.net> <16419960-3703-5988-e7ea-9d3a439f8b05@codeaurora.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <16419960-3703-5988-e7ea-9d3a439f8b05@codeaurora.org> User-Agent: Mutt/1.5.24 (2015-08-30) X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.38]); Mon, 10 Jun 2019 14:47:03 +0000 (UTC) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 06/10, Gaurav Kohli wrote: > > >@@ -1991,6 +1991,28 @@ try_to_wake_up(struct task_struct *p, un > > unsigned long flags; > > int cpu, success = 0; > >+ if (p == current) { > >+ /* > >+ * We're waking current, this means 'p->on_rq' and 'task_cpu(p) > >+ * == smp_processor_id()'. Together this means we can special > >+ * case the whole 'p->on_rq && ttwu_remote()' case below > >+ * without taking any locks. > >+ * > >+ * In particular: > >+ * - we rely on Program-Order guarantees for all the ordering, > >+ * - we're serialized against set_special_state() by virtue of > >+ * it disabling IRQs (this allows not taking ->pi_lock). > >+ */ > >+ if (!(p->state & state)) > >+ return false; > >+ > > Hi Peter, Jen, > > As we are not taking pi_lock here , is there possibility of same task dead > call comes as this point of time for current thread, bcoz of which we have > seen earlier issue after this commit 0619317ff8ba > [T114538] do_task_dead+0xf0/0xf8 > [T114538] do_exit+0xd5c/0x10fc > [T114538] do_group_exit+0xf4/0x110 > [T114538] get_signal+0x280/0xdd8 > [T114538] do_notify_resume+0x720/0x968 > [T114538] work_pending+0x8/0x10 > > Is there a chance of TASK_DEAD set at this point of time? In this case try_to_wake_up(current, TASK_NORMAL) will do nothing, see the if (!(p->state & state)) above. See also the comment about set_special_state() above. It disables irqs and this is enough to ensure that try_to_wake_up(current) from irq can't race with set_special_state(TASK_DEAD). Oleg.