Skip to contentSkip to conversation

tools/sched_ext: scx_nest: zero-initialize stats counter array

PATCH Applied David Carlier 2 participants 2 messages Feb 11 – Feb 12 Scheduler - sched_ext

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 tools/sched_ext: scx_nest: zero-initialize stats counter array

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.

---
 tools/sched_ext/scx_flatcg.c | 1 +
 1 file changed, 1 insertion(+)
tools/sched_ext/scx_flatcg.c +1 -0
index cd85eb401179..bea76d060201 100644
@@ -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;
Signature · 1 line
2.51.0
reviewer Applied
#1 lore raw

Applied to sched_ext/for-7.0-fixes with the subject fixed (s/scx_nest/scx_flatcg/).

Thanks.

--
tejun