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 B57B333E379 for ; Fri, 20 Feb 2026 12:05:45 +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=1771589146; cv=none; b=LC7Ue7QmO4h4+rEv4EblN5m0FdYMdP9opvUVDAH0ngx9oW7TeRTW1Ois2qXYDtSI2p6sAlw2nEt4QQ66JSghySQN/TTMlj5vJqUqMdDJwv1dizdIpgWy5aTnTPtXesEtZhj7dM5LKMF+yvplXMbPWuquwhn0axD0ZxYtZnpmvdk= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1771589146; c=relaxed/simple; bh=U0bxoCodDcnRs+qmJOn1nVXWDwV1/KE1VpX5bR+IshA=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=ngLyJNsKMRqiDwx/fnge/XVFD+mZRnW5kBwvu2Mr429zig4auzH3Z2/FHTpXk4j5DfC2n800Iwezs3OTX5wT6XyjrBlrc+s66Xo/bQz6WPmpXSU83CRNbjPoONGOdyiptpeInBy4pp8377yW8i6XDqEYGyPbVwPagO3MRhSil+Y= 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=f7gTnCCV; 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="f7gTnCCV" 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=7xQK/dpASK4jud9D83CXvZJ4lfaz2QwIwugNipD2epM=; b=f7gTnCCV0J5gc0ixANk5uUdJLW JG2prAdFobqDq/CalEHVOU5ORnGzZtHYpwLPYzWGfbHy+4b44nNr6rRsP88IncGtSCnV303kNv/Kk HOmZHmqYi0Ts69zP32bvY6xvnTUcW8pzcg5BePvUBrxUzs9xh1mN4ITZm5p7MBmukiVQ2rAqiw5KI 0CUE9/Oc5YulvGVSlHgFfhINOV27Cp3AM66uetH8JvKqswMUlhEjo6bfRK31T+pPX4KHCQVL4C/Fx HhXZOMnKWzZFivDs6NSjfeJV+/p5jwCnuQEmG7VQUHsE0R18hlbGxbrI+4OZw7AnMoJbyAcImQ6t0 sj+hMNig==; 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 1vtPGR-002v1t-Mu; Fri, 20 Feb 2026 13:05:43 +0100 From: Tvrtko Ursulin To: criu@lists.linux.dev Cc: David Francis , Tvrtko Ursulin Subject: [RFC 26/26] plugins/amdgpu: Hack to work around GPU virtual address conflicts Date: Fri, 20 Feb 2026 12:05:14 +0000 Message-ID: <20260220120514.4540-27-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 During the restore process buffer objects are created and mapped into the GPU virtual address space to their final addresses, and then their content is attempted to be restored. This step is done by instantiating a libdrm instance and the associated userspace virtual address range manager. This manager is unaware of the previous address range allocations on the same file, which in practice means restore will simply fail. To work around it we add some retries to try different addresses a few times, but for a proper solution we will need to either add a mechanism for reserving ranges in libdrm va manager, or rework the order of the restore operations so that the buffer objects are only mapped into their final locations once their content has been restored. Signed-off-by: Tvrtko Ursulin --- plugins/amdgpu/amdgpu_plugin.c | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/plugins/amdgpu/amdgpu_plugin.c b/plugins/amdgpu/amdgpu_plugin.c index 239eeebc5111..b2f192a80f65 100644 --- a/plugins/amdgpu/amdgpu_plugin.c +++ b/plugins/amdgpu/amdgpu_plugin.c @@ -573,6 +573,7 @@ int sdma_copy_bo(int shared_fd, uint64_t size, int storage_fd, amdgpu_context_handle h_ctx; uint32_t *ib = NULL; int j, err, err2, packets_per_buffer; + unsigned int retries = 0; buffer_bo_size = min(size, buffer_size); packets_per_buffer = ((buffer_bo_size - 1) / max_copy_size) + 1; @@ -603,6 +604,8 @@ int sdma_copy_bo(int shared_fd, uint64_t size, int storage_fd, return -EINVAL; } +retry_src_va: + retries++; err = amdgpu_va_range_alloc(h_dev, amdgpu_gpu_va_range_general, src_bo_size, 0x1000, 0, &gpu_addr_src, &h_va_src, 0); if (err) { @@ -611,6 +614,8 @@ int sdma_copy_bo(int shared_fd, uint64_t size, int storage_fd, } err = amdgpu_bo_va_op(h_bo_src, 0, src_bo_size, gpu_addr_src, 0, AMDGPU_VA_OP_MAP); if (err) { + if (retries < 1000) + goto retry_src_va; pr_perror("failed to GPU map the src BO"); goto err_src_bo_map; } @@ -639,6 +644,9 @@ int sdma_copy_bo(int shared_fd, uint64_t size, int storage_fd, goto err_dst_bo_prep; } + retries = 0; +retry_dst_va: + retries++; err = amdgpu_va_range_alloc(h_dev, amdgpu_gpu_va_range_general, dst_bo_size, 0x1000, 0, &gpu_addr_dst, &h_va_dst, 0); if (err) { @@ -647,6 +655,8 @@ int sdma_copy_bo(int shared_fd, uint64_t size, int storage_fd, } err = amdgpu_bo_va_op(h_bo_dst, 0, dst_bo_size, gpu_addr_dst, 0, AMDGPU_VA_OP_MAP); if (err) { + if (retries < 1000) + goto retry_dst_va; pr_perror("failed to GPU map the dest BO"); goto err_dst_bo_map; } -- 2.52.0