Skip to content

Driver-managed exhaustive eviction

Thomas Hellström intel-xe stable 1 version In review

Get series with b4
b4 am [email protected]

Versions newest first

  1. v1 Latest15 patches 46 repliesIn review

Patches in v1 No applies recorded yet

#Subject and filesSizeRepliesApplied
1/15drm/xe/vm: Don't use a pin the vm_resv during validationdrivers/gpu/drm/xe/xe_bo.c drivers/gpu/drm/xe/xe_vm.h+4 -163 replies
2/15drm/xe/tests/xe_dma_buf: Set the drm_object::dma_buf memberdrivers/gpu/drm/xe/tests/xe_dma_buf.c+3 -51 reply
3/15drm/xe/vm: Clear the scratch_pt pointer on errordrivers/gpu/drm/xe/xe_vm.c+6 -21 reply
4/15drm/xe: Pass down drm_exec context to validationdrivers/gpu/drm/xe/Makefile drivers/gpu/drm/xe/compat-i915-headers/gem/i915_gem_stolen.h drivers/gpu/drm/xe/display/xe_fb_pin.c +17 more+401 -1054 replies
5/15drm/xe: Introduce an xe_validation wrapper around drm_execdrivers/gpu/drm/xe/xe_validation.c drivers/gpu/drm/xe/xe_validation.h+306 -010 replies
6/15drm/xe: Convert xe_bo_create_user() for exhaustive evictiondrivers/gpu/drm/xe/tests/xe_bo.c drivers/gpu/drm/xe/tests/xe_dma_buf.c drivers/gpu/drm/xe/tests/xe_migrate.c +6 more+116 -621 reply
7/15drm/xe: Convert SVM validation for exhaustive evictiondrivers/gpu/drm/xe/xe_svm.c+30 -332 replies
8/15drm/xe: Convert existing drm_exec transactions for exhaustive evictiondrivers/gpu/drm/xe/xe_exec.c drivers/gpu/drm/xe/xe_gt_pagefault.c drivers/gpu/drm/xe/xe_svm.c +2 more+70 -1081 reply
9/15drm/xe: Convert the CPU fault handler for exhaustive evictiondrivers/gpu/drm/xe/xe_bo.c+8 -34 replies
10/15drm/xe/display: Convert __xe_pin_fb_vma()drivers/gpu/drm/xe/display/xe_fb_pin.c+16 -111 reply
11/15drm/xe: Convert xe_dma_buf.c for exhaustive evictiondrivers/gpu/drm/xe/xe_dma_buf.c+42 -174 replies
12/15drm/xe: Rename ___xe_bo_create_locked()drivers/gpu/drm/xe/xe_bo.c drivers/gpu/drm/xe/xe_bo.h drivers/gpu/drm/xe/xe_dma_buf.c+27 -281 reply
13/15drm/xe: Convert xe_bo_create_pin_map_at() for exhaustive evictiondrivers/gpu/drm/xe/compat-i915-headers/gem/i915_gem_stolen.h drivers/gpu/drm/xe/display/xe_fb_pin.c drivers/gpu/drm/xe/display/xe_plane_initial.c +3 more+101 -746 replies
14/15drm/xe: Convert xe_bo_create_pin_map() for exhaustive evictiondrivers/gpu/drm/xe/display/intel_fbdev_fb.c drivers/gpu/drm/xe/display/xe_dsb_buffer.c drivers/gpu/drm/xe/display/xe_fb_pin.c +16 more+252 -1713 replies
15/15drm/xe: Convert pinned suspend eviction for exhaustive evictiondrivers/gpu/drm/xe/xe_bo.c+108 -974 replies

Reviews trailers per patch

6 of 15 patches have a Reviewed-by or Acked-by.

PatchMatthew Brost
1/15R-b
2/15R-b
3/15R-b
4/15
5/15
6/15R-b
7/15
8/15R-b
9/15
10/15
11/15
12/15R-b
13/15
14/15
15/15

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

Read the v1 thread

Cover letter [PATCH 00/15] Driver-managed exhaustive eviction

Exhaustive eviction means that every client should in theory be able to allocate all graphics memory (minus pinned memory). This is done by evicting other client's memory.

Currently when TTM wants to evict a buffer object it will typically trylock that buffer object. It may also optionally try a sleeping lock, but if deadlock resolution kicks in while doing so (the locking returns -EDEADLK), that is converted to an -ENOMEM and returned to the caller. If there are multiple clients simultaneously wanting to evict eachother's buffer objects, there is a chance that clients end up returning -ENOMEM.

The key to resolving this is that on memory contention, lower priority clients back off, releasing their buffer object locks and thereby allow their memory to be evicted. Eventually their priority will elevate and they will succeed. TTM has long been intending to implent this using full drm_exec locking during eviction. This means that when that is implemented, clients wanting to validate memory must pass the drm_exec context used to lock its buffer object to TTM validation. Most of this series is making sure that is done, both on exec-type validation and buffer object creation. The big benefit of this approach is that it can distinguish between memory types and avoid lock release rollbacks until it is really necessary. One drawback is that it can't handle system memory contention resolved by a shrinker.

