[Devel] [PATCH RHEL8 COMMIT] bnx2: Use kvzalloc() to allocate certain internal data
Konstantin Khorenko
khorenko at virtuozzo.com
Tue May 25 12:16:42 MSK 2021
The commit is pushed to "branch-rh8-4.18.0-240.1.1.vz8.5.x-ovz" and will appear at https://src.openvz.org/scm/ovz/vzkernel.git
after rh8-4.18.0-240.1.1.vz8.5.33
------>
commit ab7d8ad816a7fdb7e03c770ff5074db834b08b14
Author: Jan Dakinevich <jan.dakinevich at virtuozzo.com>
Date: Tue May 25 12:16:42 2021 +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>
(cherry-picked from vz7 commit 66e75bd04dab ("bnx2: use kvzalloc() to allocate
certain internal data"))
Signed-off-by: Andrey Zhadchenko <andrey.zhadchenko at virtuozzo.com>
---
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 2b91e9c6a1af..f684d6861721 100644
--- a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_cmn.c
+++ b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_cmn.c
@@ -4566,9 +4566,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,
@@ -4582,7 +4581,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) =
@@ -4600,8 +4599,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 8c1887dddf60..ef9e9b6a7a22 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