From: Nayan Deshmukh <nayan26deshmukh-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
To: dri-devel-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW@public.gmane.org
Cc: Nayan Deshmukh
<nayan26deshmukh-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>,
amd-gfx-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW@public.gmane.org,
eric-WhKQ6XTQaPysTnJN9+BGXg@public.gmane.org,
alexdeucher-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org,
christian.koenig-5C7GfCeVMHo@public.gmane.org,
l.stach-bIcnvbaLZ9MEGnE8C9+IrQ@public.gmane.org
Subject: [PATCH 3/4] drm/scheduler: add new function to get least loaded sched
Date: Tue, 31 Jul 2018 16:07:35 +0530 [thread overview]
Message-ID: <20180731103736.7813-4-nayan26deshmukh@gmail.com> (raw)
In-Reply-To: <20180731103736.7813-1-nayan26deshmukh-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
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@gmail.com>
---
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);
+ rq = entity->rq_list[i];
+ }
+ }
+
+ return rq;
+}
+
static void drm_sched_entity_kill_jobs_cb(struct dma_fence *f,
struct dma_fence_cb *cb)
{
--
2.14.3
_______________________________________________
amd-gfx mailing list
amd-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/amd-gfx
next prev parent reply other threads:[~2018-07-31 10:37 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 ` Nayan Deshmukh [this message]
2018-07-31 11:27 ` [PATCH 3/4] drm/scheduler: add new function to get least loaded sched Christian König
[not found] ` <1e24b45b-027c-2742-97eb-21054798218d-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
2018-07-31 11:35 ` Nayan Deshmukh
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=20180731103736.7813-4-nayan26deshmukh@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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox