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=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 3E485C47088 for ; Wed, 26 May 2021 18:07:52 +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 EEC1D613D2 for ; Wed, 26 May 2021 18:07:51 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org EEC1D613D2 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=GIG3pNX8ebqWAHa2eVBP/gJKxxkBDaQky5q/ywIvkGk=; b=AMz0chHIFrclDR jO04NcxMCDm8OBB/YqApK9IS6uJBLwndfyTR8c8vXHJDtffugpib6Epkhjhr98Z/MXm3jR/7COefC kfHrDPPgOPLmOGZrCUl8qOXpvGrZcTlWwCLqzgc4Gi3UvoRcmekbm7E2su/I4cWdHgZt852wI/5YL q+wSOBztXQqSXjNIC4iEf8W24PqVGofuoz7CgqcbIJgeQQoLQwzshwJxalEHxBMvALfSWz0zU7WMx yyoZGOeG3ILbKjiT80yKzDRB8IJPj6GQAiKDrGe3Dd36qKO+kwcHFfoUzt/MSK5UbgYaRG0puIiXo NJGxLJ9BEbQtdsrTzpiA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1llxuQ-00GMaB-GB; Wed, 26 May 2021 18:05:35 +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 1llwv8-00FwnE-Dv for linux-arm-kernel@lists.infradead.org; Wed, 26 May 2021 17:02:17 +0000 Received: by mail.kernel.org (Postfix) with ESMTPSA id A78C8613D7; Wed, 26 May 2021 17:02:10 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1622048533; bh=GCTzDVbHhIB2dVSmWs+GdL224HTZFecYBcEfT7zK7IA=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=gYqblIvys8lw3GCSXlPEL2PYKMcev0OROB2qn9Wj8kynBUZ/fF72oEBS6FVqh25Rd Wl+R+5/zO+9k4vaGv+4dpmi1KjfrP4dCT6SxIuSyOWFCw4P8sU7dWYnkYLJAYLdpig j4MGc8JX7tDHtfZTdzmmN0qX5U7OWTJlPZEsdpoVh3T4IEF8Wacl6HU9rArjCz3v2h PGeaa2xslmuL27ULOUbz75vQBRWNEdXe2jqTtuSfyUE/8dgL5/Fl+mGHKTHhs1pu+H E6WrI4UY+Swaf48ho0/zMxr9nmXT3V7VqOFGyejLps4MF7NkkwhrhtNx50W+X5fYw1 2B2nh7481ezzA== Date: Wed, 26 May 2021 18:02:06 +0100 From: Will Deacon To: Peter Zijlstra 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: <20210526170206.GB19758@willie-the-truck> References: <20210525151432.16875-1-will@kernel.org> <20210525151432.16875-14-will@kernel.org> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: 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_100214_572787_2DDC9125 X-CRM114-Status: GOOD ( 16.28 ) 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 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. > I thought the intended semantics were somethings like: > > A - 0xff B > > restrict(0xf) // user: 0xff eff: 0xf > > sched_setaffinity(A, 0x3c) // user: 0x3c eff: 0xc > > relax() // user: NULL, eff: 0x3c If you go down this route you can get into _really_ weird situations where e.g. sys_sched_setaffinity() returns -EINVAL because the requested mask contains only 64-bit-only cores, yet we've updated the user mask. It also opens up some horrendous races between sched_setaffinity() and execve(), since the former can transiently set an invalid mask per the cpuset hierarchy. Will _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel