History

drm/i915/scheduler: Support user-defined priorities

Use a priority stored in the context as the initial value when submitting a request. This allows us to change the default priority on a per-context basis, allowing different contexts to be favoured with GPU time at the expense of lower importance work. The user can adjust the context's priority via I915_CONTEXT_PARAM_PRIORITY, with more positive values being higher priority (they will be serviced earlier, after their dependencies have been resolved). Any prerequisite work for an execbuf will have its priority raised to match the new request as required. Normal users can specify any value in the range of -1023 to 0 [default], i.e. they can reduce the priority of their workloads (and temporarily boost it back to normal if so desired). Privileged users can specify any value in the range of -1023 to 1023, [default is 0], i.e. they can raise their priority above all overs and so potentially starve the system. Note that the existing schedulers are not fair, nor load balancing, the execution is strictly by priority on a first-come, first-served basis, and the driver may choose to boost some requests above the range available to users. This priority was originally based around nice(2), but evolved to allow clients to adjust their priority within a small range, and allow for a privileged high priority range. For example, this can be used to implement EGL_IMG_context_priority https://www.khronos.org/registry/egl/extensions/IMG/EGL_IMG_context_priority.txt EGL_CONTEXT_PRIORITY_LEVEL_IMG determines the priority level of the context to be created. This attribute is a hint, as an implementation may not support multiple contexts at some priority levels and system policy may limit access to high priority contexts to appropriate system privilege level. The default value for EGL_CONTEXT_PRIORITY_LEVEL_IMG is EGL_CONTEXT_PRIORITY_MEDIUM_IMG." so we can map PRIORITY_HIGH -> 1023 [privileged, will failback to 0] PRIORITY_MED -> 0 [default] PRIORITY_LOW -> -1023 They also map onto the priorities used by VkQueue (and a VkQueue is essentially a timeline, our i915_gem_context under full-ppgtt). v2: s/CAP_SYS_ADMIN/CAP_SYS_NICE/ v3: Report min/max user priorities as defines in the uapi, and rebase internal priorities on the exposed values.

Chris Wilson committed 9 years ago

Commit ac14fbd1 parent beecec94 files · +41 −4Browse files

Showing the changes to include/uapi (1 of 4 files). Show all

Unified · Split

include/uapi/drm/i915_drm.h+7−0
@@ -402,6 +402,9 @@ typedef struct drm_i915_irq_wait { · 401 unmodified lines
402 * priorities and the driver will attempt to execute batches in priority order.402 * priorities and the driver will attempt to execute batches in priority order.
403 * The param returns a capability bitmask, nonzero implies that the scheduler403 * The param returns a capability bitmask, nonzero implies that the scheduler
404 * is enabled, with different features present according to the mask.404 * is enabled, with different features present according to the mask.
405 *
406 * The initial priority for each batch is supplied by the context and is
407 * controlled via I915_CONTEXT_PARAM_PRIORITY.
405 */408 */
406#define I915_PARAM_HAS_SCHEDULER 41409#define I915_PARAM_HAS_SCHEDULER 41
407#define I915_SCHEDULER_CAP_ENABLED (1ul << 0)410#define I915_SCHEDULER_CAP_ENABLED (1ul << 0)
@@ -1367,6 +1370,10 @@ struct drm_i915_gem_context_param { · 959 unmodified lines
1367#define I915_CONTEXT_PARAM_GTT_SIZE 0x31370#define I915_CONTEXT_PARAM_GTT_SIZE 0x3
1368#define I915_CONTEXT_PARAM_NO_ERROR_CAPTURE 0x41371#define I915_CONTEXT_PARAM_NO_ERROR_CAPTURE 0x4
1369#define I915_CONTEXT_PARAM_BANNABLE 0x51372#define I915_CONTEXT_PARAM_BANNABLE 0x5
1373#define I915_CONTEXT_PARAM_PRIORITY 0x6
1374#define I915_CONTEXT_MAX_USER_PRIORITY 1023 /* inclusive */
1375#define I915_CONTEXT_DEFAULT_PRIORITY 0
1376#define I915_CONTEXT_MIN_USER_PRIORITY -1023 /* inclusive */
1370 __u64 value;1377 __u64 value;
1371};1378};
1372 1379

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t