Received: by 10.192.165.148 with SMTP id m20csp4820269imm; Tue, 1 May 2018 04:33:55 -0700 (PDT) X-Google-Smtp-Source: AB8JxZohl2GIamv3x00IDsVAJy2NPsaPdnr9FosJNUqT5DaamTXXLvwDrx4lWlexRikMefCWJTOl X-Received: by 10.98.131.69 with SMTP id h66mr15493562pfe.0.1525174435619; Tue, 01 May 2018 04:33:55 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1525174435; cv=none; d=google.com; s=arc-20160816; b=bT/B5H9i2wQ0pdcM0o1AJl0BbvuDXzLD0S38vUrJCyKDOY3XmOUHneipRpZ6Qt7ciM L6LNqXBoduwPV/Q9NDn2tSGA3JCoEP+YBcx8WKZK48pgdpKTTLA0NfzSZavbO9fH7uCm t8bh0yPHGqtjQiTkiPC50wnfUOi9liAwraFJ4+Ojw4FZKG5aHaeSuNuv6OorR6xnwbxB qF4n0YGHZ7zkFCINze2QGCnWrcb5aFm1pDCVZGguTokrUE4zRZGy/0oEe6EdPmei00R2 hXNz/+ZRu8x5tgzhffX0XO/1r27+7yt/VI+6SHWf1IsOifN8lcXKRCyfmSyX3oDU/OQl p1ug== 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:dkim-signature:arc-authentication-results; bh=awHkaeEdPsvlGvbvEOWx95j4MsL+JMSvTnYSpS4LnRE=; b=Z2AJgrjqLPt7BL9t/Pu+TJELI11Tslk3PuWVhelk+ZJniv1gqH05CEHnOCJ+ArABLe VQCdO+ieIf+F55tRgZ6Id179BEHuw7jPUq9jQeFyKyaXOadUhqAF5K2e3Z9p6nKihUri V9tPTZV2E6MCim/0MXP0HuuAvBysYvgUD2/ZlIhTq6bpt4nf7yOS8kIZFeeR+AXPSq6H LKV1rJVPFm4mcslyitcdsxiROI6oArosZMVqIGUPZfX7XpZR0NV/JcSm+7l0ibyi5PzL 7FhI3gectR2Riefxdw2dCQQYO0Hwx299WodSzqClpOhuBZId6Ugfc+EUpqWu2eF9t64A SnlQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@infradead.org header.s=bombadil.20170209 header.b=ZCYi5SN5; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id q12-v6si9209585pli.419.2018.05.01.04.33.41; Tue, 01 May 2018 04:33:55 -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; dkim=fail header.i=@infradead.org header.s=bombadil.20170209 header.b=ZCYi5SN5; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754887AbeEALbl (ORCPT + 99 others); Tue, 1 May 2018 07:31:41 -0400 Received: from bombadil.infradead.org ([198.137.202.133]:49100 "EHLO bombadil.infradead.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753717AbeEALbk (ORCPT ); Tue, 1 May 2018 07:31:40 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=bombadil.20170209; h=In-Reply-To:Content-Type:MIME-Version :References:Message-ID:Subject:Cc:To:From:Date:Sender:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id: List-Help:List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=awHkaeEdPsvlGvbvEOWx95j4MsL+JMSvTnYSpS4LnRE=; b=ZCYi5SN5ajOmezDbAFZ9nPbMC /YsnRwzXzy4pQL4n/E0FX45LEfH8wE5RuJFpvsjGSjWVh/aJroPEZcJ9sy/mEpr7Bnm4lnnD+5LYV fvw5oiqt0zLv+Ei5SEeWpHOiXvcsGY36ABs3I6ttBU3AHneZEwn0t5btVBxoVrQafRANVdbBmye/y jgSp7dbP9PkMJAYpnEhS/n0U2fqRxijAY5CXMO0JKN3roi/nsYDbfSofsRpAPT0r9xxSgQoodsAy0 H3YdqjUIMY+nyiUbcNM4Bb8Iybx5ioeluY7Hb894xOwwVNOVqfTHqy6h2G8f2EVWNvLBlJtd7o8um noIaiAsbA==; Received: from j217100.upc-j.chello.nl ([24.132.217.100] helo=hirez.programming.kicks-ass.net) by bombadil.infradead.org with esmtpsa (Exim 4.90_1 #2 (Red Hat Linux)) id 1fDTVO-0005gS-Fy; Tue, 01 May 2018 11:31:34 +0000 Received: by hirez.programming.kicks-ass.net (Postfix, from userid 1000) id CF6D72029FA14; Tue, 1 May 2018 13:31:32 +0200 (CEST) Date: Tue, 1 May 2018 13:31:32 +0200 From: Peter Zijlstra To: "Kohli, Gaurav" Cc: tglx@linutronix.de, mpe@ellerman.id.au, mingo@kernel.org, bigeasy@linutronix.de, linux-kernel@vger.kernel.org, linux-arm-msm@vger.kernel.org, Neeraj Upadhyay , Will Deacon , Oleg Nesterov Subject: Re: [PATCH v1] kthread/smpboot: Serialize kthread parking against wakeup Message-ID: <20180501113132.GF12217@hirez.programming.kicks-ass.net> References: <1524645199-5596-1-git-send-email-gkohli@codeaurora.org> <20180425200917.GZ4082@hirez.programming.kicks-ass.net> <20180426084131.GV4129@hirez.programming.kicks-ass.net> <20180426085719.GW4129@hirez.programming.kicks-ass.net> <4d3f68f8-e599-6b27-a2e8-9e96b401d57a@codeaurora.org> <20180430111744.GE4082@hirez.programming.kicks-ass.net> <3af3365b-4e3f-e388-8e90-45a3bd4120fd@codeaurora.org> <20180501101845.GE12217@hirez.programming.kicks-ass.net> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.9.5 (2018-04-13) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, May 01, 2018 at 04:10:53PM +0530, Kohli, Gaurav wrote: > Yes with loop, it will reset TASK_PARKED but that is not happening in the > dumps we have seen. But was that with or without the fixed wait-loop? I don't care about stuff you might have seen with the current code, that is clearly broken. > > takedown_cpu() can proceed beyond smpboot_park_threads() and kill the > > CPU before any of the threads are parked -- per having the complete() > > before hitting schedule(). > > > > And, afaict, that is harmless. When we go offline, sched_cpu_dying() -> > > migrate_tasks() will migrate any still runnable threads off the cpu. > > But because at this point the thread must be in the PARKED wait-loop, it > > will hit schedule() and go to sleep eventually. > > > > Also note that kthread_unpark() does __kthread_bind() to rebind the > > threads. > > > > Aaaah... I think I've spotted a problem there. We clear SHOULD_PARK > > before we rebind, so if the thread lost the first PARKED store, > > does the completion, gets migrated, cycles through the loop and now > > observes !SHOULD_PARK and bails the wait-loop, then __kthread_bind() > > will forever wait. > > > > So during next unpark > __kthread_unpark -> __kthread_bind -> wait_task_inactive (this got failed, > as current state is running so failed on below call: Aah, yes, I seem to have mis-remembered how wait_task_inactive() works. And it is indeed still a problem.. Let me ponder what the best solution is, it's a bit of a mess.