[Devel] [PATCH RH8] /proc/vz/latency: distinguish atomic allocations in irq from in task atomics.

Andrey Zhadchenko andrey.zhadchenko at virtuozzo.com
Mon May 24 20:15:56 MSK 2021


From: Andrey Ryabinin <aryabinin at virtuozzo.com>

Add to /proc/vz/latency 'alocirq' allocation type which shows allocation latencies
done in irq contexts. 'alocatomic' now shows atomic allocations in task contexts.
Also add 'Per-CPU alloc irq' which shows per-cpu 'alocirq' numbers.

Example of new output:

Version: 2.6

Latencies:
Type                         Lat            Total_lat                Calls
scheduling:                    0                    0                    0
alocatomic:                    0                    0                27615
aloclow:                 2000000            738000000              3166625
alochigh:                      0                    0                    0
aloclowmp:                     0              4000000                15677
alochighmp:                    0                    0                    0
alocirq:                 1000000             81000000               292975
swap_in:                   10710              1553913                   25
page_in:                   50850           1141057002              2092877

Averages:
Type                        Avg1                 Avg5                Avg15
scheduling:                    0                    0                    0
alocatomic:                    0                    0                    0
aloclow:                  558150               313968               165801
alochigh:                      0                    0                    0
aloclowmp:                  5535                 9701                 4629
alochighmp:                    0                    0                    0
alocirq:                  309600               163409                66832
swap_in:                   29962                18540                 7244
page_in:                  177194                60133                29625

Per-CPU alloc irq:
Type                         Lat            Total_lat                Calls
cpu0                           0                    0                    3
cpu1                           0                    0                    0
cpu2                           0                    0                    0
cpu3                     1000000             87000000               316298

https://jira.sw.ru/browse/PSBM-87797
Signed-off-by: Andrey Ryabinin <aryabinin at virtuozzo.com>

Cc: Pavel Borzenkov <Pavel.Borzenkov at acronis.com>
Reviewed-by: Denis V. Lunev <den at openvz.org>

(cherry-picked from 62fb4398386fa408186cae3998d1813e833b0f63)
Signed-off-by: Andrey Zhadchenko <andrey.zhadchenko at virtuozzo.com>
---
 include/linux/kstat.h |  1 +
 kernel/ve/vzstat.c    | 21 +++++++++++++++++++--
 2 files changed, 20 insertions(+), 2 deletions(-)

diff --git a/include/linux/kstat.h b/include/linux/kstat.h
index 97a0f9b..6f4ba09 100644
--- a/include/linux/kstat.h
+++ b/include/linux/kstat.h
@@ -7,6 +7,7 @@ enum {
 	KSTAT_ALLOCSTAT_HIGH,
 	KSTAT_ALLOCSTAT_LOW_MP,
 	KSTAT_ALLOCSTAT_HIGH_MP,
+	KSTAT_ALLOCSTAT_IRQ,
 	KSTAT_ALLOCSTAT_NR,
 	KSTAT_SCHED = KSTAT_ALLOCSTAT_NR,
 	KSTAT_NR,
diff --git a/kernel/ve/vzstat.c b/kernel/ve/vzstat.c
index 0f299d8..0fb0cfb 100644
--- a/kernel/ve/vzstat.c
+++ b/kernel/ve/vzstat.c
@@ -10,6 +10,7 @@
 #include <linux/sched/task.h>
 #include <linux/sched/stat.h>
 #include <linux/module.h>
+#include <linux/cpu.h>
 #include <linux/mm.h>
 #include <linux/ve.h>
 #include <linux/ve_proto.h>
@@ -37,7 +38,8 @@
 	"aloclow:",
 	"alochigh:",
 	"aloclowmp:",
-	"alochighmp:"
+	"alochighmp:",
+	"alocirq:"
 };
 
 /*
@@ -180,11 +182,12 @@ static void avglat_seq_show(struct seq_file *m,
 static int latency_seq_show(struct seq_file *m, void *v)
 {
 	int i;
+	int cpu;
 
 	if (!v)
 		return 0;
 
-	seq_puts(m, "Version: 2.5\n");
+	seq_puts(m, "Version: 2.6\n");
 
 	seq_puts(m, "\nLatencies:\n");
 	seq_printf(m, "%-11s %20s %20s %20s\n",
@@ -206,6 +209,20 @@ static int latency_seq_show(struct seq_file *m, void *v)
 	avglat_seq_show(m, "swap_in:", kstat_glob.swap_in.avg);
 	avglat_seq_show(m, "page_in:", kstat_glob.page_in.avg);
 
+	seq_puts(m, "\nPer-CPU alloc irq:\n");
+	seq_printf(m, "%-11s %20s %20s %20s\n",
+			"Type", "Lat", "Total_lat", "Calls");
+
+	get_online_cpus();
+	for_each_online_cpu(cpu) {
+		struct kstat_lat_pcpu_snap_struct *snap;
+
+		snap = per_cpu_ptr(kstat_glob.alloc_lat[KSTAT_ALLOCSTAT_IRQ].cur, cpu);
+		seq_printf(m, "cpu%-8d %20Lu %20Lu %20lu\n", cpu,
+			snap->maxlat, snap->totlat, snap->count);
+	}
+	put_online_cpus();
+
 	return 0;
 }
 
-- 
1.8.3.1



More information about the Devel mailing list