From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from casper.infradead.org (casper.infradead.org [90.155.50.34]) (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 67B373DFC74 for ; Tue, 26 May 2026 11:37:25 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=90.155.50.34 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1779795447; cv=none; b=i6gJ99nZoy9liZexWr0WjcsE6HvT2uoqI/LQ2VOxPT3lBn/w/DJA9omEFOqDzhFL8CsgSuvirJuL0QFdKS26wRT2OfC7VBCELp+YKACbQ4krSTAXVME+RC18CkRj3DGCVOHIb57yuHHp6V55IoIz1QCcxHENK82xK/kYkPdhgwI= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1779795447; c=relaxed/simple; bh=fCJJ01fjSZEEk7/Fg1NK3j0USZux/yaTreO7mBAWO4Q=; h=Message-ID:Date:From:To:Cc:Cc:Cc:Cc:Cc:Cc:Cc:Cc:Cc:Cc:Cc:Cc:Cc:Cc: Cc:Cc:Cc:Cc:Cc:Cc:Cc:Cc:Cc:Subject:References:MIME-Version: Content-Type; b=JNZFehsOOx28j61uu2uO//rrKw+AAB/Vf4ti6qUWIfBu8AkaASkMhI+LIaZPwFR2xcodaG/q+jjZ4Gucg3uozf4CWKzPkadWaSxWKemuT1JTpHgFYWQC+G9PDSeU4iMJb8vusZ2bP1XtPgk2Xstapx4fbYzbgtQCMHmK/Wmj/i8= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=infradead.org; spf=none smtp.mailfrom=infradead.org; dkim=pass (2048-bit key) header.d=infradead.org header.i=@infradead.org header.b=fqZN2yiN; arc=none smtp.client-ip=90.155.50.34 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=infradead.org Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.mailfrom=infradead.org Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=infradead.org header.i=@infradead.org header.b="fqZN2yiN" DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=casper.20170209; h=Content-Type:MIME-Version:References: Subject:Cc:To:From:Date:Message-ID:Sender:Reply-To:Content-Transfer-Encoding: Content-ID:Content-Description:In-Reply-To; bh=njgKtX0JXS0a4LurnBb+fR3qGnZ4Ym+ZIPBMQl+gryI=; b=fqZN2yiNHKQ4lXyrr3cXKPgIAP Tk2xSh6cFeKqBM3HaLlrSOCqDnDNTjQ+xmrxHgsqNtdCHa/lozUPjYbpmeXEYtLOHMeJO2ZhU9Ao4 7FdrsmucTqflZ/wXR73mweDEZy5KfhxDbT/qLeKdjDipPutyNOFJFlr812IeFULHHPt0ECk7EnI13 ykGXd9yHYj0yzvOnXWskh+gq9rcjJ2q75ppnyj42Fx/RNgm5BE79pX4kucBo/7J6OK5Rq/uaBTPfB RKMV1vqYgikkYpdWXX0RzWL2eJKXm5mBFB7bBC8s1vFiOEy28qiMR5H8b2Cot0TdKjvezwRzHhqpM ogBM0rig==; Received: from 2001-1c00-8d85-4b00-266e-96ff-fe07-7dcc.cable.dynamic.v6.ziggo.nl ([2001:1c00:8d85:4b00:266e:96ff:fe07:7dcc] helo=noisy.programming.kicks-ass.net) by casper.infradead.org with esmtpsa (Exim 4.99.1 #2 (Red Hat Linux)) id 1wRq5y-00000000ziD-17LA; Tue, 26 May 2026 11:37:14 +0000 Received: by noisy.programming.kicks-ass.net (Postfix, from userid 0) id 1BC213022B1; Tue, 26 May 2026 13:37:13 +0200 (CEST) Message-ID: <20260526113322.596522894@infradead.org> User-Agent: quilt/0.68 Date: Tue, 26 May 2026 13:16:14 +0200 From: Peter Zijlstra To: John Stultz , K Prateek Nayak Cc: Joel Fernandes , "Peter Zijlstra (Intel)" Cc: Qais Yousef Cc: Ingo Molnar Cc: Juri Lelli Cc: Vincent Guittot Cc: Dietmar Eggemann Cc: Valentin Schneider Cc: Steven Rostedt Cc: Ben Segall Cc: Zimuzo Ezeozue Cc: Will Deacon Cc: Waiman Long Cc: Boqun Feng Cc: "Paul E. McKenney" Cc: Metin Kaya Cc: Xuewen Yan Cc: Thomas Gleixner Cc: Daniel Lezcano Cc: Suleiman Souhlal Cc: kuyo chang Cc: hupu Cc: linux-kernel@vger.kernel.org Cc: Mike Galbraith Subject: [PATCH 5/6] sched/proxy: Remove PROXY_WAKING References: <20260526111609.433880331@infradead.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 From: K Prateek Nayak Now that the proxy path uses ->is_blocked, use the '->is_blocked && !->blocked_on' state instead of PROXY_WAKING. Notably, this is where a blocked_on relation is broken but the donor task might still need a return migration. (Not-yet-)Signed-off-by: K Prateek Nayak Signed-off-by: Peter Zijlstra (Intel) --- include/linux/sched.h | 50 +--------------------------------------------- kernel/locking/mutex.c | 4 +-- kernel/locking/ww_mutex.h | 4 +-- kernel/sched/core.c | 13 ++++++++++- 4 files changed, 17 insertions(+), 54 deletions(-) --- a/include/linux/sched.h +++ b/include/linux/sched.h @@ -2202,19 +2202,10 @@ extern int __cond_resched_rwlock_write(r #ifndef CONFIG_PREEMPT_RT -/* - * With proxy exec, if a task has been proxy-migrated, it may be a donor - * on a cpu that it can't actually run on. Thus we need a special state - * to denote that the task is being woken, but that it needs to be - * evaluated for return-migration before it is run. So if the task is - * blocked_on PROXY_WAKING, return migrate it before running it. - */ -#define PROXY_WAKING ((struct mutex *)(-1L)) - static inline struct mutex *__get_task_blocked_on(struct task_struct *p) { lockdep_assert_held_once(&p->blocked_lock); - return p->blocked_on == PROXY_WAKING ? NULL : p->blocked_on; + return p->blocked_on; } static inline void __set_task_blocked_on(struct task_struct *p, struct mutex *m) @@ -2242,7 +2233,7 @@ static inline void __clear_task_blocked_ * blocked_on relationships, but make sure we are not * clearing the relationship with a different lock. */ - WARN_ON_ONCE(m && p->blocked_on && p->blocked_on != m && p->blocked_on != PROXY_WAKING); + WARN_ON_ONCE(m && p->blocked_on && p->blocked_on != m); p->blocked_on = NULL; } @@ -2251,35 +2242,6 @@ static inline void clear_task_blocked_on guard(raw_spinlock_irqsave)(&p->blocked_lock); __clear_task_blocked_on(p, m); } - -static inline void __set_task_blocked_on_waking(struct task_struct *p, struct mutex *m) -{ - /* Currently we serialize blocked_on under the task::blocked_lock */ - lockdep_assert_held_once(&p->blocked_lock); - - if (!sched_proxy_exec()) { - __clear_task_blocked_on(p, m); - return; - } - - /* Don't set PROXY_WAKING if blocked_on was already cleared */ - if (!p->blocked_on) - return; - /* - * There may be cases where we set PROXY_WAKING on tasks that were - * already set to waking, but make sure we are not changing - * the relationship with a different lock. - */ - WARN_ON_ONCE(m && p->blocked_on != m && p->blocked_on != PROXY_WAKING); - p->blocked_on = PROXY_WAKING; -} - -static inline void set_task_blocked_on_waking(struct task_struct *p, struct mutex *m) -{ - guard(raw_spinlock_irqsave)(&p->blocked_lock); - __set_task_blocked_on_waking(p, m); -} - #else static inline void __clear_task_blocked_on(struct task_struct *p, struct rt_mutex *m) { @@ -2288,14 +2250,6 @@ static inline void __clear_task_blocked_ static inline void clear_task_blocked_on(struct task_struct *p, struct rt_mutex *m) { } - -static inline void __set_task_blocked_on_waking(struct task_struct *p, struct rt_mutex *m) -{ -} - -static inline void set_task_blocked_on_waking(struct task_struct *p, struct rt_mutex *m) -{ -} #endif /* !CONFIG_PREEMPT_RT */ static __always_inline bool need_resched(void) --- a/kernel/locking/mutex.c +++ b/kernel/locking/mutex.c @@ -1043,7 +1043,7 @@ static noinline void __sched __mutex_unl next_lock = __get_task_blocked_on(donor); if (next_lock == lock) { next = get_task_struct(donor); - __set_task_blocked_on_waking(donor, next_lock); + __clear_task_blocked_on(next, lock); current->blocked_donor = NULL; } raw_spin_unlock(&donor->blocked_lock); @@ -1059,7 +1059,7 @@ static noinline void __sched __mutex_unl raw_spin_lock_nested(&next->blocked_lock, SINGLE_DEPTH_NESTING); debug_mutex_wake_waiter(lock, waiter); - __set_task_blocked_on_waking(next, lock); + __clear_task_blocked_on(next, lock); raw_spin_unlock(&next->blocked_lock); } --- a/kernel/locking/ww_mutex.h +++ b/kernel/locking/ww_mutex.h @@ -324,7 +324,7 @@ __ww_mutex_die(struct MUTEX *lock, struc * blocked_on to PROXY_WAKING. Otherwise we can see * circular blocked_on relationships that can't resolve. */ - set_task_blocked_on_waking(waiter->task, lock); + clear_task_blocked_on(waiter->task, lock); wake_q_add(wake_q, waiter->task); } @@ -383,7 +383,7 @@ static bool __ww_mutex_wound(struct MUTE * are waking the mutex owner, who may be currently * blocked on a different mutex. */ - set_task_blocked_on_waking(owner, NULL); + clear_task_blocked_on(owner, NULL); wake_q_add(wake_q, owner); } return true; --- a/kernel/sched/core.c +++ b/kernel/sched/core.c @@ -6856,7 +6865,7 @@ find_proxy_task(struct rq *rq, struct ta for (p = donor; p->is_blocked; p = owner) { /* if its PROXY_WAKING, do return migration or run if current */ struct mutex *mutex = p->blocked_on; - if (!mutex || mutex == PROXY_WAKING) { + if (!mutex) { clear_task_blocked_on(p, mutex); if (task_current(rq, p)) { p->is_blocked = 0;