Received: by 10.192.165.148 with SMTP id m20csp1793735imm; Thu, 26 Apr 2018 02:17:58 -0700 (PDT) X-Google-Smtp-Source: AB8JxZqa5cA6XvIdh42tFBR28PcU950KfCbcGGfBYeyIPaeeVfDgP//oXV+jDIK0T3vlHmmqsE6t X-Received: by 10.99.110.132 with SMTP id j126mr9777000pgc.310.1524734278254; Thu, 26 Apr 2018 02:17:58 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1524734278; cv=none; d=google.com; s=arc-20160816; b=OGdtKtPlU8K1fOxdo4ulNZalTh8Qx1uqw0bmnQYPCFJjuHfVjomKx0y2+Vy6XtpioQ jjNwro/0yNRriI0dlKerka2+gG7j75GbzQbdMfVtB4vIYskXjTLYe+7pUbP0zl3qwPyH olfqfsI5Ga9W08Zd1NW3Z3OSZKVOJr8W026rWXrsqN+iHNuJN/6GBSKZppEOaob7umzr +2NK8muXV295+GcCAaMAL8NCOOJ3MBOfOojwtU4ElGPXSxlz4sRfF4y+FmhlMsuVd7rv Y3mVggT75Vu87uHlGuXZ2Xd8MgY0BdjnjB47GdjeShhS6Yor4v8Y7T1UGAVke2RE/CyV sqag== 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-transfer-encoding:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature :arc-authentication-results; bh=pUEPFVxHZBgEaRHOyPcpnkRkRs0HddhkCNOWa1GBK7I=; b=nQdAjMbgM7buRNrR+45nchjg1161hB7tjbD/4Hv6Y4gw7MvHLZqXF8cmV+RaolhrwA 91Tp/Jo/6EH8dG1xzkQWzklNf9Tora9RG31Na3lEV2gsBvyrmkBIdVr6lTa57XpSZRx9 Pm+P+AV/JJODjyx8fw0TY+0ONtaz7gA1KrK901g0yCPdi8I/nZ8U05LHO7Yei2F9jPS7 Mp+9hEkFwYB/YWgdezgDxv8WziXGhFcgSzlcYy9MvHsft6ZfNJvm71p7T472I+kFwyh2 gYQpi2tOoTdisr80xBTqJ/tqpBC67DnmFZMQR8xF9fxApZa4m0MHSjKAzQ4cMylaUa5t w3Kg== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@infradead.org header.s=bombadil.20170209 header.b=sAOKRNmV; 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 w3-v6si17566350plb.17.2018.04.26.02.17.43; Thu, 26 Apr 2018 02:17:58 -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=sAOKRNmV; 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 S1754765AbeDZJO6 (ORCPT + 99 others); Thu, 26 Apr 2018 05:14:58 -0400 Received: from bombadil.infradead.org ([198.137.202.133]:50418 "EHLO bombadil.infradead.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754116AbeDZJOx (ORCPT ); Thu, 26 Apr 2018 05:14:53 -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-Transfer-Encoding :Content-Type:MIME-Version:References:Message-ID:Subject:Cc:To:From:Date: Sender:Reply-To: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=pUEPFVxHZBgEaRHOyPcpnkRkRs0HddhkCNOWa1GBK7I=; b=sAOKRNmVV/TKqbhJX4n3bx0hNU TBpHm4SOPRoy2AlK+oqQ+4cDZ4cqg+JI5H0PW0VtTZSIdEiZhSVA9KQ2PoOghnAj7MTWDb9MkU5Eo RxlZC2m/snerUco42szq/4RMCRKBKfo3kT2JeqHUp+0pMoZq7wGC0VWKx3ctMGAMCvscU7alsdqZI sv1h5kXVDQJ0ia/RoG9uqTWRz8Z0KNJ6mEtrubPMPwF3FfByBdiC0gItkhtpW6vROdeO6aOj2rwrr xWDftpuEWxtEOndHmLgcEWbYaPe0u2WRQQveHPLCxOuE/yd4qd9TzFIHOyiDbsmlygGxNjw5TIuOv QWMn/edQ==; 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 1fBczK-0002HD-PS; Thu, 26 Apr 2018 09:14:50 +0000 Received: by hirez.programming.kicks-ass.net (Postfix, from userid 1000) id 45E15203BFAE9; Thu, 26 Apr 2018 11:14:49 +0200 (CEST) Date: Thu, 26 Apr 2018 11:14:49 +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 Subject: Re: [PATCH v1] kthread/smpboot: Serialize kthread parking against wakeup Message-ID: <20180426091449.GA4082@hirez.programming.kicks-ass.net> References: <1524645199-5596-1-git-send-email-gkohli@codeaurora.org> <20180425200917.GZ4082@hirez.programming.kicks-ass.net> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: 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 09:34:36AM +0530, Kohli, Gaurav wrote: > On 4/26/2018 1:39 AM, Peter Zijlstra wrote: > > > On Wed, Apr 25, 2018 at 02:03:19PM +0530, Gaurav Kohli wrote: > > > diff --git a/kernel/smpboot.c b/kernel/smpboot.c > > > index 5043e74..c5c5184 100644 > > > --- a/kernel/smpboot.c > > > +++ b/kernel/smpboot.c > > > @@ -122,7 +122,45 @@ static int smpboot_thread_fn(void *data) > > > } > > > if (kthread_should_park()) { > > > + /* > > > + * Serialize against wakeup. > > * > > * Prior wakeups must complete and later wakeups > > * will observe TASK_RUNNING. > > * > > * This avoids the case where the TASK_RUNNING > > * store from ttwu() competes with the > > * TASK_PARKED store from kthread_parkme(). > > * > > * If the TASK_PARKED store looses that > > * competition, kthread_unpark() will go wobbly. > > > + */ > > > + raw_spin_lock(¤t->pi_lock); > > > __set_current_state(TASK_RUNNING); > > > + raw_spin_unlock(¤t->pi_lock); > > > preempt_enable(); > > > if (ht->park && td->status == HP_THREAD_ACTIVE) { > > > BUG_ON(td->cpu != smp_processor_id()); > > Does that work for you? > > We have given patch for testing, usually it takes around 2-3 days for > reproduction(we will update for the same). I only changed the comment; surely your compiler doesn't generate different code for that? I was asking if the proposed comment was good with you; but see my more recent email, that actually proposes a different fix. > > /* > > * A similar race is possible here, but loosing > > * the TASK_INTERRUPTIBLE store is harmless and > > * will make us go around the loop once more. > > */ > > Actually instead of race, i am seeing wakeup miss problem which is > very rare, if we take case of hotplug thread Yes, triggering these issues is tricky, no doubt about that. > > And of course, I suspect we actually want to use TASK_IDLE, smpboot > > threads don't want signals do they? But that probably ought to be a > > separate patch. > > Yes I agree, we can control race from here as well,? Please suggest > would below change be any help here: That is not what I suggested. I said the thing should use TASK_IDLE instead of TASK_INTERRUPTIBLE. Not change the location of it.