[PATCH v2 9/9] drm/i915/gvt: define weight according to vGPU type

Ping Gao ping.a.gao at intel.com
Tue Feb 14 04:25:55 UTC 2017


Different vGPU type has different weight definition, that means
different vGPU has corresponding performance ratio compared with
each other.

Signed-off-by: Ping Gao <ping.a.gao at intel.com>
---
 drivers/gpu/drm/i915/gvt/gvt.h          | 5 +++++
 drivers/gpu/drm/i915/gvt/kvmgt.c        | 4 ++--
 drivers/gpu/drm/i915/gvt/sched_policy.c | 1 +
 drivers/gpu/drm/i915/gvt/vgpu.c         | 9 +++++++++
 4 files changed, 17 insertions(+), 2 deletions(-)

diff --git a/drivers/gpu/drm/i915/gvt/gvt.h b/drivers/gpu/drm/i915/gvt/gvt.h
index 8c50230..13d6f8a 100644
--- a/drivers/gpu/drm/i915/gvt/gvt.h
+++ b/drivers/gpu/drm/i915/gvt/gvt.h
@@ -151,6 +151,7 @@ struct intel_vgpu {
 	bool active;
 	bool resetting;
 	void *sched_data;
+	struct intel_sched_ctl sched_ctl;
 
 	struct intel_vgpu_fence fence;
 	struct intel_vgpu_gm gm;
@@ -222,6 +223,8 @@ struct intel_vgpu_type {
 	unsigned int low_gm_size;
 	unsigned int high_gm_size;
 	unsigned int fence;
+
+	unsigned int weight;
 };
 
 struct intel_gvt {
@@ -329,6 +332,8 @@ struct intel_vgpu_creation_params {
 	__u64 fence_sz;
 	__s32 primary;
 	__u64 vgpu_id;
+
+	__u32 weight;
 };
 
 int intel_vgpu_alloc_resource(struct intel_vgpu *vgpu,
diff --git a/drivers/gpu/drm/i915/gvt/kvmgt.c b/drivers/gpu/drm/i915/gvt/kvmgt.c
index db2c965..743cc7a 100644
--- a/drivers/gpu/drm/i915/gvt/kvmgt.c
+++ b/drivers/gpu/drm/i915/gvt/kvmgt.c
@@ -295,10 +295,10 @@ static ssize_t description_show(struct kobject *kobj, struct device *dev,
 		return 0;
 
 	return sprintf(buf, "low_gm_size: %dMB\nhigh_gm_size: %dMB\n"
-				"fence: %d\n",
+				"fence: %d\nweight: %d\n",
 				BYTES_TO_MB(type->low_gm_size),
 				BYTES_TO_MB(type->high_gm_size),
-				type->fence);
+				type->fence, type->weight);
 }
 
 static MDEV_TYPE_ATTR_RO(available_instances);
diff --git a/drivers/gpu/drm/i915/gvt/sched_policy.c b/drivers/gpu/drm/i915/gvt/sched_policy.c
index 9d40693..f88006d 100644
--- a/drivers/gpu/drm/i915/gvt/sched_policy.c
+++ b/drivers/gpu/drm/i915/gvt/sched_policy.c
@@ -428,6 +428,7 @@ static int tbs_sched_init_vgpu(struct intel_vgpu *vgpu)
 	if (!data)
 		return -ENOMEM;
 
+	data->sched_ctl.weight = vgpu->sched_ctl.weight;
 	data->vgpu = vgpu;
 	INIT_LIST_HEAD(&data->list);
 	INIT_LIST_HEAD(&data->lru_list);
diff --git a/drivers/gpu/drm/i915/gvt/vgpu.c b/drivers/gpu/drm/i915/gvt/vgpu.c
index 2b0fd13..4cd825d 100644
--- a/drivers/gpu/drm/i915/gvt/vgpu.c
+++ b/drivers/gpu/drm/i915/gvt/vgpu.c
@@ -76,6 +76,7 @@ int intel_gvt_init_vgpu_types(struct intel_gvt *gvt)
 	unsigned int num_types;
 	unsigned int i, low_avail, high_avail;
 	unsigned int min_low;
+	unsigned int com_multi = 1;
 
 	/* vGPU type name is defined as GVTg_Vx_y which contains
 	 * physical GPU generation type and 'y' means maximum vGPU
@@ -110,6 +111,8 @@ int intel_gvt_init_vgpu_types(struct intel_gvt *gvt)
 						 high_avail / gvt->types[i].high_gm_size);
 		gvt->types[i].avail_instance = gvt->types[i].max_instance;
 
+		com_multi *= gvt->types[i].max_instance;
+
 		if (IS_GEN8(gvt->dev_priv))
 			sprintf(gvt->types[i].name, "GVTg_V4_%u",
 						gvt->types[i].max_instance);
@@ -125,6 +128,9 @@ int intel_gvt_init_vgpu_types(struct intel_gvt *gvt)
 			     gvt->types[i].high_gm_size, gvt->types[i].fence);
 	}
 
+	for (i = 0; i < num_types; ++i)
+		gvt->types[i].weight = com_multi / gvt->types[i].max_instance;
+
 	gvt->num_types = i;
 	return 0;
 }
@@ -277,6 +283,7 @@ static struct intel_vgpu *__intel_gvt_create_vgpu(struct intel_gvt *gvt,
 	vgpu->id = ret;
 	vgpu->handle = param->handle;
 	vgpu->gvt = gvt;
+	vgpu->sched_ctl.weight = param->weight;
 	bitmap_zero(vgpu->tlb_handle_pending, I915_NUM_ENGINES);
 
 	intel_vgpu_init_cfg_space(vgpu, param->primary);
@@ -368,6 +375,8 @@ struct intel_vgpu *intel_gvt_create_vgpu(struct intel_gvt *gvt,
 	param.low_gm_sz = BYTES_TO_MB(param.low_gm_sz);
 	param.high_gm_sz = BYTES_TO_MB(param.high_gm_sz);
 
+	param.weight = type->weight;
+
 	vgpu = __intel_gvt_create_vgpu(gvt, &param);
 	if (IS_ERR(vgpu))
 		return vgpu;
-- 
2.7.4



More information about the intel-gvt-dev mailing list