Re: [RFC 15/26] plugins/amdgpu: Add plugin to inventory even if process has no vmas

"Francis, David" <[email protected]> Fri, 27 Feb 2026 20:34:47 +0000
Newsgroups dev.linux.lists.criu
Message-ID <SA1PR12MB8144C229143C0D41F53405D1EF73A@SA1PR12MB8144.namprd12.prod.outlook.com>
This should also help in the case where kfd is open but no mapping exists

This patch is
Reviewed-By: David Francis <[email protected]>

________________________________________
From: Tvrtko Ursulin <[email protected]>
Sent: Friday, February 20, 2026 7:05 AM
To: [email protected]
Cc: Francis, David; Tvrtko Ursulin
Subject: [RFC 15/26] plugins/amdgpu: Add plugin to inventory even if process has no vmas

Currently the plugin is added to the inventory only if there were amdgpu
mapped vmas in the target process. This makes restoring a simple process
with only an open DRM fd and some buffer objects not work.

Fix it by adding the plugin to the inventory when there were open DRM
files as well.

Signed-off-by: Tvrtko Ursulin <[email protected]>
---
 plugins/amdgpu/amdgpu_plugin.c | 33 ++++++++++++++++++++++++---------
 1 file changed, 24 insertions(+), 9 deletions(-)

diff --git a/plugins/amdgpu/amdgpu_plugin.c b/plugins/amdgpu/amdgpu_plugin.c
index b3cc3a12ce2e..c9c1c8278d74 100644
--- a/plugins/amdgpu/amdgpu_plugin.c
+++ b/plugins/amdgpu/amdgpu_plugin.c
@@ -448,6 +448,22 @@ struct thread_data {
        int id; /* File ID used by CRIU to identify KFD image for this process */
 };

+static int amdgpu_add_to_inventory(void)
+{
+       int ret;
+
+       if (plugin_added_to_inventory)
+               return 0;
+
+       ret = add_inventory_plugin(CR_PLUGIN_DESC.name);
+       if (ret)
+               pr_err("Failed to add AMDGPU plugin to inventory image\n");
+       else
+               plugin_added_to_inventory = true;
+
+       return 0;
+}
+
 int amdgpu_plugin_handle_device_vma(int fd, const struct stat *st_buf)
 {
        struct stat st_kfd;
@@ -471,13 +487,8 @@ int amdgpu_plugin_handle_device_vma(int fd, const struct stat *st_buf)
        if (ret)
                pr_perror("%s(), Can't handle VMAs of input device", __func__);

-       if (!ret && !plugin_added_to_inventory) {
-               ret = add_inventory_plugin(CR_PLUGIN_DESC.name);
-               if (ret)
-                       pr_err("Failed to add AMDGPU plugin to inventory image\n");
-               else
-                       plugin_added_to_inventory = true;
-       }
+       if (!ret)
+               ret = amdgpu_add_to_inventory();

        return ret;
 }
@@ -1458,8 +1469,12 @@ int amdgpu_plugin_dump_file(int fd, int id)
                if (ret)
                        return ret;

-               /* Need to return success here so that criu can call plugins for renderD nodes */
-               return try_dump_dmabuf_list();
+               ret = try_dump_dmabuf_list();
+
+               if (!ret)
+                       ret = amdgpu_add_to_inventory();
+
+               return ret;
        }

        pr_info("%s() called for fd = %d\n", __func__, major(st.st_rdev));
--
2.52.0