From nobody Mon Jun 8 08:32:13 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 C90B040313D; Thu, 4 Jun 2026 18:45:45 +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=1780598747; cv=none; b=dRyc1coT36nlQ8IuEBD7TS0qv2nzVupPXGkEeC8tfx5qMUIJmfHfqxNKxtZrCyfIJ6JIgho3WoD6AnvGWG27P8oE2dElTvldMwZdUHG9Cdmgt39rxCICoYcM+rE1nItV484qxujmrymB+6ZCUyT6gW1US7ovy/HmcocIksvYuPE= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1780598747; c=relaxed/simple; bh=hJGtOzIOSdnxU1U1Bh2Z/bJbWb5GiUwcGbb8CKS1miM=; h=Date:From:To:Subject:Cc:In-Reply-To:References:MIME-Version: Message-ID:Content-Type; b=qlnDc/47nlv6Jht9V0EiWrG/p1YSaj0eoHwuUghSTSWZfMuf6Z7ARalTUDDQLsg6bq3uu5NowGl065eGVP0aOm5T7yqH3XYM75UW5MdIsjfwXWVPz6RrKgv4S0MdUa0cwZebohyWZ7gf/HAXoNhi0e/h1JPXoDh9PwNwBqv9TVA= 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=wY5GHJwH; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b=a47D/t/R; 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="wY5GHJwH"; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="a47D/t/R" Date: Thu, 04 Jun 2026 18:45:43 -0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1780598744; 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=W6cRwY4KUkAt3eTZSf4E/xJEB1hRDI6ha1C9hCWMG+Q=; b=wY5GHJwH06ImnakKr75LOCHbQG1Cpc+eQV98ak4jDUh7v2OC63oDgrq9CrwNHlbqa3mSqq I0b+f9eX/mjgFKXFF7732HzR6I5vsfzxOwR0Xq76ZvxY2rCeEEFhrbNyq1a8yA4FKfGV+3 8lRMkXrWz43fhNPEtsY0A+YmYMVP34cHaZwHLLYwzHE8EwkqBqav5P386GdzlemJdB6jmr e06H8pB3YedfYHjxM3V7CQOM3pnriz4cznjXl7QAFrYRurHs4V1JbQ0MW9gRP1ITGhM4K2 OIyrUVPnQwCbDhy8FOnJyPVg0rWmOz5oc3TH/CNHpDaw+mINMwWoZBepFiiyeg== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1780598744; 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=W6cRwY4KUkAt3eTZSf4E/xJEB1hRDI6ha1C9hCWMG+Q=; b=a47D/t/RGfAk1Oie/05LU2fX32AGxI7HoBAdySIt38oYJWAeXGBMNyZKkoA9Fur47sQhhf hqRa6IPcpTu129Dw== From: "tip-bot2 for Peter Zijlstra" Sender: tip-bot2@linutronix.de Reply-to: linux-kernel@vger.kernel.org To: linux-tip-commits@vger.kernel.org Subject: [tip: sched/core] sched/proxy: Optimize try_to_wake_up() Cc: "Peter Zijlstra (Intel)" , John Stultz , x86@kernel.org, linux-kernel@vger.kernel.org In-Reply-To: <20260526113322.244729903@infradead.org> References: <20260526113322.244729903@infradead.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-ID: <178059874318.710.10626900057926143504.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: abc40cca0efdf5ba28b7bc37f1db445a8cc840bd Gitweb: https://git.kernel.org/tip/abc40cca0efdf5ba28b7bc37f1db445a8= cc840bd Author: Peter Zijlstra AuthorDate: Tue, 26 May 2026 11:28:46 +02:00 Committer: Peter Zijlstra CommitterDate: Tue, 02 Jun 2026 12:26:08 +02:00 sched/proxy: Optimize try_to_wake_up() 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 Link: https://patch.msgid.link/20260526113322.244729903%40infradead.org --- kernel/sched/core.c | 14 ++++---------- 1 file changed, 4 insertions(+), 10 deletions(-) diff --git a/kernel/sched/core.c b/kernel/sched/core.c index 4c6ceff..a06d5a5 100644 --- a/kernel/sched/core.c +++ b/kernel/sched/core.c @@ -4344,14 +4344,6 @@ int try_to_wake_up(struct task_struct *p, unsigned i= nt state, int wake_flags) 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 *rq, struct ta= sk_struct *donor) 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 task_struct *do= nor, struct rq_flags *rf) 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 task_struct *do= nor, struct rq_flags *rf) * 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 task_struct *do= nor, struct rq_flags *rf) /* 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; } =20