* [PATCH net-next] bnx2x: avoid two atomic ops per page on x86
@ 2017-01-20 16:25 Eric Dumazet
2017-01-23 16:18 ` David Miller
0 siblings, 1 reply; 2+ messages in thread
From: Eric Dumazet @ 2017-01-20 16:25 UTC (permalink / raw)
To: David Miller; +Cc: netdev, Gabriel Krisman Bertazi, Yuval Mintz, Ariel Elior
From: Eric Dumazet <edumazet@google.com>
Commit 4cace675d687 ("bnx2x: Alloc 4k fragment for each rx ring buffer
element") added extra put_page() and get_page() calls on arches where
PAGE_SIZE=4K like x86
Reorder things to avoid this overhead.
Signed-off-by: Eric Dumazet <edumazet@google.com>
Cc: Gabriel Krisman Bertazi <krisman@linux.vnet.ibm.com>
Cc: Yuval Mintz <Yuval.Mintz@cavium.com>
Cc: Ariel Elior <ariel.elior@cavium.com>
---
drivers/net/ethernet/broadcom/bnx2x/bnx2x_cmn.c | 15 ++++----------
1 file changed, 5 insertions(+), 10 deletions(-)
diff --git a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_cmn.c b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_cmn.c
index 3e199d3e461ef5dd237e3176bcb666f878ac..c0dac0e5696d7d01457a42c2c13f1640c2e2 100644
--- a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_cmn.c
+++ b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_cmn.c
@@ -549,14 +549,7 @@ static int bnx2x_alloc_rx_sge(struct bnx2x *bp, struct bnx2x_fastpath *fp,
struct bnx2x_alloc_pool *pool = &fp->page_pool;
dma_addr_t mapping;
- if (!pool->page || (PAGE_SIZE - pool->offset) < SGE_PAGE_SIZE) {
-
- /* put page reference used by the memory pool, since we
- * won't be using this page as the mempool anymore.
- */
- if (pool->page)
- put_page(pool->page);
-
+ if (!pool->page) {
pool->page = alloc_pages(gfp_mask, PAGES_PER_SGE_SHIFT);
if (unlikely(!pool->page))
return -ENOMEM;
@@ -571,7 +564,6 @@ static int bnx2x_alloc_rx_sge(struct bnx2x *bp, struct bnx2x_fastpath *fp,
return -ENOMEM;
}
- get_page(pool->page);
sw_buf->page = pool->page;
sw_buf->offset = pool->offset;
@@ -581,7 +573,10 @@ static int bnx2x_alloc_rx_sge(struct bnx2x *bp, struct bnx2x_fastpath *fp,
sge->addr_lo = cpu_to_le32(U64_LO(mapping));
pool->offset += SGE_PAGE_SIZE;
-
+ if (PAGE_SIZE - pool->offset >= SGE_PAGE_SIZE)
+ get_page(pool->page);
+ else
+ pool->page = NULL;
return 0;
}
^ permalink raw reply related [flat|nested] 2+ messages in thread* Re: [PATCH net-next] bnx2x: avoid two atomic ops per page on x86
2017-01-20 16:25 [PATCH net-next] bnx2x: avoid two atomic ops per page on x86 Eric Dumazet
@ 2017-01-23 16:18 ` David Miller
0 siblings, 0 replies; 2+ messages in thread
From: David Miller @ 2017-01-23 16:18 UTC (permalink / raw)
To: eric.dumazet; +Cc: netdev, krisman, Yuval.Mintz, ariel.elior
From: Eric Dumazet <eric.dumazet@gmail.com>
Date: Fri, 20 Jan 2017 08:25:34 -0800
> From: Eric Dumazet <edumazet@google.com>
>
> Commit 4cace675d687 ("bnx2x: Alloc 4k fragment for each rx ring buffer
> element") added extra put_page() and get_page() calls on arches where
> PAGE_SIZE=4K like x86
>
> Reorder things to avoid this overhead.
>
> Signed-off-by: Eric Dumazet <edumazet@google.com>
> Cc: Gabriel Krisman Bertazi <krisman@linux.vnet.ibm.com>
> Cc: Yuval Mintz <Yuval.Mintz@cavium.com>
> Cc: Ariel Elior <ariel.elior@cavium.com>
Applied, thanks.
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2017-01-23 16:18 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-01-20 16:25 [PATCH net-next] bnx2x: avoid two atomic ops per page on x86 Eric Dumazet
2017-01-23 16:18 ` David Miller
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).