checkpoint-restore / criu

Checkpoint/Restore tool
criu.org
Other
2.9k stars 583 forks source link

How a app can know that it had been dumping by criu #2387

Closed FuwuerRyu closed 5 months ago

FuwuerRyu commented 5 months ago

How a app can know that it had been dumping by criu

adrianreber commented 5 months ago

Not really and that is the beauty of it.

You probably can detect migration by comparing MAC addresses and information from the system, but a checkpoint should not really be detectable.

Before the time namespace existed we have seen that database detect migration by reading clock monotonic and if it jumps it aborts. You could also read the local clock monotonic and if it jumps too much you could say it might be checkpointed, but I doubt that this works reliably.

If you want to signal your process that it was checkpointed you could send a signal using an action script.

I think it is really difficult to detect.

Maybe someone else has additional information.

FuwuerRyu commented 5 months ago

Not really and that is the beauty of it.

You probably can detect migration by comparing MAC addresses and information from the system, but a checkpoint should not really be detectable.

Before the time namespace existed we have seen that database detect migration by reading clock monotonic and if it jumps it aborts. You could also read the local clock monotonic and if it jumps too much you could say it might be checkpointed, but I doubt that this works reliably.

If you want to signal your process that it was checkpointed you could send a signal using an action script.

I think it is really difficult to detect.

Maybe someone else has additional information.

Could you let me know how criu stop the process before dumping it

adrianreber commented 5 months ago

Could you let me know how criu stop the process before dumping it

This is something which documented quite well. Either ptrace or cgroup freezer.

adrianreber commented 5 months ago

Why are you asking this question? If you would tell us what your goal is we could maybe help you better.

FuwuerRyu commented 5 months ago

Why are you asking this question? If you would tell us what your goal is we could maybe help you better.

Thank you very much. I am trying to migrate GPU APP with criu, so I need to dump GPU resource after criu freeze it and before criu dumpe it. If I can get the signal of freezing, I can store all GPU resources before dumping.

adrianreber commented 5 months ago

Why are you asking this question? If you would tell us what your goal is we could maybe help you better.

Thank you very much. I am trying to migrate GPU APP with criu, so I need to dump GPU resource after criu freeze it and before criu dumpe it. If I can get the signal of freezing, I can store all GPU resources before dumping.

Okay, if you control your application you can just use CRIU's action-scripts to send a signal (man 7 signal) for example. Once your applications receives your custom signal you can handle the GPU resources and once that is done CRIU can dump the non-GPU part of the process. Or you could create a file somewhere and if that file exists you can do something in you application. Or open a socket. If you control your application it should be easy to do.

FuwuerRyu commented 5 months ago

Got it. Good idea. Thank you very much again!