[CRIU] [PATCH 4/6] criu: dump: get stack pointers of all threads early

Mike Rapoport rppt at linux.vnet.ibm.com
Mon Aug 13 16:29:11 MSK 2018


The stack pointers will be later use by the memory dump to ensure that
current stack pages are not treated as lazy.

Signed-off-by: Mike Rapoport <rppt at linux.vnet.ibm.com>
---
 criu/include/pstree.h   |  1 +
 criu/parasite-syscall.c | 12 +++++++++++-
 2 files changed, 12 insertions(+), 1 deletion(-)

diff --git a/criu/include/pstree.h b/criu/include/pstree.h
index 4913aae..e6ad281 100644
--- a/criu/include/pstree.h
+++ b/criu/include/pstree.h
@@ -57,6 +57,7 @@ struct dmp_info {
 	struct page_pipe *mem_pp;
 	struct parasite_ctl *parasite_ctl;
 	struct parasite_thread_ctl **thread_ctls;
+	uint64_t *thread_sp;
 };
 
 static inline struct dmp_info *dmpi(const struct pstree_item *i)
diff --git a/criu/parasite-syscall.c b/criu/parasite-syscall.c
index 366c6c9..10504ed 100644
--- a/criu/parasite-syscall.c
+++ b/criu/parasite-syscall.c
@@ -468,24 +468,34 @@ static int parasite_prepare_threads(struct parasite_ctl *ctl,
 				    struct pstree_item *item)
 {
 	struct parasite_thread_ctl **thread_ctls;
+	uint64_t *thread_sp;
 	int i;
 
 	thread_ctls = xzalloc(sizeof(*thread_ctls) * item->nr_threads);
 	if (!thread_ctls)
 		return -1;
 
+	thread_sp = xzalloc(sizeof(*thread_sp) * item->nr_threads);
+	if (!thread_sp)
+		return -1;
+
 	for (i = 0; i < item->nr_threads; i++) {
 		struct pid *tid = &item->threads[i];
 
-		if (item->pid->real == tid->real)
+		if (item->pid->real == tid->real) {
+			thread_sp[i] = compel_get_leader_sp(ctl);
 			continue;
+		}
 
 		thread_ctls[i] = compel_prepare_thread(ctl, tid->real);
 		if (!thread_ctls[i])
 			return -1;
+
+		thread_sp[i] = compel_get_thread_sp(thread_ctls[i]);
 	}
 
 	dmpi(item)->thread_ctls = thread_ctls;
+	dmpi(item)->thread_sp = thread_sp;
 
 	return 0;
 }
-- 
2.7.4



More information about the CRIU mailing list