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

Andrey Ryabinin aryabinin at virtuozzo.com
Wed Sep 5 12:53:20 MSK 2018


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>
---
 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 370098da3250..6cc8c0170e99 100644
--- a/kernel/ve/vzstat.c
+++ b/kernel/ve/vzstat.c
@@ -163,7 +163,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 4370c4b5c504..0e292c5103eb 100644
--- a/kernel/ve/vzstat_core.c
+++ b/kernel/ve/vzstat_core.c
@@ -69,8 +69,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);
@@ -85,17 +86,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);
 	CALC_LOAD(p->avg[0], EXP_1, m);
 	CALC_LOAD(p->avg[1], EXP_5, m);
 	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);
-- 
2.16.4



More information about the Devel mailing list