From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from SN4PR2101CU001.outbound.protection.outlook.com (mail-southcentralusazon11012066.outbound.protection.outlook.com [40.93.195.66]) (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 806482E612E for ; Thu, 19 Feb 2026 06:13:14 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.93.195.66 ARC-Seal:i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1771481596; cv=fail; b=eZ0mceNqhN3G+INrnXN5mdLWsf/4mz9GWFHIXr9BYo0EJ2NFZKQQuNoGjtVnNF3K9LX1zDZVF/G/feIHBBSqUrXQS1+QBiD/P/ge7oBmTc/8BEvOEpKdNDodnaek7cUEe4gMJKqlAQ+f60no1NizcNrc/e8f6sqVahHax26jaRE= ARC-Message-Signature:i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1771481596; c=relaxed/simple; bh=MYrDMEkP0bdI01hr0Ft1uamfpVVv9vr/e6gsCKDT/K4=; h=Message-ID:Date:MIME-Version:Subject:To:CC:References:From: In-Reply-To:Content-Type; b=q1Pi+3rUVgIRepVzz7+mueh1vjg1CGTM9BJB3Aoxu6WPVSbF6iRmk7aCYEn/5WyX6nrpzPNLvuqFLqB8+Tmi3kgzRhzveWNftA298ucjdlSDD8LKiTfgF9D22hF2l+TubqcGyWPAK1Sfwjx0jimvBSobq2B4f8r5sqoJuJEH9VA= ARC-Authentication-Results:i=2; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=amd.com; spf=fail smtp.mailfrom=amd.com; dkim=pass (1024-bit key) header.d=amd.com header.i=@amd.com header.b=dYrnCscZ; arc=fail smtp.client-ip=40.93.195.66 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=amd.com Authentication-Results: smtp.subspace.kernel.org; spf=fail smtp.mailfrom=amd.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=amd.com header.i=@amd.com header.b="dYrnCscZ" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=qrtMAjhO4Z6aVYbsIDhA8TuoThkd9us94Y2VROFZG9W8UkJ+MtpEkrkjxl47CTv+ZeL78yDh3HGRKES2jmUVua7H4eY0WxISFNkWafMnHpRwvlGPfYLDejEpbitOrLCaixLhWRqJ2cb7VtMH1OM95n716S2eZ7hXvRv3GtAtSCoyXeNDCEBqEwKWUAyaEk2LTkH/Hxmn6KyIE/WZOj3Cg4GmDBY/yh0w4eYGP2HOMhHKVUPdv5t0OVnGZLDbaPANMlJpI7R5F6Z7RI314LMULwYOE8ruYQsbFsEgIGl6d/+HIkb/Ogn5tlggPD7ou+5aWt+9emyX7n4g1aCplNBReA== 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=24iz5rlZOWa+kXtyz5mEYC0dNPN1oDI404+l06snXIg=; b=M6xVT9sAcCT89RpdMfGSGA6/oDlZJUMx2XlknAwr1l08Mp24k8p1LB5ZyymQ16YsJQc33aLkkkhwXBJCTgaY/LdLzIDO3LRieo6oa09rNLFSUbYhXxl5vT42hTjVgLyHpI55kSfzq9gmCcIUxvjc+/K1G0Ae7vzct+gMWVyJHw50YvPC5kvI9NGi71LHz5vMO8lTxKWUPbbvSj0f5kWRuIfVtybWlx85/2qKwOUp7xy1IqN8CxddRdfNr/KAxXDjC27NxE3fIR/LwbFJx8C8iwQ/aZsBClKCGDL6XyYcZlt7pG2ZKyIsHS72yAMBWRUEf3FlrDkf8JZ4sUu4Oi8ZZQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=linux.intel.com smtp.mailfrom=amd.com; dmarc=pass (p=quarantine sp=quarantine pct=100) action=none header.from=amd.com; dkim=none (message not signed); arc=none (0) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amd.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=24iz5rlZOWa+kXtyz5mEYC0dNPN1oDI404+l06snXIg=; b=dYrnCscZ4PDzEP9ArOR7xQrUbH3T83eLhBS1t2OSA/imoBgsECamsf8ROUt61VWxahYFl7a/tV2mtt/GeACF7IDtQbM4nvSpG0Y9dLCr95aNcRyns3JA5qcp7K/6XPbnkULvxEKffSNTefldI0n2TbOd0C8jK1+bBHAarBY1PM0= Received: from CH5P222CA0007.NAMP222.PROD.OUTLOOK.COM (2603:10b6:610:1ee::19) by IA1PR12MB6017.namprd12.prod.outlook.com (2603:10b6:208:3d7::8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.9611.16; Thu, 19 Feb 2026 06:13:08 +0000 Received: from CH1PEPF0000AD7B.namprd04.prod.outlook.com (2603:10b6:610:1ee:cafe::1a) by CH5P222CA0007.outlook.office365.com (2603:10b6:610:1ee::19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.9632.15 via Frontend Transport; Thu, 19 Feb 2026 06:13:08 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 165.204.84.17) smtp.mailfrom=amd.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=amd.com; Received-SPF: Pass (protection.outlook.com: domain of amd.com designates 165.204.84.17 as permitted sender) receiver=protection.outlook.com; client-ip=165.204.84.17; helo=satlexmb08.amd.com; pr=C Received: from satlexmb08.amd.com (165.204.84.17) by CH1PEPF0000AD7B.mail.protection.outlook.com (10.167.244.58) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.9632.12 via Frontend Transport; Thu, 19 Feb 2026 06:13:07 +0000 Received: from satlexmb07.amd.com (10.181.42.216) by satlexmb08.amd.com (10.181.42.217) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.2562.17; Thu, 19 Feb 2026 00:13:07 -0600 Received: from [10.136.47.100] (10.180.168.240) by satlexmb07.amd.com (10.181.42.216) with Microsoft SMTP Server id 15.2.2562.17 via Frontend Transport; Thu, 19 Feb 2026 00:12:59 -0600 Message-ID: <3de1e4ff-2da5-4a58-a4ea-03accf4b7572@amd.com> Date: Thu, 19 Feb 2026 11:42:58 +0530 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH v3 04/21] sched/cache: Make LLC id continuous To: Tim Chen , "Chen, Yu C" CC: Juri Lelli , Dietmar Eggemann , Steven Rostedt , Ben Segall , Mel Gorman , Valentin Schneider , Madadi Vineeth Reddy , "Hillf Danton" , Shrikanth Hegde , "Jianyong Wu" , Yangyu Chen , Tingyin Duan , Vern Hao , Vern Hao , Len Brown , Aubrey Li , Zhao Liu , Chen Yu , Adam Li , Aaron Lu , Tim Chen , Josh Don , Gavin Guo , Qais Yousef , Libo Chen , , Peter Zijlstra , "Gautham R . Shenoy" , Vincent Guittot , Ingo Molnar References: <60a05a3f50d14a7bf3b968f62cca87893c5c552c.1770760558.git.tim.c.chen@linux.intel.com> <79755f7d-cc68-4189-b6d8-850378e54017@amd.com> <95923e36-4117-4209-97aa-a92b60f2bd49@intel.com> <6a73ac0d-1fc9-49a7-87a2-65951ab2c844@amd.com> <8df218ecf39015830856c7b1053a0f777cc1ea42.camel@linux.intel.com> <579c9039-cd66-41c3-8a72-e73d6f836ee8@amd.com> Content-Language: en-US From: K Prateek Nayak In-Reply-To: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: 7bit X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CH1PEPF0000AD7B:EE_|IA1PR12MB6017:EE_ X-MS-Office365-Filtering-Correlation-Id: 99dbf97d-e5e0-4a97-b8b0-08de6f7df35d X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|82310400026|1800799024|7416014|376014|36860700013|32650700017; X-Microsoft-Antispam-Message-Info: =?utf-8?B?VG16TTY3NnIwSzUyTVppUXY4ekFNZ2hCRm1XckVwdnpBUW1CaGtPNUhZaVVG?= =?utf-8?B?Yk9UTlpFMnVYcFlrVnJTR005cTU0YUZUMEVQcnhOZklFeDcyZlh2eTZNbHNI?= =?utf-8?B?RkhzV1pMb3pBdTNhTnUzcnROaDUwd2F0UnN6dTdOenZyc1pGcTFUQnpTVU1w?= =?utf-8?B?Vnh5ZDBjUjA0V2FkT2tBYTNtblNhb1A3OXA4TGg0QkcrcHBGR216NmlVSElp?= =?utf-8?B?Ujl5Qml4eG8ySEQ0NnVReFBrYldmR2pYMnRKMXJxRnhKRmtXamwyQW1welpi?= =?utf-8?B?ZmNSTHJXVWdtMEd3Vk9kb2ZWUDdGbDZuMG9WTG5JanAxbis1RWMzQ3BCRTlL?= =?utf-8?B?YVpFZ2w0RVZqWlByY3dpOUpkdDA2eXFwcHpPUHkzd1pXTzE3MGlkWWJIV3FZ?= =?utf-8?B?Y2Y2OGcxVnBkcCtNa3lCU0d3U25FU0tnMGswaWNmMmU3TWlSVXNIeDV1MThk?= =?utf-8?B?Yko0ZThzcDA3MVhjdXZ3ZlFGQ0FtS3gwYmdnQVhSTytBMlJsZ1lGaEJLRWxH?= =?utf-8?B?RTV5blVCWTc5ZUNucUY4Q3hTZnJPL3NSYUVvNDZsZnc1aGpNVTZwY2tKeTJP?= =?utf-8?B?N1dCVWRsZHVzdWVSYVUrUHpkM1JFY3Z2cG1xd2JybXdqeFl2bi9SSkorYUM0?= =?utf-8?B?STVIbVp4czV5Nk9KQjgvakhsRDlzSzJ5Lzl2Qit1aGx2S1pwdkxIRkwwZzA4?= =?utf-8?B?Qi93VXFMclFmRjU5eU1OenFBSFZuUTBVTGRtUjdhUzdUOFRnVldtbzFhRnY0?= =?utf-8?B?R01GaVE5bkZENnp1MzNuK2lNNzlQSCtzQjlQcVlncXRLMVF4aHFLRkJtMUpN?= =?utf-8?B?NVRBaUthRjVXVUJEQ2lsaVl0Z0loemNCRWVZQlBNTWZJR3pzWlkvMFZWRkNv?= =?utf-8?B?aEVLeERCVCtVcUtZdVc4MC9jQU9GRGQrOW4rdU9qS1RMUUs0ekxMaVpxajFt?= =?utf-8?B?UHV2Ym9RK3lCSk51dzJGdXh3SVJUeEpCeXN1bVEwVEdxQzVVRWVaK1M4R1Q4?= =?utf-8?B?dlI1ckNtTTloSTZXajh3R0NRS3lUdGR1VTNzSW1OOC93NVFDTTdZZmYzMDh2?= =?utf-8?B?cWNLbGVqU25vS0l3WjdOMkxsQVpjMlFJQUdHaHRsUEJqSlBCbFNoLy9zVG83?= =?utf-8?B?TVhpMXh6Y2s0QVQ2UEU1UHRsa2QrNUtWWWg0WFQ4QlZJd2M5aFIvclVuOGdU?= =?utf-8?B?aHdSSmMrZnR6VnVlbGVtajYzRFI1RGs5TWFqdHRhYUZDaDFnQkRLMWtFUmpp?= =?utf-8?B?Z3B6OFNkSXlpSFRWOFMwOUJhNG1lZW1lSkMycWVBZk1yVGxDOWVBMUc1WjhH?= =?utf-8?B?VFd3Rk5adnBYWGJxQS80WGVjRTdXMitycWx5QXRSVTJwQ2dWQkhFMXhoa1RY?= =?utf-8?B?b2NyMVBmSUwwMW9PcFp4c3p5SE1YNTdzTnlJZUlBL0pMY0NGem9DMEovUmFz?= =?utf-8?B?TG9Jb2xZSDN2MEJLYzViRUdIWk9XaXhDNFo1djRFbklJeXlBMDJLZm41c1F6?= =?utf-8?B?T3VmaTl1R2pyN0V2Zng2aWc1M0ZQQjBPdFNNWmE3VTc1aWhYTUpDQS9SZHJJ?= =?utf-8?B?eWpYaW52eTdhdkxYM0hrcmIxaytBa1lqRC9meWVIMUFKdkdjdXFZSnc3M0tw?= =?utf-8?B?TG5vRHRCYlMvckZvTkw1anhONW41SW9JZ2NTYTZqNVJJZm9EQ3haTGJGR09K?= =?utf-8?B?bkdnME5SblVVeGpVcTNmbWdLajErZ1dianJ6S2lNcCtYa01WdVRrVytNZ3ZV?= =?utf-8?B?SmZxWWJIZDBNN2I0OE5zUXBGMEFVaFQ2U3M2eWI4dGRoMTlFUmltQy9HTG9G?= =?utf-8?B?REZaUFpiclJ3R29EWlBOSTd5QnVOcXpuU0lYbW83cm1jTTljMzNHWWlncWlx?= =?utf-8?B?ZzlkeWU5bS95VTBEYWJsQVpRbFpRaFBlVG9aY0Fib255c2RHbjkzcFMxbzcy?= =?utf-8?B?UEVScW9VZ0FEekw0VTBqdkR5S3ZOd29yQ2lFS3dndzVIQVZtbEkrZyt4Z0tB?= =?utf-8?B?UDdIdFRtN2tzZndmSG5FeTZPbjRtRDdiNVZ3eEV3NSs3WFpiNENzdmtTY3JI?= =?utf-8?B?Y1l4Z25Nci9uWE5MRTNmM1k2OC9rRjJzdTdncWR3YzlhSzcvdU1VaHAyT3Z6?= =?utf-8?B?dHZtemx2TnBZWDZCSVlrTTE3aHRPVm5LMEJkbzgybHVDTUpsK0p1Q0Q1UlJP?= =?utf-8?B?Wk5TK1p4eUxxWGRFZ2ZkQ09lN1F1MmNHVlBTZzd1cFY5d3hpWktpQ1A5eXZS?= =?utf-8?B?Wk84RzVQaUxuY09YMFdSVG51UFJ3PT0=?= X-Forefront-Antispam-Report: CIP:165.204.84.17;CTRY:US;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:satlexmb08.amd.com;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(13230040)(82310400026)(1800799024)(7416014)(376014)(36860700013)(32650700017);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: M4pbCcHfGO101XOqSKRznnnWM4Cw/R1R48QqhXHzTWmguZv6kNDBq/c4oAk3HGQNZ+llpRpTcAQmDcDWzNF13p1K+XMrySSfLQqvpBCXyfTkl5JaPAwf6gXqDY+DDeQJ2zpP/RUIwxxqOL6+6O0046J5uhtISQeQUFqpxp29lNvVrtDIWM/io/OcpHh563GvUG9DxSf7mqodKpz3f010Ue01i3I62aBG0oSHcN14mAyVI+wEod2x8+YL9vor3RxqnM4n/6x2CTQZ2a8e8R6nvmThfBoRA++iEJYas1YxWfUeRbd1/tnX/MKqRnz8euoTqmnmD4LDd2LN2h9TMZzzCrLO57we37zWMXxVAzcXGMPmdDL1eNG7VTKcAb5TbKWII+5MhhmISllDtUNiAQImVrT9eeF4KIrACZ3eiGygAyeigYXFCKw7zJ8bPPmRtRjm X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 19 Feb 2026 06:13:07.7260 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 99dbf97d-e5e0-4a97-b8b0-08de6f7df35d X-MS-Exchange-CrossTenant-Id: 3dd8961f-e488-4e60-8e11-a82d994e183d X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=3dd8961f-e488-4e60-8e11-a82d994e183d;Ip=[165.204.84.17];Helo=[satlexmb08.amd.com] X-MS-Exchange-CrossTenant-AuthSource: CH1PEPF0000AD7B.namprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: IA1PR12MB6017 Hello Tim, Thank you for the patch. On 2/19/2026 4:51 AM, Tim Chen wrote: > diff --git a/init/Kconfig b/init/Kconfig > index 9848de949afa..4ddf54ab9cf7 100644 > --- a/init/Kconfig > +++ b/init/Kconfig > @@ -987,6 +987,7 @@ config SCHED_CACHE > bool "Cache aware load balance" > default y > depends on SMP > + depends on SCHED_MC > help > When enabled, the scheduler will attempt to aggregate tasks from > the same process onto a single Last Level Cache (LLC) domain when > diff --git a/kernel/sched/core.c b/kernel/sched/core.c > index 48626c81ba8e..75ba4e0bfcd3 100644 > --- a/kernel/sched/core.c > +++ b/kernel/sched/core.c > @@ -8474,6 +8474,8 @@ int sched_cpu_deactivate(unsigned int cpu) > */ > synchronize_rcu(); > > + sched_domains_free_llc_id(cpu); > + > sched_set_rq_offline(rq, cpu); > > scx_rq_deactivate(rq); > diff --git a/kernel/sched/sched.h b/kernel/sched/sched.h > index 6cbc56e9adfc..04f42526e6f0 100644 > --- a/kernel/sched/sched.h > +++ b/kernel/sched/sched.h > @@ -3862,6 +3862,7 @@ static inline bool sched_cache_enabled(void) > extern void sched_cache_active_set_unlocked(void); > #endif > extern void init_sched_mm(struct task_struct *p); > +void sched_domains_free_llc_id(int cpu); > > extern u64 avg_vruntime(struct cfs_rq *cfs_rq); > extern int entity_eligible(struct cfs_rq *cfs_rq, struct sched_entity *se); > diff --git a/kernel/sched/topology.c b/kernel/sched/topology.c > index 580fb2fbc900..5e59340ad9a9 100644 > --- a/kernel/sched/topology.c > +++ b/kernel/sched/topology.c > @@ -18,6 +18,7 @@ void sched_domains_mutex_unlock(void) > } > > /* Protected by sched_domains_mutex: */ > +static cpumask_var_t sched_domains_llc_id_allocmask; > static cpumask_var_t sched_domains_tmpmask; > static cpumask_var_t sched_domains_tmpmask2; > static int tl_max_llcs; > @@ -2590,6 +2591,57 @@ static bool topology_span_sane(const struct cpumask *cpu_map) > return true; > } > > +static int __sched_domains_alloc_llc_id(void) > +{ > + int lid; > + > + lockdep_assert_held(&sched_domains_mutex); > + > + lid = cpumask_first_zero(sched_domains_llc_id_allocmask); > + if (lid >= tl_max_llcs) > + tl_max_llcs = lid + 1; > + > + /* > + * llc_id space should never grow larger than the > + * possible number of CPUs in the system. > + */ > + if (!unlikely(WARN_ON_ONCE(lid >= nr_cpumask_bits))) > + cpumask_set_cpu(lid, sched_domains_llc_id_allocmask); > + return lid; > +} > + > +static void __sched_domains_free_llc_id(int cpu) > +{ > + int i, lid; > + > + lockdep_assert_held(&sched_domains_mutex); > + > + lid = per_cpu(sd_llc_id, cpu); > + if (lid == -1) > + return; > + > + per_cpu(sd_llc_id, cpu) = -1; > + > + for_each_online_cpu(i) { > + /* An online CPU owns the llc_id. */ > + if (per_cpu(sd_llc_id, i) == lid) > + return; > + } We should perhaps warn and skip clearing lid from cpumask if lid was found to be larger than "nr_cpumask_bits". Shouldn't happen but just as a precaution. > + > + cpumask_clear_cpu(lid, sched_domains_llc_id_allocmask); > + > + /* shrink max LLC size to save memory */ > + if (lid == tl_max_llcs - 1) > + lid = tl_max_llcs--; No need to assign the local "lid" variable here; Simple decrement should do. > +} > + > +void sched_domains_free_llc_id(int cpu) > +{ > + sched_domains_mutex_lock(); > + __sched_domains_free_llc_id(cpu); > + sched_domains_mutex_unlock(); > +} > + > /* > * Build sched domains for a given set of CPUs and attach the sched domains > * to the individual CPUs > @@ -2615,18 +2667,11 @@ build_sched_domains(const struct cpumask *cpu_map, struct sched_domain_attr *att > > /* Set up domains for CPUs specified by the cpu_map: */ > for_each_cpu(i, cpu_map) { > - struct sched_domain_topology_level *tl, *tl_llc = NULL; > + struct sched_domain_topology_level *tl; > int lid; > > sd = NULL; > for_each_sd_topology(tl) { > - int flags = 0; > - > - if (tl->sd_flags) > - flags = (*tl->sd_flags)(); > - > - if (flags & SD_SHARE_LLC) > - tl_llc = tl; > > sd = build_sched_domain(tl, cpu_map, attr, sd, i); > > @@ -2642,18 +2687,19 @@ build_sched_domains(const struct cpumask *cpu_map, struct sched_domain_attr *att > if (lid == -1) { > int j; > > + j = cpumask_first(cpu_coregroup_mask(i)); > /* > * Assign the llc_id to the CPUs that do not > * have an LLC. > */ > - if (!tl_llc) { > - per_cpu(sd_llc_id, i) = tl_max_llcs++; > + if (j >= nr_cpu_ids) { > + per_cpu(sd_llc_id, i) = __sched_domains_alloc_llc_id(); > > continue; > } I don't think we need to special case this out since: for_each_cpu(j, cpu_coregroup_mask(i)) { ... } would bail out if no CPU is set (also CPU "i" would definitely be set on it since it must be online) and the "if" after the loop will see "lid" as "-1" and DTRT. > > /* try to reuse the llc_id of its siblings */ > - for_each_cpu(j, tl_llc->mask(tl_llc, i)) { > + for (; j < nr_cpu_ids; j = cpumask_next(j, cpu_coregroup_mask(i))) { > if (i == j) > continue; > > @@ -2668,7 +2714,7 @@ build_sched_domains(const struct cpumask *cpu_map, struct sched_domain_attr *att > > /* a new LLC is detected */ > if (lid == -1) > - per_cpu(sd_llc_id, i) = tl_max_llcs++; > + per_cpu(sd_llc_id, i) = __sched_domains_alloc_llc_id(); > } > } > > @@ -2869,6 +2915,7 @@ int __init sched_init_domains(const struct cpumask *cpu_map) > { > int err; > > + zalloc_cpumask_var(&sched_domains_llc_id_allocmask, GFP_KERNEL); > zalloc_cpumask_var(&sched_domains_tmpmask, GFP_KERNEL); > zalloc_cpumask_var(&sched_domains_tmpmask2, GFP_KERNEL); > zalloc_cpumask_var(&fallback_doms, GFP_KERNEL); -- Thanks and Regards, Prateek