diff mbox series

drm/scheduler: use hw_rq_count for load calculation

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

Commit Message

Nayan Deshmukh Oct. 18, 2018, 3:37 p.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.

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

Comments

Christian König Oct. 22, 2018, 12:46 p.m. UTC | #1
Am 18.10.18 um 17:37 schrieb :
> 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.

>
> Signed-off-by: Nayan Deshmukh <nayan26deshmukh@gmail.com>
> ---
>   drivers/gpu/drm/scheduler/sched_entity.c | 14 ++++++++++++++
>   1 file changed, 14 insertions(+)
>
> diff --git a/drivers/gpu/drm/scheduler/sched_entity.c b/drivers/gpu/drm/scheduler/sched_entity.c
> index 3e22a54a99c2..4d18497d6ecf 100644
> --- a/drivers/gpu/drm/scheduler/sched_entity.c
> +++ b/drivers/gpu/drm/scheduler/sched_entity.c
> @@ -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;
Nayan Deshmukh Oct. 23, 2018, 2:52 p.m. UTC | #2
On Mon, Oct 22, 2018 at 9:46 PM Koenig, Christian
<Christian.Koenig@amd.com> wrote:
>
> Am 18.10.18 um 17:37 schrieb :
> > 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
> 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.
>
> >
> > Signed-off-by: Nayan Deshmukh <nayan26deshmukh@gmail.com>
> > ---
> >   drivers/gpu/drm/scheduler/sched_entity.c | 14 ++++++++++++++
> >   1 file changed, 14 insertions(+)
> >
> > diff --git a/drivers/gpu/drm/scheduler/sched_entity.c b/drivers/gpu/drm/scheduler/sched_entity.c
> > index 3e22a54a99c2..4d18497d6ecf 100644
> > --- a/drivers/gpu/drm/scheduler/sched_entity.c
> > +++ b/drivers/gpu/drm/scheduler/sched_entity.c
> > @@ -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;
>
diff mbox series

Patch

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