[CRIU] [PATCH 01/10] Revert "memory: don't use parent memdump if detected possible pid reuse"

Pavel Tikhomirov ptikhomirov at virtuozzo.com
Tue Apr 3 12:34:17 MSK 2018


This reverts commit ffd415a5b5b8a9ef8fb99904a3c9b04ecdb3052b.

Signed-off-by: Pavel Tikhomirov <ptikhomirov at virtuozzo.com>
---
 criu/cr-dump.c     | 36 ++++-----------------------------
 criu/include/mem.h |  9 ++-------
 criu/mem.c         | 58 +-----------------------------------------------------
 criu/stats.c       |  2 +-
 4 files changed, 8 insertions(+), 97 deletions(-)

diff --git a/criu/cr-dump.c b/criu/cr-dump.c
index 094d01648..9e8425504 100644
--- a/criu/cr-dump.c
+++ b/criu/cr-dump.c
@@ -1229,7 +1229,7 @@ static int assign_parasite_pids(struct pstree_item *item, struct parasite_dump_m
 	return 0;
 }
 
-static int pre_dump_one_task(struct pstree_item *item, StatsEntry *parent_se)
+static int pre_dump_one_task(struct pstree_item *item)
 {
 	pid_t pid = item->pid->real;
 	struct vm_area_list vmas;
@@ -1289,8 +1289,6 @@ static int pre_dump_one_task(struct pstree_item *item, StatsEntry *parent_se)
 
 	mdc.pre_dump = true;
 	mdc.lazy = false;
-	mdc.stat = NULL;
-	mdc.parent_se = parent_se;
 
 	ret = parasite_dump_pages_seized(item, &vmas, &mdc, parasite_ctl);
 	if (ret)
@@ -1309,7 +1307,7 @@ static int pre_dump_one_task(struct pstree_item *item, StatsEntry *parent_se)
 	goto err_free;
 }
 
