<html>
  <head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
  </head>
  <body text="#000000" bgcolor="#FFFFFF">
    <div class="moz-cite-prefix">Am 02.08.2018 um 08:47 schrieb Nayan
      Deshmukh:<br>
    </div>
    <blockquote type="cite"
cite="mid:CAFd4ddwKJvfrTu5uAub1K517DhdcOZbZ8k=gyzPy6GVqx_PhtA@mail.gmail.com">
      <meta http-equiv="content-type" content="text/html; charset=utf-8">
      <div dir="ltr"><br>
        <br>
        <div class="gmail_quote">
          <div dir="ltr">On Thu, Aug 2, 2018 at 12:12 PM Christian König
            <<a href="mailto:ckoenig.leichtzumerken@gmail.com"
              moz-do-not-send="true">ckoenig.leichtzumerken@gmail.com</a>>
            wrote:<br>
          </div>
          <blockquote class="gmail_quote" style="margin:0 0 0
            .8ex;border-left:1px #ccc solid;padding-left:1ex">Am
            02.08.2018 um 00:25 schrieb Andrey Grodzovsky:<br>
            > Thinking again about this change and 53d5f1e
            drm/scheduler: move idle <br>
            > entities to scheduler with less load v2<br>
            ><br>
            > Looks to me like use case for which fc9a539
            drm/scheduler: add NULL <br>
            > pointer check for run queue (v2) was done<br>
            ><br>
            > will not work anymore.<br>
            ><br>
            > First of all in drm_sched_entity_push_job, 'if
            (!entity->rq)' will <br>
            > never be true any more since we stopped entity->rq
            to NULL in<br>
            ><br>
            > drm_sched_entity_flush.<br>
            <br>
            Good point, going to remove that.<br>
            <br>
            ><br>
            > Second of all, even after we removed the entity from rq
            in <br>
            > drm_sched_entity_flush to terminate any subsequent
            submissions<br>
            ><br>
            > to the queue the other thread doing push job can just
            acquire again a <br>
            > run queue<br>
            ><br>
            > from drm_sched_entity_get_free_sched and continue
            submission<br>
            <br>
          </blockquote>
          <div>Hi Christian <br>
          </div>
          <blockquote class="gmail_quote" style="margin:0 0 0
            .8ex;border-left:1px #ccc solid;padding-left:1ex">
            That is actually desired.<br>
            <br>
            When another process is now using the entity to submit jobs
            adding it <br>
            back to the rq is actually the right thing to do cause the
            entity is <br>
            still in use.<br>
          </blockquote>
          <div>I am not aware of the usecase so I might just be
            rambling. but if the thread/process that created the entity
            has called drm_sched_entity_flush then we shouldn't allow
            other processes to push jobs to that entity. <br>
          </div>
        </div>
      </div>
    </blockquote>
    <br>
    Why not?<br>
    <br>
    Calling flush() only means that we should wait for all waiting jobs
    to be send to the hardware. It doesn't mean that we need to stop
    accepting new jobs.<br>
    <br>
    It is perfectly possible that a child process has inherited a file
    descriptor from it's parent and calls flush because it exits, while
    the parent is still using the file descriptor.<br>
    <br>
    The only tricky part is how to handle it when a process is killed,
    but I think we came to good conclusion there as well.<br>
    <br>
    We remove the entity from the scheduling when the last process which
    submitted jobs is killed or if there is no such process any more and
    the current flushing process is killed.<br>
    <br>
    Christian.<br>
    <br>
    <blockquote type="cite"
