All of lore.kernel.org
 help / color / mirror / Atom feed
From: Nayan Deshmukh <nayan26deshmukh-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
To: "Christian König" <christian.koenig-5C7GfCeVMHo@public.gmane.org>
Cc: Alex Deucher
	<alexdeucher-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>,
	Eric Anholt <eric-WhKQ6XTQaPysTnJN9+BGXg@public.gmane.org>,
	amd-gfx-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW@public.gmane.org,
	Maling list - DRI developers
	<dri-devel-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW@public.gmane.org>,
	l.stach-bIcnvbaLZ9MEGnE8C9+IrQ@public.gmane.org
Subject: Re: [PATCH 3/4] drm/scheduler: add new function to get least loaded sched
Date: Tue, 31 Jul 2018 17:05:54 +0530	[thread overview]
Message-ID: <CAFd4ddxxh_RtnafPTYKDZbWAih41f6umyo8iWWo1bf-Oww87QA@mail.gmail.com> (raw)
In-Reply-To: <1e24b45b-027c-2742-97eb-21054798218d-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>


[-- Attachment #1.1: Type: text/plain, Size: 2311 bytes --]

I will take care of that in v2.

On Tue, Jul 31, 2018 at 4:57 PM Christian König <
ckoenig.leichtzumerken-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:

> Am 31.07.2018 um 12:37 schrieb Nayan Deshmukh:
> > The function selects the run queue from the rq_list with the
> > least load. The load is decided by the number of jobs in a
> > scheduler.
> >
> > Signed-off-by: Nayan Deshmukh <nayan26deshmukh-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
> > ---
> >   drivers/gpu/drm/scheduler/gpu_scheduler.c | 26
> ++++++++++++++++++++++++++
> >   1 file changed, 26 insertions(+)
> >
> > diff --git a/drivers/gpu/drm/scheduler/gpu_scheduler.c
> b/drivers/gpu/drm/scheduler/gpu_scheduler.c
> > index 375f6f7f6a93..c67f65ad8f15 100644
> > --- a/drivers/gpu/drm/scheduler/gpu_scheduler.c
> > +++ b/drivers/gpu/drm/scheduler/gpu_scheduler.c
> > @@ -255,6 +255,32 @@ static bool drm_sched_entity_is_ready(struct
> drm_sched_entity *entity)
> >       return true;
> >   }
> >
> > +/**
> > + * drm_sched_entity_get_free_sched - Get the rq from rq_list with least
> load
> > + *
> > + * @entity: scheduler entity
> > + *
> > + * Return the pointer to the rq with least load.
> > + */
> > +static struct drm_sched_rq *
> > +drm_sched_entity_get_free_sched(struct drm_sched_entity *entity)
> > +{
> > +     struct drm_sched_rq *rq = NULL;
> > +     unsigned int min_jobs = UINT_MAX;
> > +     int i;
> > +
> > +     for (i = 0; i < entity->num_rq_list; ++i) {
> > +             if (atomic_read(&entity->rq_list[i]->sched->num_jobs) <
> > +                             min_jobs) {
> > +                     min_jobs = atomic_read(
> > +
>  &entity->rq_list[i]->sched->num_jobs);
>
> When you use atomic_read twice you might get different results because
> the atomic has changed in the meantime.
>
> In other words you need to store the result locally:
>
> unsigned int num_jobs = atomic_read(....);
>
> if (num_jobs < min_jobs) {
>      min_jobs = num_jobs;
>      .....
>
> Christian.
>
> > +                     rq = entity->rq_list[i];
> > +             }
> > +     }
> > +
> > +     return rq;
> > +}
> > +
> >   static void drm_sched_entity_kill_jobs_cb(struct dma_fence *f,
> >                                   struct dma_fence_cb *cb)
> >   {
>
>

[-- Attachment #1.2: Type: text/html, Size: 3123 bytes --]

[-- Attachment #2: Type: text/plain, Size: 154 bytes --]

_______________________________________________
amd-gfx mailing list
amd-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

  parent reply	other threads:[~2018-07-31 11:35 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-07-31 10:37 [PATCH 0/4] drm/scheduler: add dynamic balancing Nayan Deshmukh
     [not found] ` <20180731103736.7813-1-nayan26deshmukh-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
2018-07-31 10:37   ` [PATCH 1/4] drm/scheduler: add a list of run queues to the entity Nayan Deshmukh
2018-07-31 10:37   ` [PATCH 2/4] drm/scheduler: add counter for total jobs in scheduler Nayan Deshmukh
2018-07-31 10:37   ` [PATCH 3/4] drm/scheduler: add new function to get least loaded sched Nayan Deshmukh
2018-07-31 11:27     ` Christian König
     [not found]       ` <1e24b45b-027c-2742-97eb-21054798218d-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
2018-07-31 11:35         ` Nayan Deshmukh [this message]
2018-07-31 10:37   ` [PATCH 4/4] drm/scheduler: move idle entities to scheduler with less load Nayan Deshmukh
2018-07-31 11:32     ` Christian König
2018-07-31 11:38       ` Nayan Deshmukh

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=CAFd4ddxxh_RtnafPTYKDZbWAih41f6umyo8iWWo1bf-Oww87QA@mail.gmail.com \
    --to=nayan26deshmukh-re5jqeeqqe8avxtiumwx3w@public.gmane.org \
    --cc=alexdeucher-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org \
    --cc=amd-gfx-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW@public.gmane.org \
    --cc=christian.koenig-5C7GfCeVMHo@public.gmane.org \
    --cc=dri-devel-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW@public.gmane.org \
    --cc=eric-WhKQ6XTQaPysTnJN9+BGXg@public.gmane.org \
    --cc=l.stach-bIcnvbaLZ9MEGnE8C9+IrQ@public.gmane.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.