From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from BL0PR03CU003.outbound.protection.outlook.com (mail-eastusazon11012028.outbound.protection.outlook.com [52.101.53.28]) (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 03D7517A2E8 for ; Wed, 18 Mar 2026 06:56:46 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=52.101.53.28 ARC-Seal:i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1773817008; cv=fail; b=hy2N7XPzEXBP8xch/1E38QefGsUCNYle4esn+3BBzZ15dXeRFfEausHexRdRgRmIv7BLvV1LDUmQc8h2HD92s28W29t9icsDFpSjBZzgQzega6KvnD2wVOTudHz6sYyXfYiwUq4eUdiAfvTfQq0KwJobyQaFrpgzamZuHCWoR+Q= ARC-Message-Signature:i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1773817008; c=relaxed/simple; bh=OFUB5YWQ6U9U+WveJuSdHIhzYKZs27oHjkAwOJJ4rnw=; h=Message-ID:Date:MIME-Version:Subject:To:CC:References:From: In-Reply-To:Content-Type; b=Afzeoxl+12yu093Ops5JY9cPRst+7ghHxUeXNJqRITjllRF7pMVzrr1aH0m9aFFEmXgJ0GyQzNMy1tN/sVG2jSrQiLHhT8mXwJA7bXyp5y3+gz65DvwvxZ7XBR8De14wkVysF/Bt/sza9/W4dNkmneD4cDH/wEU7l9v4W532dIY= 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=Q9YinN0q; arc=fail smtp.client-ip=52.101.53.28 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="Q9YinN0q" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=cc1ug4RHaqc679b/pj5jCLIPEqsJrKIQAQsKkg7qFXwax/vb5vNKbnC6qw3u5u523ff4bsyZc1DakFWtfR0CFMxUn/RD3sRfb6YH03kbBy0mTHSe6Jxh9KEpxtsTOAVZKeSxVXeRGmQr9PUdmqQWk8EY6jZD/C7M2XrUmncWpPYy2ngMkO3YG7Rn1g4rO8BVdCN8fol6n41OEy3d2OCHcMPHyuq+72TQM70SVhqTnlkXc14WYmdWQhZb5oujEmjqW9PooKpEBLQtsSrR2fSMPEtaPd66SPRoOgbQLjIhP+7lqIs8wfysrPtGk1RfgfHaCiP8OfY88+7ng85UlG4hmA== 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=BfB9Hfsn8hG6OfkV8a1+YOXiprkV0A9XCXS/OtZ3e+Y=; b=y3Q11eAUvZh6Y6ayB++0sufsvtjCM4h2JpPo2BNMG7lVDlmOzSxEFV+O7BsoVycuwvf8OxTTleOQuJDustAO0cHcfAIbRg68lmpB3MSH/8Py1vXSe5lq4V9tzVhsx+Gyw0cD6bd2R/Tv+rffj1PqS00KdpWrm/yfZstYnCt1q+bVxYRT/TGOg+ODUzuG+qNRUto6shrzEhO+9YT/718SrkThS6sihb5lpLxPZ0hJOh/FltsK2mrB0NdQEqJuoNd/rC1rrSPUUnVshtmJuwkANB38cmRS/uBLtBbiek1aXBxbKea/OW7mm5hY1PJUQOzX+y0XikGbEsz7dEPOE8/POA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=redhat.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=BfB9Hfsn8hG6OfkV8a1+YOXiprkV0A9XCXS/OtZ3e+Y=; b=Q9YinN0q9OAuqE47PDCglrPKYtWaNUye8NiFihY/QAFGSJ9RkGUVFsYkpBy41n7M3HeBqVVEhNqpUKpHnrCKkbrq8LwGBbYGPXAeShjm51FcxiX5iiXlF7IpgFXWPur8x1/nDGEvTcmuoSgAnvpK1mCOdTEZX7UhdToeLGbn3Zc= Received: from BL1PR13CA0296.namprd13.prod.outlook.com (2603:10b6:208:2bc::31) by LV8PR12MB9110.namprd12.prod.outlook.com (2603:10b6:408:18b::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.9723.19; Wed, 18 Mar 2026 06:56:42 +0000 Received: from BN2PEPF00004FBE.namprd04.prod.outlook.com (2603:10b6:208:2bc:cafe::8b) by BL1PR13CA0296.outlook.office365.com (2603:10b6:208:2bc::31) with Microsoft SMTP Server (version=TLS1_3, cipher=TLS_AES_256_GCM_SHA384) id 15.20.9723.19 via Frontend Transport; Wed, 18 Mar 2026 06:56:42 +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 BN2PEPF00004FBE.mail.protection.outlook.com (10.167.243.184) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.9700.17 via Frontend Transport; Wed, 18 Mar 2026 06:56:42 +0000 Received: from SATLEXMB03.amd.com (10.181.40.144) 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; Wed, 18 Mar 2026 01:56:42 -0500 Received: from satlexmb08.amd.com (10.181.42.217) by SATLEXMB03.amd.com (10.181.40.144) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.39; Wed, 18 Mar 2026 01:56:41 -0500 Received: from [10.136.37.230] (10.180.168.240) by satlexmb08.amd.com (10.181.42.217) with Microsoft SMTP Server id 15.2.2562.17 via Frontend Transport; Wed, 18 Mar 2026 01:56:35 -0500 Message-ID: <9b2d6615-6108-4271-bbd5-902261d72864@amd.com> Date: Wed, 18 Mar 2026 12:26:30 +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 v25 9/9] sched: Handle blocked-waiter migration (and return migration) To: Juri Lelli , John Stultz CC: LKML , Joel Fernandes , Qais Yousef , Ingo Molnar , Peter Zijlstra , 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: <20260313023022.2902479-1-jstultz@google.com> <20260313023022.2902479-10-jstultz@google.com> Content-Language: en-US From: K Prateek Nayak In-Reply-To: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: 8bit Received-SPF: None (SATLEXMB03.amd.com: kprateek.nayak@amd.com does not designate permitted sender hosts) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: BN2PEPF00004FBE:EE_|LV8PR12MB9110:EE_ X-MS-Office365-Filtering-Correlation-Id: be7240bb-e3dc-4b73-175e-08de84bb82ef X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|82310400026|7416014|376014|1800799024|36860700016|56012099003|18002099003|22082099003; X-Microsoft-Antispam-Message-Info: W42pedqfCuV4+g2Fj5+4M1jLcA2HZKsmM5zm6x/IYq8AXhRowJ0GcDKq9q30Kx/YRUNq1yGpC9bf1EHxwqt6vNNsb05G03kK+T+eceqmP1jhRJMI54biFZoNPJDHf6KDOsLsLrsU2JeiMm33TaOq7g11RQ6vi7BDkI9vzD1Q0l4H8J/MYhfSmlzK6LSb/cf56vYiFpDKhLITmCIGaWKsUcRptgchWIspW3XjXIOaVw9j4rNn9fS/gyIXjj5AQTcQW2Hebm8c5wJzqR2WQeZHVnyGDDbF2dLAmxaY1KQmNbLpR0yWH1LVEuOFI+g2Kz5Zgxv5m8+0aRfwTUlvUZo8NoItb1zCxKhUT43bkU+uNYhmHFsw2p/itz9yTZc7+M2Elz6npGl1bnzNRPXB2oltZy0V8vMP+Upc+S03yl0XaJQOoK1/xUZjTjCSQB0pku5c+GJ4i9vZdfym6A/yEC9ymEGp5Nh3PTbtH/zw/jKL22/EAkwyvh8J/sSGQihW7LzfJJIa8gHjIVRGWV4vjsx8NMUewQnq4RK8kuao3wsAEVIz9IyGYgguxiiSeQw6idS5dbY2d9NEbEMiiZV1v+wbW9w28OtW/9FtgIF4kLFugXKxuvWICy2E0bJXExE2KI+BOPsBkc51gl7Ux8iW7gRyjgFr3hsx4uOV+PRez9rvdzG7BUtc6PpizDK2Wm5IhEY+WAOjlXmfJfXadz+TJ9xCTOPER0x8wT0PjLT5qJUXKsZeMeMb7HPKvsrtKl0NxhgkVCUzIPDm0KEtFBK6ncaxPg== 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)(82310400026)(7416014)(376014)(1800799024)(36860700016)(56012099003)(18002099003)(22082099003);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: olmu3GghkVMzz5uVmtZ3qbqsE/+pW5z5tw4+iQfMoT4IO01/35887ZYULhjfpcrYtEMcO/pVk2DgP1X5wiaOZf62bhCfMcYiGY+l4eMs4huNEVDGgWRnhEs860u0cEnA60qW2V8GlAexoXkEEuU9pz6DCexCf4n0oiz4+BrH62Ku9Y7YhewcOsTx6pu7Xu4tuD+kc06PEhm1QtTYqODCYfbJBFFmSn8XmALEmm1PNZx+Xdc0uY3o3X4mhN0Dm3rX+ghM4nquR1pinJOb6V7irAGz7Lqp6n1df9X/DNfVhKUYLg1jW+Vy8dAKBHgOA7YHoB4oGmgVaEQaP/0QjM7nUoyD508fcQgZ1OMh1HIbvCdl+V1Zuw2yaz3WrsO05E8iF/+4UfFk5Y6gL2gESRxBe3JGleCmiUx50WvEP9n0E3dYkH+tp5votB7xjgPLAHQR X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 18 Mar 2026 06:56:42.3365 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: be7240bb-e3dc-4b73-175e-08de84bb82ef 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: BN2PEPF00004FBE.namprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: LV8PR12MB9110 Hello Juri, On 3/18/2026 12:05 PM, Juri Lelli wrote: >> + deactivate_task(rq, p, DEQUEUE_NOCLOCK); >> + proxy_set_task_cpu(p, target_cpu); >> + >> + /* >> + * We have to zap callbacks before unlocking the rq >> + * as another CPU may jump in and call sched_balance_rq >> + * which can trip the warning in rq_pin_lock() if we >> + * leave callbacks set. >> + */ >> + zap_balance_callbacks(rq); >> + rq_unpin_lock(rq, rf); >> + raw_spin_rq_unlock(rq); >> + >> + attach_one_task(target_rq, p); > > We release rq lock between deactivate and attach (and we don't hold > neither wait_lock nor blocked_lock as they are out of scope at this > point). Can't something like the following happen? > > - Task A: blocked on mutex M, queued on CPU 0 > - Task B: owns mutex M, running on CPU 1 > > CPU 0 (migrating A→CPU 1) CPU 1 (B finishes critical section) > ------------------------- ------------------------------------ > find_proxy_task(donor=A): > owner = B, owner_cpu = 1 > action = MIGRATE > // guard releases wait_lock > > proxy_migrate_task(A, cpu=1): > deactivate_task(rq0, A) > → A->on_rq = 0 This sets TASK_ON_RQ_MIGRATING before dequeuing. block_task() is the only one that clears task->on_rq now. > proxy_set_task_cpu(A, 1) > → A->cpu = 1 > raw_spin_rq_unlock(rq0) > → RQ0 LOCK RELEASED > // Task B running > mutex_unlock(M): > lock(&M->wait_lock) // ← Can grab it > A->blocked_on = PROXY_WAKING > unlock(&M->wait_lock) > wake_up_q(): > try_to_wake_up(A): CPU1 see p->on_rq (TASK_ON_RQ_MIGRATING) and go into ttwu_runnable() and stall at __task_rq_lock() since it sees task_on_rq_migrating() ... attach is done here A->on_rq is set to TASK_ON_RQ_QUEUED ... we come back here see task_on_rq_queued() and simply do a wakeup_preempt() and bail out early from try_to_wake_up() path. > sees A->on_rq == 0 > cpu = select_task_rq(A) > → returns CPU 2 > set_task_cpu(A, 2) > ttwu_queue(A, 2) > → A enqueued on CPU 2 > → A->on_rq = 1, A->cpu = 2 > > attach_one_task(rq1, A): > attach_task(rq1, A): > WARN_ON_ONCE(task_rq(A) != rq1) > → Fires! task_rq(A) = rq2 > activate_task(rq1, A) > → Double-enqueue! A->on_rq already = 1 Thus, we avoid that unless I'm mistaken :-) -- Thanks and Regards, Prateek