Received: from fanzine2.igalia.com (fanzine2.igalia.com [213.97.179.56]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id A0783330B3A for ; Fri, 20 Feb 2026 12:05:40 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=213.97.179.56 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1771589141; cv=none; b=ZAS5XQyEvcqnqq5TFqw43okOGJUHOwGNA9klg1DY+9wktgYV6wCRzbSY6A/Nlo4jZY5/73138QBiQCeD+OBLE8jcMJhNCKHQm/jrntjBppIN8vx7JNC1+OL62yarPxnZ28Xw17A5zGOiTNN9L3JSMjrjgSyOx5SjYfmEYYlAcIQ= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1771589141; c=relaxed/simple; bh=zhgdT1N/ZRPNeg1uvv51jXzUABweE0DdneFTHx242yI=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=cXnLbf3HcciXXgljioA0el16+4KlkzZk0iDylwdopHT8S8e+YEMymTy8SsvXxbR1G+XbtWYO1e/fBGkMAx0YTI6DS276i4EtQ5e6uz0XyWJcYwLP1k7uDBCFlcREQwrmYsf5qD4zRJkPRoZUqC4ccajtn22oDgcQDX3AlUFdbvk= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=igalia.com; spf=pass smtp.mailfrom=igalia.com; dkim=pass (2048-bit key) header.d=igalia.com header.i=@igalia.com header.b=DhzuUSQw; arc=none smtp.client-ip=213.97.179.56 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=igalia.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=igalia.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=igalia.com header.i=@igalia.com header.b="DhzuUSQw" DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=igalia.com; s=20170329; h=Content-Transfer-Encoding:MIME-Version:References:In-Reply-To: Message-ID:Date:Subject:Cc:To:From:Sender:Reply-To:Content-Type:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Id:List-Help:List-Unsubscribe:List-Subscribe: List-Post:List-Owner:List-Archive; bh=aGwYD1esyjeXaVVoixjnm8G/0Xf8eXaeoHmpBj9jiEw=; b=DhzuUSQwTN/7HfHqOs8oFXaZwS QKMjM4Tw8NCn2cNwNWGsUy7f5zs9zJ1fJ6b8ceOmgDK2KlkxuG4v+72adON3wk94bzyOeqfRX7zr2 d0ggSzJ3tnLQPVpF9fV7njp3kN4UZP06Drs8Pd81jCL5GdpTsCpC0DkL+aRS58DEPG+e91Un0gz2R EYHQ9sBWnydnJiK89QlmW5JW2sNskZJpz6LnYkFaZx4DYmim02gTAi2FK11xA7pS12KxI7LkPuHBq VCJRhaikXy5tcn4ZozVXLfipna9U2S2EGfKcCzsx+Kz6vYoppBP/4efP55WhZtUygtpJZqqZR7rw4 R3tHt9OA==; Received: from [90.240.106.137] (helo=localhost) by fanzine2.igalia.com with esmtpsa (Cipher TLS1.3:ECDHE_SECP256R1__RSA_PSS_RSAE_SHA256__AES_256_GCM:256) (Exim) id 1vtPGM-002v0v-O6; Fri, 20 Feb 2026 13:05:38 +0100 From: Tvrtko Ursulin To: criu@lists.linux.dev Cc: David Francis , Tvrtko Ursulin Subject: [RFC 19/26] plugins/amdgpu: Use save_vma_updates for all call sites Date: Fri, 20 Feb 2026 12:05:07 +0000 Message-ID: <20260220120514.4540-20-tvrtko.ursulin@igalia.com> X-Mailer: git-send-email 2.52.0 In-Reply-To: <20260220120514.4540-1-tvrtko.ursulin@igalia.com> References: <20260220120514.4540-1-tvrtko.ursulin@igalia.com> Precedence: bulk X-Mailing-List: criu@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Consolidate KFD and DRM VMA handling path to the same (existing) helper. Signed-off-by: Tvrtko Ursulin --- plugins/amdgpu/amdgpu_plugin.c | 46 ++++++++++++------------------ plugins/amdgpu/amdgpu_plugin_drm.c | 3 +- plugins/amdgpu/amdgpu_plugin_drm.h | 3 +- 3 files changed, 22 insertions(+), 30 deletions(-) diff --git a/plugins/amdgpu/amdgpu_plugin.c b/plugins/amdgpu/amdgpu_plugin.c index dc808fe32373..5ab3420c1371 100644 --- a/plugins/amdgpu/amdgpu_plugin.c +++ b/plugins/amdgpu/amdgpu_plugin.c @@ -1669,7 +1669,8 @@ static int restore_bos(struct kfd_ioctl_criu_args *args, CriuKfd *e) return 0; } -int save_vma_updates(uint64_t offset, uint64_t addr, uint64_t restored_offset, int fd) +int save_vma_updates(uint64_t offset, uint64_t addr, uint64_t restored_offset, + int fd) { struct vma_metadata *vma_md; @@ -1678,14 +1679,15 @@ int save_vma_updates(uint64_t offset, uint64_t addr, uint64_t restored_offset, i return -ENOMEM; } - memset(vma_md, 0, sizeof(*vma_md)); - vma_md->old_pgoff = offset; vma_md->vma_entry = addr; - vma_md->new_pgoff = restored_offset; vma_md->fd = fd; + pr_debug("adding vma_entry:addr:%" PRIx64 " old-off:%" PRIx64 " new_off:%" PRIx64 " fd:%d\n", + vma_md->vma_entry, vma_md->old_pgoff, vma_md->new_pgoff, + vma_md->fd); + list_add_tail(&vma_md->list, &update_vma_info_list); return 0; @@ -1703,37 +1705,25 @@ static int restore_bo_data(int id, struct kfd_criu_bo_bucket *bo_buckets, CriuKf if (bo_bucket->alloc_flags & (KFD_IOC_ALLOC_MEM_FLAGS_VRAM | KFD_IOC_ALLOC_MEM_FLAGS_GTT | KFD_IOC_ALLOC_MEM_FLAGS_MMIO_REMAP | KFD_IOC_ALLOC_MEM_FLAGS_DOORBELL)) { - struct vma_metadata *vma_md; uint32_t target_gpu_id; /* actual gpu_id where the BO will be restored */ - vma_md = xmalloc(sizeof(*vma_md)); - if (!vma_md) { - ret = -ENOMEM; - goto exit; - } - - memset(vma_md, 0, sizeof(*vma_md)); - - vma_md->old_pgoff = bo_bucket->offset; - vma_md->vma_entry = bo_bucket->addr; - - target_gpu_id = maps_get_dest_gpu(&restore_maps, bo_bucket->gpu_id); - - tp_node = sys_get_node_by_gpu_id(&dest_topology, target_gpu_id); + target_gpu_id = maps_get_dest_gpu(&restore_maps, + bo_bucket->gpu_id); + tp_node = sys_get_node_by_gpu_id(&dest_topology, + target_gpu_id); if (!tp_node) { - pr_err("Failed to find node with gpu_id:0x%04x\n", target_gpu_id); + pr_err("Failed to find node with gpu_id:0x%04x\n", + target_gpu_id); ret = -ENODEV; goto exit; } - vma_md->new_pgoff = bo_bucket->restored_offset; - vma_md->fd = node_get_drm_render_device(tp_node); - - pr_debug("adding vma_entry:addr:0x%lx old-off:0x%lx new_off:0x%lx new_minor:%d\n", - vma_md->vma_entry, vma_md->old_pgoff, - vma_md->new_pgoff, tp_node->drm_render_minor); - - list_add_tail(&vma_md->list, &update_vma_info_list); + ret = save_vma_updates(bo_bucket->offset, + bo_bucket->addr, + bo_bucket->restored_offset, + node_get_drm_render_device(tp_node)); + if (ret) + goto exit; } } diff --git a/plugins/amdgpu/amdgpu_plugin_drm.c b/plugins/amdgpu/amdgpu_plugin_drm.c index 070b5b19ec47..de6d6f178d51 100644 --- a/plugins/amdgpu/amdgpu_plugin_drm.c +++ b/plugins/amdgpu/amdgpu_plugin_drm.c @@ -557,7 +557,8 @@ int amdgpu_plugin_drm_restore_file(int fd, CriuRenderNode *rd) } } - ret = save_vma_updates(boinfo->offset, boinfo->addr, mmap_args.out.addr_ptr, fd); + ret = save_vma_updates(boinfo->offset, boinfo->addr, + mmap_args.out.addr_ptr, fd); if (ret < 0) goto exit; } diff --git a/plugins/amdgpu/amdgpu_plugin_drm.h b/plugins/amdgpu/amdgpu_plugin_drm.h index c766def563f6..f76e29f7f73f 100644 --- a/plugins/amdgpu/amdgpu_plugin_drm.h +++ b/plugins/amdgpu/amdgpu_plugin_drm.h @@ -34,7 +34,8 @@ int store_dmabuf_fd(int handle, int fd); int get_gem_handle(amdgpu_device_handle h_dev, int dmabuf_fd); -int save_vma_updates(uint64_t offset, uint64_t addr, uint64_t restored_offset, int gpu_id); +int save_vma_updates(uint64_t offset, uint64_t addr, uint64_t restored_offset, + int fd); #endif /* __AMDGPU_PLUGIN_DRM_H__ */ -- 2.52.0