Skip to content

Commit

Permalink
criu: Restore rseq_cs state slightly earlier in the restore sequence …
Browse files Browse the repository at this point in the history
…and run the plugin finalizer later in the dump sequence

Restore rseq_cs state before calling RESUME_DEVICES_LATE as the CUDA plugin will
temporarily unfreeze a thread during the plugin hook to assist with device
restore

Run the plugin finalizer later in the dump sequence since the finalizer is used
by the CUDA plugin to handle some process cleanup

Signed-off-by: Jesus Ramos <[email protected]>
  • Loading branch information
jesus-ramos committed Jun 7, 2024
1 parent 9eaab45 commit 1d383a7
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 5 deletions.
4 changes: 3 additions & 1 deletion criu/cr-dump.c
Original file line number Diff line number Diff line change
Expand Up @@ -2035,7 +2035,6 @@ static int cr_dump_finish(int ret)
if (bfd_flush_images())
ret = -1;

cr_plugin_fini(CR_PLUGIN_STAGE__DUMP, ret);
cgp_fini();

if (!ret) {
Expand Down Expand Up @@ -2089,6 +2088,9 @@ static int cr_dump_finish(int ret)

if (arch_set_thread_regs(root_item, true) < 0)
return -1;

cr_plugin_fini(CR_PLUGIN_STAGE__DUMP, ret);

pstree_switch_state(root_item, (ret || post_dump_ret) ? TASK_ALIVE : opts.final_state);
timing_stop(TIME_FROZEN);
free_pstree(root_item);
Expand Down
9 changes: 5 additions & 4 deletions criu/cr-restore.c
Original file line number Diff line number Diff line change
Expand Up @@ -2224,6 +2224,11 @@ static int restore_root_task(struct pstree_item *init)
}

finalize_restore();

/* just before releasing threads we have to restore rseq_cs */
if (restore_rseq_cs())
pr_err("Unable to restore rseq_cs state\n");

/*
* Some external devices such as GPUs might need a very late
* trigger to kick-off some events, memory notifiers and for
Expand Down Expand Up @@ -2255,10 +2260,6 @@ static int restore_root_task(struct pstree_item *init)
if (restore_freezer_state())
pr_err("Unable to restore freezer state\n");

/* just before releasing threads we have to restore rseq_cs */
if (restore_rseq_cs())
pr_err("Unable to restore rseq_cs state\n");

/* Detaches from processes and they continue run through sigreturn. */
if (finalize_restore_detach())
goto out_kill_network_unlocked;
Expand Down

0 comments on commit 1d383a7

Please sign in to comment.