[PATCH 3/3] plugins/amdgpu: Make next_fd without kfd

David Francis <[email protected]> Fri, 10 Apr 2026 10:45:09 -0400
Newsgroups dev.linux.lists.criu
Message-ID <[email protected]>
The amdgpu plugin needs to know what high fds are safe to use
to store drm fds during the restore process. This is kept in
next_fd, which is set as part of kfd restore.

If there's no kfd restore, set next_fd anyways. Use the
current pid as the pid to check; by this point in the restore
the pid has been changed to the correct value.

Signed-off-by: David Francis <[email protected]>
---
 plugins/amdgpu/amdgpu_plugin.c | 11 +++++++++++
 1 file changed, 11 insertions(+)

diff --git a/plugins/amdgpu/amdgpu_plugin.c b/plugins/amdgpu/amdgpu_plugin.c
index 1e9785440..5dcf80363 100644
--- a/plugins/amdgpu/amdgpu_plugin.c
+++ b/plugins/amdgpu/amdgpu_plugin.c
@@ -1926,6 +1926,17 @@ int amdgpu_plugin_restore_file(int id, bool *retry_needed)
 
 		pr_info("render node gpu_id = 0x%04x\n", rd->gpu_id);
 
+		if (fd_next == -1) {
+			current_pid = getpid();
+			fd_next = find_unused_fd_pid(getpid());
+			if (fd_next <= 0) {
+				pr_err("Failed to find unused fd (fd:%d)\n", fd_next);
+				ret = -EINVAL;
+				goto exit;
+			}
+			pr_info("High fd for pid %d set to %d\n", current_pid, fd_next);
+		}
+
 		if (list_empty(&restore_maps.cpu_maps) && list_empty(&restore_maps.gpu_maps)) {
 			AmdgpuDevinfo *ad;
 
-- 
2.34.1