From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=pass header.oldest-pass=0 smtp.remote-ip=52.101.85.52 ARC-Seal: i=2; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=pass; t=1796201806; b=19Q322pvU2nOFkOpWlfLoAy+j5w1e6hiAjQbUIoBhHvW0Ft1833Akp/N2XZ0dvl7al7A SCIggn4KoxSza6ts+81SN5ZWXrUaPrTLoDNpB0cfDCajB/ucQ1/XBCimCWeeaglPDb3zM V28LLwioE+Ei0hnL8q08QHZu0pc+hcl2bPH06hb3vmFF/fgiECSXx0yAy/+wTR+D8eRfi ZJrwE+vKduxYiWJQx5nq36PSIZDBTD4SPuZYWdQj/ZB83H9NMjSYW19qQloyFutaHZb0X hB6X6xik5Qa47v4jS2SRW7EjFVxuMPs3dSgqbTYzVaed3IjlURmz1WU3jImUSOSx54g== ARC-Message-Signature: i=2; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796201806; h=DMARC-Filter:DKIM-Signature:Received:Received: X-MS-Exchange-Authentication-Results:Received-SPF:Received:Received: Received:Received:Message-ID:Date:MIME-Version:User-Agent:Subject:To: CC:References:Content-Language:From:In-Reply-To:Content-Type: Content-Transfer-Encoding:X-EOPAttributedMessage: X-MS-PublicTrafficType:X-MS-TrafficTypeDiagnostic: X-MS-Office365-Filtering-Correlation-Id:X-MS-Exchange-SenderADCheck: X-MS-Exchange-AntiSpam-Relay:X-Microsoft-Antispam: X-Microsoft-Antispam-Message-Info:X-Forefront-Antispam-Report: X-MS-Exchange-AntiSpam-MessageData-ChunkCount: X-MS-Exchange-AntiSpam-MessageData-0:X-OriginatorOrg: X-MS-Exchange-CrossTenant-OriginalArrivalTime: X-MS-Exchange-CrossTenant-Network-Message-Id: X-MS-Exchange-CrossTenant-Id: X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: X-MS-Exchange-CrossTenant-AuthSource:X-MS-Exchange-CrossTenant-AuthAs: X-MS-Exchange-CrossTenant-FromEntityHeader: X-MS-Exchange-Transport-CrossTenantHeadersStamped; bh=6qOPdr4jRlmLHoQ780AAC6dY4/+6HOjRcy9dQ5qTkrA=; b=5W5ueCFk2csh5i5CXDvw5Q9iVq9xXMrf0QzjfeJsHF6JLBR1W1nEgfC1RqXK/G41O1ZW WJj19KYIULdkYrapG2VOVC3fMYktK91fSvJMy7qCkL3jC5HYTwn7G3cAj5tdXOrxmwpZY j717lcqzOhyOQiakMOSQTnPTlgiPxlcBHPLhGzg3YhU+Zu9vj7zW+hLRnKA2ZMo1CQkHj Mv7aTpNIkmByX+qSAOTrcosvYSJ/7ETx1Y3mKtC9tO8VoO8iRQGiixagsIRNlmjNnjkr+ b7iVlD1ZijV2mxC+zMCewg14nX2w5jSM0x/nQ8U2NwHbVZIx0+F3PRiuKlW1VYip85g== ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass header.from=amd.com; spf=fail smtp.mailfrom=amd.com; dkim=pass header.d=amd.com header.i=@amd.com header.a=rsa-sha256 header.s=selector1 header.b="d5/dH9lX"; arc=pass header.oldest-pass=0 smtp.remote-ip=52.101.85.52 Received: from BYAPR05CU005.outbound.protection.outlook.com (mail-westusazon11010052.outbound.protection.outlook.com [52.101.85.52]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange ECDHE (secp384r1) server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 51F03606A322 for ; Wed, 2 Dec 2026 08:56:44 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 51F03606A322 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, unprotected) header.d=amd.com header.i=@amd.com header.a=rsa-sha256 header.s=selector1 header.b=d5/dH9lX ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=K2+9EWLsjYws7uvgaT6AdZh/DxglZbetuk+C5hQpx+TOGBhQqrkEDS1y+V+cLXrv3SaRpxvbf8sy/+1E6+0QQaWFFhkFUmTqTnMAbtOaxkAS+Z1U+BXMmNgwCpcB2CjFA8atw821y21lz3hsxE5klG1Dd9CrJlDPAtK5Udb2jcKZjnd7gaeKcJ3b2ZrV0d+JxynxfdIxw55Y3pyipnr5qrXn6mblN/K/s+K7t/qznx0jQ9pOFlMFn6TSwu2MqO+54y2DXYhSpugYLEsPj0V4LcallYVIogIsVxnyzaNOgvoO1A/WmNaNICIWkTV98GT3tCWeIVHTfIPECk+OODBfkg== 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=6qOPdr4jRlmLHoQ780AAC6dY4/+6HOjRcy9dQ5qTkrA=; b=XSTJy/Md97rN6adwUIkWBZzieaeLqfnlM0BtzhnnzIjRQ0a5S0WvNwCp92IvdJxRSt/8pEcvtTwAvWgVT5fanuKKCgTGZY3d0bn38qmA9n7+r+Oex2Mp+dPdfrZbbnYJPHcFrOoPXxcezF6E/8p/v6WsLOfFd/HfHRbo5nO2qwPf3aOGTA7dVioE/k05p5boWcGLjOmwB7Rhlh20XMyRD0UMHdGIO7dXwMfXCMdPlaR/iS3xYzXx8zsezX9AvuLQsscvyUvL6MFvnYbKRyzjwGEVtNRkxP8gb0g1MGoTsc/LEj0yiQ0ejg0Xmz+3gNLLHMJW+jPHIRgyzuePPNPsIg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=google.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=6qOPdr4jRlmLHoQ780AAC6dY4/+6HOjRcy9dQ5qTkrA=; b=d5/dH9lX3i5IKlm3HkSEgV5jw8bVt4h4QllXXie8tiXTXjaPyVu0D11bwyF8AM+8Ff2FrhY7cbi901swK/xR26dwIm/E9g2S6yS8yhmU5i5XP+Au21ss3S72Xq8ELrOKxrqcjZl7PNg6qBCjGPT9AEZhSKYedvl3s37PGa9efkQ= Received: from MW4PR04CA0345.namprd04.prod.outlook.com (2603:10b6:303:8a::20) by IA3PR12MB880721.namprd12.prod.outlook.com (2603:10b6:208:713::8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.21.688.11; Wed, 2 Dec 2026 08:56:40 +0000 Received: from MW1PEPF00018893.namprd03.prod.outlook.com (2603:10b6:303:8a:cafe::85) by MW4PR04CA0345.outlook.office365.com (2603:10b6:303:8a::20) with Microsoft SMTP Server (version=TLS1_3, cipher=TLS_AES_256_GCM_SHA384) id 15.21.662.13 via Frontend Transport; Wed, 2 Dec 2026 08:56:39 +0000 X-MS-Exchange-Authentication-Results: mx.microsoft.com 1; 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 MW1PEPF00018893.mail.protection.outlook.com (10.167.249.170) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.21.688.5 via Frontend Transport; Wed, 2 Dec 2026 08:56:39 +0000 Received: from Satlexmb09.amd.com (10.181.42.218) 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.57; Wed, 2 Dec 2026 02:56:34 -0600 Received: from satlexmb08.amd.com (10.181.42.217) by satlexmb09.amd.com (10.181.42.218) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.2562.57; Wed, 2 Dec 2026 02:56:34 -0600 Received: from [10.136.42.27] (10.180.168.240) by satlexmb08.amd.com (10.181.42.217) with Microsoft SMTP Server id 15.2.2562.57 via Frontend Transport; Wed, 2 Dec 2026 02:56:25 -0600 Message-ID: <4b2f3354-9688-4b36-ad43-dce817cbe985@amd.com> Date: Wed, 2 Dec 2026 14:26:24 +0530 X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH v34 14/14] sched/proxy: Add deactivated (sleeping) owner handling to find_proxy_task() To: John Stultz , LKML CC: Peter Zijlstra , Juri Lelli , Valentin Schneider , Connor O'Brien , Ingo Molnar , Thomas Gleixner , Vincent Guittot , "Valentin Schneider" , Suleiman Souhlal , Andrea Righi , Johannes Weiner , "Metin Kaya" , Dietmar Eggemann , Steven Rostedt , Zimuzo Ezeozue , Waiman Long , Boqun Feng , "Paul E. McKenney" , Joel Fernandes , "Qais Yousef" , Xuewen Yan , kuyo chang , hupu , Zhan Xusheng , "zhidao su (Xiaomi)" , Hui Su , "Shubhang Kaushik (Ampere)" , References: <20261202035248.1210026-1-jstultz@google.com> <20261202035248.1210026-15-jstultz@google.com> Content-Language: en-US From: K Prateek Nayak In-Reply-To: <20261202035248.1210026-15-jstultz@google.com> Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: 7bit X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: MW1PEPF00018893:EE_|IA3PR12MB880721:EE_ X-MS-Office365-Filtering-Correlation-Id: 6f3a8b28-f88a-48cd-9c2d-08df50522dc1 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|376014|7416014|82310400026|36860700016|1800799024|23010399003|11063799006|4143699003|261009223027099003|22082099003|18002099003|56012099006|10067099003|261022105027099003|261022075727099003|261021123027099003|261028144727099003|261026121527099003|261026140227099003; X-Microsoft-Antispam-Message-Info: wIhWGHlh2hqSzdhD0EoJkvYbhLN3H+SpdJoQQwFEUXn14m86F1sO6xs7skbKEKfdaU44hljJ70yE2iMEDOiqAfMITMvqnDStAQvBE08eY40mT/jiOXhupo7WrNWRVsZADmniI38f+aD+OcmVzqQwIm80b9IpFvEwoWXBueaFbLzWbBdbBVD8eSHAfmqD0TyU3DJhMsUaKmnAMJ8xg3cTl91GTS9vKRXrpBEZVFbhHM7PaaxgcQQHTD4sqfBNIf4o38ox4Smlq95ukp3tk8id8v3N0ZiEuXdVqWHrOSurbkSirvccGI5NQ0qayBzj8qB02fwywi71iaWFPzrW9GalwLejSoDSctClXDR1CKSXZGdbt+Lj0Ei6zuAP36RBMr6DsA7xoCswMpZVi6fif6gLIGlegrw4v6AxjBbiJl9HXcNTQMYB9n9vMkmjrL9c4jqKWjmh4NY4+780yymMkjeZbuZuGJXTrPmxSQsmcqCGkX8xjhCA9M/r39DSUT2aQhkImNU/RcTGoh9kmJlpH06qpqka+ygciVBDuYLsrcMnBTrLOQbzq9XnASheaEsX3K0cPCF1eu5Bv7448wZAuttW6fv8kqo9Wc+tD4epO5mk58Xk4AzSIRVhUZCvWw75GebWln06cqc01hnsG+iCWjsBa31rO3z9zRxJ00mG/QCMljT0L+zwIcyL9JHK2naEF43TpT4zep2z0++tmwxkX0tnmg== 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)(376014)(7416014)(82310400026)(36860700016)(1800799024)(23010399003)(11063799006)(4143699003)(261009223027099003)(22082099003)(18002099003)(56012099006)(10067099003)(261022105027099003)(261022075727099003)(261021123027099003)(261028144727099003)(261026121527099003)(261026140227099003);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: yX4ANF3w4Mid6pRVd/fbNekNFntFh5rrKLANnKeVox4FogKYKhHcCSwfQEn5zz52f2Mn/7o/zPa8jnKih2EYwTzBYvEnATFbRYCkjfQZKEaPrcxNr8qnWxL++gnG2k6zVKpgrTtJngJCqYLaH2d12e+spoxArki2vNgx2peFWA+MsLSgosyhBT8nOQNfuQkLZtRMFU5mWIrVV06NJonnQVi9LAX0DHxHdNLKzVPSo8HoXwyHZfUuKVqgpx7y/d6cXCap5Ndh6O8WHxG5Ao3CyjtbazG5PSD4VElss3Gry+wQhXuNryqYLmUbENuDNdT7yRKkJuae3EM5KnB3AYdaO990W3aHfxYo6UWwdmfab0hpz9eeaKJQcnpL0mBgU0zugbdYNfoddRfazKn1W2yhb4PMG4NXikt5h7PVw//zr+Fy4J/yYGgMfvvtpgv37PsO X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 02 Dec 2026 08:56:39.3754 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 6f3a8b28-f88a-48cd-9c2d-08df50522dc1 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: MW1PEPF00018893.namprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: IA3PR12MB880721 Hello John, On 12/2/2026 9:22 AM, John Stultz wrote: > +static void do_activate_blocked_waiter(struct rq *target_rq, struct task_struct *p, int en_flags) > +{ > + struct rq_flags rf; > + int target_cpu = cpu_of(target_rq); > + > + scoped_guard (raw_spinlock_irqsave, &p->pi_lock) { > + scoped_guard (raw_spinlock, &p->blocked_lock) { > + int state = READ_ONCE(p->__state); > + > + /* If task is no longer blocked, don't activate */ > + if (!READ_ONCE(p->is_blocked)) > + return; > + > + /* Avoid racing with ttwu */ > + if (state == TASK_WAKING) > + return; > + > + /* Dead tasks don't activate */ > + if (state == TASK_DEAD || READ_ONCE(p->exit_state)) > + return; > + > + /* > + * We raced with a non mutex handoff activation of p. > + * That activation will also take care of activating > + * all of the tasks after p in the blocked_head list, > + * so we're done here. > + */ State checks vs p->on_rq check needs to be ordered with smp_mb() too based on __task_needs_rq_lock() and ... > + if (READ_ONCE(p->on_rq)) > + return; > + > + /* > + * Its possible this activation is very late, and > + * we already were woken up and are running on a > + * different cpu. If that task blocked, it could be > + * dequeued (so on_rq == 0), but still on_cpu. > + * Bail in this case, as we definitely don't want to > + * activate a task when its on_cpu elsewhere. > + * > + * Use smp_load_acquire since we don't hold rq lock. > + */ > + if (smp_load_acquire(&p->on_cpu)) ... isn't smp_load_acquire() basically: READ_ONCE(p->on_cpu) smp_mb() ? I think the patten here should be: READ_ONCE(p->on_rq) smp_mb(); smp_cond_load_acquire(p->on_cpu, !VAL); > + return; > + > + /* > + * Again, if activation is delayed, it's possible the > + * task has been woken and is no longer blocked_on, > + * but went back to sleep, so double check blocked_on > + * before activating onto the owner's rq > + */ > + if (!task_is_blocked(p)) > + return; > + > + /* > + * This was cleared right before calling > + * do_activate_blocked_waiter(), so if it is set we've > + * woken, and went on to queue on a different sleeping > + * owner. They will activate us later when its > + * appropriate, so bail now. > + */ > + if (READ_ONCE(p->sleeping_owner)) > + return; > + } > + > + if (task_cpu(p) != target_cpu) { > + en_flags |= ENQUEUE_MIGRATED; > + psi_ttwu_dequeue(p); > + proxy_set_task_cpu(p, target_cpu); > + } > + rq_lock_irqsave(target_rq, &rf); > + /* > + * proxy_enqueue_on_owner() called block_task() which > + * increments nr_uninterruptible, so we need to reverse > + * that when we activate the blocked waiter > + */ > + if (p->sched_contributes_to_load) > + target_rq->nr_uninterruptible--; > + update_rq_clock(target_rq); > + activate_task(target_rq, p, en_flags); > + wakeup_preempt(target_rq, p, 0); > + rq_unlock_irqrestore(target_rq, &rf); > + } > +} > + > +static void activate_blocked_waiters(struct rq *target_rq, > + struct task_struct *owner, > + int wake_flags) > +{ > + struct list_head bal_head; > + unsigned long flags; > + int en_flags = ENQUEUE_WAKEUP | ENQUEUE_NOCLOCK; > + > + if (!sched_proxy_exec()) > + return; > + > + /* > + * A whole bunch of waiting donor tasks back this blocked > + * lock owner task, wake them all up to give this task its > + * 'fair' share. > + * > + * This is a little unique here and the locking is messy. > + * At this point we only hold the blocked_lock, so the > + * owner task may be able to run and do all sorts of > + * things while we are processing the blocked_head list, > + * including going back to sleep, which can cause tasks > + * to be added to the owners->blocked_head while we are > + * processing it! > + * Thus, we pull the entire list off the owner->blocked_head > + * here so that we will only process a finite amount of > + * tasks. Tasks added after this will be processed by the > + * future wake events. > + * Even though we have pulled the list off the blocked_head > + * the removed list is *still* "owned" and serialized by > + * the owner->blocked_lock! As we have to serialize against > + * mid-chain wakeups, who may try to remove themselves from > + * the list. > + */ > + raw_spin_lock_irqsave(&owner->blocked_lock, flags); > + if (!list_empty(&owner->blocked_activation_node)) { > + raw_spin_unlock_irqrestore(&owner->blocked_lock, flags); > + return; > + } > + > + if (list_empty(&owner->blocked_head)) { > + raw_spin_unlock_irqrestore(&owner->blocked_lock, flags); > + return; > + } > + > + get_task_struct(owner); > + INIT_LIST_HEAD(&bal_head); > + list_add_tail(&owner->blocked_activation_node, &bal_head); > + raw_spin_unlock_irqrestore(&owner->blocked_lock, flags); > + > + while (!list_empty(&bal_head)) { > + struct list_head tmp_head; > + > + INIT_LIST_HEAD(&tmp_head); > + owner = list_first_entry(&bal_head, struct task_struct, blocked_activation_node); > + > + raw_spin_lock_irqsave(&owner->blocked_lock, flags); > + list_replace_init(&owner->blocked_head, &tmp_head); > + list_del_init(&owner->blocked_activation_node); > + while (!list_empty(&tmp_head)) { > + struct task_struct *p; > + > + p = list_first_entry(&tmp_head, > + struct task_struct, > + blocked_node); > + WARN_ON(p == owner); > + get_task_struct(p); > + __proxy_remove_from_sleeping_owner(owner, p); > + raw_spin_unlock_irqrestore(&owner->blocked_lock, flags); > + > + do_activate_blocked_waiter(target_rq, p, en_flags); > + > + raw_spin_lock_irqsave(&p->blocked_lock, flags); > + if (list_empty(&p->blocked_activation_node)) { > + get_task_struct(p); > + list_add_tail(&p->blocked_activation_node, &bal_head); > + } > + raw_spin_unlock_irqrestore(&p->blocked_lock, flags); > + put_task_struct(p); > + > + raw_spin_lock_irqsave(&owner->blocked_lock, flags); > + } > + raw_spin_unlock_irqrestore(&owner->blocked_lock, flags); > + put_task_struct(owner); // put matches get prior to adding to local bal_head > + } > +} > + > +static inline struct task_struct *proxy_resched_idle(struct rq *rq); > + > /* > * Checks to see if task p has been proxy-migrated to another rq > * and needs to be returned. If so, we deactivate the task here > @@ -3931,8 +4189,7 @@ static inline bool proxy_needs_return(struct rq *rq, struct task_struct *p) > if (task_current(rq, p)) > return false; > } > - > - dequeued = dequeue_block_task(rq, p, TASK_WAKING); > + dequeued = dequeue_block_task(rq, p, TASK_WAKING, 0); > > /* > * Dequeue @p from its scheduling class before resetting rq->donor. > @@ -3954,6 +4211,10 @@ static inline bool proxy_needs_return(struct rq *rq, struct task_struct *p) > { > return false; > } > + > +static inline void activate_blocked_waiters(struct rq *target_rq, > + struct task_struct *owner, > + int wake_flags) {} > #endif /* CONFIG_SCHED_PROXY_EXEC */ > > static void > @@ -4023,8 +4284,10 @@ static int ttwu_runnable(struct task_struct *p, int wake_flags) > > update_rq_clock(rq); > if (p->is_blocked) { > - if (p->se.sched_delayed) > + if (p->se.sched_delayed) { > + proxy_remove_from_sleeping_owner(p); > enqueue_task(rq, p, ENQUEUE_NOCLOCK | ENQUEUE_DELAYED); > + } > /* > * If we're waking a blocked task and we are > * currently proxying, force a resched in case > @@ -4411,6 +4674,7 @@ int try_to_wake_up(struct task_struct *p, unsigned int state, int wake_flags) > { > guard(preempt)(); > int cpu, success = 0; > + bool woken = false; > > wake_flags |= WF_TTWU; > > @@ -4438,6 +4702,7 @@ int try_to_wake_up(struct task_struct *p, unsigned int state, int wake_flags) > > trace_sched_waking(p); > ttwu_do_wakeup(p); > + woken = true; This branch cannot have "p->is_blocked" so it probably doesn't require sleeping owner handling right? > goto out; > } > > @@ -4453,6 +4718,7 @@ int try_to_wake_up(struct task_struct *p, unsigned int state, int wake_flags) > if (!ttwu_state_match(p, state, &success)) > break; > > + woken = true; > trace_sched_waking(p); > > /* > @@ -4568,6 +4834,8 @@ int try_to_wake_up(struct task_struct *p, unsigned int state, int wake_flags) > ttwu_queue(p, cpu, wake_flags); > } > out: > + if (woken) > + activate_blocked_waiters(cpu_rq(task_cpu(p)), p, wake_flags); I think there is a very convoluted race possible here like: /* Wakeup from task context. */ try_to_wake_up() ttwu_queue_wakelist() /* sends IPI */ ---------------> ttwu_do_activate(owner) activate_task(owner) /* stalls */ /* Owner runs */ mutex_unlock() wake_up_process(sleeping_donor) activate_task() proxy_remove_from_sleeping_owner() put_task_struct(owner) /* &owner->usage is 1 after this */ /* Owner dies */ finish_task_switch() if (prev_state == TASK_DEAD) put_task_struct_rcu_user(prev = owner); /* owner->usage turns 0 */ /* Queues RCU callback to free owner */ /*Back */ raw_spin_rq_lock_irqrestore(p->pi_lock); /* Preempted; RCU grace period done. */ activate_blocked_waiters(owner) /* !!! Use after free for owner !!! */ I suppose it is also possible for any remote wakeup and not necessarily dependent on TTWU_QUEUE bit. Am I missing something that prevents this? One way to get around this is to do a guard(irqsave)() before grabbing the &p->pi_lock and that way, you should have an RCU-protected reference for the entirety of activate_blocked_waiters(). IRQs will be disabled for the duration of chain wakeup but that is also true today if the owner wakes up from an IRQ handler so it should be okay? > if (success) > ttwu_stat(p, task_cpu(p), wake_flags); > -- Thanks and Regards, Prateek