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 1B3C042B731 for ; Tue, 26 May 2026 14:57:21 +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=1779807444; cv=none; b=PLOzikIRkm86Ar1TRVfjNm4UcrGepeSx2pryv2450aPmUzKl6RP58+wt6Ty8u0bvp9z3195RvZItO/+nkQIumjHwyNxU8Uhr9+PTMTF7326Oh8LluNQXdszFW/JVHIK2afjEwXYk+98eyt30C68xfucsbOLGFiUVBzxwDFk5vtQ= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1779807444; c=relaxed/simple; bh=Qsk2XhugMg/RoNrBLN4U9Tyz+rEr3AxDfCZ9OPpcRhs=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=hzTofD5jRJRB+EEgj3yDFvbSMqh/J24PUHRS4zTpv9w4/3kDDZM63Ma2Su5qi3jNMQ11hyoWkXGzbvuBzlJz111N21RPnTwZ8Ms6vATfzhFGArx8G2i7g3Vlr8/fvMwt3+Pc+H5U1yh66YCUPdlj0EOa8iq4FEYl8KcX8krrp0k= 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=WJT9ukia; 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="WJT9ukia" DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=casper.20170209; h=In-Reply-To:Content-Type:MIME-Version: References:Message-ID:Subject:Cc:To:From:Date:Sender:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description; bh=SFtCsyJxQdpjC/xKt9xy8M1Gyg10mGGG4GGA/ICRjXY=; b=WJT9ukiaOb4CYSu6xcQXtzqPW+ kmu9jWv+NYbccDA53A1r4jo4SB7YDwBQoSUZ1CaYCcT0HXg7hR3zDXTe9Qrs9jEpzhJT6+owWIbIf iKlmqQYROZcGuZ4g2sfEwjKxKcgO5bEmyRnCVIEQrrbv1Ycg67sa624ynwNtc7rFXF0+OlDHTL6Kv Vh/ph3uA/EzypmMVw5pw75fGhJx+FY3HwfdK64IfprYe0YcSxgS+Pw1dxtUX1/5V7OzW/swuDavgz vTVDXacTAozuFaBTGI8bFoxmiAYZN6WbJj8f55+pk2siabR0lroRZpNECmmwULlLjpPaNZgUkKrfT HvzuniFg==; 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 casper.infradead.org with esmtpsa (Exim 4.99.1 #2 (Red Hat Linux)) id 1wRtDO-00000001BkI-3FP8; Tue, 26 May 2026 14:57:06 +0000 Received: by noisy.programming.kicks-ass.net (Postfix, from userid 1000) id 54A5A300323; Tue, 26 May 2026 16:57:05 +0200 (CEST) Date: Tue, 26 May 2026 16:57:05 +0200 From: Peter Zijlstra To: John Stultz , K Prateek Nayak Cc: Joel Fernandes , Qais Yousef , Ingo Molnar , Juri Lelli , Vincent Guittot , Dietmar Eggemann , Valentin Schneider , Steven Rostedt , Ben Segall , Zimuzo Ezeozue , Will Deacon , Waiman Long , Boqun Feng , "Paul E. McKenney" , Metin Kaya , Xuewen Yan , Thomas Gleixner , Daniel Lezcano , Suleiman Souhlal , kuyo chang , hupu , linux-kernel@vger.kernel.org, Mike Galbraith Subject: Re: [PATCH 4/6] sched/proxy: Switch proxy to use p->is_blocked Message-ID: <20260526145705.GB3493090@noisy.programming.kicks-ass.net> References: <20260526111609.433880331@infradead.org> <20260526113322.477954312@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=us-ascii Content-Disposition: inline In-Reply-To: <20260526113322.477954312@infradead.org> On Tue, May 26, 2026 at 01:16:13PM +0200, Peter Zijlstra wrote: > 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; Oh, I think we can solve things if we have a cpus_allowed check here. If the task is on an allowed CPU, it don't need migration and we can carry on without eating the overhead. > > 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); > >