From nobody Mon Jun 8 07:24:35 2026 Received: from galois.linutronix.de (Galois.linutronix.de [193.142.43.55]) (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 E331C481232; Thu, 4 Jun 2026 18:45:48 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=193.142.43.55 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1780598750; cv=none; b=AXFASBg4kjpK+JIyB+fEr7D5gRTVBXDkDdoYtKnFctcvpO9WaH+XKWkbkLXUwfDOyn9937uqEAFXvk31I42xdarbZwwIUQGzL6jhjzdfAXQsQ0E38HEgGXEA5bx5jeoHMSaW3iBwNzuUIPxf3D0ubsIfC+AKQiCflouTJuWGMzc= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1780598750; c=relaxed/simple; bh=JPk1xy/NNUqeaxzWfLQvuw71FAeE7BcAIJA5KheLVqc=; h=Date:From:To:Subject:Cc:In-Reply-To:References:MIME-Version: Message-ID:Content-Type; b=XERefqH+NllEup6FRSYMgPBZ1w9gM6PrvEBa8B7e3wcYS+L+J20NKeF2iuiWcWEQUCc+KQF9JahGaAy2Iyx75FYfsKV3WEZzEimQJz/7vSRZ7F/lhHDw4K/j50i4i2kpMG6lbyy0S4s3e+2eI4o6CcdzUVW1Gfh0dUC4Vr3F32U= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linutronix.de; spf=pass smtp.mailfrom=linutronix.de; dkim=pass (2048-bit key) header.d=linutronix.de header.i=@linutronix.de header.b=jkBksvUZ; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b=JAmrFoIZ; arc=none smtp.client-ip=193.142.43.55 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linutronix.de Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linutronix.de Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="jkBksvUZ"; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="JAmrFoIZ" Date: Thu, 04 Jun 2026 18:45:45 -0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1780598747; h=from:from:sender:sender:reply-to:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=rOYPl1rZk7mliy4Hmu7T36mCMOMN6DgMsMQWnAf0VoM=; b=jkBksvUZhn70gnjkLFCqV1stTG+8NAPRjX+l1QA9pG/j5E+pd93rAd40ZF1wU+bvyuQ+k/ gp7InP9wzvp+d19V89YkfpsZ5i8zn56e3SADYVtgqhmb9aK5zEbj4AEK2XCpCHNIKvm5oT bEsy2Aov8OM0xaFhcwbgAaXpUxRKzbbHhXontlCJpjY6JoYzdvBC7aX7csXYk1y6hjxRik 1tTKWLVj/e1+UZ/4nQA5ulkkYrn2yEse2FymlT4iYSFOhjFtXX9fV9/gvcC2OSzl2HEEkP ZL+JrLMQJdVagRw48ylZ95uD4r215K04eY61Z1+Hj+xkjOE5pBUaWTiL5KgdOg== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1780598747; h=from:from:sender:sender:reply-to:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=rOYPl1rZk7mliy4Hmu7T36mCMOMN6DgMsMQWnAf0VoM=; b=JAmrFoIZkLNLemNKQL5zX7oFmVAoujN03lPz/EQ+V0KIi7vuPviHsGi2kpJDy/Ef6DGEKK oxj3XEwEpWeisEAw== From: "tip-bot2 for John Stultz" Sender: tip-bot2@linutronix.de Reply-to: linux-kernel@vger.kernel.org To: linux-tip-commits@vger.kernel.org Subject: [tip: sched/core] sched: Add is_blocked task flag Cc: Vineeth Pillai , Peter Zijlstra , John Stultz , x86@kernel.org, linux-kernel@vger.kernel.org In-Reply-To: <20260512025635.2840817-7-jstultz@google.com> References: <20260512025635.2840817-7-jstultz@google.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-ID: <178059874581.710.18326867166918808568.tip-bot2@tip-bot2> Robot-ID: Robot-Unsubscribe: Contact to get blacklisted from these emails Precedence: bulk Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable The following commit has been merged into the sched/core branch of tip: Commit-ID: 4c2a20413d7fb3fc3dd7adf233a4f82bb203fb58 Gitweb: https://git.kernel.org/tip/4c2a20413d7fb3fc3dd7adf233a4f82bb= 203fb58 Author: John Stultz AuthorDate: Tue, 12 May 2026 02:56:16=20 Committer: Peter Zijlstra CommitterDate: Tue, 02 Jun 2026 12:26:07 +02:00 sched: Add is_blocked task flag Add a new is_blocked flag to the task struct. This flag is set by try_to_block_task() and cleared by ttwu_do_wakeup() and tracks if the task is blocked. Traditionally this would mirror !p->on_rq, however due things like DELAY_DEQUEUE and PROXY_EXEC, this can diverge, so its useful to manage separately. Additionally with this, we might be able to get rid of the p->se.sched_delayed (ab)use in the core code (eventually). Taken whole cloth from Peter's email: https://lore.kernel.org/lkml/20260501132143.GC1026330@noisy.programming.k= icks-ass.net/ With a few additional p->is_blocked =3D 0 in a few cases where we return current if blocked_on gets zeroed or there is no owner. This may hint that these current special cases might be dropped eventually. This change also helps resolve wait-queue stalls seen with proxy-execution. See previous patch attempts for details: https://lore.kernel.org/lkml/20260430215103.2978955-2-jstultz@google.com/ Reported-by: Vineeth Pillai Suggested-by: Peter Zijlstra Signed-off-by: John Stultz Signed-off-by: Peter Zijlstra (Intel) Link: https://patch.msgid.link/20260512025635.2840817-7-jstultz@google.com --- include/linux/sched.h | 7 +++++-- kernel/sched/core.c | 16 +++++++++++++++- 2 files changed, 20 insertions(+), 3 deletions(-) diff --git a/include/linux/sched.h b/include/linux/sched.h index 5dea5b1..ec17066 100644 --- a/include/linux/sched.h +++ b/include/linux/sched.h @@ -852,7 +852,11 @@ struct task_struct { struct alloc_tag *alloc_tag; #endif =20 - int on_cpu; + u8 on_cpu; + u8 on_rq; + u8 is_blocked; + u8 __pad; + struct __call_single_node wake_entry; unsigned int wakee_flips; unsigned long wakee_flip_decay_ts; @@ -867,7 +871,6 @@ struct task_struct { */ int recent_used_cpu; int wake_cpu; - int on_rq; =20 int prio; int static_prio; diff --git a/kernel/sched/core.c b/kernel/sched/core.c index 3f71dd9..c755286 100644 --- a/kernel/sched/core.c +++ b/kernel/sched/core.c @@ -624,6 +624,12 @@ int task_llc(const struct task_struct *p) * [ The astute reader will observe that it is possible for two tasks on= one * CPU to have ->on_cpu =3D 1 at the same time. ] * + * p->is_blocked <- { 0, 1 }: + * + * is set by try_to_block_task() and cleared by ttwu_do_wakeup() and tra= cks + * if the task is blocked. Traditionally this would mirror p->on_rq, how= ever + * due things like DELAY_DEQUEUE and PROXY_EXEC, this can diverge. + * * task_cpu(p): is changed by set_task_cpu(), the rules are: * * - Don't call set_task_cpu() on a blocked task: @@ -3719,6 +3725,7 @@ ttwu_stat(struct task_struct *p, int cpu, int wake_fl= ags) */ static inline void ttwu_do_wakeup(struct task_struct *p) { + p->is_blocked =3D 0; WRITE_ONCE(p->__state, TASK_RUNNING); trace_sched_wakeup(p); } @@ -4252,6 +4259,7 @@ int try_to_wake_up(struct task_struct *p, unsigned in= t state, int wake_flags) * it disabling IRQs (this allows not taking ->pi_lock). */ WARN_ON_ONCE(p->se.sched_delayed); + WARN_ON_ONCE(p->is_blocked); /* If p is current, we know we can run here, so clear blocked_on */ clear_task_blocked_on(p, NULL); if (!ttwu_state_match(p, state, &success)) @@ -4563,6 +4571,7 @@ static void __sched_fork(u64 clone_flags, struct task= _struct *p) =20 /* A delayed task cannot be in clone(). */ WARN_ON_ONCE(p->se.sched_delayed); + WARN_ON_ONCE(p->is_blocked); =20 #ifdef CONFIG_FAIR_GROUP_SCHED p->se.cfs_rq =3D NULL; @@ -6676,6 +6685,7 @@ static bool try_to_block_task(struct rq *rq, struct t= ask_struct *p, unsigned long task_state =3D *task_state_p; =20 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); @@ -6683,6 +6693,8 @@ static bool try_to_block_task(struct rq *rq, struct t= ask_struct *p, return false; } =20 + p->is_blocked =3D 1; + /* * We check should_block after signal_pending because we * will want to wake the task in that case. But if @@ -6843,6 +6855,7 @@ find_proxy_task(struct rq *rq, struct task_struct *do= nor, struct rq_flags *rf) /* if its PROXY_WAKING, do return migration or run if current */ if (mutex =3D=3D PROXY_WAKING) { if (task_current(rq, p)) { + p->is_blocked =3D 0; clear_task_blocked_on(p, PROXY_WAKING); return p; } @@ -6878,6 +6891,7 @@ find_proxy_task(struct rq *rq, struct task_struct *do= nor, struct rq_flags *rf) * just run on this rq), or return-migrate the task. */ if (task_current(rq, p)) { + p->is_blocked =3D 0; __clear_task_blocked_on(p, NULL); return p; } @@ -7111,7 +7125,7 @@ pick_again: clear_task_blocked_on(prev, NULL); =20 rq_set_donor(rq, next); - if (unlikely(next->blocked_on)) { + if (unlikely(next->is_blocked && next->blocked_on)) { next =3D find_proxy_task(rq, next, &rf); if (!next) { zap_balance_callbacks(rq);