Skip to content

Commit b903274

Browse files
edumazetdavem330
authored andcommitted
bnx2x: avoid two atomic ops per page on x86
Commit 4cace67 ("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 <[email protected]> Cc: Gabriel Krisman Bertazi <[email protected]> Cc: Yuval Mintz <[email protected]> Cc: Ariel Elior <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent 41e8c70 commit b903274

File tree

1 file changed

+5
-10
lines changed

1 file changed

+5
-10
lines changed

drivers/net/ethernet/broadcom/bnx2x/bnx2x_cmn.c

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -549,14 +549,7 @@ static int bnx2x_alloc_rx_sge(struct bnx2x *bp, struct bnx2x_fastpath *fp,
549549
struct bnx2x_alloc_pool *pool = &fp->page_pool;
550550
dma_addr_t mapping;
551551

552-
if (!pool->page || (PAGE_SIZE - pool->offset) < SGE_PAGE_SIZE) {
553-
554-
/* put page reference used by the memory pool, since we
555-
* won't be using this page as the mempool anymore.
556-
*/
557-
if (pool->page)
558-
put_page(pool->page);
559-
552+
if (!pool->page) {
560553
pool->page = alloc_pages(gfp_mask, PAGES_PER_SGE_SHIFT);
561554
if (unlikely(!pool->page))
562555
return -ENOMEM;
@@ -571,7 +564,6 @@ static int bnx2x_alloc_rx_sge(struct bnx2x *bp, struct bnx2x_fastpath *fp,
571564
return -ENOMEM;
572565
}
573566

574-
get_page(pool->page);
575567
sw_buf->page = pool->page;
576568
sw_buf->offset = pool->offset;
577569

@@ -581,7 +573,10 @@ static int bnx2x_alloc_rx_sge(struct bnx2x *bp, struct bnx2x_fastpath *fp,
581573
sge->addr_lo = cpu_to_le32(U64_LO(mapping));
582574

583575
pool->offset += SGE_PAGE_SIZE;
584-
576+
if (PAGE_SIZE - pool->offset >= SGE_PAGE_SIZE)
577+
get_page(pool->page);
578+
else
579+
pool->page = NULL;
585580
return 0;
586581
}
587582

0 commit comments

Comments
 (0)