From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from MW6PR02CU001.outbound.protection.outlook.com (mail-westus2azon11012046.outbound.protection.outlook.com [52.101.48.46]) (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 A5E7C3AB262 for ; Fri, 29 May 2026 06:45:28 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=52.101.48.46 ARC-Seal:i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1780037130; cv=fail; b=IlMI09/0vFl7xqHzHZh8AOO1zzXeZO7trweHeycmAs82oKMdwseJ/NjH/P2P9ayspXoItB/+iQoCl8zl0fvIsasw9FGT9DkcgfUbPVAP8D1vkeZ1sdtMfHvYxWO1GIMDJGLgmCbAZpdnMII4c66rlc0tQn7e1bFRKD9/coXukbQ= ARC-Message-Signature:i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1780037130; c=relaxed/simple; bh=SSXUKF2N+LLY1xa0g8XAzV+oipMJkVe3RVTCo9vEW5Y=; h=Message-ID:Date:MIME-Version:Subject:To:CC:References:From: In-Reply-To:Content-Type; b=hV71h3pD90g96t/3xhcXuQOgaCyGgP2n6NHK9X9L2YTSV1vklDxzfcyX35siQDzSW5msHOor9ny0HS3kjeQwsp96LrPLmPp48ZYNnb7m0O24V4fXtinQtlBMdinSNQDsA1RCrCmQ8alTtI4/o36eeRwZm0SX+PuiUdv4CcnFtA4= 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=LDHSyMuF; arc=fail smtp.client-ip=52.101.48.46 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="LDHSyMuF" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=PjTSZZYYkV3nqo0DMFC1AyZrhTZfmHTBsiwQVIDhfewo1wQ11k53PZ7WixnFUzLu+GTkooTL4o1nH2Kum4F4bpVJZBx7q2NXiM8NJ1XuK+8yZK6Hx1jX9MfF9fy9e9HaNp0KYFvYsxiIIPNe+NOjvWe9fR32Zui+hBM1Kk75KeyIbh/dovGoCfbXRR6J2UVYfWXtgnoaA5K0TNsjaWkauAaM2GCzdokhwq4ueuUUJbNDAQlg2HzGASKT8m1D2fn4X1JqyXkhG3d39rGmOIjdJ/kc2J05QCiiEZiLscNkqstmsx2TxIOlHPr2xrtfV8oMVK8zVvcgdmhI4n2SrArf+w== 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=C4XOx8IqyAijihGNJBolLt2HJTwxADDJmh+NWNyUlAE=; b=OqadbdswoBIkhMqpirmUa+4f6Nr/AFSNhaMt3eX+QyZ5w3cEKrXfx5PLI91ZYNYfsNgtRBwsGhoUAQJacvg+lwwsLYd/qxYVf3Xba/YClbtbwHBYS89Sv5YEMOUAexe6WcHWotuuMrSw2HZwLxSxHDMTsYtMfk18qdKrqhi6nFFbRdPjsnUBmCLjQiPupkeITotthBv/PBXKs6FHdmkQ/4v7tXxdMTHP5xgT1uKpE46EdIuJndG4BQVAsjWMX6Z13A/F3Z5oiFgbNOmERD3GN3pdEQ22ziZGv+qnejD3ipR9j9XLw11MhZ8rZyEvrEQh1qnbIf6FE/Q8c0XMgfVYyQ== 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=C4XOx8IqyAijihGNJBolLt2HJTwxADDJmh+NWNyUlAE=; b=LDHSyMuFrMT7uEwiALoMU/0q7XM1/2fMxYhcs72CxGpaNouzqePeXacpDrvk7tD6plujzkRmfNwa941QUh/WFL9Gsn82skvcB2GDPyEljwfIh0ZRnqkoDQ1KhwLRmkxlaHO9r3GqUgW07fleQ89wuShqmRhmwdle4T9rbtROwlM= Received: from BY5PR03CA0026.namprd03.prod.outlook.com (2603:10b6:a03:1e0::36) by SN7PR12MB8434.namprd12.prod.outlook.com (2603:10b6:806:2e6::6) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.21.71.14; Fri, 29 May 2026 06:45:22 +0000 Received: from SJ5PEPF000001CE.namprd05.prod.outlook.com (2603:10b6:a03:1e0:cafe::24) by BY5PR03CA0026.outlook.office365.com (2603:10b6:a03:1e0::36) with Microsoft SMTP Server (version=TLS1_3, cipher=TLS_AES_256_GCM_SHA384) id 15.21.48.20 via Frontend Transport; Fri, 29 May 2026 06:45:22 +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 SJ5PEPF000001CE.mail.protection.outlook.com (10.167.242.38) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.21.92.5 via Frontend Transport; Fri, 29 May 2026 06:45:22 +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; Fri, 29 May 2026 01:45:21 -0500 Received: from satlexmb07.amd.com (10.181.42.216) 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; Fri, 29 May 2026 01:45:21 -0500 Received: from [10.136.36.222] (10.180.168.240) by satlexmb07.amd.com (10.181.42.216) with Microsoft SMTP Server id 15.2.2562.41 via Frontend Transport; Fri, 29 May 2026 01:45:15 -0500 Message-ID: Date: Fri, 29 May 2026 12:15:09 +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 1/6] sched/proxy: Remove superfluous clear_task_blocked_in() To: John Stultz , Peter Zijlstra CC: Joel Fernandes , Qais Yousef , Ingo Molnar , Juri Lelli , "Vincent Guittot" , Dietmar Eggemann , Valentin Schneider , "Steven Rostedt" , Ben Segall , "Zimuzo Ezeozue" , Will Deacon , Waiman Long , Boqun Feng , "Paul E. McKenney" , Metin Kaya , Xuewen Yan , Thomas Gleixner , "Daniel Lezcano" , Suleiman Souhlal , kuyo chang , hupu , , Mike Galbraith References: <20260526111609.433880331@infradead.org> <20260526113322.120970670@infradead.org> Content-Language: en-US From: K Prateek Nayak In-Reply-To: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: 7bit X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: SJ5PEPF000001CE:EE_|SN7PR12MB8434:EE_ X-MS-Office365-Filtering-Correlation-Id: b76ddeed-bc26-4f31-a9bb-08debd4ddb3f X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|7416014|376014|36860700016|1800799024|82310400026|18002099003|22082099003|11063799006|56012099006|4143699003; X-Microsoft-Antispam-Message-Info: vAskW+PkZ8eFilYW+D4q/XPm43jJiC8aF6AlIm4JrKXnc8OiwgUt7IoF/2u/Il5JipO9nvkQ1FdmuEhqdEIpPYWHMOmOaOUF8/NLnSKQc2R5qJoCNP4/MPGSWOwXRwh5yP3vmnJg9I9RjrkIaElFm4lGmhFEngrgB1gOn3OBm2vcYO8JwXTaroUTbOxk/pEy176cr+S5EGtoy448AUsG9Fww+E6E/VNM3002ceJ4b7p0UsfzdPo2tKDfxhP6FqUOM0pfHalmxPch89x5h8kKX4r0wDyM9NdvN/cN5RH+ZSyWM6QiNX6IdyK2C8MwaXPphCRLjpNFddU8YCF+OEZqf0yL5yXE2XGAsfjjbZzu7NrBb3BB8zDf8akG4aI2B+SuuMxTpzxlLyc06r2iQoQOgvCW8xko6ccDcraQFIrNft5oteuJ3YX33ncXCk0PZphmwvM911/8qJ5xem+Y31JWBvDBAXYyXm6R0EOIHYQJvOK+tWI2PbzVz5vsdrZatpZh1OmsdSMSC0UQVj+8/OTBzU3wROiSd6EZWS8pCeUQBB3zt8dE08qIEJSsRjFvvN1e2Au0h/qt+dsgRpzXjqqphmxYCONtuHHYdxiTPAofKAGH7N1LWSAm9gHVIiFEh4xHlBzoxmzy/lQwXcCECe1KgfwjjCsnDWklN/GyDebFdMotWKo1tdJyQ2iqgVVhJEp/Qmd0abXqhvkkNqoIwMpXn5mpJdWUB41J87trodr8W5w= 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)(7416014)(376014)(36860700016)(1800799024)(82310400026)(18002099003)(22082099003)(11063799006)(56012099006)(4143699003);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: XanDgfhPPXo7g3kyhIJnO9WkpoJi5g7ONhbFeLh1uwFBJB4VbL4taIF9P8mLswV0MhFldeYY9/JcJzp7aJnQ92/Hb9PcHg9IAzkAGf54yB6Tj8u3v5QMO/pWDy1S43MOKpJC1bMMGUwqovzPuo4lzIkt4tMl3E4zeplCNRiZMiIbTaJRH0sJkozmXZjmQFXmbkaIE+PsC8yO8Vp+YGKuBpeOEiYSI3elOxbKxq+nKlaqtdDYrpjcerU2ILeKHp0+Nxsh51vyQ3Hrl8BR3Rb9O0IeLoS3jC9mEpblYDHmv+IzlrKzVRc6vbkWMfNgk79T2aaZ7j15z7F9UCnwwP3YyaKmoe4SaadUexvlAme+boAP24viAH+dgYnVtF7k4OxQOle1+fhF6wjsRWS6OZLqIl+MgP36lkI+YSV64n5XkVZhu5GFsvj9LNaNLYFGMLQZ X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 29 May 2026 06:45:22.0369 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: b76ddeed-bc26-4f31-a9bb-08debd4ddb3f 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: SJ5PEPF000001CE.namprd05.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: SN7PR12MB8434 Hello John, On 5/29/2026 4:50 AM, John Stultz wrote: > However, even with the fix I poined out, I've unfortunately hit races > with the ww_mutex selftest at the point of this patch in the series. > Basically between commit > 1b89b7b21bf5 ("sched/proxy: Remove superfluous clear_task_blocked_in()") > and > a8be1edac5a1 ("sched/proxy: Remove PROXY_WAKING") > > I'm currently tracing down exactly why the race is cropping up but I > believe the chunk removed in this case is avoiding cases where we end > up getting PROXY_WAKING set on a TASK_RUNNING task. This seems to be the failure path: /* Task p*/ mutex_lock(mutex) ... try_to_wake_up(p) schedule_preempt_disabled() ttwu_runnable() __schedule() __task_rq_lock() /* Wins */ rq_lock() /* Waits */ if (task_on_rq_queued(p)) /* * p->is_blocked is still not set! * proxy_needs_return() bails out early. */ ttwu_do_wakeup() p->__state = TASK_RUNNING; __tsk_rq_unlock(); ... /* p->__state = TASK_RUNNING */ prev_state = p->__state; if (prev_state && ...) { /* * Skipped since task is * already TASK_RUNNING */ } /* p->is_blocked = 0; p->blocked_on = PROXY_WAKING */ next = p; /* Returns from schedule_preempt_disabled() set_task_blocked_on(p, mutex) !!! p->blocked_on == PROXY_WAKING && p->blocked_on != mutex !!! --- Also proxy_needs_return() bails out too early - a wakeup from signal should still clear p->blocked_on even if p->wake_cpu is same as task_cpu(). I think we need the following at commit 83f9b04ef50c ("sched/proxy: Switch proxy to use p->is_blocked") to clear p->blocked_on in the wakeup path irrespective of p->is_blocked: (Lightly tested) diff --git a/kernel/sched/core.c b/kernel/sched/core.c index a125e65c35bb..fe903976fd09 100644 --- a/kernel/sched/core.c +++ b/kernel/sched/core.c @@ -3764,28 +3764,28 @@ static inline void proxy_reset_donor(struct rq *rq) */ static inline bool proxy_needs_return(struct rq *rq, struct task_struct *p) { - if (!p->is_blocked) - return false; - - /* - * Typically per __set_task_cpu(), task_cpu(p) == p->wake_cpu. - * - * However, proxy_set_task_cpu() is such that it preserves the - * original cpu in p->wake_cpu while migrating p for proxy reasons - * (possibly outside of the allowed p->cpus_ptr). - * - * Furthermore, migration_cpu_stop() / __migrate_swap_task(), will - * only set p->wake_cpu when !p->on_rq, and since here p->on_rq, this - * will not apply. But if it did, this check is the safe way around - * and would migrate. - */ - if (task_cpu(p) == p->wake_cpu) + if (!task_is_blocked(p)) return false; scoped_guard(raw_spinlock, &p->blocked_lock) { /* Task is waking up; clear any blocked_on relationship */ __clear_task_blocked_on(p, NULL); + /* + * Typically per __set_task_cpu(), task_cpu(p) == p->wake_cpu. + * + * However, proxy_set_task_cpu() is such that it preserves the + * original cpu in p->wake_cpu while migrating p for proxy reasons + * (possibly outside of the allowed p->cpus_ptr). + * + * Furthermore, migration_cpu_stop() / __migrate_swap_task(), will + * only set p->wake_cpu when !p->on_rq, and since here p->on_rq, this + * will not apply. But if it did, this check is the safe way around + * and would migrate. + */ + if (task_cpu(p) == p->wake_cpu) + return false; + /* If already current, don't need to return migrate */ if (task_current(rq, p)) return false; --- Part of that belongs in commit e2ff8b7bde07 ("sched/proxy: Only return migrate when needed") and the first hunk of 83f9b04ef50c ("sched/proxy: Switch proxy to use p->is_blocked") in proxy_needs_return() should be dropped. -- Thanks and Regards, Prateek