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 94F881552FD for ; Wed, 11 Feb 2026 08:49:09 +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=1770799753; cv=none; b=GHZjmPn1/PH4wVUtAJgC1/U5UAhyJNRkjYGaoBKk3Y3EqDCxnOiyUrgrT8b65nZfdnFvzTN0JjI3LwkJxwWc7/8sNjFHcVmf4oyXL5S+nRVvaDV5ny3JebsEybwgDaR0RAONxpUHPYDD57xtuzkM9eUeoLjn4fBGTKkSlM6WQ4o= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1770799753; c=relaxed/simple; bh=WK+vtDd3Sn3rZLaapnfD5uaxF4dfOK75X5QUIWhuiyg=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=epK8lBzN1qgFEAUNdBeImmO1+aEaIoUIYVm0J5SHB+E8/l1F/+6oguENoW23BJQtOlNWPIpdXA1bAFToiVIqlD24mDPmK7nnTf9LbRXCsNIAqhKivEhdlS7LpOgfL5Ed9vrKfO51WppI/feJ3+0xbwGO2NJiUBZ1pXPHmux1tcs= 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=SeFzBezR; 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="SeFzBezR" 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=uSjSTNb2EPzLwHPT/FFGG2U/uvCRZyevVBoXlTaOrPQ=; b=SeFzBezRyfJ3pTGagM9dOt7Fak zi2AARfjGn/nOeAz53p+M3mfMuPirN+FPDFl+mPBUXdKnOUI3Pk0kR0PesUvfoFaYVjhXuDyzTlSo KIxTgCt97Lmm7dVGuswlqcVp3Qab8Uns4kgqlkUcpnKAe2MJxYLlsS5wFsk6ce0+/yUUPuuDP5xBj n7iNvfAVV6DkvsoVzk58RMnlWVGH2c5j1iwlsR04p1/6XANi8zpFvdfqYIBqmx8PUUMzKxDqdog5P GRQYQ4UI9tsls7sOQWiT1PO/iRivgls+X5X1dWUXAEOens7Vj5qzMo0QwliJuN3+J/I5E2A1jvlKF 599sORRw==; 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 1vq5u4-0000000COHg-0Tat; Wed, 11 Feb 2026 08:48:56 +0000 Received: by noisy.programming.kicks-ass.net (Postfix, from userid 1000) id A6BB8300FB6; Wed, 11 Feb 2026 09:48:54 +0100 (CET) Date: Wed, 11 Feb 2026 09:48:54 +0100 From: Peter Zijlstra To: Vincent Guittot Cc: K Prateek Nayak , 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, wuyun.abel@bytedance.com, dsmythies@telus.net Subject: Re: [PATCH 0/4] sched: Various reweight_entity() fixes Message-ID: <20260211084854.GX1282955@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 09:52:29PM +0100, Vincent Guittot wrote: > > Subject: sched/fair: Fix zero_vruntime tracking > > From: Peter Zijlstra > > Date: Mon Feb 9 15:28:16 CET 2026 > > > > It turns out that zero_vruntime tracking is broken when there is but a single > > task running. Current update paths are through __{en,de}queue_entity(), and > > when there is but a single task, pick_next_task() will always return that one > > task, and put_prev_set_next_task() will end up in neither function. > > > > This can cause entity_key() to grow indefinitely large and cause overflows, > > leading to much pain and suffering. > > > > Furtermore, doing update_zero_vruntime() from __{de,en}queue_entity(), which > > are called from {set_next,put_prev}_entity() has problems because: > > > > - set_next_entity() calls __dequeue_entity() before it does cfs_rq->curr = se. > > This means the avg_vruntime() will see the removal but not current, missing > > the entity for accounting. > > > > - put_prev_entity() calls __enqueue_entity() before it does cfs_rq->curr = > > NULL. This means the avg_vruntime() will see the addition *and* current, > > leading to double accounting. > > > > Both cases are incorrect. > > > > Noting that avg_vruntime is already called on each {en,de}queue, remove the > > explicit avg_vruntime() calls (which removes an extra 64bit division for each > > {en,de}queue) and have avg_vruntime() update zero_vruntime itself. > > > > Additionally, have the tick call avg_vruntime() -- discarding the result, but > > for the side-effect of updating zero_vruntime. > > > > While there, optimize avg_vruntime() by noting that the average of one value is > > rather trivial to compute. > > > > Test case: > > # taskset -c -p 1 $$ > > # taskset -c 2 bash -c 'while :; do :; done&' > > # cat /sys/kernel/debug/sched/debug | awk '/^cpu#/ {P=0} /^cpu#2,/ {P=1} {if (P) print $0}' | grep -e zero_vruntime -e "^>" > > > > PRE: > > .zero_vruntime : 31316.407903 > > >R bash 487 50787.345112 E 50789.145972 2.800000 50780.298364 16 120 0.000000 0.000000 0.000000 / > > .zero_vruntime : 382548.253179 > > >R bash 487 427275.204288 E 427276.003584 2.800000 427268.157540 23 120 0.000000 0.000000 0.000000 / > > > > POST: > > .zero_vruntime : 17259.709467 > > >R bash 526 17259.709467 E 17262.509467 2.800000 16915.031624 9 120 0.000000 0.000000 0.000000 / > > .zero_vruntime : 18702.723356 > > >R bash 526 18702.723356 E 18705.523356 2.800000 18358.045513 9 120 0.000000 0.000000 0.000000 / > > > > Fixes: 79f3f9bedd14 ("sched/eevdf: Fix min_vruntime vs avg_vruntime") > > Reported-by: K Prateek Nayak > > Signed-off-by: Peter Zijlstra (Intel) > > Hi Peter, > > This patch w/ the patchset on top of tip/sched/core create regressions > for hackbench (tbench doesn't seem to be impacted) on my dragonboard > rb5 Durr... That was obviously not so expected. Let me go poke.