From: =?UTF-8?Q?Christian_K=c3=b6nig?= Subject: Re: [PATCH] drm/scheduler: fix last_scheduled handling Date: Wed, 8 Aug 2018 13:06:33 +0200 Message-ID: <9a379b2d-8699-c69e-5c13-b509f8954992@gmail.com> References: <20180807125424.36948-1-christian.koenig@amd.com> Reply-To: christian.koenig@amd.com Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="===============0419137590==" Return-path: Received: from mail-wr1-x444.google.com (mail-wr1-x444.google.com [IPv6:2a00:1450:4864:20::444]) by gabe.freedesktop.org (Postfix) with ESMTPS id D3C626E524 for ; Wed, 8 Aug 2018 11:06:35 +0000 (UTC) Received: by mail-wr1-x444.google.com with SMTP id h9-v6so1662524wro.3 for ; Wed, 08 Aug 2018 04:06:35 -0700 (PDT) In-Reply-To: Content-Language: en-US List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" To: Nayan Deshmukh Cc: Maling list - DRI developers List-Id: dri-devel@lists.freedesktop.org This is a multi-part message in MIME format. --===============0419137590== Content-Type: multipart/alternative; boundary="------------6AD8839B10898619568358C4" Content-Language: en-US This is a multi-part message in MIME format. --------------6AD8839B10898619568358C4 Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 8bit Am 08.08.2018 um 12:55 schrieb Nayan Deshmukh: > Hi Christian, > > On Wed, Aug 8, 2018 at 4:20 PM Christian König > > wrote: > > Ping, Nayan any comments on that or can I commit it? > > This is just a stripped down version of my original last_scheduled > improvement patch. > > I had missed the mail yesterday. I was just looking at the code right > now. The code looks fine but I wanted to run it once before giving it > a Rb. > > I was wondering why you stripped it down. Was there some problem with > the previous one? No, not really. But this is a bug fix and bug fixes should be as simple as possible. Improvements should come in separate patches. Didn't thought initially that this is actually a fix. BTW: Another small fix is required, looks like we need the scheduler correctly set for debugging even earlier. Christian. > > Cheers, > Nayan > > Christian. > > Am 07.08.2018 um 14:54 schrieb Christian König: > > Make sure we access last_scheduled only after checking that > there are no > > more jobs on the entity. > > > > Signed-off-by: Christian König > > > --- > >   drivers/gpu/drm/scheduler/gpu_scheduler.c | 21 > +++++++++++---------- > >   1 file changed, 11 insertions(+), 10 deletions(-) > > > > diff --git a/drivers/gpu/drm/scheduler/gpu_scheduler.c > b/drivers/gpu/drm/scheduler/gpu_scheduler.c > > index 8ee249886473..bd7883d1b964 100644 > > --- a/drivers/gpu/drm/scheduler/gpu_scheduler.c > > +++ b/drivers/gpu/drm/scheduler/gpu_scheduler.c > > @@ -568,19 +568,20 @@ void drm_sched_entity_push_job(struct > drm_sched_job *sched_job, > >                              struct drm_sched_entity *entity) > >   { > >       struct drm_sched_rq *rq = entity->rq; > > -     bool first, reschedule, idle; > > +     bool first; > > > > -     idle = entity->last_scheduled == NULL || > > -  dma_fence_is_signaled(entity->last_scheduled); > >       first = spsc_queue_count(&entity->job_queue) == 0; > > -     reschedule = idle && first && (entity->num_rq_list > 1); > > +     if (first && (entity->num_rq_list > 1)) { > > +             struct dma_fence *fence; > > > > -     if (reschedule) { > > -             rq = drm_sched_entity_get_free_sched(entity); > > -             spin_lock(&entity->rq_lock); > > -  drm_sched_rq_remove_entity(entity->rq, entity); > > -             entity->rq = rq; > > -             spin_unlock(&entity->rq_lock); > > +             fence = READ_ONCE(entity->last_scheduled); > > +             if (fence == NULL || dma_fence_is_signaled(fence)) { > > +                     rq = drm_sched_entity_get_free_sched(entity); > > +  spin_lock(&entity->rq_lock); > > +  drm_sched_rq_remove_entity(entity->rq, entity); > > +                     entity->rq = rq; > > +  spin_unlock(&entity->rq_lock); > > +             } > >       } > > > >       sched_job->sched = entity->rq->sched; > --------------6AD8839B10898619568358C4 Content-Type: text/html; charset=utf-8 Content-Transfer-Encoding: 8bit
Am 08.08.2018 um 12:55 schrieb Nayan Deshmukh:
Hi Christian,

