From: Christophe JAILLET Date: Thu, 2 Feb 2023 20:23:24 +0000 (+0100) Subject: RDMA/irdma: Slightly optimize irdma_form_ah_cm_frame() X-Git-Tag: v6.4-rc1~75^2~16 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=a2e20b29cf9ce6d2070a6e36666e2239f7f9625b;p=thirdparty%2Fkernel%2Flinux.git RDMA/irdma: Slightly optimize irdma_form_ah_cm_frame() 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. Link: https://lore.kernel.org/r/098e3c397be0436f1867899245ecfe656c472110.1675369386.git.christophe.jaillet@wanadoo.fr Signed-off-by: Christophe JAILLET Reviewed-by: Shiraz Saleem Signed-off-by: Jason Gunthorpe --- diff --git a/drivers/infiniband/hw/irdma/cm.c b/drivers/infiniband/hw/irdma/cm.c index 195aa9ea18b6c..48c2a303e9ecc 100644 --- a/drivers/infiniband/hw/irdma/cm.c +++ b/drivers/infiniband/hw/irdma/cm.c @@ -337,7 +337,7 @@ static struct irdma_puda_buf *irdma_form_ah_cm_frame(struct irdma_cm_node *cm_no pktsize = sizeof(*tcph) + opts_len + hdr_len + pd_len; - memset(buf, 0, pktsize); + memset(buf, 0, sizeof(*tcph)); sqbuf->totallen = pktsize; sqbuf->tcphlen = sizeof(*tcph) + opts_len;