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 A404C3DCD86 for ; Wed, 18 Mar 2026 13:52:19 +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=1773841942; cv=none; b=t2fDb3hCVMRCZI2AxYirmXaPfSDuHVBiiX0a5Uh5hOFhB4ehqhVkPqfODOBlFaZDVq2j4+ZkBlTkBWIQ/7DpZThVTB2AyAI3JkmCiHYXyNZ8rflfBg0l+4NW0+PhAzzuk9cvn1ALhwqTN/P/sfhZ89wd+94NfYyUtrt6GWtFqlQ= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1773841942; c=relaxed/simple; bh=xHuskebXypQKYSbfOfINpnDnaQgdI7+DD7nvqQY75OM=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=h0KqoXTtbgEk6zM5Hi7tKt9tzR/utY8bTWXI9VLJ4Atko7GPiApKheqbzIvpIaiTy4/m0dFHI/baIpsyMp1phA5/9NoqJc4hOSVjRBfXkwvSpTEWKOBjbkrvhdb83W0Dl/2M8P9k+a0iydYMGp8W9y9NCxISCf7JvOUz4tbOTQA= 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=Cm/EKYeX; 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="Cm/EKYeX" 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=bO/vOp6S4tF8KyrxLW3P/Ma2NwHOZcuS1ajF9ubHak8=; b=Cm/EKYeXixadORU8BXEcxQQ3UI D3fDxunKrXncSWtdZ7dT1JEWRs2H+f7wWjmtKRV1LTARk1cE37OkQ78V1bLPMxj7MEo1fedtRjFHt 69FlETkD+Md98GSUYCtAFM0iopqDFpa/Kf0oDN4Tb2JS1kiYMAi3nbUrvmLc/xDio1AFX0T+nAzqW wBP9Tr/OFpWo2Z68PAzw14zdiLefU2GceiB1DuDuDn7aQF4vqLu0RFgSd16gUm/9LwCRLN1EJbOmo hVP+xgKKs6SFhao/HA8VV5pP0FLOQRrgWd+lCFAcreyXQIbX3YzVVKj6FpcVqseW2SKVk7yPLK2Ko hucfQ8qw==; Received: from 2001-1c00-8d85-5700-266e-96ff-fe07-7dcc.cable.dynamic.v6.ziggo.nl ([2001:1c00:8d85:5700:266e:96ff:fe07:7dcc] helo=noisy.programming.kicks-ass.net) by desiato.infradead.org with esmtpsa (Exim 4.98.2 #2 (Red Hat Linux)) id 1w2rJg-0000000BJCf-3wP8; Wed, 18 Mar 2026 13:52:09 +0000 Received: by noisy.programming.kicks-ass.net (Postfix, from userid 1000) id EFFF03007C4; Wed, 18 Mar 2026 14:52:02 +0100 (CET) Date: Wed, 18 Mar 2026 14:52:02 +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: <20260318135202.GA3739106@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> <20260318133640.GJ3738010@noisy.programming.kicks-ass.net> 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: <20260318133640.GJ3738010@noisy.programming.kicks-ass.net> On Wed, Mar 18, 2026 at 02:36:40PM +0100, Peter Zijlstra wrote: > 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 != prev > + 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);