From mboxrd@z Thu Jan 1 00:00:00 1970 From: Stephen Hemminger Subject: [PATCH 2/5] virtio: don't use unlikely for normal tx stuff Date: Sun, 18 Oct 2015 22:16:09 -0700 Message-ID: <1445231772-17467-3-git-send-email-stephen@networkplumber.org> References: <1445231772-17467-1-git-send-email-stephen@networkplumber.org> Cc: dev@dpdk.org To: huawei.xie@intel.com, changchun.ouyang@intel.com Return-path: Received: from mail-pa0-f52.google.com (mail-pa0-f52.google.com [209.85.220.52]) by dpdk.org (Postfix) with ESMTP id 375648E80 for ; Mon, 19 Oct 2015 07:16:07 +0200 (CEST) Received: by pabrc13 with SMTP id rc13so179467234pab.0 for ; Sun, 18 Oct 2015 22:16:06 -0700 (PDT) In-Reply-To: <1445231772-17467-1-git-send-email-stephen@networkplumber.org> List-Id: patches and discussions about DPDK List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Sender: "dev" Don't use unlikely() for VLAN or ring getting full. GCC will not optimize code in unlikely paths and since these can happen with normal code that can hurt performance. Signed-off-by: Stephen Hemminger --- drivers/net/virtio/virtio_rxtx.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/drivers/net/virtio/virtio_rxtx.c b/drivers/net/virtio/virtio_rxtx.c index 5b50ed0..dbe6665 100644 --- a/drivers/net/virtio/virtio_rxtx.c +++ b/drivers/net/virtio/virtio_rxtx.c @@ -763,7 +763,7 @@ virtio_xmit_pkts(void *tx_queue, struct rte_mbuf **tx_pkts, uint16_t nb_pkts) int need = txm->nb_segs - txvq->vq_free_cnt + 1; /* Positive value indicates it need free vring descriptors */ - if (unlikely(need > 0)) { + if (need > 0) { nb_used = VIRTQUEUE_NUSED(txvq); virtio_rmb(); need = RTE_MIN(need, (int)nb_used); @@ -778,7 +778,7 @@ virtio_xmit_pkts(void *tx_queue, struct rte_mbuf **tx_pkts, uint16_t nb_pkts) } /* Do VLAN tag insertion */ - if (unlikely(txm->ol_flags & PKT_TX_VLAN_PKT)) { + if (txm->ol_flags & PKT_TX_VLAN_PKT) { error = rte_vlan_insert(&txm); if (unlikely(error)) { rte_pktmbuf_free(txm); @@ -798,10 +798,9 @@ virtio_xmit_pkts(void *tx_queue, struct rte_mbuf **tx_pkts, uint16_t nb_pkts) break; } txvq->bytes += txm->pkt_len; + ++txvq->packets; } - txvq->packets += nb_tx; - if (likely(nb_tx)) { vq_update_avail_idx(txvq); -- 2.1.4