From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga11.intel.com (mga11.intel.com [192.55.52.93]) by dpdk.org (Postfix) with ESMTP id DD88DB3A6 for ; Wed, 3 Sep 2014 17:45:43 +0200 (CEST) Received: from fmsmga001.fm.intel.com ([10.253.24.23]) by fmsmga102.fm.intel.com with ESMTP; 03 Sep 2014 08:49:45 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.04,458,1406617200"; d="scan'208";a="585697553" Received: from irvmail001.ir.intel.com ([163.33.26.43]) by fmsmga001.fm.intel.com with ESMTP; 03 Sep 2014 08:49:40 -0700 Received: from sivswdev02.ir.intel.com (sivswdev02.ir.intel.com [10.237.217.46]) by irvmail001.ir.intel.com (8.14.3/8.13.6/MailSET/Hub) with ESMTP id s83Fnenl025436; Wed, 3 Sep 2014 16:49:40 +0100 Received: from sivswdev02.ir.intel.com (localhost [127.0.0.1]) by sivswdev02.ir.intel.com with ESMTP id s83FneKm010500; Wed, 3 Sep 2014 16:49:40 +0100 Received: (from bricha3@localhost) by sivswdev02.ir.intel.com with id s83FneKe010496; Wed, 3 Sep 2014 16:49:40 +0100 From: Bruce Richardson To: dev@dpdk.org Date: Wed, 3 Sep 2014 16:49:37 +0100 Message-Id: <1409759378-10113-13-git-send-email-bruce.richardson@intel.com> X-Mailer: git-send-email 1.7.0.7 In-Reply-To: <1409759378-10113-1-git-send-email-bruce.richardson@intel.com> References: <1409759378-10113-1-git-send-email-bruce.richardson@intel.com> Subject: [dpdk-dev] [PATCH 12/13] ixgbe: Fix perf regression due to moved pool ptr X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: patches and discussions about DPDK List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 03 Sep 2014 15:45:45 -0000 Adjust the fast-path code to fix the regression caused by the pool pointer moving to the second cache line. This change adjusts the prefetching and also the way in which the mbufs are freed back to the mempool. Note: slow-path e.g. path supporting jumbo frames, is still slower, but is dealt with by a later commit Signed-off-by: Bruce Richardson --- lib/librte_pmd_ixgbe/ixgbe_rxtx.c | 8 ++- lib/librte_pmd_ixgbe/ixgbe_rxtx.h | 14 +----- lib/librte_pmd_ixgbe/ixgbe_rxtx_vec.c | 93 +++++++++++++---------------------- 3 files changed, 39 insertions(+), 76 deletions(-) diff --git a/lib/librte_pmd_ixgbe/ixgbe_rxtx.c b/lib/librte_pmd_ixgbe/ixgbe_rxtx.c index f48c62a..ebbcee8 100644 --- a/lib/librte_pmd_ixgbe/ixgbe_rxtx.c +++ b/lib/librte_pmd_ixgbe/ixgbe_rxtx.c @@ -142,10 +142,6 @@ ixgbe_tx_free_bufs(struct igb_tx_queue *txq) */ txep = &(txq->sw_ring[txq->tx_next_dd - (txq->tx_rs_thresh - 1)]); - /* prefetch the mbufs that are about to be freed */ - for (i = 0; i < txq->tx_rs_thresh; ++i) - rte_prefetch0((txep + i)->mbuf); - /* free buffers one at a time */ if ((txq->txq_flags & (uint32_t)ETH_TXQ_FLAGS_NOREFCOUNT) != 0) { for (i = 0; i < txq->tx_rs_thresh; ++i, ++txep) { @@ -186,6 +182,7 @@ tx4(volatile union ixgbe_adv_tx_desc *txdp, struct rte_mbuf **pkts) ((uint32_t)DCMD_DTYP_FLAGS | pkt_len); txdp->read.olinfo_status = (pkt_len << IXGBE_ADVTXD_PAYLEN_SHIFT); + rte_prefetch0(&(*pkts)->pool); } } @@ -205,6 +202,7 @@ tx1(volatile union ixgbe_adv_tx_desc *txdp, struct rte_mbuf **pkts) ((uint32_t)DCMD_DTYP_FLAGS | pkt_len); txdp->read.olinfo_status = (pkt_len << IXGBE_ADVTXD_PAYLEN_SHIFT); + rte_prefetch0(&(*pkts)->pool); } /* @@ -1876,7 +1874,7 @@ ixgbe_dev_tx_queue_setup(struct rte_eth_dev *dev, PMD_INIT_LOG(INFO, "Using simple tx code path\n"); #ifdef RTE_IXGBE_INC_VECTOR if (txq->tx_rs_thresh <= RTE_IXGBE_TX_MAX_FREE_BUF_SZ && - ixgbe_txq_vec_setup(txq, socket_id) == 0) { + ixgbe_txq_vec_setup(txq) == 0) { PMD_INIT_LOG(INFO, "Vector tx enabled.\n"); dev->tx_pkt_burst = ixgbe_xmit_pkts_vec; } diff --git a/lib/librte_pmd_ixgbe/ixgbe_rxtx.h b/lib/librte_pmd_ixgbe/ixgbe_rxtx.h index 5e98b21..dbb57af 100644 --- a/lib/librte_pmd_ixgbe/ixgbe_rxtx.h +++ b/lib/librte_pmd_ixgbe/ixgbe_rxtx.h @@ -96,14 +96,6 @@ struct igb_tx_entry_v { }; /** - * continuous entry sequence, gather by the same mempool - */ -struct igb_tx_entry_seq { - const struct rte_mempool* pool; - uint32_t same_pool; -}; - -/** * Structure associated with each RX queue. */ struct igb_rx_queue { @@ -191,10 +183,6 @@ struct igb_tx_queue { volatile union ixgbe_adv_tx_desc *tx_ring; uint64_t tx_ring_phys_addr; /**< TX ring DMA address. */ struct igb_tx_entry *sw_ring; /**< virtual address of SW ring. */ -#ifdef RTE_IXGBE_INC_VECTOR - /** continuous tx entry sequence within the same mempool */ - struct igb_tx_entry_seq *sw_ring_seq; -#endif volatile uint32_t *tdt_reg_addr; /**< Address of TDT register. */ uint16_t nb_tx_desc; /**< number of TX descriptors. */ uint16_t tx_tail; /**< current value of TDT reg. */ @@ -259,7 +247,7 @@ struct ixgbe_txq_ops { #ifdef RTE_IXGBE_INC_VECTOR uint16_t ixgbe_recv_pkts_vec(void *rx_queue, struct rte_mbuf **rx_pkts, uint16_t nb_pkts); uint16_t ixgbe_xmit_pkts_vec(void *tx_queue, struct rte_mbuf **tx_pkts, uint16_t nb_pkts); -int ixgbe_txq_vec_setup(struct igb_tx_queue *txq, unsigned int socket_id); +int ixgbe_txq_vec_setup(struct igb_tx_queue *txq); int ixgbe_rxq_vec_setup(struct igb_rx_queue *rxq); int ixgbe_rx_vec_condition_check(struct rte_eth_dev *dev); #endif diff --git a/lib/librte_pmd_ixgbe/ixgbe_rxtx_vec.c b/lib/librte_pmd_ixgbe/ixgbe_rxtx_vec.c index 3332a92..4f63086 100644 --- a/lib/librte_pmd_ixgbe/ixgbe_rxtx_vec.c +++ b/lib/librte_pmd_ixgbe/ixgbe_rxtx_vec.c @@ -342,9 +342,8 @@ static inline int __attribute__((always_inline)) ixgbe_tx_free_bufs(struct igb_tx_queue *txq) { struct igb_tx_entry_v *txep; - struct igb_tx_entry_seq *txsp; uint32_t status; - uint32_t n, k; + uint32_t n; #ifdef RTE_MBUF_REFCNT uint32_t i; int nb_free = 0; @@ -364,23 +363,39 @@ ixgbe_tx_free_bufs(struct igb_tx_queue *txq) */ txep = &((struct igb_tx_entry_v *)txq->sw_ring)[txq->tx_next_dd - (n - 1)]; - txsp = &txq->sw_ring_seq[txq->tx_next_dd - (n - 1)]; - - while (n > 0) { - k = RTE_MIN(n, txsp[n-1].same_pool); #ifdef RTE_MBUF_REFCNT - for (i = 0; i < k; i++) { - m = __rte_pktmbuf_prefree_seg((txep+n-k+i)->mbuf); - if (m != NULL) - free[nb_free++] = m; - } - rte_mempool_put_bulk((void *)txsp[n-1].pool, - (void **)free, nb_free); + m = __rte_pktmbuf_prefree_seg(txep[0].mbuf); +#else + m = txep[0].mbuf; +#endif + if (likely(m != NULL)) { + free[0] = m; + nb_free = 1; + for (i = 1; i < n; i++) { +#ifdef RTE_MBUF_REFCNT + m = __rte_pktmbuf_prefree_seg(txep[i].mbuf); #else - rte_mempool_put_bulk((void *)txsp[n-1].pool, - (void **)(txep+n-k), k); + m = txep[i]->mbuf; #endif - n -= k; + if (likely(m != NULL)) { + if (likely(m->pool == free[0]->pool)) + free[nb_free++] = m; + else { + rte_mempool_put_bulk(free[0]->pool, + (void *)free, nb_free); + free[0] = m; + nb_free = 1; + } + } + } + rte_mempool_put_bulk(free[0]->pool, (void **)free, nb_free); + } + else { + for (i = 1; i < n; i++) { + m = __rte_pktmbuf_prefree_seg(txep[i].mbuf); + if (m != NULL) + rte_mempool_put(m->pool, m); + } } /* buffers were freed, update counters */ @@ -394,19 +409,11 @@ ixgbe_tx_free_bufs(struct igb_tx_queue *txq) static inline void __attribute__((always_inline)) tx_backlog_entry(struct igb_tx_entry_v *txep, - struct igb_tx_entry_seq *txsp, struct rte_mbuf **tx_pkts, uint16_t nb_pkts) { int i; - for (i = 0; i < (int)nb_pkts; ++i) { + for (i = 0; i < (int)nb_pkts; ++i) txep[i].mbuf = tx_pkts[i]; - /* check and update sequence number */ - txsp[i].pool = tx_pkts[i]->pool; - if (txsp[i-1].pool == tx_pkts[i]->pool) - txsp[i].same_pool = txsp[i-1].same_pool + 1; - else - txsp[i].same_pool = 1; - } } uint16_t @@ -416,7 +423,6 @@ ixgbe_xmit_pkts_vec(void *tx_queue, struct rte_mbuf **tx_pkts, struct igb_tx_queue *txq = (struct igb_tx_queue *)tx_queue; volatile union ixgbe_adv_tx_desc *txdp; struct igb_tx_entry_v *txep; - struct igb_tx_entry_seq *txsp; uint16_t n, nb_commit, tx_id; uint64_t flags = DCMD_DTYP_FLAGS; uint64_t rs = IXGBE_ADVTXD_DCMD_RS|DCMD_DTYP_FLAGS; @@ -435,14 +441,13 @@ ixgbe_xmit_pkts_vec(void *tx_queue, struct rte_mbuf **tx_pkts, tx_id = txq->tx_tail; txdp = &txq->tx_ring[tx_id]; txep = &((struct igb_tx_entry_v *)txq->sw_ring)[tx_id]; - txsp = &txq->sw_ring_seq[tx_id]; txq->nb_tx_free = (uint16_t)(txq->nb_tx_free - nb_pkts); n = (uint16_t)(txq->nb_tx_desc - tx_id); if (nb_commit >= n) { - tx_backlog_entry(txep, txsp, tx_pkts, n); + tx_backlog_entry(txep, tx_pkts, n); for (i = 0; i < n - 1; ++i, ++tx_pkts, ++txdp) vtx1(txdp, *tx_pkts, flags); @@ -457,10 +462,9 @@ ixgbe_xmit_pkts_vec(void *tx_queue, struct rte_mbuf **tx_pkts, /* avoid reach the end of ring */ txdp = &(txq->tx_ring[tx_id]); txep = &(((struct igb_tx_entry_v *)txq->sw_ring)[tx_id]); - txsp = &(txq->sw_ring_seq[tx_id]); } - tx_backlog_entry(txep, txsp, tx_pkts, nb_commit); + tx_backlog_entry(txep, tx_pkts, nb_commit); vtx(txdp, tx_pkts, nb_commit, flags); @@ -484,7 +488,6 @@ ixgbe_tx_queue_release_mbufs(struct igb_tx_queue *txq) { unsigned i; struct igb_tx_entry_v *txe; - struct igb_tx_entry_seq *txs; uint16_t nb_free, max_desc; if (txq->sw_ring != NULL) { @@ -502,10 +505,6 @@ ixgbe_tx_queue_release_mbufs(struct igb_tx_queue *txq) for (i = 0; i < txq->nb_tx_desc; i++) { txe = (struct igb_tx_entry_v *)&txq->sw_ring[i]; txe->mbuf = NULL; - - txs = &txq->sw_ring_seq[i]; - txs->pool = NULL; - txs->same_pool = 0; } } } @@ -520,11 +519,6 @@ ixgbe_tx_free_swring(struct igb_tx_queue *txq) rte_free((struct igb_rx_entry *)txq->sw_ring - 1); txq->sw_ring = NULL; } - - if (txq->sw_ring_seq != NULL) { - rte_free(txq->sw_ring_seq - 1); - txq->sw_ring_seq = NULL; - } } static void @@ -533,7 +527,6 @@ ixgbe_reset_tx_queue(struct igb_tx_queue *txq) static const union ixgbe_adv_tx_desc zeroed_desc = { .read = { .buffer_addr = 0} }; struct igb_tx_entry_v *txe = (struct igb_tx_entry_v *)txq->sw_ring; - struct igb_tx_entry_seq *txs = txq->sw_ring_seq; uint16_t i; /* Zero out HW ring memory */ @@ -545,8 +538,6 @@ ixgbe_reset_tx_queue(struct igb_tx_queue *txq) volatile union ixgbe_adv_tx_desc *txd = &txq->tx_ring[i]; txd->wb.status = IXGBE_TXD_STAT_DD; txe[i].mbuf = NULL; - txs[i].pool = NULL; - txs[i].same_pool = 0; } txq->tx_next_dd = (uint16_t)(txq->tx_rs_thresh - 1); @@ -588,28 +579,14 @@ ixgbe_rxq_vec_setup(struct igb_rx_queue *rxq) return 0; } -int ixgbe_txq_vec_setup(struct igb_tx_queue *txq, - unsigned int socket_id) +int ixgbe_txq_vec_setup(struct igb_tx_queue *txq) { - uint16_t nb_desc; - if (txq->sw_ring == NULL) return -1; - /* request addtional one entry for continous sequence check */ - nb_desc = (uint16_t)(txq->nb_tx_desc + 1); - - txq->sw_ring_seq = rte_zmalloc_socket("txq->sw_ring_seq", - sizeof(struct igb_tx_entry_seq) * nb_desc, - CACHE_LINE_SIZE, socket_id); - if (txq->sw_ring_seq == NULL) - return -1; - - /* leave the first one for overflow */ txq->sw_ring = (struct igb_tx_entry *) ((struct igb_tx_entry_v *)txq->sw_ring + 1); - txq->sw_ring_seq += 1; txq->ops = &vec_txq_ops; return 0; -- 1.9.3