[Devel] [PATCH RHEL7 COMMIT] bnx2: use kvzalloc() to allocate certain internal data

Konstantin Khorenko khorenko at virtuozzo.com
Wed Oct 10 19:00:06 MSK 2018


The commit is pushed to "branch-rh7-3.10.0-862.14.4.vz7.72.x-ovz" and will appear at https://src.openvz.org/scm/ovz/vzkernel.git
after rh7-3.10.0-862.14.4.vz7.72.6
------>
commit 66e75bd04dabf65c2ca65e63b76125b484b577fd
Author: Jan Dakinevich <jan.dakinevich at virtuozzo.com>
Date:   Wed Oct 10 19:00:04 2018 +0300

    bnx2: use kvzalloc() to allocate certain internal data
    
    These structures are not disigned for DMA'ing and don't require
    physically contiguous memory.
    
    https://jira.sw.ru/browse/HCI-140
    Signed-off-by: Jan Dakinevich <jan.dakinevich at virtuozzo.com>
    Acked-by: Denis V. Lunev <den at openvz.org>
---
 drivers/net/ethernet/broadcom/bnx2x/bnx2x_cmn.c | 11 +++++------
 drivers/net/ethernet/broadcom/bnx2x/bnx2x_cmn.h |  2 +-
 2 files changed, 6 insertions(+), 7 deletions(-)

diff --git a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_cmn.c b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_cmn.c
index f0a091280741..78103cd653b3 100644
--- a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_cmn.c
+++ b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_cmn.c
@@ -4552,9 +4552,8 @@ static int bnx2x_alloc_fp_mem_at(struct bnx2x *bp, int index)
 			   "allocating tx memory of fp %d cos %d\n",
 			   index, cos);
 
-			txdata->tx_buf_ring = kcalloc(NUM_TX_BD,
-						      sizeof(struct sw_tx_bd),
-						      GFP_KERNEL);
+			txdata->tx_buf_ring = kvzalloc(sizeof(struct sw_tx_bd) * NUM_TX_BD,
+						       GFP_KERNEL);
 			if (!txdata->tx_buf_ring)
 				goto alloc_mem_err;
 			txdata->tx_desc_ring = BNX2X_PCI_ALLOC(&txdata->tx_desc_mapping,
@@ -4568,7 +4567,7 @@ static int bnx2x_alloc_fp_mem_at(struct bnx2x *bp, int index)
 	if (!skip_rx_queue(bp, index)) {
 		/* fastpath rx rings: rx_buf rx_desc rx_comp */
 		bnx2x_fp(bp, index, rx_buf_ring) =
-			kcalloc(NUM_RX_BD, sizeof(struct sw_rx_bd), GFP_KERNEL);
+			kvzalloc(sizeof(struct sw_rx_bd) * NUM_RX_BD, GFP_KERNEL);
 		if (!bnx2x_fp(bp, index, rx_buf_ring))
 			goto alloc_mem_err;
 		bnx2x_fp(bp, index, rx_desc_ring) =
@@ -4586,8 +4585,8 @@ static int bnx2x_alloc_fp_mem_at(struct bnx2x *bp, int index)
 
 		/* SGE ring */
 		bnx2x_fp(bp, index, rx_page_ring) =
-			kcalloc(NUM_RX_SGE, sizeof(struct sw_rx_page),
-				GFP_KERNEL);
+			kvzalloc(sizeof(struct sw_rx_page) * NUM_RX_SGE,
+				 GFP_KERNEL);
 		if (!bnx2x_fp(bp, index, rx_page_ring))
 			goto alloc_mem_err;
 		bnx2x_fp(bp, index, rx_sge_ring) =
diff --git a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_cmn.h b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_cmn.h
index 39ffb37e8d6d..43f76c2c59f8 100644
--- a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_cmn.h
+++ b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_cmn.h
@@ -45,7 +45,7 @@ extern int bnx2x_num_queues;
 #define BNX2X_FREE(x) \
 	do { \
 		if (x) { \
-			kfree((void *)x); \
+			kvfree((void *)x); \
 			x = NULL; \
 		} \
 	} while (0)



More information about the Devel mailing list