[v2,1/5] net/i40e: use relaxed and remove duplicate barrier
diff mbox series

Message ID 1568633238-47888-2-git-send-email-gavin.hu@arm.com
State Accepted, archived
Delegated to: Ferruh Yigit
Headers show
Series
  • fix and optimize barriers usage with some PMDs
Related show

Checks

Context Check Description
ci/checkpatch success coding style OK
ci/Intel-compilation success Compilation OK
ci/iol-dpdk_compile_ovs success Compile Testing PASS
ci/iol-dpdk_compile_spdk success Compile Testing PASS
ci/iol-dpdk_compile success Compile Testing PASS
ci/intel-Performance success Performance Testing PASS
ci/mellanox-Performance success Performance Testing PASS

Commit Message

Gavin Hu Sept. 16, 2019, 11:27 a.m. UTC
To guarantee the orderings of successive stores to CIO and MMIO memory,
a lighter weight rte_io_wmb [1] can be used instead of rte_wmb, and since
the I40E_PCI_REG_WRITE API already has an inclusive rte_io_wmb, this
explicit call can be even saved.

[1] http://git.dpdk.org/dpdk/tree/lib/librte_eal/common/include/generic/
rte_atomic.h#n98

Signed-off-by: Gavin Hu <gavin.hu@arm.com>
---
 drivers/net/i40e/i40e_rxtx.c | 12 +++---------
 1 file changed, 3 insertions(+), 9 deletions(-)

Comments

Zhang, Qi Z Sept. 17, 2019, 1:53 a.m. UTC | #1
> -----Original Message-----
> From: dev [mailto:dev-bounces@dpdk.org] On Behalf Of Gavin Hu
> Sent: Monday, September 16, 2019 7:27 PM
> To: dev@dpdk.org
> Cc: nd@arm.com; thomas@monjalon.net; Richardson, Bruce
> <bruce.richardson@intel.com>; Liu, Yong <yong.liu@intel.com>; Wang, Yinan
> <yinan.wang@intel.com>; ajit.khaparde@broadcom.com;
> somnath.kotur@broadcom.com; Honnappa.Nagarahalli@arm.com;
> ruifeng.wang@arm.com; steve.capper@arm.com
> Subject: [dpdk-dev] [PATCH v2 1/5] net/i40e: use relaxed and remove
> duplicate barrier
> 
> To guarantee the orderings of successive stores to CIO and MMIO memory, a
> lighter weight rte_io_wmb [1] can be used instead of rte_wmb, and since the
> I40E_PCI_REG_WRITE API already has an inclusive rte_io_wmb, this explicit call
> can be even saved.
> 
> [1] http://git.dpdk.org/dpdk/tree/lib/librte_eal/common/include/generic/
> rte_atomic.h#n98
> 
> Signed-off-by: Gavin Hu <gavin.hu@arm.com>

Can you also capture the one at the tail of i40e_xmit_pkts?

Otherwise
Acked-by: Qi Zhang <qi.z.zhang@intel.com>
Gavin Hu Sept. 17, 2019, 2:07 a.m. UTC | #2
Hi Qi,

> -----Original Message-----
> From: Zhang, Qi Z <qi.z.zhang@intel.com>
> Sent: Tuesday, September 17, 2019 9:53 AM
> To: Gavin Hu (Arm Technology China) <Gavin.Hu@arm.com>; dev@dpdk.org
> Cc: nd <nd@arm.com>; thomas@monjalon.net; Richardson, Bruce
> <bruce.richardson@intel.com>; Liu, Yong <yong.liu@intel.com>; Wang, Yinan
> <yinan.wang@intel.com>; ajit.khaparde@broadcom.com;
> somnath.kotur@broadcom.com; Honnappa Nagarahalli
> <Honnappa.Nagarahalli@arm.com>; Ruifeng Wang (Arm Technology China)
> <Ruifeng.Wang@arm.com>; Steve Capper <Steve.Capper@arm.com>
> Subject: RE: [dpdk-dev] [PATCH v2 1/5] net/i40e: use relaxed and remove
> duplicate barrier
> 
> 
> 
> > -----Original Message-----
> > From: dev [mailto:dev-bounces@dpdk.org] On Behalf Of Gavin Hu
> > Sent: Monday, September 16, 2019 7:27 PM
> > To: dev@dpdk.org
> > Cc: nd@arm.com; thomas@monjalon.net; Richardson, Bruce
> > <bruce.richardson@intel.com>; Liu, Yong <yong.liu@intel.com>; Wang,
> Yinan
> > <yinan.wang@intel.com>; ajit.khaparde@broadcom.com;
> > somnath.kotur@broadcom.com; Honnappa.Nagarahalli@arm.com;
> > ruifeng.wang@arm.com; steve.capper@arm.com
> > Subject: [dpdk-dev] [PATCH v2 1/5] net/i40e: use relaxed and remove
> > duplicate barrier
> >
> > To guarantee the orderings of successive stores to CIO and MMIO memory,
> a
> > lighter weight rte_io_wmb [1] can be used instead of rte_wmb, and since
> the
> > I40E_PCI_REG_WRITE API already has an inclusive rte_io_wmb, this explicit
> call
> > can be even saved.
> >
> > [1] http://git.dpdk.org/dpdk/tree/lib/librte_eal/common/include/generic/
> > rte_atomic.h#n98
> >
> > Signed-off-by: Gavin Hu <gavin.hu@arm.com>
> 
> Can you also capture the one at the tail of i40e_xmit_pkts?
Thanks for your review, I will fix this in next version.
> 
> Otherwise
> Acked-by: Qi Zhang <qi.z.zhang@intel.com>
>
Gavin Hu Sept. 17, 2019, 3:23 a.m. UTC | #3
Hi Qi, 

