Received: by 2002:a05:6a10:16a7:0:0:0:0 with SMTP id gp39csp1037473pxb; Fri, 13 Nov 2020 02:30:01 -0800 (PST) X-Google-Smtp-Source: ABdhPJwdNT9c82epFDUkgeIliqXouV8NUmXenfuy7ilUF8rpJPggfYw9BMSuC7r7x8W8oN1P9cpN X-Received: by 2002:a17:906:4d52:: with SMTP id b18mr1221176ejv.553.1605263401107; Fri, 13 Nov 2020 02:30:01 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1605263401; cv=none; d=google.com; s=arc-20160816; b=AzziFPg03DcCJdq1Bdokzb26RTvSAXlhYgPLHKZa94mNuQLtMY3d88iMu4cVaTTFpd VTLI3h0yAiCiRhdDwGT0DfNbSsKdB8dlFnH+sTqeBBIBvQcbliw6X89sjzND6Q3cZnL1 iHbwfDAwuhCabmacEYLk4nlcdsAqSGJr9kNK8Z97kEQJubP3mUYZaTzAUZkLvRK4/4kr KjJF/hfPaw3a11zOcubIvyhRuWBLUGIkuCANahkjWlK7dqn47u8qjZmnNSy0QQe88Qjk TjXXsLnynRk+lMa9D99TP33RhaCaI+OsTIx+Iu7Ux3Odyv8Y8SUWEkZthL3dTAPEUBBu fKQw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=d/KlS2pzfp8sOne97UF0Zm10zOHX7PS1VzOMej7apbY=; b=V4p4Hpkex2g42rTDkZjxX2t7xF9DJ7z2oqvO/O3mO0n955fGkRlDnrdL8PAflRUtEZ H17JR4xLmX+b1EcKoH5Co64lRmY1yaNYkTZj5CpN/KkVDGOtA8thr0CyHVeLyu6anUOt Y+moglfpXJncrwN+0rwWiPIbdP6QCvNdpKECJ6jps9Vv5VvfmgiLNd7Z74JbdfI96f9y 2X2C5/0X0MWnKtivgdWBRtjZwhGQTSAKJ7drLn3yztajCgEWPrLfjoCJ0ZvudQjS0X1L s2JjiB+OKEDkik7ndmCQLsSEjBkBTHbsxJ9YTK9tZxP8VvDtdsxmod1PtO96VWnDmzR7 5JnQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@infradead.org header.s=merlin.20170209 header.b=OzOcddny; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id bi24si6457747edb.452.2020.11.13.02.29.37; Fri, 13 Nov 2020 02:30:01 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@infradead.org header.s=merlin.20170209 header.b=OzOcddny; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726343AbgKMK2B (ORCPT + 99 others); Fri, 13 Nov 2020 05:28:01 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48672 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726237AbgKMK2A (ORCPT ); Fri, 13 Nov 2020 05:28:00 -0500 Received: from merlin.infradead.org (merlin.infradead.org [IPv6:2001:8b0:10b:1231::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6DFB0C0613D1 for ; Fri, 13 Nov 2020 02:28:00 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=merlin.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; bh=d/KlS2pzfp8sOne97UF0Zm10zOHX7PS1VzOMej7apbY=; b=OzOcddnySIP6GHq4GAmp22N1jM NxdbA1ix2l/H6Vhjsvmh5GKS/UxInVEUtH4MdnKDhIEdz5OLO6MKDvKKp3cBbCragW++/iee3Eefk eHrlmarf7mgpKQ6RYZYyGtiX4L8XzWAub6Yg/uCqRiKE60RsXET3ms3DSWQmLG72+woIFjxnPbfkh RWv1TJCejM5my7d0WiNQtLj3NrK99qCNAzL24IeCbcqYkO08ncmUdwKwKnCSpUgnlxP6YatiyfYIH ltH/LupG9dLf/DjTUUAX5wN66Ehsi5VeQm5j7WBMdVkmg/idozsRjpjJXf05iPhOhlaMHXhJiyk0Q BdTmRzlQ==; Received: from j217100.upc-j.chello.nl ([24.132.217.100] helo=noisy.programming.kicks-ass.net) by merlin.infradead.org with esmtpsa (Exim 4.92.3 #3 (Red Hat Linux)) id 1kdWIs-0001vI-D1; Fri, 13 Nov 2020 10:27:38 +0000 Received: from hirez.programming.kicks-ass.net (hirez.programming.kicks-ass.net [192.168.1.225]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by noisy.programming.kicks-ass.net (Postfix) with ESMTPS id E4B783003E1; Fri, 13 Nov 2020 11:27:34 +0100 (CET) Received: by hirez.programming.kicks-ass.net (Postfix, from userid 1000) id D12CB2BCDBFCC; Fri, 13 Nov 2020 11:27:34 +0100 (CET) Date: Fri, 13 Nov 2020 11:27:34 +0100 From: Peter Zijlstra To: Valentin Schneider Cc: Qian Cai , tglx@linutronix.de, mingo@kernel.org, linux-kernel@vger.kernel.org, bigeasy@linutronix.de, qais.yousef@arm.com, swood@redhat.com, juri.lelli@redhat.com, vincent.guittot@linaro.org, dietmar.eggemann@arm.com, rostedt@goodmis.org, bsegall@google.com, mgorman@suse.de, bristot@redhat.com, vincent.donnefort@arm.com, tj@kernel.org, ouwen210@hotmail.com Subject: Re: [PATCH v4 10/19] sched: Fix migrate_disable() vs set_cpus_allowed_ptr() Message-ID: <20201113102734.GE2628@hirez.programming.kicks-ass.net> References: <20201023101158.088940906@infradead.org> <20201023102346.921768277@infradead.org> <8b62fd1ad1b18def27f18e2ee2df3ff5b36d0762.camel@redhat.com> <13786aa5a5fc958708ef1182c885d1a574449d99.camel@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, Nov 12, 2020 at 07:31:12PM +0000, Valentin Schneider wrote: > I think what is happening here is: > > affine_move_task() > // task_running() case > stop_one_cpu() > wait_for_completion(&pending->done); > > and this is !PREEMPT, so the stopper can very well hit: > > migration_cpu_stop() > // Task moved between unlocks and scheduling the stopper > task_rq(p) != rq && > // task_running() case > dest_cpu >= 0 > > => no complete_all(), ever :( Damn... > diff --git a/kernel/sched/core.c b/kernel/sched/core.c > index 02076e6d3792..fad0a8e62aca 100644 > --- a/kernel/sched/core.c > +++ b/kernel/sched/core.c > @@ -1923,7 +1923,7 @@ static int migration_cpu_stop(void *data) > else > p->wake_cpu = dest_cpu; > > - } else if (dest_cpu < 0) { > + } else if (dest_cpu < 0 || pending) { > /* > * This happens when we get migrated between migrate_enable()'s > * preempt_enable() and scheduling the stopper task. At that > @@ -1933,6 +1933,17 @@ static int migration_cpu_stop(void *data) > * more likely. > */ > > + /* > + * The task moved before the stopper got to run. We're holding > + * ->pi_lock, so the allowed mask is stable - if it got > + * somewhere allowed, we're done. > + */ > + if (pending && cpumask_test_cpu(task_cpu(p), p->cpus_ptr)) { > + p->migration_pending = NULL; > + complete = true; > + goto out; > + } > + > /* > * When this was migrate_enable() but we no longer have an > * @pending, a concurrent SCA 'fixed' things and we should be Agreed, this is very clearly a missing case and the proposed solution seems straight forward enough; but I'm struggling to convince my sleep deprived brain we're actually complete now. I'll continue staring at it a little more. Could you make it into a proper patch?