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 EB7DE31A065 for ; Wed, 12 Aug 2026 14:03:52 +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=1786543436; cv=none; b=h8HjkYIX6DowrBWPLzDv3Da3oLEQmVQGBbj9soOaVIFBZ6a187xa+XH6JJM73PwT0mRh5K2HzppBHfis/clcqmARGev3Q7wfsd+wRCiB2KpTNJ6pZksSEwlI2n7mseqel3DWmExRNm5WObJAq/lvB5sWcrrn8l2nZh44GhfplPs= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1786543436; c=relaxed/simple; bh=WC41w/Edko+2v5HCrFecXG63MFwt/VVfL5b6e76bDAo=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=Kwmvmb2iiQr+kAxYYhxdPa7i8hGJGBW132qhlzCHH5EgA1NPsB9I2Rukt8eg/0La+pR2/5yDkcFgEj9PSKCP9RtwKGSL7mVxG/GCBDfzNjXgOwvn+DDEKi3hLsSgLCrbErhJ8Txw6PyHXChVqf4HNWOQ/W+kAxVsFbeyC3hF1Nk= 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=frQy6Bec; 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="frQy6Bec" 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=adHlLT8J2ElfGFRv7tCcsfQmrGcdPWJZDjwJgElXyqg=; b=frQy6Bectwh8u+uYcKmRkHLloK ziVoEQGVWOYgOM3xXt+vwo4WDo+atAnra21F/rpCoTf+V37TibkgCo/vLDXKgG80Yxx85JcQFP1uW 5DXMWwbgkAjblYDl6mYXQjr4I5uWRWp4YXFENOFnmrn3nrCIMfS+2h63tway3vjiMyxMyXynPJZHO TsmGX7tKzUMkw8Pi4IJVU7TgazlHhw7J3Ky5hT7uYYAIMOGrkSjHjcrP1YeE3+Gv9V6VfDBmkCrdG pVkkA8yIL7P0/zGZ3wnnr1E+XnyL+X2TYCIdIQpDuYHC1c2xQ6HIleF/RlNjzPCdbk5s2h3O9z/lL S2D7yj3A==; 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 1wu9YK-000000024y8-0zMI; Wed, 12 Aug 2026 14:03:37 +0000 Received: by noisy.programming.kicks-ass.net (Postfix, from userid 1000) id 1E846300382; Wed, 12 Aug 2026 16:03:31 +0200 (CEST) Date: Wed, 12 Aug 2026 16:03:31 +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: <20260812140331.GN776954@noisy.programming.kicks-ass.net> References: <20260812125039.1717249-1-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: <20260812125039.1717249-1-vincent.guittot@linaro.org> On Wed, Aug 12, 2026 at 02:50:39PM +0200, Vincent Guittot wrote: > 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 doesn't quite make sense to me; on the one hand you talk about vruntime (which is only relevant for rq->cfs) on the other hand you talk about non overlapping cgroup hierarchies. Hmm, update_curr() looks at ->h_curr, which is the intermediate crud. So even though it updates all the cgroup nonsense, it will not in fact update the root group, because it never actually sees rq->cfs.curr. Bah. > diff --git a/kernel/sched/fair.c b/kernel/sched/fair.c > index dcf860c59a14..649b4f7505a1 100644 > --- a/kernel/sched/fair.c > +++ b/kernel/sched/fair.c > @@ -7983,6 +7983,9 @@ enqueue_task_fair(struct rq *rq, struct task_struct *p, int flags) > if (!p->se.sched_delayed || (flags & ENQUEUE_DELAYED)) > util_est_enqueue(cfs_rq, p); > > + if (cfs_rq->curr) > + update_curr(cfs_rq_of(cfs_rq->curr)); > + Still, I think this wants to be in a different spot. It needs to be below the whole initial if(curr) place_entity() thing. Perhaps stick these into {en,de}queue_hierarchy() ? > if (flags & ENQUEUE_DELAYED) { > requeue_delayed_entity(cfs_rq, se); > return; > @@ -8103,7 +8106,8 @@ static bool __dequeue_task(struct rq *rq, struct task_struct *p, int flags) > > clear_buddies(cfs_rq, se); > > - update_curr(cfs_rq_of(se)); > + if (cfs_rq->curr) > + update_curr(cfs_rq_of(cfs_rq->curr)); > update_entity_lag(cfs_rq, se); > > if (flags & DEQUEUE_DELAYED) { > -- > 2.43.0 >