[Security,Check] drm/i915/gvt: add a fastpath for cmd parsing on MI_NOOP

Submitted by Zhao, Yan Y on July 25, 2018, 6:42 a.m.

Details

Message ID 20180725064237.17412-1-yan.y.zhao@intel.com
State New
Headers show
Series "drm/i915/gvt: add a fastpath for cmd parsing on MI_NOOP" ( rev: 1 ) in Intel GVT devel

Not browsing as part of any series.

Commit Message

Zhao, Yan Y July 25, 2018, 6:42 a.m.
MI_NOOP is a common command appearing in almost all command buffers, put it
into a fastpath can improve perfomance, especially in command buffers
contains lots of MI_NOOPs (0s).

Take glmark2 as an example, 3% performance increase is observed after
introduced this patch. Meanwhile, in case where abundant in MI_NOOPs,
up to 12% performance increase is measured.

Signed-off-by: Li Weinan <weinan.z.li@intel.com>
Signed-off-by: Zhao Yan <yan.y.zhao@intel.com>
---
 drivers/gpu/drm/i915/gvt/cmd_parser.c | 11 ++++++++++-
 1 file changed, 10 insertions(+), 1 deletion(-)

Patch hide | download patch | download mbox

diff --git a/drivers/gpu/drm/i915/gvt/cmd_parser.c b/drivers/gpu/drm/i915/gvt/cmd_parser.c
index 45e89b1e0481..c39e13abe50d 100644
--- a/drivers/gpu/drm/i915/gvt/cmd_parser.c
+++ b/drivers/gpu/drm/i915/gvt/cmd_parser.c
@@ -1840,6 +1840,8 @@  static int cmd_handler_mi_batch_buffer_start(struct parser_exec_state *s)
 	return ret;
 }
 
+static int MI_NOOP_INDEX;
+
 static struct cmd_info cmd_info[] = {
 	{"MI_NOOP", OP_MI_NOOP, F_LEN_CONST, R_ALL, D_ALL, 0, 1, NULL},
 
@@ -2525,7 +2527,12 @@  static int cmd_parser_exec(struct parser_exec_state *s)
 
 	cmd = cmd_val(s, 0);
 
-	info = get_cmd_info(s->vgpu->gvt, cmd, s->ring_id);
+	/* fastpath for MI_NOOP */
+	if (cmd == MI_NOOP)
+		info = &cmd_info[MI_NOOP_INDEX];
+	else
+		info = get_cmd_info(s->vgpu->gvt, cmd, s->ring_id);
+
 	if (info == NULL) {
 		gvt_vgpu_err("unknown cmd 0x%x, opcode=0x%x, addr_type=%s, ring %d, workload=%p\n",
 				cmd, get_opcode(cmd, s->ring_id),
@@ -2928,6 +2935,8 @@  static int init_cmd_table(struct intel_gvt *gvt)
 			kfree(e);
 			return -EEXIST;
 		}
+		if (cmd_info[i].opcode == OP_MI_NOOP)
+			MI_NOOP_INDEX = i;
 
 		INIT_HLIST_NODE(&e->hlist);
 		add_cmd_entry(gvt, e);

Comments


On 2018.07.25 02:42:37 -0400, Zhao Yan wrote:
> MI_NOOP is a common command appearing in almost all command buffers, put it
> into a fastpath can improve perfomance, especially in command buffers
> contains lots of MI_NOOPs (0s).
> 
> Take glmark2 as an example, 3% performance increase is observed after
> introduced this patch. Meanwhile, in case where abundant in MI_NOOPs,
> up to 12% performance increase is measured.
> 
> Signed-off-by: Li Weinan <weinan.z.li@intel.com>
> Signed-off-by: Zhao Yan <yan.y.zhao@intel.com>
> ---
>  drivers/gpu/drm/i915/gvt/cmd_parser.c | 11 ++++++++++-
>  1 file changed, 10 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/gpu/drm/i915/gvt/cmd_parser.c b/drivers/gpu/drm/i915/gvt/cmd_parser.c
> index 45e89b1e0481..c39e13abe50d 100644
> --- a/drivers/gpu/drm/i915/gvt/cmd_parser.c
> +++ b/drivers/gpu/drm/i915/gvt/cmd_parser.c
> @@ -1840,6 +1840,8 @@ static int cmd_handler_mi_batch_buffer_start(struct parser_exec_state *s)
>  	return ret;
>  }
>  
> +static int MI_NOOP_INDEX;
> +

pls use lowercase for static variable name, otherwises it's looked
like a macro definition.

>  static struct cmd_info cmd_info[] = {
>  	{"MI_NOOP", OP_MI_NOOP, F_LEN_CONST, R_ALL, D_ALL, 0, 1, NULL},
>  
> @@ -2525,7 +2527,12 @@ static int cmd_parser_exec(struct parser_exec_state *s)
>  
>  	cmd = cmd_val(s, 0);
>  
> -	info = get_cmd_info(s->vgpu->gvt, cmd, s->ring_id);
> +	/* fastpath for MI_NOOP */
> +	if (cmd == MI_NOOP)
> +		info = &cmd_info[MI_NOOP_INDEX];
> +	else
> +		info = get_cmd_info(s->vgpu->gvt, cmd, s->ring_id);
> +
>  	if (info == NULL) {
>  		gvt_vgpu_err("unknown cmd 0x%x, opcode=0x%x, addr_type=%s, ring %d, workload=%p\n",
>  				cmd, get_opcode(cmd, s->ring_id),
> @@ -2928,6 +2935,8 @@ static int init_cmd_table(struct intel_gvt *gvt)
>  			kfree(e);
>  			return -EEXIST;
>  		}
> +		if (cmd_info[i].opcode == OP_MI_NOOP)
> +			MI_NOOP_INDEX = i;
>  
>  		INIT_HLIST_NODE(&e->hlist);
>  		add_cmd_entry(gvt, e);
> -- 
> 2.17.1
> 
> _______________________________________________
> intel-gvt-dev mailing list
> intel-gvt-dev@lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/intel-gvt-dev