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 F338A2248A8 for ; Mon, 23 Feb 2026 11:51:17 +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=1771847481; cv=none; b=I4UwfgZkdz3Em3V92kSq+ypJfhvFRGRsfKhfDCj6qhmgLAfTXBbiojwGkyQS2BWsPTp2vXHRaEg1HCrw2I0y+wZQO2bZUySwQpiGH9+LJrNQZDMYMJJAG0Br2TCxOiLcOS8BAlTWqzpbMsO8+Z27q09II/KqFm+n+7ofBtQHDtI= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1771847481; c=relaxed/simple; bh=06Mdr3+eigw6wKP58nzADINBZ9Hv3/2sC0g8PQrJh6Q=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=RQ+Sxa7DHjXmnc4U0nfwagt2jLD2OHJCSaoDsOm2EZizrX3tAFSWhq/bjEgLfL8uolmSw4qhAU2M2e9iyJcv8+T99kyIJae2Skrx5t2r0aj4UOluTXvKjDdtFJRJQAwoTvjNDzRP3wz8NXUL27OVI1Sx1PJuJTxNkjJiogcYMa4= 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=OrwTBXtP; 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="OrwTBXtP" 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=kP3PkW7GV2GgnqqYCDcgO6cqEAQjxnzTnfdRrVwQiUM=; b=OrwTBXtPjNbTpupcRZnGOKats1 SkrmsqojFYNwUCKLyAmHouRraCe8vXkMac46VWt0Nswzx+vTdwsmITS+PoolGGUNf0/U3q1E8OLqy 0h9ZG+QZkSKIpObJp9L0BVaMYp+sXbcdEOudap+XeY7z+JNegMowijhdQ0O8XiugcSAWtHhWQeKQH qpcH/KySzMeN0yW2haKJ/vI19D696MUh5UeL6810BJ8pcjgec2ujS7V3z9Kk9Dvtb4tPBLY+GekuU 9f56ESnEyvKEx37VRDLeYfLFosnTiVmy/vFdrauD714+98mSSvir/gquGJxDZ0LM0GT1PxUjzZPdf TItyB3PQ==; 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.98.2 #2 (Red Hat Linux)) id 1vuUSs-00000004wC7-3rrw; Mon, 23 Feb 2026 11:51:03 +0000 Received: by noisy.programming.kicks-ass.net (Postfix, from userid 1000) id 23BBC3008D6; Mon, 23 Feb 2026 12:51:00 +0100 (CET) Date: Mon, 23 Feb 2026 12:51:00 +0100 From: Peter Zijlstra To: Vincent Guittot Cc: mingo@kernel.org, juri.lelli@redhat.com, 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, kprateek.nayak@amd.com, dsmythies@telus.net, shubhang@os.amperecomputing.com Subject: Re: [PATCH v2 5/7] sched/fair: Increase weight bits for avg_vruntime Message-ID: <20260223115100.GI2995752@noisy.programming.kicks-ass.net> References: <20260219075840.162631716@infradead.org> <20260219080624.942813440@infradead.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: On Mon, Feb 23, 2026 at 11:56:33AM +0100, Vincent Guittot wrote: > On Thu, 19 Feb 2026 at 09:10, Peter Zijlstra wrote: > > > > Due to the zero_vruntime patch, the deltas are now a lot smaller and > > measurement with kernel-build and hackbench runs show about 45 bits > > used. > > > > This ensures avg_vruntime() tracks the full weight range, reducing > > numerical artifacts in reweight and the like. > > Instead of paranoid, would it be better to add WARN_ONCE ? > > I'm afraid that we will not notice any potential overflow without a > long study of the regression with SCHED_FEAT(PARANOID_AVG, false) > > Couldn't we add a cheaper WARN_ONCE (key > 2^50) in __sum_w_vruntime_add ? > > We should always have > key < 110ms (max slice+max tick) * nice_0 (2^20) / weight (2) > key < 2^46 > > We can use 50 bits to get margin > > Weight is always less than 27bits and key*weight gives us 110ms (max > slice+max tick) * nice_0 (2^20) so we should never add more than 2^47 > to ->sum_weight > > so a WARN_ONCE (cfs_rq->sum_weight > 2^63) should be enough Ha, I was >< close to pushing out these patches when I saw this. The thing is signed, so bit 63 is the sign bit, but I suppose we can test bit 62 like so: Let me go build and boot that. --- a/kernel/sched/fair.c +++ b/kernel/sched/fair.c @@ -679,9 +679,13 @@ static inline void __sum_w_vruntime_add(struct cfs_rq *cfs_rq, struct sched_entity *se) { unsigned long weight = avg_vruntime_weight(cfs_rq, se->load.weight); - s64 key = entity_key(cfs_rq, se); + s64 w_vruntime, key = entity_key(cfs_rq, se); - cfs_rq->sum_w_vruntime += key * weight; + w_vruntime = key * weight; + + WARN_ON_ONCE((w_vruntime >> 63) != (w_vruntime >> 62)); + + cfs_rq->sum_w_vruntime += w_vruntime; cfs_rq->sum_weight += weight; }