Skip to content

RFC amdgpu plugin render node only discussion

Tvrtko Ursulin criu 1 version In review

Get series with b4
b4 am [email protected]

Versions newest first

  1. v1 RFC Latest26 patches 18 repliesIn review

Patches in v1 No applies recorded yet

#Subject and filesSizeRepliesApplied
1/26plugins/amgdpu: Fix one error messageplugins/amdgpu/amdgpu_plugin_drm.c+1 -10 replies
2/26plugins/amdgpu: Remove unused current_pid global variableplugins/amdgpu/amdgpu_plugin.c+0 -10 replies
3/26plugins/amdgpu: Remove unused new_minor from struct vma_metadataplugins/amdgpu/amdgpu_plugin.c+1 -30 replies
4/26plugins/amdgpu: Fix drm pages size headerplugins/amdgpu/amdgpu_plugin_drm.c+1 -00 replies
5/26plugins/amdgpu: Fix logging of failures to open files during restore initplugins/amdgpu/amdgpu_plugin.c+2 -30 replies
6/26plugins/amdgpu: Propagate failure to save buffer object contentplugins/amdgpu/amdgpu_plugin.c plugins/amdgpu/amdgpu_plugin_drm.c+18 -150 replies
7/26plugins/amdgpu: Close the directory when image probing failsplugins/amdgpu/amdgpu_plugin.c+46 -300 replies
8/26plugins/amdgpu: Close dma-buf image file if the read failsplugins/amdgpu/amdgpu_plugin_dmabuf.c+1 -20 replies
9/26plugins/amdgpu: Check images were opened successfullyplugins/amdgpu/amdgpu_plugin_drm.c+9 -00 replies
10/26plugins/amdgpu: Flatten amdgpu_restore_init a bitplugins/amdgpu/amdgpu_plugin.c+60 -550 replies
11/26plugins/amdgpu: Fix error handling in amdgpu_plugin_drm_restore_file()plugins/amdgpu/amdgpu_plugin_drm.c+9 -40 replies
12/26plugins/amdgpu: Add error handling for seek operationsplugins/amdgpu/amdgpu_plugin.c+12 -10 replies
13/26plugins/amdgpu: Consolidate vm_info collectionplugins/amdgpu/amdgpu_plugin_drm.c+25 -222 replies
14/26plugins/amdgpu: Remove plugin_log_msg()plugins/amdgpu/amdgpu_plugin.c plugins/amdgpu/amdgpu_plugin_drm.c plugins/amdgpu/amdgpu_plugin_util.h+27 -293 replies
15/26plugins/amdgpu: Add plugin to inventory even if process has no vmasplugins/amdgpu/amdgpu_plugin.c+24 -91 reply
16/26plugins/amdgpu: Move drm file dump and restore into helpersplugins/amdgpu/amdgpu_plugin.c plugins/amdgpu/amdgpu_plugin_dmabuf.c+145 -1301 reply
17/26plugins/amdgpu: Use the load_img helper in drm file restoreplugins/amdgpu/amdgpu_plugin.c+5 -202 replies
18/26plugins/amdgpu: Convert away from libc buffered file IOplugins/amdgpu/amdgpu_plugin.c plugins/amdgpu/amdgpu_plugin_dmabuf.c plugins/amdgpu/amdgpu_plugin_drm.c +2 more+140 -1462 replies
19/26plugins/amdgpu: Use save_vma_updates for all call sitesplugins/amdgpu/amdgpu_plugin.c plugins/amdgpu/amdgpu_plugin_drm.c plugins/amdgpu/amdgpu_plugin_drm.h+22 -301 reply
20/26plugins/amdgpu: amdgpu_plugin_drm_restore_file() does not need to use libdrmplugins/amdgpu/amdgpu_plugin_drm.c+3 -152 replies
21/26plugins/amdgpu: Enable restore with only the drm node openplugins/amdgpu/amdgpu_plugin.c plugins/amdgpu/amdgpu_plugin_drm.c plugins/amdgpu/amdgpu_plugin_topology.c +1 more+62 -90 replies
22/26plugins/amdgpu: Handle DRM render node mmapsplugins/amdgpu/amdgpu_plugin.c+19 -160 replies
23/26plugins/amdgpu: Consolidate shared memory handlingplugins/amdgpu/amdgpu_plugin.c+49 -360 replies
24/26plugins/amdgpu: Store VMA data in shared memoryplugins/amdgpu/amdgpu_plugin.c+28 -130 replies
25/26plugins/amdgpu: Hack to save a fd number which works for vma restoreplugins/amdgpu/amdgpu_plugin.c plugins/amdgpu/amdgpu_plugin_drm.c plugins/amdgpu/amdgpu_plugin_drm.h+18 -50 replies
26/26plugins/amdgpu: Hack to work around GPU virtual address conflictsplugins/amdgpu/amdgpu_plugin.c+10 -03 replies

Reviews trailers per patch

8 of 26 patches have a Reviewed-by or Acked-by.

PatchDavid Francis
1/26
2/26
3/26
4/26
5/26
6/26
7/26
8/26
9/26
10/26
11/26
12/26
13/26R-b
14/26R-b
15/26R-b
16/26R-b
17/26
18/26R-b
19/26R-b
20/26R-b
21/26
22/26
23/26
24/26
25/26
26/26R-b

