Received: by 2002:a05:6a10:8c0a:0:0:0:0 with SMTP id go10csp271329pxb; Thu, 25 Feb 2021 01:58:23 -0800 (PST) X-Google-Smtp-Source: ABdhPJyb1oJW7aEeczhWEw1Rjs+R0zcytmNEQJha1HdsIWgFoiM494cajKjC5qL54a4Pd9xIReUv X-Received: by 2002:a17:906:4ec5:: with SMTP id i5mr1846328ejv.395.1614247103745; Thu, 25 Feb 2021 01:58:23 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1614247103; cv=none; d=google.com; s=arc-20160816; b=ESw9Tk7VIESOl62mh9oq6sMpB8XFNOG1xAhNthB755WKUO/FyaJYrbyP81Zwouy/eE 6+pmnUPhM14qZX61Xqz0BZaKdlJx700SV/nirAJscQRgwcr5tzPnNzqS5lQNXwg3HZLE F5Huyi8HVin4UjCPEX7HlUBy8fSlRg4dwB3yyMPJc/FvJVnHdi1GnusujYpksbXeGJDh 52V9r7pn1j/JKkFJjigh0xn0X6AFbgeZTwjOuQuZT33Hzz7gHLmgf24HbjjA54i6CxxN qUmk/aZ9PxEKR4S8EJXL+axMmKX/7ldnq+Yx9eHs2nLQwX6HniYLkB1k7paD85S+7Wv9 XEUQ== 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=0chbbTizAM4s+RnstfoLBGU6yV6ryXMRj6cwHmxWsO4=; b=x5BdDLP2UZfzPdPcf20xrUyLD/evaW23cKalAoglkiZgZa/6BCFTfwLBbG85J9PUd4 CQrktuihdY8lK9x68lFYHGWai2mzU7IALn8iOZdGZfANrvKN0137k8XDgTO6SivAhCa9 pTUQr7FmcEmxXkdJV/MUFZblV0ofXlD4PJipqHJc/c8/T7UtvrtrPwKrgCJQ5hvbCZmL HyvBQmuHIHVH/o3TaKOsj8OcQZtq7c3EIOXGu1FPoXyAzeSMojTx8bRiC7DIOk9mhzBE a3lG3gQaZlihLEHMLbKysabOQ3znb5b1HbreKAXU8u5Df72ajr0gqFMmX5NeQ90972Sr jQ2g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@infradead.org header.s=casper.20170209 header.b=k6HHV2W7; 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 s26si3150306edr.515.2021.02.25.01.58.01; Thu, 25 Feb 2021 01:58:23 -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=casper.20170209 header.b=k6HHV2W7; 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 S235972AbhBYIrM (ORCPT + 99 others); Thu, 25 Feb 2021 03:47:12 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36566 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235168AbhBYIrK (ORCPT ); Thu, 25 Feb 2021 03:47:10 -0500 Received: from casper.infradead.org (casper.infradead.org [IPv6:2001:8b0:10b:1236::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A2214C061574 for ; Thu, 25 Feb 2021 00:46:30 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=casper.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=0chbbTizAM4s+RnstfoLBGU6yV6ryXMRj6cwHmxWsO4=; b=k6HHV2W7YjVTYREl888DFS+XNX 35rEWttPio2L2lB3zTCqNYH3fmBHvBgodCdCtGafbTYaw5YS5yTmGYBu5ZtTnyWgQ/bl/ry+9EIse wBSSNQF+aawn4wXBu75JuL/5XQH6cHKGWmY49y/d28RLs73Nl7RwnfY7DorHIjsfEDkNLhydVmFvJ U6KU6CeZzCD5+g6lx6D3YS65Y3fzjDwG+dqVPOxvFKo8yU0qU9na7LeLDjBs6ziEJ9CErnZNjaRmN YRFrP7vu5E0gWOVHsxXpuYMXthRDDvNJAtEmPepkIuZJTvgZ6mRJx+KqTqU4Fw9PDiAv7E1QJWVxz aMDyNsrg==; Received: from j217100.upc-j.chello.nl ([24.132.217.100] helo=noisy.programming.kicks-ass.net) by casper.infradead.org with esmtpsa (Exim 4.94 #2 (Red Hat Linux)) id 1lFCHR-00ATzC-LB; Thu, 25 Feb 2021 08:46:00 +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 2C1E53010D2; Thu, 25 Feb 2021 09:45:53 +0100 (CET) Received: by hirez.programming.kicks-ass.net (Postfix, from userid 1000) id E91CF20BC9281; Thu, 25 Feb 2021 09:45:52 +0100 (CET) Date: Thu, 25 Feb 2021 09:45:52 +0100 From: Peter Zijlstra To: Valentin Schneider 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() Message-ID: References: <20210224122439.176543586@infradead.org> <20210224131355.430014682@infradead.org> 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 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.