From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from PH8PR06CU001.outbound.protection.outlook.com (mail-westus3azon11012006.outbound.protection.outlook.com [40.107.209.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 6258B3BFE2F for ; Mon, 30 Mar 2026 10:17:24 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.209.6 ARC-Seal:i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1774865846; cv=fail; b=mbnutzk7Xt0jC/Btly/IQhuaoXlnhta8mT/QAdOEC/eRgsOCXYlT8ofLRgsm83c+YPdYKTJC7lpHWIPCgqPYyXVbB2y0ZCYxA7RMA3tK7MddHOSvNvl8KFhmqAYnHrG6hkQnYrh9WiTjqI+Qpf9KTk3d6mwrRV2wXQcztEM4Bgs= ARC-Message-Signature:i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1774865846; c=relaxed/simple; bh=D93S9u1SGoMutIpMC4qRfgOQpYfeeXxx9AMyQPJMpXM=; h=Message-ID:Date:MIME-Version:Subject:To:CC:References:From: In-Reply-To:Content-Type; b=BFTm/BE6i8BZXJhChujs1ZHyMqYyPXU6lMFCXd2rlz9NWKxNts2HVCXbAX3VYgKPt2YFjf2Bw0dPl138AyToKP3H9SvhaUyJdfYG3Ihvalw/Od3SWjv8wGnMy7yZKuxlHubCexY4X21s5uJCPSb3DQ+sIQNVKncFzcjbVETJlpU= 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=Fpc5sY5U; arc=fail smtp.client-ip=40.107.209.6 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="Fpc5sY5U" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=LU3sg5sWiWhRSQ+dOQcRkNErmkztirV53DOr/Vw2DDMAQkd/2qU9GqJY1pdXjNWonqI1PSNDtxdBgzQt+8h59QzqRdQjqQwUgnL6YyRy4lJesGS3v61uruq//htqZY37J10kLqUCdlQkvIF6m5xhxKdFek9fbMKX1lDvvFoQ2/BXIoME9s5m3tZobxwRep9nf6KMbVqJUd88I2vj9q09qlR+cZJKccJvjX6xNCHkEE4Nrdcp9hfnbPJBFSZvUWjAIgV4IiJ9WbOfR9W+PvO6vFVFGvLicbYT5VngGYQ3vEB+O4mlczxqYDv4uFTLHcGvZrsSsyu4Z3njmguGGshHDA== 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=/IzP7i6QcJ9sR/w9f/Gb+3OiKThR754sBHYevfkceA4=; b=aoCM+6YqzeyPzcUGH8s/Y6Pb5AAfUsyQL7kWSvrrd8oDApx3mkWU4j35xbPHjiY4I3A97kTvipl26rOGwN+Jih1SisgtcS8FLN1RTEHpZUD/8s2/ndSaW+xr3/HsXo++3Fu1NwLEtxis8p8jlWjJWTZzRmZvXYFMVwm/KqxyYLuXK4zInRV7hXQvWZyO+uhQQG4SiiABxeSaACksetPpXSoCV7rKkbtYGVdsATJmVF7qNM8q7wkeu0TQrKtULmRq7DRymYa2oFigrEREkLKh8qJFtXeC9eOYBbLxnGLpfAwSE1cr1+L61Xg+UAKv2eUBtVAxH4387AKniB+WvntXCg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=nvidia.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=/IzP7i6QcJ9sR/w9f/Gb+3OiKThR754sBHYevfkceA4=; b=Fpc5sY5UTTx94yafrLJzgPnRYbXMAUmIJfsvvQQd1BmIyh0BFW/7jjK76WKjjYwH0zs8nt/867AG6qh2vfLIbV9oJxG52ADzCxAEZPIWG/SoxlBD27vC+0USgBDQ2jRzUTfWCia0S+t6b2+R6LAHHViLKPc+23rOq+uMfncIfw8= Received: from BL1PR13CA0268.namprd13.prod.outlook.com (2603:10b6:208:2ba::33) by PH7PR12MB9103.namprd12.prod.outlook.com (2603:10b6:510:2f5::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.9769.15; Mon, 30 Mar 2026 10:17:17 +0000 Received: from BL6PEPF0001AB56.namprd02.prod.outlook.com (2603:10b6:208:2ba:cafe::f0) by BL1PR13CA0268.outlook.office365.com (2603:10b6:208:2ba::33) with Microsoft SMTP Server (version=TLS1_3, cipher=TLS_AES_256_GCM_SHA384) id 15.20.9745.28 via Frontend Transport; Mon, 30 Mar 2026 10:17:17 +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 BL6PEPF0001AB56.mail.protection.outlook.com (10.167.241.8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.9723.19 via Frontend Transport; Mon, 30 Mar 2026 10:17:17 +0000 Received: from SATLEXMB04.amd.com (10.181.40.145) by satlexmb08.amd.com (10.181.42.217) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.2.2562.17; Mon, 30 Mar 2026 05:17:17 -0500 Received: from satlexmb07.amd.com (10.181.42.216) by SATLEXMB04.amd.com (10.181.40.145) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.39; Mon, 30 Mar 2026 05:17:16 -0500 Received: from [172.31.184.125] (10.180.168.240) by satlexmb07.amd.com (10.181.42.216) with Microsoft SMTP Server id 15.2.2562.17 via Frontend Transport; Mon, 30 Mar 2026 05:17:13 -0500 Message-ID: <258e2e94-ee42-4ea4-998c-4770732cbad0@amd.com> Date: Mon, 30 Mar 2026 15:47:07 +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 1/4] sched/fair: Prefer fully-idle SMT cores in asym-capacity idle selection To: Andrea Righi CC: Ingo Molnar , Peter Zijlstra , Juri Lelli , Vincent Guittot , Dietmar Eggemann , Steven Rostedt , Ben Segall , "Mel Gorman" , Valentin Schneider , "Christian Loehle" , Koba Ko , "Felix Abecassis" , Balbir Singh , References: <20260326151211.1862600-1-arighi@nvidia.com> <20260326151211.1862600-2-arighi@nvidia.com> Content-Language: en-US From: K Prateek Nayak In-Reply-To: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: 7bit Received-SPF: None (SATLEXMB04.amd.com: kprateek.nayak@amd.com does not designate permitted sender hosts) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: BL6PEPF0001AB56:EE_|PH7PR12MB9103:EE_ X-MS-Office365-Filtering-Correlation-Id: 4074833c-365c-472c-233b-08de8e458551 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|36860700016|82310400026|7416014|1800799024|376014|18002099003|22082099003|56012099003; X-Microsoft-Antispam-Message-Info: Sp8eXweoE+UwAUSGwc33lkZgLvRPrtiyWu1Ew/t6yB0XkW4ufWuHpcvpUZdgIRsq9BR627TyOVDiMil6NPxsZwnkVHhcS2NCg2E+K/PSPHWCKTu46uE29sZ1HOtlde8PS8U0mBA4gBOOb1uvrnGL6vwZZ5iHjgAPt7UkpF3STfvryUXVBAVvSAVm1q94zpraJx/+deUmfMoElcgAmlodgG0QhdkyGUUeTTc6OvWEdKC4cjkeO/3NBsCWeQiA1nnqN4/RhGL2StyH44Le1xv/AOy1w2NJ3Bbu4q108OtfgvRKxRoYq7Rx6tTF450iDJ+hxr42rilIC2OGvJvOh8xGdObvk3CMrGUY13pLAnNeueJRm7hqexJ2EGPg8hdkQUxIRqFicpMnEt80VFl3wCCitb5yVU42MjqD/+1E4rI7jLChSi7tjVxPqg3Zm7XASMGH7hgF5ABTtuvStWbaAJ1KgQxfdvD0BVbdZFOmxP2oVMq7HvusxhHCi/U3J+CkXMOe0CC/VFWboINLKGw7A2p8oLUcSc/nfx2GLNSLMBFK0iOdI0ZXjDHtgY/vzD+SzPgshc9X+mGpvVZjRzwZ9bRO8r/FlZz11uhEpCmgAl6vFclRVwaYpWyiNsIsgWxV+Ud4kp6EbwLVph9Ltm8MrN1bhdfZOfS8LTYJ+QLdkBeWoon7jvSgDmDvTnFb0rs925baksj+LLsBMflWUvzCKx3XHy3yt+AmaLWpv0i7j2KdI9FFEzA14bHa6VblbvE1GMSStEjao+HNicGCiRzqMJm3hQ== 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)(36860700016)(82310400026)(7416014)(1800799024)(376014)(18002099003)(22082099003)(56012099003);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: jlbXQ59d/GC2xEYuI5MnmAnoAT2T/sUf5nz9isus3lf4Crnw2V4uZv6XoOiDdl9t6xj5TW1GxsN5F7/uZn66X3ZRz+t87L1ki1yuk2DWZm/yS3A2TkRwynl8xhhv8XlGzVYkydWH+hHf7ZU1U0fxkdMSwFq12dPzhZwOrzdQCyIXJLdxkqn4hDFGXsFoigXhlR2s5IHgYjTnRoByTyNF6oe2LVIL4IurpcnBVFwQBj+GT8os9Jj5L3Kw3nL9D/7FSzwV4rfqI/5RbL2Vz4aHZKlzqUqqoiGc/rkM2wA36DnbSZvJtOxOPrvkx9bu7rSYhrBdYADto7yorHsupOk2+eDDS8CWavu4K6YZvRUuNt3kuIwkUrAzxs0cFwlslup9AyibampPvaf9jIBvAWfuwBGiQhBHm3rKdVMffdwNbIg43Sq2DjOxaA9tD3ipcEP4 X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 30 Mar 2026 10:17:17.3315 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 4074833c-365c-472c-233b-08de8e458551 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: BL6PEPF0001AB56.namprd02.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH7PR12MB9103 Hello Andrea, On 3/27/2026 10:09 PM, Andrea Righi wrote: >> My naive eyes say it should be equivalent of what you have but maybe >> I'm wrong? > > It seems correct to my naive eyes as well. Will test this out to make sure. So I found one small problem with fits > 0 && !preferred_core where even though it is an ideal target, we don't end up preferring it because of the larger "fits" value. Here is an updated diff: (Only build tested) diff --git a/kernel/sched/fair.c b/kernel/sched/fair.c index 226509231e67..580218656865 100644 --- a/kernel/sched/fair.c +++ b/kernel/sched/fair.c @@ -7949,6 +7949,7 @@ static int select_idle_cpu(struct task_struct *p, struct sched_domain *sd, bool static int select_idle_capacity(struct task_struct *p, struct sched_domain *sd, int target) { + bool prefers_idle_core = sched_smt_active() && test_idle_cores(target); unsigned long task_util, util_min, util_max, best_cap = 0; int fits, best_fits = 0; int cpu, best_cpu = -1; @@ -7962,6 +7963,7 @@ select_idle_capacity(struct task_struct *p, struct sched_domain *sd, int target) util_max = uclamp_eff_value(p, UCLAMP_MAX); for_each_cpu_wrap(cpu, cpus, target) { + bool preferred_core = !prefers_idle_core || is_core_idle(cpu); unsigned long cpu_cap = capacity_of(cpu); if (!choose_idle_cpu(cpu, p)) @@ -7970,7 +7972,7 @@ select_idle_capacity(struct task_struct *p, struct sched_domain *sd, int target) fits = util_fits_cpu(task_util, util_min, util_max, cpu); /* This CPU fits with all requirements */ - if (fits > 0) + if (fits > 0 && preferred_core) return cpu; /* * Only the min performance hint (i.e. uclamp_min) doesn't fit. @@ -7978,9 +7980,30 @@ select_idle_capacity(struct task_struct *p, struct sched_domain *sd, int target) */ else if (fits < 0) cpu_cap = get_actual_cpu_capacity(cpu); + /* + * fits > 0 implies we are not on a preferred core + * but the util fits CPU capacity. Set fits to -2 so + * the effective range becomes [-2, 0] where: + * 0 - does not fit + * -1 - fits with the exception of UCLAMP_MIN + * -2 - fits with the exception of preferred_core + */ + else if (fits > 0) + fits = -2; + + /* + * If we are on an preferred core, translate the range of fits + * of [-1, 0] to [-4, -3]. This ensures that an idle core + * is always given priority over (partially) busy core. + * + * A fully fitting idle core would have returned early and hence + * fits > 0 for preferred_core need not be dealt with. + */ + if (preferred_core) + fits -= 3; /* - * First, select CPU which fits better (-1 being better than 0). + * First, select CPU which fits better (lower is more preferred). * Then, select the one with best capacity at same level. */ if ((fits < best_fits) || --- Sorry for the oversight but this should now be equivalent to your Patch 1. I'll let Vincent comment if he prefers this to the original or not :-) -- Thanks and Regards, Prateek