From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from CO1PR03CU002.outbound.protection.outlook.com (mail-westus2azon11010002.outbound.protection.outlook.com [52.101.46.2]) (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 CD780470EA9 for ; Thu, 23 Jul 2026 03:48:53 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=52.101.46.2 ARC-Seal:i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1784778535; cv=fail; b=lZ+bpycMDJ9kQJF5QKlworGQ0K6GXqP4T7W2ibGaT0M9/nNLZTsXzbFPSKsKZhx7FvxcDu6vzI9IrSelkT+l1xWlyoekTxrIYkuwWDiXUl1k7gqeFdDYQ5rFJdywSyVOkcStsB6dRejfMTg2lj6vvfKDl1Gbxit7T15tCsuZYF8= ARC-Message-Signature:i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1784778535; c=relaxed/simple; bh=yrapg2Z5Z959MqGEOhn3XvJmRL0DNde8Dk77jwXR7as=; h=Message-ID:Date:MIME-Version:Subject:To:CC:References:From: In-Reply-To:Content-Type; b=ickxnHUtxfKXfMhs1NvnVKKQFEloe/Jt6H87kblIrvYxubgOJwmq42pNOoDIEK2S0ipIKzcWGH5FHHnqMsKaXon/s9ZpEU5urTMBjpm55mmBwXAJ6eqtOxJ8jYoDZxcV62u4wqWIgtLy3BaTnsQAw709iRb/gtkTjlFJ9DzL0uk= 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=ga58Sphh; arc=fail smtp.client-ip=52.101.46.2 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="ga58Sphh" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=kfmc0YJB+tCOIq8roE097DQnpWFoeGUbGtFtbvrfle0oAaMbhsxeFB8Bj99PVZYKtpeXQnUqWbErcmf78GNEXzSc96qhss0Pr5NsN0pqte+w54a4yOTk4z1mhvK2c98RDwupExMlUb84XTyaUkZSlg75R7iGKTYSV83vt4B9vLbZ2ACaLhfO6YRAVZpUWUr9t7iKJlF+BxR9oOIy2ibU3MZAY96nknNefRC+Wla1+XDhnBfxBehZV5OvBejuVXwoZaydz3wDM3cwV2DekA4SMaFHnoXa7dWkir9KnUAtyBU9FYB8aGswvVbKKE3l5ly+cFQB/Z27aIyxf26GofjOMQ== 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=6ze/N2CLeafauerqn2NNPeyUDagWYONmHAc/WR+y7Kw=; b=fipIJV5qYYaGGGeC4Ubv6rkmihmSPhziqrvUcGlYUVyO/xv28i/9FfdIMEiptlB1RD2XGhkqiMmb2mDNG1We4+fesO8O7/jDhiUReWlHAo45SiDWB55B3muqWHFXtvkqtmqdWVwCkxAvyBA/3PdHDq8/lCdwzK4gcqkeJLtUNakW2FNE84kejE3UaIWrnr5gJQxNHJiNIWAAJ4ze7fdBKXgREKk6SeUBWTEBXz/kaSBWGuYcaRMiwZ0Yv0Z4zeFgm8ej52EGxdrQ/HfQyRnNRGFzAc0ze8VAXs4FWKFu9ZL4uBftcIe4ivr46k8UHKskpMkDkgrVFAnH6+dqIk5bnA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=gentwo.org 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=6ze/N2CLeafauerqn2NNPeyUDagWYONmHAc/WR+y7Kw=; b=ga58SphhBJFqZW7+IfB0IVQtPPkAyj3CtP4v//Goe52WVgUQqHZrO5Gjtrm0XMG3EP1B2DRzwS5zqAKCGk0fINRy0oZ43zq8ves/HwoFW/jUMwPWiNSLfZe0MAHT6WIaLtajwJ1klRXLfgqTwvHParQGu3X8x/YPIsZoeGP8Q3c= Received: from BL1PR13CA0375.namprd13.prod.outlook.com (2603:10b6:208:2c0::20) by CH2PR12MB4328.namprd12.prod.outlook.com (2603:10b6:610:a6::14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.21.245.10; Thu, 23 Jul 2026 03:48:50 +0000 Received: from BL02EPF0001A100.namprd03.prod.outlook.com (2603:10b6:208:2c0:cafe::7a) by BL1PR13CA0375.outlook.office365.com (2603:10b6:208:2c0::20) with Microsoft SMTP Server (version=TLS1_3, cipher=TLS_AES_256_GCM_SHA384) id 15.21.245.10 via Frontend Transport; Thu, 23 Jul 2026 03:48:50 +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 BL02EPF0001A100.mail.protection.outlook.com (10.167.242.107) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.21.245.5 via Frontend Transport; Thu, 23 Jul 2026 03:48:49 +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; Wed, 22 Jul 2026 22:48:49 -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; Wed, 22 Jul 2026 22:48:49 -0500 Received: from [172.31.184.125] (10.180.168.240) by satlexmb08.amd.com (10.181.42.217) with Microsoft SMTP Server id 15.2.2562.41 via Frontend Transport; Wed, 22 Jul 2026 22:48:45 -0500 Message-ID: <341baa60-8840-447d-ac60-780199bca371@amd.com> Date: Thu, 23 Jul 2026 09:18:44 +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 v2] sched/fair: Prefer waker CPU for reciprocal sync wakeups To: "Shubhang Kaushik (Ampere)" , Ingo Molnar , Peter Zijlstra , Juri Lelli , Vincent Guittot , Dietmar Eggemann , Steven Rostedt , Ben Segall , Mel Gorman , Valentin Schneider CC: "Christoph Lameter (Ampere)" , Shubhang Kaushik , References: <20260722-b4-sched-sync-wakeup-v2-1-f1164560b24b@gentwo.org> Content-Language: en-US From: K Prateek Nayak In-Reply-To: <20260722-b4-sched-sync-wakeup-v2-1-f1164560b24b@gentwo.org> Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: 7bit X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: BL02EPF0001A100:EE_|CH2PR12MB4328:EE_ X-MS-Office365-Filtering-Correlation-Id: 42ee1156-2f5c-4d1f-4893-08dee86d4e87 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|23010399003|82310400026|36860700016|1800799024|7416014|376014|11063799006|10067099003|56012099006|921020|22082099003|18002099003; X-Microsoft-Antispam-Message-Info: PM2rGuIAGEJubWqGAx127S8ide3PfwEisYzLsgby5rZ0eNLgNKD64KTeZPwH98YI28OghSixJUH4JqC1A39bSHACKsDK+RW2+fYWYlH4cpqRFNqaPkXH7uovt95BegRNxu3hnH3x0C5lEdZlai7yQpI0boZkSzLGq+gKd/A9oyJ0rcAKC+OmyUTT1YpXyoMwDNvAa+h5I5BDWr5e+ULIA9gX+uOPqOD8ykCHNMpyozBNFxOcBsl7oMB0V8BnSrs6p2NKkZIJffvCLvk0jQr/tQv4MwthPJDxzFDPtihreGaN6zGcYGaISO1FhOduNUZlJmMgB3gKDmVEotO22NKAITQ6fG2wzII5r9SmXpreZR+sg4NiTRXI1VlA6DAnJT6tm+QjQtnXJM8SBRVFvai6YfbpCZfkMQAMd2SzjvwewnZoH5RPBYS9y0V7fKI/LYXan+SyR3H4rGdLJ3i92aw2KNiEz/EOPNF/Q2Z/bTRcSHjnZNkcVA1vTn4KvvgX/CUm43wrj/LbMfO3KtPZUC3THNSghMtBPrTk2k2yOCOVgODZG7Dl3pUuNXrcaLiAYPtBOFFb6LMZmgfm2AGLhc26xB73ChHG8H54RUX8Av2icVgkGVmgiUUdEIm3xroQ+SPR7RjibWd7H5qRMDrgPyTOAqRakB4zpJj2vt6qJNKSkqrXjXz/aaDB7e5SjmOWaUKFyl6AmpCNl/0jM8jCIXVZFsbqeZg6uhCr3esSYLoEeAKMIdVEe5OTrV7lYmdOshj+ 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)(23010399003)(82310400026)(36860700016)(1800799024)(7416014)(376014)(11063799006)(10067099003)(56012099006)(921020)(22082099003)(18002099003);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: r5qYnZrLrGHyJnnB5nbHeup7/3Cjpf4Cm56gUGUqY2xDrctlQpp6FB4aRwfyELt9SHxL9zoARdTZI7g+dBzqJ+T6z3SYYrLW2pvwP91UX95dvrQW2si0Umhhzn6SpnseN+5ZGn273ZkY/rTJUtv0pZHv77Sf10C3SxxB2i/x27LNMB9KGMyXX/RmEthhjKc2Ms9ijZ4ti+OyRqArGxQfRYW61l2m60dLh/AwlHopgssgn06Wfs58ZfDFlVGUnFEt0rdpHPGxH3f4+KE0gujuMpy7VIdCzTRoFj4rjkXnsZE1cuV1bVfdSTm1XHmSomov4EvimqxV1p726cppEV2KjWPicevuDmoB9oH0DbkKuMLjp/6Y8XXJaFxsB1S/LKQ8mI5dNFf0uD5xc5rQ75aDWltHC8+zp7zZ+FPjyvr54fAErgfrfVtic5iw/jQhqKYw X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 23 Jul 2026 03:48:49.9325 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 42ee1156-2f5c-4d1f-4893-08dee86d4e87 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: BL02EPF0001A100.namprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: CH2PR12MB4328 Hello Shubhang, On 7/23/2026 4:20 AM, Shubhang Kaushik (Ampere) wrote: > +/* > + * For reciprocal WF_SYNC handoffs, prefer the waker CPU when it has no > + * other runnable fair task. > + */ > +static bool prefer_sync_pair_cpu(struct task_struct *p, int cpu) > +{ > + struct rq *rq = cpu_rq(cpu); > + > + if ((rq->nr_running - cfs_h_nr_delayed(rq)) != 1) > + return false; > + > + if (!cpumask_test_cpu(cpu, p->cpus_ptr)) > + return false; want_affine already covers the affinity test now that you've moved it into the SD_WAKE_AFFINE branch. > + > + if (sched_asym_cpucap_active()) { > + sync_entity_load_avg(&p->se); > + if (!task_fits_cpu(p, cpu)) > + return false; > + } > + > + return true; Reads a lot like WA_IDLE. Couldn't this simply be an early returns in select_idle_sibling() if we passed wake_flags there? > +} > + > /* > * Try and locate an idle core/thread in the LLC cache domain. > */ > @@ -9579,6 +9602,11 @@ select_task_rq_fair(struct task_struct *p, int prev_cpu, int wake_flags) > */ > if (want_affine && (tmp->flags & SD_WAKE_AFFINE) && > cpumask_test_cpu(prev_cpu, sched_domain_span(tmp))) { > + if (sync && > + READ_ONCE(p->last_wakee) == current && No need for READ_ONCE(), Last wakee is recorded when "p" has last woken up a task and given we are now doing a wakeup for "p", it is completely off the rq and p->last_wakee is stable. > + prefer_sync_pair_cpu(p, cpu)) > + return cpu; > + > if (cpu != prev_cpu) > new_cpu = wake_affine(tmp, p, cpu, prev_cpu, sync); > > > --- > base-commit: 248951ddc14de84de3910f9b13f51491a8cd91df > change-id: 20260721-b4-sched-sync-wakeup-04d40cbeb1da > > Best regards, -- Thanks and Regards, Prateek