-static int dump_one_task(struct pstree_item *item, StatsEntry *parent_se)
+static int dump_one_task(struct pstree_item *item)
 {
 	pid_t pid = item->pid->real;
 	struct vm_area_list vmas;
@@ -1450,8 +1448,6 @@ static int dump_one_task(struct pstree_item *item, StatsEntry *parent_se)
 
 	mdc.pre_dump = false;
 	mdc.lazy = opts.lazy_pages;
-	mdc.stat = &pps_buf;
-	mdc.parent_se = parent_se;
 
 	ret = parasite_dump_pages_seized(item, &vmas, &mdc, parasite_ctl);
 	if (ret)
@@ -1638,7 +1634,6 @@ static int cr_pre_dump_finish(int ret)
 
 int cr_pre_dump_tasks(pid_t pid)
 {
-	StatsEntry *parent_se = NULL;
 	struct pstree_item *item;
 	int ret = -1;
 
@@ -1703,18 +1698,10 @@ int cr_pre_dump_tasks(pid_t pid)
 	if (collect_namespaces(false) < 0)
 		goto err;
 
-	/* Errors handled later in detect_pid_reuse */
-	parent_se = get_parent_stats();
-
 	for_each_pstree_item(item)
-		if (pre_dump_one_task(item, parent_se))
+		if (pre_dump_one_task(item))
 			goto err;
 
-	if (parent_se) {
-		stats_entry__free_unpacked(parent_se, NULL);
-		parent_se = NULL;
-	}
-
 	ret = cr_dump_shmem();
 	if (ret)
 		goto err;
@@ -1724,9 +1711,6 @@ int cr_pre_dump_tasks(pid_t pid)
 
 	ret = 0;
 err:
-	if (parent_se)
-		stats_entry__free_unpacked(parent_se, NULL);
-
 	return cr_pre_dump_finish(ret);
 }
 
@@ -1847,7 +1831,6 @@ static int cr_dump_finish(int ret)
 int cr_dump_tasks(pid_t pid)
 {
 	InventoryEntry he = INVENTORY_ENTRY__INIT;
-	StatsEntry *parent_se = NULL;
 	struct pstree_item *item;
 	int pre_dump_ret = 0;
 	int ret = -1;
@@ -1942,19 +1925,11 @@ int cr_dump_tasks(pid_t pid)
 	if (collect_seccomp_filters() < 0)
 		goto err;
 
-	/* Errors handled later in detect_pid_reuse */
-	parent_se = get_parent_stats();
-
 	for_each_pstree_item(item) {
-		if (dump_one_task(item, parent_se))
+		if (dump_one_task(item))
 			goto err;
 	}
 
-	if (parent_se) {
-		stats_entry__free_unpacked(parent_se, NULL);
-		parent_se = NULL;
-	}
-
 	/*
 	 * It may happen that a process has completed but its files in
 	 * /proc/PID/ are still open by another process. If the PID has been
@@ -2010,8 +1985,5 @@ int cr_dump_tasks(pid_t pid)
 	if (ret)
 		goto err;
 err:
-	if (parent_se)
-		stats_entry__free_unpacked(parent_se, NULL);
-
 	return cr_dump_finish(ret);
 }
diff --git a/criu/include/mem.h b/criu/include/mem.h
index e61e175a8..bb897c599 100644
--- a/criu/include/mem.h
+++ b/criu/include/mem.h
@@ -4,9 +4,6 @@
 #include <stdbool.h>
 #include "int.h"
 #include "vma.pb-c.h"
-#include "pid.h"
-#include "proc_parse.h"
-#include "stats.pb-c.h"
 
 struct parasite_ctl;
 struct vm_area_list;
@@ -15,10 +12,8 @@ struct pstree_item;
 struct vma_area;
 
 struct mem_dump_ctl {
-	bool			pre_dump;
-	bool			lazy;
-	struct proc_pid_stat	*stat;
-	StatsEntry		*parent_se;
+	bool	pre_dump;
+	bool	lazy;
 };
 
 extern bool vma_has_guard_gap_hidden(struct vma_area *vma);
diff --git a/criu/mem.c b/criu/mem.c
index 9ee50299b..4c6942a11 100644
--- a/criu/mem.c
+++ b/criu/mem.c
@@ -30,11 +30,9 @@
 #include "fault-injection.h"
 #include "prctl.h"
 #include <compel/compel.h>
-#include "proc_parse.h"
 
 #include "protobuf.h"
 #include "images/pagemap.pb-c.h"
-#include "images/stats.pb-c.h"
 
 static int task_reset_dirty_track(int pid)
 {
@@ -292,51 +290,6 @@ static int xfer_pages(struct page_pipe *pp, struct page_xfer *xfer)
 	return ret;
 }
 
-static int detect_pid_reuse(struct pstree_item *item,
-			    struct proc_pid_stat* pps,
-			    StatsEntry *parent_se)
-{
-	struct proc_pid_stat pps_buf;
-	unsigned long long tps; /* ticks per second */
-	int ret;
-
-	tps = sysconf(_SC_CLK_TCK);
-	if (tps == -1) {
-		pr_perror("Failed to get clock ticks via sysconf");
-		return -1;
-	}
-
-	if (!pps) {
-		pps = &pps_buf;
-		ret = parse_pid_stat(item->pid->real, pps);
-		if (ret < 0)
-			return -1;
-	}
-
-	if (!parent_se) {
-		pr_perror("No parent stats, for real error, please, " \
-			  "check warnings in get_parent_stats");
-		return -1;
-	}
-
-	if (parent_se->dump->has_dump_uptime) {
-		unsigned long long dump_ticks;
-
-		dump_ticks = parent_se->dump->dump_uptime/(USEC_PER_SEC/tps);
-
-		if (pps->start_time >= dump_ticks) {
-			/* Print "*" if unsure */
-			pr_warn("Pid reuse%s detected for pid %d\n",
-				pps_buf.start_time == dump_ticks ? "*" : "",
-				item->pid->real);
-			return 1;
-		}
-	} else
-		pr_warn_once("Parent image has no dump timestamp, " \
-			     "pid reuse detection is OFF!\n");
-	return 0;
-}
-
 static int __parasite_dump_pages_seized(struct pstree_item *item,
 		struct parasite_dump_pages_args *args,
 		struct vm_area_list *vma_area_list,
@@ -350,7 +303,6 @@ static int __parasite_dump_pages_seized(struct pstree_item *item,
 	int ret = -1;
 	unsigned cpp_flags = 0;
 	unsigned long pmc_size;
-	int possible_pid_reuse = 0;
 
 	if (opts.check_only)
 		return 0;
@@ -408,14 +360,6 @@ static int __parasite_dump_pages_seized(struct pstree_item *item,
 			xfer.parent = NULL + 1;
 	}
 
-	if (xfer.parent) {
-		possible_pid_reuse = detect_pid_reuse(item, mdc->stat,
-						      mdc->parent_se);
-		if (possible_pid_reuse == -1)
-			goto out_xfer;
-	}
-
-
 	/*
 	 * Step 1 -- generate the pagemap
 	 */
@@ -442,7 +386,7 @@ static int __parasite_dump_pages_seized(struct pstree_item *item,
 		else {
 again:
 			ret = generate_iovs(vma_area, pp, map, &off,
-				has_parent && !possible_pid_reuse);
+				has_parent);
 			if (ret == -EAGAIN) {
 				BUG_ON(!(pp->flags & PP_CHUNK_MODE));
 
diff --git a/criu/stats.c b/criu/stats.c
index d344ad336..2c880102c 100644
--- a/criu/stats.c
+++ b/criu/stats.c
@@ -213,7 +213,7 @@ void write_stats(int what)
 		display_stats(what, &stats);
 }
 
-StatsEntry *get_parent_stats(void)
+__maybe_unused StatsEntry *get_parent_stats(void)
 {
 	struct cr_img *img;
 	StatsEntry *se;
-- 
2.14.3



More information about the CRIU mailing list