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

Nikita Yushchenko nikita.yushchenko at virtuozzo.com
Wed Oct 13 18:26:16 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 vz7 commit 62fb4398386f ("/proc/vz/latency:
distinguish atomic allocations in irq from in task atomics."))

Signed-off-by: Konstantin Khorenko <khorenko at virtuozzo.com>

(cherry-picked from vz8 commit d8467b3fbfa2 ("/proc/vz/latency: distinguish
atomic allocations in irq from in task atomics."))

Signed-off-by: Nikita Yushchenko <nikita.yushchenko at virtuozzo.com>
---
 include/linux/kstat.h |  1 +
 kernel/ve/vzstat.c    | 21 +++++++++++++++++++--
 mm/page_alloc.c       | 10 +++++++---
 3 files changed, 27 insertions(+), 5 deletions(-)

diff --git a/include/linux/kstat.h b/include/linux/kstat.h
index e33f70fbed42..3fbd7a72092f 100644
--- a/include/linux/kstat.h
+++ b/include/linux/kstat.h
@@ -16,6 +16,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 a7ef426b1bfc..6e7dcf55c0fc 100644
--- a/kernel/ve/vzstat.c
+++ b/kernel/ve/vzstat.c
@@ -11,6 +11,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>
@@ -38,7 +39,8 @@ static const char *alloc_descr[KSTAT_ALLOCSTAT_NR] = {
 	"aloclow:",
 	"alochigh:",
 	"aloclowmp:",
-	"alochighmp:"
+	"alochighmp:",
+	"alocirq:"
 };
 
 /*
@@ -181,11 +183,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",
@@ -207,6 +210,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;
 }
 
diff --git a/mm/page_alloc.c b/mm/page_alloc.c
index 4f825ec6f1f5..cdc719098dbb 100644
--- a/mm/page_alloc.c
+++ b/mm/page_alloc.c
@@ -5449,13 +5449,17 @@ static void __alloc_collect_stats(gfp_t gfp_mask, unsigned int order,
 
 	current_clock = sched_clock();
 	delta = current_clock - time;
-	if (!(gfp_mask & __GFP_RECLAIM))
-		ind = KSTAT_ALLOCSTAT_ATOMIC;
-	else
+	if (!(gfp_mask & __GFP_RECLAIM)) {
+		if (in_task())
+			ind = KSTAT_ALLOCSTAT_ATOMIC;
+		else
+			ind = KSTAT_ALLOCSTAT_IRQ;
+	} else {
 		if (order > 0)
 			ind = KSTAT_ALLOCSTAT_LOW_MP;
 		else
 			ind = KSTAT_ALLOCSTAT_LOW;
+	}
 
 	local_irq_save(flags);
 	cpu = smp_processor_id();
-- 
2.30.2



More information about the Devel mailing list