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 843EE331EDF for ; Thu, 25 Jun 2026 08:34:07 +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=1782376452; cv=none; b=XadqClNmNVnhNcWd9iLrEWkM2RPyrtpxqHtMUPSDxGQa4aocE5qB0D/wTkpgAJyELyYYNcOnthq7gK7C2gLXpVRRyWMPakJxB+c3md0GnrKIinKJ0jcv37uaHGV2KPmnS3dSsDpnT+JGcAUCWu8kzQZfpfgXtNu3lLT4+dVlV7k= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1782376452; c=relaxed/simple; bh=m13Vgs3woq/Lq75L4XOES5tx+PDuCPi5t0bGt2UAUn0=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=kioGtgAZ9FbzY3CdS6syP+HyN3lgSJKJca+JBGmC3Oq1L3oIzGhgn7f6cSlcZSiodo7cykC7yFhOeq5QWZbx6Ija43JvPm7REx2TS9891xTX0pXB7gP/s2A+vrHSZPaNXXYuqE3f3pQxWJTAN7GwFQOaxioGi7Hf28azP8hAhZ4= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=infradead.org; spf=pass smtp.mailfrom=infradead.org; dkim=pass (2048-bit key) header.d=infradead.org header.i=@infradead.org header.b=P4kp86uB; 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=pass 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="P4kp86uB" 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=m+9nP7qWGHoZzKHzT6RxGve8ZH1LTfHqJ/Bnsqn0RFg=; b=P4kp86uBHmasOES+njuWHVWUFj NgT5WmA4BBErAe5pBk62swsN4RNgpmBxbbhmh29cpx/olBN2x/IfrYDsmKLa2M7kw80EA44WW/Go/ xBTzhU5Amy5+r28GF+lHF9jT8nOrsAzpTpUPJaK25ZiD/N67efTdXmfItJlBUdpS3XiZ+vgA6SJwr UnhvO1N3BWbpCBFdC1aCD1KwT9XkFEk+CJin2AJa5Tawgaj/WRGwQh49jq0ueEkjEvIADQkuaezxu bIh42CHJbGzBAxq34KMpJ7v13yUNJZI0wEiIg3oeBFjWpfbc+BEHCFaLZ9CdrMPcmfm8YWJOU2zAj z8Uw8ZkQ==; 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 1wcfX2-00000009ZPR-0OPk; Thu, 25 Jun 2026 08:33:57 +0000 Received: by noisy.programming.kicks-ass.net (Postfix, from userid 1000) id 7F058300B5F; Thu, 25 Jun 2026 10:33:55 +0200 (CEST) Date: Thu, 25 Jun 2026 10:33:55 +0200 From: Peter Zijlstra To: Vincent Guittot Cc: mingo@redhat.com, juri.lelli@redhat.com, dietmar.eggemann@arm.com, rostedt@goodmis.org, bsegall@google.com, mgorman@suse.de, vschneid@redhat.com, kprateek.nayak@amd.com, linux-kernel@vger.kernel.org, qyousef@layalina.io Subject: Re: [PATCH 6/6 v3] sched/eevdf: Speedup short slice task scheduling Message-ID: <20260625083355.GQ42921@noisy.programming.kicks-ass.net> References: <20260624151229.1710703-1-vincent.guittot@linaro.org> <20260624151229.1710703-7-vincent.guittot@linaro.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: <20260624151229.1710703-7-vincent.guittot@linaro.org> On Wed, Jun 24, 2026 at 05:12:29PM +0200, Vincent Guittot wrote: > When a task with a shorter slice is enqueued, we protect the running > task which has a longer slice until it becomes ineligible instead of a > full slice in order to speedup the switch to other tasks until the task > with the shortest slice is scheduled. This helps to the task to not wait > too many full slices before running. > > Signed-off-by: Vincent Guittot > Tested-by: K Prateek Nayak > --- > kernel/sched/fair.c | 52 +++++++++++++++++++++++++++++++++++++++++++-- > 1 file changed, 50 insertions(+), 2 deletions(-) > > diff --git a/kernel/sched/fair.c b/kernel/sched/fair.c > index f972987618e7..7c541f27a1ed 100644 > --- a/kernel/sched/fair.c > +++ b/kernel/sched/fair.c > @@ -813,6 +813,48 @@ u64 avg_vruntime(struct cfs_rq *cfs_rq) > return cfs_rq->zero_vruntime; > } > > +/* > + * Compute the vruntime until which the entity remains eligible when it runs > + * or is about to run on the CPU. We use this value to set vprot to the min > + * value until which other entities would not be picked anyway. > + * \Sum (v_i - v0)*w_i > + * V = ------------------- + v0 > + * \Sum w_i > + * > + * We want V' for (v_se - v0) == 0. Previous entity has already been enqueued > + * in the rb tree and next is already dequeued so > + * > + * cfs_rq->sum_w_vruntime > + * V' = ------------------------- + v0 > + * cfs_rq->sum_weight + w_se > + > + */ > +static u64 eligible_vruntime(struct cfs_rq *cfs_rq, struct sched_entity *se) > +{ > + struct sched_entity *curr = cfs_rq->curr; > + long weight = cfs_rq->sum_weight; > + s64 delta = 0; 'curr' goes unused in this function, did you want: if (curr && !curr->on_rq) curr = NULL; > + > + if (weight) { > + s64 runtime = cfs_rq->sum_w_vruntime; if (curr) { unsigned long w = avg_vruntime_weight(cfs_rq, curr->load.weight); runtime += entity_key(cfs_rq, curr) * w; weight += w; } ? > + > + weight += avg_vruntime_weight(cfs_rq, se->load.weight); > + > + /* sign flips effective floor / ceiling */ > + if (runtime < 0) > + runtime -= (weight - 1); > + > + delta = div64_long(runtime, weight); > + } else { > + /* > + * When there is but one element, it is the average. > + */ > + delta = 0; > + } > + > + return cfs_rq->zero_vruntime + delta + 1; > +}