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 36F2C3A4F2A for ; Wed, 18 Mar 2026 13:36:52 +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=1773841013; cv=none; b=ZklSot/f/hpg9Yr+E5jeTdppTOXzryr1Xn77XX5zdXydjlX+F5gEsqImISy8NYdMLjgAQdx+CSU8z9ymFSdaIn5xrhgrrQvz3FrD/8hiR+T2DaheECquuJjWsHKvCwMu/FSDVY6kAndw0oArNyDUsRdoQePL8TkHMey6W+hkHNw= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1773841013; c=relaxed/simple; bh=1ySmEC1MHWkZ2pgY0sHgCQZu/scmclZr9WWqxp19HUM=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=ZDxSW109Tu20qP6LnOqgtNUHrRp8WQidn+Ixw/voON8azR+a7ySk63sM61mGQ04AoNYC3Ed/pAUdOOwrlEMf0ul+YmPCHFsXZO+0B2gaAPhItNdPMe4vX4thSiE4cAdbjvGZClizm/WfpmA6LncuI/SSAny+LNKJTKIxK+Lzq/Y= 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=FpxeAxWS; 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="FpxeAxWS" DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=desiato.20200630; h=In-Reply-To:Content-Transfer-Encoding: Content-Type:MIME-Version:References:Message-ID:Subject:Cc:To:From:Date: Sender:Reply-To:Content-ID:Content-Description; bh=QhXQvafdpiVDDMrIlPmd+Cnzvt6Ag0WVa0Zoj4yTiyM=; b=FpxeAxWSWXkheY2MN5Ya2acT2c tic+2AZHTHAlXSTZhENYXYOpXhVGY9+qoSRvO69g8LBjq64Fs5/aQB8TJ8XaWE4vnsQC5ipGSP+GR uQMFxJvZaucL09Lq8DNG3x2Sb2DDKQysD/dcmzSDm6uyl3yCQVBM1JMXOwqdcg+23s8JW+lA0X0oK 76lh8CCATBdwJ2sTJzGvzclN+uWomnxa3SLuxECa3Ng7U+y59vMFiGl1SVE1wJPL0zTEy5HGketB2 M1SETK7D4o5QG+AJpbdSpvTm5le+HmWugqwb/hJcLMqs+0f7wJba0xEhTNPO5m9/3KKGOnpsrIHCd LcppedEw==; Received: from 77-249-17-252.cable.dynamic.v4.ziggo.nl ([77.249.17.252] helo=noisy.programming.kicks-ass.net) by desiato.infradead.org with esmtpsa (Exim 4.98.2 #2 (Red Hat Linux)) id 1w2r4j-0000000BH32-36S6; Wed, 18 Mar 2026 13:36:41 +0000 Received: by noisy.programming.kicks-ass.net (Postfix, from userid 1000) id 8A49C3007C4; Wed, 18 Mar 2026 14:36:40 +0100 (CET) Date: Wed, 18 Mar 2026 14:36:40 +0100 From: Peter Zijlstra To: John Stultz Cc: K Prateek Nayak , LKML , Joel Fernandes , Qais Yousef , Ingo Molnar , Juri Lelli , Vincent Guittot , Dietmar Eggemann , Valentin Schneider , Steven Rostedt , Ben Segall , Zimuzo Ezeozue , Mel Gorman , Will Deacon , Waiman Long , Boqun Feng , "Paul E. McKenney" , Metin Kaya , Xuewen Yan , Thomas Gleixner , Daniel Lezcano , Suleiman Souhlal , kuyo chang , hupu , kernel-team@android.com Subject: Re: [PATCH v25 1/9] sched: Make class_schedulers avoid pushing current, and get rid of proxy_tag_curr() Message-ID: <20260318133640.GJ3738010@noisy.programming.kicks-ass.net> References: <20260313023022.2902479-1-jstultz@google.com> <20260313023022.2902479-2-jstultz@google.com> <20ea3670-c30a-433b-a07f-c4ff98ae2379@amd.com> 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 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: On Mon, Mar 16, 2026 at 11:04:28PM -0700, John Stultz wrote: > On Mon, Mar 16, 2026 at 10:41 PM K Prateek Nayak wrote: > > On 3/17/2026 10:19 AM, John Stultz wrote: > > > > > > I guess adding a new helper function to manually do the > > > put_prev/set_next could be added to the top level __schedule() logic > > > in the (prev != next) case, though we'll have to preserve the > > > prev_donor on the stack probably. > > > > That seems like the best option to me too. > > > > Also, deadline, RT, fair, and idle don't really care about the "next" > > argument of put_prev_task() and the only one that does care is > > put_prev_task_scx() to call switch_class() callback so putting it as > > either NULL or "rq->donor" should be safe. > > Ack. > Here's the change I'm testing tonight (against 6.18): > https://github.com/johnstultz-work/linux-dev/commit/0cc72a4923143f496e33711cbcc1afdf6d861ca6 > > Feel free to suggest a better name for the helper function. It feels a > little clunky (and sort of sad right after getting rid of the clunky > proxy_tag_curr(), to re-add something so similar). Does this capture it? --- a/kernel/sched/core.c +++ b/kernel/sched/core.c @@ -7100,9 +7103,11 @@ static void __sched notrace __schedule(i pick_again: assert_balance_callbacks_empty(rq); next = pick_next_task(rq, rq->donor, &rf); - rq_set_donor(rq, next); rq->next_class = next->sched_class; if (sched_proxy_exec()) { + struct task_struct *prev_donor = rq->donor; + + rq_set_donor(rq, next); if (unlikely(next->blocked_on)) { next = find_proxy_task(rq, next, &rf); if (!next) { @@ -7114,6 +7119,24 @@ static void __sched notrace __schedule(i goto keep_resched; } } + + /* + * When transitioning like: + * + * prev next + * donor: B B + * curr: A B + * + * then put_prev_set_next_task() will not have done anything, + * since B == B. However, A might have missed a RT/DL balance + * opportunity due to being on_cpu. + */ + if (next == rq->donor && next == prev_donor) { + next->sched_class->put_prev_task(rq, next, next); + next->sched_class->set_next_task(rq, next, true); + } + } else { + rq_set_donor(rq, next); } picked: clear_tsk_need_resched(prev);