Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

criu: Add pidfd support #2259

Draft
wants to merge 2 commits into
base: criu-dev
Choose a base branch
from

Conversation

h0lyalg0rithm
Copy link
Contributor

No description provided.

@h0lyalg0rithm h0lyalg0rithm force-pushed the pidfd_support branch 5 times, most recently from 406a571 to 9724703 Compare September 5, 2023 21:38
@h0lyalg0rithm h0lyalg0rithm changed the title ciur: Add pidfd support criu: Add pidfd support Sep 5, 2023
@codecov-commenter
Copy link

codecov-commenter commented Sep 5, 2023

Codecov Report

Patch coverage: 8.16% and project coverage change: -0.17% ⚠️

Comparison is base (82bfb67) 70.67% compared to head (07b717f) 70.50%.

❗ Current head 07b717f differs from pull request most recent head 9b0a7ce. Consider uploading reports for the commit 9b0a7ce to get more accurate results

Additional details and impacted files
@@             Coverage Diff              @@
##           criu-dev    #2259      +/-   ##
============================================
- Coverage     70.67%   70.50%   -0.17%     
============================================
  Files           133      135       +2     
  Lines         33330    33379      +49     
============================================
- Hits          23556    23534      -22     
- Misses         9774     9845      +71     
Files Changed Coverage Δ
criu/cr-restore.c 67.38% <ø> (-0.19%) ⬇️
criu/files.c 80.45% <0.00%> (-0.39%) ⬇️
criu/include/pidfd.h 0.00% <0.00%> (ø)
criu/pidfd.c 0.00% <0.00%> (ø)
criu/proc_parse.c 67.96% <7.14%> (-0.58%) ⬇️
criu/image.c 71.58% <100.00%> (+0.15%) ⬆️

... and 6 files with indirect coverage changes

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@h0lyalg0rithm h0lyalg0rithm force-pushed the pidfd_support branch 2 times, most recently from 9d2321c to 9b0a7ce Compare September 5, 2023 22:18
@warusadura
Copy link
Member

@h0lyalg0rithm Is it ok, if I write the zdtm test for this?

@h0lyalg0rithm
Copy link
Contributor Author

@warusadura There is one bug that is to be fixed.Currently the patch lets you dump pidfd for processes which are not part of the current process tree.

I have the test prepared where I fork the test and have pidfd on the child process.
But once you try to restore the process it fails as the child process is not created yet.
One way to get around this is to wait until all the whole process tree is restored and then restore the pidfd.

I cannot think about any thing which doesnt sound hacky. What do you think?

Signed-off-by: Suraj Shirvankar <surajshirvankar@gmail.com>
@h0lyalg0rithm h0lyalg0rithm force-pushed the pidfd_support branch 2 times, most recently from 0d46cc3 to 4939627 Compare September 6, 2023 07:37
@warusadura
Copy link
Member

I cannot think about any thing which doesnt sound hacky. What do you think?

sorry @h0lyalg0rithm I'm not sure :)

PidfdEntry *pidfde = info->pidfde;

pr_info("Creating new pidfd %" PRId64 "\n", pidfde->pid);
fd = pidfd_open(pidfde->pid, 0);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

a task linked to fd can be dead and pidfd_open will fail in this case.


test_init(argc, argv);

pidfd = pidfd_open(1, 0);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The test has to create more than one pidfd linked to different tasks and then checks that they are linked to proper tasks after C/R.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@avagin I tried to write a test that would create a fork of a process and the parent process would monitor the pid of the child process. The dumping and restore process would first restore the parent process and the child process would still not be restored, hence the restore would fail.
I was thinking of restoring the pidfd after all the child processes have been restored, does that make sense.
To do this I would have to dump the pidfd seperate from the regular fd dump process.

fail();
}

if (pollfd.revents & POLLIN) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why can it be triggered?

criu/image.c Outdated

img = open_image(CR_FD_INVENTORY, O_RSTR);
if (!img)
return -1;

if (pb_read_one(img, &he, PB_INVENTORY) < 0)
loaded = pb_read_one(img, &he, PB_INVENTORY);
if (loaded < 0)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This change looks unnecessary.

@@ -100,6 +100,7 @@
#define BPFMAP_FILE_MAGIC 0x57506142 /* Alapayevsk */
#define BPFMAP_DATA_MAGIC 0x64324033 /* Arkhangelsk */
#define APPARMOR_MAGIC 0x59423047 /* Nikolskoye */
#define PIDFD_MAGIC 0x59423447
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we tend to use location coordinates of a city as a magic number. For example, Nikolskoye is a city with the following coordinates (from Wikipedia) 59°42'N 30°47'E -> 0x59423047.

Signed-off-by: Suraj Shirvankar <surajshirvankar@gmail.com>
Copy link

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants