RE: [PATCH rdma-next 09/15] RDMA/hfi: Zero all allocated memory

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



> -----Original Message-----
> From: linux-rdma-owner@xxxxxxxxxxxxxxx [mailto:linux-rdma-
> owner@xxxxxxxxxxxxxxx] On Behalf Of Leon Romanovsky
> Sent: Monday, March 12, 2018 10:16 AM
> To: Doug Ledford <dledford@xxxxxxxxxx>; Jason Gunthorpe
> <jgg@xxxxxxxxxxxx>
> Cc: Leon Romanovsky <leonro@xxxxxxxxxxxx>; RDMA mailing list <linux-
> rdma@xxxxxxxxxxxxxxx>; Steve Wise <swise@xxxxxxxxxxxxxxxxxxxxx>
> Subject: [PATCH rdma-next 09/15] RDMA/hfi: Zero all allocated memory
> 
> From: Leon Romanovsky <leonro@xxxxxxxxxxxx>
> 
> Replace general allocations to be zero based.
> 
> Signed-off-by: Leon Romanovsky <leonro@xxxxxxxxxxxx>
> ---
>  drivers/infiniband/hw/hfi1/sdma.c    | 11 ++++-------
> 
> diff --git a/drivers/infiniband/hw/hfi1/sdma.c
> b/drivers/infiniband/hw/hfi1/sdma.c
> index 1f203309cf24..e5696c70e7a2 100644
> --- a/drivers/infiniband/hw/hfi1/sdma.c
> +++ b/drivers/infiniband/hw/hfi1/sdma.c
> @@ -1658,7 +1658,7 @@ static inline u8 ahg_mode(struct sdma_txreq *tx)
>  }
> 
>  /**
> - * __sdma_txclean() - clean tx of mappings, descp *kmalloc's
> + * __sdma_txclean() - clean tx of mappings, descp *kzalloc's
>   * @dd: hfi1_devdata for unmapping
>   * @tx: tx request to clean
>   *
> @@ -1688,7 +1688,7 @@ void __sdma_txclean(
>  	}
>  	kfree(tx->coalesce_buf);
>  	tx->coalesce_buf = NULL;
> -	/* kmalloc'ed descp */
> +	/* kzalloc'ed descp */
>  	if (unlikely(tx->desc_limit > ARRAY_SIZE(tx->descs))) {
>  		tx->desc_limit = ARRAY_SIZE(tx->descs);
>  		kfree(tx->descp);
> @@ -3067,7 +3067,7 @@ static int _extend_sdma_tx_descs(struct
> hfi1_devdata *dd, struct sdma_txreq *tx)
>  			tx->desc_limit = MAX_DESC;
>  		} else if (!tx->coalesce_buf) {
>  			/* allocate coalesce buffer with space for padding */
> -			tx->coalesce_buf = kmalloc(tx->tlen + sizeof(u32),
> +			tx->coalesce_buf = kzalloc(tx->tlen + sizeof(u32),
>  						   GFP_ATOMIC);
>  			if (!tx->coalesce_buf)
>  				goto enomem;
> @@ -3079,10 +3079,7 @@ static int _extend_sdma_tx_descs(struct
> hfi1_devdata *dd, struct sdma_txreq *tx)
>  	if (unlikely(tx->num_desc == MAX_DESC))
>  		goto enomem;
> 
> -	tx->descp = kmalloc_array(
> -			MAX_DESC,
> -			sizeof(struct sdma_desc),
> -			GFP_ATOMIC);
> +	tx->descp = kcalloc(MAX_DESC, sizeof(struct sdma_desc),
> GFP_ATOMIC);
>  	if (!tx->descp)
>  		goto enomem;

The above allocations are in the HOT path.  Changing them to the zero based
allocation will have performance implications.

Please do not update any GFP_ATOMIC allocations.

Thanks,

Mike
--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html



[Index of Archives]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Photo]     [Yosemite News]     [Yosemite Photos]     [Linux Kernel]     [Linux SCSI]     [XFree86]

  Powered by Linux