On Wed, Aug 8, 2018 at 4:20 PM Christian König <ckoenig.leichtzumerken@gmail.com> wrote:
Ping, Nayan any comments on that or can I commit it?

This is just a stripped down version of my original last_scheduled
improvement patch.

I had missed the mail yesterday. I was just looking at the code right now. The code looks fine but I wanted to run it once before giving it a Rb.

I was wondering why you stripped it down. Was there some problem with the previous one?

No, not really. But this is a bug fix and bug fixes should be as simple as possible.

Improvements should come in separate patches. Didn't thought initially that this is actually a fix.

BTW: Another small fix is required, looks like we need the scheduler correctly set for debugging even earlier.

Christian.


Cheers,
Nayan
Christian.

Am 07.08.2018 um 14:54 schrieb Christian König:
> Make sure we access last_scheduled only after checking that there are no
> more jobs on the entity.
>
> Signed-off-by: Christian König <christian.koenig@amd.com>
> ---
>   drivers/gpu/drm/scheduler/gpu_scheduler.c | 21 +++++++++++----------
>   1 file changed, 11 insertions(+), 10 deletions(-)
>
> diff --git a/drivers/gpu/drm/scheduler/gpu_scheduler.c b/drivers/gpu/drm/scheduler/gpu_scheduler.c
> index 8ee249886473..bd7883d1b964 100644
> --- a/drivers/gpu/drm/scheduler/gpu_scheduler.c
> +++ b/drivers/gpu/drm/scheduler/gpu_scheduler.c
> @@ -568,19 +568,20 @@ void drm_sched_entity_push_job(struct drm_sched_job *sched_job,
>                              struct drm_sched_entity *entity)
>   {
>       struct drm_sched_rq *rq = entity->rq;
> -     bool first, reschedule, idle;
> +     bool first;
>   
> -     idle = entity->last_scheduled == NULL ||
> -             dma_fence_is_signaled(entity->last_scheduled);
>       first = spsc_queue_count(&entity->job_queue) == 0;
> -     reschedule = idle && first && (entity->num_rq_list > 1);
> +     if (first && (entity->num_rq_list > 1)) {
> +             struct dma_fence *fence;
>   
> -     if (reschedule) {
> -             rq = drm_sched_entity_get_free_sched(entity);
> -             spin_lock(&entity->rq_lock);
> -             drm_sched_rq_remove_entity(entity->rq, entity);
> -             entity->rq = rq;
> -             spin_unlock(&entity->rq_lock);
> +             fence = READ_ONCE(entity->last_scheduled);
> +             if (fence == NULL || dma_fence_is_signaled(fence)) {
> +                     rq = drm_sched_entity_get_free_sched(entity);
> +                     spin_lock(&entity->rq_lock);
> +                     drm_sched_rq_remove_entity(entity->rq, entity);
> +                     entity->rq = rq;
> +                     spin_unlock(&entity->rq_lock);
> +             }
>       }
>   
>       sched_job->sched = entity->rq->sched;


--------------6AD8839B10898619568358C4-- --===============0419137590== Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: base64 Content-Disposition: inline X19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX18KZHJpLWRldmVs IG1haWxpbmcgbGlzdApkcmktZGV2ZWxAbGlzdHMuZnJlZWRlc2t0b3Aub3JnCmh0dHBzOi8vbGlz dHMuZnJlZWRlc2t0b3Aub3JnL21haWxtYW4vbGlzdGluZm8vZHJpLWRldmVsCg== --===============0419137590==--