]> www.infradead.org Git - users/jedix/linux-maple.git/commitdiff
bnx2x: avoid two atomic ops per page on x86
authorEric Dumazet <edumazet@google.com>
Fri, 20 Jan 2017 16:25:34 +0000 (08:25 -0800)
committerChuck Anderson <chuck.anderson@oracle.com>
Mon, 27 Feb 2017 05:48:26 +0000 (21:48 -0800)
Orabug: 25477835

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>
Signed-off-by: David S. Miller <davem@davemloft.net>
(cherry picked from commit b9032741e4f86844d8c4a7c18001ee328dae2f7a)
Signed-off-by: Brian Maly <brian.maly@oracle.com>
drivers/net/ethernet/broadcom/bnx2x/bnx2x_cmn.c

index 6169d047fab66f1a886210f861fb90d97fd31e52..64dac43eac875ec2fde67758a9728f2757d73cad 100644 (file)
@@ -551,14 +551,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;
@@ -573,7 +566,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;
 
@@ -583,7 +575,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;
 }