]> git.proxmox.com Git - mirror_ubuntu-eoan-kernel.git/commit
bnx2: Remove some unnecessary smp_mb() in tx fast path.
authorMichael Chan <mchan@broadcom.com>
Mon, 19 Jul 2010 14:15:04 +0000 (14:15 +0000)
committerDavid S. Miller <davem@davemloft.net>
Tue, 20 Jul 2010 03:30:06 +0000 (20:30 -0700)
commit11848b964777af9c68d9160582628c2eb11f46d5
tree6b026650813b24b50da954c5978811246f811a76
parent379b39a2ad613745bfbfe80256957d19689b7b94
bnx2: Remove some unnecessary smp_mb() in tx fast path.

smp_mb() inside bnx2_tx_avail() is used twice in the normal
bnx2_start_xmit() path (see illustration below).  The full memory
barrier is only necessary during race conditions with tx completion.
We can speed up the tx path by replacing smp_mb() in bnx2_tx_avail()
with a compiler barrier.  The compiler barrier is to force the
compiler to fetch the tx_prod and tx_cons from memory.

In the race condition between bnx2_start_xmit() and bnx2_tx_int(),
we have the following situation:

bnx2_start_xmit()                       bnx2_tx_int()
    if (!bnx2_tx_avail())
            BUG();

    ...

    if (!bnx2_tx_avail())
            netif_tx_stop_queue();          update_tx_index();
            smp_mb();                       smp_mb();
            if (bnx2_tx_avail())            if (netif_tx_queue_stopped() &&
                    netif_tx_wake_queue();      bnx2_tx_avail())

With smp_mb() removed from bnx2_tx_avail(), we need to add smp_mb() to
bnx2_start_xmit() as shown above to properly order netif_tx_stop_queue()
and bnx2_tx_avail() to check the ring index.  If it is not strictly
ordered, the tx queue can be stopped forever.

This improves performance by about 5% with 2 ports running bi-directional
64-byte packets.

Reviewed-by: Benjamin Li <benli@broadcom.com>
Reviewed-by: Matt Carlson <mcarlson@broadcom.com>
Signed-off-by: Michael Chan <mchan@broadcom.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
drivers/net/bnx2.c