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

Various minore fixes in the amdgpu plugin #2274

Merged
merged 3 commits into from
Oct 5, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion criu/files-reg.c
Original file line number Diff line number Diff line change
Expand Up @@ -2506,7 +2506,7 @@ static int open_filemap(int pid, struct vma_area *vma)
* using dup because dup returns a reference to the same struct file inside kernel, but we
* cannot open a new FD.
*/
ret = dup(plugin_fd);
ret = plugin_fd;
} else if (vma->e->status & VMA_AREA_MEMFD) {
if (!inherited_fd(vma->vmfd, &ret))
ret = memfd_open(vma->vmfd, &flags);
Expand Down
21 changes: 16 additions & 5 deletions plugins/amdgpu/amdgpu_plugin.c
Original file line number Diff line number Diff line change
Expand Up @@ -165,6 +165,7 @@ FILE *open_img_file(char *path, bool write, size_t *size)
fp = fdopen(fd, write ? "w" : "r");
avagin marked this conversation as resolved.
Show resolved Hide resolved
if (!fp) {
pr_perror("%s: Failed get pointer for %s", path, write ? "write" : "read");
close(fd);
return NULL;
}

Expand Down Expand Up @@ -1795,7 +1796,12 @@ int amdgpu_plugin_restore_file(int id)
* copy of the fd. CRIU core owns the duplicated returned fd, and amdgpu_plugin owns the fd stored in
* tp_node.
*/
return dup(fd);
fd = dup(fd);
if (fd == -1) {
pr_perror("unable to duplicate the render fd");
return -1;
}
return fd;
}

fd = open(AMDGPU_KFD_DEVICE, O_RDWR | O_CLOEXEC);
Expand Down Expand Up @@ -1955,10 +1961,15 @@ int amdgpu_plugin_update_vmamap(const char *in_path, const uint64_t addr, const
if (addr == vma_md->vma_entry && old_offset == vma_md->old_pgoff) {
*new_offset = vma_md->new_pgoff;

if (is_renderD)
*updated_fd = vma_md->fd;
else
*updated_fd = -1;
*updated_fd = -1;
if (is_renderD) {
int fd = dup(vma_md->fd);
if (fd == -1) {
pr_perror("unable to duplicate the render fd");
return -1;
}
*updated_fd = fd;
}

plugin_log_msg("old_pgoff=0x%lx new_pgoff=0x%lx fd=%d\n", vma_md->old_pgoff, vma_md->new_pgoff,
*updated_fd);
Expand Down
Loading