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.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS 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 4ECD3C4708A for ; Thu, 27 May 2021 07:57:21 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 2C66761417 for ; Thu, 27 May 2021 07:57:21 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235297AbhE0H6v (ORCPT ); Thu, 27 May 2021 03:58:51 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42710 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232240AbhE0H6R (ORCPT ); Thu, 27 May 2021 03:58:17 -0400 Received: from desiato.infradead.org (desiato.infradead.org [IPv6:2001:8b0:10b:1:d65d:64ff:fe57:4e05]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D7681C06138B; Thu, 27 May 2021 00:56:42 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=desiato.20200630; 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=r7vS+Qu0ROyOXMOHwL+bMWAA8km2aB6VnaLoAAsQzvU=; b=rXSRfMMSiXLXqF/ssBC0ntassy pBpDW4nGdTQ2Xz1vZMDozyyWzGu3DbFP9ZgeW5EdpMU82Y3+MolU/cPL2oeGpjHMSMraxNL+VsxGc DAhxXseMR1/30G5dAtNqb43s0YqemFdlRbEJr9Wvj3y4wNxSV6JadEmcdblLpYiYhBtMc0HaecQxb yXCfk3zXT9RqvVLBguKM/xUQxVTr+FSSlTp1pLPPZzMP7b5hxljnIMoE365EIKsDLjmduQ9WsKOuN ctomzDxTCQh4EDj9T98eqyYVYiVSOIjgTojxhz/2bC38u2UIEJd9M34oGHecq56mVDedMCABuMF0P X8w9r0lA==; Received: from j217100.upc-j.chello.nl ([24.132.217.100] helo=noisy.programming.kicks-ass.net) by desiato.infradead.org with esmtpsa (Exim 4.94.2 #2 (Red Hat Linux)) id 1lmAsS-000wyY-RR; Thu, 27 May 2021 07:56:31 +0000 Received: from hirez.programming.kicks-ass.net (hirez.programming.kicks-ass.net [192.168.1.225]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (Client did not present a certificate) by noisy.programming.kicks-ass.net (Postfix) with ESMTPS id ACD7F300202; Thu, 27 May 2021 09:56:30 +0200 (CEST) Received: by hirez.programming.kicks-ass.net (Postfix, from userid 1000) id 923102C6C99AE; Thu, 27 May 2021 09:56:30 +0200 (CEST) Date: Thu, 27 May 2021 09:56:30 +0200 From: Peter Zijlstra To: Will Deacon Cc: linux-arm-kernel@lists.infradead.org, linux-arch@vger.kernel.org, linux-kernel@vger.kernel.org, Catalin Marinas , Marc Zyngier , Greg Kroah-Hartman , 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 13/22] sched: Allow task CPU affinity to be restricted on asymmetric systems Message-ID: References: <20210525151432.16875-1-will@kernel.org> <20210525151432.16875-14-will@kernel.org> <20210526170206.GB19758@willie-the-truck> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20210526170206.GB19758@willie-the-truck> Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, May 26, 2021 at 06:02:06PM +0100, Will Deacon wrote: > On Wed, May 26, 2021 at 06:30:08PM +0200, Peter Zijlstra wrote: > > On Tue, May 25, 2021 at 04:14:23PM +0100, Will Deacon wrote: > > > @@ -2426,20 +2421,166 @@ static int __set_cpus_allowed_ptr(struct task_struct *p, > > > > > > __do_set_cpus_allowed(p, new_mask, flags); > > > > > > - return affine_move_task(rq, p, &rf, dest_cpu, flags); > > > + if (flags & SCA_USER) > > > + release_user_cpus_ptr(p); > > > + > > > + return affine_move_task(rq, p, rf, dest_cpu, flags); > > > > > > out: > > > - task_rq_unlock(rq, p, &rf); > > > + task_rq_unlock(rq, p, rf); > > > > > > return ret; > > > } > > > > So sys_sched_setaffinity() releases the user_cpus_ptr thingy ?! How does > > that work? > > Right, I think if the task explicitly changes its affinity then it makes > sense to forget about what it had before. It then behaves very similar to > CPU hotplug, which is the analogy I've been trying to follow: if you call > sched_setaffinity() with a mask containing offline CPUs then those CPUs > are not added back to the affinity mask when they are onlined. Oh right, crap semantics all the way down :/ I always forget how horrible they are. You're right though; this is consistent with the current mess.