From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from BL2PR02CU003.outbound.protection.outlook.com (mail-eastusazon11011012.outbound.protection.outlook.com [52.101.52.12]) (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 B361C2116F6 for ; Wed, 18 Feb 2026 03:28:18 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=52.101.52.12 ARC-Seal:i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1771385300; cv=fail; b=V9bSw2KUSMZKqo8VISc11M1LVeXfBWnk+hEgcy7//AKBLQ6r6MQS8RgEswzZv+jqAO5+cyLM3ZVk6FiOV8XfCdn2VMRg5nbqyDJymcxcpPIUOCzGqgp40LtJGR+HCZXvOBBeyxOaxMJf9p2k2hvVK5PQ6XZ79uiKG4WwTjSuZ4s= ARC-Message-Signature:i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1771385300; c=relaxed/simple; bh=zhEFLJJGhu0ui7EqHHLjJznnEo4bx2z1W57Ktr/vg+s=; h=Message-ID:Date:MIME-Version:Subject:To:CC:References:From: In-Reply-To:Content-Type; b=ORIi41nqMmiyMAcyKM8Pdb1bA5m/nGcoWeSFp0bNfVsTJ/HRk0n4HsHnuuecyRwOfwWp4NszGcQMxqasx20VdPIxNPVeHrOxDzFhPuqVp72HIwbtEddgbJy2m+RXzmNaBhphxXZCr37NoPdDOEqmvoAjQr+v/sSEZ5XzRK7UNbY= 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=M/AQibpr; arc=fail smtp.client-ip=52.101.52.12 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="M/AQibpr" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=ZGHRmM27jUjQB38TJAA95FXViOPjI7FCVX9ZMCLY0hUChVSPHG0knq587xDXwskCDm3vx1CSiX4aYo/SQfFbhb7XaY79MpetoDiD6Y4ExGDkF3uVOqllDzYiUy8f090BKCCCw+5xBL3ZNggvaf8xzlAPAO551U1Lg9jzXeQhyI3YsCcJ170nBtLC1qiQ7UkUugQAsbB9/kYVMjnlGANwpHZcMH2KvcbIb3SomWJJ0lrArRlbuOESk+qtS9e7GoOcw3LOD0WJrXNV5QWyXP3Ep+xe8sEu2BCxFAYpE1ilgA2JySkH+OMzt9uy98lL/GHV++7tlc9SvaRddu2qIhRAZQ== 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=3ch26obQjO45jAGD3AGaDn/1unzKqd+g05rV4sNt6k4=; b=d9g6c9Xn+fSTNdlZdKKQeyraqO90WBvQY/gYbpLPmpqUtRiyI4hi8GYo7Lveo4JkZgodmoX9nuFdUMkU+oTNWDXifk4i5SyZQ+L1NbZQugw4C5ppeOzp/9Ijtxta2MJZ+zxNGhhTW8fT32Zy7fEnO14W+trlPivIXD6t58aFrnGPyxtdxdNfdEo+9pN516bALL/f7/4phOhUb6IJ/eaByskQZx8V9kdtMFTT8kL8ZL+V1EVsh+AveSVzkW1Xr7qLvdeGOXyPXGpOK1G2EueaBiPSpx4yvbcETTejw0QdCP7zm6C8+HCmBoAh8IDX7QcGO6n2dKAsnrpASu4agXTGCQ== 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=3ch26obQjO45jAGD3AGaDn/1unzKqd+g05rV4sNt6k4=; b=M/AQibprEXGb1Z8mqXkI4h7lYPnYjM4QoWmSt8cLrNGOxvCUTEwvutLuc1gsD2pfqpo/ILWdkyCUIYDVDLj7g6MIjecrsQg/agSPMNUFxPQroVwmZxnf4F6AGhBd5pRgBBOmEKT8ztArrv7he7F5NTGw+geKPRi0oQkoyZ1AfKc= Received: from BY1P220CA0011.NAMP220.PROD.OUTLOOK.COM (2603:10b6:a03:59d::11) by CY5PR12MB6275.namprd12.prod.outlook.com (2603:10b6:930:20::9) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.9632.13; Wed, 18 Feb 2026 03:28:14 +0000 Received: from SJ5PEPF000001F0.namprd05.prod.outlook.com (2603:10b6:a03:59d:cafe::8e) by BY1P220CA0011.outlook.office365.com (2603:10b6:a03:59d::11) with Microsoft SMTP Server (version=TLS1_3, cipher=TLS_AES_256_GCM_SHA384) id 15.20.9632.14 via Frontend Transport; Wed, 18 Feb 2026 03:28:14 +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 SJ5PEPF000001F0.mail.protection.outlook.com (10.167.242.68) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.9632.12 via Frontend Transport; Wed, 18 Feb 2026 03:28:13 +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; Tue, 17 Feb 2026 21:28:11 -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; Tue, 17 Feb 2026 21:28:04 -0600 Message-ID: <579c9039-cd66-41c3-8a72-e73d6f836ee8@amd.com> Date: Wed, 18 Feb 2026 08:58:03 +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> Content-Language: en-US From: K Prateek Nayak In-Reply-To: <8df218ecf39015830856c7b1053a0f777cc1ea42.camel@linux.intel.com> Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: 8bit X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: SJ5PEPF000001F0:EE_|CY5PR12MB6275:EE_ X-MS-Office365-Filtering-Correlation-Id: 5f738107-5975-41f5-3955-08de6e9dbfa2 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|376014|7416014|82310400026|1800799024|36860700013|32650700017; X-Microsoft-Antispam-Message-Info: =?utf-8?B?N1NrMDVtSHVONHQ3Z0RBS0VuS3laQ1dPWjdHZnVxOXBmNEczbTMvSENHK1dL?= =?utf-8?B?NDdIcWNJUEJwVERwN2s1Qis0cWRQaDUxRWQ0K2lXRzFPNDcwdGhVQitiMmpT?= =?utf-8?B?TnJXRkZJdThMa1lheXVvVXg5K2RIeWVnZWxXQlpHMzE4dVU5MVFXR2FOM0tB?= =?utf-8?B?cW9uT29aY3NyQVIycm1KVW9zUW9hSTA2ekFpMGIvaGdKakFTSUpTaDZaR3A1?= =?utf-8?B?MXFYd3phaVRWYjI1VFZLYmo1b2pCSVNPZ1Z3Mmp3ajUvSVFtajhWdmZ1Y1dr?= =?utf-8?B?S2NNS21pMENGWDYrT3p6ci8rcTJYMlhUSXNhU3VmaU5LVHVxK0s2NGdNc3JM?= =?utf-8?B?Y2JZKyt1TEI5YzFOd3hLWE1NclcrV2VxTGlKY1JRa3NpSlRIcmtmTlo5eXMx?= =?utf-8?B?a3h4Y1dTYmhVNVluY01KeVFtN2MwZWx6VUpvWjNNRFM2YVBEcGxQbUExUkx1?= =?utf-8?B?WWVpZ25BL00yNkpZVC9xYWhzVkkvRktMcHRpaTh1aDV1RXZIS2s0OXIvWDNW?= =?utf-8?B?TDk5ZmpqWFU1V291ZWRyZnowSUlOSlFFaVJ6bDZmUWFIZ1BqUlBnZzhuYVhI?= =?utf-8?B?bEJnN0FqeFFGbmI3K3dwZDZsN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JQUGQ0aFlRU2ZGa1p6ZDN0ZTVoMVlmZy9iL3M0eTNDaEgzcG41akgz?= =?utf-8?B?ZWkxdDdyVEp0NFVPWkVVdUwwNzdCaUo4UkxZeFRwTS9sMDh0WnVIVVJzVi9N?= =?utf-8?B?T3JLSlBkcVloOG9GK3VMa01LdjBzRWJmaU1Gc0VyTWdieUJIakxaYTVzQmEz?= =?utf-8?B?SjBZSCtiTHRhT21xZnA3QkRZSytiZU1JQlpPUE1PeUJoMzJXVG9LUWIxUHFZ?= =?utf-8?B?Qk1uSjBBcnJBSUh5YUoreE4vMWV6VW16eHg4dCtiYmdIeWFXOG54dFE3UG15?= =?utf-8?B?UGZ5dEFMcnZiUWgzZmpsN2huRGVUdy9WdXNzQ0E3L3JseHJPem9qaUd5MVhr?= =?utf-8?B?blBNQzRGQjc5L2VXeVI4aVJ4cnpsUkNlZ3lxNnZaejNMSENYYlgzVFlpSzEy?= =?utf-8?B?KzNiamtNUXRFMlViZVVzWitaeHc5NjFzYzZKbUs1QjZpUlZaVytRSlduaUIr?= =?utf-8?B?eWVRaWpKcVB1bjMzKzM4M0xiSnQ3RHhVemVLTEczdXhjNnIrVXdMcWIxeGRh?= =?utf-8?B?ODVsMVdXZHYyRnZuZWFEWS9IMldGQ2xCemtVOHY4RGlnRkJRd0NsQTJhb0N0?= =?utf-8?B?WHJBVWRpR1dQNWI0K1hMWDNrU2JrWksyUFo4bjdacUJZMkZmOGRONnFuaER4?= =?utf-8?B?cTFPUitzODdLNUIxOHlzYmpzUGNQaFJsY1NiLzdnVHFVUXI1ZnpCcmhvd0l4?= =?utf-8?B?MlJNbnBJMjl2Uy93UzBvM3JYU2JnPT0=?= 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)(376014)(7416014)(82310400026)(1800799024)(36860700013)(32650700017);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: m52hBGNf0xKSuDgCl6loqmROHToWytq3N3IkXuDKpCyC9Da01rwxbrc0ZeWAe059I4OFENvaWmimVJYUbBwZO4T7WbarkXnOoheXEqfKIhSZmJqfgMdK6sUji9g926BmQEV8pgUSOsB/AgSdGyqPwPQmPP+S1O27gV6HNTFcdHd5EeiD1S65oxJgo9v+RQ7yJLcpAZ0oFyvDqXU8vWi7muH8yUd8N6n2CNHKot0lCql5QT/r/YRMow98hZu6tMMc7PyyvvnP7Y8yszy+7nAULk0xedwAp6lMnB8Q+s93qkPnNQi6wP8LyxWUgXVd0er/43zvW/bQ8zn5j1yt44Jl7ORpEgdNMoXDLKy0pED523TTPkFkCRdO1zOqG8Re90sFiI4JpvBfggF/nCTWif/Gjs3ux6dBMsIUhIUrDkhT2zJBwTMaixL64DaV8FuBfKry X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 18 Feb 2026 03:28:13.5824 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 5f738107-5975-41f5-3955-08de6e9dbfa2 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: SJ5PEPF000001F0.namprd05.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: CY5PR12MB6275 Hello Tim, On 2/18/2026 4:42 AM, Tim Chen wrote: > On Tue, 2026-02-17 at 13:39 +0530, K Prateek Nayak wrote: >> Hello Chenyu, >> >> > > [...snip...] > > >>>>>    */ >>>>>   DEFINE_PER_CPU(struct sched_domain __rcu *, sd_llc); >>>>>   DEFINE_PER_CPU(int, sd_llc_size); >>>>> -DEFINE_PER_CPU(int, sd_llc_id); >>>>> +DEFINE_PER_CPU(int, sd_llc_id) = -1; >>>>>   DEFINE_PER_CPU(int, sd_share_id); >>>>>   DEFINE_PER_CPU(struct sched_domain_shared __rcu *, sd_llc_shared); >>>>>   DEFINE_PER_CPU(struct sched_domain __rcu *, sd_numa); >>>>> @@ -684,7 +685,6 @@ static void update_top_cache_domain(int cpu) >>>>>         rcu_assign_pointer(per_cpu(sd_llc, cpu), sd); >>>>>       per_cpu(sd_llc_size, cpu) = size; >>>>> -    per_cpu(sd_llc_id, cpu) = id; >>>>>       rcu_assign_pointer(per_cpu(sd_llc_shared, cpu), sds); >>>>>         sd = lowest_flag_domain(cpu, SD_CLUSTER); >>>>> @@ -2567,10 +2567,18 @@ 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; >>>>> +        struct sched_domain_topology_level *tl, *tl_llc = NULL; >>>>> +        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; >>>> >>>> nit. This loop breaks out when sched_domain_span(sd) covers the entire >>>> cpu_map and it might have not reached the topmost SD_SHARE_LLC domain >>>> yet. Is that cause for any concern? >>>> >>> >>> Could you please elaborate a little more on this? If it covers the >>> entire cpu_map shouldn't it stop going up to its parent domain? >>> Do you mean, sd_llc_1 and its parent sd_llc_2 could cover the same cpu_map, >>> and we should let tl_llc to assigned to sd_llc_2 (sd_llc_1 be degenerated? ) >> >> I'm not sure if this is technically possible but assume following >> topology: >> >> [ LLC: 8-15 ] >> [ SMT: 8,9 ][ SMT: 10,11 ] ... [ SMT: 14,15 ] >> >> and the following series of events: >> >> o All CPUs in LLC are offline to begin with (maxcpus = 1 like scenario). >> >> o CPUs 10-15 are onlined first. >> >> o CPU8 is put in a separate root partition and brought online. >> (XXX: I'm not 100% sure if this is possible in this order) >> >> o build_sched_domains() will bail out at SMT domain since the cpumap >> is covered by tl->mask() and tl_llc = tl_smt. >> >> o llc_id calculation uses the tl_smt->mask() which will not contain >> CPUs 10-15 and CPU8 will get a unique LLC id even though there are >> other online CPUs in the LLC with a different llc_id (!!!) >> >> >> Instead, if we traversed to tl_mc, we would have seen all the online >> CPUs in the MC and reused the llc_id from them. Might not be an issue on >> its own but if this root partition is removed later, CPU8 will continue >> to have the unique llc_id even after merging into the same MC domain. > > There is really no reason to reuse the llc_id as far as cache aware scheduling > goes in its v3 revision (see my reply to Madadi on this patch).   Even I don't mind having some holes in the llc_id space when CPUs are offlined but my major concern would be seeing an inconsistent state where CPUs in same MC domains end up with different llc_id when after a bunch of hotplug activity. > > I am thinking that if we just simply rebuild LLC id across sched domain > rebuilds, that is probably the cleanest solution. There could be some races > in cpus_share_cache() as llc_id gets reassigned for some CPUs when they > come online/offline. But we also having similar races in current mainline code. > Worst it can do is some temporary sub-optimal scheduling task placement. > > Thoughts? If you are suggesting populating the sd_llc_id for all the CPUs on topology rebuild, I'm not entirely against the idea. On a separate note, if we add a dependency on SCHED_MC for SCHED_CACHE, we can simply look at cpu_coregroup_mask() and either allocate a new llc_id / borrow llc id in sched_cpu_activate() when CPU is onlined or reassign them in sched_cpu_deactivate() if an entire LLC is offlined. -- Thanks and Regards, Prateek