Received: by 2002:a05:6a10:f347:0:0:0:0 with SMTP id d7csp1303512pxu; Thu, 17 Dec 2020 07:03:34 -0800 (PST) X-Google-Smtp-Source: ABdhPJyEvXkhi+zWK1pA4kOUb/E5zuOZ1+y+mAqzSZawoYSgFAkyMtRYazzo8nbyO5DgXCYdF5Z9 X-Received: by 2002:a50:e848:: with SMTP id k8mr24458029edn.77.1608217413942; Thu, 17 Dec 2020 07:03:33 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1608217413; cv=none; d=google.com; s=arc-20160816; b=s245FOuH2NkdpH76/B1a9Te5yljBnavNLKnHu6YZoEkpX/h/75QKX96oqLMF7rOk5U I+UHDsa33rQjYAq//j12jfniwmU5FyVeBm8oeuXmtQaYklfx1NupgK48ixCRPEEhI6VR IPU+0VnpMeESzb+l2BGUcMf6PLSbKZQdUpNRFskrP/YLTL4eNEzrhyioFtfTlGs2U/NM eba7lM6I/EJtpmT81xSH12sTCUMgXQcj4jCGT+ahIE7TSfd0u+YKHnhpi4ckduBLQK5G RFGFnqQz0CoqSr2LfBuNdwDi+Whm2Zke3TRTT7Actzug33EDWzmYBKM8OCsAzKF/Lv2S 6AHg== 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; bh=TbwLLp4q0Z02fyvSdl5vi0k30kJxpT7wuPYzAe1LIww=; b=LLSSX5+CNvtn7juGsb2B0F8mvNaRaMhlSgPMmN7vrFh1a5Ryje64coaD8yDbA9ltgv E43GTFHGDz2IMgg1lPc+9OtFP0u7FnlCcGNzmTC1/JCAPdRixlE/vrwP4p0q4OmN8912 vwCr6Pc22WfhqX6U4vRz5yHiURU/QIaNsaws2YZur9CY77rE9PMpCbF44E7sg3oG7Cmn m6odxENk+O3kt+92RtVIdXSgxDDE3/GOV9hsPZCB4AiN9kLfdUPsfG7zQiF6wGGWFM2R NiXFNnXdGp9lpoBNJGu/3GlhArhCfRkDlSbxIxDvm7N/wK4wFTSNomV9WTHb3TnPCO2t ZWTg== ARC-Authentication-Results: i=1; mx.google.com; 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id gs31si2543729ejc.337.2020.12.17.07.03.09; Thu, 17 Dec 2020 07:03:33 -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; 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728668AbgLQPBj (ORCPT + 99 others); Thu, 17 Dec 2020 10:01:39 -0500 Received: from foss.arm.com ([217.140.110.172]:40786 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728086AbgLQPBj (ORCPT ); Thu, 17 Dec 2020 10:01:39 -0500 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 6A48130E; Thu, 17 Dec 2020 07:00:53 -0800 (PST) Received: from e107158-lin.cambridge.arm.com (e107158-lin.cambridge.arm.com [10.1.194.78]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id F036B3F66B; Thu, 17 Dec 2020 07:00:50 -0800 (PST) Date: Thu, 17 Dec 2020 15:00:48 +0000 From: Qais Yousef To: Peter Zijlstra Cc: Will Deacon , 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 , Suren Baghdasaryan , Quentin Perret , Tejun Heo , Li Zefan , Johannes Weiner , Ingo Molnar , Juri Lelli , Vincent Guittot , kernel-team@android.com Subject: Re: [PATCH v5 07/15] cpuset: Don't use the cpu_possible_mask as a last resort for cgroup v1 Message-ID: <20201217150048.d6enq5hhchvh32hz@e107158-lin.cambridge.arm.com> References: <20201208132835.6151-1-will@kernel.org> <20201208132835.6151-8-will@kernel.org> <20201217121552.ds7g2icvqp5nvtha@e107158-lin.cambridge.arm.com> <20201217134401.GY3040@hirez.programming.kicks-ass.net> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: <20201217134401.GY3040@hirez.programming.kicks-ass.net> Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 12/17/20 14:44, Peter Zijlstra wrote: > On Thu, Dec 17, 2020 at 12:15:52PM +0000, Qais Yousef wrote: > > On 12/08/20 13:28, Will Deacon wrote: > > > If the scheduler cannot find an allowed CPU for a task, > > > cpuset_cpus_allowed_fallback() will widen the affinity to cpu_possible_mask > > > if cgroup v1 is in use. > > > > > > In preparation for allowing architectures to provide their own fallback > > > mask, just return early if we're not using cgroup v2 and allow > > > select_fallback_rq() to figure out the mask by itself. > > > > > > Cc: Li Zefan > > > Cc: Tejun Heo > > > Cc: Johannes Weiner > > > Reviewed-by: Quentin Perret > > > Signed-off-by: Will Deacon > > > --- > > > kernel/cgroup/cpuset.c | 6 ++++-- > > > 1 file changed, 4 insertions(+), 2 deletions(-) > > > > > > diff --git a/kernel/cgroup/cpuset.c b/kernel/cgroup/cpuset.c > > > index 57b5b5d0a5fd..e970737c3ed2 100644 > > > --- a/kernel/cgroup/cpuset.c > > > +++ b/kernel/cgroup/cpuset.c > > > @@ -3299,9 +3299,11 @@ void cpuset_cpus_allowed(struct task_struct *tsk, struct cpumask *pmask) > > > > > > void cpuset_cpus_allowed_fallback(struct task_struct *tsk) > > > { > > > + if (!is_in_v2_mode()) > > > + return; /* select_fallback_rq will try harder */ > > > + > > > rcu_read_lock(); > > > - do_set_cpus_allowed(tsk, is_in_v2_mode() ? > > > - task_cs(tsk)->cpus_allowed : cpu_possible_mask); > > > + do_set_cpus_allowed(tsk, task_cs(tsk)->cpus_allowed); > > > > Why is it safe to return that for cpuset v2? > > v1 > > Because in that case it does cpu_possible_mask, which, if you look at > select_fallback_rq(), is exactly what happens when cpuset 'fails' to > find a candidate. > > Or at least, that's how I read the patch. Okay I can see that if v2 has effectively empty mask for the 32bit tasks, then we'll fallback to the 'possible' switch case where we set task_cpu_possible_mask(). But how about when task_cs(tsk)->cpus_allowed contains partially invalid cpus? The search for a candidate cpu will return a correct dest_cpu, but the actual cpu_mask of the task will contain invalid cpus that could be picked up later, no? Shouldn't we cpumask_and(mask, task_cs(tsk)->cpus_allowed, task_cpu_possible_mask()) to remove those invalid cpus? Thanks -- Qais Yousef