From mboxrd@z Thu Jan 1 00:00:00 1970 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-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 this clause from the common wake-up path. Signed-off-by: Peter Zijlstra (Intel) --- 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); /* - * 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 = READ_ONCE(donor->__state); WARN_ON_ONCE(state == 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 = donor; (mutex = p->blocked_on); p = owner) { /* if its PROXY_WAKING, do return migration or run if current */ if (mutex == PROXY_WAKING) { + clear_task_blocked_on(p, PROXY_WAKING); if (task_current(rq, p)) { p->is_blocked = 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 = 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; }