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 53B0E33F8B3 for ; Tue, 10 Feb 2026 10:29:44 +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=1770719387; cv=none; b=pIP9EWQlM83fPNdYTuoeRGGw4/n4qmmcdVqilO6TWd3ffFe2kXxsxwhp46RMY0zjYfj1DSHp47hfRebxEQQ90VCuBi0Lh9SzSN0b7htLSZU9GyVG4fnssS5jBvxJo0hDP9BLDnYObGmuW/lP/AfJ8gbTFmMZY5gGedJPuoTp58g= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1770719387; c=relaxed/simple; bh=AIMEgHcwYZmJZZrizZAe8nrTKn7gcXb1LVCJRnaznUc=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=ZHON1hG0mDavuNLe/nm3rCx/MOaomtOdp56Bjgt4wyy/vuWlXMBTQcGRWUwcB/0Fw8WiApxQA1YxfRc8oy3CuryP8azfIsXoBGHOopzBEhliNUw5mu/7m9CmLItFL7Bct2aG1YzQpgIBnMr3KX6EkWRiqOtA2p+ZzVEw5UJcSjU= 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=qQyvAwm+; 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=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="qQyvAwm+" 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=p0ri8h563N7lA3tq0bSrvKXFe2cqGzloPJg2F1NUOrU=; b=qQyvAwm+ROmfDhEOeM6cf/G9My v3F2bKkuwQ23AkNKCIZqHdGajMxTvm0vpz4gTAQHwQ0h4H41vrSVTokqZBA6JBIFHixCM0fozTAkj 8GRvgNTmSZtHSuaItXr4bfuvrdBHhI1XuK99Sdgq6r+iTQRKFFE7zailaJRpgAn8qPGWZcAbs978N drOQDN2QWqeEDUdDpN3vJLjSSSSaT+83azZXASwRkWXSa1DH13xNKYDv7z0QOI+Bno6heE/e+0SxR mhtxb8yC2Pile6sCZzbP1PndJ/d+f/SFj13G2SSUbkOGID0UNHfP0SGKT2m3Q/bVnU4SE6I99FvPK eiU81rig==; 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 casper.infradead.org with esmtpsa (Exim 4.98.2 #2 (Red Hat Linux)) id 1vpkzo-0000000AwLr-1mES; Tue, 10 Feb 2026 10:29:28 +0000 Received: by noisy.programming.kicks-ass.net (Postfix, from userid 1000) id 16748300754; Tue, 10 Feb 2026 11:29:27 +0100 (CET) Date: Tue, 10 Feb 2026 11:29:27 +0100 From: Peter Zijlstra To: K Prateek Nayak Cc: mingo@kernel.org, juri.lelli@redhat.com, vincent.guittot@linaro.org, dietmar.eggemann@arm.com, rostedt@goodmis.org, bsegall@google.com, mgorman@suse.de, vschneid@redhat.com, linux-kernel@vger.kernel.org, wangtao554@huawei.com, quzicheng@huawei.com, wuyun.abel@bytedance.com, dsmythies@telus.net Subject: Re: [PATCH 0/4] sched: Various reweight_entity() fixes Message-ID: <20260210102927.GG3016024@noisy.programming.kicks-ass.net> References: <20260130093439.803225718@infradead.org> <4c48fe59-8ff3-41fb-83cb-869409f6fbc6@amd.com> <20260203111134.GL1282955@noisy.programming.kicks-ass.net> <38ef3462-4c4e-4f40-8d63-84dd71cbd043@amd.com> <20260209154718.GW1282955@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 Tue, Feb 10, 2026 at 10:46:28AM +0530, K Prateek Nayak wrote: > Hello Peter, > > On 2/9/2026 9:17 PM, Peter Zijlstra wrote: > > I ended up with the below; and I've already pushed out a fresh > > queue/sched/core. Could you please test again? > > I haven't seen any "sum_shifts" turning non-zero on the overnight runs, > even with the larger workloads, so feel free to include: > > Tested-by: K Prateek Nayak Awesome, thanks! > > The overall patch looks good. I only have couple of cosmetic nits > inlined below: > > [..snip..] > > > u64 avg_vruntime(struct cfs_rq *cfs_rq) > > { > > struct sched_entity *curr = cfs_rq->curr; > > - s64 avg = cfs_rq->sum_w_vruntime; > > - long load = cfs_rq->sum_weight; > > + s64 delta = 0, runtime = cfs_rq->sum_w_vruntime; > > nit. > > "runtime" is only ever used in "weight" != 0 case so perhaps it can be > moved there to preserve the reverse x-mas (or this whole line can be > moved up top). Indeed! > > + long weight = cfs_rq->sum_weight; > > > > - if (curr && curr->on_rq) { > > - unsigned long weight = scale_load_down(curr->load.weight); > > + if (curr && !curr->on_rq) > > + curr = NULL; > > > > - avg += entity_key(cfs_rq, curr) * weight; > > - load += weight; > > - } > > + if (weight) { > > + if (curr) { > > + unsigned long w = scale_load_down(curr->load.weight); > > + > > + runtime += entity_key(cfs_rq, curr) * w; > > + weight += w; > > + } > > > > - if (load) { > > /* sign flips effective floor / ceiling */ > > - if (avg < 0) > > - avg -= (load - 1); > > - avg = div_s64(avg, load); > > + if (runtime < 0) > > + runtime -= (weight - 1); > > + > > + delta = div_s64(runtime, weight); > > + > > nit. Is this empty line necessary? Not really, but somehow I always find myself ending a block with an empty line when there's an else statement following. I'll get rid of it :-)