[PATCH v2 8/9] drm/i915/gvt: control the scheduler by timeslice usage
Ping Gao
ping.a.gao at intel.com
Tue Feb 14 04:25:54 UTC 2017
The timeslice usage will determine vGPU whether has chance to
schedule or not at every vGPU switch checkpoint.
Signed-off-by: Ping Gao <ping.a.gao at intel.com>
---
drivers/gpu/drm/i915/gvt/sched_policy.c | 27 +++++++++++++++++++++++++--
1 file changed, 25 insertions(+), 2 deletions(-)
diff --git a/drivers/gpu/drm/i915/gvt/sched_policy.c b/drivers/gpu/drm/i915/gvt/sched_policy.c
index 081a512..9d40693 100644
--- a/drivers/gpu/drm/i915/gvt/sched_policy.c
+++ b/drivers/gpu/drm/i915/gvt/sched_policy.c
@@ -194,6 +194,9 @@ static void try_to_schedule_next_vgpu(struct intel_gvt *gvt)
wake_up(&scheduler->waitq[i]);
}
+#define vgpu_has_ts_limit(vgpu_data) \
+((vgpu_data)->ts_alloc < GVT_TS_BALANCE_PERIOD_CYC)
+
static struct intel_vgpu *get_vgpu_timeslice_left(struct list_head *head,
struct tbs_sched_data *sched_data)
{
@@ -210,8 +213,16 @@ static struct intel_vgpu *get_vgpu_timeslice_left(struct list_head *head,
if (!vgpu_has_pending_workload(vgpu_data->vgpu))
continue;
- vgpu = vgpu_data->vgpu;
- break;
+ /* Return the vGPU if there is no time slice limitation */
+ if (!vgpu_has_ts_limit(vgpu_data)) {
+ vgpu = vgpu_data->vgpu;
+ break;
+
+ /* Return the vGPU only if it has time slice left */
+ } else if (vgpu_data->ts_usage > 0) {
+ vgpu = vgpu_data->vgpu;
+ break;
+ }
}
return vgpu;
@@ -275,6 +286,9 @@ static struct list_head *get_sched_head(struct tbs_sched_data *sched_data)
static struct intel_vgpu *pickup_next_vgpu(struct tbs_sched_data *sched_data)
{
+ struct intel_gvt *gvt = sched_data->gvt;
+ struct intel_gvt_workload_scheduler *scheduler = &gvt->scheduler;
+ struct tbs_vgpu_data *cur_vgpu_data;
struct tbs_vgpu_data *next_vgpu_data;
struct intel_vgpu *next_vgpu;
struct list_head *head;
@@ -299,6 +313,15 @@ static struct intel_vgpu *pickup_next_vgpu(struct tbs_sched_data *sched_data)
} else {
/* Choose the vGPU which has timeslice left */
next_vgpu = get_vgpu_timeslice_left(head, sched_data);
+
+ /* Switch to dummy vGPU when all next candidates are
+ * empty and the current vGPU has timeslice limitation.
+ */
+ if (!next_vgpu && scheduler->current_vgpu) {
+ cur_vgpu_data = scheduler->current_vgpu->sched_data;
+ if (vgpu_has_ts_limit(cur_vgpu_data))
+ next_vgpu = gvt->dummy_vgpu;
+ }
}
return next_vgpu;
--
2.7.4
More information about the intel-gvt-dev
mailing list