checkpoint-restore / criu

Checkpoint/Restore tool
criu.org
Other
2.76k stars 559 forks source link

How to make parasite code support glibc? #2393

Open sirius0118 opened 2 months ago

sirius0118 commented 2 months ago

I want to add some new functions in the parasite code, which need to call the function of glibc.

I noticed that there is a macro definition -DCR_NOGLIBC in the Makefile(criu/Makefile), so can we also use glibc without defining this macro?

If we use the implementation of the std_printf function in compel (implemented step by step by manually wrapping the system call), it will be very complicated to implement this function step by step through the system call. I tried to add a printf("hello world\n"); code to the dump_page function of criu/criu/pie/parasite.c(or others position in the parasite code). When the printf is executed, the segment error is triggered. How can I fix this?

Handle-elf-host.c can generate relocation rules, but when I add printf, there is another relocation type(R_x86_64_GOTTPOFF), which has no corresponding handling in handle-elf-host.c, so I simply skip it and don't handle this relocation.

avagin commented 2 months ago

I want to add some new functions in the parasite code, which need to call the function of glibc.

What function is it?

I noticed that there is a macro definition -DCR_NOGLIBC in the Makefile(criu/Makefile), so can we also use glibc without defining this macro?

We probably can do that, but first we need to understand why we need it.

sirius0118 commented 2 months ago

Thanks for your reply @avagin.

I want to add some new functions in the parasite code, which need to call the function of glibc.

What function is it?

I want to add the RDMA function to the parasite code. In lazy-page mode the parasite code can create connection with page-client, so the parasite code can serve the page fault request directly(maybe 5us). If we put the RDMA function in page-server, we need add once extra page copy time(maybe 2us), because RDMA transmission pages need to memory registion first, which can only regist the memory in the process' virtual memory address space.

So agfter add this function in CRIU, we can reduce the page fault serving time in lazy-page mode.

I noticed that there is a macro definition -DCR_NOGLIBC in the Makefile(criu/Makefile), so can we also use glibc without defining this macro?

We probably can do that, but first we need to understand why we need it.

If I can run glibc helper function in parasite code, I think I can relize the ibverbs function work in parasite code. And I will contribute the code to the community. Can you tell me how to modify the CRIU? It is very important for me. Thank you very much.

rst0git commented 2 months ago

I want to add the RDMA function to the parasite code. Can you tell me how to modify the CRIU?

If I recall correctly, Mike Rapoport (@rppt) had a proof-of-concept for this functionality ^1 and might be able to provide some advice on how it can be implemented.

sirius0118 commented 2 months ago

I want to add the RDMA function to the parasite code. Can you tell me how to modify the CRIU?

If I recall correctly, Mike Rapoport (@rppt) had a proof-of-concept for this functionality 12 and might be able to provide some advice on how it can be implemented.

Footnotes

  1. https://lpc.events/event/2/contributions/135/
  2. https://lpc.events/event/2/contributions/205/

Thank you very much @rst0git , your information was very effective. I had readed the slide and watched the video. But I can not seem to find an open source demo. @rppt

github-actions[bot] commented 1 month ago

A friendly reminder that this issue had no activity for 30 days.