STRUCT DRM_SCHED_ENTITY(9)
π NAME π
Okay bestie, welcome to the struct drm_sched_entity(9) page in the Kernel API Manual. This struct is literally a wrapper around a job queue (typically attached to the DRM file_priv). Thatβs the whole vibe.
β¨ SYNOPSIS β¨
struct drm_sched_entity {
struct list_head list;
spinlock_t lock;
struct drm_sched_rq *rq;
struct drm_sched_entity_stats *stats;
struct drm_gpu_scheduler **sched_list;
unsigned int num_sched_list;
enum drm_sched_priority priority;
enum drm_sched_priority rq_priority;
ktime_t rr_ts;
struct spsc_queue job_queue;
atomic_t fence_seq;
uint64_t fence_context;
struct dma_fence *dependency;
struct dma_fence_cb cb;
atomic_t *guilty;
struct dma_fence *last_scheduled;
struct task_struct *last_user;
bool stopped;
struct completion entity_idle;
ktime_t oldest_job_waiting;
struct rb_node rb_tree_node;
};
π«Ά Members π«Ά
listβ Used to append this struct to the list of entities in the runqueuerqunderdrm_sched_rq.entities.
Protected by drm_sched_rq.lock of rq.
lockβ Lock protecting the run-queue (rq) to which this entity belongs,priority, the list of schedulers (sched_list,num_sched_list) and therr_tsfield.rqβ Runqueue on which this entity is currently scheduled.
FIXME: Locking is very unclear for this. Writers are protected bylock, but readers are generally lockless and seem to just race with not even aREAD_ONCE.
statsβ Stats object reference held by the entity and jobs.sched_listβ A list of schedulers (struct drm_gpu_scheduler). Jobs from this entity can be scheduled on any scheduler on this list.
This can be modified by calling drm_sched_entity_modify_sched. Locking is entirely up to the driver, see the above function for more details.
This will be set to NULL if num_sched_list equals 1 and rq has been set already.
FIXME: This means priority changes through drm_sched_entity_set_priority will be lost henceforth in this case.
num_sched_listβ Number ofdrm_gpu_schedulersin thesched_list.priorityβ Priority of the entity. This can be modified by callingdrm_sched_entity_set_priority. Protected bylock.rq_priorityβ Run-queue priority.rr_tsβ Fake timestamp of the last popped job from the entity.job_queueβ the list of jobs of this entity.fence_seqβ A linearly increasing seqno incremented with each newdrm_sched_fencewhich is part of the entity.
FIXME: Callers of drm_sched_job_arm need to ensure correct locking, this doesnβt need to be atomic.
fence_contextβ A unique context for all the fences which belong to this entity. Thedrm_sched_fence.scheduleduses thefence_contextbutdrm_sched_fence.finishedusesfence_context + 1.dependencyβ The dependency fence of the job which is on the top of the job queue.cbβ Callback for the dependency fence above.guiltyβ Points to entitiesβ guilty.last_scheduledβ Points to the finished fence of the last scheduled job. Only written bydrm_sched_entity_pop_job. Can be accessed locklessly fromdrm_sched_job_armif the queue is empty.last_userβ last group leader pushing a job into the entity.stoppedβ Marks the enity as removed fromrqand destined for termination. This is set by callingdrm_sched_entity_flush.entity_idleβ Signals when entity is not in use, used to sequence entity cleanup indrm_sched_entity_fini.oldest_job_waitingβ Marks earliest job waiting in SW queue.rb_tree_nodeβ The node used to insert this entity into time based priority queue.
π Description π
Entities emit jobs in order to their corresponding hardware ring, and the scheduler alternates between entities based on scheduling policy. Periodt. π₯
π SEE ALSO π
Bestie, go read these too:
- Kernel file
./include/drm/gpu_scheduler.h DRM_SCHED_FENCE_DONT_PIPELINE(9)DRM_SCHED_FENCE_FLAG_HAS_DEADLINE_BIT(9)struct drm_sched_rq(9)struct drm_sched_fence(9)struct drm_sched_job(9)enum drm_gpu_sched_stat(9)struct drm_sched_backend_ops(9)struct drm_gpu_scheduler(9)struct drm_sched_init_args(9)struct drm_sched_pending_job_iter(9)drm_sched_for_each_pending_job(9)
Kernel API Manual, source ./include/drm, October 2026 β page struct drm_sched_entity(9), mwah π
π¦ where this page comes from
- nixpkgs unstable: linux-manual 7.3.1
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms