From nobody Mon Jun 8 21:46:13 2026 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 67A9F3DEFF5 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=M77hvX19qTMPZ/RN8I+GbJKxeS73YL5OeISHPzxXayorY61fHbl+kez9C+hxNCoDjwiahgegUaB3H1n3dsKxdNt6vbvcoSMaYxgxq3ev+E51fn/uQAdwbfuuf9IWg5CebyB7LxF3HCA6y6yxwazVTjgEpmntXzqxpU4DyZCYiD4= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1779795447; c=relaxed/simple; bh=sFwr926G2kZRY6EdIxnYvkB9SXokQ2O/b3RMZy4ayH8=; 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=isGooa4h0cCBXsf04qT5pgPRqeAnsKWKkxcR35tDug1NfxXwJPIj5bsI7bY7f1/FUPuHOKXZVlioyU8RgNVZLMlyxVH+2rPdAu6fzUFiFYBKkrTc0LrY7E6XGvtdtIXkSSRze9lONwxngnMyldp0JFCM8nhRDDV5dSH9qmktEZw= 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=it9sysgm; 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="it9sysgm" 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=FBbI84bIZ3XgIkk4RD6nwPQBjp6JKindKKOMk9s6xQ0=; b=it9sysgmcF6pSStN6LLxbBbMJ7 9aMBpWV51vWoqiWYxqZtfhjIBOvjKMhxV4WRZXs710RqamR1ImlqjoxcD3sGNL0EGpI9OFj5x4cGS zk+gR3zx6EzFL5je7QYqSFK+oIwzDwRFnI2Wy/o7dqHseBnkVEYbWdMZUCsrhxW3/gPTU+sQ3U6u0 eObaUMEU6HnXP2gxPtf2i/xxlzB6Xqwk9BT696I0paRkJzH0exNDGzgxcylTpBb+276zGNz81W4D1 SOCExAONb8+nV+SzpAd+3lD8u3p59F3ukMYwGOY9m9O/SUsz9dNedEaWXMSrcPdVd+cEbXw94DBHt YgJlxxaQ==; 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 1wRq5x-00000000zi5-2Sjw; Tue, 26 May 2026 11:37:13 +0000 Received: by noisy.programming.kicks-ass.net (Postfix, from userid 0) id 09995300324; Tue, 26 May 2026 13:37:13 +0200 (CEST) Message-ID: <20260526113322.120970670@infradead.org> User-Agent: quilt/0.68 Date: Tue, 26 May 2026 13:16:10 +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 1/6] sched/proxy: Remove superfluous clear_task_blocked_in() 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-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Per the discussion here: https://lore.kernel.org/all/20260403112810.GG3738786@noisy.programming.ki= cks-ass.net/ The reason for this condition is that the signal condition in try_to_block_task() would set_task_blocked_in_waking(). However, it no long= er does that, in fact, that path does clear_task_blocked_on(), rendering the clause under discussion moot. Signed-off-by: Peter Zijlstra (Intel) Acked-by: John Stultz --- kernel/sched/core.c | 3 --- 1 file changed, 3 deletions(-) --- a/kernel/sched/core.c +++ b/kernel/sched/core.c @@ -7132,9 +7132,6 @@ static void __sched notrace __schedule(i if (sched_proxy_exec()) { struct task_struct *prev_donor =3D rq->donor; =20 - if (!prev_state && prev->blocked_on) - clear_task_blocked_on(prev, NULL); - rq_set_donor(rq, next); next->blocked_donor =3D NULL; if (unlikely(next->is_blocked && next->blocked_on)) { From nobody Mon Jun 8 21:46:13 2026 Received: from desiato.infradead.org (desiato.infradead.org [90.155.92.199]) (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 02CD43DDDB8 for ; Tue, 26 May 2026 11:37:24 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=90.155.92.199 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1779795447; cv=none; b=EEvIitobqFlBhEc+XtUs6exBVmFmv+cZKO9kdH3fkiY7e/XyVQ+K3G2MyqP6ODkXo3M5Dr+M2UqDcsfgTDyorpJPms+qgeGMnKp0lMgM+nDd0aAJcV9tjjLvGlIJKecJslTz5Z/f18us9GOzAvWHVJOe+dUcuXGkIW4x3LZDQcU= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1779795447; c=relaxed/simple; bh=PrjevSyCvNXxyiReU5H3J2AR5Ni8E3451UTF7j50pmE=; 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=RtH92QQEsaiVsDj6/ceqmICAmK9xh457BblVkpX4OZOc0+osL3LBEuqkHxL9M8cE2XFvBHXMmnEpUpKhzo140xZeic4A5iKmTDktk1LCui7PG/MLm8tawOJO81nk2AXx8sUGcmZIeULwUqZh1BQp3XDMXfrjeuiQ5v7PYsI9EbE= 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=I0o0r8vy; arc=none smtp.client-ip=90.155.92.199 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="I0o0r8vy" DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=desiato.20200630; 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=hDglwFJtxmRrj8+nl5xh4Ii8hHU2oa8XDGgtdiuxWn0=; b=I0o0r8vyIHVzs5V5/sTf/11VIK iFbz3HIg4rcUtJ8hCRQqYuL52IHaUpddXU4dKZlJHCGFynrcIToFLZCcGzy4WE24DFqQLVHUgiGvH SmfC/xiFZfvNq9PUvN3hjngz4dVJzGcBUKZi4ndWNSNfeb9WqQTu35JERlxdT+YQLXpMJGYuMRJs+ F5Yyjw0SxwoULOefHi5CKP79dCP+FyV1heERl7/OkU6O+IW3dBtv4592PuMDEZ7o12fiEDFaRy50g tqnvdqu4Vaz6QVR3MlHc3wZRvVzRpuXTV5Bib1ZO5FNjEitkq4fHa1dU0WN9IAxyfRwctXWpoqrA+ n2a1O9UQ==; 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 desiato.infradead.org with esmtpsa (Exim 4.99.1 #2 (Red Hat Linux)) id 1wRq5x-0000000B6hS-3r8U; Tue, 26 May 2026 11:37:14 +0000 Received: by noisy.programming.kicks-ass.net (Postfix, from userid 0) id 0E1D53006DD; Tue, 26 May 2026 13:37:13 +0200 (CEST) Message-ID: <20260526113322.244729903@infradead.org> User-Agent: quilt/0.68 Date: Tue, 26 May 2026 13:16:11 +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 2/6] sched/proxy: Optimize try_to_wake_up() 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-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" The reason for the clause in try_to_wake_up() is, per its comment, that find_proxy_task()'s proxy_deactivate() is not always called with a cleared p->blocked_on. However, that seems silly and easily cured. Make sure to always call proxy_deactivate() with a cleared p->blocked_on such that we might remove t= his clause from the common wake-up path. Signed-off-by: Peter Zijlstra (Intel) Acked-by: John Stultz --- kernel/sched/core.c | 14 ++++---------- 1 file changed, 4 insertions(+), 10 deletions(-) --- a/kernel/sched/core.c +++ b/kernel/sched/core.c @@ -4344,14 +4344,6 @@ int try_to_wake_up(struct task_struct *p WRITE_ONCE(p->__state, TASK_WAKING); =20 /* - * We never clear the blocked_on relation on proxy_deactivate. - * If we don't clear it here, we have TASK_RUNNING + p->blocked_on - * when waking up. Since this is a fully blocked, off CPU task - * waking up, it should be safe to clear the blocked_on relation. - */ - if (task_is_blocked(p)) - clear_task_blocked_on(p, NULL); - /* * If the owning (remote) CPU is still in the middle of schedule() with * this task as prev, considering queueing p on the remote CPUs wake_list * which potentially sends an IPI instead of spinning on p->on_cpu to @@ -6739,6 +6731,7 @@ static void proxy_deactivate(struct rq * unsigned long state =3D READ_ONCE(donor->__state); =20 WARN_ON_ONCE(state =3D=3D TASK_RUNNING); + WARN_ON_ONCE(donor->blocked_on); /* * Because we got donor from pick_next_task(), it is *crucial* * that we call proxy_resched_idle() before we deactivate it. @@ -6864,9 +6857,9 @@ find_proxy_task(struct rq *rq, struct ta for (p =3D donor; (mutex =3D p->blocked_on); p =3D owner) { /* if its PROXY_WAKING, do return migration or run if current */ if (mutex =3D=3D PROXY_WAKING) { + clear_task_blocked_on(p, PROXY_WAKING); if (task_current(rq, p)) { p->is_blocked =3D 0; - clear_task_blocked_on(p, PROXY_WAKING); return p; } goto deactivate; @@ -6900,9 +6893,9 @@ find_proxy_task(struct rq *rq, struct ta * and return p (if it is current and safe to * just run on this rq), or return-migrate the task. */ + __clear_task_blocked_on(p, NULL); if (task_current(rq, p)) { p->is_blocked =3D 0; - __clear_task_blocked_on(p, NULL); return p; } goto deactivate; @@ -6912,6 +6905,7 @@ find_proxy_task(struct rq *rq, struct ta /* XXX Don't handle blocked owners/delayed dequeue yet */ if (curr_in_chain) return proxy_resched_idle(rq); + __clear_task_blocked_on(p, NULL); goto deactivate; } From nobody Mon Jun 8 21:46:13 2026 Received: from desiato.infradead.org (desiato.infradead.org [90.155.92.199]) (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 4F9FD3DE43D for ; Tue, 26 May 2026 11:37:25 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=90.155.92.199 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1779795450; cv=none; b=QNPjbo3heyxEj/5Cy3wsETNDfaA2zVsnY/THsOzduJIOr94ifFx2PBfzLnok8ZhJYIvuJ5Cf1ozJzpCh8ApU1fXkY/PFZo4lG5xlY6wl2AZBv+cFgWP0Gz4bgOgVHvDa+rqBBG62dzEInuvPNNcXX25b2f4BL62ahQnJgUfQo+M= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1779795450; c=relaxed/simple; bh=tau4FSth8sgMFh0UrOnpIuIpqklAnd9eIaPrhRTo69E=; 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=UlJFgZJWhopg57SNK/aGro6s6Mtfvk3GyQrR8PHXl4En3qlCPyq+zY9+KoDIxVWAmClM2xFwKJmkFcks4WRIrIDUo+hyH6M1JsflrNrYFrvRCOXM3ICtYzlYSrYqegCytPccTpOUTk7YkqrdbjV5/69SBOySIShFP/iAfkxNe/A= 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=J2QzXWah; arc=none smtp.client-ip=90.155.92.199 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="J2QzXWah" DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=desiato.20200630; 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=wGN1IyFUzbOpWlJeTtIkgrO+8lsk4Jnkxv4B2FoNGlw=; b=J2QzXWahEmKbAqjJF2E1jn3p+e zj5jSZxE6kGuFHoaz2HxzIwhlSiMjA3RmNM9IyoSOIdgkR8egluCNaTSKamcWU4KlmA6qKqyEZzSo sSBgENfyfWed9xQPuWaFrndicz2JtCh98R0BhjWWdGLYI/4fk5+pKnUNDiSw+J7eBchkbGQFa7CSk w/V5jRCAJiMNPGV1U3zIfNrt6CDs2uYR/ljfyJCUD5AACwbJxrDQp2zEmR1tUus3HklTO2JAMVn8k NTgLlBkk0XcjmuAAJvVZl9XL5gW7AnCSX8yidrtGO5/Q0DjgdGOZ3cpUaXrtBTTtkPuRRZ5otuvNu j4R3rFHA==; Received: from 77-249-17-252.cable.dynamic.v4.ziggo.nl ([77.249.17.252] helo=noisy.programming.kicks-ass.net) by desiato.infradead.org with esmtpsa (Exim 4.99.1 #2 (Red Hat Linux)) id 1wRq5x-0000000B6hT-3wVc; Tue, 26 May 2026 11:37:14 +0000 Received: by noisy.programming.kicks-ass.net (Postfix, from userid 0) id 12606301CEB; Tue, 26 May 2026 13:37:13 +0200 (CEST) Message-ID: <20260526113322.364017314@infradead.org> User-Agent: quilt/0.68 Date: Tue, 26 May 2026 13:16:12 +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 3/6] sched: Be more strict about p->is_blocked 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-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Upon entry to try_to_block_task(), p->is_blocked should be false. After all, the prior wakeup would have made it so per ttwu_do_wakeup(). Ensure this is the case, rather than clearing it in the path that doesn't s= et it. Signed-off-by: Peter Zijlstra (Intel) Acked-by: John Stultz --- kernel/sched/core.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) --- a/kernel/sched/core.c +++ b/kernel/sched/core.c @@ -6676,8 +6676,9 @@ static bool try_to_block_task(struct rq { unsigned long task_state =3D *task_state_p; =20 + WARN_ON_ONCE(p->is_blocked); + if (signal_pending_state(task_state, p)) { - p->is_blocked =3D 0; WRITE_ONCE(p->__state, TASK_RUNNING); *task_state_p =3D TASK_RUNNING; clear_task_blocked_on(p, NULL); From nobody Mon Jun 8 21:46:13 2026 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 67BE63DFC84 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=dTonekRlSLDXM0TaDd8wi9RJ9JDTJa8maXHnfcqkfqQZbGrFcJ7P3C5673uJjHHXFIr/0KkWfLZhXK2PabkNET48fnTryy1RswM1x4A1x67ew1oYFdROvuUFIo1uR9dYuZb1WLkbjyhvWmO/+yxKqcF5f2IO+YZvl90Osk90jZ4= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1779795447; c=relaxed/simple; bh=Ci6yzyeBfrcI6SbqaiZYB0Qsdedi68rUiGEC981kXtM=; 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=L+JW93KV9Uvg+S85UqfPuwKVF1zbqEKyjj8XyGRKShRfjq358ad8vc4DM8vQMkrKbMcfIA0fxjyS2o0+blzma4Urul27ah+xYWVpHr4iLzeuOJxxkrfRydoELS8JNx6l7mdBvZmLV3Wwed4soJvyRQ6XjyUeODJ63FW+WTWnOP8= 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=hSfYbSv1; 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="hSfYbSv1" 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=/a38ZgPvmYx1A7rtj81dUcD2A1xa40OuuyNZ8tu3y0Q=; b=hSfYbSv1IsbseHpM3NxOBecx+j +1hOIZzEsdOSaBlrzx3VySByU71FOrpW4FsYCNgZ/BC26/R6KkaWGXFpsWS3GDmPfdwAdd6Sj4u1M tiJp4Lo33iIl3hXDNC8tYGmGn8tww0hHPixKi2KB9UcXv7ali3t9xk/7zDOL7BjVPT5bS6KbvmTym /4HlWQFLZe3UEpPRGoF9kc76xf1MOVjJjoFYRJgHVtGFHQNAPQz9pT7mUbG8diaVrjlpQcAgGhiMJ 2lWBxo/pa17AY/XwlTQI3GwJXdZRb8c/r4i3fKfdkxA4Ta5ZFcb8u/7f6XVtlAdt1u68Ke91S6qSg DJ9Uvn7g==; Received: from 77-249-17-252.cable.dynamic.v4.ziggo.nl ([77.249.17.252] helo=noisy.programming.kicks-ass.net) by casper.infradead.org with esmtpsa (Exim 4.99.1 #2 (Red Hat Linux)) id 1wRq5x-00000000zi7-24DO; Tue, 26 May 2026 11:37:13 +0000 Received: by noisy.programming.kicks-ass.net (Postfix, from userid 0) id 16E8930217C; Tue, 26 May 2026 13:37:13 +0200 (CEST) Message-ID: <20260526113322.477954312@infradead.org> User-Agent: quilt/0.68 Date: Tue, 26 May 2026 13:16:13 +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 4/6] sched/proxy: Switch proxy to use p->is_blocked 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-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Rather than gate the proxy paths with p->blocked_on, use p->is_blocked. This opens up the state: '->is_blocked && !->blocked_on' for future use. Notably, only proxy and delayed tasks can be ->on_rq && ->is_blocked, and i= t is guaranteed that sched_class::pick_task() will never return a delayed task. Therefore any task returned from pick_next_task() that has ->is_blocked set, must be a proxy task. XXX: ttwu_runnable(): AFAICT this results in all delayed tasks getting bloc= ked and send down the long wakeup-path -- and while there were some plans there [*], that was especially careful to not take all those locks. [*] https://lore.kernel.org/r/20250702114924.091581796@infradead.org Suggested-by: K Prateek Nayak Signed-off-by: Peter Zijlstra (Intel) --- kernel/sched/core.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) --- a/kernel/sched/core.c +++ b/kernel/sched/core.c @@ -3764,7 +3764,7 @@ static inline void proxy_reset_donor(str */ static inline bool proxy_needs_return(struct rq *rq, struct task_struct *p) { - if (!task_is_blocked(p)) + if (!p->is_blocked) return false; =20 scoped_guard(raw_spinlock, &p->blocked_lock) { @@ -6850,14 +6850,14 @@ find_proxy_task(struct rq *rq, struct ta bool curr_in_chain =3D false; int this_cpu =3D cpu_of(rq); struct task_struct *p; - struct mutex *mutex; int owner_cpu; =20 /* Follow blocked_on chain. */ - for (p =3D donor; (mutex =3D p->blocked_on); p =3D owner) { + for (p =3D donor; p->is_blocked; p =3D owner) { /* if its PROXY_WAKING, do return migration or run if current */ - if (mutex =3D=3D PROXY_WAKING) { - clear_task_blocked_on(p, PROXY_WAKING); + struct mutex *mutex =3D p->blocked_on; + if (!mutex || mutex =3D=3D PROXY_WAKING) { + clear_task_blocked_on(p, mutex); if (task_current(rq, p)) { p->is_blocked =3D 0; return p; @@ -7128,7 +7128,7 @@ static void __sched notrace __schedule(i =20 rq_set_donor(rq, next); next->blocked_donor =3D NULL; - if (unlikely(next->is_blocked && next->blocked_on)) { + if (unlikely(next->is_blocked)) { next =3D find_proxy_task(rq, next, &rf); if (!next) { zap_balance_callbacks(rq); From nobody Mon Jun 8 21:46:13 2026 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-Transfer-Encoding: quoted-printable 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 =20 #ifndef CONFIG_PREEMPT_RT =20 -/* - * 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 =3D=3D PROXY_WAKING ? NULL : p->blocked_on; + return p->blocked_on; } =20 static inline void __set_task_blocked_on(struct task_struct *p, struct mut= ex *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 !=3D m && p->blocked_on = !=3D PROXY_WAKING); + WARN_ON_ONCE(m && p->blocked_on && p->blocked_on !=3D m); p->blocked_on =3D NULL; } =20 @@ -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, str= uct 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 !=3D m && p->blocked_on !=3D PROXY_WAKING= ); - p->blocked_on =3D PROXY_WAKING; -} - -static inline void set_task_blocked_on_waking(struct task_struct *p, struc= t 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 r= t_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, str= uct rt_mutex *m) -{ -} - -static inline void set_task_blocked_on_waking(struct task_struct *p, struc= t rt_mutex *m) -{ -} #endif /* !CONFIG_PREEMPT_RT */ =20 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 =3D __get_task_blocked_on(donor); if (next_lock =3D=3D lock) { next =3D get_task_struct(donor); - __set_task_blocked_on_waking(donor, next_lock); + __clear_task_blocked_on(next, lock); current->blocked_donor =3D NULL; } raw_spin_unlock(&donor->blocked_lock); @@ -1059,7 +1059,7 @@ static noinline void __sched __mutex_unl =20 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); =20 } --- 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); } =20 @@ -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 =3D donor; p->is_blocked; p =3D owner) { /* if its PROXY_WAKING, do return migration or run if current */ struct mutex *mutex =3D p->blocked_on; - if (!mutex || mutex =3D=3D PROXY_WAKING) { + if (!mutex) { clear_task_blocked_on(p, mutex); if (task_current(rq, p)) { p->is_blocked =3D 0; From nobody Mon Jun 8 21:46:13 2026 Received: from desiato.infradead.org (desiato.infradead.org [90.155.92.199]) (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 257243E0758 for ; Tue, 26 May 2026 11:37:26 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=90.155.92.199 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1779795448; cv=none; b=Ew728JGMp2HU0wjW8gE2rWyCyrk9grNb6VcbYZ2vof6pcOwBrez2s30rTnMu9/NIS2OP6b1u9MEgDVqnEs9R+GdRgLuDAApiOX5EOMdYY2WzLl4Xa2bf+0CfIX1mellyVlezvMouZfkMWzQtydK82L/WpoPpil8WhpxGp6kxOPc= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1779795448; c=relaxed/simple; bh=r44Xt/7xL671+y/eS2DTdtMXXiwkQThd7EGnPtefZe8=; 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=ryGUDL5PfLCKkoC7q5M9yMmfBK/huERHL8rDZnuVIRsee7R0ZhYzjfq7l26hNiaF3Lt4k/47hywu2QB52xT8xwTVwt5/BRr/KOcGHjvCBuri+VYZ2DSHSJ9Q1La6NNERiwOnThoED36dpqTXogeeJckm1uXmfeA+/kZ9JGbnU9o= 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=eUX5GVcs; arc=none smtp.client-ip=90.155.92.199 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="eUX5GVcs" DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=desiato.20200630; 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=m87+WvYfaiN9KLfknSWGtPMTqpIsdP2+5lbxqYEJyQU=; b=eUX5GVcsGp158OuAgOEz2iTZQ7 xXjZLM2g4X9lbcygQ6mz3gtS2iTEXHuwbBjol4P1ZR/h0QRwmU4uRwODlIfcqtm1MymrNWmGXj+OU x2iaBWXqxhsuPjHUVe4rksU3x8EKZPlwZJUqnWJK0guPppJ17H5MTz+91CFV49dAZY5L5Ch7mv5AT he4/C/oyserJ+kTpbEIEPeS2D/ieq8OTK97zDZr7zz297gzP5SYIMqiungnYBf00LyOCfeFSPU3Zn W//hTZ9zwsVQHw4Av82J/3bd1/4MRU0MvnL3091CW/yANvOzaev/3MVDkohUPj4h64Im8rRG3d5ho d4dgldBA==; Received: from 77-249-17-252.cable.dynamic.v4.ziggo.nl ([77.249.17.252] helo=noisy.programming.kicks-ass.net) by desiato.infradead.org with esmtpsa (Exim 4.99.1 #2 (Red Hat Linux)) id 1wRq5y-0000000B6hV-00j1; Tue, 26 May 2026 11:37:14 +0000 Received: by noisy.programming.kicks-ass.net (Postfix, from userid 0) id 1FF5A302813; Tue, 26 May 2026 13:37:13 +0200 (CEST) Message-ID: <20260526113322.714832584@infradead.org> User-Agent: quilt/0.68 Date: Tue, 26 May 2026 13:16:15 +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 6/6] sched: Simplify ttwu_runnable() 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-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Note that both proxy and delayed tasks have ->is_blocked set. Use this one condition to guard both paths. Signed-off-by: Peter Zijlstra (Intel) --- kernel/sched/core.c | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) --- a/kernel/sched/core.c +++ b/kernel/sched/core.c @@ -3764,9 +3764,6 @@ static inline void proxy_reset_donor(str */ static inline bool proxy_needs_return(struct rq *rq, struct task_struct *p) { - if (!p->is_blocked) - return false; - scoped_guard(raw_spinlock, &p->blocked_lock) { /* Task is waking up; clear any blocked_on relationship */ __clear_task_blocked_on(p, NULL); @@ -3860,10 +3857,12 @@ static int ttwu_runnable(struct task_str return 0; =20 update_rq_clock(rq); - if (p->se.sched_delayed) - enqueue_task(rq, p, ENQUEUE_NOCLOCK | ENQUEUE_DELAYED); - if (proxy_needs_return(rq, p)) - return 0; + if (p->is_blocked) { + if (p->se.sched_delayed) + enqueue_task(rq, p, ENQUEUE_NOCLOCK | ENQUEUE_DELAYED); + if (proxy_needs_return(rq, p)) + return 0; + } if (!task_on_cpu(rq, p)) { /* * When on_rq && !on_cpu the task is preempted, see if