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=-8.8 required=3.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE, SPF_PASS autolearn=ham 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 13271C43381 for ; Wed, 24 Feb 2021 15:49:27 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id B061A64EDB for ; Wed, 24 Feb 2021 15:49:26 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236204AbhBXPr7 (ORCPT ); Wed, 24 Feb 2021 10:47:59 -0500 Received: from foss.arm.com ([217.140.110.172]:36876 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231942AbhBXPfl (ORCPT ); Wed, 24 Feb 2021 10:35:41 -0500 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 47BDE31B; Wed, 24 Feb 2021 07:34:43 -0800 (PST) Received: from e113632-lin (e113632-lin.cambridge.arm.com [10.1.194.46]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 102123F70D; Wed, 24 Feb 2021 07:34:41 -0800 (PST) From: Valentin Schneider To: Peter Zijlstra , Ingo Molnar , Thomas Gleixner Cc: Vincent Guittot , Mel Gorman , Dietmar Eggemann , linux-kernel@vger.kernel.org, peterz@infradead.org, Andi Kleen Subject: Re: [PATCH 2/6] sched: Simplify migration_cpu_stop() In-Reply-To: <20210224131355.430014682@infradead.org> References: <20210224122439.176543586@infradead.org> <20210224131355.430014682@infradead.org> User-Agent: Notmuch/0.21 (http://notmuchmail.org) Emacs/26.3 (x86_64-pc-linux-gnu) Date: Wed, 24 Feb 2021 15:34:36 +0000 Message-ID: MIME-Version: 1.0 Content-Type: text/plain Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 24/02/21 13:24, Peter Zijlstra wrote: > @@ -1950,31 +1931,20 @@ static int migration_cpu_stop(void *data > goto out; > > if (pending) { > - p->migration_pending = NULL; > + if (p->migration_pending == pending) > + p->migration_pending = NULL; > complete = true; > } > > - /* migrate_enable() -- we must not race against SCA */ > - if (dest_cpu < 0) { > - /* > - * When this was migrate_enable() but we no longer > - * have a @pending, a concurrent SCA 'fixed' things > - * and we should be valid again. Nothing to do. > - */ > - if (!pending) { > - WARN_ON_ONCE(!cpumask_test_cpu(task_cpu(p), &p->cpus_mask)); > - goto out; > - } > - This is fixed by 5+6, but at this patch I think you can have double completions - I thought this was an issue, but briefly looking at completion stuff it might not. In any case, consider: task_cpu(p) == Y SCA(p, X); SCA(p, Y); SCA(p, Y) will uninstall SCA(p, X)'s pending and complete. migration/Y kicked by SCA(p, X) will grab arg->pending, which is still SCA(p, X)'s pending and also complete. > + if (dest_cpu < 0) > dest_cpu = cpumask_any_distribute(&p->cpus_mask); > - } > > if (task_on_rq_queued(p)) > rq = __migrate_task(rq, &rf, p, dest_cpu); > else > p->wake_cpu = dest_cpu; > > - } else if (dest_cpu < 0 || pending) { > + } else if (pending) { > /* > * This happens when we get migrated between migrate_enable()'s > * preempt_enable() and scheduling the stopper task. At that