* [PATCH][next][v2] iavf: use kvzalloc instead of kzalloc for rx/tx_bi buffer
@ 2020-08-28 5:26 Li RongQing
2020-09-14 23:24 ` Jesse Brandeburg
0 siblings, 1 reply; 2+ messages in thread
From: Li RongQing @ 2020-08-28 5:26 UTC (permalink / raw)
To: netdev, intel-wired-lan; +Cc: edumazet
when changes the rx/tx ring to 4096, kzalloc may fail due to
a temporary shortage on slab entries.
so using kvmalloc to allocate this memory as there is no need
that this memory area is physical continuously.
and using __GFP_RETRY_MAYFAIL to allocate from kmalloc as
far as possible, which can reduce TLB pressure than vmalloc
as suggested by Eric Dumazet
Signed-off-by: Li RongQing <lirongqing@baidu.com>
---
v2: __GFP_RETRY_MAYFAIL is used
drivers/net/ethernet/intel/iavf/iavf_txrx.c | 14 ++++++++------
1 file changed, 8 insertions(+), 6 deletions(-)
diff --git a/drivers/net/ethernet/intel/iavf/iavf_txrx.c b/drivers/net/ethernet/intel/iavf/iavf_txrx.c
index 256fa07d54d5..e7a1e9039cee 100644
--- a/drivers/net/ethernet/intel/iavf/iavf_txrx.c
+++ b/drivers/net/ethernet/intel/iavf/iavf_txrx.c
@@ -92,7 +92,7 @@ void iavf_clean_tx_ring(struct iavf_ring *tx_ring)
void iavf_free_tx_resources(struct iavf_ring *tx_ring)
{
iavf_clean_tx_ring(tx_ring);
- kfree(tx_ring->tx_bi);
+ kvfree(tx_ring->tx_bi);
tx_ring->tx_bi = NULL;
if (tx_ring->desc) {
@@ -622,7 +622,8 @@ int iavf_setup_tx_descriptors(struct iavf_ring *tx_ring)
/* warn if we are about to overwrite the pointer */
WARN_ON(tx_ring->tx_bi);
bi_size = sizeof(struct iavf_tx_buffer) * tx_ring->count;
- tx_ring->tx_bi = kzalloc(bi_size, GFP_KERNEL);
+ tx_ring->tx_bi = kvzalloc(bi_size, GFP_KERNEL |
+ __GFP_RETRY_MAYFAIL);
if (!tx_ring->tx_bi)
goto err;
@@ -643,7 +644,7 @@ int iavf_setup_tx_descriptors(struct iavf_ring *tx_ring)
return 0;
err:
- kfree(tx_ring->tx_bi);
+ kvfree(tx_ring->tx_bi);
tx_ring->tx_bi = NULL;
return -ENOMEM;
}
@@ -714,7 +715,7 @@ void iavf_clean_rx_ring(struct iavf_ring *rx_ring)
void iavf_free_rx_resources(struct iavf_ring *rx_ring)
{
iavf_clean_rx_ring(rx_ring);
- kfree(rx_ring->rx_bi);
+ kvfree(rx_ring->rx_bi);
rx_ring->rx_bi = NULL;
if (rx_ring->desc) {
@@ -738,7 +739,8 @@ int iavf_setup_rx_descriptors(struct iavf_ring *rx_ring)
/* warn if we are about to overwrite the pointer */
WARN_ON(rx_ring->rx_bi);
bi_size = sizeof(struct iavf_rx_buffer) * rx_ring->count;
- rx_ring->rx_bi = kzalloc(bi_size, GFP_KERNEL);
+ rx_ring->rx_bi = kvzalloc(bi_size, GFP_KERNEL |
+ __GFP_RETRY_MAYFAIL);
if (!rx_ring->rx_bi)
goto err;
@@ -762,7 +764,7 @@ int iavf_setup_rx_descriptors(struct iavf_ring *rx_ring)
return 0;
err:
- kfree(rx_ring->rx_bi);
+ kvfree(rx_ring->rx_bi);
rx_ring->rx_bi = NULL;
return -ENOMEM;
}
--
2.16.2
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH][next][v2] iavf: use kvzalloc instead of kzalloc for rx/tx_bi buffer
2020-08-28 5:26 [PATCH][next][v2] iavf: use kvzalloc instead of kzalloc for rx/tx_bi buffer Li RongQing
@ 2020-09-14 23:24 ` Jesse Brandeburg
0 siblings, 0 replies; 2+ messages in thread
From: Jesse Brandeburg @ 2020-09-14 23:24 UTC (permalink / raw)
To: Li RongQing; +Cc: netdev, intel-wired-lan, edumazet
Li RongQing wrote:
> when changes the rx/tx ring to 4096, kzalloc may fail due to
> a temporary shortage on slab entries.
>
> so using kvmalloc to allocate this memory as there is no need
> that this memory area is physical continuously.
>
> and using __GFP_RETRY_MAYFAIL to allocate from kmalloc as
> far as possible, which can reduce TLB pressure than vmalloc
> as suggested by Eric Dumazet
This change is no good, it's using RETRY_MAYFAIL but still using
v*alloc.
Please see my replies to the i40e version of the patch. I don't think
we should apply these.
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2020-09-14 23:24 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2020-08-28 5:26 [PATCH][next][v2] iavf: use kvzalloc instead of kzalloc for rx/tx_bi buffer Li RongQing
2020-09-14 23:24 ` Jesse Brandeburg
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).