> -----Original Message-----
> From: dev <dev-bounces@dpdk.org> On Behalf Of Gavin Hu (Arm
> Technology China)
> Sent: Tuesday, September 17, 2019 10:08 AM
> To: Zhang, Qi Z <qi.z.zhang@intel.com>; dev@dpdk.org
> Cc: nd <nd@arm.com>; thomas@monjalon.net; Richardson, Bruce
> <bruce.richardson@intel.com>; Liu, Yong <yong.liu@intel.com>; Wang,
> Yinan <yinan.wang@intel.com>; ajit.khaparde@broadcom.com;
> somnath.kotur@broadcom.com; Honnappa Nagarahalli
> <Honnappa.Nagarahalli@arm.com>; Ruifeng Wang (Arm Technology China)
> <Ruifeng.Wang@arm.com>; Steve Capper <Steve.Capper@arm.com>
> Subject: Re: [dpdk-dev] [PATCH v2 1/5] net/i40e: use relaxed and remove
> duplicate barrier
> 
> Hi Qi,
> 
> > -----Original Message-----
> > From: Zhang, Qi Z <qi.z.zhang@intel.com>
> > Sent: Tuesday, September 17, 2019 9:53 AM
> > To: Gavin Hu (Arm Technology China) <Gavin.Hu@arm.com>;
> dev@dpdk.org
> > Cc: nd <nd@arm.com>; thomas@monjalon.net; Richardson, Bruce
> > <bruce.richardson@intel.com>; Liu, Yong <yong.liu@intel.com>; Wang,
> Yinan
> > <yinan.wang@intel.com>; ajit.khaparde@broadcom.com;
> > somnath.kotur@broadcom.com; Honnappa Nagarahalli
> > <Honnappa.Nagarahalli@arm.com>; Ruifeng Wang (Arm Technology
> China)
> > <Ruifeng.Wang@arm.com>; Steve Capper <Steve.Capper@arm.com>
> > Subject: RE: [dpdk-dev] [PATCH v2 1/5] net/i40e: use relaxed and remove
> > duplicate barrier
> >
> >
> >
> > > -----Original Message-----
> > > From: dev [mailto:dev-bounces@dpdk.org] On Behalf Of Gavin Hu
> > > Sent: Monday, September 16, 2019 7:27 PM
> > > To: dev@dpdk.org
> > > Cc: nd@arm.com; thomas@monjalon.net; Richardson, Bruce
> > > <bruce.richardson@intel.com>; Liu, Yong <yong.liu@intel.com>; Wang,
> > Yinan
> > > <yinan.wang@intel.com>; ajit.khaparde@broadcom.com;
> > > somnath.kotur@broadcom.com; Honnappa.Nagarahalli@arm.com;
> > > ruifeng.wang@arm.com; steve.capper@arm.com
> > > Subject: [dpdk-dev] [PATCH v2 1/5] net/i40e: use relaxed and remove
> > > duplicate barrier
> > >
> > > To guarantee the orderings of successive stores to CIO and MMIO
> memory,
> > a
> > > lighter weight rte_io_wmb [1] can be used instead of rte_wmb, and
> since
> > the
> > > I40E_PCI_REG_WRITE API already has an inclusive rte_io_wmb, this
> explicit
> > call
> > > can be even saved.
> > >
> > > [1]
> http://git.dpdk.org/dpdk/tree/lib/librte_eal/common/include/generic/
> > > rte_atomic.h#n98
> > >
> > > Signed-off-by: Gavin Hu <gavin.hu@arm.com>
> >
> > Can you also capture the one at the tail of i40e_xmit_pkts?
> Thanks for your review, I will fix this in next version.
I checked again, in this version, the rte_wmb at the tail of i40e_xmit_pkts was already removed
and the following I40E_PCI_REG_WRITE_RELAXED was replaced by  I40E_PCI_REG_WRITE, which has an inclusive rte_io_wmb. 
> >
> > Otherwise
> > Acked-by: Qi Zhang <qi.z.zhang@intel.com>
> >
Zhang, Qi Z Sept. 17, 2019, 5:13 a.m. UTC | #4
> -----Original Message-----
> From: Gavin Hu (Arm Technology China) [mailto:Gavin.Hu@arm.com]
> Sent: Tuesday, September 17, 2019 11:24 AM
> To: Gavin Hu (Arm Technology China) <Gavin.Hu@arm.com>; Zhang, Qi Z
> <qi.z.zhang@intel.com>; dev@dpdk.org
> Cc: nd <nd@arm.com>; thomas@monjalon.net; Richardson, Bruce
> <bruce.richardson@intel.com>; Liu, Yong <yong.liu@intel.com>; Wang, Yinan
> <yinan.wang@intel.com>; ajit.khaparde@broadcom.com;
> somnath.kotur@broadcom.com; Honnappa Nagarahalli
> <Honnappa.Nagarahalli@arm.com>; Ruifeng Wang (Arm Technology China)
> <Ruifeng.Wang@arm.com>; Steve Capper <Steve.Capper@arm.com>
> Subject: RE: [dpdk-dev] [PATCH v2 1/5] net/i40e: use relaxed and remove
> duplicate barrier
> 
> Hi Qi,
> 
> > -----Original Message-----
> > From: dev <dev-bounces@dpdk.org> On Behalf Of Gavin Hu (Arm Technology
> > China)
> > Sent: Tuesday, September 17, 2019 10:08 AM
> > To: Zhang, Qi Z <qi.z.zhang@intel.com>; dev@dpdk.org
> > Cc: nd <nd@arm.com>; thomas@monjalon.net; Richardson, Bruce
> > <bruce.richardson@intel.com>; Liu, Yong <yong.liu@intel.com>; Wang,
> > Yinan <yinan.wang@intel.com>; ajit.khaparde@broadcom.com;
> > somnath.kotur@broadcom.com; Honnappa Nagarahalli
> > <Honnappa.Nagarahalli@arm.com>; Ruifeng Wang (Arm Technology China)
> > <Ruifeng.Wang@arm.com>; Steve Capper <Steve.Capper@arm.com>
> > Subject: Re: [dpdk-dev] [PATCH v2 1/5] net/i40e: use relaxed and
> > remove duplicate barrier
> >
> > Hi Qi,
> >
> > > -----Original Message-----
> > > From: Zhang, Qi Z <qi.z.zhang@intel.com>
> > > Sent: Tuesday, September 17, 2019 9:53 AM
> > > To: Gavin Hu (Arm Technology China) <Gavin.Hu@arm.com>;
> > dev@dpdk.org
> > > Cc: nd <nd@arm.com>; thomas@monjalon.net; Richardson, Bruce
> > > <bruce.richardson@intel.com>; Liu, Yong <yong.liu@intel.com>; Wang,
> > Yinan
> > > <yinan.wang@intel.com>; ajit.khaparde@broadcom.com;
> > > somnath.kotur@broadcom.com; Honnappa Nagarahalli
> > > <Honnappa.Nagarahalli@arm.com>; Ruifeng Wang (Arm Technology
> > China)
> > > <Ruifeng.Wang@arm.com>; Steve Capper <Steve.Capper@arm.com>
> > > Subject: RE: [dpdk-dev] [PATCH v2 1/5] net/i40e: use relaxed and
> > > remove duplicate barrier
> > >
> > >
> > >
> > > > -----Original Message-----
> > > > From: dev [mailto:dev-bounces@dpdk.org] On Behalf Of Gavin Hu
> > > > Sent: Monday, September 16, 2019 7:27 PM
> > > > To: dev@dpdk.org
> > > > Cc: nd@arm.com; thomas@monjalon.net; Richardson, Bruce
> > > > <bruce.richardson@intel.com>; Liu, Yong <yong.liu@intel.com>;
> > > > Wang,
> > > Yinan
> > > > <yinan.wang@intel.com>; ajit.khaparde@broadcom.com;
> > > > somnath.kotur@broadcom.com; Honnappa.Nagarahalli@arm.com;
> > > > ruifeng.wang@arm.com; steve.capper@arm.com
> > > > Subject: [dpdk-dev] [PATCH v2 1/5] net/i40e: use relaxed and
> > > > remove duplicate barrier
> > > >
> > > > To guarantee the orderings of successive stores to CIO and MMIO
> > memory,
> > > a
> > > > lighter weight rte_io_wmb [1] can be used instead of rte_wmb, and
> > since
> > > the
> > > > I40E_PCI_REG_WRITE API already has an inclusive rte_io_wmb, this
> > explicit
> > > call
> > > > can be even saved.
> > > >
> > > > [1]
> > http://git.dpdk.org/dpdk/tree/lib/librte_eal/common/include/generic/
> > > > rte_atomic.h#n98
> > > >
> > > > Signed-off-by: Gavin Hu <gavin.hu@arm.com>
> > >
> > > Can you also capture the one at the tail of i40e_xmit_pkts?
> > Thanks for your review, I will fix this in next version.
> I checked again, in this version, the rte_wmb at the tail of i40e_xmit_pkts was
> already removed and the following I40E_PCI_REG_WRITE_RELAXED was
> replaced by  I40E_PCI_REG_WRITE, which has an inclusive rte_io_wmb.

