[CRIU] [PATCH 4/3] stats: Make dstats shmem

Pavel Emelianov xemul at virtuozzo.com
Tue May 21 20:24:34 MSK 2019


Dumping shmem segments causing stats "pages written" counter to mismatch
the real pages* sizes. This is due to ipcns' dumping happens in another
process and the relevant shmem dumping counters remain in its address space.

Signed-off-by: Cyrill Gorcunov <gorcunov at gmail.com>
---
 criu/stats.c | 10 +++++++++-
 1 file changed, 9 insertions(+), 1 deletion(-)

diff --git a/criu/stats.c b/criu/stats.c
index a643835..7410b5c 100644
--- a/criu/stats.c
+++ b/criu/stats.c
@@ -201,7 +201,15 @@ void write_stats(int what)
 int init_stats(int what)
 {
 	if (what == DUMP_STATS) {
-		dstats = xzalloc(sizeof(*dstats));
+		/*
+		 * Dumping happens via one process most of the time,
+		 * so we are typically OK with the plain malloc, but
+		 * when dumping namespaces we fork() a separate process
+		 * for it and when it goes and dumps shmem segments
+		 * it will alter the CNT_SHPAGES_ counters, so we need
+		 * to have them in shmem.
+		 */
+		dstats = shmalloc(sizeof(*dstats));
 		return dstats ? 0 : -1;
 	}
 
-- 
2.1.4



More information about the CRIU mailing list