From d28996b46516ca11c97434935ee1430ed36c021d Mon Sep 17 00:00:00 2001 From: Liu Hua Date: Mon, 14 Oct 2024 19:41:00 +0800 Subject: [PATCH] uffd: add config to disable fetch memory data in the background Signed-off-by: Liu Hua --- criu/cr-restore.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/criu/cr-restore.c b/criu/cr-restore.c index d5b6c8037a..83e7ce9157 100644 --- a/criu/cr-restore.c +++ b/criu/cr-restore.c @@ -116,6 +116,7 @@ #endif struct pstree_item *current; +static bool disable_background_lazy_page_fetch; static int restore_task_with_children(void *); static int sigreturn_restore(pid_t pid, struct task_restore_args *ta, unsigned long alen, CoreEntry *core); @@ -2213,7 +2214,7 @@ static int restore_root_task(struct pstree_item *init) goto out_kill_network_unlocked; } - if (lazy_pages_finish_restore()) + if (!disable_background_lazy_page_fetch && lazy_pages_finish_restore()) goto out_kill_network_unlocked; __restore_switch_stage(CR_STATE_COMPLETE); @@ -3499,3 +3500,8 @@ static int sigreturn_restore(pid_t pid, struct task_restore_args *task_args, uns exit(1); return -1; } + +static void __attribute__((constructor)) pagemap_cache_init(void) +{ + disable_background_lazy_page_fetch = (getenv("CRIU_DISABLE_BACKGROUND_LAZY_PAGE_FETCH") != NULL); +}