Sorry, I must mixed the with ice patch, yes you are right, its already there.

> > >
> > > Otherwise
> > > Acked-by: Qi Zhang <qi.z.zhang@intel.com>
> > >

Patch
diff mbox series

diff --git a/drivers/net/i40e/i40e_rxtx.c b/drivers/net/i40e/i40e_rxtx.c
index 692c3ba..bfe161f 100644
--- a/drivers/net/i40e/i40e_rxtx.c
+++ b/drivers/net/i40e/i40e_rxtx.c
@@ -564,8 +564,7 @@  i40e_rx_alloc_bufs(struct i40e_rx_queue *rxq)
 	}
 
 	/* Update rx tail regsiter */
-	rte_wmb();
-	I40E_PCI_REG_WRITE_RELAXED(rxq->qrx_tail, rxq->rx_free_trigger);
+	I40E_PCI_REG_WRITE(rxq->qrx_tail, rxq->rx_free_trigger);
 
 	rxq->rx_free_trigger =
 		(uint16_t)(rxq->rx_free_trigger + rxq->rx_free_thresh);
@@ -1208,13 +1207,11 @@  i40e_xmit_pkts(void *tx_queue, struct rte_mbuf **tx_pkts, uint16_t nb_pkts)
 	}
 
 end_of_tx:
-	rte_wmb();
-
 	PMD_TX_LOG(DEBUG, "port_id=%u queue_id=%u tx_tail=%u nb_tx=%u",
 		   (unsigned) txq->port_id, (unsigned) txq->queue_id,
 		   (unsigned) tx_id, (unsigned) nb_tx);
 
-	I40E_PCI_REG_WRITE_RELAXED(txq->qtx_tail, tx_id);
+	I40E_PCI_REG_WRITE(txq->qtx_tail, tx_id);
 	txq->tx_tail = tx_id;
 
 	return nb_tx;
@@ -1365,8 +1362,7 @@  tx_xmit_pkts(struct i40e_tx_queue *txq,
 		txq->tx_tail = 0;
 
 	/* Update the tx tail register */
-	rte_wmb();
-	I40E_PCI_REG_WRITE_RELAXED(txq->qtx_tail, txq->tx_tail);
+	I40E_PCI_REG_WRITE(txq->qtx_tail, txq->tx_tail);
 
 	return nb_pkts;
 }
@@ -1544,8 +1540,6 @@  i40e_dev_rx_queue_start(struct rte_eth_dev *dev, uint16_t rx_queue_id)
 		return err;
 	}
 
-	rte_wmb();
-
 	/* Init the RX tail regieter. */
 	I40E_PCI_REG_WRITE(rxq->qrx_tail, rxq->nb_rx_desc - 1);