From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from CY7PR03CU001.outbound.protection.outlook.com (mail-westcentralusazon11010071.outbound.protection.outlook.com [40.93.198.71]) (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 9717734750F for ; Mon, 27 Apr 2026 16:02:10 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.93.198.71 ARC-Seal:i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1777305733; cv=fail; b=cIsnk4gonb2wujWaaZMdxBXV/8lJWsOmikF4rVr5nxfXmv/1ed8nPyuDOcUDkTpRFE7rhFpZoTqNAJdbvHZddZ2P6c5jmop5f/zNEY+1qpWnQJUKN9O2C3Ybpo8UCWsK1BZTLDNwvNzD5/JVWSayxsjQo/Ffa83CVj1TLkvcg1E= ARC-Message-Signature:i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1777305733; c=relaxed/simple; bh=o5OAaXpCZmB2BIEXLKLRzQcez8NBWWFZX5kAo2u7ID0=; h=Date:From:To:Cc:Subject:Message-ID:References:Content-Type: Content-Disposition:In-Reply-To:MIME-Version; b=TqGot41lbtlOLDB/RVC7DXL8+IGiNShUwd0QEHYE27U9elPHwGc4pGwBEH3g7pHzXnrz+MQEp8SxVFxEkljHfa976W9lKHbzjx1gR0upUXXDM1xhbyqXelcrotFKdYAJQhkJRPtRa7h2TBoqTA0BN+fmABIDIzkRcm1eP9sUWw0= 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=JbZNgpLE; arc=fail smtp.client-ip=40.93.198.71 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="JbZNgpLE" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=Yp6IAolvEhJVtu+dMP6THYFoqi0eBGEPk2J5IBQfq+tsCivu3kziw6aCTQvq5bMPwVdyYlRkwBTFjmIzgh4F3C/FZO5+v8erlvzV4ERzqlqew1Ut9qmkUxZOQV3Fuoi9UM6n2n/J3X5n+eQ2icS2WPcha3Ac0Tqei9tTfS4dGWsPkPbgbnSSiCpqJJJObDEZ7E2DhC5xhEIXThk/I4g1McLUVi2YjIHYfoka9dW7Cbo78dZ4tTM4t98jTDrYsQu/j+EP7xFwpfaJ7WmZUAnIIQ7E/b+CGk+1sE2SS9co509FMTNshG7xImWQsICM2G8PJBjonSuEuTfI42GDCEXWsA== 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=QHnueURQSKFYqyIrb7QIWUWCMhuG0+gOgTC5SdkRuSI=; b=cdYUvv/0uGu6BGrSf2PThL81QqLUXw12/i+tMBfMBiEscxSVFuYNIg4RN7gguBTkP2a3jRp96mRBt3ItUhbqCKK215ajLAOgy720QKDEwFz+anWUu3GU8XBwUv2nmW75wCkxZob/zCY+t3dFZptVAzc6dVcH8Di/X4GCQeuXv1Ux9X5CzLxKH5nn6p5scm6omgpFpFs4UEe//EJ/BSkutNk+FlKVW01SSUQb9x8OGmUnjS1inI7iBUV8P3eFaAF2lPDihiZKEZWL7yXwA/1F9QX40MJYyMJyoSMA67lzuzFZOVe4Kvh7rnnS3aw/pw05nucbthPEIZDeDBamHFV0Pg== 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=QHnueURQSKFYqyIrb7QIWUWCMhuG0+gOgTC5SdkRuSI=; b=JbZNgpLEEOWNOhxOnGCRf1jCYmolPPDVyp6THClSFbgWE6riMKxFk8M/vOZVSRXoMN+iB07/WwoTL/x60Jz6Sxk4y7cFi7f65smtVSagKaXLwizhtdpFuNymXGhhbjPBMFseQW83M1fEl2U0EQVOTvGRyKCQMiut5opZUkuX4Blxedw1gi+ujDHZ7ETh932wEg6EDEls733usPnLfPEJgqZs7qAu/5z7Vh8KWscjbRgcUc99E0OfkZtP4z4NgQVSukzdWBYt7DZLTHi14yvDK/kMqa8GHG8LOs4tkjxXUhKNvr71Dmy2EEPWp6Hbv5BKu6rGlFfRKn3es/znLxZxpQ== 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 DS4PR12MB9796.namprd12.prod.outlook.com (2603:10b6:8:2a2::21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.9870.16; Mon, 27 Apr 2026 16:02:06 +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.9870.013; Mon, 27 Apr 2026 16:02:05 +0000 Date: Mon, 27 Apr 2026 18:01:50 +0200 From: Andrea Righi To: Vincent Guittot Cc: K Prateek Nayak , Ingo Molnar , Peter Zijlstra , Juri Lelli , Dietmar Eggemann , Steven Rostedt , Ben Segall , Mel Gorman , Valentin Schneider , Christian Loehle , Koba Ko , Felix Abecassis , Balbir Singh , Joel Fernandes , Shrikanth Hegde , linux-kernel@vger.kernel.org Subject: Re: [PATCH 4/5] sched/fair: Add SIS_UTIL support to select_idle_capacity() Message-ID: References: <20260423074135.380390-1-arighi@nvidia.com> <20260423074135.380390-5-arighi@nvidia.com> <44bb43b1-b033-44cd-ac98-3162af74ca1d@amd.com> Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: X-ClientProxiedBy: ZR2P278CA0049.CHEP278.PROD.OUTLOOK.COM (2603:10a6:910:53::15) 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_|DS4PR12MB9796:EE_ X-MS-Office365-Filtering-Correlation-Id: c552cd2b-1f95-43b0-728a-08dea476539c X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|366016|376014|7416014|1800799024|56012099003|18002099003|22082099003; X-Microsoft-Antispam-Message-Info: OEHZ61Nz8vYO/upyaAHVouM9Adv2lxSOsV9xRAoRtCcfkcT1TAESR3f7bsKFK6wvOWcGtUml9ztinNKRyT++Z0U+xVZdfSdCZJoShfbmcNsq9gi89TXDD8PbK1q5FsMTe7u6RzV0JTtTFRWdWMv3vJA8Y4nvYTJOhpg6ChZbbjF4itrHmF8j44dd1/uiIoAxkSW4u+874SgyHp1nLHTA53ymmy80SSK5HUj4ptU5qcSqS0xJZZjhudRmqgXTaCIOEvnSXi35xrbutsAP6ljmPdwj4V0r5XeP86WIjeRhcVrMb6uAH/ExEW3+mTlAkoa68o66DTvNN6K2NslGImxHguofhmqr9qXzfdl/VE+7Sqx0AywCI76s8GCSLr2pG0Yy0REyZUZwh1HUnu4pYQ8VeioeM0sCp7NdtRRq/hH+ctRbtxkTDVjyLKbhz2OX/MyB/BGDwK4Q205BhsY7qG28rKrwH0A/4HZwTPvWNDo8CKLrKV4yN3gOoItJXJ3aM87PUAbKUf+dzIZhooUIhdknPxZnkrcHRTaKQibRI4IFeUZEof4PQP2QgzFpys2TV791U+l0zE0Jix7uZRRK5z64ZbupEBICHoALZ0xRWYhKxbpbDoMrg9FSw7fBrxIxhBPi3W/MnG7NfPIvRhYKzQTmbJDLo7VLFFhYg+T1ixM6cxU1OZ7A9zgIm9FrUNca+viBzId385S4toJuCdVdaii6dBS3fAqlqGv3IA3zFg0E44I= 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)(366016)(376014)(7416014)(1800799024)(56012099003)(18002099003)(22082099003);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?us-ascii?Q?LiIRkUiLpDTRjd94p2XpRYDHu4GkJnu4S20wF7RZYrUYdDZwuUeItisEmYRk?= =?us-ascii?Q?E91pPbojCHEOkss552MzOs6ecOFHG1qQXe9KyOcxipV2cIkopWfFLblh8mhI?= =?us-ascii?Q?upXWAAGBjkTaVrwb3KQ8Ze0fZWz7YCF7uy6OEjzK9xialQ8ZFhzoXTS93eNH?= =?us-ascii?Q?wIPiMlJFN9n/i3faRiCuMRKlJzNo8WZqM7UQBUDrUfexn9u1Z5Grhay7X8+g?= =?us-ascii?Q?iePBDiN+S4JmMleVYavZXgH47Lg0vaZyikBf+MyGuuU19kvQVs7r7SCYW+r7?= =?us-ascii?Q?DogjlpgoyhU9bJEgehN4JCjbi8aWk5zrvcJgtnUtxOZWm2HYQ6tXvGSx/ZWh?= =?us-ascii?Q?AWRzv4SECA1iwN70Uu9n53Y7IGL5Dpm5bxHQG1gFGFNAZwm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X/qGJ3cFtwljuP9BFKcbOMK5mnmXjZbQFtFud9d8rKk9XthOoKq?= =?us-ascii?Q?oWr6rq4BdA5EO4vaHgeWH1ZMilHg7doqYCZ3TCHcNtu4IU/xX+GaeA+rHbEE?= =?us-ascii?Q?Ny6f+4RxsRXqfqhEbH06jRMfLeZoAy1u70jTxLCP1fl4Zow0xlxEeq/oVV6N?= =?us-ascii?Q?HRU894kXwDQoACEpg6vIH/Vd4LrX4s5oCTq+MIp50+ZfgpG0oUsf97MSNpGy?= =?us-ascii?Q?cW0tbCUWDuMFwLeF4P88aa/Uo7sKZNzJWuMI75nPVpozp44kr1mEKco23vld?= =?us-ascii?Q?VCeUtmJEEIBhHQNOPC5pqdxxl7VMz3Ke5reMOa8vVW6IHOPGkF63RBQft9+B?= =?us-ascii?Q?Cis3X83Qu7MBFQ8+zMe1d6b6w7+QrwS1eS8W1i1bEfwWG3rTEtaWcHe3ojFr?= =?us-ascii?Q?mc7kZ1N/Yc6A9c3xHM3C/55GdF/j4BygP9i6py1kTh+90bnqBnH8pIwHWuDV?= =?us-ascii?Q?v340dQpW6w=3D=3D?= X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-Network-Message-Id: c552cd2b-1f95-43b0-728a-08dea476539c X-MS-Exchange-CrossTenant-AuthSource: LV8PR12MB9620.namprd12.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 27 Apr 2026 16:02:05.1211 (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: I+9Quv4n+rHO5tovN8QsZ0xQrbqbXSlsxQoteYsTlm1oxAKJyqAjTkgGzSzYsdw5kZzgtttMMK0ycXWI2jYruw== X-MS-Exchange-Transport-CrossTenantHeadersStamped: DS4PR12MB9796 Hi Vincent and Prateek, On Mon, Apr 27, 2026 at 10:35:59AM +0200, Vincent Guittot wrote: > On Mon, 27 Apr 2026 at 07:13, K Prateek Nayak wrote: > > > > Hello Vincent, > > > > On 4/24/2026 6:02 PM, Vincent Guittot wrote: > > >> + if (sched_feat(SIS_UTIL) && sd->shared) { > > >> + /* > > >> + * Increment because !--nr is the condition to stop scan. > > >> + * > > >> + * Since "sd" is "sd_llc" for target CPU dereferenced in the > > >> + * caller, it is safe to directly dereference "sd->shared". > > >> + * Topology bits always ensure it assigned for "sd_llc" and it > > >> + * cannot disappear as long as we have a RCU protected > > >> + * reference to one the associated "sd" here. > > >> + */ > > >> + nr = READ_ONCE(sd->shared->nr_idle_scan) + 1; > > >> + /* overloaded LLC is unlikely to have idle cpu/core */ > > >> + if (nr == 1) > > >> + return -1; > > > > > > The comment below applies to select_idle_cpu but we want same behavior > > > for both function > > > If test_idle_cores is true we will not look for it whereas we don't > > > care about nr value when test_idle_core is true in the > > > for_each_cpu_wrap loop > > > > Ack but the initial "nr" based bailout in select_idle_cpu() applies even > > when test_idle_cores() is true too right? > > Yes there is an early bail out for nr == 1 even with idle core. I did some tests changing the early bailout condition as !prefers_idle_core && nr == 1. On Vera I see small performance regressions with this (4-5% slowdown), especially when approaching system saturation, which makes sense I think. At this point I'd personally stick with the early bailout condition, considering that it's still consistent with select_idle_cpu() and it seems to provide slightly better results. What do you think? > > > > > > > > > > > >> + } > > >> + > > >> for_each_cpu_wrap(cpu, cpus, target) { > > >> bool preferred_core = !prefers_idle_core || is_core_idle(cpu); > > >> unsigned long cpu_cap = capacity_of(cpu); > > >> > > >> + /* We have found a good enough target. Just use it. */ > > >> + if (--nr <= 0 && best_fits == -4) > > >> + return best_cpu; > > > > > > In select_idle_cpu(), we return immediatly when nr == 0 and > > > test_idle_cores is false but we loop on all cpus if test_idle_cores is > > > true until we found an idle core. In the case of > > > select_idle_capacity(), I agree that util_fits_cpu() add another level > > > but shouldn't we continue to loop even if we found a best_fits == -4 > > > > I see what you mean! We can additionally guard the bailout on > > "!prefers_idle_core". > > > > For the case where test_idle_cores() returns false, is stopping for a > > UCLAMP_MIN restricted CPU alright if SIS_UTIL bailout suggests it might > > not be fruitful to search further? > > > > Do you think it might trigger too many misfit balancing? > > For SMT, I don't think this will make a real diff but for !SMT this > would indeed trigger more misfits. You mean the SIS_UTIL mechanism in general (not the extra !prefers_idle_core guard), right? Because in the !SMT case, prefers_idle_core is always false. Thanks, -Andrea