All of lore.kernel.org
 help / color / mirror / Atom feed
From: Jason Gunthorpe <jgg@nvidia.com>
To: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
Cc: Mustafa Ismail <mustafa.ismail@intel.com>,
	Shiraz Saleem <shiraz.saleem@intel.com>,
	Leon Romanovsky <leon@kernel.org>,
	linux-kernel@vger.kernel.org, kernel-janitors@vger.kernel.org,
	linux-rdma@vger.kernel.org
Subject: Re: [PATCH] RDMA/irdma: Slightly optimize irdma_form_ah_cm_frame()
Date: Wed, 12 Apr 2023 20:06:39 -0300	[thread overview]
Message-ID: <ZDc5f7SFUhli8T3h@nvidia.com> (raw)
In-Reply-To: <098e3c397be0436f1867899245ecfe656c472110.1675369386.git.christophe.jaillet@wanadoo.fr>

On Thu, Feb 02, 2023 at 09:23:24PM +0100, Christophe JAILLET wrote:
> There is no need to zero 'pktsize' bytes of 'buf', only the header needs
> to be cleared, to be safe.
> All the other bytes are already written with some memcpy() at the end of
> the function.
> 
> Doing so also gives the opportunity to the compiler to avoid the memset()
> call. It can be inlined now that the length is known as compile time.
> 
> Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
> Reviewed-by: Shiraz Saleem <shiraz.saleem@intel.com>
> ---
> Just in case, here is the diff of what is generated by gcc 11.3.0 before
> and after the patch.
> 
>  .L736:
> -# drivers/infiniband/hw/irdma/cm.c:340: 	memset(buf, 0, pktsize);
> +# drivers/infiniband/hw/irdma/cm.c:340: 	memset(buf, 0, sizeof(*tcph));
>  	call	__sanitizer_cov_trace_pc	#
> -	xorl	%esi, %esi	#
> -	movzwl	%r13w, %edx	# _194, __fortify_size
> -	movq	%rbp, %rdi	# buf,
> -	call	memset	#
> -	leaq	104(%r12), %rax	#, _259
> +	movl	$0, 16(%rbp)	#, MEM <char[1:20]> [(void *)buf_114]
> +	leaq	104(%r12), %rax	#, _295
> +# drivers/infiniband/hw/irdma/cm.c:342: 	sqbuf->totallen = pktsize;
> +	movzwl	%r13w, %r13d	# _192, _192
> +# drivers/infiniband/hw/irdma/cm.c:340: 	memset(buf, 0, sizeof(*tcph));
> +	movq	$0, 0(%rbp)	#, MEM <char[1:20]> [(void *)buf_114]
> +# drivers/infiniband/hw/irdma/cm.c:342: 	sqbuf->totallen = pktsize;
> +	movq	%rax, %rdi	# _295,
> +# drivers/infiniband/hw/irdma/cm.c:340: 	memset(buf, 0, sizeof(*tcph));
> +	movq	$0, 8(%rbp)	#, MEM <char[1:20]> [(void *)buf_114]
> +	movq	%rax, 64(%rsp)	# _295, %sfp
>  # drivers/infiniband/hw/irdma/cm.c:342: 	sqbuf->totallen = pktsize;
> ---
>  drivers/infiniband/hw/irdma/cm.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)

Applied to for-next

Thanks,
Jason

      parent reply	other threads:[~2023-04-12 23:06 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-02-02 20:23 [PATCH] RDMA/irdma: Slightly optimize irdma_form_ah_cm_frame() Christophe JAILLET
2023-04-12 16:02 ` Jason Gunthorpe
2023-04-12 17:03   ` Saleem, Shiraz
2023-04-12 23:06 ` Jason Gunthorpe [this message]

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=ZDc5f7SFUhli8T3h@nvidia.com \
    --to=jgg@nvidia.com \
    --cc=christophe.jaillet@wanadoo.fr \
    --cc=kernel-janitors@vger.kernel.org \
    --cc=leon@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-rdma@vger.kernel.org \
    --cc=mustafa.ismail@intel.com \
    --cc=shiraz.saleem@intel.com \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.