However, since TTM has still to implement drm_exec validation, this series, while preparing for the TTM implementation, takes a different approach with an outer rw semaphore on top of the drm_exec retry loop. When a client wants to allocate graphics memory, the lock is taken in non-exclusive mode. If an OOM is hit, the locks are released and the outer lock is retaken in exclusive mode. That ensures that on memory contention, the client will, when the exclusive lock is held, be the only client trying to allocate memory. It requires, however, that all clients adhere to the same scheme.

The idea is that when TTM implements drm_exec eviction, the driver- managed scheme could be retired.

Patch 1 to 3 fixes fixes problems hit while testing.
Patch 4 identifies the code-paths where we need a drm_exec transaction. Patch 5 introduces the wrapper with the rw-semaphore

The rest of the patches ensure that we wrap graphics memory allocation in the combined rw-semaphore / drm-exec loop.

As a follow up, additional patches around suspend / resume will be posted.

Thomas Hellström (15):
drm/xe/vm: Don't use a pin the vm_resv during validation drm/xe/tests/xe_dma_buf: Set the drm_object::dma_buf member drm/xe/vm: Clear the scratch_pt pointer on error
drm/xe: Pass down drm_exec context to validation
drm/xe: Introduce an xe_validation wrapper around drm_exec drm/xe: Convert xe_bo_create_user() for exhaustive eviction drm/xe: Convert SVM validation for exhaustive eviction drm/xe: Convert existing drm_exec transactions for exhaustive eviction drm/xe: Convert the CPU fault handler for exhaustive eviction drm/xe/display: Convert __xe_pin_fb_vma()
drm/xe: Convert xe_dma_buf.c for exhaustive eviction drm/xe: Rename ___xe_bo_create_locked()
drm/xe: Convert xe_bo_create_pin_map_at() for exhaustive eviction drm/xe: Convert xe_bo_create_pin_map() for exhaustive eviction drm/xe: Convert pinned suspend eviction for exhaustive eviction

 drivers/gpu/drm/xe/Makefile                   |   1 +
 .../compat-i915-headers/gem/i915_gem_stolen.h |  24 +-
 drivers/gpu/drm/xe/display/intel_fbdev_fb.c   |  18 +-
 drivers/gpu/drm/xe/display/xe_dsb_buffer.c    |  10 +-
 drivers/gpu/drm/xe/display/xe_fb_pin.c        |  62 +-
 drivers/gpu/drm/xe/display/xe_hdcp_gsc.c      |   8 +-
 drivers/gpu/drm/xe/display/xe_plane_initial.c |   4 +-
 drivers/gpu/drm/xe/tests/xe_bo.c              |  36 +-
 drivers/gpu/drm/xe/tests/xe_dma_buf.c         |  24 +-
 drivers/gpu/drm/xe/tests/xe_migrate.c         |  66 +-
 drivers/gpu/drm/xe/xe_bo.c                    | 589 ++++++++++++------
 drivers/gpu/drm/xe/xe_bo.h                    |  56 +-
 drivers/gpu/drm/xe/xe_device.c                |   2 +
 drivers/gpu/drm/xe/xe_device_types.h          |   3 +
 drivers/gpu/drm/xe/xe_dma_buf.c               |  70 ++-
 drivers/gpu/drm/xe/xe_eu_stall.c              |   6 +-
 drivers/gpu/drm/xe/xe_exec.c                  |  26 +-
 drivers/gpu/drm/xe/xe_ggtt.c                  |  15 +-
 drivers/gpu/drm/xe/xe_ggtt.h                  |   5 +-
 drivers/gpu/drm/xe/xe_gsc.c                   |   8 +-
 drivers/gpu/drm/xe/xe_gt_pagefault.c          |  24 +-
 drivers/gpu/drm/xe/xe_gt_sriov_pf_config.c    |  22 +-
 drivers/gpu/drm/xe/xe_gt_sriov_pf_migration.c |  24 +-
 drivers/gpu/drm/xe/xe_guc_engine_activity.c   |  13 +-
 drivers/gpu/drm/xe/xe_lmtt.c                  |  12 +-
 drivers/gpu/drm/xe/xe_lrc.c                   |   7 +-
 drivers/gpu/drm/xe/xe_migrate.c               |  20 +-
 drivers/gpu/drm/xe/xe_oa.c                    |   6 +-
 drivers/gpu/drm/xe/xe_pt.c                    |  10 +-
 drivers/gpu/drm/xe/xe_pt.h                    |   3 +-
 drivers/gpu/drm/xe/xe_pxp_submit.c            |  34 +-
 drivers/gpu/drm/xe/xe_svm.c                   |  65 +-
 drivers/gpu/drm/xe/xe_validation.c            | 248 ++++++++
 drivers/gpu/drm/xe/xe_validation.h            | 176 ++++++
 drivers/gpu/drm/xe/xe_vm.c                    | 287 +++++----
 drivers/gpu/drm/xe/xe_vm.h                    |  52 +-
 drivers/gpu/drm/xe/xe_vm_types.h              |  32 +-
 37 files changed, 1413 insertions(+), 655 deletions(-)
 create mode 100644 drivers/gpu/drm/xe/xe_validation.c
 create mode 100644 drivers/gpu/drm/xe/xe_validation.h
Signature · 1 line
2.50.1