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

Refactor criu plugin baseline v1 #2295

Open
wants to merge 179 commits into
base: criu-dev
Choose a base branch
from

Conversation

rerrabolu
Copy link
Contributor

No description provided.

prakritigoyal19 and others added 30 commits June 11, 2023 23:30
Change made through this commit:
- Include copy of flog as a seperate tree.
- Modify the makefile to add and compile flog code.

Signed-off-by: prakritigoyal19 <[email protected]>
CID 302713 (checkpoint-restore#1 of 1): Missing varargs init or cleanup (VARARGS)
 va_end was not called for argptr.

Signed-off-by: Adrian Reber <[email protected]>
Separate commit for easier criu-dev <-> master transfer.

Acked-by: Mike Rapoport <[email protected]>
Signed-off-by: Adrian Reber <[email protected]>
It is mapped, not maped. Same applies for mmap I guess.

Found by codespell, except it wants to change it to mapped,
which will make it less specific.

Signed-off-by: Kir Kolyshkin <[email protected]>
Brought to you by

    codespell -w

(using codespell v2.1.0).

[v2: use "make indent" on the result]

Signed-off-by: Kir Kolyshkin <[email protected]>
The TOS(type of service) field in the ip header allows you specify the
priority of the socket data.

Signed-off-by: Suraj Shirvankar <[email protected]>
The pipe_size type is unsigned int, when the fcntl call fails and
return -1, it will cause a negative rollover problem.

Signed-off-by: zhoujie <[email protected]>
Newer Intel CPUs (Sapphire Rapids) have a much larger xsave area than
before. Looking at older CPUs I see 2440 bytes.

    # cpuid -1 -l 0xd -s 0
    ...
        bytes required by XSAVE/XRSTOR area     = 0x00000988 (2440)

On newer CPUs (Sapphire Rapids) it grows to 11008 bytes.

    # cpuid -1 -l 0xd -s 0
    ...
        bytes required by XSAVE/XRSTOR area     = 0x00002b00 (11008)

This increase the xsave area from one page to four pages.

Without this patch the fpu03 test fails, with this patch it works again.

Signed-off-by: Adrian Reber <[email protected]>
Using the fact that we know criu_pid and criu is a parent of restored
process we can create pidfile with pid on caller pidns level.

We need to move mount namespace creation to child so that criu-ns can
see caller pidns proc.

Signed-off-by: Pavel Tikhomirov <[email protected]>
By default, the file name 'amdgpu_plugin.txt' is used also as the name
for the corresponding man page (`man amdgpu_plugin`). However, when
this man page is installed system-wide it would be more appropriate
to have a prefix 'criu-' (e.g., `man criu-amdgpu-plugin`).

Signed-off-by: Radostin Stoyanov <[email protected]>
crun wants to set empty_ns and this interface is missing from the
library. This adds it to libcriu.

Signed-off-by: Adrian Reber <[email protected]>
--criu-binary argument provides a way to supply the CRIU binary
location to run_criu().

Related to: checkpoint-restore#1909

Signed-off-by: Dhanuka Warusadura <[email protected]>
These changes remove and update the changes introduced in
7177938 in favor of the
Python version in CI.

os.waitstatus_to_exitcode() function appeared in Python 3.9

Related to: checkpoint-restore#1909

Signed-off-by: Dhanuka Warusadura <[email protected]>
These changes add test implementations for criu-ns script.

Fixes: checkpoint-restore#1909

Signed-off-by: Dhanuka Warusadura <[email protected]>
These changes fix the `ImportError: No module named pathlib`
error when executing criu-ns tests located at criu/test/others/criu-ns

Signed-off-by: Dhanuka Warusadura <[email protected]>
CentOS 7 CI environment uses Python 2. To execute criu-ns
script in CentOS 7 changing the current shebang line to
python is required.

This reverse the changes made in a15a63f

Signed-off-by: Dhanuka Warusadura <[email protected]>
This is a patch proposed by Thomas here:
https://lore.kernel.org/all/87ilczc7d9.ffs@tglx/

It removes (created id > desired id) "sanity" check and adds proper
checking that ids start at zero and increment by one each time when we
create/delete a posix timer.

First purpose of it is to fix infinite looping in create_posix_timers on
old pre 3.11 kernels.

Second purpose is to allow kernel interface of creating posix timers
with desired id change from iterating with predictable next id to just
setting next id directly. And at the same time removing predictable next
id so that criu with this patch would not get to infinite loop in
create_posix_timers if this happens.

Thanks a lot to Thomas!

Signed-off-by: Pavel Tikhomirov <[email protected]>
This hook allows to start image streamer process from an action script.

Signed-off-by: Radostin Stoyanov <[email protected]>
…tions

This does cgroup namespace creation separately from joining task
cgroups. This makes the code more logical, because creating cgroup
namespace also involves joining cgroups but these cgroups can be
different to task's cgroups as they are cgroup namespace roots
(cgns_prefix), and mixing all of them together may lead to
misunderstanding.

Another positive thing is that we consolidate !item->parent checks in
one place in restore_task_with_children.

Signed-off-by: Valeriy Vdovin <[email protected]>
Signed-off-by: Pavel Tikhomirov <[email protected]>
4.15-based kernels don't allow F_*SEAL for memfds created with MFD_HUGETLB.
Since seals are not possible in this case, fake F_GETSEALS result as if it
was queried for a non-sealing-enabled memfd.

Signed-off-by: Michał Mirosław <[email protected]>
Linux 4.15 doesn't like empty string for cgroup2 mount options.
Pass NULL then to satisfy the kernel check. Log the options for
easier debugging.

Signed-off-by: Michał Mirosław <[email protected]>
The original commit added saving THP_DISABLED flag value, but missed
restoring it. There is restoring code, but used only when --lazy_pages
mode is enabled. Restore the prctl flag always. While at it, rename the
`has_thp_enabled` -> `!thp_disabled` for consistency.

Fixes: bbbd597 (2017-06-28 "mem: add dump state of THP_DISABLED prctl")
Signed-off-by: Michał Mirosław <[email protected]>
If prctl(SET_THP_DISABLE) is not used due to bad semantics, log it
for easier debugging.

Signed-off-by: Michał Mirosław <[email protected]>
While at it, don't carry over stale errno to the fail() message.

Signed-off-by: Michał Mirosław <[email protected]>
Add a sanity check for THP_DISABLE. This discovered a broken commit
in Google's kernel tree.

Signed-off-by: Michał Mirosław <[email protected]>
Taemin Ha and others added 12 commits October 8, 2023 08:47
The is_native field is a boolean. Therefore, else if() should can be
changed to a simple else{}.

Signed-off-by: Taemin Ha <[email protected]>
Signed-off-by: Andrei Vagin <[email protected]>
The condition meant to check fd2 instead of fd1, which is checked in
line 24.

Signed-off-by: Taemin Ha <[email protected]>
Signed-off-by: Andrei Vagin <[email protected]>
line 131 checks if (ret >= 0). line 133 could be replaced by a simple else statement

Signed-off-by: Taemin Ha <[email protected]>
Signed-off-by: Andrei Vagin <[email protected]>
Eventpollentry's fields are set only when ret == 3 or ret == 6. The
remaining cases can be grouped together to an error

Signed-off-by: Taemin Ha <[email protected]>
Signed-off-by: Andrei Vagin <[email protected]>
At this point the correct position is already restored, so reading from
the fd results in the position being moved forward by 5 bytes.

Fixes: 9191f87 ("criu/files-reg.c: add build-id validation functionality")
Signed-off-by: Michal Clapinski <[email protected]>
cgroup_ifpriomap test needs net_prio cgroup, which might not be
available. Make the .checkskip script check it.

Signed-off-by: Michał Mirosław <[email protected]>
Newer versions of pip use an isolated virtual environment when building
Python projects. However, when the source code of CRIT is copied into
the isolated environment, the symlink for `../lib/py` (pycriu) becomes
invalid. As a workaround, we used the `--no-build-isolation` option for
`pip install`. However, this functionality has issues in some versions
of PIP [1, 2]. To fix this problem, this patch adds separate packages
for pycriu and crit, and each package is installed independently.

[1] pypa/pip#8221
[2] pypa/pip#8165 (comment)

Signed-off-by: Radostin Stoyanov <[email protected]>
Do not use $(USERCFLAGS) for anything other than what the user provide.

Signed-off-by: Marcus Folkesson <[email protected]>
…vices

Add a new compilation unit to host symbols and methods that will be
needed to C&R DRM devices. Refactor code that indicates support for
C&R and checkpoints KFD and DRM devices

Signed-off-by: Ramesh Errabolu <[email protected]>
Refactor code used to Checkpoint DRM devices. Code is moved
into amdgpu_plugin_drm.c file which hosts various methods to
checkpoint and restore a workload.

Signed-off-by: Ramesh Errabolu <[email protected]>
@rerrabolu
Copy link
Contributor Author

Could someone advise me as to what is blocking? The 3 tests that are failing are doing so in "build" phase. It is not clear how that is connected to my change. What are the next steps

@Snorch
Copy link
Member

Snorch commented Nov 10, 2023

# 1  DCO
Commit sha: [ff42a4f](https://github.com/checkpoint-restore/criu/pull/2295/commits/ff42a4f97f41849c45f5331dfa3c1b5840baa028), Author: Ramesh Errabolu, Committer: GitHub; The sign-off is missing.

# 2 CentOS Stream 8 based test
------------------------ grep Error ------------------------
b'(00.011876)     53: cg: setting cgns prefix to /system.slice/google-startup-scripts.service'
b'(00.011883)     53: cg: setting cgns prefix to /system.slice/google-startup-scripts.service'
b'(00.011890)     53: cg: setting cgns prefix to /system.slice/google-startup-scripts.service'
b'(00.011898)     53: cg: setting cgns prefix to /test'
b"(00.011905)     53: Error (criu/cgroup.c:1135): cg: Can't move 53 into zdtmtst//test/cgroup.procs (-1/-1): No such file or directory"
b"(00.011907)     53: Error (criu/cgroup.c:1191): cg: couldn't set cgns prefix zdtmtst//test/cgroup.procs: No such file or directory"
b'(00.011909)     53: Error (criu/cgroup.c:1282): cg: failed preparing cgns'
b'(00.012183) Error (criu/cr-restore.c:1513): 53 exited, status=1'
b'(00.012190) Error (criu/cr-restore.c:2557): Restoring FAILED.'
b'(00.016876) Error (criu/cgroup.c:1970): cg: cgroupd: recv req error: No such file or directory'
------------------------ ERROR OVER ------------------------
################ Test zdtm/static/cgroupns FAIL at CRIU restore ################

# 3 CentOS Stream 9 based test
gcc -g -Wall -Werror -D _GNU_SOURCE -shared -nostartfiles -fPIC -DCR_PLUGIN_DEFAULT="/usr/local/lib/criu" -I ../../compel/include/uapi amdgpu_plugin.c amdgpu_plugin_drm.c amdgpu_plugin_topology.c amdgpu_plugin_util.c criu-amdgpu.pb-c.c -o amdgpu_plugin.so -iquote../../include -iquote../../criu/include -iquote../../criu/arch/x86/include/ -iquote../../ -lpthread -lrt -ldrm -ldrm_amdgpu -I/usr/include/libdrm
/usr/bin/ld: /tmp/ccrGAnOx.o:/tmp/criu/plugins/amdgpu/amdgpu_plugin_util.c:52: multiple definition of `fd_next'; /tmp/cczVlqFR.o:/tmp/criu/plugins/amdgpu/amdgpu_plugin_topology.c:69: first defined here
/usr/bin/ld: /tmp/ccrGAnOx.o:/tmp/criu/plugins/amdgpu/amdgpu_plugin_util.c:54: multiple definition of `kfd_fw_version_check'; /tmp/cczVlqFR.o:/tmp/criu/plugins/amdgpu/amdgpu_plugin_topology.c:50: first defined here
/usr/bin/ld: /tmp/ccrGAnOx.o:/tmp/criu/plugins/amdgpu/amdgpu_plugin_util.c:55: multiple definition of `kfd_sdma_fw_version_check'; /tmp/cczVlqFR.o:/tmp/criu/plugins/amdgpu/amdgpu_plugin_topology.c:52: first defined here
/usr/bin/ld: /tmp/ccrGAnOx.o:/tmp/criu/plugins/amdgpu/amdgpu_plugin_util.c:56: multiple definition of `kfd_caches_count_check'; /tmp/cczVlqFR.o:/tmp/criu/plugins/amdgpu/amdgpu_plugin_topology.c:54: first defined here
/usr/bin/ld: /tmp/ccrGAnOx.o:/tmp/criu/plugins/amdgpu/amdgpu_plugin_util.c:57: multiple definition of `kfd_num_gws_check'; /tmp/cczVlqFR.o:/tmp/criu/plugins/amdgpu/amdgpu_plugin_topology.c:56: first defined here
/usr/bin/ld: /tmp/ccrGAnOx.o:/tmp/criu/plugins/amdgpu/amdgpu_plugin_util.c:58: multiple definition of `kfd_vram_size_check'; /tmp/cczVlqFR.o:/tmp/criu/plugins/amdgpu/amdgpu_plugin_topology.c:58: first defined here
/usr/bin/ld: /tmp/ccrGAnOx.o:/tmp/criu/plugins/amdgpu/amdgpu_plugin_util.c:59: multiple definition of `kfd_numa_check'; /tmp/cczVlqFR.o:/tmp/criu/plugins/amdgpu/amdgpu_plugin_topology.c:60: first defined here
/usr/bin/ld: /tmp/ccrGAnOx.o:/tmp/criu/plugins/amdgpu/amdgpu_plugin_util.c:60: multiple definition of `kfd_capability_check'; /tmp/cczVlqFR.o:/tmp/criu/plugins/amdgpu/amdgpu_plugin_topology.c:62: first defined here
collect2: error: ld returned 1 exit status
make[3]: *** [Makefile:32: amdgpu_plugin.so] Error 1
make[2]: *** [Makefile:347: amdgpu_plugin] Error 2
make[2]: Leaving directory '/tmp/criu'
make[1]: *** [Makefile:4: run] Error 2
make[1]: Leaving directory '/tmp/criu/test/others/make'
+ cleanup_cgroup
+ ./test/zdtm_umount_cgroups 12456
make: *** [Makefile:2: local] Error 2
make: Leaving directory '/tmp/criu/scripts/ci'

# 4 Vagrant Fedora Rawhide based test 
------------------------ grep Error ------------------------
b'(00.031043)     59: net: \tRunning ip rule delete table local'
b'(00.034514)     59: net: \tRunning ip rule restore'
b'(00.051113)     59: net: \tRunning iptables-restore -w for iptables-restore -w'
b'(00.055342)     59: net: \tRunning ip6tables-restore -w for ip6tables-restore -w'
b'(00.060395)     59: Error (criu/libnetlink.c:54): -16 reported by netlink: Device or resource busy'
b"(00.060445)     59: Error (criu/util.c:1495): Can't wait or bad status: errno=0, status=65280"
b'(00.060792) Error (criu/cr-restore.c:2557): Restoring FAILED.'
------------------------ ERROR OVER ------------------------
######### Test zdtm/static/socket-tcp-nfconntrack FAIL at CRIU restore #########

You can just enter details section of each check and see errors by yourself. 1 and 3 are obviously introduced by your code, so you should fix them. 4 is definitely unrelated to your code as I saw it in other PRs, 2 is likely unrelated - I triggered a rerun for it. I also approved all checks for your PR, so you may expect some more fails.

@codecov-commenter
Copy link

Codecov Report

All modified and coverable lines are covered by tests ✅

Comparison is base (c474816) 70.55% compared to head (3ad74b3) 70.62%.

❗ Current head 3ad74b3 differs from pull request most recent head ff42a4f. Consider uploading reports for the commit ff42a4f to get more accurate results

Additional details and impacted files
@@             Coverage Diff              @@
##           criu-dev    #2295      +/-   ##
============================================
+ Coverage     70.55%   70.62%   +0.06%     
============================================
  Files           132      133       +1     
  Lines         33508    33312     -196     
============================================
- Hits          23642    23525     -117     
+ Misses         9866     9787      -79     

see 21 files with indirect coverage changes

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

@@ -1244,7 +1244,7 @@ static bool map_devices(struct tp_system *src_sys, struct tp_system *dest_sys, s
return true;
} else {
/* We could not map remaining nodes in the list. Add dest node back
* to list and try to map next dest ndoe in list to current src
* to list and try to map next dest node in list to current src
Copy link
Member

Choose a reason for hiding this comment

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

Would you be able to apply this change in the previous commit (using git rebase or git commit --amend)?
https://github.com/checkpoint-restore/criu/blob/criu-dev/CONTRIBUTING.md#pull-request-guidelines

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks for pointing out the procedure to look at the details.
I am rather new to submitting to repo on github that goes through an approval.
I was getting an error when I fixed the error (typo) locally and tried to push it again.
The git pull was messing up my local repo branch and thus the commit online on github itself

Copy link
Member

Choose a reason for hiding this comment

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

After modifying the commit you might need to use git push with -f to update your github branch.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Given my headaches, will push a new branch which will contain resolution to the various comments.

plugins/amdgpu/amdgpu_plugin.c Show resolved Hide resolved
plugins/amdgpu/criu-amdgpu.proto Show resolved Hide resolved
plugins/amdgpu/amdgpu_plugin_util.h Show resolved Hide resolved
return ret;
}

void print_kfd_bo_stat(int bo_cnt, struct kfd_criu_bo_bucket *bo_list)
Copy link
Member

Choose a reason for hiding this comment

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

This function is not used anywhere.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I add this as a helper method that could be used in debugging if needed. Is this not allowed

Copy link
Member

Choose a reason for hiding this comment

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

The problem with adding unused debugging functions upstream is that other people are not going to use them and test if they still work when new changes are being introduced. This makes it more difficult to maintain the code base and creates confusion for new contributors working on the project.

plugins/amdgpu/amdgpu_plugin_drm.c Show resolved Hide resolved
plugins/amdgpu/amdgpu_plugin_util.c Show resolved Hide resolved
plugins/amdgpu/amdgpu_plugin_util.c Show resolved Hide resolved
plugins/amdgpu/amdgpu_plugin_util.c Show resolved Hide resolved
plugins/amdgpu/amdgpu_plugin_util.c Show resolved Hide resolved
Copy link

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

{
dev_file_cnt--;
pr_info("\n");
pr_info("Sairam: %s(), Number of Checkpoints LEFT: %d\n", __func__, dev_file_cnt);
Copy link
Contributor

Choose a reason for hiding this comment

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

Please remove all prints with Sairam:

@@ -68,6 +68,13 @@ struct vma_metadata {

extern int fd_next;

// FD of KFD device used to checkpoint
Copy link
Contributor

Choose a reason for hiding this comment

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

Use consistent commenting style. I think rest of this file uses this style:

/**
 * Comments
 */


/* Helper macros to Checkpoint and Restore a ROCm file */
#define HSAKMT_SHM_PATH "/dev/shm/hsakmt_shared_mem"
#define HSAKMT_SHM "/hsakmt_shared_mem"
Copy link
Contributor

Choose a reason for hiding this comment

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

mis-alignment for the right-hand-sides here

return (dev_file_cnt == 0);
}

void decrement_checkpoint_count()
Copy link
Contributor

Choose a reason for hiding this comment

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

Please put this function in the other commit as it is used there

@@ -840,6 +840,9 @@ void topology_free(struct tp_system *sys)
list_del(&p2pgroup->listm_system);
xfree(p2pgroup);
}

/* Update Topology as being freed */
sys->parsed = false;
Copy link
Contributor

Choose a reason for hiding this comment

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

I don't think parsed is used anywhere else?

@dayatsin-amd
Copy link
Contributor

Overall, the general idea/concept of this refactor is fine.

@github-actions github-actions bot removed the stale-pr label Dec 14, 2023
Copy link

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

@avagin avagin added no-auto-close Don't auto-close as a stale issue and removed stale-pr labels Jan 17, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
no-auto-close Don't auto-close as a stale issue
Projects
None yet
Development

Successfully merging this pull request may close these issues.