[Devel] [PATCH vz10] vzstat: store calc_load() result back into kstat_glob.nr_unint_avg[]
Konstantin Khorenko
khorenko at virtuozzo.com
Thu Jun 4 12:08:30 MSK 2026
calc_load() is a pure function that returns the updated load average; it
does not modify its first argument (passed by value). calc_load_ve()
computed the three nr_unint_avg[] values but discarded the return value:
calc_load(kstat_glob.nr_unint_avg[0], EXP_1, nr_unint);
calc_load(kstat_glob.nr_unint_avg[1], EXP_5, nr_unint);
calc_load(kstat_glob.nr_unint_avg[2], EXP_15, nr_unint);
so kstat_glob.nr_unint_avg[] stayed 0 forever and the "Processes avg:
unint" line of the vzstat output always reported 0. The neighbouring
per-tg avenrun update in the same file does it correctly
(tg->avenrun[i] = calc_load(tg->avenrun[i], ...)).
Assign the result back, matching the avenrun pattern.
Fixes: a9c243968603 ("vzstat: Add kstat_glob.nr_unint_avg real accounting")
https://virtuozzo.atlassian.net/browse/VSTOR-132310
Signed-off-by: Konstantin Khorenko <khorenko at virtuozzo.com>
---
kernel/sched/loadavg.c | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/kernel/sched/loadavg.c b/kernel/sched/loadavg.c
index a69358e4951d..bc0b6bcdae2d 100644
--- a/kernel/sched/loadavg.c
+++ b/kernel/sched/loadavg.c
@@ -161,9 +161,9 @@ void calc_load_ve(void)
nr_unint = nr_uninterruptible() * FIXED_1;
write_seqcount_begin(&kstat_glob.nr_unint_avg_seq);
- calc_load(kstat_glob.nr_unint_avg[0], EXP_1, nr_unint);
- calc_load(kstat_glob.nr_unint_avg[1], EXP_5, nr_unint);
- calc_load(kstat_glob.nr_unint_avg[2], EXP_15, nr_unint);
+ kstat_glob.nr_unint_avg[0] = calc_load(kstat_glob.nr_unint_avg[0], EXP_1, nr_unint);
+ kstat_glob.nr_unint_avg[1] = calc_load(kstat_glob.nr_unint_avg[1], EXP_5, nr_unint);
+ kstat_glob.nr_unint_avg[2] = calc_load(kstat_glob.nr_unint_avg[2], EXP_15, nr_unint);
write_seqcount_end(&kstat_glob.nr_unint_avg_seq);
}
#endif /* CONFIG_VE */
--
2.47.1
More information about the Devel
mailing list