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=-14.1 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS 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 E6A28C47088 for ; Wed, 26 May 2021 16:32:56 +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 A145160FE3 for ; Wed, 26 May 2021 16:32:56 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org A145160FE3 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=infradead.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=N9wrOA2eloFmoKT3GY9/s5yPFpvIW/jAqJwW7frwU6c=; b=te+ReiO0znVcpJ hDcLXH+o4n6jzQpucWBWiUFqr8TK7aY9JGAn9jbxKZiQcj8CT+PLKD7or7054Sys90OB7Y1+CRk5Y n3LS9Aqi8D0tXnp5LDn0q0q4o/6UeX888Cq1xF55lUo5eIlf4rBG/X0FAaxkyx1qZej/PNHUgV8Yx BTXWgsNNWh3jGorr3qeSdqCqnJiUOAnvxIYMWh3oLfge6FiaUDDNhtQfGgBHZG3SW6J2vf4Pw4nsX /qaemwB/B0XVNpPFcIHw1olgdKTHNDASqtDu59xz7DgwPO+xZ065xZE9/mIF1kLRRH11FUy3NpvTZ a7jAH4UXQy9FUkytX//g==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1llwQD-00FkIE-DY; Wed, 26 May 2021 16:30:18 +0000 Received: from casper.infradead.org ([2001:8b0:10b:1236::1]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1llvGl-00FH5d-KM for linux-arm-kernel@bombadil.infradead.org; Wed, 26 May 2021 15:16:27 +0000 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=B480aaO2rxlrnIc+fI2c45cdJeBughiR9HhYUCJoqp4=; b=dkkSVZ57J19yhpw/Kd8ax12s27 wfbw3QtiaX0CKX2eY2/JpK1l/nzQqetSt7yExUXtufZ594v9dloXiYAg2tK60bwDotMfR4DSgeq1G CPR5iwtxLi9Rmcs4eoJc4uPB8YvWznp4BonvXm8PdSag2DPdpw7kxKhdz0K/jw5tsHhHpoZi9bUsP hbLhbE4RdBuPErMMvmOM4WyRSt/pItSzAKPWw/6oeO8jJv9gCGhf2WFDp5EdFoJTgAkNN/KI/uirv mw3M47EWfn4E1JXupcfmaip0BglBgabrba6ufnudJAGGIsdCvGGSDHhMrAEoaxOKO/IOJyVsTyzsd EofQrECQ==; 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 1llvGC-004dwG-QY; Wed, 26 May 2021 15:16:13 +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)) (Client did not present a certificate) by noisy.programming.kicks-ass.net (Postfix) with ESMTPS id C21EB30022A; Wed, 26 May 2021 17:15:51 +0200 (CEST) Received: by hirez.programming.kicks-ass.net (Postfix, from userid 1000) id A4CEF200D3A72; Wed, 26 May 2021 17:15:51 +0200 (CEST) Date: Wed, 26 May 2021 17:15:51 +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 10/22] sched: Reject CPU affinity changes based on task_cpu_possible_mask() Message-ID: References: <20210525151432.16875-1-will@kernel.org> <20210525151432.16875-11-will@kernel.org> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <20210525151432.16875-11-will@kernel.org> 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 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. _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel