From: "Christian König" <christian.koenig@amd.com>
To: Nirmoy Das <nirmoy.aiemd@gmail.com>, amd-gfx@lists.freedesktop.org
Cc: alexander.deucher@amd.com, Boyuan.Zhang@amd.com,
nirmoy.das@amd.com, Leo.Liu@amd.com, James.Zhu@amd.com
Subject: Re: [PATCH 1/2] drm/sched: implement and export drm_sched_pick_best
Date: Fri, 13 Mar 2020 14:39:02 +0100 [thread overview]
Message-ID: <17bcfd9b-2540-ff00-925d-c6c4b8c4f820@amd.com> (raw)
In-Reply-To: <20200313120508.36004-1-nirmoy.das@amd.com>
Am 13.03.20 um 13:05 schrieb Nirmoy Das:
> Refactor drm_sched_entity_get_free_sched() to move the logic of picking
> the least loaded drm scheduler from a drm scheduler list to implement
> drm_sched_pick_best(). This patch also exports drm_sched_pick_best() so
> that it can be utilized by other drm drivers.
>
> Signed-off-by: Nirmoy Das <nirmoy.das@amd.com>
> ---
> drivers/gpu/drm/scheduler/sched_entity.c | 20 +++-----------
> drivers/gpu/drm/scheduler/sched_main.c | 35 ++++++++++++++++++++++++
> include/drm/gpu_scheduler.h | 3 ++
> 3 files changed, 42 insertions(+), 16 deletions(-)
>
> diff --git a/drivers/gpu/drm/scheduler/sched_entity.c b/drivers/gpu/drm/scheduler/sched_entity.c
> index d631521a9679..3f6397d60bff 100644
> --- a/drivers/gpu/drm/scheduler/sched_entity.c
> +++ b/drivers/gpu/drm/scheduler/sched_entity.c
> @@ -147,24 +147,12 @@ 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_gpu_scheduler *sched;
> struct drm_sched_rq *rq = NULL;
> - unsigned int min_jobs = UINT_MAX, num_jobs;
> - int i;
> -
> - for (i = 0; i < entity->num_sched_list; ++i) {
> - struct drm_gpu_scheduler *sched = entity->sched_list[i];
>
> - if (!entity->sched_list[i]->ready) {
> - DRM_WARN("sched%s is not ready, skipping", sched->name);
> - continue;
> - }
> -
> - num_jobs = atomic_read(&sched->num_jobs);
> - if (num_jobs < min_jobs) {
> - min_jobs = num_jobs;
> - rq = &entity->sched_list[i]->sched_rq[entity->priority];
> - }
> - }
> + sched = drm_sched_pick_best(entity->sched_list, entity->num_sched_list);
> + if (sched)
> + rq = &sched->sched_rq[entity->priority];
Keeping the function just for the two lines doesn't make much sense.
IIRC it is called only once, just inline there.
>
> return rq;
> }
> diff --git a/drivers/gpu/drm/scheduler/sched_main.c b/drivers/gpu/drm/scheduler/sched_main.c
> index 3fad5876a13f..d640f4087795 100644
> --- a/drivers/gpu/drm/scheduler/sched_main.c
> +++ b/drivers/gpu/drm/scheduler/sched_main.c
> @@ -705,6 +705,41 @@ drm_sched_get_cleanup_job(struct drm_gpu_scheduler *sched)
> return job;
> }
>
> +/**
> + * drm_sched_pick_best - Get a drm sched from a sched_list with the least load
> + * @sched_list: list of drm_gpu_schedulers
> + * @num_sched_list: number of drm_gpu_schedulers in the sched_list
> + *
> + * Returns pointer of the sched with the least load or NULL if none of the
> + * drm_gpu_schedulers are ready
> + */
> +struct drm_gpu_scheduler *
> +drm_sched_pick_best(struct drm_gpu_scheduler **sched_list,
> + unsigned int num_sched_list)
> +{
> + struct drm_gpu_scheduler *sched, *picked_sched = NULL;
> + unsigned int min_jobs = UINT_MAX, num_jobs;
> + int i;
> +
> + for (i = 0; i < num_sched_list; ++i) {
> + sched = sched_list[i];
> +
> + if (!sched->ready) {
> + DRM_WARN("sched%s is not ready, skipping", sched->name);
There is a space missing here between "sched" and "%s". And maybe write
"scheduler" in the message.
Apart from that looks good of hand,
Christian.
> + continue;
> + }
> +
> + num_jobs = atomic_read(&sched->num_jobs);
> + if (num_jobs < min_jobs) {
> + min_jobs = num_jobs;
> + picked_sched = sched;
> + }
> + }
> +
> + return picked_sched;
> +}
> +EXPORT_SYMBOL(drm_sched_pick_best);
> +
> /**
> * drm_sched_blocked - check if the scheduler is blocked
> *
> diff --git a/include/drm/gpu_scheduler.h b/include/drm/gpu_scheduler.h
> index ae39eacee250..ca6b8b01fac9 100644
> --- a/include/drm/gpu_scheduler.h
> +++ b/include/drm/gpu_scheduler.h
> @@ -341,5 +341,8 @@ void drm_sched_fence_finished(struct drm_sched_fence *fence);
> unsigned long drm_sched_suspend_timeout(struct drm_gpu_scheduler *sched);
> void drm_sched_resume_timeout(struct drm_gpu_scheduler *sched,
> unsigned long remaining);
> +struct drm_gpu_scheduler *
> +drm_sched_pick_best(struct drm_gpu_scheduler **sched_list,
> + unsigned int num_sched_list);
>
> #endif
> --
> 2.25.0
>
_______________________________________________
amd-gfx mailing list
amd-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/amd-gfx
next prev parent reply other threads:[~2020-03-13 13:39 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-03-13 12:05 [PATCH 1/2] drm/sched: implement and export drm_sched_pick_best Nirmoy Das
2020-03-13 12:05 ` [PATCH 2/2] drm/amdgpu: disable gpu_sched load balancer for vcn jobs Nirmoy Das
2020-03-13 13:39 ` Christian König [this message]
-- strict thread matches above, loose matches on Subject: below --
2020-03-13 13:59 [PATCH 1/2] drm/sched: implement and export drm_sched_pick_best Nirmoy Das
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=17bcfd9b-2540-ff00-925d-c6c4b8c4f820@amd.com \
--to=christian.koenig@amd.com \
--cc=Boyuan.Zhang@amd.com \
--cc=James.Zhu@amd.com \
--cc=Leo.Liu@amd.com \
--cc=alexander.deucher@amd.com \
--cc=amd-gfx@lists.freedesktop.org \
--cc=nirmoy.aiemd@gmail.com \
--cc=nirmoy.das@amd.com \
/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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox