Received: by 2002:ac0:a5b6:0:0:0:0:0 with SMTP id m51-v6csp1250344imm; Tue, 5 Jun 2018 11:22:12 -0700 (PDT) X-Google-Smtp-Source: ADUXVKKTb3xImYDpGcZmYpldGIazdd/gK3ptA4lW0nM//L0Kwg8PzX1Un485NJjSZ6aSAySvHajb X-Received: by 2002:a63:5f54:: with SMTP id t81-v6mr21903527pgb.108.1528222932846; Tue, 05 Jun 2018 11:22:12 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1528222932; cv=none; d=google.com; s=arc-20160816; b=HYdl+drzG9oR9cdayWis6IlQ4QiHMT8qar29Pz9vspbsEv3xqUb9CWKXqxjL8GtLVp En2ipTdxJLm0rnQhXgx6VVRMvlM3ImVkpUqXJQ4HEJyJu+oroFRaMUaRnRIvRHvAVaC7 9JQvTAp6ozEmCDKzlnFFAcokpsBpgVR4js2lrbepyS/H8AOunpOSUtw+KGOah2RuRQNR cgcCFq+S0EUVOvlyzejq7lYUtAv/qx5oG8v3omWMGey7rYJSjauv8WjJORtxkKqsQWTA QmaA8D1jDruBtBiecHXf0mGszR90ur5FiXzu5bwNAdY1h3oLQphmr1QXBOV4VFn/c9v1 2ftQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding :content-language: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=38UAGAxh10kT3eqxoDXEfSDsiBiXKBihSK8T36cXjQ4=; b=VYir63nqW17N045ru4nOnVWf7NVhxsK3/wKY0ysRaSIvDv4c8dVEXzRy7qjUT2FYDV Q36Z9Zfq0poZyqCrmlnd3CQU0FALWaclO8/UmNy0yKeE5dK5Kzmh4wgHfwVU9dgf8BWW wlZgT81jp+1V7LNzVkdp9xHmmDag+aPjvzF6fHcAUtAL5HiUFCmeV2GgwjcZ714T4Q2U 1P8wdJY17Vxvi4RRHfSOSAOt787vCZwaBtisGIHbC/c3ePdcg2cBWY+yMAyktpFdET9D rUzDZEVovVpCoajOqLDkUQUUjNoHGp7ZkefWdBejC+VDGztMZqMMpRyMTgS4LF/Bzsbx uVBg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@codeaurora.org header.s=default header.b=niu9QGRM; dkim=pass header.i=@codeaurora.org header.s=default header.b=n7guRYpF; 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 j15-v6si23255371pga.252.2018.06.05.11.21.57; Tue, 05 Jun 2018 11:22:12 -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=niu9QGRM; dkim=pass header.i=@codeaurora.org header.s=default header.b=n7guRYpF; 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 S1752044AbeFESVb (ORCPT + 99 others); Tue, 5 Jun 2018 14:21:31 -0400 Received: from smtp.codeaurora.org ([198.145.29.96]:51402 "EHLO smtp.codeaurora.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751803AbeFESV2 (ORCPT ); Tue, 5 Jun 2018 14:21:28 -0400 Received: by smtp.codeaurora.org (Postfix, from userid 1000) id D38CA60764; Tue, 5 Jun 2018 18:21:27 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=codeaurora.org; s=default; t=1528222887; bh=bsQDye/bSS3UpRXM70uoFp0+4BPF51IDtD+mAh4UvDI=; h=Subject:To:Cc:References:From:Date:In-Reply-To:From; b=niu9QGRMBhrG2D8mwAkjWWStdDpsMp8SGS23FpA+nLFTgzgIKUNJrrasWjbiclg9F CMDiAiWIkufv9PPFyDQ4D4aj89HisYe1N14YOdieqNI39gWPtCxxuMOibmoX2BtvkF aSdyrO52aJ+kZYeaMxGS3SSsnePzNbdsWK9R/SYI= 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.5] (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 618F3601B4; Tue, 5 Jun 2018 18:21:23 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=codeaurora.org; s=default; t=1528222886; bh=bsQDye/bSS3UpRXM70uoFp0+4BPF51IDtD+mAh4UvDI=; h=Subject:To:Cc:References:From:Date:In-Reply-To:From; b=n7guRYpFNk3+51qvtN8Zpoz2ZMUfusgbHk5jd6d/p8RVs4oUDJy27FNFSaRkLcMGe CWiGFjEu6TcQfGYcSgq7oZd9eS+uy16wGcgDfvIMTOsDhsB2KHTWUOVOE1czSYJz4c bljWiA0xtVdIxynsjbOh83Hh4Fx7ba5vnIw6skqY= DMARC-Filter: OpenDMARC Filter v1.3.2 smtp.codeaurora.org 618F3601B4 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: Oleg Nesterov , 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 References: <20180501131904.GG12217@hirez.programming.kicks-ass.net> <9b289790-9b3a-73bd-7166-bf39f32cefd8@codeaurora.org> <20180502082011.GB12180@hirez.programming.kicks-ass.net> <830d7225-af90-a55a-991a-bb2023d538f1@codeaurora.org> <55221a5b-dd52-3359-f582-86830dd9f205@codeaurora.org> <20180605150841.GA24053@redhat.com> <20180605152212.GY12180@hirez.programming.kicks-ass.net> <20180605154053.GB12235@hirez.programming.kicks-ass.net> <20180605163515.GB24053@redhat.com> From: "Kohli, Gaurav" Message-ID: Date: Tue, 5 Jun 2018 23:51:18 +0530 User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:52.0) Gecko/20100101 Thunderbird/52.8.0 MIME-Version: 1.0 In-Reply-To: <20180605163515.GB24053@redhat.com> Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi, Just for info , the patch that I have shared earlier with pi_lock approach has been tested since last one month and no issue has been observed, https://lkml.org/lkml/2018/4/25/189 Can we take this if it looks good? Regards Gaurav On 6/5/2018 10:05 PM, Oleg Nesterov wrote: > On 06/05, Peter Zijlstra wrote: >> >> On Tue, Jun 05, 2018 at 05:22:12PM +0200, Peter Zijlstra wrote: >> >>>> OK, but __kthread_parkme() can be preempted before it calls schedule(), so the >>>> caller still can be migrated? Plus kthread_park_complete() can be called twice. >>> >>> Argh... I forgot TASK_DEAD does the whole thing with preempt_disable(). >>> Let me stare at that a bit. >> >> This should ensure we only ever complete when we read PARKED, right? >> >> diff --git a/kernel/sched/core.c b/kernel/sched/core.c >> index 8d59b259af4a..e513b4600796 100644 >> --- a/kernel/sched/core.c >> +++ b/kernel/sched/core.c >> @@ -2641,7 +2641,7 @@ prepare_task_switch(struct rq *rq, struct task_struct *prev, >> * past. prev == current is still correct but we need to recalculate this_rq >> * because prev may have moved to another CPU. >> */ >> -static struct rq *finish_task_switch(struct task_struct *prev) >> +static struct rq *finish_task_switch(struct task_struct *prev, bool preempt) >> __releases(rq->lock) >> { >> struct rq *rq = this_rq(); >> @@ -2674,7 +2674,7 @@ static struct rq *finish_task_switch(struct task_struct *prev) >> * >> * We must observe prev->state before clearing prev->on_cpu (in >> * finish_task), otherwise a concurrent wakeup can get prev >> - * running on another CPU and we could rave with its RUNNING -> DEAD >> + * running on another CPU and we could race with its RUNNING -> DEAD >> * transition, resulting in a double drop. >> */ >> prev_state = prev->state; >> @@ -2720,7 +2720,8 @@ static struct rq *finish_task_switch(struct task_struct *prev) >> break; >> >> case TASK_PARKED: >> - kthread_park_complete(prev); >> + if (!preempt) >> + kthread_park_complete(prev); > > > Yes, but this won't fix the race decribed by Kohli... > > Plus this complicates the schedule() paths for the very special case, and to me > it seems that all this kthread_park/unpark logic needs some serious cleanups... > > Not that I can suggest something better right now. > > Oleg. > > -- > To unsubscribe from this list: send the line "unsubscribe linux-arm-msm" in > the body of a message to majordomo@vger.kernel.org > More majordomo info at http://vger.kernel.org/majordomo-info.html > -- Qualcomm India Private Limited, on behalf of Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum, a Linux Foundation Collaborative Project.