Received: by 2002:a05:6a10:8c0a:0:0:0:0 with SMTP id go10csp328574pxb; Thu, 25 Feb 2021 03:49:02 -0800 (PST) X-Google-Smtp-Source: ABdhPJx9OV4hpDZHr7jokSAAA97EuaazgsgAesiLEKZ0xA84qOOBdIEmoQ1gyCeymxnj3PKR8EH2 X-Received: by 2002:a17:906:f891:: with SMTP id lg17mr1907726ejb.69.1614253741807; Thu, 25 Feb 2021 03:49:01 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1614253741; cv=none; d=google.com; s=arc-20160816; b=aAun3sJjxaaov57nRzUuqNg1trWXa01frhz43siJetjRNUx4I93wMIJb3s4vV7t+pN IGyp58nQHBvOaDhMbS2VQr4N9yTBD3CaAyV1dOBTNwTPQ03VIXLP4MrF354SsVK6Qeop rY9Iyi+RBo0xWekA2hgqkpElPa7A8FgDkxdpA7OAyug9K5t9kXLyWkJzxK8Kht15RDM6 lGzx7vDH/Bx+50XtOdrKcGMd/RmhNUPWjwa33cNTz/DcjXIjFGJvksMwXpduvL4nibkJ eIf+m6h/qgSYN4/wAff+UogL16cHw1peyK+kuRadgXCKgRbLMiD4pZiHZFJZBl8NuJqh BgXg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:message-id:date:user-agent :references:in-reply-to:subject:cc:to:from; bh=tq5UUVn//tTorLCnsjibVUTuwKDwz9x525nbzurdBQ8=; b=y6ic8wbNGp2Rd8m8drQOIQwUJtPnBUDkG94kqWIucLYV8MT02mkzAxC5pVAZIrueuf KUWKsNLCjE/POTuOTtqx3YB91uFWoXoM+xXyFOG110f+GNNhSGnpMs4awfFBVs0br+LM konqztzeq6NH6GkQG2t+bEktY3NHnNorr0gJZGOXOnVa5F26o50KGzQ7vBXcdh5picO5 Uq5rmOx92Nm+zGehLEKJEWvAgk036ax2YUVqmmAoqTBZ4+2roTBNyw5J2JAKSFfuJikq XGEc6TUTHml47NkplngZfBcWQNnl9aCmRvCC9rcAOyUA9wB7BFyB3agMEGpQmd8lYKL+ 5mjg== ARC-Authentication-Results: i=1; mx.google.com; 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id hp10si3060523ejc.168.2021.02.25.03.48.39; Thu, 25 Feb 2021 03:49: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; 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233916AbhBYLMo (ORCPT + 99 others); Thu, 25 Feb 2021 06:12:44 -0500 Received: from foss.arm.com ([217.140.110.172]:54204 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233594AbhBYLLs (ORCPT ); Thu, 25 Feb 2021 06:11:48 -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 788771063; Thu, 25 Feb 2021 03:11:02 -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 585CE3F73D; Thu, 25 Feb 2021 03:11:01 -0800 (PST) From: Valentin Schneider To: Peter Zijlstra Cc: Ingo Molnar , Thomas Gleixner , Vincent Guittot , Mel Gorman , Dietmar Eggemann , linux-kernel@vger.kernel.org, Andi Kleen Subject: Re: [PATCH 2/6] sched: Simplify migration_cpu_stop() In-Reply-To: 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: Thu, 25 Feb 2021 11:10:56 +0000 Message-ID: MIME-Version: 1.0 Content-Type: text/plain Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 25/02/21 09:45, Peter Zijlstra wrote: > On Wed, Feb 24, 2021 at 03:34:36PM +0000, Valentin Schneider wrote: >> 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. > > Right, so I didn't really think too hard about the intermediate states, > given it's all pretty buggered until at least 5. But yeah, double > complete is harmless. > > Specifically, the refcount the stopper has should avoid the stack from > getting released. Aye that should be fine, it really was just the double complete which I was unsure about.