Received: by 10.192.165.148 with SMTP id m20csp1775945imm; Thu, 26 Apr 2018 02:00:57 -0700 (PDT) X-Google-Smtp-Source: AIpwx4+XoECntP7fiXOlTpRI34BO7MUjNRLFQjSq+MoYCVqB8JCDxVSyXnFJhXSiUCJ4G84Q0Upz X-Received: by 2002:a17:902:887:: with SMTP id 7-v6mr33583003pll.319.1524733257534; Thu, 26 Apr 2018 02:00:57 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1524733257; cv=none; d=google.com; s=arc-20160816; b=fQo+9F2NB4zuudzvNEjTl5b2mlauBQFYWGdmfwJ2xHG+ZZQMWhJe2F8hjjWdWklwPc hyQrYVgseotbabH2Xv3KBgQYJWWNBJqqozvTCPxghA9ubLlJ0lIN1JJyk7clesrbkiDY acg80ekunhZwoEZl+66lecIvTulM6I8eDNkpaDtIuL5x6TTEhNGCYNNzStQ0zRx/cpxS N1YZq7oJB/9s1GOyxs5/d7suf52oXXgIiWWoCJfDYMOle1Sc2PAEHI9X8r+WvpmVX1GA ARZFLxWcn3FZVvMpRVPKANbU0bd+mS2UbkpeiVm2SG9KN5BB1oWvl4b1hLs/zS6jjpON eWfw== 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=kd4l6zVYf+11oN+Zl3W0X4IfI7F9a6G5UWgT8/XMV70=; b=uEqnC5Z9UPQ9Lo0VnpnagL7ZEPmCjyTlqn4ILty/sWrHp0qvPI2TQTsOopKDr63Gxu luHFsSKWorJP4wWWDW+ZOQoqps895wTHeYoUATgautaevWKNGd1AmHEpi17MChWjrqPH WLoMTA4SGv2ozfu3EG8jktBxHO++7rBAoIR0Q+6Hc6eA8wtHblKamXBGXzgyPWegfxxw PsfaA3OffxZPL9h5Owq4U7ZkhwM01bSvENKvmwR0qPmS3TktOWuCtLi3pWxDaxhanEVk GjstVT+hMkvjXM+JZ8dffgLwEpXz/U+JnYiRtehTAzugnZQowfICndwL5ELdSQoch/1U TS+g== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@infradead.org header.s=bombadil.20170209 header.b=guw+DHyd; 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 x28si7313583pfa.37.2018.04.26.02.00.42; Thu, 26 Apr 2018 02:00:57 -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=guw+DHyd; 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 S1754888AbeDZI5f (ORCPT + 99 others); Thu, 26 Apr 2018 04:57:35 -0400 Received: from bombadil.infradead.org ([198.137.202.133]:44690 "EHLO bombadil.infradead.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754539AbeDZI5c (ORCPT ); Thu, 26 Apr 2018 04:57:32 -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=kd4l6zVYf+11oN+Zl3W0X4IfI7F9a6G5UWgT8/XMV70=; b=guw+DHydEdlYD08sOSeYZesAX wlYsyvdqc7hK9CLv2HvdFwLHrrLRkgVcTnCUq2Mfx3K+66DsgW724mTVvrl24s76VjRYKp8sNj/sF 3K3eYyRP3A+28ezGhJOFRvMWNo8nYDnBWf5TgljogtXBz2e6yEMUZwPvkxNgcNh5FQiF8otoTSxOX 1TBX5RvURKBCOV7Y3LOGWzCtWqR3eYG9izkmjihMuUFK3jmIHwRVmnk4M/WXGPYaU8H5ByowwtGDH wkTuCHxKeuG7eBTN33Ec9TtK4LX3It5j6iZ4u3WwQb8hx1VBXWd7J0bXrdrGXd2jBgfCtNdKgc2LI V1Pp8O8XA==; 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 1fBciP-0007k8-Jz; Thu, 26 Apr 2018 08:57:21 +0000 Received: by hirez.programming.kicks-ass.net (Postfix, from userid 1000) id 5BBF9203BFAEE; Thu, 26 Apr 2018 10:57:19 +0200 (CEST) Date: Thu, 26 Apr 2018 10:57:19 +0200 From: Peter Zijlstra To: Gaurav Kohli 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: <20180426085719.GW4129@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> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20180426084131.GV4129@hirez.programming.kicks-ass.net> User-Agent: Mutt/1.9.3 (2018-01-21) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, Apr 26, 2018 at 10:41:31AM +0200, Peter Zijlstra wrote: > diff --git a/kernel/kthread.c b/kernel/kthread.c > index cd50e99202b0..4b6503c6a029 100644 > --- a/kernel/kthread.c > +++ b/kernel/kthread.c > @@ -177,12 +177,13 @@ void *kthread_probe_data(struct task_struct *task) > > static void __kthread_parkme(struct kthread *self) > { > - __set_current_state(TASK_PARKED); > - while (test_bit(KTHREAD_SHOULD_PARK, &self->flags)) { > + for (;;) { > + __set_task_state(TASK_PARKED); set_current_state(TASK_PARKED); of course.. > + if (!test_bit(KTHREAD_SHOULD_PARK, &self->flags)) > + break; > if (!test_and_set_bit(KTHREAD_IS_PARKED, &self->flags)) > complete(&self->parked); > schedule(); > - __set_current_state(TASK_PARKED); > } > clear_bit(KTHREAD_IS_PARKED, &self->flags); > __set_current_state(TASK_RUNNING); >