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 8B1333C872C for ; Fri, 14 Aug 2026 11:22:39 +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=1786706565; cv=none; b=qNdyRIoPMOkKPW0OVSdulzT5A47n3KTiHe2wpkPe0WYDj84kU8DQGySuulVpg52NYIUq9NS9eJepXm9B5WRaMIKV1z39qYMiogK/Iliql2EOouNUUuAxG8FQ3JY3bkHNSuJOuC+MXyJGqqqqcnf+9rq/A/4juADV5OvJ5MVaskw= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1786706565; c=relaxed/simple; bh=+HXhpznD8Qe/7CZKaWs1QEA5I+yfND5UeJGdGZVOwwI=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=LI9i2ErQFtZl1PEhTeFitefJZpt9GuBFmkqyBZXJXS7FCcgFrWIeOMYo6AyEf30MSxsBG1ilPNHrbrSCRC2Db+m0RHIkaPrcOCsaWO7Mx+h0Gk1aWiACV+2b+3AxrUG5wBmfC5QFbQfSBZ8Ym74sdCuKZk1tn/FhL/I425MzpRg= 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=VW4N9WvM; 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=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="VW4N9WvM" DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=desiato.20200630; 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=VBnv35pwyBBw/797XWWQJlWbtOicHc8dTcoMbxe4mqg=; b=VW4N9WvMBmvgTsz5OHaAyjCovw MrKim6F6jCi8/RpZR4PwPAkNvws3Hi8hxWF/ZuVTr4Gwi/Dlo5k+xZfZFZKUXbuEJozlXf5joRNxi jNPx9N9Mm9MIuqOFqKO7yAbgs4aLlhsdlfpPUa2l2BAiv/4jN1nDbsMBIVthdBoZ4gOFtQofIHFgz wwlx+w10KZvQZqzrdsjmJNUdNi1G2Qja4iWvDuCn4LTM6ktachstWzdOKxWd63brNrMzBpsJNyDAY AgcSqgvOU/UY55EbcGnHazd/7U3s3GzNZQ5GwrEWvOGuMwFufARyhgmRFtM1uLIZDRbyy9TWDC3RQ ozz6A8kg==; 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.99.2 #2 (Red Hat Linux)) id 1wupza-0000000Gspa-3OBz; Fri, 14 Aug 2026 11:22:31 +0000 Received: by noisy.programming.kicks-ass.net (Postfix, from userid 1000) id 2F679300323; Fri, 14 Aug 2026 13:22:22 +0200 (CEST) Date: Fri, 14 Aug 2026 13:22:22 +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 Subject: Re: [PATCH] sched/fair: Fix flat hierarchy Message-ID: <20260814112222.GY687043@noisy.programming.kicks-ass.net> References: <20260812125039.1717249-1-vincent.guittot@linaro.org> <20260812140331.GN776954@noisy.programming.kicks-ass.net> <20260813103155.GC1246887@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=us-ascii Content-Disposition: inline In-Reply-To: On Fri, Aug 14, 2026 at 11:26:13AM +0200, Vincent Guittot wrote: > For the enqueue, the 1st requeue_delayed_entity() which is the main > path for delayed task, requires the update. Then another one before > reweight_eevdf(cfs_rq, se, weight, false); in the !curr case. > > But I'm not sure we want to spread this in different places. Fair enough. I'll test the below and then push to sched/urgent. --- Subject: sched/fair: Fix flat hierarchy From: Vincent Guittot Date: Wed, 12 Aug 2026 14:50:39 +0200 From: Vincent Guittot When a fair task is enqueued, we must update curr and more precisely its vruntime before placing the enqueued task so avg vruntime will take into account the last exec phase. Example: TA is an always running task in cgroup G0. TB is a short running task (cyclictest) in cgroup G1. The lag of TB always increases up the clamp limit because TB is placed before TA(curr) is updated (since the last tick). When curr(TA) is finally updated, its last exec phase provide positive lag to TB Because TA and TB don't belong to the same group, enqueue_hierarchy() will not update TA's entity when updating curr but only G0's entity at root level. The same applies when dequeuing. This is because update_curr() uses ->h_curr, rather than ->curr, and therefore, while it is invoked on the root cfs_rq, which contains all the eevdf bits, it does not do the right thing. Fixes: 85570f10a4c6 ("sched/eevdf: Move to a single runqueue") Signed-off-by: Vincent Guittot Signed-off-by: Peter Zijlstra (Intel) Link: https://patch.msgid.link/20260812125039.1717249-1-vincent.guittot@linaro.org --- kernel/sched/fair.c | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) --- a/kernel/sched/fair.c +++ b/kernel/sched/fair.c @@ -7958,6 +7958,15 @@ static unsigned long enqueue_hierarchy(s return weight; } +/* Update curr's vruntime before placing entity or updating lag */ +static inline void update_curr_eevdf(struct cfs_rq *cfs_rq) +{ + if (!cfs_rq->curr) + return; + + update_curr(cfs_rq_of(cfs_rq->curr)); +} + /* * The enqueue_task method is called before nr_running is * increased. Here we update the fair scheduling stats and @@ -7985,6 +7994,8 @@ enqueue_task_fair(struct rq *rq, struct if (!p->se.sched_delayed || (flags & ENQUEUE_DELAYED)) util_est_enqueue(cfs_rq, p); + update_curr_eevdf(cfs_rq); + if (flags & ENQUEUE_DELAYED) { requeue_delayed_entity(cfs_rq, se); return; @@ -8105,7 +8116,7 @@ static bool __dequeue_task(struct rq *rq clear_buddies(cfs_rq, se); - update_curr(cfs_rq_of(se)); + update_curr_eevdf(cfs_rq); update_entity_lag(cfs_rq, se); if (flags & DEQUEUE_DELAYED) {