cite="mid:CAFd4ddwKJvfrTu5uAub1K517DhdcOZbZ8k=gyzPy6GVqx_PhtA@mail.gmail.com">
      <div dir="ltr">
        <div class="gmail_quote">
          <div><br>
          </div>
          <div>Nayan  <br>
          </div>
          <blockquote class="gmail_quote" style="margin:0 0 0
            .8ex;border-left:1px #ccc solid;padding-left:1ex">
            <br>
            Christian.<br>
            <br>
            > so you can't substitute ' if (!entity->rq)' to 'if <br>
            > (list_empty(&entity->list))'.<br>
            ><br>
            > What about adding a 'stopped' flag to drm_sched_entity
            to be set in <br>
            > drm_sched_entity_flush and in<br>
            ><br>
            > drm_sched_entity_push_job check for  'if
            (!entity->stopped)' instead <br>
            > of  ' if (!entity->rq)' ?<br>
            ><br>
            > Andrey<br>
            ><br>
            ><br>
            > On 07/30/2018 07:03 AM, Christian König wrote:<br>
            >> We removed the redundancy of having an extra
            scheduler field, so we<br>
            >> can't set the rq to NULL any more or otherwise
            won't know which<br>
            >> scheduler to use for the cleanup.<br>
            >><br>
            >> Just remove the entity from the scheduling list
            instead.<br>
            >><br>
            >> Signed-off-by: Christian König <<a
              href="mailto:christian.koenig@amd.com" target="_blank"
              moz-do-not-send="true">christian.koenig@amd.com</a>><br>
            >> ---<br>
            >>   drivers/gpu/drm/scheduler/gpu_scheduler.c | 35 <br>
            >> +++++++------------------------<br>
            >>   1 file changed, 8 insertions(+), 27 deletions(-)<br>
            >><br>
            >> diff --git
            a/drivers/gpu/drm/scheduler/gpu_scheduler.c <br>
            >> b/drivers/gpu/drm/scheduler/gpu_scheduler.c<br>
            >> index f563e4fbb4b6..1b733229201e 100644<br>
            >> --- a/drivers/gpu/drm/scheduler/gpu_scheduler.c<br>
            >> +++ b/drivers/gpu/drm/scheduler/gpu_scheduler.c<br>
            >> @@ -198,21 +198,6 @@ int
            drm_sched_entity_init(struct <br>
            >> drm_sched_entity *entity,<br>
            >>   }<br>
            >>   EXPORT_SYMBOL(drm_sched_entity_init);<br>
            >>   -/**<br>
            >> - * drm_sched_entity_is_initialized - Query if
            entity is initialized<br>
            >> - *<br>
            >> - * @sched: Pointer to scheduler instance<br>
            >> - * @entity: The pointer to a valid scheduler
            entity<br>
            >> - *<br>
            >> - * return true if entity is initialized, false
            otherwise<br>
            >> -*/<br>
            >> -static bool drm_sched_entity_is_initialized(struct
            drm_gpu_scheduler <br>
            >> *sched,<br>
            >> -                        struct drm_sched_entity
            *entity)<br>
            >> -{<br>
            >> -    return entity->rq != NULL &&<br>
            >> -        entity->rq->sched == sched;<br>
            >> -}<br>
            >> -<br>
            >>   /**<br>
            >>    * drm_sched_entity_is_idle - Check if entity is
            idle<br>
            >>    *<br>
            >> @@ -224,7 +209,8 @@ static bool
            drm_sched_entity_is_idle(struct <br>
            >> drm_sched_entity *entity)<br>
            >>   {<br>
            >>       rmb();<br>
            >>   -    if (!entity->rq ||
            spsc_queue_peek(&entity->job_queue) == NULL)<br>
            >> +    if (list_empty(&entity->list) ||<br>
            >> +        spsc_queue_peek(&entity->job_queue)
            == NULL)<br>
            >>           return true;<br>
            >>         return false;<br>
            >> @@ -279,8 +265,6 @@ long
            drm_sched_entity_flush(struct <br>
            >> drm_sched_entity *entity, long timeout)<br>
            >>       long ret = timeout;<br>
            >>         sched = entity->rq->sched;<br>
            >> -    if (!drm_sched_entity_is_initialized(sched,
            entity))<br>
            >> -        return ret;<br>
            >>       /**<br>
            >>        * The client will not queue more IBs during
            this fini, consume <br>
            >> existing<br>
            >>        * queued IBs or discard them on SIGKILL<br>
            >> @@ -299,7 +283,7 @@ long
            drm_sched_entity_flush(struct <br>
            >> drm_sched_entity *entity, long timeout)<br>
            >>       last_user =
            cmpxchg(&entity->last_user, current->group_leader,
            <br>
            >> NULL);<br>
            >>       if ((!last_user || last_user ==
            current->group_leader) &&<br>
            >>           (current->flags & PF_EXITING)
            && (current->exit_code == <br>
            >> SIGKILL))<br>
            >> -        drm_sched_entity_set_rq(entity, NULL);<br>
            >> +        drm_sched_rq_remove_entity(entity->rq,
            entity);<br>
            >>         return ret;<br>
            >>   }<br>
            >> @@ -320,7 +304,7 @@ void
            drm_sched_entity_fini(struct <br>
            >> drm_sched_entity *entity)<br>
            >>       struct drm_gpu_scheduler *sched;<br>
            >>         sched = entity->rq->sched;<br>
            >> -    drm_sched_entity_set_rq(entity, NULL);<br>
            >> +    drm_sched_rq_remove_entity(entity->rq,
            entity);<br>
            >>         /* Consumption of existing IBs wasn't
            completed. Forcefully<br>
            >>        * remove them here.<br>
            >> @@ -416,15 +400,12 @@ void
            drm_sched_entity_set_rq(struct <br>
            >> drm_sched_entity *entity,<br>
            >>       if (entity->rq == rq)<br>
            >>           return;<br>
            >>   -    spin_lock(&entity->rq_lock);<br>
            >> -<br>
            >> -    if (entity->rq)<br>
            >> -        drm_sched_rq_remove_entity(entity->rq,
            entity);<br>
            >> +    BUG_ON(!rq);<br>
            >>   +    spin_lock(&entity->rq_lock);<br>
            >> +    drm_sched_rq_remove_entity(entity->rq,
            entity);<br>
            >>       entity->rq = rq;<br>
            >> -    if (rq)<br>
            >> -        drm_sched_rq_add_entity(rq, entity);<br>
            >> -<br>
            >> +    drm_sched_rq_add_entity(rq, entity);<br>
            >>       spin_unlock(&entity->rq_lock);<br>
            >>   }<br>
            >>   EXPORT_SYMBOL(drm_sched_entity_set_rq);<br>
            ><br>
            <br>
          </blockquote>
        </div>
      </div>
      <br>
      <fieldset class="mimeAttachmentHeader"></fieldset>
      <br>
      <pre wrap="">_______________________________________________
dri-devel mailing list
<a class="moz-txt-link-abbreviated" href="mailto:dri-devel@lists.freedesktop.org">dri-devel@lists.freedesktop.org</a>
<a class="moz-txt-link-freetext" href="https://lists.freedesktop.org/mailman/listinfo/dri-devel">https://lists.freedesktop.org/mailman/listinfo/dri-devel</a>
</pre>
    </blockquote>
    <br>
  </body>
</html>