From nobody Mon Jun 8 07:24:44 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 58D163C4171; Thu, 4 Jun 2026 18:45:51 +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=1780598752; cv=none; b=PPTPCn0Y6o6GmDPFll53rI8zdajYEzUkqEJCrN1EmMXQhSOFCaGNEZVTk/Y67BTqqvkKiUqJ3iaeYH7g+zbPTroZe9bVSkRF+D17sO+/JmortC0bl91PxqLgosemO5H7MlXfg3bfSNfzNwf2XhZ2U+cnV/0YfvYYWoqs5rTnD6c= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1780598752; c=relaxed/simple; bh=XZzQPyAde90lnwUnT+/mM4nzr5PNqTLx5VlFhl6NhLg=; h=Date:From:To:Subject:Cc:In-Reply-To:References:MIME-Version: Message-ID:Content-Type; b=YgUYs67hlC3sN7cqy6mwqVDs1mtNKo+QjXOrZ/AkJpBYkgjcCXGu0nDnZXQJZXVpQyZ0N2qD5i+VxPnjHKaZ4gns3SgIicemnM/WpajsRNdUd7vsq8xcQ7i4LCCNUhYvLFVwxqafMDLSvptfc97uNH07IUXHMDIycrS/oVSqBDg= 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=EmZJXNTS; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b=pnuDqS6c; 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="EmZJXNTS"; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="pnuDqS6c" Date: Thu, 04 Jun 2026 18:45:48 -0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1780598749; 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=pJx0eouf85NBjL7CPJctCoi/Tmlddz9lSZeCQ5E+qpQ=; b=EmZJXNTS/3agQY7tpdyv65KtVZ7Y/0uaamiYx8w587vYfZnSXorwuUMzYcbesNY7rSuQb+ 4IRj36qBYcJXsTCX2XXhXSXz1zhHUpeP4h8kZ9kNAkHbyhNky/zRO6/uFIQ0cGeYmN2Of2 Lg1xC9HPcvCgCSI+P/SEywx0oIayhn7sP7yo/EArxSgfiZJSGMFl2ehZQQsLkjEufOGhmf OPr0LV79MyJl5zI1DuQqHQb2pWS0BsNrqfq6TVVhNcc5UdvW5BuLAagCqdHtO4RM0el7En qni99keejTryVhfrJl9BgEoqxB7i3vy1GtUATkkT/zZ90LMnmm3XaVa8xW78HA== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1780598749; 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=pJx0eouf85NBjL7CPJctCoi/Tmlddz9lSZeCQ5E+qpQ=; b=pnuDqS6cn0QAntkIUQLDHk/JINT3kE4tOaTMtfVasFA5y4IuiVIIx797E9RsBj1pWeUSd9 mih3QbdWF2++WiDw== 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: Rework block_task so it can be directly called Cc: Peter Zijlstra , John Stultz , x86@kernel.org, linux-kernel@vger.kernel.org In-Reply-To: <20260512025635.2840817-5-jstultz@google.com> References: <20260512025635.2840817-5-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: <178059874846.710.9474562652450493070.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: f0c1ecde6447079505f1d4557d30401136218ae0 Gitweb: https://git.kernel.org/tip/f0c1ecde6447079505f1d4557d3040113= 6218ae0 Author: John Stultz AuthorDate: Tue, 12 May 2026 02:56:14=20 Committer: Peter Zijlstra CommitterDate: Tue, 02 Jun 2026 12:26:06 +02:00 sched: Rework block_task so it can be directly called Pull most of the logic out of try_to_block_task() and put it into block_task() directly, so that we can call block_task() and not have to worry about the failing cases in try_to_block_task() Suggested-by: Peter Zijlstra Signed-off-by: John Stultz Signed-off-by: Peter Zijlstra (Intel) Link: https://patch.msgid.link/20260512025635.2840817-5-jstultz@google.com --- kernel/sched/core.c | 45 ++++++++++++++++++++++---------------------- 1 file changed, 23 insertions(+), 22 deletions(-) diff --git a/kernel/sched/core.c b/kernel/sched/core.c index a9c9b89..2f1e85d 100644 --- a/kernel/sched/core.c +++ b/kernel/sched/core.c @@ -2236,8 +2236,29 @@ void deactivate_task(struct rq *rq, struct task_stru= ct *p, int flags) dequeue_task(rq, p, flags); } =20 -static void block_task(struct rq *rq, struct task_struct *p, int flags) +static void block_task(struct rq *rq, struct task_struct *p, unsigned long= task_state) { + int flags =3D DEQUEUE_NOCLOCK; + + p->sched_contributes_to_load =3D + (task_state & TASK_UNINTERRUPTIBLE) && + !(task_state & TASK_NOLOAD) && + !(task_state & TASK_FROZEN); + + if (unlikely(is_special_task_state(task_state))) + flags |=3D DEQUEUE_SPECIAL; + + /* + * __schedule() ttwu() + * prev_state =3D prev->state; if (p->on_rq && ...) + * if (prev_state) goto out; + * p->on_rq =3D 0; smp_acquire__after_ctrl_dep(); + * p->state =3D TASK_WAKING + * + * Where __schedule() and ttwu() have matching control dependencies. + * + * After this, schedule() must not care about p->state any more. + */ if (dequeue_task(rq, p, DEQUEUE_SLEEP | flags)) __block_task(rq, p); } @@ -6587,7 +6608,6 @@ static bool try_to_block_task(struct rq *rq, struct t= ask_struct *p, unsigned long *task_state_p, bool should_block) { unsigned long task_state =3D *task_state_p; - int flags =3D DEQUEUE_NOCLOCK; =20 if (signal_pending_state(task_state, p)) { WRITE_ONCE(p->__state, TASK_RUNNING); @@ -6607,26 +6627,7 @@ static bool try_to_block_task(struct rq *rq, struct = task_struct *p, if (!should_block) return false; =20 - p->sched_contributes_to_load =3D - (task_state & TASK_UNINTERRUPTIBLE) && - !(task_state & TASK_NOLOAD) && - !(task_state & TASK_FROZEN); - - if (unlikely(is_special_task_state(task_state))) - flags |=3D DEQUEUE_SPECIAL; - - /* - * __schedule() ttwu() - * prev_state =3D prev->state; if (p->on_rq && ...) - * if (prev_state) goto out; - * p->on_rq =3D 0; smp_acquire__after_ctrl_dep(); - * p->state =3D TASK_WAKING - * - * Where __schedule() and ttwu() have matching control dependencies. - * - * After this, schedule() must not care about p->state any more. - */ - block_task(rq, p, flags); + block_task(rq, p, task_state); return true; } =20