Received: by 10.192.165.148 with SMTP id m20csp2306753imm; Thu, 26 Apr 2018 08:55:05 -0700 (PDT) X-Google-Smtp-Source: AIpwx4+Gu6e+VvSZAUwWZZRYYf2KDKH5HsMHZ5molhArBU8coILHnwvefnSH2SJu1/1p3TGgLtHN X-Received: by 10.99.2.199 with SMTP id 190mr28663243pgc.11.1524758105684; Thu, 26 Apr 2018 08:55:05 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1524758105; cv=none; d=google.com; s=arc-20160816; b=04k6HFli/b2zlwAzTXriaPOOyKEH3cg5QhoFujwLVqOasd83vY1j0vgQ/FYZESRSPo yycTSXVQaLsaujLRWCYTwkng8W7KBMJW0eeyNYWZ/eCNghesoelM+ytG24ZqwPZE9lwx KHSTPishLcCyyUmAfkTnBD3zxAfWBG7isO75rbXetyUXTiOgZD9J4FGX4Cpox/1VPXDU gNhItZ5u/nreExGFv8IZe6LU7nNjs1Vfb7GD3G3LYYdZWPnTjaUtSrEl77JEUmUUwaQx cM7HQm4DIAcGZAx/eV6ZqO/c36a8YWLEwzWgkzRSLNx0PMPDdxXgiPTBnDitQfXf/O1l 0ucg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-language :content-transfer-encoding:in-reply-to:mime-version:user-agent:date :message-id:from:references:cc:to:subject:dmarc-filter :dkim-signature:dkim-signature:arc-authentication-results; bh=RFUwgaqBXMqglSkv67zBrflYkzIVWP+KiRMpNYVl9bE=; b=P677uJCTrZPYJKfA7yv1R8FKZFBqPQv/9IfmpAfx9k5qobymUeC/UPz1jOLgIQo+Ji meVBmIntQmj86lGqgnjjIOSxa1o7SO796Zx4hs/zPOeGanLid8t5eLhvd273kNQl9/wC Rpmk4w/pUDbOm/fSHm1TXKvjZr/n+eUAQ1SiUlfYcSfvlTpcpoqK7hu/IUnEat0ElH61 Kl6r7P8DW/RFd9A6DFbgj6wI3oNHmU/bW2XVT9f8UccbAj1SS952yvrerwaQhM9ednQ5 XoK42ik1iyV2Hx0g7NCqRkwS10auxsRF2rOB6gS/FtIxKWZk1XY33sMrfVjl8jYYEgk3 LWWw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@codeaurora.org header.s=default header.b=PkEnSOYi; dkim=pass header.i=@codeaurora.org header.s=default header.b=c+HKk906; 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 y8-v6si20178580pli.242.2018.04.26.08.54.49; Thu, 26 Apr 2018 08:55:05 -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=pass header.i=@codeaurora.org header.s=default header.b=PkEnSOYi; dkim=pass header.i=@codeaurora.org header.s=default header.b=c+HKk906; 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 S1756726AbeDZPxj (ORCPT + 99 others); Thu, 26 Apr 2018 11:53:39 -0400 Received: from smtp.codeaurora.org ([198.145.29.96]:37540 "EHLO smtp.codeaurora.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1756589AbeDZPxh (ORCPT ); Thu, 26 Apr 2018 11:53:37 -0400 Received: by smtp.codeaurora.org (Postfix, from userid 1000) id 40EAB60F93; Thu, 26 Apr 2018 15:53:37 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=codeaurora.org; s=default; t=1524758017; bh=uFXghT5MlppkXqAPnYvLKWZDFaelFGvSdmSi+RejTT8=; h=Subject:To:Cc:References:From:Date:In-Reply-To:From; b=PkEnSOYi2hdiO4qJKXk5oPVM7jJeBmXFsJWSCmGIpIjPrlHGxip1mfk+vp0Ih1/Wd 40jsDw5HTAzgorykv+0XItWmKSVIq/2rzdMu40NNMFRc/tzUj3F05RgRhyn7+Z+6FO 5ZKLOddLKnufh4LvdCxJIg5uGqWI0QMViBpFaHKc= X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on pdx-caf-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.8 required=2.0 tests=ALL_TRUSTED,BAYES_00, DKIM_SIGNED,T_DKIM_INVALID autolearn=no autolearn_force=no version=3.4.0 Received: from [192.168.0.2] (unknown [183.83.204.93]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) (Authenticated sender: gkohli@smtp.codeaurora.org) by smtp.codeaurora.org (Postfix) with ESMTPSA id A934360FED; Thu, 26 Apr 2018 15:53:28 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=codeaurora.org; s=default; t=1524758016; bh=uFXghT5MlppkXqAPnYvLKWZDFaelFGvSdmSi+RejTT8=; h=Subject:To:Cc:References:From:Date:In-Reply-To:From; b=c+HKk906BDgvyFaa2pXkig/kNuD3fBBUThsHh9Nzvhb4ebiBb3V5ZlmKp74bj7Nl3 sJPz9G8oWNayPM9k5xBWZbdox8sKfyv8OO1lBUadTyLbFcwlaFxz5rjVHnMHCBf+/C JEVZjtrD6kIYB0vvLKDh0ZLG6KURJ8/yLQPoY4Bg= DMARC-Filter: OpenDMARC Filter v1.3.2 smtp.codeaurora.org A934360FED Authentication-Results: pdx-caf-mail.web.codeaurora.org; dmarc=none (p=none dis=none) header.from=codeaurora.org Authentication-Results: pdx-caf-mail.web.codeaurora.org; spf=none smtp.mailfrom=gkohli@codeaurora.org Subject: Re: [PATCH v1] kthread/smpboot: Serialize kthread parking against wakeup To: Peter Zijlstra 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 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> From: "Kohli, Gaurav" Message-ID: <4d3f68f8-e599-6b27-a2e8-9e96b401d57a@codeaurora.org> Date: Thu, 26 Apr 2018 21:23:25 +0530 User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:52.0) Gecko/20100101 Thunderbird/52.7.0 MIME-Version: 1.0 In-Reply-To: <20180426085719.GW4129@hirez.programming.kicks-ass.net> Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 8bit Content-Language: en-US Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 4/26/2018 2:27 PM, Peter Zijlstra wrote: > 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.. Hi Peter, Maybe i am missing something , but still that race can come as we don't put task_parked on special state. Controller                                                                       Hotplug                                                                                  Loop                                                                                  Task_Interruptible Set SHOULD_PARK wakeup -> Proceeds                                                                                   Set Running                                                                                   kthread_parkme                                                                                   SET TASK_PARKED                                                                                   schedule Set TASK_RUNNING Can you please correct ME, if I misunderstood this. > >> + 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); >> >> -- Qualcomm India Private Limited, on behalf of Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum, a Linux Foundation Collaborative Project.