From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from SN4PR0501CU005.outbound.protection.outlook.com (mail-southcentralusazon11011026.outbound.protection.outlook.com [40.93.194.26]) (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 BA5213B4407 for ; Wed, 26 Aug 2026 06:30:52 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.93.194.26 ARC-Seal:i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1787725857; cv=fail; b=fNi0rJpmwznaWfXymk2au1p6GQXhFxLh6WNxLVY80Qz/xNcf9m2aHDaKOq28WXOq9ZMIo33fSGbP88LeLX/tcNl2AJV3Qd3Mte5XHh+2hELD39p/DDdSXQEWDANx9EMeUzzxXPmuKLmcXq3bKX9V+Dyf1vkbX2E51Ef1oyMw/QU= ARC-Message-Signature:i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1787725857; c=relaxed/simple; bh=T3NMGknl2wQ+6uJGbazuRhpwkzUBa6XS52uVW4iTw8M=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=DJPhkCIClEkNKY+C5EaKc0l1rcvJeXXW+XJFItlXWvi4hBT3pES7GFWyUnO9tOdLwV9s3LkNBcph/3/E/bRPdFe6BpFo1J1+NLErL1AiMWpD1IPHh58ewm1UmemIb6tzGYRQCOdadUNc26bwS9B945U2luGlIcpEzdlvzroFm4g= 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=tnwlGrcC; arc=fail smtp.client-ip=40.93.194.26 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="tnwlGrcC" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=Y9zzSS7CXPxRYxo3s3q4OFGD7dyEOTJAlxr+qtPYrdzWfqhnA2rn9HKdtAEcensbvKJDN3bx4A+HNu4yn7E7KSNpvbqXzPDsnFav+4lTlJ97HAjjbuxjvnWTrLLipUDdYMpzmjenctAfqcYxAJIvRQ7uYYb3sRe50QgYdqWANUtywDtj6y65nqwfHtUNTgQrBcDUa3r763POjxnuwWjwmHe45RRdwZVFrPK5g+8kj9acHFrZ7WYLN9E3ny1sjgv3EulKlPUWkCcaw50tPFK+DrP6c4/a1FiLvtsr/VthZBE/7RnI9rXNtknmDJ1Xdd8y7tCEZlwE570LVvKTnPhcWg== 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=8sh35/wwhhiaPhou4AKCiqdBAOZwTcYCdh9QAXmgBeU=; b=lJOmtxruV6nLlms1GxXoyCIY4CDRaU/jI0OBL6vcvhk4Vvl+CSdwN4mu8/2kYZqSTHpTg91NLzPkbgT7pO3IQzMYRMK1QQZyoqmWB3ZUk2CflV72DJ7oS/Ry69hhLDzvYHcE4k2EsFgfRYb2/UW/naXUBzfM/xjCEq5jmHdzvKUj/rswm0Jw+sre21nOns1a1Y6Y3MI5y4xfY4++K4PAQegiwVUW20LRSgBDbVsz+rcZYI/9Um8vOxGjnqVuCUEd/AgGOmS9ivCDy4OW2mh+wNZZtKnI245oLWgoeO8tk+LSkahqBRGS0R7mJtMQmVppFk7wqQP57nveG+OatSBvmw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=softfail (sender ip is 149.199.90.133) smtp.rcpttodomain=google.com smtp.mailfrom=amd.com; dmarc=fail (p=quarantine sp=quarantine pct=100) action=quarantine 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=8sh35/wwhhiaPhou4AKCiqdBAOZwTcYCdh9QAXmgBeU=; b=tnwlGrcCwIcXAnliqFiMS5tPgB8/kXhWVXYQsqqupsozHEbbBxiBuv7IFW7K0CV9Li9NHPSYfgLd9qNlO/kOaOWXqZTCbIbYmMsqwTVzDQsAeSoHMSpK5TtR8rwfiHyKhhO4RE22ZgvtPYBktqfCg4UYJ60t6zVa2fB/vNGHhFs= Received: from CH5P221CA0009.NAMP221.PROD.OUTLOOK.COM (2603:10b6:610:1f2::14) by SJ5PPF2CD49510F.namprd12.prod.outlook.com (2603:10b6:a0f:fc02::98f) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.21.360.8; Wed, 26 Aug 2026 06:30:44 +0000 Received: from CH2PEPF00000143.namprd02.prod.outlook.com (2603:10b6:610:1f2:cafe::ad) by CH5P221CA0009.outlook.office365.com (2603:10b6:610:1f2::14) with Microsoft SMTP Server (version=TLS1_3, cipher=TLS_AES_256_GCM_SHA384) id 15.21.360.8 via Frontend Transport; Wed, 26 Aug 2026 06:30:44 +0000 X-MS-Exchange-Authentication-Results: spf=softfail (sender IP is 149.199.90.133) smtp.mailfrom=amd.com; dkim=none (message not signed) header.d=none;dmarc=fail action=quarantine header.from=amd.com; Received-SPF: SoftFail (protection.outlook.com: domain of transitioning amd.com discourages use of 149.199.90.133 as permitted sender) Received: from satlexmb07.amd.com (149.199.90.133) by CH2PEPF00000143.mail.protection.outlook.com (10.167.244.100) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.21.360.3 via Frontend Transport; Wed, 26 Aug 2026 06:30:44 +0000 Received: from BLRKPRNAYAK.amd.com (10.180.168.240) 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.45; Wed, 26 Aug 2026 01:30:38 -0500 From: K Prateek Nayak To: John Stultz , Suleiman Souhlal , Ingo Molnar , Peter Zijlstra , "Juri Lelli" , Vincent Guittot , Will Deacon , Boqun Feng , Andrea Righi , CC: Dietmar Eggemann , Steven Rostedt , Ben Segall , Mel Gorman , Valentin Schneider , Waiman Long , K Prateek Nayak Subject: [RFC PATCH 04/16] sched/core: Activate blocked donor when no owner is found Date: Wed, 26 Aug 2026 06:28:48 +0000 Message-ID: <20260826062901.2137-5-kprateek.nayak@amd.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20260826062901.2137-1-kprateek.nayak@amd.com> References: <20260826062901.2137-1-kprateek.nayak@amd.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain X-ClientProxiedBy: satlexmb07.amd.com (10.181.42.216) To satlexmb07.amd.com (10.181.42.216) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CH2PEPF00000143:EE_|SJ5PPF2CD49510F:EE_ X-MS-Office365-Filtering-Correlation-Id: 5c7c6b61-8aaf-44fa-6671-08df033b8ed9 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|82310400026|1800799024|23010399003|7416014|376014|36860700016|921020|10067099003|56012099006|11063799006|22082099003|18002099003; X-Microsoft-Antispam-Message-Info: DwGDdzWfg+JA1FhHRXV+W7pQdHTXQLllpFLz+C0MsAWpAPxdRJdRw6xrk7XTyEgRJxtmRPfNer7tCmRG0Cpp9jng4rQQ8IuLlnodI+tt0FusBcu9DxXJYLTvRPLkLhjDhXL9U23j4sdXgETsxRx2+1OXNbEeeNVbZI3p4qpkUzmczmKbXwa5dLid9L0yaI409UsNM3t7q2ft8bbnGWiVeF5bCKg4ANXrwflvsuohnjko5RXjQxRR3OEXBCSjpJahpOG2wjnbkwTSRN76AvTcSDLBknYHGfq7P+2FSuR1AffDisjoPiN/LxHIbiXLMoDaxL4BB9abIvzgUurDn6FJ6Wifwi99UvKOmds67r/oLc8Gb6/XAwmchseYg0x57GN0dX70WVCeNJg/2VMZBnVi+mr72ALbgk0p1t2Jd0M23W2ruDXh1XgxtDcdryRjKt/tRZzU6sRCwwJ9Qvu1xmTn4pXicMElC1fj33fChnQXiNt0Vd0RZ6DJV8dVQG0G1kKaPvqml578qJT5gzNt7xmTEluHxGQLtm0r1B02phcjUyo+np6qr5aC95flNS+zowtfJ9uDHTHkjpIA+YoroVoVxh81Il2PTyaxWmDNIXcRLvQl/WuHtyqIAI61tb7bJxOr4X4vuc/nLswR67TZTsSF8gFm6zemqIjuG2sqsLFpNQIJRhISutUG0vbBfqrzx7xFT+6QjvLNIBZ92H3+1dhVfEIBwkJXSd8xiYRdETfKt4dBzKiUF/o2mi/gFzlCerEj X-Forefront-Antispam-Report: CIP:149.199.90.133;CTRY:US;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:satlexmb07.amd.com;PTR:unknown-90-133.xilinx.com;CAT:NONE;SFS:(13230040)(82310400026)(1800799024)(23010399003)(7416014)(376014)(36860700016)(921020)(10067099003)(56012099006)(11063799006)(22082099003)(18002099003);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: A4GQx7ldkjeb/FwlZv6z2+GXUOXEGvfiwvRCgfCH7RIYjoxbdPAIUfRwWCvnt9VBnrhRI3XSCAQ4Sg/KpGCWrPMLP/QcajgtE57Rv6CnfU64xadq3aeXFfjUXQNr09faxOBUbplBT2mnywqNe+vSt8iZ/DwhFbomAMIKyNK2PYFFOktSW8fH/qiqHdeEdytZhxQd/IdpBasSnleDYJCPMErtA61k4CRKlDfVgUTMeSgxKPAtFG/+/dstecX3qOafWEkErFsF8WMyhO0ndG5HZQsQ1/1YZ7ft2y1+56uKMaaebBu0Ine4DOteeUdd4Mh73b+lymuogbi/kvOt/YGGzTapditQCYThl6+rG+mn7pXvN1/ezC3h1zdSRgKvrJZ2Wf/7i1pv5OGdOjOn4nBRtFn/QrarYSfmfOBHKhW/ZsPp2RgBqvRPncYYyG0mHXYh X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 26 Aug 2026 06:30:44.3105 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 5c7c6b61-8aaf-44fa-6671-08df033b8ed9 X-MS-Exchange-CrossTenant-Id: 3dd8961f-e488-4e60-8e11-a82d994e183d X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=3dd8961f-e488-4e60-8e11-a82d994e183d;Ip=[149.199.90.133];Helo=[satlexmb07.amd.com] X-MS-Exchange-CrossTenant-AuthSource: CH2PEPF00000143.namprd02.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: SJ5PPF2CD49510F mutex_unlock_slowpath() follows: if (owner & MUTEX_FLAG_HANDOFF) break /* ... and do __mutex_handoff() */ if (atomic_long_try_cmpxchg_release(&lock->owner, &owner, __owner_flags(owner))) { if (owner & MUTEX_FLAG_WAITERS) break; /* ... and wake up the forst waiter. */ MUTEX_FLAG_HANDOFF is only set by first-waiter after it has been woken up and in absence of MUTEX_FLAG_HANDOFF, the owner clears itself from the lock_word and wakes up the first waiter to try a __mutex_trylock_or_handoff(). MUTEX_FLAG_HANDOFF exists to prevent new optimistic spinners from trying to hijack the lock from waiter all the time and potentially starving them but it is not necessary for MUTEX_FLAG_HANDOFF to be always set in presence of a waiter. If a blocked donor is deactivated when no owner is observed, it may not be woken up until it becomes the first waiter and is naturally woken up which breaks proxy in the interim. Wake up the blocked donor and allow it to grab the lock when no owner is observed. If the task manages to grab the lock, the block chain will follow at the next proxy migration. If the task fails to grab the lock, same situation is restored and everyone migrated to the CPU of new owner. Fixes: f13beb010e4a ("sched: Have try_to_wake_up() handle return-migration for PROXY_WAKING case") Signed-off-by: K Prateek Nayak --- XXX: Is there a better way to handle this? If we can confirm a owner in find_proxy_task(), we don't need to do a spurious wakeup of every task observing !owner. proxy_resched_idle() until owner appears in an option but it will spin until next owner appears. --- kernel/sched/core.c | 23 ++++++++++++++++++++--- 1 file changed, 20 insertions(+), 3 deletions(-) diff --git a/kernel/sched/core.c b/kernel/sched/core.c index 4cd69b08b415..9d9db7ccf01f 100644 --- a/kernel/sched/core.c +++ b/kernel/sched/core.c @@ -6809,6 +6809,19 @@ static inline void proxy_reacquire_rq_lock(struct rq *rq, struct rq_flags *rf) update_rq_clock(rq); } +static void +proxy_activate(struct rq *rq, struct rq_flags *rf, struct task_struct *p) + __must_hold(__rq_lockp(rq)) +{ + lockdep_assert_rq_held(rq); + proxy_resched_idle(rq); + proxy_release_rq_lock(rq, rf); + + wake_up_process(p); + + proxy_reacquire_rq_lock(rq, rf); +} + /* * If the blocked-on relationship crosses CPUs, migrate @p to the * owner's CPU. @@ -6934,14 +6947,15 @@ find_proxy_task(struct rq *rq, struct task_struct *donor, struct rq_flags *rf) /* * If there is no owner, either clear blocked_on * and return p (if it is current and safe to - * just run on this rq), or return-migrate the task. + * just run on this rq), or wake the task to try + * and grab the lock it is blocked on. */ __clear_task_blocked_on(p, NULL); - if (task_current(rq, p)) { + if (task_current(rq, p) || p->wake_cpu == task_cpu(p)) { p->is_blocked = 0; return p; } - goto deactivate; + goto activate; } if (!READ_ONCE(owner->on_rq) || owner->se.sched_delayed) { @@ -7029,6 +7043,9 @@ find_proxy_task(struct rq *rq, struct task_struct *donor, struct rq_flags *rf) } return owner; +activate: + proxy_activate(rq, rf, p); + return NULL; deactivate: proxy_deactivate(rq, p); return NULL; -- 2.34.1