From mboxrd@z Thu Jan 1 00:00:00 1970 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-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 it 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 blocked 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; scoped_guard(raw_spinlock, &p->blocked_lock) { @@ -6850,14 +6850,14 @@ find_proxy_task(struct rq *rq, struct ta bool curr_in_chain = false; int this_cpu = cpu_of(rq); struct task_struct *p; - struct mutex *mutex; int owner_cpu; /* Follow blocked_on chain. */ - for (p = donor; (mutex = p->blocked_on); p = owner) { + for (p = donor; p->is_blocked; p = owner) { /* if its PROXY_WAKING, do return migration or run if current */ - if (mutex == PROXY_WAKING) { - clear_task_blocked_on(p, PROXY_WAKING); + struct mutex *mutex = p->blocked_on; + if (!mutex || mutex == PROXY_WAKING) { + clear_task_blocked_on(p, mutex); if (task_current(rq, p)) { p->is_blocked = 0; return p; @@ -7128,7 +7128,7 @@ static void __sched notrace __schedule(i rq_set_donor(rq, next); next->blocked_donor = NULL; - if (unlikely(next->is_blocked && next->blocked_on)) { + if (unlikely(next->is_blocked)) { next = find_proxy_task(rq, next, &rf); if (!next) { zap_balance_callbacks(rq);