drm-compute.rst 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. ==================================
  2. Long running workloads and compute
  3. ==================================
  4. Long running workloads (compute) are workloads that will not complete in 10
  5. seconds. (The time let the user wait before he reaches for the power button).
  6. This means that other techniques need to be used to manage those workloads,
  7. that cannot use fences.
  8. Some hardware may schedule compute jobs, and have no way to pre-empt them, or
  9. have their memory swapped out from them. Or they simply want their workload
  10. not to be preempted or swapped out at all.
  11. This means that it differs from what is described in driver-api/dma-buf.rst.
  12. As with normal compute jobs, dma-fence may not be used at all. In this case,
  13. not even to force preemption. The driver with is simply forced to unmap a BO
  14. from the long compute job's address space on unbind immediately, not even
  15. waiting for the workload to complete. Effectively this terminates the workload
  16. when there is no hardware support to recover.
  17. Since this is undesirable, there need to be mitigations to prevent a workload
  18. from being terminated. There are several possible approach, all with their
  19. advantages and drawbacks.
  20. The first approach you will likely try is to pin all buffers used by compute.
  21. This guarantees that the job will run uninterrupted, but also allows a very
  22. denial of service attack by pinning as much memory as possible, hogging the
  23. all GPU memory, and possibly a huge chunk of CPU memory.
  24. A second approach that will work slightly better on its own is adding an option
  25. not to evict when creating a new job (any kind). If all of userspace opts in
  26. to this flag, it would prevent cooperating userspace from forced terminating
  27. older compute jobs to start a new one.
  28. If job preemption and recoverable pagefaults are not available, those are the
  29. only approaches possible. So even with those, you want a separate way of
  30. controlling resources. The standard kernel way of doing so is cgroups.
  31. This creates a third option, using cgroups to prevent eviction. Both GPU and
  32. driver-allocated CPU memory would be accounted to the correct cgroup, and
  33. eviction would be made cgroup aware. This allows the GPU to be partitioned
  34. into cgroups, that will allow jobs to run next to each other without
  35. interference.
  36. The interface to the cgroup would be similar to the current CPU memory
  37. interface, with similar semantics for min/low/high/max, if eviction can
  38. be made cgroup aware.
  39. What should be noted is that each memory region (tiled memory for example)
  40. should have its own accounting.
  41. The key is set to the regionid set by the driver, for example "tile0".
  42. For the value of $card, we use drmGetUnique().