diff --git a/criu/include/seize.h b/criu/include/seize.h index 4545bf2627..3225029dd3 100644 --- a/criu/include/seize.h +++ b/criu/include/seize.h @@ -8,5 +8,6 @@ extern bool alarm_timeouted(void); extern char *task_comm_info(pid_t pid, char *comm, size_t size); extern char *__task_comm_info(pid_t pid); +extern void dont_use_freeze_cgroup(void); #endif diff --git a/criu/seize.c b/criu/seize.c index ba26072e6e..69e479fc7f 100644 --- a/criu/seize.c +++ b/criu/seize.c @@ -967,6 +967,19 @@ static int cgroup_version(void) return -1; } +static bool freeze_cgroup_disabled; + +/* + * Disables the use of freeze cgroups for process seizing, even if explicitly + * requested via the --freeze-cgroup option. This is necessary for plugins + * (e.g., CUDA) that do not function correctly when processes are frozen using + * cgroups. + */ +void __attribute__((used)) dont_use_freeze_cgroup(void) +{ + freeze_cgroup_disabled = true; +} + int collect_pstree(void) { pid_t pid = root_item->pid->real; @@ -993,12 +1006,14 @@ int collect_pstree(void) pr_debug("Detected cgroup V%d freezer\n", cgroup_v2 ? 2 : 1); - if (opts.freeze_cgroup && freeze_processes()) - goto err; - - if (!opts.freeze_cgroup && compel_interrupt_task(pid)) { - set_cr_errno(ESRCH); - goto err; + if (opts.freeze_cgroup && !freeze_cgroup_disabled) { + if (freeze_processes()) + goto err; + } else { + if (compel_interrupt_task(pid)) { + set_cr_errno(ESRCH); + goto err; + } } ret = compel_wait_task(pid, -1, parse_pid_status, NULL, &creds.s, NULL); diff --git a/plugins/cuda/cuda_plugin.c b/plugins/cuda/cuda_plugin.c index 1745454760..04d70b114f 100644 --- a/plugins/cuda/cuda_plugin.c +++ b/plugins/cuda/cuda_plugin.c @@ -483,6 +483,8 @@ int cuda_plugin_init(int stage) INIT_LIST_HEAD(&cuda_pids); } + dont_use_freeze_cgroup(); + return 0; }