Skip to content

Commit

Permalink
freeze_processes: fix nr_attempts calculation
Browse files Browse the repository at this point in the history
Commit 9fae23f grossly (by 1000x) miscalculated the number
of attempts required, as a result, we are seeing something like this:

> (00.000340) freezing processes: 100000 attempts with 100 ms steps
> (00.000351) freezer.state=THAWED
> (00.000358) freezer.state=FREEZING
> (00.100446) freezer.state=FREEZING
> ...close to 100 lines skipped...
> (09.915110) freezer.state=FREEZING
> (10.000432) Error (criu/cr-dump.c:1467): Timeout reached. Try to interrupt: 0
> (10.000563) freezer.state=FREEZING

For 10s with 100ms steps we only need 100 attempts, not 100000.

While at it, add an error print in case we hit the timeout earlier than
i reaches nr_attempts.

Signed-off-by: Kir Kolyshkin <[email protected]>
  • Loading branch information
kolyshkin committed Dec 16, 2024
1 parent 32d5a76 commit a678a3b
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions criu/seize.c
Original file line number Diff line number Diff line change
Expand Up @@ -542,7 +542,7 @@ static int freeze_processes(void)
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 @@ static int freeze_processes(void)
* 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,8 +594,10 @@ static int freeze_processes(void)

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);
}

Expand Down

0 comments on commit a678a3b

Please sign in to comment.