diff mbox series

[v2] drm/scheduler: use hw_rq_count for load calculation

Message ID 20181028095925.20389-1-nayan26deshmukh@gmail.com (mailing list archive)
State New, archived
Headers show
Series [v2] drm/scheduler: use hw_rq_count for load calculation | expand

Commit Message

Nayan Deshmukh Oct. 28, 2018, 9:59 a.m. UTC
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

Signed-off-by: Nayan Deshmukh <nayan26deshmukh@gmail.com>
---
 drivers/gpu/drm/scheduler/sched_entity.c | 12 +++++++++---
 1 file changed, 9 insertions(+), 3 deletions(-)

Comments

Christian König Nov. 7, 2018, 8:09 a.m. UTC | #1
Am 28.10.18 um 10:59 schrieb Nayan Deshmukh:
> 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

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.

>
> Signed-off-by: Nayan Deshmukh <nayan26deshmukh@gmail.com>
> ---
>   drivers/gpu/drm/scheduler/sched_entity.c | 12 +++++++++---
>   1 file changed, 9 insertions(+), 3 deletions(-)
>
> diff --git a/drivers/gpu/drm/scheduler/sched_entity.c b/drivers/gpu/drm/scheduler/sched_entity.c
> index 3e22a54a99c2..cfe48df6621d 100644
> --- a/drivers/gpu/drm/scheduler/sched_entity.c
> +++ b/drivers/gpu/drm/scheduler/sched_entity.c
> @@ -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;
> +			}
>   		}
>   	}
>
diff mbox series

Patch

diff --git a/drivers/gpu/drm/scheduler/sched_entity.c b/drivers/gpu/drm/scheduler/sched_entity.c
index 3e22a54a99c2..cfe48df6621d 100644
--- a/drivers/gpu/drm/scheduler/sched_entity.c
+++ b/drivers/gpu/drm/scheduler/sched_entity.c
@@ -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;
+			}
 		}
 	}