From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from SN4PR0501CU005.outbound.protection.outlook.com (mail-southcentralusazon11011047.outbound.protection.outlook.com [40.93.194.47]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id B93313176E4 for ; Wed, 8 Apr 2026 17:57:35 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.93.194.47 ARC-Seal:i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1775671057; cv=fail; b=DlGiTlMzr4mKqLqXeh3RrKGCWfDjuSXaqW6WZDSJ2osAeqJQz/VRjXPfXEhHtD9EUYzlUNAM3+XuDSfefG2kRmG+RTnqZc8MxA6XeBNhWxVr6zfCE5ee82+qYMn3QSaklPbxOrf+pPsDYl0MV0gZlNXbpbaN3PYBrfsM1Y/q34g= ARC-Message-Signature:i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1775671057; c=relaxed/simple; bh=jchgqBg5NhTjOI6OuJ/1ZheI5ayXsrZR0t6HakJa6e8=; h=Date:From:To:Cc:Subject:Message-ID:References:Content-Type: Content-Disposition:In-Reply-To:MIME-Version; b=mhqM0jC9+UPD+RrDUSUXqkswZrCwmFrsANNTnwLjW/Ca1HVOgF722lv8E8u1eAm/+5dJwCNJmFNm95dsjoEBB2qJHasII3h3z9Lc8CnklOY7EcZ6Xz+nLLUEkDYCQaYshunab6pS3VsBQqhju4adSGkPkmIWT1SgawhZ3ezK+Tg= ARC-Authentication-Results:i=2; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=nvidia.com; spf=fail smtp.mailfrom=nvidia.com; dkim=pass (2048-bit key) header.d=Nvidia.com header.i=@Nvidia.com header.b=uRofgA50; arc=fail smtp.client-ip=40.93.194.47 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=nvidia.com Authentication-Results: smtp.subspace.kernel.org; spf=fail smtp.mailfrom=nvidia.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=Nvidia.com header.i=@Nvidia.com header.b="uRofgA50" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=KXoVDqIEL/W+QXWdVbrrJHNa8JvUaoXEHVim6XjXu/3y0rY8mZnC0xU/NNhOsHstvxHh6F4sY75SSfHmmRaX3RT0KCUO6l/Rb7oR/FE2c3pFOb+mDwCFwn3f7Ro8AHUltBcqRIKsqT9zjQB+9cf7cNyz4tETL4dTV9//vwvJ6+jnTLgUxHmac5t2kHUiMHR1Pvf19qcJGNpHOo6+ZyJtesO3B/w6l0IKccqQ15biNkZVZ616/0RS8CyYaM355+VnRddtP+Ug4xP0u7v97zlocUjsQmTPq65GAIq4+g4hKlfnS3m/K7bU6yU/AqHo/NakCsqzAr38CWaToehuhgmU+Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=sQdK4NruDA57A4ZKbxXfjxvaLvRjPco/s03Cp+Y9GJk=; b=j7/GeQlosi6z/hVOyGKED8wzlYMfI85gYobcLjeYqTaiwJ+SkRoXzG3wJxwmVcfTZ3GF0m+ZYSpKHwSHPeOVMxoztcr2v0yWmk/3kg1kYmqPyxqxgcgL3Oc6pPV8kFYuZ5LPpEKoZufjXyljfYU0Hr/QTBmDXXivZWIeEQhdY/RPqreAeSkClZLsDOHz9BFjxC3vchCF2144GHtIbky3jY0sstIx3HLsfE94s4DYhsDs1KSwi6gSZ2R9+m+ECsGjyAKz5Qn8NmwFYJgr9q371FZwRFHNNVRhPIWKHYowrO6yKDhCREqRo3XC8NoOMAJYAPGtlAB6W85BGCnHeBhFbQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=nvidia.com; dmarc=pass action=none header.from=nvidia.com; dkim=pass header.d=nvidia.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=Nvidia.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=sQdK4NruDA57A4ZKbxXfjxvaLvRjPco/s03Cp+Y9GJk=; b=uRofgA500xmGaiiP0ITZ8YsT3nhNDnM6MCKk6Jjo8IL+bNgd0Q+0mAysUjllmA/Q8O1hcnuLudPyMmwGvHBX3wwZw1wPrcthk9/HWpqNFl+mNBZnkUUIl3rJjZpi9ijG25kx+kzBfVpVTjgbcwA9rFT7QiZc/6AnJ/lG/fVT9HrIEe0I54rNuTRZVKmMemerBGHRlx6g9PqXHWwWAhhI7iDtbmH7ofsYUytii/NgUp2jMiY6OsoT/ed/5Hp9MmkWw3dKeW3+1qa533iCa3P1YPHC4VavdJOr/q5eerQqrKKHjt0IVMhJgwL2RKcusUDCTHx17Ig4bDdnhEerxv/7kQ== Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=nvidia.com; Received: from CY8PR12MB8300.namprd12.prod.outlook.com (2603:10b6:930:7d::16) by DS0PR12MB6536.namprd12.prod.outlook.com (2603:10b6:8:d3::17) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.9769.17; Wed, 8 Apr 2026 17:57:25 +0000 Received: from CY8PR12MB8300.namprd12.prod.outlook.com ([fe80::ce75:8187:3ac3:c5de]) by CY8PR12MB8300.namprd12.prod.outlook.com ([fe80::ce75:8187:3ac3:c5de%3]) with mapi id 15.20.9769.018; Wed, 8 Apr 2026 17:57:25 +0000 Date: Wed, 8 Apr 2026 13:57:23 -0400 From: Yury Norov To: Shrikanth Hegde Cc: linux-kernel@vger.kernel.org, mingo@kernel.org, peterz@infradead.org, juri.lelli@redhat.com, vincent.guittot@linaro.org, tglx@linutronix.de, yury.norov@gmail.com, gregkh@linuxfoundation.org, pbonzini@redhat.com, seanjc@google.com, kprateek.nayak@amd.com, vschneid@redhat.com, iii@linux.ibm.com, huschle@linux.ibm.com, rostedt@goodmis.org, dietmar.eggemann@arm.com, mgorman@suse.de, bsegall@google.com, maddy@linux.ibm.com, srikar@linux.ibm.com, hdanton@sina.com, chleroy@kernel.org, vineeth@bitbyteword.org, joelagnelf@nvidia.com Subject: Re: [PATCH v2 03/17] cpumask: Introduce cpu_preferred_mask Message-ID: References: <20260407191950.643549-1-sshegde@linux.ibm.com> <20260407191950.643549-4-sshegde@linux.ibm.com> <0d8412de-e18a-476f-9eb6-9a977f4474a3@linux.ibm.com> Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <0d8412de-e18a-476f-9eb6-9a977f4474a3@linux.ibm.com> X-ClientProxiedBy: BN9PR03CA0133.namprd03.prod.outlook.com (2603:10b6:408:fe::18) To CY8PR12MB8300.namprd12.prod.outlook.com (2603:10b6:930:7d::16) Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CY8PR12MB8300:EE_|DS0PR12MB6536:EE_ X-MS-Office365-Filtering-Correlation-Id: dbb1e9e5-e2d7-4a32-8913-08de95984ab3 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|1800799024|7416014|376014|366016|10070799003|18002099003|56012099003|22082099003; X-Microsoft-Antispam-Message-Info: +ApUlyb8H96/UnTBcH93nuQd/wBwvL4eLssyDF7YDqLshYoLSJtRNWN9+E+qpk+LZkPoFH6GsxqBsYxSPfubh7i9h6CKw4iDyFTkcwBxfZjkUOmFtTlzkMshFHn68yt60pWs1nGlyJUbrKyOqXwu1jDG9B9NZcA6FI7UPOZRnqACHHwPA8/uMQoHz4snndQFYVWrA2wIT/b6mzwup2kP0+D/OYuDCKWXCNKxI4JK5n1WtR9b42QQIvKhRdXLM3fdneYqnNrxNRnzaUojoqjcCD+veIo4/NqrL3h454Z5ebpptP3d5oi82p/m1Stkep2CttZYPq+sae057B24IUygRVcC3uninyOgA5wkimMy435A197uLT6LWws2CbNXU7Gvkq6nVxJBOTv83rK5+//ypw5wZ/xiFHed27zCUWmTDU/yxxaFqtf0h/KflmmOfSya8Ys1MEFLFBFJUy5a0aPxwK09HN/N/1OAk7RLXt5B8AjFQvSKB49LjHjC3vCiVDJoKu6X+ciPx5QhuxVnKvffmB8oJwqGn5+vAHC22DR2Rcq672WvKCO0/ZxzlV3svICyd3KGw2088w0iruydpnMc0fdwmb1eFHj8Bq8pZftg1gXTqKaAVk2OxUl93rcCSgo8mwgGqHDuvvSUKAB1XMw6F3iQ1L14cSv7L5v9mZArkY3kpm8qcKThupQIJ8WBOUOfrjrTUaU2C0ZdEi8mXFjrTsbcpOwh7LeKhIl73uxNvrU= X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:CY8PR12MB8300.namprd12.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230040)(1800799024)(7416014)(376014)(366016)(10070799003)(18002099003)(56012099003)(22082099003);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?us-ascii?Q?bOILyk7YHEAxLLs8y35CZ6wp0tWyFumC2y/HuCPAvoIUG4twjNjRHuR21Gv4?= =?us-ascii?Q?pFCaBgN/YIuEZe6vCFjXjByFpXjy5DE1iKzFCx0n8uVdjSICppKkZV8Jqx3k?= =?us-ascii?Q?HUeQCm9A+ZfKFZeEglkDJUc0H1VSToQc6P6RmrWtsOCHh6HurHCMZoR+Qktp?= =?us-ascii?Q?fvo2G6+oS0ilhY8pnMLnfQ0hCnEICUHIVS0MuWaaMxccK+VorPLEEAUg1tA7?= =?us-ascii?Q?U6dOuR+T/MQihXkgKBXh/O4up6BqF8ED1MFFGTdjB29vuj3r1Kja7GGYZblM?= =?us-ascii?Q?o2t3F0L4Ytq1uKYyA9LtHR5KXjg98fKyZXhpXhOXzH7tu3ghrT6eFYtBnCzQ?= =?us-ascii?Q?Qif8LszDraVYUCi7RK+BmaFHl8TQklngBqfMTmH71fN71ElF5o/VtzCFidVR?= =?us-ascii?Q?5TiuAAHM5MewAkFqJ1iauNL6k8bIY8JARfggNktUbkofFk5oJhP4GJuTi7Xx?= =?us-ascii?Q?ICVsDqtWLURk/NW0HWc9k6vHL9+xUcKrLlKeSvj32tWjDtcEpSktJTTK74Fg?= =?us-ascii?Q?zQux8wMeUleIODtyRQyFTRn2mt1ALibvr5iF4XPFFB4fv7/tpP3MYAx+uS1+?= =?us-ascii?Q?v5RLCjVPC0i3INhTXC6eWj40rOl69+DzHrp2RfzWa2VZdS3I1jC0AFc6kDJt?= =?us-ascii?Q?fRFK4PXG2uSMY6mFb/nbDA/Vxo55Vscsb5az8cN4Lkqkyf85cLtSJTy8ESUY?= =?us-ascii?Q?WKGpJWgQDIeyL2WTjmzI8R2XSUd0xhSORcmxPqzf1zQ4J+L3z9NO28Ui6SbH?= =?us-ascii?Q?lOOZIyimiE4za49E17S9nCfgAmEEpLgqqV2NpeNPIP+IK3q3e8vgcRyZvp8M?= =?us-ascii?Q?LxtBwRGzzCx4ou/9fUgwWD7fDQjKWsbOYSvQ+28Jo/0Ja5cGRURSFK1COH8B?= =?us-ascii?Q?HZA7CIP54YU6I9UDlOym5kacpWL8quzi7bVllMJccXqplCDeYIZq5IQoZ9i6?= =?us-ascii?Q?fFJxV6w6DIejm4hLvIGjgGQW7bEPFeyFxQk1RZS1q1TcWd36gQEptkJRZJNU?= =?us-ascii?Q?ZKQh1ou623/+++CmR+YK7UEUuCcnWA8DJ2xs7IsORsagY0T0wFw2Momk8S5B?= =?us-ascii?Q?BW5NrPXPr2wfCQgRobEZ/sKOGRWL/Y30t1qm3aOGm8NC9nw4Zi/idcYNH0YF?= =?us-ascii?Q?vcYa4BbPkHwN3fPICvegI5QBg/LJhLeX7fzspQWdvWGvO6UH2Um7UA2XW8Ip?= =?us-ascii?Q?XzQS01sLZ1h37CiSu0tOscb/4ULuoxzp6AzTEMj35mr0IJ3F+EDIj3vCCrk8?= =?us-ascii?Q?+n3GrrZuNIkZnQW1a2+FBXNuvdZnMF9P0O+Cf+2JMDiKLnJ+JWCwNQP0zvhd?= =?us-ascii?Q?5TwPCqPuCNaz5LZKUa9Ks+xTjEj+WTg7b1tW3cDvdktK6nQdd35WggX3Jnlg?= =?us-ascii?Q?rvQ5fBnQlAbu2SjfX5AqqD2iu69HjPWWftboHONI898stSIhp8q43upq5X1y?= =?us-ascii?Q?CRHL5wHKsQZbjblSltK3Boa0SRdfswNhEL9S4Ux6WogS9jqcp9NKoLTf3evm?= =?us-ascii?Q?gvkwEsIapT8/a3il77MoFQQDbmkCL5XPYiBrvjc3DoXgsfUni1ioxMffySPu?= =?us-ascii?Q?2ooupfrDYw0Usa9ZGbp6nPi4S3lZbhFDFdKvlJsXvtAMId3Ww6YrscqXTN6A?= =?us-ascii?Q?6BNPqlHa8V3I4yHpLlpDUxKD0uFLjH2BXx8vKiktYPVidMinvhnWSMUedW13?= =?us-ascii?Q?9AnIXnvB1okLoa7ose8XL3ji20YWLOvpvQY2hO3NwUni0HgVZRNpoj0Ll1ns?= =?us-ascii?Q?JpJCgECGISfEwvvXLpTA2I1imScwLMz1Z+eUqHwBFgU75uex0pMO?= X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-Network-Message-Id: dbb1e9e5-e2d7-4a32-8913-08de95984ab3 X-MS-Exchange-CrossTenant-AuthSource: CY8PR12MB8300.namprd12.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 08 Apr 2026 17:57:25.7128 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 43083d15-7273-40c1-b7db-39efd9ccc17a X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: d/NSHbWe8kCCTKWeJksdUV+LbswqsNGe6vMoQzSB+xxuuDMvrwjtRdOF85e9dGQiC/0R/YE+Pm4CalaPkSrivg== X-MS-Exchange-Transport-CrossTenantHeadersStamped: DS0PR12MB6536 On Wed, Apr 08, 2026 at 02:46:03PM +0530, Shrikanth Hegde wrote: > Hi Yury. Thanks for going through the series. > > On 4/8/26 1:57 AM, Yury Norov wrote: > > On Wed, Apr 08, 2026 at 12:49:36AM +0530, Shrikanth Hegde wrote: > > > This patch does > > > - Declare and Define cpu_preferred_mask. > > > - Get/Set helpers for it. > > > > > > Values are set/clear by the scheduler by detecting the steal time values. > > > > > > A CPU is set to preferred when it comes online. Later it may be > > > marked as non-preferred depending on steal time values with > > > STEAL_MONITOR enabled. > > > > > > Signed-off-by: Shrikanth Hegde > > > --- > > > include/linux/cpumask.h | 22 ++++++++++++++++++++++ > > > kernel/cpu.c | 6 ++++++ > > > kernel/sched/core.c | 5 +++++ > > > 3 files changed, 33 insertions(+) > > > > > > diff --git a/include/linux/cpumask.h b/include/linux/cpumask.h > > > index 80211900f373..80c5cc13b8ad 100644 > > > --- a/include/linux/cpumask.h > > > +++ b/include/linux/cpumask.h > > > @@ -1296,6 +1296,28 @@ static __always_inline bool cpu_dying(unsigned int cpu) > > > #endif /* NR_CPUS > 1 */ > > > +/* > > > + * All related wrappers kept together to avoid too many ifdefs > > > + * See Documentation/scheduler/sched-arch.rst for details > > > + */ > > > +#ifdef CONFIG_PARAVIRT > > > +extern struct cpumask __cpu_preferred_mask; > > > +#define cpu_preferred_mask ((const struct cpumask *)&__cpu_preferred_mask) > > > +#define set_cpu_preferred(cpu, preferred) assign_cpu((cpu), &__cpu_preferred_mask, (preferred)) > > > + > > > +static __always_inline bool cpu_preferred(unsigned int cpu) > > > +{ > > > + return cpumask_test_cpu(cpu, cpu_preferred_mask); > > > +} > > > +#else > > > +static __always_inline bool cpu_preferred(unsigned int cpu) > > > +{ > > > + return true; > > > +} > > > > This doesn't look consistent, probably not correct. What if > > I pass an offline CPU here? Is it still preferred? > > preferred cpu state follows the online state. This was done by change > below in set_cpu_online. So when cpu goes offline, it will be removed from > the preferred mask too. > In the design principle I wanted, preferred to be always subset of online > > preferred <= online <= possible. > > > Later you say that preferred CPU is online + STEAL-approved one. > > So in non-paravirtualized case, I believe, you should consider > > There it would clearly be same as online CPUs. In PARAVIRT-off case you have no cpu_preferred_mask at all, and always return true. So, asking again: does cpu_preferred() work correctly in this case? >From what you said, it should be: +#ifdef CONFIG_PARAVIRT ... +#else +static __always_inline bool cpu_preferred(unsigned int cpu) +{ + return cpu_online(cpu); +} +#endif > > that only online CPUs are preferred. What about dying CPUs? Can > > they be preferred too? > > When there is no CPU hotplug, preferred will be subset of online. > > Lets see different cases with CPU hotplug. > when STEAL_MONITOR is on and there is high steal time. > > Lets say, 600 CPUs system with SMT. > > Case 1: > CPU 500 was offline. It would have it's preferred bit=0 . after a while > there was high steal time, and preferred_cpus = <0-399> and once the contention > was gone, since it is using cpu_smt_mask, it would set 500's preferred bit=1, though > it is offline. > > Case 2: > all online CPUs were preferred. 500 was offline. after a while there was > high steal and while iterating through cpu_smt_mask, after say 499 was done, > 500 is brought online. that would set it in preferred. > Since it was part of the mask, 500 will be marked preferred=0. > That's ok. It was meant to be anyway. > > Case 3: > all online CPUs were preferred. 500 was offline. after a while there was high steal > and preferred_cpus = <0-399> and 500 is brought online. that would set it > in preferred. In the next cycle, bringing online causes more steal time, and since it is > the last CPU in the mask, it will be marked as non-preferred. Thats ok. > > So Case 1 is the one where the construct is broken. > This is solvable by checking the online state in steal time handling code. > > diff --git a/kernel/sched/core.c b/kernel/sched/core.c > index d3b2bcb6008c..bad091f1f604 100644 > --- a/kernel/sched/core.c > +++ b/kernel/sched/core.c > @@ -11329,7 +11329,7 @@ void sched_steal_detection_work(struct work_struct *work) > if (cpumask_equal(cpu_smt_mask(last_cpu), cpu_smt_mask(this_cpu))) > return; > - for_each_cpu(tmp_cpu, cpu_smt_mask(last_cpu)) { > + for_each_cpu_and(tmp_cpu, cpu_smt_mask(last_cpu), cpu_online_mask) { > set_cpu_preferred(tmp_cpu, false); > if (tick_nohz_full_cpu(tmp_cpu)) > tick_nohz_dep_set_cpu(tmp_cpu, TICK_DEP_BIT_SCHED); > @@ -11345,7 +11345,7 @@ void sched_steal_detection_work(struct work_struct *work) > if (first_cpu >= nr_cpu_ids) > return; > - for_each_cpu(tmp_cpu, cpu_smt_mask(first_cpu)) > + for_each_cpu_and(tmp_cpu, cpu_smt_mask(first_cpu), cpu_online_mask) > set_cpu_preferred(tmp_cpu, true); You don't need a loop: cpumask_and(__cpu_preferred_mask, cpu_online_mask, cpu_smt_mask(first_cpu)); > } I didn't passed through patch 6 yet :) > I had thought of this scenario. I hadn't seen it from consistency point of > view. It should be consistent since it is exposed to user. > > Functionality wise it was okay since, current code has enough checks to > schedule only on online CPUs. Even is_cpu_allowed returns true only > if it is online. But i get the point, and above diff should address it. Yeah, your reasoning looks correct. To stay on a safe side, I'd add assertions for that here and there, like: #ifdef CONFIG_WHATEVER_DEBUG WARN_ON(cpumask_subset(cpu_preferred_mask, cpu_online_mask)); #endif > > At least, please run cpumask_check() on the argument. > > It is set either within online or in PATCH 15/17 by iterating through > cpu_smt_mask. That should always yeild cpu < nr_cpu_ids. > > I didn't get why cpumask_check is needed again. cpumsk_check() is a debugging feature. It's an no-op unless CONFIG_DEBUG_PER_CPU_MAPS is enabled, and every cpumask function that takes raw CPU is expected to use it. In your case, it's needed when CONFIG_PARAVIRT=off. > > There's a top-comment describing all the system cpumasks. Except for > > cpu_dying, it's nice and complete. Can you describe your new creature > > there? > > Ok. I can add a comment there. > > > > > Finally, I don't think that __cpu_preferred_mask should depend on > > PARAVIRT config. Consider cpu_present_mask. It mirrors cpu_possible_mask > > if hotplug is disabled, but it's still a real mask even in that case. > > The way you're doing it, you spread CONFIG_PARAVIRT ifdefery pretty > > much anywhere where people might want to use this new mask for anything > > except for testing a bit. > > > > One concern you had raised earlier was bloating of the code for systems > CONFIG_PARAVIRT=n. > > Maybe in some of the hotpaths we could do, IS_ENABLED(CONFIG_PARAVIRT) check and > that should be ok? My point is that there most likely will be users of PARAVIRT who will not need this machinery, and will not be happy of bloating their kernels with another useless (for them) feature. Moreover, it's O(N^2) in some cases. I suggest adding, for example, config PREFERRED_CPUS that would select PARAVIRT, and would be disabled by default. Regardless, whatever you decide, please keep all the cpu_paravirt_mask ifdefery on the cpumasks level. For example, in patch #5: +#ifdef CONFIG_PARAVIRT +static inline bool task_can_run_on_preferred_cpu(struct task_struct *p) +{ + return cpumask_intersects(p->cpus_ptr, cpu_preferred_mask); +} +#else +static inline bool task_can_run_on_preferred_cpu(struct task_struct *p) +{ + return true; +} +#endif That looks wrong to me. Instead, either declare cpu_preferred_mask unconditionally, and maintain it well, or +#ifdef CONFIG_PREFERRED_CPUS +extern struct cpumask __cpu_preferred_mask; +#else +#define __cpu_preferred_mask __cpu_online_mask +#endif This way, your higher level code will be clean. Thanks, Yury