Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Freeze fixes and v1 kludges #2545

Open
wants to merge 2 commits into
base: criu-dev
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 33 additions & 3 deletions criu/seize.c
Original file line number Diff line number Diff line change
Expand Up @@ -542,7 +542,7 @@
enum freezer_state state = THAWED;

static const unsigned long step_ms = 100;
unsigned long nr_attempts = (opts.timeout * 1000000) / step_ms;
unsigned long nr_attempts = (opts.timeout * 1000) / step_ms;
unsigned long i = 0;

const struct timespec req = {
Expand All @@ -555,7 +555,7 @@
* If timeout is turned off, lets
* wait for at least 10 seconds.
*/
nr_attempts = (10 * 1000000) / step_ms;
nr_attempts = (10 * 1000) / step_ms;
}

pr_debug("freezing processes: %lu attempts with %lu ms steps\n", nr_attempts, step_ms);
Expand Down Expand Up @@ -594,9 +594,39 @@

if (state == FROZEN)
break;
if (alarm_timeouted())
if (alarm_timeouted()) {
pr_err("Unable to freeze cgroup %s (timed out)\n", opts.freeze_cgroup);
goto err;
}
nanosleep(&req, NULL);

if (cgroup_v2)
continue;

/* As per older kernel docs (freezer-subsystem.txt before
* the kernel commit ef9fe980c6fcc1821), if FREEZING is seen,
* userspace should either retry or thaw. While current
* kernel cgroup v1 docs no longer mention a need to retry,
* even recent kernels can't reliably freeze a cgroup v1.
*
* Let's keep asking the kernel to freeze from time to time.
* In addition, do occasional thaw/sleep/freeze.
*
* This is still a game of chances (the real fix belongs to the kernel)
* but these kludges might improve the probability of success.
*
* Cgroup v2 does not have this problem.
*/
switch (i%32) {

Check warning on line 620 in criu/seize.c

View workflow job for this annotation

GitHub Actions / build

case 30:
freezer_write_state(fd, THAWED);
break;
case 9:
case 20:
case 31:
freezer_write_state(fd, FROZEN);
break;
}
}

if (i > nr_attempts) {
Expand Down
Loading