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=-15.9 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,INCLUDES_CR_TRAILER,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 8F3A0C47089 for ; Wed, 26 May 2021 17:23:06 +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 59A10613C7 for ; Wed, 26 May 2021 17:23:04 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 59A10613C7 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=PzgtwfeZvo7eGh/J4wE+UhjxkoB+zifKlCHXVCHKVrY=; b=YTQD1jPPknZNlH RgUe5I7dUchxtEfaemgDnT0OcTTaEi4kQshVw0bdKg1NKLNicOobD3hYXsvkr2lPvllaRiN7xLaTR 3yqAKxyINlytGx29+7a6fxJ51mf5DwSJf+KX8qzT3U/VjyI+6tAjydlcNwalQrl3wA9J4R5VEV9LO sJ4SotEfpHD3+98HRmshnznzf1smBPwVfdwrZiPVsTDiRS/Du8BfYN08o7uDJOTJW+GY5ZoRqdWEr wJ3pehFqgD9tFTjwNGuIcNARR27ZX5CxdvGG36AuVMqtwZmjcUoOoAPpfmIaxHeifUnCJ7PxCEYyo bYo5jTesVbFvk6dBFGcQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1llxD8-00G3yw-3U; Wed, 26 May 2021 17:20:51 +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 1llw9Q-00Fdrb-Ch for linux-arm-kernel@lists.infradead.org; Wed, 26 May 2021 16:12:57 +0000 Received: by mail.kernel.org (Postfix) with ESMTPSA id C7E4F611BE; Wed, 26 May 2021 16:12:52 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1622045575; bh=Lpj06ByCJmTxPWA4x0Oyba4e2Wlf4pynAXzKIJbruZI=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=mEBW4cmZTsN62rBVHYLfrVtCPnifgwsBV3ZCNcKdb20TQOulcn8BYboc5IsWdQ3/4 4KfVhE6HjNj91vCzYxvCaqh4MdYHyL1mUAEVeV+te/IsXinEpwhBb7J+JCm/J8mZ38 4OBP3BI6GJG8L1yXGVxIymXYBB5Bri5n43V2sIHu6jY7WNFktCa4eYP0d7wiFN2ljb kjKWwbOuNK3qdDxgX9sFHOn2c/G9tOe6egcPfvwpkmy8eNdX9fJ62iIwzxqNuo0Vsl uK83iTEg5j9iYCGFQdOyy+enF2fN6RrF0KpH16UQ+A2XcwRyYTXu5goBw7tVWRaXLl t60xbZ5ma10AQ== Date: Wed, 26 May 2021 17:12:49 +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 10/22] sched: Reject CPU affinity changes based on task_cpu_possible_mask() Message-ID: <20210526161249.GD19691@willie-the-truck> References: <20210525151432.16875-1-will@kernel.org> <20210525151432.16875-11-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_091256_492066_D905C885 X-CRM114-Status: GOOD ( 26.43 ) 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 05:15:51PM +0200, Peter Zijlstra wrote: > On Tue, May 25, 2021 at 04:14:20PM +0100, Will Deacon wrote: > > Reject explicit requests to change the affinity mask of a task via > > set_cpus_allowed_ptr() if the requested mask is not a subset of the > > mask returned by task_cpu_possible_mask(). This ensures that the > > 'cpus_mask' for a given task cannot contain CPUs which are incapable of > > executing it, except in cases where the affinity is forced. > > > > Reviewed-by: Quentin Perret > > Signed-off-by: Will Deacon > > --- > > kernel/sched/core.c | 4 ++++ > > 1 file changed, 4 insertions(+) > > > > diff --git a/kernel/sched/core.c b/kernel/sched/core.c > > index 00ed51528c70..8ca7854747f1 100644 > > --- a/kernel/sched/core.c > > +++ b/kernel/sched/core.c > > @@ -2346,6 +2346,7 @@ static int __set_cpus_allowed_ptr(struct task_struct *p, > > u32 flags) > > { > > const struct cpumask *cpu_valid_mask = cpu_active_mask; > > + const struct cpumask *cpu_allowed_mask = task_cpu_possible_mask(p); > > unsigned int dest_cpu; > > struct rq_flags rf; > > struct rq *rq; > > @@ -2366,6 +2367,9 @@ static int __set_cpus_allowed_ptr(struct task_struct *p, > > * set_cpus_allowed_common() and actually reset p->cpus_ptr. > > */ > > cpu_valid_mask = cpu_online_mask; > > + } else if (!cpumask_subset(new_mask, cpu_allowed_mask)) { > > + ret = -EINVAL; > > + goto out; > > } > > So what about the case where the 32bit task is in-kernel and in > migrate-disable ? surely we ought to still validate the new mask against > task_cpu_possible_mask. That's a good question. Given that 32-bit tasks in the kernel are running in 64-bit mode, we can actually tolerate them moving around arbitrarily as long as they _never_ try to return to userspace on a 64-bit-only CPU. I think this should be the case as long as we don't try to return to userspace with migration disabled, no? Will _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel