[dpdk-dev,v2] ethdev: Prefetch driver variable structure

Message ID 745DB4B8861F8E4B9849C970520ABBF14975C429@ORSMSX102.amr.corp.intel.com (mailing list archive)
State Rejected, archived
Delegated to: Thomas Monjalon
Headers

Commit Message

Mike A. Polehn Nov. 11, 2015, 1:59 p.m. UTC
  Adds ethdev driver prefetch of variable structure to CPU cache 0
while calling into tx or rx device driver operation.

RFC 2544 test of NIC task test measurement points show improvement
of lower latency and/or better packet throughput indicating clock
cycles saved.

Signed-off-by: Mike A. Polehn <mike.a.polehn@intel.com>
---
 lib/librte_ether/rte_ethdev.h | 16 +++++++++++++---
 1 file changed, 13 insertions(+), 3 deletions(-)
  

Comments

Thomas Monjalon Nov. 24, 2015, 9:26 p.m. UTC | #1
2015-11-11 13:59, Polehn, Mike A:
> Adds ethdev driver prefetch of variable structure to CPU cache 0
> while calling into tx or rx device driver operation.
> 
> RFC 2544 test of NIC task test measurement points show improvement
> of lower latency and/or better packet throughput indicating clock
> cycles saved.
> 
> Signed-off-by: Mike A. Polehn <mike.a.polehn@intel.com>

There are still some spacing issues with this patch.

Bruce, what is your opinion about this prefetch?
  
Ferruh Yigit Dec. 19, 2018, 9:14 p.m. UTC | #2
On 11/11/2015 1:59 PM, mike.a.polehn at intel.com (Polehn, Mike A) wrote:
> Adds ethdev driver prefetch of variable structure to CPU cache 0
> while calling into tx or rx device driver operation.
> 
> RFC 2544 test of NIC task test measurement points show improvement
> of lower latency and/or better packet throughput indicating clock
> cycles saved.
> 
> Signed-off-by: Mike A. Polehn <mike.a.polehn at intel.com>

Hi Mike,

This patch is sitting on patchwork since 2015 without review, I am updating it
as rejected, if it is still relevant please let us know.

Sorry for any inconvenience caused.
  

Patch

diff --git a/lib/librte_ether/rte_ethdev.h b/lib/librte_ether/rte_ethdev.h
index 48a540d..f1c35de 100644
--- a/lib/librte_ether/rte_ethdev.h
+++ b/lib/librte_ether/rte_ethdev.h
@@ -2458,12 +2458,17 @@  rte_eth_rx_burst(uint8_t port_id, uint16_t queue_id,
 		 struct rte_mbuf **rx_pkts, const uint16_t nb_pkts)
 {
 	struct rte_eth_dev *dev;
+	int16_t nb_rx;
 
 	dev = &rte_eth_devices[port_id];
 
-	int16_t nb_rx = (*dev->rx_pkt_burst)(dev->data->rx_queues[queue_id],
-			rx_pkts, nb_pkts);
+	{ /* limit scope of rxq variable */
+		/* rxq is going to be immediately used, prefetch it */
+		void *rxq = dev->data->rx_queues[queue_id];
+		rte_prefetch0(rxq);
 
+		nb_rx = (*dev->rx_pkt_burst)(rxq, rx_pkts, nb_pkts);
+	}
 #ifdef RTE_ETHDEV_RXTX_CALLBACKS
 	struct rte_eth_rxtx_callback *cb = dev->post_rx_burst_cbs[queue_id];
 
@@ -2600,6 +2605,7 @@  rte_eth_tx_burst(uint8_t port_id, uint16_t queue_id,
 		 struct rte_mbuf **tx_pkts, uint16_t nb_pkts)
 {
 	struct rte_eth_dev *dev;
+	void *txq;
 
 	dev = &rte_eth_devices[port_id];
 
@@ -2615,7 +2621,11 @@  rte_eth_tx_burst(uint8_t port_id, uint16_t queue_id,
 	}
 #endif
 
-	return (*dev->tx_pkt_burst)(dev->data->tx_queues[queue_id], tx_pkts, nb_pkts);
+	/* txq is going to be immediately used, prefetch it */
+	txq = dev->data->tx_queues[queue_id];
+	rte_prefetch0(txq);
+
+	return (*dev->tx_pkt_burst)(txq, tx_pkts, nb_pkts);
 }
 #endif