From 4c39f68155eed97bf2c47a90631ae70b4b200a6a Mon Sep 17 00:00:00 2001 From: Radostin Stoyanov Date: Sat, 21 Dec 2024 14:17:35 +0000 Subject: [PATCH] seize: use separate checkpoint_devices function Move `run_plugins(CHECKPOINT_DEVICES)` out of `collect_pstree()` to ensure that the function's sole responsibility is to use the cgroup freezer for the process tree. This allows us to avoid a time-out error when checkpointing applications with large GPU state. v2: This patch calls `checkpoint_devices()` only for `criu dump`. Support for GPU checkpointing with `pre-dump` will be introduced in a separate patch. Suggested-by: Andrei Vagin Suggested-by: Jesus Ramos Signed-off-by: Radostin Stoyanov --- criu/cr-dump.c | 3 +++ criu/include/seize.h | 1 + criu/seize.c | 23 ++++++++++++++++------- 3 files changed, 20 insertions(+), 7 deletions(-) diff --git a/criu/cr-dump.c b/criu/cr-dump.c index 1bc5d934f5..302078caa0 100644 --- a/criu/cr-dump.c +++ b/criu/cr-dump.c @@ -2192,6 +2192,9 @@ int cr_dump_tasks(pid_t pid) if (collect_pstree()) goto err; + if (checkpoint_devices()) + goto err; + if (collect_pstree_ids()) goto err; diff --git a/criu/include/seize.h b/criu/include/seize.h index 64e8d2d12f..fc7facad37 100644 --- a/criu/include/seize.h +++ b/criu/include/seize.h @@ -2,6 +2,7 @@ #define __CR_SEIZE_H__ extern int collect_pstree(void); +extern int checkpoint_devices(void); struct pstree_item; extern void pstree_switch_state(struct pstree_item *root_item, int st); extern const char *get_real_freezer_state(void); diff --git a/criu/seize.c b/criu/seize.c index 007e8e580d..f56357ac7b 100644 --- a/criu/seize.c +++ b/criu/seize.c @@ -1050,7 +1050,6 @@ int collect_pstree(void) pid_t pid = root_item->pid->real; int ret, exit_code = -1; struct proc_status_creds creds; - struct pstree_item *iter; timing_start(TIME_FREEZING); @@ -1111,6 +1110,21 @@ int collect_pstree(void) goto err; } + exit_code = 0; + timing_stop(TIME_FREEZING); + timing_start(TIME_FROZEN); + +err: + /* Freezing stage finished in time - disable timer. */ + alarm(0); + return exit_code; +} + +int checkpoint_devices(void) +{ + struct pstree_item *iter; + int ret, exit_code = -1; + for_each_pstree_item(iter) { if (!task_alive(iter)) continue; @@ -1120,11 +1134,6 @@ int collect_pstree(void) } exit_code = 0; - timing_stop(TIME_FREEZING); - timing_start(TIME_FROZEN); - err: - /* Freezing stage finished in time - disable timer. */ - alarm(0); return exit_code; -} +} \ No newline at end of file