From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-10.9 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE, SPF_PASS,USER_AGENT_SANE_1 autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id DDE63C47082 for ; Wed, 26 May 2021 17:14:51 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id A23C8613BE for ; Wed, 26 May 2021 17:14:51 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org A23C8613BE Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=kernel.org Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:In-Reply-To:MIME-Version:References: Message-ID:Subject:Cc:To:From:Date:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=FfgdtP0lduu1qUerkZPsI1y5K0L8PyTX3zX6T+z3hag=; b=UmAhpJ7LfXfd5K wYwhwbrOQG7J4pOumob5lgb1kw3sLitVk5bBHgOwg2E7xXqavVJxuVEFMv/SmPebll2tUsZe/V2Vn zvbm0f1cqQE04eyR5difl/YFmxb1rUhifQBaqBNZU+jgpcNjUlFwYHAcuLoLKsDYQOpaM2ddqZudU jT/t2WSMdyET/xPAGD/KmRYWFaVjxsymkda3Gd+aeX+Hpxi6yXIs1NroiHp/3E9YKNxo6s3F1Ehet MdWHBqZ4W6jMMDADWDxOYfWWzrqqE0y/37xIwiP+OXHRmyL//kyii8ucGjiImcAu2oMPD7pDNikxU qSMgpZM0f01zt9fDxehw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1llx5E-00G0tM-GA; Wed, 26 May 2021 17:12:41 +0000 Received: from mail.kernel.org ([198.145.29.99]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1llw0D-00FaUb-6y for linux-arm-kernel@lists.infradead.org; Wed, 26 May 2021 16:03:26 +0000 Received: by mail.kernel.org (Postfix) with ESMTPSA id 1E8B861284; Wed, 26 May 2021 16:03:20 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1622045004; bh=brygyaZMme8W1VhWpvcS9FsnOYnmb8rPHENNvFQRLRM=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=uqwacT1bgi2y30ruYAfzKsbxd36BLQcdd8NtUaxp4vsDMZhKAXSNYD8hzBUiT9deM O5vDX7PehPAUYthTGZHHtPMKpFWDBFWSww927muxE1oMWy0gwaSbaSaoNFDlILbLNl DFQLmjrH5vnxE1MZTmxhI7944zkKGYAqqIE+m4aCKSkxyfp5Q2X0h5wVCtDZ7jV08i HKP5Ci2LLqi+j5xt7IOEVt2GfhBrQYtxwdz/aqK89L4VaBGfJ1VWa2bJ1mUjHxU6JK bbR0YIWG65rQ6MHBDeCJrz9YMHSI7oOwXryoWmvYGQQBHQh57S3hqLGCuDS5GU9Ei/ vytVMeqpVskbA== Date: Wed, 26 May 2021 17:03:18 +0100 From: Will Deacon To: Valentin Schneider Cc: linux-arm-kernel@lists.infradead.org, linux-arch@vger.kernel.org, linux-kernel@vger.kernel.org, Catalin Marinas , Marc Zyngier , Greg Kroah-Hartman , Peter Zijlstra , Morten Rasmussen , Qais Yousef , Suren Baghdasaryan , Quentin Perret , Tejun Heo , Johannes Weiner , Ingo Molnar , Juri Lelli , Vincent Guittot , "Rafael J. Wysocki" , Dietmar Eggemann , Daniel Bristot de Oliveira , kernel-team@android.com Subject: Re: [PATCH v7 01/22] sched: Favour predetermined active CPU as migration destination Message-ID: <20210526160317.GB19691@willie-the-truck> References: <20210525151432.16875-1-will@kernel.org> <20210525151432.16875-2-will@kernel.org> <877djlhhmb.mognet@arm.com> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <877djlhhmb.mognet@arm.com> User-Agent: Mutt/1.10.1 (2018-07-13) X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20210526_090325_327437_72DBBF81 X-CRM114-Status: GOOD ( 19.39 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org On Wed, May 26, 2021 at 12:14:20PM +0100, Valentin Schneider wrote: > On 25/05/21 16:14, Will Deacon wrote: > > diff --git a/kernel/sched/core.c b/kernel/sched/core.c > > index 5226cc26a095..1702a60d178d 100644 > > --- a/kernel/sched/core.c > > +++ b/kernel/sched/core.c > > @@ -1869,6 +1869,7 @@ static struct rq *move_queued_task(struct rq *rq, struct rq_flags *rf, > > struct migration_arg { > > struct task_struct *task; > > int dest_cpu; > > + const struct cpumask *dest_mask; > > struct set_affinity_pending *pending; > > }; > > > > @@ -1917,6 +1918,7 @@ static int migration_cpu_stop(void *data) > > struct set_affinity_pending *pending = arg->pending; > > struct task_struct *p = arg->task; > > int dest_cpu = arg->dest_cpu; > > + const struct cpumask *dest_mask = arg->dest_mask; > > struct rq *rq = this_rq(); > > bool complete = false; > > struct rq_flags rf; > > @@ -1956,12 +1958,8 @@ static int migration_cpu_stop(void *data) > > complete = true; > > } > > > > - if (dest_cpu < 0) { > > - if (cpumask_test_cpu(task_cpu(p), &p->cpus_mask)) > > - goto out; > > - > > - dest_cpu = cpumask_any_distribute(&p->cpus_mask); > > - } > > + if (dest_mask && (cpumask_test_cpu(task_cpu(p), dest_mask))) > > + goto out; > > > > IIRC the reason we deferred the pick to migration_cpu_stop() was because of > those insane races involving multiple SCA calls the likes of: > > p->cpus_mask = [0, 1]; p on CPU0 > > CPUx CPUy CPU0 > > SCA(p, [2]) > __do_set_cpus_allowed(); > queue migration_cpu_stop() > SCA(p, [3]) > __do_set_cpus_allowed(); > migration_cpu_stop() > > The stopper needs to use the latest cpumask set by the second SCA despite > having an arg->pending set up by the first SCA. Doesn't this break here? Yes, well spotted. I was so caught up with the hotplug race that I didn't even consider a straightforward SCA race. Hurumph. > I'm not sure I've paged back in all of the subtleties laying in ambush > here, but what about the below? I can't break it, but I'm also not very familiar with this code. Please can you post it as a proper patch so that I drop this from my series? Thanks, Will _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel