[4/3] stats: Make dstats shmem

Submitted by Pavel Emelianov on May 21, 2019, 5:24 p.m.

Details

Message ID 2e22e825-5c3b-6354-5640-100938f32c0d@virtuozzo.com
State New
Series "stats: Fix, tune and check badly accounted dump stats"
Headers show

Commit Message

Pavel Emelianov May 21, 2019, 5:24 p.m.
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@gmail.com>
---
 criu/stats.c | 10 +++++++++-
 1 file changed, 9 insertions(+), 1 deletion(-)

Patch hide | download patch | download mbox

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;
 	}