Trailers given in replies are filled; those carried in the patches from earlier versions are outlined with dashes.

Read the v1 thread

Cover letter [RFC 00/26] amdgpu plugin render node only discussion

Hi all,

Long story short, I am trying to make some inroads towards having a working checkpoint and restore for render node only applications (ie. no KFD).

Plan is to write test scenarios in an increasing order of complexity and make them work. Those tests can be found here:

https://cgit.freedesktop.org/~tursulin/intel-gpu-tools/log/?h=amd-criu

For those unfamiliar, once built the list of subtest can be obtained like this:

$ amd_criu --l
open
one-bo
map-one
mmap-one
map-and-mmap-one
map-mmap-fork

Each test will pause after the setup phase waiting for a return key. This is the point when they can be checkpointed and restored. The tests are in the order of how I was fixing issues one by one, give or take some details.

Without this series nothing works, while with it, they all pass (last one is the superset of all previous ones, or the most complex test):

$ amd_criu --r map-mmap-fork
...
$ sudo /usr/local/sbin/criu dump -t `pgrep amd_criu | head -1` -L /usr/local/lib/criu/ -vvv -o criu.log -j --link-remap --tcp-established --file-locks --ext-unix-sk
$ sudo /usr/local/sbin/criu restore  -L /usr/local/lib/criu/ -vvv -o restore.log --shell-job --link-remap --tcp-established --file-locks --ext-unix-sk

Subtest map-mmap-fork: SUCCESS (6.310s)

However trivial the tests may currently be, the combination of them and this series is supposed to be a starting point for a design discussion since it appears there are many issues to address.

Having said that, this series actually starts with a fair number of cleanup patches which can be reviewed and merged independently. Or I can easily send them as a standalone pull request if that would work better.

Only the last six patches, plus "plugins/amdgpu: Add plugin to inventory even if process has no vmas", are the ones with fixes and hacks which make the tests pass.

In no particular order the main issues I currently see are:

* GPU discovery with no KFD open or present
* Rendernode VMA handling
* VMA handling with forked processes
* GPU VA conflicts during restore

Some of these may require changes to CRIU plugin parameters and input from CRIU experts.

More details on each of these topics can be found in the respective patch commit messages. I will also gladly expand on any.

For now I wanted to test the waters first by sending this early and see who is interested and to what extent. This is far from a working render node support but it illustrates that such basic scenarios currently do not work, that I think those basics need to be fixed first before proceeding with anything more complex.

Also, nothing in this series is supposed to negatively influence the KFD paths, but with a disclaimer that I did not test that side at all. Suggestions on a suitable KFD test program would be welcomed.

Tvrtko

Tvrtko Ursulin (26):
plugins/amgdpu: Fix one error message
plugins/amdgpu: Remove unused current_pid global variable plugins/amdgpu: Remove unused new_minor from struct vma_metadata plugins/amdgpu: Fix drm pages size header
plugins/amdgpu: Fix logging of failures to open files during restore
init
plugins/amdgpu: Propagate failure to save buffer object content plugins/amdgpu: Close the directory when image probing fails plugins/amdgpu: Close dma-buf image file if the read fails plugins/amdgpu: Check images were opened successfully plugins/amdgpu: Flatten amdgpu_restore_init a bit plugins/amdgpu: Fix error handling in amdgpu_plugin_drm_restore_file() plugins/amdgpu: Add error handling for seek operations plugins/amdgpu: Consolidate vm_info collection plugins/amdgpu: Remove plugin_log_msg()
plugins/amdgpu: Add plugin to inventory even if process has no vmas plugins/amdgpu: Move drm file dump and restore into helpers plugins/amdgpu: Use the load_img helper in drm file restore plugins/amdgpu: Convert away from libc buffered file IO plugins/amdgpu: Use save_vma_updates for all call sites plugins/amdgpu: amdgpu_plugin_drm_restore_file() does not need to use
libdrm
plugins/amdgpu: Enable restore with only the drm node open plugins/amdgpu: Handle DRM render node mmaps plugins/amdgpu: Consolidate shared memory handling plugins/amdgpu: Store VMA data in shared memory plugins/amdgpu: Hack to save a fd number which works for vma restore plugins/amdgpu: Hack to work around GPU virtual address conflicts

 plugins/amdgpu/amdgpu_plugin.c          | 856 ++++++++++++++----------
 plugins/amdgpu/amdgpu_plugin_dmabuf.c   |  17 +-
 plugins/amdgpu/amdgpu_plugin_drm.c      | 125 ++--
 plugins/amdgpu/amdgpu_plugin_drm.h      |   5 +-
 plugins/amdgpu/amdgpu_plugin_topology.c |   2 +
 plugins/amdgpu/amdgpu_plugin_topology.h |   2 +
 plugins/amdgpu/amdgpu_plugin_util.c     | 106 +--
 plugins/amdgpu/amdgpu_plugin_util.h     |  17 +-
 8 files changed, 636 insertions(+), 494 deletions(-)
Signature · 1 line
2.52.0