Skip to content

Commit a678a3b

Browse files
committed
freeze_processes: fix nr_attempts calculation
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]>
1 parent 32d5a76 commit a678a3b

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

criu/seize.c

+5-3
Original file line numberDiff line numberDiff line change
@@ -542,7 +542,7 @@ static int freeze_processes(void)
542542
enum freezer_state state = THAWED;
543543

544544
static const unsigned long step_ms = 100;
545-
unsigned long nr_attempts = (opts.timeout * 1000000) / step_ms;
545+
unsigned long nr_attempts = (opts.timeout * 1000) / step_ms;
546546
unsigned long i = 0;
547547

548548
const struct timespec req = {
@@ -555,7 +555,7 @@ static int freeze_processes(void)
555555
* If timeout is turned off, lets
556556
* wait for at least 10 seconds.
557557
*/
558-
nr_attempts = (10 * 1000000) / step_ms;
558+
nr_attempts = (10 * 1000) / step_ms;
559559
}
560560

561561
pr_debug("freezing processes: %lu attempts with %lu ms steps\n", nr_attempts, step_ms);
@@ -594,8 +594,10 @@ static int freeze_processes(void)
594594

595595
if (state == FROZEN)
596596
break;
597-
if (alarm_timeouted())
597+
if (alarm_timeouted()) {
598+
pr_err("Unable to freeze cgroup %s (timed out)\n", opts.freeze_cgroup);
598599
goto err;
600+
}
599601
nanosleep(&req, NULL);
600602
}
601603

0 commit comments

Comments
 (0)