All of lore.kernel.org
 help / color / mirror / Atom feed
From: David Carlier <devnexen@gmail.com>
To: Tejun Heo <tj@kernel.org>, David Vernet <dvernet@meta.com>
Cc: linux-kernel@vger.kernel.org, David Carlier <devnexen@gmail.com>
Subject: [PATCH] tools/sched_ext: scx_nest: zero-initialize stats counter array
Date: Wed, 11 Feb 2026 21:52:13 +0000	[thread overview]
Message-ID: <20260211215213.917724-1-devnexen@gmail.com> (raw)

The local cnts array in read_stats() is not initialized before being
accumulated into per-CPU stats, which may lead to reading garbage
values. Zero it out with memset alongside the existing stats array
initialization.

Signed-off-by: David Carlier <devnexen@gmail.com>
---
 tools/sched_ext/scx_flatcg.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/tools/sched_ext/scx_flatcg.c b/tools/sched_ext/scx_flatcg.c
index cd85eb401179..bea76d060201 100644
--- a/tools/sched_ext/scx_flatcg.c
+++ b/tools/sched_ext/scx_flatcg.c
@@ -106,6 +106,7 @@ static void fcg_read_stats(struct scx_flatcg *skel, __u64 *stats)
 	__u32 idx;
 
 	memset(stats, 0, sizeof(stats[0]) * FCG_NR_STATS);
+	memset(cnts, 0, sizeof(cnts));
 
 	for (idx = 0; idx < FCG_NR_STATS; idx++) {
 		int ret, cpu;
-- 
2.51.0


             reply	other threads:[~2026-02-11 21:52 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-02-11 21:52 David Carlier [this message]
2026-02-12 17:29 ` [PATCH] tools/sched_ext: scx_nest: zero-initialize stats counter array Tejun Heo

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20260211215213.917724-1-devnexen@gmail.com \
    --to=devnexen@gmail.com \
    --cc=dvernet@meta.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=tj@kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.