From 7d6d795d28109a0bfc973face7cdf7de16b97032 Mon Sep 17 00:00:00 2001 From: Andrei Vagin Date: Wed, 8 Nov 2017 03:36:01 +0300 Subject: [PATCH] stats: add counters for pipes and page_pipe_bufs The number of pipes are limited in a system, so it is better to know how many we use. Acked-by: Mike Rapoport Signed-off-by: Andrei Vagin --- criu/include/stats.h | 2 ++ criu/page-pipe.c | 3 +++ criu/page-xfer.c | 4 ++++ criu/stats.c | 4 ++++ images/stats.proto | 2 ++ 5 files changed, 15 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 63c5a8a75..518248aaf 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 7ba50502c..86f1e6692 100644 --- a/criu/page-xfer.c +++ b/criu/page-xfer.c @@ -20,6 +20,7 @@ #include "pstree.h" #include "parasite-syscall.h" #include "rst_info.h" +#include "stats.h" static int page_server_sk = -1; @@ -966,6 +967,9 @@ int cr_page_server(bool daemon_mode, bool lazy_dump, int cfd) int sk = -1; int ret; + if (init_stats(DUMP_STATS)) + 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 {