From nobody Sun Jun 14 11:28:41 2026 Received: from galois.linutronix.de (Galois.linutronix.de [193.142.43.55]) (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 3F2B63D16E7; Thu, 2 Apr 2026 11:46:36 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=193.142.43.55 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1775130405; cv=none; b=XZFJN+ZAz+GlsLgfs/Kxcroc3pAOJaf4bL00AdOHK++Nrj79Btd0KaeOdF+nA2CNCjFcoj2YmyoOSQO75fovvvx0YpbOLrb1lHIk9FUWGkiP+v42/KDYuPMxgeEOLk9qXcgHl9TlWEy8moRqeTWSZ1wD/kcxTUoJJl0pw2BOgzM= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1775130405; c=relaxed/simple; bh=5Q5rhaALzWdSTp9crU644/lKNpsT0B3+psMow7/VAyk=; h=Date:From:To:Subject:Cc:In-Reply-To:References:MIME-Version: Message-ID:Content-Type; b=kNYojWNkb6JDMdXAfOlPnfugeoTRtYB3KOhLYDhXxocZXxub9ChHrlTCOw9HYM0DTHVysKYy/9ZFisx6RQiUskhlPV5WF7BVKweHdDUYx2Ysvu/j7sn7+2ZLbMCdQLhSDRubTgf81bGdc9zBjNDB6CiFbYKch62rANtyh65QSVA= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linutronix.de; spf=pass smtp.mailfrom=linutronix.de; dkim=pass (2048-bit key) header.d=linutronix.de header.i=@linutronix.de header.b=cjO1FLVW; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b=p88lCWlf; arc=none smtp.client-ip=193.142.43.55 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linutronix.de Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linutronix.de Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="cjO1FLVW"; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="p88lCWlf" Date: Thu, 02 Apr 2026 11:46:27 -0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1775130389; h=from:from:sender:sender:reply-to:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=VoUA5uHkgYJBnzsV6Wr89Dc40Wz4QThfr0RPSm5XdPM=; b=cjO1FLVWfwRGfqza8cVACVjjyt6vB6iH84lsawVyt8pGpMm9M111eV9bIMiGlNLkpyiqo9 CRKFFRrd10PO5nIORVD7bQSykEBVrF2/XFExirnUy+bKOApmS8OakhUl6IwQtMV0JChy68 oSxq2jfANseZuOo7G7O/hJK45upQAIxb2zTGowfxi3MTfUj7XA/Nh2FZc0CM5grb58Qz0c qUgH68Pprla8LW3duztOaNuZcqN7Wywl8H9XwNGws71TvjWFt73q0YFCCWJWSw29fXGW0y ZH1K7EGlYRdFGSshmFKvuTw/V/L1Lsi0ecPVM/4thOH9CxcF9rph6ci8mATgCQ== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1775130389; h=from:from:sender:sender:reply-to:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=VoUA5uHkgYJBnzsV6Wr89Dc40Wz4QThfr0RPSm5XdPM=; b=p88lCWlfr6gwLZw8hIujP5Gj0Jw63NQ95PdpYQQuPgOOCMRBjxhrQFleKEniecbv387Z+B pJ1/Dn9GFq52OBDA== From: "tip-bot2 for Peter Zijlstra" Sender: tip-bot2@linutronix.de Reply-to: linux-kernel@vger.kernel.org To: linux-tip-commits@vger.kernel.org Subject: [tip: sched/urgent] sched/fair: Fix zero_vruntime tracking fix Cc: John Stultz , "Peter Zijlstra (Intel)" , Vincent Guittot , K Prateek Nayak , x86@kernel.org, linux-kernel@vger.kernel.org In-Reply-To: <20260401132355.081530332@infradead.org> References: <20260401132355.081530332@infradead.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-ID: <177513038772.1647592.5931920652769919013.tip-bot2@tip-bot2> Robot-ID: Robot-Unsubscribe: Contact to get blacklisted from these emails Precedence: bulk Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable The following commit has been merged into the sched/urgent branch of tip: Commit-ID: 1319ea57529e131822bab56bf417c8edc2db9ae8 Gitweb: https://git.kernel.org/tip/1319ea57529e131822bab56bf417c8edc= 2db9ae8 Author: Peter Zijlstra AuthorDate: Wed, 01 Apr 2026 15:20:20 +02:00 Committer: Peter Zijlstra CommitterDate: Thu, 02 Apr 2026 13:42:43 +02:00 sched/fair: Fix zero_vruntime tracking fix John reported that stress-ng-yield could make his machine unhappy and managed to bisect it to commit b3d99f43c72b ("sched/fair: Fix zero_vruntime tracking"). The combination of yield and that commit was specific enough to hypothesize the following scenario: Suppose we have 2 runnable tasks, both doing yield. Then one will be eligible and one will not be, because the average position must be in between these two entities. Therefore, the runnable task will be eligible, and be promoted a full slice (all the tasks do is yield after all). This causes it to jump over the other task and now the other task is eligible and current is no longer. So we schedule. Since we are runnable, there is no {de,en}queue. All we have is the __{en,de}queue_entity() from {put_prev,set_next}_task(). But per the fingered commit, those two no longer move zero_vruntime. All that moves zero_vruntime are tick and full {de,en}queue. This means, that if the two tasks playing leapfrog can reach the critical speed to reach the overflow point inside one tick's worth of time, we're up a creek. Additionally, when multiple cgroups are involved, there is no guarantee the tick will in fact hit every cgroup in a timely manner. Statistically speaking it will, but that same statistics does not rule out the possibility of one cgroup not getting a tick for a significant amount of time -- however unlikely. Therefore, just like with the yield() case, force an update at the end of every slice. This ensures the update is never more than a single slice behind and the whole thing is within 2 lag bounds as per the comment on entity_key(). Fixes: b3d99f43c72b ("sched/fair: Fix zero_vruntime tracking") Reported-by: John Stultz Signed-off-by: Peter Zijlstra (Intel) Reviewed-by: Vincent Guittot Tested-by: K Prateek Nayak Tested-by: John Stultz Link: https://patch.msgid.link/20260401132355.081530332@infradead.org --- kernel/sched/fair.c | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/kernel/sched/fair.c b/kernel/sched/fair.c index bf948db..ab41147 100644 --- a/kernel/sched/fair.c +++ b/kernel/sched/fair.c @@ -707,7 +707,7 @@ void update_zero_vruntime(struct cfs_rq *cfs_rq, s64 de= lta) * Called in: * - place_entity() -- before enqueue * - update_entity_lag() -- before dequeue - * - entity_tick() + * - update_deadline() -- slice expiration * * This means it is one entry 'behind' but that puts it close enough to wh= ere * the bound on entity_key() is at most two lag bounds. @@ -1131,6 +1131,7 @@ static bool update_deadline(struct cfs_rq *cfs_rq, st= ruct sched_entity *se) * EEVDF: vd_i =3D ve_i + r_i / w_i */ se->deadline =3D se->vruntime + calc_delta_fair(se->slice, se); + avg_vruntime(cfs_rq); =20 /* * The task has consumed its request, reschedule. @@ -5593,11 +5594,6 @@ entity_tick(struct cfs_rq *cfs_rq, struct sched_enti= ty *curr, int queued) update_load_avg(cfs_rq, curr, UPDATE_TG); update_cfs_group(curr); =20 - /* - * Pulls along cfs_rq::zero_vruntime. - */ - avg_vruntime(cfs_rq); - #ifdef CONFIG_SCHED_HRTICK /* * queued ticks are scheduled to match the slice, so don't bother @@ -9128,7 +9124,7 @@ static void yield_task_fair(struct rq *rq) */ if (entity_eligible(cfs_rq, se)) { se->vruntime =3D se->deadline; - se->deadline +=3D calc_delta_fair(se->slice, se); + update_deadline(cfs_rq, se); } } =20