From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from BYAPR05CU005.outbound.protection.outlook.com (mail-westusazon11010006.outbound.protection.outlook.com [52.101.85.6]) (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 82121321445 for ; Fri, 8 May 2026 22:05:18 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=52.101.85.6 ARC-Seal:i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1778277919; cv=fail; b=PRvxSees8zsl0SvlOclz8tlAmWf2l7fh6DMjIfeQJIR93wroJohTAzqIZGUKoua84IRhbzcdO+xXvy3qQMqVyGWCFrlUiAv4HG4qz+2XJAvMgrMFMq24IE6mc6xFMCw/J97Qa6usu47VskCV4vvMw8u8XqAyouk19Em8iA7EQxQ= ARC-Message-Signature:i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1778277919; c=relaxed/simple; bh=wfyfIM9cBn6r4MrEre+lPZ4mz6rKqlu5O1wf0+kerxU=; h=Date:From:To:Cc:Subject:Message-ID:References:Content-Type: Content-Disposition:In-Reply-To:MIME-Version; b=KY8v7aMdbOQfwYhDqJvXlQ/t+UsoMmaTlm3N3Wz/qm/3EJMIsv1oYao+s8Q67aLaWbcbUVux+Bm9tDdTkxb0SL4dpDc4dS99qjGt0uM5o3pWzC6gDHi5v1Kimxc7UiBOzjub/KPz9skOo2nGf27XxXkwtvZy/VZtiLrf7jgb43k= 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=LYHK41qm; arc=fail smtp.client-ip=52.101.85.6 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="LYHK41qm" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=TUArrpsvJt39hkGzGdLCO/MRZfsBOt4jeWgTz8wS+MLc3D2ugYRitEbe41dLdPi+p2DBFkWDfvsH3U5Lh4ozC3JBGrN/xxvSM9c53RrpcZ6kw6ki9Eodr3iQrAuTGy4OXH5g2dMYalLV/rr9OYM4cJnX6GBJv/flRo3XPUR3l1MthSXVlo3W01RMe44d1NegCF8g1jQnewJ0/iGKKtgoh3gQKrc6wjkNbXRoMax3mI/5dr4yXABVagTFGMkhEC+aUnnT4w1gXYu0/zwAtNExVy7NhDli0p1ZvjkTLRAiD9HLKjkBg5wa61yODfFlouj9pPIenccWwTODcdD71tkcEg== 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=f7RhicwbS2eTmJrJbAqfyNfan6JWcc35tcpiH12PiNI=; b=IlVF4tVxSuMYqUqJPSv7ML918vkT0cPguF0a8eFQoQHk7qYIvLb4nn99gfm/H92pS+8M1J3zAzZTNjn+M49ge/tABXEMoCp2M/Xh+YIM1ARyNM3khO2B2pIRg8xm1dSywgW4MqJQ+yb0e6zwa+1P3yPPTnGH9/fGi8l5V334qN2k6rOugG/Tcu7OxPRcjTnmEjnh2Nne4IFTVJxWQGPuTSAUqGlpnvSBs6n22Q58w3dY712RHYF9Rai3WdJW2OkyhdJ+EwUWtzmD0gJ36d+apPV5NfHBCEZc9AKFBYFUKdH9VTdjYI9l6Xglt+gGcYWoAE3yD/cPo7ckCUOKH2ApYQ== 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=f7RhicwbS2eTmJrJbAqfyNfan6JWcc35tcpiH12PiNI=; b=LYHK41qmDLJW9Pih4UUhChtBM1kCkiWLtXicYCwYw5tXZhnYb3LNGERZAT4J1LnIsf4FWmdvCP/X7NX009+evSkaNYBheeUs29pL/6cr0zCGbYtz9L9UbEvHwplXa3XdFa0fkKbYwT4r/nD8yy8/RC323Xvu+vmilyGF2HLU57+T6zK//7IV2t9uMh4zQPhZl2ybj3++4bdx/JHXGTuTZkZPcmpqelJlBBRxE36mNlH2W3fzVcuxZBEOqa2rzUYoTHrRfRP3GlN+o2H52wF3hRsbMMsfD2lTtXAZsUmoBj0AGw/xaspGGsYU3ZPz7Gu+R54jdpbOK7obHYeCJjvQNA== Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=nvidia.com; Received: from LV8PR12MB9620.namprd12.prod.outlook.com (2603:10b6:408:2a1::19) by DM4PR12MB7717.namprd12.prod.outlook.com (2603:10b6:8:103::14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.9891.19; Fri, 8 May 2026 22:05:14 +0000 Received: from LV8PR12MB9620.namprd12.prod.outlook.com ([fe80::299d:f5e0:3550:1528]) by LV8PR12MB9620.namprd12.prod.outlook.com ([fe80::299d:f5e0:3550:1528%5]) with mapi id 15.20.9891.017; Fri, 8 May 2026 22:05:14 +0000 Date: Sat, 9 May 2026 00:05:01 +0200 From: Andrea Righi To: Dietmar Eggemann Cc: Vincent Guittot , Ingo Molnar , Peter Zijlstra , Juri Lelli , Steven Rostedt , Ben Segall , Mel Gorman , Valentin Schneider , K Prateek Nayak , Christian Loehle , Koba Ko , Felix Abecassis , Balbir Singh , Joel Fernandes , Shrikanth Hegde , linux-kernel@vger.kernel.org Subject: Re: [PATCH 5/5] sched/fair: Add SIS_UTIL support to select_idle_capacity() Message-ID: References: <20260428144352.3575863-1-arighi@nvidia.com> <20260428144352.3575863-6-arighi@nvidia.com> <34ed67bc-6f1c-42c6-821a-ca9f1e56cca3@arm.com> Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <34ed67bc-6f1c-42c6-821a-ca9f1e56cca3@arm.com> X-ClientProxiedBy: MI1PEPF000008D7.ITAP293.PROD.OUTLOOK.COM (2603:10a6:298:1::42e) To LV8PR12MB9620.namprd12.prod.outlook.com (2603:10b6:408:2a1::19) 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: LV8PR12MB9620:EE_|DM4PR12MB7717:EE_ X-MS-Office365-Filtering-Correlation-Id: c75cdbe5-9be4-49ac-3aee-08dead4de17e X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|376014|7416014|366016|1800799024|56012099003|22082099003|18002099003; X-Microsoft-Antispam-Message-Info: JPk0QIIRkTpK+V9t6zwKVFob1mXxy9S/IOZY/UFKoirzqOxtwjnRI39JvUSv5r2ZgJUzchk/E1fZh8vXRYXq27RgJfFieeqQbdw5n34P8D1PHBsoqx+I3Xye7YOIK/Mse70+I2pupwY/u5l3sp3fmqO5qeMlKB1Gva4DQqihE1Rp8Hy7h4LJLWugUIXh3WnAFhVly49lP2igfZ4QasIwe3mcpVk3XJ9ahrWGYReD0Y5wNlhsOQ2Nx66e2r+ibRxruQCyJ9SfETA5KgqXrAk+KpjumJKX6ZITYDsRUjRYSxwyu/uVPCiHHnvKZ1j17Fq0j7KmClflLOmQo55n336yq/Ptjg90JHC16XdO0AnWgqTcJLj8NfdqBXqr5CmIulh2llczP2TqGOv4X7KdY4MzFIKtM4pi/PF6xEybD3zCbimaUfFw468AGkBn2N9aiNhdFazpWsfnZoOUalNVQi2U/ovQETR7+Ar8xCkZf5cZqy8Q3tjPWn/Pju+i3HInTh7IvcxopEs8/Jlnn5+1gy86k3vY331Xod4uFxvg+cUqsptz4MAHVV7KW7cI9BJcz8udWzUuSHiiMMXhE7x4Wz9llnU7LXoHs/Yy6Y+aW6jrw6zmJDwaLZC2tXYow6yjTB05pULTBCjHduk/Eju2IVSw0vNh36cEx4aB48IxFKeKqF/bTnaiDW+1hPnsBXq6nYSK X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:LV8PR12MB9620.namprd12.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230040)(376014)(7416014)(366016)(1800799024)(56012099003)(22082099003)(18002099003);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?us-ascii?Q?CHdH6mzCV9AlcTZcsAxSjFNIgRyfEyhRm++PDW09JO/i99JoWAAJdr45l/3Y?= =?us-ascii?Q?BZjIGeMX3dR1aYwWwwxjgNyuanlnMiSph8B6KpJzpXj+8tIyRIwvjqzKevBR?= =?us-ascii?Q?Ko7zPitiCW3+p4+KxsryPoBBN43abj4vWGfwjrJidPrYKLn/7zu9Fru2R2Wu?= =?us-ascii?Q?ILvyQUu5QPmcxs0gSDA6kzWPHlE6ueyx05opxiCOO6ey2Fd4YaKkredzf4og?= =?us-ascii?Q?2Vi+CZCKOPVHYSWYHIiAxiHWMe69IlKn6S3HQNBlgBjkjXAPkgLJzXRSJYW7?= =?us-ascii?Q?wgtdNFzoCCb5CsQff4Taw5FCoH0kkmSg1gKC9HuJAftXgSCcEFVvHpWhukNM?= =?us-ascii?Q?zyIrPMEYQb6uyoGQuUD42NS9pUyEyfi47h7Zw56b+vrh4Y9+83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CDYXGu2CSqLOTeUW2seSBPVDgD1Tv2?= =?us-ascii?Q?xlXcDug4nuU7SqmO1HQnB9Jmac0eVMMjjyyid8rBiTyDW1mYbn7L59nx5vC8?= =?us-ascii?Q?wmDL/3ndA3uNq7GiwAM1jtF3INC3VCHC4rbKoNxbqQsdvWw8qMAGBvHk9j5T?= =?us-ascii?Q?Qn+uQdCHUCGT5O/ayIhsi6QbLqkd7l3Q8X5J/jzDHAMkYo5APFxh8pmygYrd?= =?us-ascii?Q?wSUC9y+Bf3a2wSfkPSarZpngiJG4eftNimelUOsQ/jqoaGIAkQw0/utgjHPG?= =?us-ascii?Q?Bc7T637E+WeiYRdNKinEumeaDmSgEbjTmwRe6JPs7Z4AfkqRQv4jxB2GHz5I?= =?us-ascii?Q?BYG6Ylg3azF3zCyn0gTbmMnjHr6SuhQKYMDUwEE5Sk6Xa4Mlj+s4iswdqyFj?= =?us-ascii?Q?lDK/YibUBL3w52BeCoyPDCy1x4ZM7DWf0UvKZkt3FeFhGRH41brLVSjWWd6e?= =?us-ascii?Q?i/woztDsWQ=3D=3D?= X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-Network-Message-Id: c75cdbe5-9be4-49ac-3aee-08dead4de17e X-MS-Exchange-CrossTenant-AuthSource: LV8PR12MB9620.namprd12.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 08 May 2026 22:05:14.2607 (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: UO+0sqV0tEgrKEM+fOxFe6A6X9VSiQQcgw519TXdHBn0KAvSBZrNsBYp7PBGcM8iKD4vUtv3FvbeNALZaTDbXw== X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM4PR12MB7717 Hi Dietmar, On Fri, May 08, 2026 at 04:49:06PM +0200, Dietmar Eggemann wrote: > On 07.05.26 08:47, Vincent Guittot wrote: > > On Wed, 6 May 2026 at 20:11, Andrea Righi wrote: > >> > >> Hi Dietmar and Vincent, > >> > >> On Wed, May 06, 2026 at 07:01:35PM +0200, Dietmar Eggemann wrote: > >>> On 06.05.26 14:59, Vincent Guittot wrote: > >>>> On Tue, 28 Apr 2026 at 16:44, Andrea Righi wrote: > >>>>> > >>>>> From: K Prateek Nayak > >>> > >>> [...] > >>> > >>>>> @@ -8026,10 +8027,28 @@ select_idle_capacity(struct task_struct *p, struct sched_domain *sd, int target) > >>>>> util_min = uclamp_eff_value(p, UCLAMP_MIN); > >>>>> util_max = uclamp_eff_value(p, UCLAMP_MAX); > >>>>> > >>>>> + if (sched_feat(SIS_UTIL) && sd->shared) { > >>>>> + /* > >>>>> + * Same nr_idle_scan hint as select_idle_cpu(), nr only limits > >>>>> + * the scan when not preferring an idle core. > >>>>> + */ > >>>>> + nr = READ_ONCE(sd->shared->nr_idle_scan) + 1; > >>>>> + /* overloaded domain is unlikely to have idle cpu/core */ > >>>>> + if (nr == 1) > >>>>> + return -1; > >>>>> + } > >>>>> + > >>>>> for_each_cpu_wrap(cpu, cpus, target) { > >>>>> bool preferred_core = !prefers_idle_core || is_core_idle(cpu); > >>>>> unsigned long cpu_cap = capacity_of(cpu); > >>>>> > >>>>> + /* > >>>>> + * Good-enough early exit (mirrors select_idle_cpu() logic). > >>>>> + */ > >>>>> + if (!prefers_idle_core && > >>>>> + --nr <= 0 && best_fits == ASYM_IDLE_CORE_UCLAMP_MISFIT) > >>>> > >>>> With SMT, !prefers_idle_core implies that there is no idle core; Is > >>>> best_fits == ASYM_IDLE_CORE_UCLAMP_MISFIT really expected in such case > >>>> ? > >>>> > >>>> With !SMT, !prefers_idle_core is always true and we will bail out > >>>> early as expected > >>> > >>> I struggle to comprehend: > >>> > >>> I assume the mirrored select_idle_cpu() logic is: > >>> > >>> for_each_cpu_wrap(cpu, cpus, target + 1) > >>> > >>> if (has_idle_core) > >>> > >>> else > >>> if (--nr <= 0) > >>> return -1 > >> > >> So, the logic in select_idle_cpu() is that as soon as nr <= 0, we stops the walk > >> and returns -1, without any "only stop if the answer is good enough" guard. > >> > >> With this change in select_idle_capacity() when nr is exhausted, we stop only if > >> best_cpu is "good enough" (ASYM_IDLE_CORE_UCLAMP_MISFIT), otherwise we keep > >> scanning. Therefore, we're not perfectly mirroring select_idle_cpu(). > > But when '--nr <= 0', does it actually make sense to continue scanning > for an _idle_ CPU? > > for_each_cpu_wrap(cpu, cpus, target) > > if (!prefers_idle_core && > --nr <= 0 && best_fits == ASYM_IDLE_CORE_UCLAMP_MISFIT) > return best_cpu; > > if (!choose_idle_cpu(cpu, p)) <--- !!! > continue; Hm... yeah and only an idle CPU can update best_fits via the ranking down below: /* * First, select CPU which fits better (lower is more preferred). * Then, select the one with best capacity at same level. */ if ((fits < best_fits) || ((fits == best_fits) && (cpu_cap > best_cap))) { best_cap = cpu_cap; best_cpu = cpu; best_fits = fits; } So, we'll likely continue iterating on choose_idle_cpu() and the chance of best_fits flipping to ASYM_IDLE_CORE_UCLAMP_MISFIT after nr is exhausted is low. > > I thought we want to bail since it doesn't. The likelihood that > choose_idle_cpu() will return 0 is high so from the point of '--nr <= 0' > we would not be able to reach the condition to alter best_cpu anymore? > > Isn't this similar to select_idle_cpu()? > > for_each_cpu_wrap(cpu, cpus, target + 1) > > else > if (--nr <= 0) > return -1; > idle_cpu = __select_idle_cpu(cpu, p); > choose_idle_cpu(cpu, p) > if ((unsigned int)idle_cpu < nr_cpumask_bits) > break; Yes, with that said I think the right thing to do is to just mirror select_idle_cpu unconditionally and do: if (!prefers_idle_core && --nr <= 0) return best_cpu; If we all agree on this I'll fold this change in the next version (and re-test). Thanks, -Andrea