Authentication-Results: smtp.subspace.kernel.org; arc=pass header.oldest-pass=0 smtp.remote-ip=52.101.57.52 ARC-Seal: i=2; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=pass; t=1796191829; b=zt5gRmOpFr8EbGRl2raGD+3Ccj4D5Ikfklb3+f1HTmg9NcvWaZoTQ1ccj5PnA5knI62D lBo9l+XvXTXLhNkj7QfqLiRkqc6VRePq253GMYgK2Ixh/icbGTkFdapBb7IQ3o24/LUkz zifeanBWRDNqlE/hTtl4BHHF3E1BplJXMUOjz1WmWfH+WzeNKYtJ7VSPOd0BsqRWl5GKp ElhYME4Dbh2t2Mk43SJBgdAi9YWWflfkLVmGmkoWua6FXMnq3VI2X/4FJ3efDVyXCcJuV kUMNSs8VlcRHtBaRYTZieWrb0HOPRXZFTo0gGAca37lHBuW95M6yMALMCEeVj+uFElA== ARC-Message-Signature: i=2; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796191829; h=DMARC-Filter:DKIM-Signature:Received:Received: X-MS-Exchange-Authentication-Results:Received-SPF: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=C9BFKX/SwxZnlyvh7u3w8qw/k5yFOAzdoF8mj2Icyhg=; b=MQD+CYnEX+hBTbUQkl1x+kEtSrfSoD5K5dQQIE5VUYkKukkS9onM3lEQRNVwVsGBIzw9 JhwJVamPJO6W5+0vKMKvqR0YuWpAnG4kX7xuszxhFHfibzwYm/+XnXLbkg/Wkwt0sHBAI lRZE4oqHsP7xtPxcVjuZDmp710YdkZE0jyFHxeJaJ+7iSBy/ryCYmsf6IsNWh8Dpvv1d+ SwENBogo+tyuinsxCpNNim6i/8yA0bcxU9SRlwCSduAq8j8KgzjmWa9j4RBDFkPC0rBMy HSTijnTp1YcZZCDYoPBrfXrIICHS3TRVrZrUxkI4KSwJ7ejoeMEQhJyCmUeREgg2HRQ== 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=KzuFFPy+; arc=pass header.oldest-pass=0 smtp.remote-ip=52.101.57.52 Received: from BN8PR05CU002.outbound.protection.outlook.com (mail-eastus2azon11011052.outbound.protection.outlook.com [52.101.57.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 77756606A31A for ; Wed, 2 Dec 2026 06:10:28 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 77756606A31A 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=KzuFFPy+ ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=KW17z46m1Og6d7+UblFrQTQSu/WGg4/55TtopMogvyG2CTMsxJHSitbpykSTyAWRwcXEsn7T49yVcTgwJixG+pxh6iyMKi3fBeLmEXvaG1UHS4lz0YlpOAh2vPeiKPZvSmtvTXRjaZHTP1gJXzDb33Z1Q7H7QkIitGK+3xHsjPBgOyudp/0KIAD3wkGg++HzMWsFYE2g5+kMFOOpMuOVRVcGIBWe4XqDaL1leXv50I+SN+T/MZkSQoDlf6Dp5FN14ISFbWHtkH1DyrXHM4crDGE67VIVCF6lfgbuBMOPBxYBtwCl9qfXwSoYCLUrc+cg9QA4kolH0RfGJPvE3CnHDw== 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=C9BFKX/SwxZnlyvh7u3w8qw/k5yFOAzdoF8mj2Icyhg=; b=P9JyXp8xlMTs2CgJJyQ0ZRTl1ok/0Sw6ukHemkzFXpXEe7wuxt7z1cIWjt1aj3KYR+3nQRZxPsdjbjdAgnSNeWfDZIQ8610/OwxCRAabjhWKphJM/j/7bhqQpLOHBLZj1dHLOkP0PGISdKVWaw/KshLWe+3kwU9pbV/9/vPxQbGge1fYudodDMG/+a4QX9UGjrkrVnQI458mZMzd2ECeUDirlpBkJzxUtrKzxFANoXnzsLuP6C4kJq41Vqr142tNcmTMe+VCL8J2v7zXaJxxW3QqJaciOEQ6OZ6NBUTD5hzNI8h7K5cvIf6M5TXjIlTOjWZv0rFgzZfMJLR23AADQg== 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=C9BFKX/SwxZnlyvh7u3w8qw/k5yFOAzdoF8mj2Icyhg=; b=KzuFFPy+y2L4oUuIX63OyuJN+41vxuqsQ9CyN0L8s0TTy4ffahL7p/AF+8KWfHRwHS6L32Y3cKrHfeF/kX1inKqYlePO7TIoectSsNGH90RL2ENr601VNsMUNhmT8bNtpOdGUsfsxAM0kebt3vauM3ranzwUZmFU32yaxH8om74= Received: from MW3PR06CA0022.namprd06.prod.outlook.com (2603:10b6:303:2a::27) by SA1PR12MB7269.namprd12.prod.outlook.com (2603:10b6:806:2be::5) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.21.688.10; Wed, 2 Dec 2026 06:10:22 +0000 Received: from BY1PEPF00026956.namprd05.prod.outlook.com (2603:10b6:303:2a:cafe::50) by MW3PR06CA0022.outlook.office365.com (2603:10b6:303:2a::27) with Microsoft SMTP Server (version=TLS1_3, cipher=TLS_AES_256_GCM_SHA384) id 15.21.688.10 via Frontend Transport; Wed, 2 Dec 2026 06:10:21 +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 BY1PEPF00026956.mail.protection.outlook.com (10.167.244.164) 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 06:10:21 +0000 Received: from satlexmb07.amd.com (10.181.42.216) 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 00:10:17 -0600 Received: from [10.136.42.27] (10.180.168.240) by satlexmb07.amd.com (10.181.42.216) with Microsoft SMTP Server id 15.2.2562.57 via Frontend Transport; Wed, 2 Dec 2026 00:10:09 -0600 Message-ID: <2422a051-ea4c-47ef-b5de-9523a351faf7@amd.com> Date: Wed, 2 Dec 2026 11:40:08 +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 05/14] sched/proxy: Clear blocked_donor when the donor stops donating To: John Stultz , LKML CC: Mathieu Desnoyers , Peter Zijlstra , Ingo Molnar , Thomas Gleixner , Juri Lelli , 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-6-jstultz@google.com> Content-Language: en-US From: K Prateek Nayak In-Reply-To: <20261202035248.1210026-6-jstultz@google.com> Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: 7bit X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: BY1PEPF00026956:EE_|SA1PR12MB7269:EE_ X-MS-Office365-Filtering-Correlation-Id: d989cd15-269a-4ca1-9f42-08df503af255 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|82310400026|36860700016|7416014|376014|1800799024|23010399003|4143699003|18002099003|22082099003|10067099003|56012099006|261028144727099003|261022075727099003|261026121527099003|261026140227099003|261022105027099003|11063799006; X-Microsoft-Antispam-Message-Info: aUcPa50RegoOIihPHL1mpg/ndnwVu0HJQ5FYDq2OM68dYYP6WLfrzcz3ld3oI92ZNTEFvQh4oXWfQhoqAPMr6KWOFXzN5hY8FK3StR6bVmfZCLhmxC8UvRw2yxb1d60VsGn3yVVNGVLFQp5IZQQ4v66eHXjsnnBhcgK5rjIAq6cUfEuCHMM9vui4WaZOHQnSIunYULU+YlIXJRCVKQ2IaWRijoaN/Zh1lDaDnE0BwIK7T5WnnpgYsR228mUDQjd45zVk//CbiMHKBzjMXw2smuPY9nfn+4zEll7pIEBhJHl04uWCHFOsrU3seHiYqSoa0AJNVWlBmw/u3ZKIw/5Bd3aHz8wnaAgv9gb/AqZFJtcpVKzV2tB6HXviZPFgXI5zNvmVYiHdmZxBDc7BturumweB4ZN8syxnG5HahmicZp10LbQOweFOWHhklK92CY6Yi0FC0dIBO2TScJV37UX6PyfyLpfsP7kyS2y35ceaaHeUWhco2GI6B+uXNXQNHyHkEg5MPurrVFPu2QoPbwHBzV6qSiKzjCCSe0kzmzG6fRU1LXA/FlrmrEl12ThamPSwdZa8UqZz/YGCzLcj4hjbOji8w6US+EBuz7cvnqfms8E31QVNSX4QHM7DLP6ONClOOPqLnfmbVpeubmiTTbvctcrMJ6RoXXRDKh8yE99YfRB8VUxOVaNr2AFfIjbLt8cMjZ3bfALYQrMRIP6+WnlWoA== 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)(7416014)(376014)(1800799024)(23010399003)(4143699003)(18002099003)(22082099003)(10067099003)(56012099006)(261028144727099003)(261022075727099003)(261026121527099003)(261026140227099003)(261022105027099003)(11063799006);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: KPEsIthHc6vEj5wbJ1AXX7Zn+FzwA8YiBsGRKuP7VvCwDvKh4N8Iiq3DwtUePVUkwuV06dfO9HdeGYMdfAbJ8mHz+AAciLiCsp6sosBoakte1BpsRfEFmJG4dNo/5UgsJ1eV4j4yZeF7jd0349Q3qmG3LmsFMUjQeqKcu5SnA4nfLUi8wJSlBtCHP2Qef2/QUgI9DwG7xmcvB2BjNViCXQpd0fcZZqLxt2iAyEF/26mPBDJoTS3O+n/AcaE1K5LJFdvoB9wBg0l9p7XQyA3NPvlbopXD8BvSHoONooL0KFm+HrC5kod5dbOLjy6h8U/C5BC056bWv4hD989sBBrbvXh+aVOvSUWaJNSD4PwXZNA3DSFyvVjjCcGcXE2Gt3h5HLux2c0y4JTnW8o+HATqroGZkbM3qu+ku1eP0NmUpc53Ms5Rd8yMczm+9CxIwtyR X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 02 Dec 2026 06:10:21.2895 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: d989cd15-269a-4ca1-9f42-08df503af255 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: BY1PEPF00026956.namprd05.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: SA1PR12MB7269 Hello John, Mathieu, On 12/2/2026 9:22 AM, John Stultz wrote: > From: Mathieu Desnoyers > > find_proxy_task() sets owner->blocked_donor to the task that donates to > the owner. __mutex_unlock_slowpath() reads current->blocked_donor to > hand the mutex to that task. The comment of the field says that it is > set in schedule() and only stable under preempt_disable(). So the > pointer is valid until the owner schedules again. > > But the donor can stop donating while the owner keeps running. It is > woken, or a change of its scheduling class or of its affinity takes it > off the runqueue. The owner keeps its blocked_donor until it schedules. > Meanwhile the donor can run on another CPU and exit. So we can just clear it in proxy_reset_donor() right? Only current->blocked_donor is ever looked at and, it the proxy breaks mid way, the only path that can be taken is via ttwu_runnable(). If the task is retained on the same CPU, it is safe to get the reference since unlock is done with preempt disable - otherwise, we check: donor = current->blocked_donor; guard(&donor->blocked_lock); next_lock = __get_task_blocked_on(donor); if (next_lock == lock) next = get_task_struct(donor); ... If ttwu_runnable() manages to clear the blocked_on relation first under the blocked lock then we don't take a reference here and if we manage to take a reference here, the task cannot exit unexpectedly - it'll just get a spurious wakeup in the worst case. IMO, a simple READ_ONCE() to check it here and WRITE_ONCE() in proxy_reset_donor() after the re-arrangement suggested on Patch3 should do the trick based on my understanding. o Race: try_to_wake_up(donor) mutex_unlock_slowpath() ttwu_runnable(rq, donor) /* MUTEX_HANDOFF */ proxy_needs_return(rq, donor) donor = current->blocked_donor; proxy_reset_donor(rq) raw_spin_lock_nested(donor->blocked_lock) WRITE_ONCE(rq->curr->blocked_donor, NULL); next = get_task_struct(donor); ... /* Donor wakes up runs, exits */ /* * t->__state = TASK_DEAD * t->usage != 0 so freeing is deferred wake_up_process(p) */ !ttwu_state_match() put_task_struct() /* Freed via RCU */ If the task runs and blocks on a different lock, wake_up_process() from mutex_unlock_slowpath() (if it still think lock has not changed) will just lead to a spurious wakeup. Is here a scenario where proxy_reset_donor() clearing is not enough? -- Thanks and Regards, Prateek