Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

drm/sched: Optimise drm_sched_entity_push_job

In FIFO mode (which is the default), both drm_sched_entity_push_job() and
drm_sched_rq_update_fifo(), where the latter calls the former, are
currently taking and releasing the same entity->rq_lock.

We can avoid that design inelegance, and also have a miniscule
efficiency improvement on the submit from idle path, by introducing a new
drm_sched_rq_update_fifo_locked() helper and pulling up the lock taking to
its callers.

v2:
* Remove drm_sched_rq_update_fifo() altogether. (Christian)

v3:
* Improved commit message. (Philipp)

Signed-off-by: Tvrtko Ursulin <tvrtko.ursulin@igalia.com>
Cc: Christian König <christian.koenig@amd.com>
Cc: Alex Deucher <alexander.deucher@amd.com>
Cc: Luben Tuikov <ltuikov89@gmail.com>
Cc: Matthew Brost <matthew.brost@intel.com>
Cc: Philipp Stanner <pstanner@redhat.com>
Reviewed-by: Christian König <christian.koenig@amd.com>
Signed-off-by: Philipp Stanner <pstanner@redhat.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20241016122013.7857-2-tursulin@igalia.com

authored by

Tvrtko Ursulin and committed by
Philipp Stanner
d42a2546 fd3b2c5f

+13 -8
+9 -4
drivers/gpu/drm/scheduler/sched_entity.c
··· 514 514 struct drm_sched_job *next; 515 515 516 516 next = to_drm_sched_job(spsc_queue_peek(&entity->job_queue)); 517 - if (next) 518 - drm_sched_rq_update_fifo(entity, next->submit_ts); 517 + if (next) { 518 + spin_lock(&entity->rq_lock); 519 + drm_sched_rq_update_fifo_locked(entity, 520 + next->submit_ts); 521 + spin_unlock(&entity->rq_lock); 522 + } 519 523 } 520 524 521 525 /* Jobs and entities might have different lifecycles. Since we're ··· 617 613 sched = rq->sched; 618 614 619 615 drm_sched_rq_add_entity(rq, entity); 620 - spin_unlock(&entity->rq_lock); 621 616 622 617 if (drm_sched_policy == DRM_SCHED_POLICY_FIFO) 623 - drm_sched_rq_update_fifo(entity, submit_ts); 618 + drm_sched_rq_update_fifo_locked(entity, submit_ts); 619 + 620 + spin_unlock(&entity->rq_lock); 624 621 625 622 drm_sched_wakeup(sched); 626 623 }
+3 -3
drivers/gpu/drm/scheduler/sched_main.c
··· 163 163 } 164 164 } 165 165 166 - void drm_sched_rq_update_fifo(struct drm_sched_entity *entity, ktime_t ts) 166 + void drm_sched_rq_update_fifo_locked(struct drm_sched_entity *entity, ktime_t ts) 167 167 { 168 168 /* 169 169 * Both locks need to be grabbed, one to protect from entity->rq change 170 170 * for entity from within concurrent drm_sched_entity_select_rq and the 171 171 * other to update the rb tree structure. 172 172 */ 173 - spin_lock(&entity->rq_lock); 173 + lockdep_assert_held(&entity->rq_lock); 174 + 174 175 spin_lock(&entity->rq->lock); 175 176 176 177 drm_sched_rq_remove_fifo_locked(entity); ··· 182 181 drm_sched_entity_compare_before); 183 182 184 183 spin_unlock(&entity->rq->lock); 185 - spin_unlock(&entity->rq_lock); 186 184 } 187 185 188 186 /**
+1 -1
include/drm/gpu_scheduler.h
··· 593 593 void drm_sched_rq_remove_entity(struct drm_sched_rq *rq, 594 594 struct drm_sched_entity *entity); 595 595 596 - void drm_sched_rq_update_fifo(struct drm_sched_entity *entity, ktime_t ts); 596 + void drm_sched_rq_update_fifo_locked(struct drm_sched_entity *entity, ktime_t ts); 597 597 598 598 int drm_sched_entity_init(struct drm_sched_entity *entity, 599 599 enum drm_sched_priority priority,