From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from DM5PR21CU001.outbound.protection.outlook.com (mail-centralusazon11011044.outbound.protection.outlook.com [52.101.62.44]) (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 B5AC71C84DE for ; Fri, 3 Apr 2026 13:43:45 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=52.101.62.44 ARC-Seal:i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1775223827; cv=fail; b=apGeFGYbnk9g5mdK/E12nMMPcGHTzDHCJoDdz8teJJ+idqIklh0o7Av5VlmThBzprCKjx/5Zp4dQMqucyN1ni6HFojfh5qjfBz0GgdmB7uOtwXEKdXkzNrtViCdVUnRDn00AcKOFRlj8rkxYSpg4ktAGkquSqbDPKsj4QdYVL1I= ARC-Message-Signature:i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1775223827; c=relaxed/simple; bh=rH+y6mxCBGUjeHO1MD7HTsueKFFMLUTkLuoA4yBMs7E=; h=Message-ID:Date:MIME-Version:Subject:To:CC:References:From: In-Reply-To:Content-Type; b=JWrJ6I4y+ERLF4+V7eYlq+e81SF6006Tixp/6du4RcVHDsgnm6HFNrBDUs/KDT4n+wkjjboFNnGnOwdLdlzUf0TM0fY/fdpGDVGprz4GLpU+ReE0wzJm1AuxHMP7elTd6ZO2rpKe+5uUyYPHXoGmxGXkvh83T6UQjq+jSdVaNzc= 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=SLH5Qwbf; arc=fail smtp.client-ip=52.101.62.44 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="SLH5Qwbf" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=OdE0cnZsRihaoQ5Mf1UQ/APi+Fb5fX1cTCs/68IreIME975aGx4lD1DAZlhMw4rirxEO6Ph3hNcB1vGuWqgVqGo6V5D1Kvvvm8bCjn7yqIp9lrjfQRiZ07IHD76n7kRM52jBD9veQrVJ64oa9Mw7rlkDIspxjF83sAA8RlKvwPr30+r8UcHRPiggWsXFXtRsNzpe7e+qj1XeAzhX5FUgl9w4sDd5DKGCi8abwz+Lppa4wfg6TANbeyeWW1nyaT0qUun31xG7upuR+5+c9HPz/le8sH58B018sFKN2Ql3ZveyzTtJhhu16eTZVJh06TfKGM3IBDUhJdKXIusnSywqPA== 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=HB8W+arirQThFD63wajKRDKHmQ/OX2cKSKruIZnPbto=; b=wZy/vKMlnNSqrDc3r0OqXXVaz5j8cD55aoetBzzq+GyvpRStDhJPBaFicyYg5HuD3K5K6x5roDwgGGzzQ5HOtmS/0FSFPkq4sq3wUoVDrbK/vdT53qZzoflAjQ4dxrUufX5p2UFy/82cyfq8iK1YTptl+/VJFcJ1LvCjgMHO5DwLD8BgUIW3/maJBSX7IXK4PAKcou42rCXefHGa4hhFXs6vT2RR17cT1AbkwikNL9Q8xULqJM+Rl4CVsOdAKq9k41Sc7yXYvj+aBUs/rzy3bLR3lpq0pR5T6YJVu2AMa+h2EiViI3i+HpkHptqvKXjGscqy2OcTr/+sFKLWYL4+/A== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=infradead.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=HB8W+arirQThFD63wajKRDKHmQ/OX2cKSKruIZnPbto=; b=SLH5QwbfpY5clewuigMo6Hwb751Mfu+SAq37HzGXVeFNBX+MdhQeR1LS3QPNdVdsJA4dpgogK9AmbN/fWArcn2JDQoAfU4OFBMScK1k40vNCNoOiwi/h22B6Wzdrn6dA+g+r/QHAsZ3Q7vmMg6Vk0n2l1rQwg+2BLObbttUnaJM= Received: from SJ0PR13CA0222.namprd13.prod.outlook.com (2603:10b6:a03:2c1::17) by DS0PR12MB9397.namprd12.prod.outlook.com (2603:10b6:8:1bd::15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.9769.20; Fri, 3 Apr 2026 13:43:41 +0000 Received: from SJ1PEPF00001CDE.namprd05.prod.outlook.com (2603:10b6:a03:2c1:cafe::e0) by SJ0PR13CA0222.outlook.office365.com (2603:10b6:a03:2c1::17) with Microsoft SMTP Server (version=TLS1_3, cipher=TLS_AES_256_GCM_SHA384) id 15.20.9769.23 via Frontend Transport; Fri, 3 Apr 2026 13:43:41 +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 SJ1PEPF00001CDE.mail.protection.outlook.com (10.167.242.6) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.9769.17 via Frontend Transport; Fri, 3 Apr 2026 13:43:41 +0000 Received: from SATLEXMB04.amd.com (10.181.40.145) by satlexmb07.amd.com (10.181.42.216) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.2.2562.17; Fri, 3 Apr 2026 08:43:39 -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; Fri, 3 Apr 2026 08:43:39 -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; Fri, 3 Apr 2026 08:43:31 -0500 Message-ID: <5e2337e7-24d8-4cc7-a86d-b8f5a19fb3ce@amd.com> Date: Fri, 3 Apr 2026 19:13:29 +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 v26 00/10] Simple Donor Migration for Proxy Execution To: Peter Zijlstra CC: John Stultz , LKML , Joel Fernandes , Qais Yousef , Ingo Molnar , Juri Lelli , "Vincent Guittot" , Dietmar Eggemann , Valentin Schneider , "Steven Rostedt" , Ben Segall , "Zimuzo Ezeozue" , Mel Gorman , Will Deacon , Waiman Long , Boqun Feng , "Paul E. McKenney" , Metin Kaya , Xuewen Yan , Thomas Gleixner , Daniel Lezcano , "Suleiman Souhlal" , kuyo chang , hupu , References: <36e96f87-a682-436e-aefc-13e2e5810019@amd.com> <20260327114844.GQ2872@noisy.programming.kicks-ass.net> <33e60181-1809-44e1-bc4c-8ac7f79d49d6@amd.com> <20260327160017.GK3738010@noisy.programming.kicks-ass.net> <1515d405-62fc-4952-842f-b69e2bf192c0@amd.com> <20260402155055.GV3738010@noisy.programming.kicks-ass.net> <20260403095225.GY3738010@noisy.programming.kicks-ass.net> <1d2d4596-93d6-4d87-babc-084b8d6c2d98@amd.com> <20260403112810.GG3738786@noisy.programming.kicks-ass.net> Content-Language: en-US From: K Prateek Nayak In-Reply-To: <20260403112810.GG3738786@noisy.programming.kicks-ass.net> 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: SJ1PEPF00001CDE:EE_|DS0PR12MB9397:EE_ X-MS-Office365-Filtering-Correlation-Id: 234d956a-f6b6-4d04-7a52-08de91870470 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|82310400026|36860700016|376014|7416014|1800799024|13003099007|56012099003|22082099003|18002099003; X-Microsoft-Antispam-Message-Info: LsOHRPWf1q/JxmPWOX/SXXub+BzCmk0mjmhCOurbkEVhu8NMYPapCSOOoCMiP66V6Wg6AzckQqP5a+eV+cEGQh8T/saSYcCFisbdkWaKwo7bsQjSH6caWSMfiB7OVC49Dd7aX/vowneCRlblLW6Po5K1a7p6YHwN80jJeuBwFWnzFc+8VM9idDX5vqZToWDfgiqH1/YWi4QOe0+L5EUWvRBpKTPjCxXXsXeWpcTWUXzkXsSplPd4waypWFEa4vMTQxJidgIcMOlapv4Q5ta2BRsNmhekxisRgg2B73AxRwDYeXhApaEJ1+cz45YNUVOhmbMeE0PMcIabakFJgvyNdd//wG1VDkK8Mxahasf9ZS09hzjSJR+pLZv+HILt/os7ytR1+whxzpovXoVxeS/LKSxgpEbAEunGNT8VgcIRdUEnVUE0jhF5KCy1s7WAOjpzqUj5rHZCGsJR0tjlxkoVfgpNbms1lX0onUNR5Exf1vJlDrsuRCIQ0sQfrpBgRPUQtoj/1lGR4XkRTOMCR1tSZHIv3fJhObbd3yjOjd95/bhyA3aHtLQHxhqwv/fqpg/ZsOnyFbetlSuDua5adLEUG10AxI4yCvjaL43Od20tY+byoI4iZDhFjhQNwe4ZQl2xwnpMM0G0veVFvnNHj2DaKfDlfvaoqeVeLZO98ypIY012qUql5V8+6fqm3Z/ip2XOs7M312ZHYd3RWwTo1veqVxsRSH6WK9EOHxJRYRvOJx31u4GiG2dKpTGB0WaBxfXh/dZzzEwuGZBu10xQCJS3kw== 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)(82310400026)(36860700016)(376014)(7416014)(1800799024)(13003099007)(56012099003)(22082099003)(18002099003);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: dvAry2oNzXdQrIbf95mJOieIAIUqsYqnY8HDDEvWnN9QtlMZmUWuHYxpMV9IZCK+vy9NxVnvHDaLvr5Xrt/U2m9Pmn+LHcnG8AQLZXFIanAq1L/ksLW92vSz0ezK7LnZD8QKAZlsi/4R10QRqySRU0qZgqyq1IA1Y17gWyd6CcWdjZY0PofmEcLR8ERAJh6X5MoBmYtTE6ozkcCETQHfZ5OkAo+EOod1swSJ+y7YiIT6sIkfekGQWxPr5ZlVVlqbEFRFKUYSYG2Sag5Ct+W7QNr8EB9beVvzWQI6fzUp6yG0MQIGnQp16zgZ3qAlFNPTaL8APM5yte1CgAJdDJxHT6B4wV5z066C2KI124QDurof/MZIuSGlD9RAk/BI+Tmi6kJDFwP81VXIw8tw3rq6c3Z0Z9Nz62ai++0WqiOyVOuVjIPpbYb44gLLSCBox3d6 X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 03 Apr 2026 13:43:41.3486 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 234d956a-f6b6-4d04-7a52-08de91870470 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: SJ1PEPF00001CDE.namprd05.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DS0PR12MB9397 Hello Peter, On 4/3/2026 4:58 PM, Peter Zijlstra wrote: > On Fri, Apr 03, 2026 at 03:55:22PM +0530, K Prateek Nayak wrote: >>>> @@ -4256,6 +4277,15 @@ int try_to_wake_up(struct task_struct *p, unsigned int state, int wake_flags) >>>> */ >>>> smp_cond_load_acquire(&p->on_cpu, !VAL); >>>> >>>> + /* >>>> + * We never clear the blocked_on relation on proxy_deactivate. >>>> + * If we don't clear it here, we have TASK_RUNNING + p->blocked_on >>>> + * when waking up. Since this is a fully blocked, off CPU task >>>> + * waking up, it should be safe to clear the blocked_on relation. >>>> + */ >>>> + if (task_is_blocked(p)) >>>> + clear_task_blocked_on(p, NULL); >>>> + >>> >>> Aah, yes! This is when find_proxy_task() hits deactivate() for us and we >>> skip ttwu_runnable(). We still need to clear ->blocked_on. > > I wonder, should we have proxy_deactivate() do this instead? That is one way to tackle that, yes! > >>> >>>> cpu = select_task_rq(p, p->wake_cpu, &wake_flags); >>>> if (task_cpu(p) != cpu) { >>>> if (p->in_iowait) { >>>> @@ -6977,6 +7007,10 @@ static void __sched notrace __schedule(int sched_mode) >>>> switch_count = &prev->nvcsw; >>>> } >>>> >>>> + /* See: https://github.com/kudureranganath/linux/commit/0d6a01bb19db39f045d6f0f5fb4d196500091637 */ >>>> + if (!prev_state && task_is_blocked(prev)) >>>> + clear_task_blocked_on(prev, NULL); >>>> + >>> >>> This one confuses me, ttwu() should never results in ->blocked_on being >>> set. >> >> This is from the signal_pending_state() in try_to_block_task() putting >> prev to TASK_RUNNING while still having p->blocked_on. > > Ooh, I misread that. I saw that set_task_blocked_on_waking(, NULL) in > there and though it would clear. Damn, sometimes reading is so very > hard... > > Anyhow, with my changes on, try_to_block_task() is only ever called from > __schedule() on current. This means this could in fact be > clear_task_blocked_on(), right? Yes, that should work too but there is also the case you mentioned on the parallel thread - if ttwu() doesn't see p->blocked_on, it won't clear it and if ttwu_runnable() wins we can simply go into __schedule() with TASK_RUNNING + p->blocked_on with no guarantee that same task will be picked again. Then the task gets preempted and stays in an illegal state. Clearing of ->blocked_on in schedule also safeguards against that race: o Scenario 1: ttwu_runnable() wins CPU0 CPU1 LOCK ACQUIRE [W] ->blocked_on = lock [R] ->__state [W] ->__state = state; RMB [R] ->blocked_on [W] ->__state = RUNNING /* Synchronized by rq_lock */ MB [R] if (!->__state && [R] ->blocked_on) [W] ->blocked_on = NULL; /* Safeguard */ o Scenario 2: __schedule() wins CPU0 CPU1 LOCK ACQUIRE [W] ->blocked_on = lock [R] ->__state [W] ->__state = state; /* Synchronized by rq_lock */ MB [W] __block_task() MB /* Full wakeup. */ [R] if (->blocked_on) [W] ->blocked_on = NULL -- Thanks and Regards, Prateek