drm/scheduler: use hw_rq_count for load calculation
Subsystems (3)
PATCH 1/1 drm/scheduler: use hw_rq_count for load calculation
If the hardware queue for a scheduler is empty then we don't need to the shift the entities from their current scheduler as they are not getting scheduled because of some dependency.
--- drivers/gpu/drm/scheduler/sched_entity.c | 14 ++++++++++++++ 1 file changed, 14 insertions(+)
drivers/gpu/drm/scheduler/sched_entity.c +14 -0
@@ -130,6 +130,12 @@ drm_sched_entity_get_free_sched(struct drm_sched_entity *entity)int i;for (i =0 ; i < entity->num_rq_list; ++i) { +if (atomic_read (&entity->rq_list[i]->sched->hw_rq_count) < + entity->rq_list[i]->sched->hw_submission_limit) { + rq = entity->rq_list[i]; +break ; + } + num_jobs =atomic_read (&entity->rq_list[i]->sched->num_jobs);if (num_jobs < min_jobs) { min_jobs = num_jobs;
@@ -470,6 +476,14 @@ void drm_sched_entity_select_rq(struct drm_sched_entity *entity)if (spsc_queue_count (&entity->job_queue) || entity->num_rq_list <=1 )return ; +/* +* We don't need to shift entity if the hardware +* queue of current scheduler is empty +*/ +if (atomic_read (&entity->rq->sched->hw_rq_count) < + entity->rq->sched->hw_submission_limit) +return ; + fence =READ_ONCE (entity->last_scheduled);if (fence && !dma_fence_is_signaled (fence))return ;
Signature · 6 lines
2.14.3 _______________________________________________ dri-devel mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/dri-devel
Am 18.10.18 um 17:37 schrieb :
Quoted 3 lines
If the hardware queue for a scheduler is empty then we don't need to the shift the entities from their current scheduler as they are not getting scheduled because of some dependency.
That is most likely not a good idea. The scheduler might not have anything todo right now, but we can't guarantee that it will stay this way.
Instead when the number of jobs on a rq is identical we should select the one with the least entities on it.
This should make sure that we distribute the entities equally among the runqueues even when they are idle.
Christian.
Quoted 28 lines
Signed-off-by Nayan Deshmukh <[email protected]>--- drivers/gpu/drm/scheduler/sched_entity.c | 14 ++++++++++++++ 1 file changed, 14 insertions(+)drivers/gpu/drm/scheduler/sched_entity.c +7
-0@@ -130,6 +130,12 @@ drm_sched_entity_get_free_sched(struct drm_sched_entity *entity)int i;for (i =0 ; i < entity->num_rq_list; ++i) { +if (atomic_read (&entity->rq_list[i]->sched->hw_rq_count) < + entity->rq_list[i]->sched->hw_submission_limit) { + rq = entity->rq_list[i]; +break ; + } + num_jobs =atomic_read (&entity->rq_list[i]->sched->num_jobs);if (num_jobs < min_jobs) { min_jobs = num_jobs;@@ -470,6 +476,14 @@ void drm_sched_entity_select_rq(struct drm_sched_entity *entity)if (spsc_queue_count (&entity->job_queue) || entity->num_rq_list <=1 )return ; +/*
drivers/gpu/drm/scheduler/sched_entity.c void drm_sched_entity_select_rq(struct drm_sched_entity *entity) · line 489
Quoted 10 lines
drivers/gpu/drm/scheduler/sched_entity.c +7
-0+* We don't need to shift entity if the hardware +* queue of current scheduler is empty +*/ +if (atomic_read (&entity->rq->sched->hw_rq_count) < + entity->rq->sched->hw_submission_limit) +return ; + fence =READ_ONCE (entity->last_scheduled);if (fence && !dma_fence_is_signaled (fence))return ;
_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
Quoted 9 lines · Christian
Am 18.10.18 um 17:37 schrieb :
Quoted 3 lines
If the hardware queue for a scheduler is empty then we don't need to the shift the entities from their current scheduler as they are not getting scheduled because of some dependency.
That is most likely not a good idea. The scheduler might not have anything todo right now, but we can't guarantee that it will stay this way.
I agree. But conversely it might also happens that one hardware engine is sitting idle until the runqueue of the other schedulers comes to the level of this scheduler.
I think the best option is to pick the scheduler with empty hardware queue when the difference in their software queues is less that MAX_DIFF. The problem is that determining the optimal value of MAX_DIFF is not all that easy.
For now it's better to use MAX_DIFF=0 as you suggested until we can find a way to determine its value.
Regards,
Nayan
Quoted 35 lines
Instead when the number of jobs on a rq is identical we should select the one with the least entities on it.
This should make sure that we distribute the entities equally among the runqueues even when they are idle.
Christian.
Quoted 27 lines
Signed-off-by Nayan Deshmukh <[email protected]>--- drivers/gpu/drm/scheduler/sched_entity.c | 14 ++++++++++++++ 1 file changed, 14 insertions(+)drivers/gpu/drm/scheduler/sched_entity.c +6
-0@@ -130,6 +130,12 @@ drm_sched_entity_get_free_sched(struct drm_sched_entity *entity)int i;for (i =0 ; i < entity->num_rq_list; ++i) { +if (atomic_read (&entity->rq_list[i]->sched->hw_rq_count) < + entity->rq_list[i]->sched->hw_submission_limit) { + rq = entity->rq_list[i]; +break ; + } + num_jobs =atomic_read (&entity->rq_list[i]->sched->num_jobs);if (num_jobs < min_jobs) { min_jobs = num_jobs;@@ -470,6 +476,14 @@ void drm_sched_entity_select_rq(struct drm_sched_entity *entity)if (spsc_queue_count (&entity->job_queue) || entity->num_rq_list <=1 )return ;
Quoted 12 lines
drivers/gpu/drm/scheduler/sched_entity.c void drm_sched_entity_select_rq(struct drm_sched_entity *entity) · line 489
Quoted 11 lines
drivers/gpu/drm/scheduler/sched_entity.c +8
-0+/* +* We don't need to shift entity if the hardware +* queue of current scheduler is empty +*/ +if (atomic_read (&entity->rq->sched->hw_rq_count) < + entity->rq->sched->hw_submission_limit) +return ; + fence =READ_ONCE (entity->last_scheduled);if (fence && !dma_fence_is_signaled (fence))return ;
_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
PATCH v2 1/1 drm/scheduler: use hw_rq_count for load calculation
If the hardware queue for a scheduler is empty then we don't need to the shift the entities from their current scheduler as they are not getting scheduled because of some dependency.
v2: to calculate the least loaded scheduler we only use hw_rq_count when the number of jobs in their run queue are same
--- drivers/gpu/drm/scheduler/sched_entity.c | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-)
drivers/gpu/drm/scheduler/sched_entity.c +9 -3
@@ -125,15 +125,21 @@ bool drm_sched_entity_is_ready(struct drm_sched_entity *entity)static struct drm_sched_rq *drm_sched_entity_get_free_sched (struct drm_sched_entity *entity) { -struct drm_sched_rq *rq =NULL ; +struct drm_sched_rq *rq =NULL , *curr_rq =NULL ;unsigned int min_jobs =UINT_MAX , num_jobs;int i;for (i =0 ; i < entity->num_rq_list; ++i) { - num_jobs =atomic_read (&entity->rq_list[i]->sched->num_jobs); + curr_rq = entity->rq_list[i]; + num_jobs =atomic_read (&curr_rq->sched->num_jobs);if (num_jobs < min_jobs) { min_jobs = num_jobs; - rq = entity->rq_list[i]; + rq = curr_rq; + }else if (num_jobs == min_jobs) { +if (atomic_read (&curr_rq->sched->hw_rq_count) < +atomic_read (&rq->sched->hw_rq_count)) { + rq = curr_rq; + } } }
Signature · 6 lines
2.14.3 _______________________________________________ dri-devel mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/dri-devel
Christian König
reviewerAm 28.10.18 um 10:59 schrieb Nayan Deshmukh:
Quoted 6 lines
If the hardware queue for a scheduler is empty then we don't need to the shift the entities from their current scheduler as they are not getting scheduled because of some dependency.
v2: to calculate the least loaded scheduler we only use
hw_rq_countwhen the number of jobs in their run queue are same
I still don't think that the hw_rq_count is the right thing to use here.
It is only a very short living snapshot of the momentary load and doesn't reflect what is going on the ring in general.
When the number of jobs is equal I would rather use the number of entities a scheduler has already assigned.
Christian.
Quoted 25 lines
Signed-off-by Nayan Deshmukh <[email protected]>--- drivers/gpu/drm/scheduler/sched_entity.c | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-)drivers/gpu/drm/scheduler/sched_entity.c +3
-2@@ -125,15 +125,21 @@ bool drm_sched_entity_is_ready(struct drm_sched_entity *entity)static struct drm_sched_rq *drm_sched_entity_get_free_sched (struct drm_sched_entity *entity) { -struct drm_sched_rq *rq =NULL ; +struct drm_sched_rq *rq =NULL , *curr_rq =NULL ;unsigned int min_jobs =UINT_MAX , num_jobs;int i;for (i =0 ; i < entity->num_rq_list; ++i) { - num_jobs =atomic_read (&entity->rq_list[i]->sched->num_jobs); + curr_rq = entity->rq_list[i]; + num_jobs =atomic_read (&curr_rq->sched->num_jobs);if (num_jobs < min_jobs) { min_jobs = num_jobs;
drivers/gpu/drm/scheduler/sched_entity.c bool drm_sched_entity_is_ready(struct drm_sched_entity *entity) · line 145
Quoted 10 lines
drivers/gpu/drm/scheduler/sched_entity.c +6
-1- rq = entity->rq_list[i]; + rq = curr_rq; + }else if (num_jobs == min_jobs) { +if (atomic_read (&curr_rq->sched->hw_rq_count) < +atomic_read (&rq->sched->hw_rq_count)) { + rq = curr_rq; + } } }
_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel