[CRIU] [PATCH 1/5] stats: add counters for pipes and page_pipe_bufs

Andrei Vagin avagin at openvz.org
Wed Nov 8 03:36:01 MSK 2017


From: Andrei Vagin <avagin at virtuozzo.com>

The number of pipes are limited in a system, so it is better to know how
many we use.

Signed-off-by: Andrei Vagin <avagin at virtuozzo.com>
---
 criu/include/stats.h | 2 ++
 criu/page-pipe.c     | 3 +++
 criu/page-xfer.c     | 6 ++++++
 criu/stats.c         | 4 ++++
 images/stats.proto   | 2 ++
 5 files changed, 17 insertions(+)

diff --git a/criu/include/stats.h b/criu/include/stats.h
index d30be6a39..07690b8ea 100644
--- a/criu/include/stats.h
+++ b/criu/include/stats.h
@@ -26,6 +26,8 @@ enum {
 	CNT_PAGES_SKIPPED_PARENT,
 	CNT_PAGES_WRITTEN,
 	CNT_PAGES_LAZY,
+	CNT_PAGE_PIPES,
+	CNT_PAGE_PIPE_BUFS,
 
 	DUMP_CNT_NR_STATS,
 };
diff --git a/criu/page-pipe.c b/criu/page-pipe.c
index a47119b18..7da8bebc3 100644
--- a/criu/page-pipe.c
+++ b/criu/page-pipe.c
@@ -9,6 +9,7 @@
 #include "criu-log.h"
 #include "page-pipe.h"
 #include "fcntl.h"
+#include "stats.h"
 
 /* can existing iov accumulate the page? */
 static inline bool iov_grow_page(struct iovec *iov, unsigned long addr)
@@ -34,12 +35,14 @@ static struct page_pipe_buf *ppb_alloc(struct page_pipe *pp)
 	ppb = xmalloc(sizeof(*ppb));
 	if (!ppb)
 		return NULL;
+	cnt_add(CNT_PAGE_PIPE_BUFS, 1);
 
 	if (pipe(ppb->p)) {
 		xfree(ppb);
 		pr_perror("Can't make pipe for page-pipe");
 		return NULL;
 	}
+	cnt_add(CNT_PAGE_PIPES, 1);
 
 	ppb->pipe_size = fcntl(ppb->p[0], F_GETPIPE_SZ, 0) / PAGE_SIZE;
 	pp->nr_pipes++;
diff --git a/criu/page-xfer.c b/criu/page-xfer.c
index 814dc8367..f62bb6f47 100644
--- a/criu/page-xfer.c
+++ b/criu/page-xfer.c
@@ -21,6 +21,7 @@
 #include "parasite-syscall.h"
 #include "rst_info.h"
 #include "img-remote.h"
+#include "stats.h"
 
 static int page_server_sk = -1;
 
@@ -988,6 +989,11 @@ int cr_page_server(bool daemon_mode, bool lazy_dump, int cfd)
 	int sk = -1;
 	int ret;
 
+	if (init_stats(DUMP_STATS)) {
+		close(sk);
+		return -1;
+	}
+
 	if (!opts.lazy_pages)
 		up_page_ids_base();
 	else if (!lazy_dump)
diff --git a/criu/stats.c b/criu/stats.c
index 2b0c1a60b..64679b134 100644
--- a/criu/stats.c
+++ b/criu/stats.c
@@ -160,6 +160,10 @@ void write_stats(int what)
 		ds_entry.pages_skipped_parent = dstats->counts[CNT_PAGES_SKIPPED_PARENT];
 		ds_entry.pages_written = dstats->counts[CNT_PAGES_WRITTEN];
 		ds_entry.pages_lazy = dstats->counts[CNT_PAGES_LAZY];
+		ds_entry.page_pipes = dstats->counts[CNT_PAGE_PIPES];
+		ds_entry.has_page_pipes = true;
+		ds_entry.page_pipe_bufs = dstats->counts[CNT_PAGE_PIPE_BUFS];
+		ds_entry.has_page_pipe_bufs = true;
 
 		name = "dump";
 	} else if (what == RESTORE_STATS) {
diff --git a/images/stats.proto b/images/stats.proto
index ad6279a81..d76503441 100644
--- a/images/stats.proto
+++ b/images/stats.proto
@@ -14,6 +14,8 @@ message dump_stats_entry {
 	optional uint32			irmap_resolve		= 8;
 
 	required uint64			pages_lazy		= 9;
+	optional uint64			page_pipes		= 10;
+	optional uint64			page_pipe_bufs		= 11;
 }
 
 message restore_stats_entry {
-- 
2.13.6



More information about the CRIU mailing list