[Devel] [PATCH 1/8] /proc/vz/latency: Show max latency in 2 min instead of 5sec.

Andrey Zhadchenko andrey.zhadchenko at virtuozzo.com
Fri May 21 19:26:45 MSK 2021


From: Andrey Ryabinin <aryabinin at virtuozzo.com>

Historically the "Lat" column in /proc/vz/latency showed max latency
in 5 seconds. Chnage it to max latency in the last 2 minutes, the same
as in the /proc/<pid>/vz_latency

Signed-off-by: Andrey Ryabinin <aryabinin at virtuozzo.com>

(cherry-picked from 0c5707cfcc841fa900ceda93060dccd1c682c289)
Signed-off-by: Andrey Zhadchenko <andrey.zhadchenko at virtuozzo.com>
---
 kernel/ve/vzstat.c      |  2 +-
 kernel/ve/vzstat_core.c | 17 +++++++++++------
 2 files changed, 12 insertions(+), 7 deletions(-)

diff --git a/kernel/ve/vzstat.c b/kernel/ve/vzstat.c
index 7f9fa61..0f299d8 100644
--- a/kernel/ve/vzstat.c
+++ b/kernel/ve/vzstat.c
@@ -166,7 +166,7 @@ static void lastlat_seq_show(struct seq_file *m,
 		struct kstat_lat_snap_struct *snap)
 {
 	seq_printf(m, "%-11s %20Lu %20Lu %20lu\n", name,
-			snap->maxlat[0], snap->totlat, snap->count);
+			get_max_lat(snap), snap->totlat, snap->count);
 }
 
 static void avglat_seq_show(struct seq_file *m,
diff --git a/kernel/ve/vzstat_core.c b/kernel/ve/vzstat_core.c
index 3ec69bf..7f8d346 100644
--- a/kernel/ve/vzstat_core.c
+++ b/kernel/ve/vzstat_core.c
@@ -70,8 +70,9 @@ void KSTAT_LAT_PCPU_UPDATE(struct kstat_lat_pcpu_struct *p)
 	unsigned i, cpu;
 	seqcount_t *seq;
 	u64 m;
+	u64 maxlat = 0, totlat = 0;
+	unsigned long count = 0;
 
-	memset(&p->last, 0, sizeof(p->last));
 	for_each_online_cpu(cpu) {
 		cur = per_cpu_ptr(p->cur, cpu);
 		seq = per_cpu_ptr(&kstat_pcpu_seq, cpu);
@@ -86,17 +87,21 @@ void KSTAT_LAT_PCPU_UPDATE(struct kstat_lat_pcpu_struct *p)
 		 */
 		cur->maxlat = 0;
 
-		p->last.count += snap.count;
-		p->last.totlat += snap.totlat;
-		if (p->last.maxlat[0] < snap.maxlat)
-			p->last.maxlat[0] = snap.maxlat;
+		count += snap.count;
+		totlat += snap.totlat;
+		if (maxlat < snap.maxlat)
+			maxlat = snap.maxlat;
 	}
 
-	m = (p->last.maxlat[0] > p->max_snap ? p->last.maxlat[0] : p->max_snap);
+	m = (maxlat > p->max_snap ? maxlat : p->max_snap);
 	p->avg[0] = calc_load(p->avg[0], EXP_1, m);
 	p->avg[1] = calc_load(p->avg[1], EXP_5, m);
 	p->avg[2] = calc_load(p->avg[2], EXP_15, m);
 	/* reset max_snap to calculate it correctly next time */
 	p->max_snap = 0;
+
+	p->last.count = count;
+	p->last.totlat = totlat;
+	update_maxlat(&p->last, maxlat, jiffies);
 }
 EXPORT_SYMBOL(KSTAT_LAT_PCPU_UPDATE);
-- 
1.8.3.1



More information about the Devel mailing list