From nobody Wed Apr 1 22:00:30 2026 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 41E69423172 for ; Wed, 1 Apr 2026 13:24:45 +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=1775049890; cv=none; b=hvEJ/Poa3xvT2oLDA92bJN7k5Uz1BcIsph3VvXcaLlAHkijxby8HH3wAzTN+pyen9e1n2e0MpnUe9mG3kjgJqverhtOV7H0VI8K5O4/zE0MEFxuIIE3v3ta65QiPKOhC95hBpQcJzcvWoYegp6FvkyvGfgBY6uj7TuKExD7fxuI= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1775049890; c=relaxed/simple; bh=bRKevCBkcAiU/KBV2rb1Q+kky57892UoenIbrE83GgY=; h=Message-ID:Date:From:To:Cc:Subject:References:MIME-Version: Content-Type; b=DcV2Rffp+Iqpk2NG6QXbHn30kPSwgSy8wsmUi15Jzp5nxi8C35oLm6JhvMtRJS3GciWZml4jlQCaz4zeCPQK+0GMOdWcYxlCshIHPzKk4NXjpJVuswP0iorGYhOb+bW2QRupnthrv+B2hT5Nqe+bCu/xoVFkta8j/J76CSoBFk0= 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=eqS5rW58; 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="eqS5rW58" DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=casper.20170209; h=Content-Type:MIME-Version:References: Subject:Cc:To:From:Date:Message-ID:Sender:Reply-To:Content-Transfer-Encoding: Content-ID:Content-Description:In-Reply-To; bh=tUEKIQcwI8w8RS8oBNNmgZVSvoomRGWAg5LG4t6ZKwE=; b=eqS5rW58E7Z2cLsfI8dVyyjA+V 9rjkv1XXsZO4hvsc4cn6NhmB/cXeEfHifGBK1jdxoqMSO5W6ykI0aXqdDqayMsHv4IFsbXAZlse0I rAxb3U7X5hobCA4z0oRM+8eqiR0fadCbvSjSPl32g7W8QBOc0/yxQAtGqRLKa47J0htGUnUfMxHlD RL2w8Km9vIIQ+cD49A5b6RyGpWPO3wMEnx1+OmVN2Phhg5JbVyRU1OY3VedPPZxoxN/OeqpTQuBQV AqT11s75FiLHLfPG9VUn5+W7azjBCsyJ+MULa5OxQCuQ57v7m9sgivOcZN4Q7oBh7V6HUSNotcWwi HW5hPEJQ==; Received: from 2001-1c00-8d85-4b00-266e-96ff-fe07-7dcc.cable.dynamic.v6.ziggo.nl ([2001:1c00:8d85:4b00: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 1w7vYk-0000000AQ9a-3X94; Wed, 01 Apr 2026 13:24:38 +0000 Received: by noisy.programming.kicks-ass.net (Postfix, from userid 0) id 78D273032EA; Wed, 01 Apr 2026 15:24:37 +0200 (CEST) Message-ID: <20260401132355.196370805@infradead.org> User-Agent: quilt/0.68 Date: Wed, 01 Apr 2026 15:20:21 +0200 From: Peter Zijlstra To: jstultz@google.com, kprateek.nayak@amd.com Cc: linux-kernel@vger.kernel.org, peterz@infradead.org, 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 Subject: [PATCH 2/2] sched/debug: Fix avg_vruntime() usage References: <20260401132019.057895815@infradead.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" 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 commit in question changes avg_vruntime() from a function that is a pure reader, to a function that updates variables. This turns an unlocked sched/debug usage of this function from a minor mistake into a data corruptor. Fixes: af4cf40470c2 ("sched/fair: Add cfs_rq::avg_vruntime") Fixes: b3d99f43c72b ("sched/fair: Fix zero_vruntime tracking") Reported-by: John Stultz Signed-off-by: Peter Zijlstra (Intel) Tested-by: K Prateek Nayak Tested-by: John Stultz Reviewed-by: Vincent Guittot --- kernel/sched/debug.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) --- a/kernel/sched/debug.c +++ b/kernel/sched/debug.c @@ -902,6 +902,7 @@ static void print_rq(struct seq_file *m, void print_cfs_rq(struct seq_file *m, int cpu, struct cfs_rq *cfs_rq) { s64 left_vruntime =3D -1, zero_vruntime, right_vruntime =3D -1, left_dead= line =3D -1, spread; + u64 avruntime; struct sched_entity *last, *first, *root; struct rq *rq =3D cpu_rq(cpu); unsigned long flags; @@ -925,6 +926,7 @@ void print_cfs_rq(struct seq_file *m, in if (last) right_vruntime =3D last->vruntime; zero_vruntime =3D cfs_rq->zero_vruntime; + avruntime =3D avg_vruntime(cfs_rq); raw_spin_rq_unlock_irqrestore(rq, flags); =20 SEQ_printf(m, " .%-30s: %Ld.%06ld\n", "left_deadline", @@ -934,7 +936,7 @@ void print_cfs_rq(struct seq_file *m, in SEQ_printf(m, " .%-30s: %Ld.%06ld\n", "zero_vruntime", SPLIT_NS(zero_vruntime)); SEQ_printf(m, " .%-30s: %Ld.%06ld\n", "avg_vruntime", - SPLIT_NS(avg_vruntime(cfs_rq))); + SPLIT_NS(avruntime)); SEQ_printf(m, " .%-30s: %Ld.%06ld\n", "right_vruntime", SPLIT_NS(right_vruntime)); spread =3D right_vruntime - left_vruntime;