Skip to content

Commit

Permalink
criu: Allow disabling freeze cgroups
Browse files Browse the repository at this point in the history
Some plugins (e.g., CUDA) may not function correctly when processes are
frozen using cgroups. This change introduces a mechanism to disable the
use of freeze cgroups during process seizing, even if explicitly
requested via the --freeze-cgroup option.

The CUDA plugin is updated to utilize this new mechanism to ensure
compatibility.

Signed-off-by: Andrei Vagin <[email protected]>
  • Loading branch information
avagin committed Sep 12, 2024
1 parent 4ca4a09 commit d77f04c
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 6 deletions.
1 change: 1 addition & 0 deletions criu/include/seize.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
27 changes: 21 additions & 6 deletions criu/seize.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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);
Expand Down
2 changes: 2 additions & 0 deletions plugins/cuda/cuda_plugin.c
Original file line number Diff line number Diff line change
Expand Up @@ -483,6 +483,8 @@ int cuda_plugin_init(int stage)
INIT_LIST_HEAD(&cuda_pids);
}

dont_use_freeze_cgroup();

return 0;
}

Expand Down

0 comments on commit d77f04c

Please sign in to comment.