forcedeth: optimize the rx with likely
authorZhu Yanjun <yanjun.zhu@oracle.com>
Tue, 26 Dec 2017 06:22:50 +0000 (01:22 -0500)
committerDavid S. Miller <davem@davemloft.net>
Tue, 2 Jan 2018 18:29:23 +0000 (13:29 -0500)
In the rx fastpath, the function netdev_alloc_skb rarely fails.
Therefore, a likely() optimization is added to this error check
conditional.

CC: Srinivas Eeda <srinivas.eeda@oracle.com>
CC: Joe Jin <joe.jin@oracle.com>
CC: Junxiao Bi <junxiao.bi@oracle.com>
Signed-off-by: Zhu Yanjun <yanjun.zhu@oracle.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
drivers/net/ethernet/nvidia/forcedeth.c

index 49d6d789459ed3460c5731002d94ad7272dbdeb4..a79b9f81484420f19e3ebde36ed5e43f28f7fa22 100644 (file)
@@ -1817,7 +1817,7 @@ static int nv_alloc_rx(struct net_device *dev)
 
        while (np->put_rx.orig != less_rx) {
                struct sk_buff *skb = netdev_alloc_skb(dev, np->rx_buf_sz + NV_RX_ALLOC_PAD);
-               if (skb) {
+               if (likely(skb)) {
                        np->put_rx_ctx->skb = skb;
                        np->put_rx_ctx->dma = dma_map_single(&np->pci_dev->dev,
                                                             skb->data,
@@ -1858,7 +1858,7 @@ static int nv_alloc_rx_optimized(struct net_device *dev)
 
        while (np->put_rx.ex != less_rx) {
                struct sk_buff *skb = netdev_alloc_skb(dev, np->rx_buf_sz + NV_RX_ALLOC_PAD);
-               if (skb) {
+               if (likely(skb)) {
                        np->put_rx_ctx->skb = skb;
                        np->put_rx_ctx->dma = dma_map_single(&np->pci_dev->dev,
                                                             skb->data,