[PATCH v4 9/9] drm/i915/gvt: control the scheduler by timeslice usage

Ping Gao ping.a.gao at intel.com
Wed Mar 8 06:24:36 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 | 33 ++++++++++++++++++++++++++++-----
 1 file changed, 28 insertions(+), 5 deletions(-)

diff --git a/drivers/gpu/drm/i915/gvt/sched_policy.c b/drivers/gpu/drm/i915/gvt/sched_policy.c
index 36f2445..011ec7f 100644
--- a/drivers/gpu/drm/i915/gvt/sched_policy.c
+++ b/drivers/gpu/drm/i915/gvt/sched_policy.c
@@ -202,7 +202,10 @@ enum {
 	HAS_ACTIVE_VGPU_SCHED,
 };
 
-static struct intel_vgpu *get_vgpu_has_workload(struct list_head *head,
+#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 gvt_sched_data *sched_data)
 {
 	struct vgpu_sched_data *vgpu_data;
@@ -218,8 +221,16 @@ static struct intel_vgpu *get_vgpu_has_workload(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;
@@ -284,6 +295,9 @@ static struct list_head *get_sched_head(struct gvt_sched_data *sched_data)
 
 static struct intel_vgpu *pickup_next_vgpu(struct gvt_sched_data *sched_data)
 {
+	struct intel_gvt *gvt = sched_data->gvt;
+	struct intel_gvt_workload_scheduler *scheduler = &gvt->scheduler;
+	struct vgpu_sched_data *cur_vgpu_data;
 	struct vgpu_sched_data *next_vgpu_data;
 	struct intel_vgpu *next_vgpu;
 	struct list_head *head;
@@ -309,8 +323,17 @@ static struct intel_vgpu *pickup_next_vgpu(struct gvt_sched_data *sched_data)
 		list_del_init(&next_vgpu_data->list);
 		list_add(&next_vgpu_data->list, head);
 	} else {
-		/* Choose the vGPU which has pending workload */
-		next_vgpu = get_vgpu_has_workload(head, sched_data);
+		/* Choose the vGPU which has timeslice left */
+		next_vgpu = get_vgpu_timeslice_left(head, sched_data);
+
+		/* Switch to idle 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->idle_vgpu;
+		}
 	}
 
 	return next_vgpu;
-- 
2.7.4



More information about the intel-gvt-dev mailing list