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 5EBB340F8D8 for ; Mon, 2 Mar 2026 15:27:38 +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=1772465260; cv=none; b=hC3UOCCl1JMPYKyL8YyLE8ZyHmvNI97CYmPIY27Kzappye7H4bRi1rrHqA5oNf7Hj99PHMMkpCTIubW0a5GBT8rWNA4LG+FSabO1E/6jtegwu8vhTwCbTYmKPIdh8CGVy2W2ZT6nMr0vtGC/s/HZLSzgA6eTs6K/FMnNErgyVCw= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1772465260; c=relaxed/simple; bh=toKinoz4tCBYZmLZ7PsTOm5GrxeE5+LCDPWk35Aobc4=; h=Message-ID:Date:MIME-Version:Subject:To:References:From: In-Reply-To:Content-Type; b=JAC3QUZYkzK6CpiAgi7d4B5NHhkG1WAMrfPmkHuTG9DBs2HbEw3+zIRI0hRWXfqqP4yywIWVhKLqFuQs981D03c2forFPXy8iJruiRc7X+SRKqmVBWMvJrKk4TUicHhz8t1laGEEpUCjwTkLdJyf2Gm3WvjNlFulP8HDa5c+2Vk= 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=aSGJmJoA; 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="aSGJmJoA" DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=igalia.com; s=20170329; h=Content-Transfer-Encoding:Content-Type:In-Reply-To:From: References:To:Subject:MIME-Version:Date:Message-ID:Sender:Reply-To:Cc: 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=Od/3HDrQGWYzlk1CudpzyCv9GPnJrENBm1GAp4g/zp4=; b=aSGJmJoARRyWq3ia5oBU4wC6Tw Sxouwd39Q5UgYsr53hbIkntbqcxYEntcsgPcqyjO3kDdPZiIIpO1tcIqMIsqcbjD2fh9NrjlEkxi2 IM1BEU8FDPh9kizmAzsJBMf0DssTf4SCoFkeQFHkG1IEQrYaDXxq2vBkFOgwKAXH86j4xwidAZJRr 26oot4sEGS2ozjzuPN1icsTdl89ojEB4FWNe3pfyqxqRc0yJXebuGf6N55w+IcMe7scNSuJ3+A2Qt nrUNNkXUYuOBa1Y+BfrwSndX3hG3NR1Q3A2ie2LCFK4GPwhpVGZbHY6aJziLktGo7NM2O8m7iVp/C PQDiGJ2g==; Received: from [90.240.106.137] (helo=[192.168.0.101]) by fanzine2.igalia.com with esmtpsa (Cipher TLS1.3:ECDHE_X25519__RSA_PSS_RSAE_SHA256__AES_128_GCM:128) (Exim) id 1vx5BH-007wxk-So; Mon, 02 Mar 2026 16:27:35 +0100 Message-ID: Date: Mon, 2 Mar 2026 15:27:35 +0000 Precedence: bulk X-Mailing-List: criu@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [RFC 17/26] plugins/amdgpu: Use the load_img helper in drm file restore To: "Francis, David" , "criu@lists.linux.dev" References: <20260220120514.4540-1-tvrtko.ursulin@igalia.com> <20260220120514.4540-18-tvrtko.ursulin@igalia.com> Content-Language: en-GB From: Tvrtko Ursulin In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit On 02/03/2026 14:52, Francis, David wrote: > >> Use the recently added image load helper in one more function which >> contains the exactly same flow of open-alloc-read. > > Code looks cleaner for sure. How recently was this recently added image > load helper added, and to what? Does this change CRIU's dependencies? In patch 7/26. ;) Helper is simply a result of code consolidation. Regards, Tvrtko > ________________________________________ > From: Tvrtko Ursulin > Sent: Friday, February 20, 2026 7:05 AM > To: criu@lists.linux.dev > Cc: Francis, David; Tvrtko Ursulin > Subject: [RFC 17/26] plugins/amdgpu: Use the load_img helper in drm file restore > > Use the recently added image load helper in one more function which > contains the exactly same flow of open-alloc-read. > > Signed-off-by: Tvrtko Ursulin > --- > plugins/amdgpu/amdgpu_plugin.c | 25 +++++-------------------- > 1 file changed, 5 insertions(+), 20 deletions(-) > > diff --git a/plugins/amdgpu/amdgpu_plugin.c b/plugins/amdgpu/amdgpu_plugin.c > index 9ba12bd3a466..a653ba1aa2d9 100644 > --- a/plugins/amdgpu/amdgpu_plugin.c > +++ b/plugins/amdgpu/amdgpu_plugin.c > @@ -1859,7 +1859,6 @@ static int amdgpu_plugin_restore_drm_file(int id, bool *retry_needed) > CriuRenderNode *rd; > unsigned char *buf; > size_t img_size; > - FILE *img_fp; > int fd, ret; > > /* This is restorer plugin for renderD nodes. Criu doesn't guarantee that they will > @@ -1868,9 +1867,8 @@ static int amdgpu_plugin_restore_drm_file(int id, bool *retry_needed) > * first as we assume restore_maps is already filled. Need to fix this later. > */ > snprintf(img_path, sizeof(img_path), IMG_DRM_FILE, id); > - > - img_fp = open_img_file(img_path, false, &img_size); > - if (!img_fp) { > + ret = load_img(img_path, &buf, &img_size); > + if (ret < 0) { > ret = amdgpu_plugin_dmabuf_restore(id); > if (ret == 1) { > /* This is a dmabuf fd, but the corresponding buffer object that was > @@ -1882,29 +1880,16 @@ static int amdgpu_plugin_restore_drm_file(int id, bool *retry_needed) > } > return ret; > } > - pr_info("Restoring RenderD %s\n", img_path); > - pr_debug("RenderD Image file size:%ld\n", img_size); > - buf = xmalloc(img_size); > - if (!buf) { > - pr_perror("Failed to allocate memory"); > - return -ENOMEM; > - } > > - ret = read_fp(img_fp, buf, img_size); > - if (ret) { > - pr_perror("Unable to read from %s", img_path); > - xfree(buf); > - return -1; > - } > + pr_info("Restoring RenderD %s image of %lu bytes\n", > + img_path, img_size); > > rd = criu_render_node__unpack(NULL, img_size, buf); > if (rd == NULL) { > - pr_perror("Unable to parse the RenderD message %d", id); > + pr_perror("Unable to parse the RenderD image %d", id); > xfree(buf); > - fclose(img_fp); > return -1; > } > - fclose(img_fp); > > pr_info("render node gpu_id = 0x%04x\n", rd->gpu_id); > > -- > 2.52.0 >