From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from CH1PR05CU001.outbound.protection.outlook.com (mail-northcentralusazon11010038.outbound.protection.outlook.com [52.101.193.38]) (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 CD33A368952 for ; Fri, 27 Mar 2026 11:14:10 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=52.101.193.38 ARC-Seal:i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1774610054; cv=fail; b=mGLOteNqK20fxnNRR9ZwFXAWsHGZkQ5GmqfmTyCUtvPBFZZv4uk+vP/N0N21+LK8DQ1TkBrsgcaMwIddcH0DM9U3FHsNi3sGBRCQkl+MW2RZm6t3vru+iEIdCTrou2AtofRWrH/VRY45HZ3RhDZJKJoqTbXuv6QzhrTVMzR9qNY= ARC-Message-Signature:i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1774610054; c=relaxed/simple; bh=fYwM2SRtT8l9MkyWzy64xaXsqC3Ye6xEhDhAzz6IVsU=; h=Message-ID:Date:MIME-Version:Subject:To:CC:References:From: In-Reply-To:Content-Type; b=a4D++QgrZN2VLRvLeTdU7ZTN+7PkHfQWM+ePh4LF2X9RKaCSzS/qC4DQb6ImGiDPzxm4ZZhi/UQiPPQnCi1KxRCrJDgWng/7CTMAsR+wEYjaDBkme21ilSSYcSBVDA52+RdRySrmJZs/h7Wu4/N7BKI1ibReG0xbS7LYyWFu8gw= 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=EVVegBLX; arc=fail smtp.client-ip=52.101.193.38 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="EVVegBLX" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=jPmpvQJIIrXol2/rf8NRbxPGNEWf9g7KCGHp11cJ9QnmPwU4t05nUVRO1SaDiTITVjh62JNNxAXQtUgMktqDe03wXF8xzroXL+9UX8nM29yBPx5DnhWfbgSw8nKlgaWLsT9jZdPylTF5AiZHAlaYVAFc2HDzpUqoUJ1Bz/iYSJSy/lzLnz9Gx32Ou+XW0/E27/NJqpxCHQezNnmFLtxGg8HZKAdpcRP0yRdceraDa0shcqao3gBh94qwZT6VfICz6Gl17Vxp3YzHpirqkkNYCCHupx49fYMAxWUEAiRV/Eh7tFxbVLQ8qikWQnYUVWzKoGKZCycyXUQdswE6Vs0hUw== 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=AG0g4k5mqogUrng77iyvu/fv0KA7mj68HYEKjDYxiVU=; b=hhH4T8Pknr12R+AZDGvisK7coNhTOYR6qLuEDsRHjHREOJTHsocv6Zs4EIqUf0cPjQi6yK1NTdq4UUBlPo/cWBkJwV99kaAQ1uAYZWZSgw3xFvl/v9TBjGNicGcYgzowJZF2emOeiMSanC65dIHaIw7LA8A4+A/EFWs645UIyYq+EQ4k/Aqzrs20R6VqkNXJ6c1hpq+6EEorIsQDCSBFwvoq6JygBULQBzAVQKq0qTFWQyFpX0BA0362oZd2IbnAFR7shOISDdqSbRru4MjEXAHyh4L093lzLyXukc+CuXX1YlSpxmWar3FHlC/48PdLwwpbaOUzd/ZIt0hA6v/egw== 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=AG0g4k5mqogUrng77iyvu/fv0KA7mj68HYEKjDYxiVU=; b=EVVegBLXeQ6d+kABFkXmxs6nm1x9vgXkVX6gJAvPEXF7+ZNf8veI9OnQaYInifZcvXm/LUAjRy4ovWUQnf4es0OPgb5rd8BUk2n/+8MlhtcFFMyYmSac4XV7Bs7gr17k4+MGOBkWAruNJJHVDsvD8NadbLyllPNAldrOVjJnqEY= Received: from IA4P220CA0009.NAMP220.PROD.OUTLOOK.COM (2603:10b6:208:558::10) by LV3PR12MB9166.namprd12.prod.outlook.com (2603:10b6:408:19c::13) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.9769.10; Fri, 27 Mar 2026 11:14:06 +0000 Received: from BN3PEPF0000B06D.namprd21.prod.outlook.com (2603:10b6:208:558:cafe::56) by IA4P220CA0009.outlook.office365.com (2603:10b6:208:558::10) with Microsoft SMTP Server (version=TLS1_3, cipher=TLS_AES_256_GCM_SHA384) id 15.20.9745.23 via Frontend Transport; Fri, 27 Mar 2026 11:14:06 +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 BN3PEPF0000B06D.mail.protection.outlook.com (10.167.243.72) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.9769.0 via Frontend Transport; Fri, 27 Mar 2026 11:14:06 +0000 Received: from satlexmb10.amd.com (10.181.42.219) 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; Fri, 27 Mar 2026 06:14:06 -0500 Received: from satlexmb08.amd.com (10.181.42.217) by satlexmb10.amd.com (10.181.42.219) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.2562.17; Fri, 27 Mar 2026 06:14:05 -0500 Received: from [10.136.39.136] (10.180.168.240) by satlexmb08.amd.com (10.181.42.217) with Microsoft SMTP Server id 15.2.2562.17 via Frontend Transport; Fri, 27 Mar 2026 06:14:02 -0500 Message-ID: Date: Fri, 27 Mar 2026 16:44:01 +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 X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: BN3PEPF0000B06D:EE_|LV3PR12MB9166:EE_ X-MS-Office365-Filtering-Correlation-Id: 6428ccfc-f7fc-4a76-c041-08de8bf1f603 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|7416014|82310400026|36860700016|376014|1800799024|22082099003|18002099003|56012099003; X-Microsoft-Antispam-Message-Info: zZIIRQRXRuYpatamVDCfAjHRup4GTv+ygVfHJMqm9MsfpuBgTkFfF3EqakbOueh4gnUvSEaT1Z83/EAc8spfXWYKJPflDXa7rAzbsh9LNZdtz8yUnqzU1XxvGq+SXkn/Y8kh57xpf3vOA+NBrwsYvQlnjpM5YU3WMnJZtj6uecsMUCiXLcJuGcblikAhg9sok98153wmDvQwQcN099txc0GcWxzXVdm9pvmPXMjs2nHxT+/VMoEaICuOhuPUFsGutT5/xO1qcRjyAs56Qrp7c4Rxhi8Z/+GUVxpFAJg6+CgPiCitou5gCQ6Vpjjv/nc7L1kUT9wlbn+PBsMtRKYjsi8/vuGRnJuhhFDXS859/ined4eRjKDH2b20REaYf7qrZunq/s2w2FbEeX0c1Q0LqshjaNpfmfzDy3+mHIYkrPa/FBQ3tjJjpjv933Nnp1w6ViAqWdZJYbm51lT0oMdT3LNBdBbCV1e9xMRF0Jt4SMGIgTwqO/jPa06aiixiUUgCNpZZNneqcHd9DdMLhZd4CgeL0qXJWuzpCpeQcQKdFIlR3CjIZO+dV8zkSM8KtQew7tjaoihAp6yqG+NzhjABRpME2CFiF61QA4FI1L1rQz4+8o2XwAbBQwdpGq/mttiyMt4S2rfs3KuQ6ZrOpih3XSg7kbbeyCMa3HwEy5sMxSRHHqHDezV4bVFWN8SIdR1JJEP/+Iwy7dDhueKr/anDnukX9+L+w7r43Amv7Jf0wGFHbSH7JJHEaRhQ7rQs2q4NXrU+QzBMT0DtLMa/a0rr5A== 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)(7416014)(82310400026)(36860700016)(376014)(1800799024)(22082099003)(18002099003)(56012099003);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: dUJbybbhHVtaSrMqB5dbM7tnCmWsvLFEAJWwUq51YG5Ucmhi25qDkNMgbPf0QbeMQn9yKBiHUZ5QZnwLuXJwAVT5n+bLb++35FCXRvpi1Ie8gKXR6nhxDs3IJsXDJrTrw21+6rfm8IvMfxDJ0uRso/SAdck4+zDT6bpudV5OauqVy/+Lq1lKy2N8P83hoRkbehOCigtZ6DD/MJ2KrwswydgFy9v1S7KWX/eadcvW72BePZUE5d+6DuHBzQNnXnFckNWrpiCEVfCi8in7JuI3LQl0N0ziKvapP5cVrCgahXPk3vEdCh7tk6tiutBaWpOLQvUabOJYKQWZ5FHitzi0s6PxuZujbjPX6cx42cz3ssDDp1DtvSAP/PtfvAX961cnNV1Rk2PKYP+HdQXy6Cb+TsX33tON05u8HQfXlg/G7rx0jsWucz2WjjQO/OVsJ308 X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 27 Mar 2026 11:14:06.3582 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 6428ccfc-f7fc-4a76-c041-08de8bf1f603 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: BN3PEPF0000B06D.namprd21.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: LV3PR12MB9166 Hello Andrea, On 3/27/2026 4:28 PM, Andrea Righi wrote: > On Fri, Mar 27, 2026 at 04:14:57PM +0530, K Prateek Nayak wrote: >> Hello Andrea, >> >> On 3/26/2026 8:32 PM, Andrea Righi wrote: >>> /* This CPU fits with all requirements */ >>> - if (fits > 0) >>> - return cpu; >>> + if (fits > 0) { >>> + if (prefer_idle_cores && on_idle_core) >>> + return cpu; >>> + if (!prefer_idle_cores) >>> + return cpu; >> >> nit. >> >> Can the above two be re-wittern as: >> >> if (!prefer_idle_cores || on_idle_core) >> return cpu; >> >> since they are equivalent. > > Oh yes, indeed. Also, can we just rewrite this Patch as: (Includes feedback from Vincent; Only build tested) diff --git a/kernel/sched/fair.c b/kernel/sched/fair.c index 700d0f145ca6..cffd5649b54e 100644 --- a/kernel/sched/fair.c +++ b/kernel/sched/fair.c @@ -7946,6 +7946,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; @@ -7959,6 +7960,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)) @@ -7967,7 +7969,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. @@ -7976,6 +7978,14 @@ select_idle_capacity(struct task_struct *p, struct sched_domain *sd, int target) else if (fits < 0) cpu_cap = get_actual_cpu_capacity(cpu); + /* + * If we are on an preferred core, translate the range of fits + * from [-1, 1] to [-4, -2]. This ensures that an idle core + * is always given priority over (paritally) busy core. + */ + if (preferred_core) + fits -= 3; + /* * First, select CPU which fits better (-1 being better than 0). * Then, select the one with best capacity at same level. --- My naive eyes say it should be equivalent of what you have but maybe I'm wrong? -- Thanks and Regards, Prateek