From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from CH5PR02CU005.outbound.protection.outlook.com (mail-northcentralusazon11012033.outbound.protection.outlook.com [40.107.200.33]) (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 361CBEACD for ; Tue, 4 Aug 2026 04:49:23 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.200.33 ARC-Seal:i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1785818965; cv=fail; b=UPzCKMkgu6WQFsv3xDlQHX2JmWMgt6EVpc5ylqZJEEf3wHDUzyDE5Xh5JcV7fwtBfPF6f+2VlDd21kDgWhHZI2wyZwZHEcWzVXyor08nOUHSwdAdhAkGTk3AAg3xFrPVePWDZg9g6HjbgTIfGLQwwFK6CCxKxEvYPBhFSNckZlQ= ARC-Message-Signature:i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1785818965; c=relaxed/simple; bh=mNLH2LrLDHCsO6ez70M9zq4U4F2YmmKqcMvmDChDYmg=; h=Message-ID:Date:MIME-Version:Subject:To:CC:References:From: In-Reply-To:Content-Type; b=TeS4XhqYdW3TI1xdGP6KYQvMqM0Wdjw1WrhNtJWR3eKGUD31qn49kNkARH5lO29okJFvblwVbAp+CwWKXkwiZhrYNMVVc0bvzw4owPUaMoXF6YHJs61ev48Eqo9dG8MdIgUo4BejpAwU1p3Jobrr9f1fh4qpOSzVKZ+jMIEH23g= 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=fhfNmHKb; arc=fail smtp.client-ip=40.107.200.33 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="fhfNmHKb" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=G7b88LBa0u5w0bea+HsY/L2UtZx20+ulmVkXiIi3kI8KEvEEBPA8UtyqP2iJDGkg6tOygpXLigr0N6N5ic+097xWpMdWwGD9albaIa2XyvpmerPAyolhTeF2ZGuGWY2mc2MY3GJ3CGHnxuubHcXGCxn17pbKaX/qwV1L0x48B6khcR3N/pkUEQqO9uI6pX7KOJfAemNNMgExZhYCntLEyrwM1mnXNGjJpNxjV+hIEho7Up4eRODFflEweWuLf9sRCxuZoUdCn1ODlA06FMYoQYPDy7y7BAdOqmq0GdWMf+9r4ZVGeGD2kKy4VuIa/1Cy6Y53bWteXfl+ZFmQrh2qxQ== 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=L+72BFjB1hAKUwU6OChT99cMWPowpvcERDmeWzPTy4M=; b=ZPq4nP4K/37LW/+RzSbj+Gleyk5tMi3TmMrLlbQR6DfdB527w3eEtMxfXGkdUolxrMlLlKm7FKe6XUyJ/mENHJWB5S/TFJTEVrWT0S5FglcUAMEhvU/Y4q3k+MMcTiGCe8D9QZpDp1tKV7C+lj15nGHa6gMr/5DbaW1iqUb7/T+kTBXjY69KGVkiAKAaxol4KXCia3W3zf2eqxQEu4dH0tc6lXoummS3m4Rfokuo2u4/aBGUls6L9XuKxGEgJT43f7cT0dmE2hFjvnauBm729xoSvvrzzh4XbkJnZxmJLgQ4BWobBcJ3hy0A4FCHjFK4ou1Vp0GTEDglA1Q793tf8g== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=linux.ibm.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=L+72BFjB1hAKUwU6OChT99cMWPowpvcERDmeWzPTy4M=; b=fhfNmHKbK96H5YQ+FOqYWS5XFjRIIycmmJJL824StzKvGHUKzsPr2Nb8/HWC+JHg/JwMdQ+PBYSYannBQcBUo6cCzFkhgXwO7NdS+BmK4OsliB8TSf5QbXXyxpgmct00q2xXk1zER6Q98ZD3FcRKmtb0rxPpqr63QDKaMW1gXCc= Received: from CH2PR16CA0007.namprd16.prod.outlook.com (2603:10b6:610:50::17) by DS0PR12MB7631.namprd12.prod.outlook.com (2603:10b6:8:11e::11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.21.270.18; Tue, 4 Aug 2026 04:49:20 +0000 Received: from DS2PEPF00003448.namprd04.prod.outlook.com (2603:10b6:610:50:cafe::a4) by CH2PR16CA0007.outlook.office365.com (2603:10b6:610:50::17) with Microsoft SMTP Server (version=TLS1_3, cipher=TLS_AES_256_GCM_SHA384) id 15.21.292.15 via Frontend Transport; Tue, 4 Aug 2026 04:49:19 +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=satlexmb07.amd.com; pr=C Received: from satlexmb07.amd.com (165.204.84.17) by DS2PEPF00003448.mail.protection.outlook.com (10.167.17.75) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.21.292.8 via Frontend Transport; Tue, 4 Aug 2026 04:49:19 +0000 Received: from satlexmb10.amd.com (10.181.42.219) by satlexmb07.amd.com (10.181.42.216) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.2562.41; Mon, 3 Aug 2026 23:49:19 -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.41; Mon, 3 Aug 2026 23:49:18 -0500 Received: from [10.136.47.95] (10.180.168.240) by satlexmb08.amd.com (10.181.42.217) with Microsoft SMTP Server id 15.2.2562.41 via Frontend Transport; Mon, 3 Aug 2026 23:49:14 -0500 Message-ID: <492e6bb3-504d-486a-ad9d-226e9d7235a3@amd.com> Date: Tue, 4 Aug 2026 10:19:13 +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] sched/fair: Let sync wakeups target the waker's core To: Madadi Vineeth Reddy , Ingo Molnar , Peter Zijlstra , Juri Lelli , Vincent Guittot , Dietmar Eggemann , Steven Rostedt , Ben Segall , Mel Gorman , Valentin Schneider CC: , References: <20260801035532.260625-1-vineethr@linux.ibm.com> Content-Language: en-US From: K Prateek Nayak In-Reply-To: <20260801035532.260625-1-vineethr@linux.ibm.com> Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: 7bit X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DS2PEPF00003448:EE_|DS0PR12MB7631:EE_ X-MS-Office365-Filtering-Correlation-Id: 3b7b8169-bd40-488d-c0be-08def1e3bf14 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|1800799024|82310400026|36860700016|376014|7416014|23010399003|921020|22082099003|18002099003|5023799004|11063799006|56012099006|10067099003; X-Microsoft-Antispam-Message-Info: mSgv2uSP25H7WiAINWOXPsV9ti1be23ilTa3dDh7gDaHdRwFjTu+muGCHCpz/NG4xC+bKfvfEvcYBmJ3SEhFfw1aL2V/b8Kvdjz0r23q/21hQ+ROtfvLnJADi66eiyWxkPIO+n1SdSon4K2w0UKgAQA79TKnP6nWEjhBwjmts7ubG4XZd2e3cMV4LcyFptueROF7fXArndBCrnoPmbCtRHKYmLrj4HRP6bJxXNGBfvq4sJxxY61YC7tGY+KxNgzPfImlbhwjdBB88IcZlSWKQnhSm6beKwd5o/J7L8Fqc0i9v9/ndApn56JfU6H31czru07t3xY2sNfg0H6Py8O8KBZYqWSYcnm171gm+UApxxIH3vtlRWd1NMioe1XHOPfTGl9Y9ZTd43sLoQJwi+Pxvk51KOn3Jp6mbzqLNZyyhZqoR2WqyiYUvDYgAvoYwAQwjvMB+6xHTkO+GkEDJddxHs1gRXtVHJqQJXX5S8XHiM1s1KEsDwNuh1vBPNJ/gJNHwfLzUNuRpDOg6ge1R0hOOlQBp/IL2v+esdnTIJDZlCtxl7+Qx9C2o6Z/K1J6ZFAQJc0I+GzEcxafuJan7MtrMSr5HQggiFKPUbp95I1OebYOYtbMQzjRzOz6R0TB/F/J2MWs2eYZOJB+xdMMYv7Cu5eA5amGRIhRTFDpFQhkypYvyolwNPixqg1//2qdbJT102j4Pt9gz94/raFhNExIBvGY/a5X6dsKcIoQn6ogW59SDn2fKqYsR4ESychImsA2 X-Forefront-Antispam-Report: CIP:165.204.84.17;CTRY:US;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:satlexmb07.amd.com;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(13230040)(1800799024)(82310400026)(36860700016)(376014)(7416014)(23010399003)(921020)(22082099003)(18002099003)(5023799004)(11063799006)(56012099006)(10067099003);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: 66z4wIpuZ/TBu3+LwDFGMhxjywtlFcTFQ1geSTYlC6FyP71RjYPDvqPZgjNY5Er/34h3+DveE04gWsUO3rvaFxgyNUxmawIC8poVerNS9y0rVDcyeCHuJHRYCE/0ZfM8qODE7uc8m+UT6dOkxKxJ2bDtgDJs4y17zexmG3qw+5LvrCKlE0685cFjlxFQZOIfSfmHn0961QbWJ0W79YwJdELIjl7nA3+JTmAh8HSa/mqL+lChR26OBH8VTk/j+U92qU7UvATTLht96NOPZTLYwl8AKSvfVDXIBfVNnJlB0+nA/HJsePdOx1f6K0QNNae1rYKlYSLc5ekV69D5CWF41ptZW92uTC5kcwc1mdGCYsrLkW1BENlln0cJT0V56SAFCmk6E7/D0Ynb4wfRXhhtJM9fVEj3FK8VMdyC/K8CSXNhSheJd9FH6axh/n+3LArU X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 04 Aug 2026 04:49:19.8306 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 3b7b8169-bd40-488d-c0be-08def1e3bf14 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=[satlexmb07.amd.com] X-MS-Exchange-CrossTenant-AuthSource: DS2PEPF00003448.namprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DS0PR12MB7631 Hello Vineeth, On 8/1/2026 9:25 AM, Madadi Vineeth Reddy wrote: > -static int select_idle_core(struct task_struct *p, int core, struct cpumask *cpus, int *idle_cpu) > +static int select_idle_core(struct task_struct *p, int core, struct cpumask *cpus, > + int *idle_cpu, int sync_cpu) > { > bool idle = true; > int cpu; > > for_each_cpu(cpu, cpu_smt_mask(core)) { > - if (!available_idle_cpu(cpu)) { > + bool sync_waker = (cpu == sync_cpu); > + > + /* > + * @sync_cpu, if set, is running a waker that is about to > + * block with nothing else runnable behind it. Treat it as > + * idle so this core stays an idle-core candidate: placing > + * the wakee on a sibling keeps the cache sharing that > + * stacking on the waker's rq would get, without serialising > + * the wakee behind the waker's remaining work. > + */ > + if (!available_idle_cpu(cpu) && !sync_waker) { If I'm not wrong, all you want to make is the sync_waker appear idle and then see if you can then consider that core as idle core or not right? Why can't this be done in select_idle_sibling() extending that early check for (!has_idle_core && cpus_share_cache(prev, target)) condition and then initializing "idle_cpu" in select_idle_cpu() accordingly? Something along the lines of: (Only build tested) diff --git a/kernel/sched/fair.c b/kernel/sched/fair.c index df8c9c2c7918..dd62bceb3838 100644 --- a/kernel/sched/fair.c +++ b/kernel/sched/fair.c @@ -1301,7 +1301,6 @@ static bool update_deadline(struct cfs_rq *cfs_rq, struct sched_entity *se) #include "pelt.h" -static int select_idle_sibling(struct task_struct *p, int prev_cpu, int cpu); static unsigned long task_h_load(struct task_struct *p); static unsigned long capacity_of(int cpu); @@ -8661,10 +8660,11 @@ static int select_idle_smt(struct task_struct *p, struct sched_domain *sd, int t * comparing the average scan cost (tracked in sd->avg_scan_cost) against the * average idle time for this rq (as found in rq->avg_idle). */ -static int select_idle_cpu(struct task_struct *p, struct sched_domain *sd, bool has_idle_core, int target) +static int select_idle_cpu(struct task_struct *p, struct sched_domain *sd, bool has_idle_core, + int target, int idle_cpu) { struct cpumask *cpus = this_cpu_cpumask_var_ptr(select_rq_mask); - int i, cpu, idle_cpu = -1, nr = INT_MAX; + int i, cpu, nr = INT_MAX; if (sched_feat(SIS_UTIL) && sd->shared) { /* @@ -8928,7 +8928,7 @@ static inline bool asym_fits_cpu(unsigned long util, /* * Try and locate an idle core/thread in the LLC cache domain. */ -static int select_idle_sibling(struct task_struct *p, int prev, int target) +static int select_idle_sibling(struct task_struct *p, int prev, int target, int sync_cpu) { bool has_idle_core = false; struct sched_domain *sd; @@ -9028,16 +9028,19 @@ static int select_idle_sibling(struct task_struct *p, int prev, int target) return target; if (sched_smt_active()) { + int cpu = ((unsigned)sync_cpu < nr_cpumask_bits) ? sync_cpu : prev; + has_idle_core = test_idle_cores(target); - if (!has_idle_core && cpus_share_cache(prev, target)) { - i = select_idle_smt(p, sd, prev); - if ((unsigned int)i < nr_cpumask_bits) + if (sync_cpu == target || (!has_idle_core && cpus_share_cache(prev, target))) { + i = select_idle_smt(p, sd, cpu); + + if (!has_idle_core && ((unsigned int)i < nr_cpumask_bits)) return i; } } - i = select_idle_cpu(p, sd, has_idle_core, target); + i = select_idle_cpu(p, sd, has_idle_core, target, i); if ((unsigned)i < nr_cpumask_bits) return i; @@ -9733,8 +9736,18 @@ select_task_rq_fair(struct task_struct *p, int prev_cpu, int wake_flags) return sched_balance_find_dst_cpu(sd, p, cpu, prev_cpu, sd_flag); /* Fast path */ - if (wake_flags & WF_TTWU) - return select_idle_sibling(p, prev_cpu, new_cpu); + if (wake_flags & WF_TTWU) { + int sync_cpu = -1; + + if (want_affine && sync && new_cpu == cpu) { + struct rq *rq = cpu_rq(cpu); + + if ((rq->nr_running - cfs_h_nr_delayed(rq)) == 1) + sync_cpu = cpu; + } + + return select_idle_sibling(p, prev_cpu, new_cpu, sync_cpu); + } return new_cpu; } --- You can probably infer sync hint by checking "target == smp_preocessor_id()" too in select_idle_sibling() instead of passing it on. > idle = false; > if (*idle_cpu == -1) { > if (choose_sched_idle_rq(cpu_rq(cpu), p) && -- Thanks and Regards, Prateek