[dpdk-dev,2/5] virtio: don't use unlikely for normal tx stuff

Message ID 1445231772-17467-3-git-send-email-stephen@networkplumber.org (mailing list archive)
State Changes Requested, archived
Headers

Commit Message

Stephen Hemminger Oct. 19, 2015, 5:16 a.m. UTC
  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 <stephen@networkplumber.org>
---
 drivers/net/virtio/virtio_rxtx.c | 7 +++----
 1 file changed, 3 insertions(+), 4 deletions(-)
  

Patch

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);