raw/ntb: fix write memory barrier issue
PATCH 1/1 raw/ntb: fix write memory barrier issue
All buffers and ring info should be written before tail register update. This patch relocates the write memory barrier before updating tail register to avoid potential issues.
--- drivers/raw/ntb/ntb.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/raw/ntb/ntb.c +2 -2
@@ -683,8 +683,8 @@ ntb_enqueue_bufs(struct rte_rawdev *dev, sizeof(struct ntb_used) * nb1);rte_memcpy (txq->tx_used_ring, tx_used + nb1,sizeof (struct ntb_used ) * nb2); - *txq->used_cnt = txq->last_used;rte_wmb (); + *txq->used_cnt = txq->last_used;/* update queue stats */ hw->ntb_xstats[NTB_TX_BYTES_ID + off] += bytes;
@@ -789,8 +789,8 @@ ntb_dequeue_bufs(struct rte_rawdev *dev, sizeof(struct ntb_desc) * nb1);rte_memcpy (rxq->rx_desc_ring, rx_desc + nb1,sizeof (struct ntb_desc ) * nb2); - *rxq->avail_cnt = rxq->last_avail;rte_wmb (); + *rxq->avail_cnt = rxq->last_avail;/* update queue stats */ off =NTB_XSTATS_NUM * ((size_t )context +1 );
Signature · 1 line
2.17.1
Hi Xiaoyun,
Quoted 24 lines
-----Original Message-----
From: dev <[email protected]> On Behalf Of Xiaoyun Li
Sent: Wednesday, December 4, 2019 11:19 PM
To: [email protected]
Cc: [email protected]; Xiaoyun Li <[email protected]>; [email protected]
Subject: [dpdk-dev] [PATCH] raw/ntb: fix write memory barrier issueAll buffers and ring info should be written before tail register update. This patch relocates the write memory barrier before updating tail register to avoid potential issues.
Fixes 11b5c7daf019 ("raw/ntb: add enqueue and dequeue functions")Signed-off-by Xiaoyun Li <[email protected]>--- drivers/raw/ntb/ntb.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)drivers/raw/ntb/ntb.c +0
-0
drivers/raw/ntb/ntb.c ntb_enqueue_bufs(struct rte_rawdev *dev, · line 687
Quoted 6 lines
drivers/raw/ntb/ntb.c +1
-1@@ -683,8 +683,8 @@ ntb_enqueue_bufs(struct rte_rawdev *dev, sizeof(struct ntb_used) * nb1);rte_memcpy (txq->tx_used_ring, tx_used + nb1,sizeof (struct ntb_used ) * nb2); - *txq->used_cnt = txq->last_used;rte_wmb (); + *txq->used_cnt = txq->last_used;
I am ok with the re-location of the barrier, but why not the rte_io_wmb instead of rte_wmb? Rte_io_wmb is sufficient to guarantee the preceding stores are visible to the device, rte_wmb is overkill.
https://code.dpdk.org/dpdk/latest/source/lib/librte_eal/common/include/generic/rte_atomic.h#L92
Quoted 15 lines
drivers/raw/ntb/ntb.c +1
-2/* update queue stats */ hw->ntb_xstats[NTB_TX_BYTES_ID + off] += bytes;@@ -789,8 +789,8 @@ ntb_dequeue_bufs(struct rte_rawdev *dev, sizeof(struct ntb_desc) * nb1);rte_memcpy (rxq->rx_desc_ring, rx_desc + nb1,sizeof (struct ntb_desc ) * nb2); - *rxq->avail_cnt = rxq->last_avail;rte_wmb (); + *rxq->avail_cnt = rxq->last_avail;/* update queue stats */ off =NTB_XSTATS_NUM * ((size_t )context +1 ); --2.17.1
Didn't notice that. Will fix it in v2. Thanks!
Quoted 60 lines
-----Original Message-----
From: Gavin Hu (Arm Technology China) [mailto:[email protected]]
Sent: Saturday, December 14, 2019 23:30
To: Li, Xiaoyun <[email protected]>; Wu, Jingjing <[email protected]>
Cc: [email protected]; [email protected]; nd <[email protected]>
Subject: RE: [dpdk-dev] [PATCH] raw/ntb: fix write memory barrier issueHi Xiaoyun,
Quoted 24 lines
-----Original Message-----
From: dev <[email protected]> On Behalf Of Xiaoyun Li
Sent: Wednesday, December 4, 2019 11:19 PM
To: [email protected]
Cc: [email protected]; Xiaoyun Li <[email protected]>; [email protected]
Subject: [dpdk-dev] [PATCH] raw/ntb: fix write memory barrier issueAll buffers and ring info should be written before tail register update. This patch relocates the write memory barrier before updating tail register to avoid potential issues.
Fixes 11b5c7daf019 ("raw/ntb: add enqueue and dequeue functions")Signed-off-by Xiaoyun Li <[email protected]>--- drivers/raw/ntb/ntb.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)drivers/raw/ntb/ntb.c +0
-0drivers/raw/ntb/ntb.c ntb_enqueue_bufs(struct rte_rawdev *dev, · line 687
Quoted 6 lines
drivers/raw/ntb/ntb.c +1
-1@@ -683,8 +683,8 @@ ntb_enqueue_bufs(struct rte_rawdev *dev, sizeof(struct ntb_used) * nb1);rte_memcpy (txq->tx_used_ring, tx_used + nb1,sizeof (struct ntb_used ) * nb2); - *txq->used_cnt = txq->last_used;rte_wmb (); + *txq->used_cnt = txq->last_used;I am ok with the re-location of the barrier, but why not the
rte_io_wmbinstead ofrte_wmb?Rte_io_wmbis sufficient to guarantee the preceding stores are visible to the device,rte_wmbis overkill.
https://code.dpdk.org/dpdk/latest/source/lib/librte_eal/common/include/gener
ic/rte_atomic.h#L92Quoted 15 lines
drivers/raw/ntb/ntb.c +1
-2/* update queue stats */ hw->ntb_xstats[NTB_TX_BYTES_ID + off] += bytes;@@ -789,8 +789,8 @@ ntb_dequeue_bufs(struct rte_rawdev *dev, sizeof(struct ntb_desc) * nb1);rte_memcpy (rxq->rx_desc_ring, rx_desc + nb1,sizeof (struct ntb_desc ) * nb2); - *rxq->avail_cnt = rxq->last_avail;rte_wmb (); + *rxq->avail_cnt = rxq->last_avail;/* update queue stats */ off =NTB_XSTATS_NUM * ((size_t )context +1 ); --2.17.1
Gavin Hu
Reviewed-byPATCH v2 1/1 raw/ntb: fix write memory barrier issue
In reply to Xiaoyun LiAll buffers and ring info should be written before tail register update. This patch relocates the write memory barrier before updating tail register to avoid potential issues.
---
v2:
* Replaced rte_wmb with rte_io_wmb since rte_io_wmb is enough.
--- drivers/raw/ntb/ntb.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/raw/ntb/ntb.c +2 -2
@@ -683,8 +683,8 @@ ntb_enqueue_bufs(struct rte_rawdev *dev, sizeof(struct ntb_used) * nb1);rte_memcpy (txq->tx_used_ring, tx_used + nb1,sizeof (struct ntb_used ) * nb2); +rte_io_wmb (); *txq->used_cnt = txq->last_used; -rte_wmb ();/* update queue stats */ hw->ntb_xstats[NTB_TX_BYTES_ID + off] += bytes;
@@ -789,8 +789,8 @@ ntb_dequeue_bufs(struct rte_rawdev *dev, sizeof(struct ntb_desc) * nb1);rte_memcpy (rxq->rx_desc_ring, rx_desc + nb1,sizeof (struct ntb_desc ) * nb2); +rte_io_wmb (); *rxq->avail_cnt = rxq->last_avail; -rte_wmb ();/* update queue stats */ off =NTB_XSTATS_NUM * ((size_t )context +1 );
Signature · 1 line
2.17.1
Quoted 30 lines
-----Original Message-----
From: dev <[email protected]> On Behalf Of Xiaoyun Li
Sent: Monday, December 16, 2019 9:59 AM
To: [email protected]
Cc: [email protected]; [email protected]; Xiaoyun Li <[email protected]>; [email protected]
Subject: [dpdk-dev] [PATCH v2] raw/ntb: fix write memory barrier issueAll buffers and ring info should be written before tail register update. This patch relocates the write memory barrier before updating tail register to avoid potential issues.
Fixes 11b5c7daf019 ("raw/ntb: add enqueue and dequeue functions")Signed-off-by Xiaoyun Li <[email protected]>---
v2:
* Replacedrte_wmbwithrte_io_wmbsincerte_io_wmbis enough.--- drivers/raw/ntb/ntb.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)drivers/raw/ntb/ntb.c +0
-0
drivers/raw/ntb/ntb.c ntb_enqueue_bufs(struct rte_rawdev *dev, · line 686
Quoted 4 lines
drivers/raw/ntb/ntb.c +1
-0@@ -683,8 +683,8 @@ ntb_enqueue_bufs(struct rte_rawdev *dev, sizeof(struct ntb_used) * nb1);rte_memcpy (txq->tx_used_ring, tx_used + nb1,sizeof (struct ntb_used ) * nb2); +rte_io_wmb ();
As both txq->tx_used_ring and *txq->used_cnt are physically reside in the PCI device side, rte_io_wmb is correct to ensure the ordering.
Quoted 16 lines
drivers/raw/ntb/ntb.c +1
-3*txq->used_cnt = txq->last_used; -rte_wmb ();/* update queue stats */ hw->ntb_xstats[NTB_TX_BYTES_ID + off] += bytes;@@ -789,8 +789,8 @@ ntb_dequeue_bufs(struct rte_rawdev *dev, sizeof(struct ntb_desc) * nb1);rte_memcpy (rxq->rx_desc_ring, rx_desc + nb1,sizeof (struct ntb_desc ) * nb2); +rte_io_wmb (); *rxq->avail_cnt = rxq->last_avail; -rte_wmb ();/* update queue stats */ off =NTB_XSTATS_NUM * ((size_t )context +1 ); --
Quoted 1 line
2.17.1
Hi
I reconsidered and retested about this issue.
I still need to use rte_wmb instead of using rte_io_wmb.
Because to achieve high performance, ntb needs to turn on WC(write combining) feature. The perf difference with and without WC enabled is more than 20X. And when WC enabled, rte_io_wmb cannot make sure the instructions are in order only rte_wmb can make sure that.
And in my retest, when sending 64 bytes packets, using rte_io_wmb will cause out-of-order issue and cause memory corruption on rx side. And using rte_wmb is fine.
So I can only use v1 patch and suspend v2 patch in patchwork.
Best Regards
Xiaoyun Li
Quoted 65 lines
-----Original Message-----
From: Gavin Hu (Arm Technology China) [mailto:[email protected]]
Sent: Monday, December 16, 2019 18:50
To: Li, Xiaoyun <[email protected]>; Wu, Jingjing <[email protected]>
Cc: [email protected]; Maslekar, Omkar <[email protected]>; [email protected]; nd <[email protected]>
Subject: RE: [dpdk-dev] [PATCH v2] raw/ntb: fix write memory barrier issueQuoted 28 lines
-----Original Message-----
From: dev <[email protected]> On Behalf Of Xiaoyun Li
Sent: Monday, December 16, 2019 9:59 AM
To: [email protected]
Cc: [email protected]; [email protected]; Xiaoyun Li <[email protected]>; [email protected]
Subject: [dpdk-dev] [PATCH v2] raw/ntb: fix write memory barrier issueAll buffers and ring info should be written before tail register update. This patch relocates the write memory barrier before updating tail register to avoid potential issues.
Fixes 11b5c7daf019 ("raw/ntb: add enqueue and dequeue functions")Signed-off-by Xiaoyun Li <[email protected]>---
v2:
* Replacedrte_wmbwithrte_io_wmbsincerte_io_wmbis enough.--- drivers/raw/ntb/ntb.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)drivers/raw/ntb/ntb.c index renamed from drivers/raw/ntb/ntb.c +0
-0
ad7f6abfd..c7de86f36100644drivers/raw/ntb/ntb.c ntb_enqueue_bufs(struct rte_rawdev *dev, · line 686
Quoted 4 lines
drivers/raw/ntb/ntb.c +1
-0@@ -683,8 +683,8 @@ ntb_enqueue_bufs(struct rte_rawdev *dev, sizeof(struct ntb_used) * nb1);rte_memcpy (txq->tx_used_ring, tx_used + nb1,sizeof (struct ntb_used ) * nb2); +rte_io_wmb ();As both
txq->tx_used_ringand*txq->used_cntare physically reside in the PCI device side,rte_io_wmbis correct to ensure the ordering.drivers/raw/ntb/ntb.c ntb_enqueue_bufs(struct rte_rawdev *dev,
Quoted 5 lines
drivers/raw/ntb/ntb.c +0
-1*txq->used_cnt = txq->last_used; -rte_wmb ();/* update queue stats */ hw->ntb_xstats[NTB_TX_BYTES_ID + off] += bytes; @@ -789,8+789,8 @@
Quoted 11 lines
ntb_dequeue_bufs(struct
rte_rawdev*dev,drivers/raw/ntb/ntb.c +1
-2sizeof(struct ntb_desc) * nb1);rte_memcpy (rxq->rx_desc_ring, rx_desc + nb1,sizeof (struct ntb_desc ) * nb2); +rte_io_wmb (); *rxq->avail_cnt = rxq->last_avail; -rte_wmb ();/* update queue stats */ off =NTB_XSTATS_NUM * ((size_t )context +1 ); --Quoted 1 line
2.17.1
Reviewed-by Gavin Hu <[email protected]>
Hi Xiaoyun,
Quoted 18 lines
-----Original Message-----
From: Li, Xiaoyun <[email protected]>
Sent: Monday, December 23, 2019 3:52 PM
To: Gavin Hu <[email protected]>; Wu, Jingjing <[email protected]>
Cc: [email protected]; Maslekar, Omkar <[email protected]>; [email protected]; nd <[email protected]>
Subject: RE: [dpdk-dev] [PATCH v2] raw/ntb: fix write memory barrier issueHi
I reconsidered and retested about this issue.
I still need to userte_wmbinstead of usingrte_io_wmb.Because to achieve high performance, ntb needs to turn on WC(write combining) feature. The perf difference with and without WC enabled is more than 20X.
And when WC enabled,rte_io_wmbcannot make sure the instructions are in order onlyrte_wmbcan make sure that.
Quoted 3 lines
And in my retest, when sending 64 bytes packets, using
rte_io_wmbwill cause out-of-order issue and cause memory corruption on rx side. And usingrte_wmbis fine.
That's true, as it is declared as 'write combine' region, even x86 is known as strong ordered, it is the interconnect or PCI RC may do the reordering, 'write combine', 'write coalescing', which caused this problem. IMO, rte_io_*mb barriers on x86 should be promoted to stronger is WC is involved(but that will sap performance for non-WC memories?).
https://code.dpdk.org/dpdk/latest/source/lib/librte_eal/common/include/arch/x86/rte_atomic.h#L78
Using rte_wmb will hurt performance for aarch64 also, as pci device memory accesses to a single device are strongly ordered therefore the strongest rte_wmb is not necessary.
Quoted 74 lines
So I can only use v1 patch and suspend v2 patch in patchwork.
Best Regards
Xiaoyun LiQuoted 4 lines
-----Original Message-----
From: Gavin Hu (Arm Technology China) [mailto:[email protected]]
Sent: Monday, December 16, 2019 18:50
To: Li, Xiaoyun <[email protected]>; Wu, JingjingQuoted 3 lines
Cc: [email protected]; Maslekar, Omkar <[email protected]>; [email protected]; nd <[email protected]>
Subject: RE: [dpdk-dev] [PATCH v2] raw/ntb: fix write memory barrierissue
Quoted 26 lines
Quoted 26 lines
-----Original Message-----
From: dev <[email protected]> On Behalf Of Xiaoyun Li
Sent: Monday, December 16, 2019 9:59 AM
To: [email protected]
Cc: [email protected]; [email protected]; Xiaoyun Li <[email protected]>; [email protected]
Subject: [dpdk-dev] [PATCH v2] raw/ntb: fix write memory barrier issueAll buffers and ring info should be written before tail register update. This patch relocates the write memory barrier before updating tail register to avoid potential issues.
Fixes 11b5c7daf019 ("raw/ntb: add enqueue and dequeue functions")Signed-off-by Xiaoyun Li <[email protected]>---
v2:
* Replacedrte_wmbwithrte_io_wmbsincerte_io_wmbis enough.--- drivers/raw/ntb/ntb.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)Quoted 10 lines
drivers/raw/ntb/ntb.c ntb_enqueue_bufs(struct rte_rawdev *dev, · line 686
Quoted 9 lines
drivers/raw/ntb/ntb.c index renamed from drivers/raw/ntb/ntb.c +0
-0
ad7f6abfd..c7de86f36100644drivers/raw/ntb/ntb.c +1
-0@@ -683,8 +683,8 @@ ntb_enqueue_bufs(struct rte_rawdev *dev, sizeof(struct ntb_used) * nb1);rte_memcpy (txq->tx_used_ring, tx_used + nb1,sizeof (struct ntb_used ) * nb2); +rte_io_wmb ();As both
txq->tx_used_ringand*txq->used_cntare physically reside in thePCI
Quoted 7 lines
device side,
rte_io_wmbis correct to ensure the ordering.drivers/raw/ntb/ntb.c ntb_enqueue_bufs(struct rte_rawdev *dev,
Quoted 5 lines
drivers/raw/ntb/ntb.c +0
-1*txq->used_cnt = txq->last_used; -rte_wmb ();/* update queue stats */ hw->ntb_xstats[NTB_TX_BYTES_ID + off] += bytes; @@ -789,8
Quoted 15 lines
+789,8 @@
Quoted 11 lines
ntb_dequeue_bufs(struct
rte_rawdev*dev,drivers/raw/ntb/ntb.c +1
-2sizeof(struct ntb_desc) * nb1);rte_memcpy (rxq->rx_desc_ring, rx_desc + nb1,sizeof (struct ntb_desc ) * nb2); +rte_io_wmb (); *rxq->avail_cnt = rxq->last_avail; -rte_wmb ();/* update queue stats */ off =NTB_XSTATS_NUM * ((size_t )context +1 ); --Quoted 1 line
2.17.1
Reviewed-by Gavin Hu <[email protected]>
Hi
Still, stability and correctness are much more important than performance.
As I said, with WC can benefit more than 20X perf. Comparing to this benefit, the difference between rte_wmb and rte_io_wmb is not that important. And in my test, the performance is not that bad with rte_wmb especially with large packets which are the normal use cases.
BTW, I've searched linux kernel codes and don't see any NTB device on arm platform. So I don't think you need to consider the perf hurt to arm.
Best Regards
Xiaoyun Li
Quoted 121 lines
-----Original Message-----
From: Gavin Hu [mailto:[email protected]]
Sent: Monday, December 23, 2019 16:38
To: Li, Xiaoyun <[email protected]>; Wu, Jingjing <[email protected]>
Cc: [email protected]; Maslekar, Omkar <[email protected]>; [email protected]; nd <[email protected]>; [email protected]; Honnappa Nagarahalli <[email protected]>; Richardson, Bruce <[email protected]>; nd <[email protected]>
Subject: RE: [dpdk-dev] [PATCH v2] raw/ntb: fix write memory barrier issueHi Xiaoyun,
Quoted 19 lines
-----Original Message-----
From: Li, Xiaoyun <[email protected]>
Sent: Monday, December 23, 2019 3:52 PM
To: Gavin Hu <[email protected]>; Wu, Jingjing <[email protected]>
Cc: [email protected]; Maslekar, Omkar <[email protected]>; [email protected]; nd <[email protected]>
Subject: RE: [dpdk-dev] [PATCH v2] raw/ntb: fix write memory barrier issueHi
I reconsidered and retested about this issue.
I still need to userte_wmbinstead of usingrte_io_wmb.Because to achieve high performance, ntb needs to turn on WC(write combining) feature. The perf difference with and without WC enabled is more than 20X.
And when WC enabled,rte_io_wmbcannot make sure the instructions are in order onlyrte_wmbcan make sure that.Quoted 3 lines
And in my retest, when sending 64 bytes packets, using
rte_io_wmbwill cause out-of-order issue and cause memory corruption on rx side. And usingrte_wmbis fine.That's true, as it is declared as 'write combine' region, even x86 is known as strong ordered, it is the interconnect or PCI RC may do the reordering, 'write combine', 'write coalescing', which caused this problem.
IMO, rte_io_*mb barriers on x86 should be promoted to stronger is WC is involved(but that will sap performance for non-WC memories?).
https://code.dpdk.org/dpdk/latest/source/lib/librte_eal/common/include/arch/
x86/rte_atomic.h#L78Using
rte_wmbwill hurt performance for aarch64 also, as pci device memory accesses to a single device are strongly ordered therefore the strongestrte_wmbis not necessary.Quoted 76 lines
So I can only use v1 patch and suspend v2 patch in patchwork.
Best Regards
Xiaoyun LiQuoted 4 lines
-----Original Message-----
From: Gavin Hu (Arm Technology China) [mailto:[email protected]]
Sent: Monday, December 16, 2019 18:50
To: Li, Xiaoyun <[email protected]>; Wu, JingjingQuoted 3 lines
Cc: [email protected]; Maslekar, Omkar <[email protected]>; [email protected]; nd <[email protected]>
Subject: RE: [dpdk-dev] [PATCH v2] raw/ntb: fix write memory barrierissue
Quoted 27 lines
Quoted 27 lines
-----Original Message-----
From: dev <[email protected]> On Behalf Of Xiaoyun Li
Sent: Monday, December 16, 2019 9:59 AM
To: [email protected]
Cc: [email protected]; [email protected]; Xiaoyun Li <[email protected]>; [email protected]
Subject: [dpdk-dev] [PATCH v2] raw/ntb: fix write memory barrier issueAll buffers and ring info should be written before tail register update. This patch relocates the write memory barrier before updating tail register to avoid potential issues.
Fixes 11b5c7daf019 ("raw/ntb: add enqueue and dequeue functions")Signed-off-by Xiaoyun Li <[email protected]>---
v2:
* Replacedrte_wmbwithrte_io_wmbsincerte_io_wmbis enough.--- drivers/raw/ntb/ntb.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)Quoted 11 lines
drivers/raw/ntb/ntb.c ntb_enqueue_bufs(struct rte_rawdev *dev, · line 686
Quoted 9 lines
drivers/raw/ntb/ntb.c index renamed from drivers/raw/ntb/ntb.c +0
-0
ad7f6abfd..c7de86f36100644drivers/raw/ntb/ntb.c +1
-0@@ -683,8 +683,8 @@ ntb_enqueue_bufs(struct rte_rawdev *dev, sizeof(struct ntb_used) * nb1);rte_memcpy (txq->tx_used_ring, tx_used + nb1,sizeof (struct ntb_used ) * nb2); +rte_io_wmb ();As both
txq->tx_used_ringand*txq->used_cntare physically reside in thePCI
Quoted 7 lines
device side,
rte_io_wmbis correct to ensure the ordering.drivers/raw/ntb/ntb.c ntb_enqueue_bufs(struct rte_rawdev *dev,
Quoted 5 lines
drivers/raw/ntb/ntb.c +0
-1*txq->used_cnt = txq->last_used; -rte_wmb ();/* update queue stats */ hw->ntb_xstats[NTB_TX_BYTES_ID + off] += bytes; @@ -789,8
Quoted 15 lines
+789,8 @@
Quoted 11 lines
ntb_dequeue_bufs(struct
rte_rawdev*dev,drivers/raw/ntb/ntb.c +1
-2sizeof(struct ntb_desc) * nb1);rte_memcpy (rxq->rx_desc_ring, rx_desc + nb1,sizeof (struct ntb_desc ) * nb2); +rte_io_wmb (); *rxq->avail_cnt = rxq->last_avail; -rte_wmb ();/* update queue stats */ off =NTB_XSTATS_NUM * ((size_t )context +1 ); --Quoted 1 line
2.17.1
Reviewed-by Gavin Hu <[email protected]>
Hi Xiaoyun,
Quoted 10 lines
-----Original Message-----
From: Li, Xiaoyun <[email protected]>
Sent: Monday, December 23, 2019 5:36 PM
To: Gavin Hu <[email protected]>; Wu, Jingjing <[email protected]>
Cc: [email protected]; Maslekar, Omkar <[email protected]>; [email protected]; nd <[email protected]>; [email protected]; Honnappa Nagarahalli <[email protected]>; Richardson, Bruce <[email protected]>; nd <[email protected]>
Subject: RE: [dpdk-dev] [PATCH v2] raw/ntb: fix write memory barrier issue
Quoted 7 lines
Hi
Still, stability and correctness are much more important than performance. As I said, with WC can benefit more than 20X perf. Comparing to this benefit, the difference between
rte_wmbandrte_io_wmbis not that important. And in my test, the performance is not that bad withrte_wmbespecially with large packets which are the normal use cases.
I agree 'sfence' is the correct barrier for WC, as it is a weak memory model. Rte_io on x86 is a compiler barrier, that is not strong enough.
Quoted 4 lines
BTW, I've searched linux kernel codes and don't see any NTB device on arm platform.
So I don't think you need to consider the perf hurt to arm.
Limited the discussion to NTB, I am fine, and since WC in not used for any other NICs, that's ok.
Quoted 130 lines
Best Regards
Xiaoyun LiQuoted 4 lines
-----Original Message-----
From: Gavin Hu [mailto:[email protected]]
Sent: Monday, December 23, 2019 16:38
To: Li, Xiaoyun <[email protected]>; Wu, JingjingQuoted 6 lines
Cc: [email protected]; Maslekar, Omkar <[email protected]>; [email protected]; nd <[email protected]>; [email protected]; Honnappa Nagarahalli <[email protected]>; Richardson, Bruce <[email protected]>; nd <[email protected]>
Subject: RE: [dpdk-dev] [PATCH v2] raw/ntb: fix write memory barrier issueQuoted 19 lines
Hi Xiaoyun,
Quoted 17 lines
-----Original Message-----
From: Li, Xiaoyun <[email protected]>
Sent: Monday, December 23, 2019 3:52 PM
To: Gavin Hu <[email protected]>; Wu, Jingjing <[email protected]>
Cc: [email protected]; Maslekar, Omkar <[email protected]>; [email protected]; nd <[email protected]>
Subject: RE: [dpdk-dev] [PATCH v2] raw/ntb: fix write memory barrier issueHi
I reconsidered and retested about this issue.
I still need to userte_wmbinstead of usingrte_io_wmb.Because to achieve high performance, ntb needs to turn on WC(write combining) feature. The perf difference with and without WC enabled is more than 20X.
And when WC enabled,rte_io_wmbcannot make sure the instructionsare
Quoted 11 lines
Quoted 5 lines
in order only
rte_wmbcan make sure that.And in my retest, when sending 64 bytes packets, using
rte_io_wmbwill cause out-of-order issue and cause memory corruption on rx side. And usingrte_wmbis fine.That's true, as it is declared as 'write combine' region, even x86 is known as strong ordered, it is the interconnect or PCI RC may do the reordering, 'write combine', 'write coalescing', which caused this problem.
IMO, rte_io_*mb barriers on x86 should be promoted to stronger is WC is involved(but that will sap performance for non-WC memories?).https://code.dpdk.org/dpdk/latest/source/lib/librte_eal/common/include/ar
ch/Quoted 3 lines
x86/rte_atomic.h#L78
Using
rte_wmbwill hurt performance for aarch64 also, as pci devicememory
Quoted 78 lines
accesses to a single device are strongly ordered therefore the strongest
rte_wmbis not necessary.Quoted 76 lines
So I can only use v1 patch and suspend v2 patch in patchwork.
Best Regards
Xiaoyun LiQuoted 4 lines
-----Original Message-----
From: Gavin Hu (Arm Technology China) [mailto:[email protected]]
Sent: Monday, December 16, 2019 18:50
To: Li, Xiaoyun <[email protected]>; Wu, JingjingQuoted 3 lines
Cc: [email protected]; Maslekar, Omkar <[email protected]>; [email protected]; nd <[email protected]>
Subject: RE: [dpdk-dev] [PATCH v2] raw/ntb: fix write memory barrierissue
Quoted 27 lines
Quoted 27 lines
-----Original Message-----
From: dev <[email protected]> On Behalf Of Xiaoyun Li
Sent: Monday, December 16, 2019 9:59 AM
To: [email protected]
Cc: [email protected]; [email protected]; Xiaoyun Li <[email protected]>; [email protected]
Subject: [dpdk-dev] [PATCH v2] raw/ntb: fix write memory barrier issueAll buffers and ring info should be written before tail register update. This patch relocates the write memory barrier before updating tail register to avoid potential issues.
Fixes 11b5c7daf019 ("raw/ntb: add enqueue and dequeue functions")Signed-off-by Xiaoyun Li <[email protected]>---
v2:
* Replacedrte_wmbwithrte_io_wmbsincerte_io_wmbis enough.--- drivers/raw/ntb/ntb.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)Quoted 11 lines
drivers/raw/ntb/ntb.c ntb_enqueue_bufs(struct rte_rawdev *dev, · line 686
Quoted 9 lines
drivers/raw/ntb/ntb.c index renamed from drivers/raw/ntb/ntb.c +0
-0
ad7f6abfd..c7de86f36100644drivers/raw/ntb/ntb.c +1
-0@@ -683,8 +683,8 @@ ntb_enqueue_bufs(struct rte_rawdev *dev, sizeof(struct ntb_used) * nb1);rte_memcpy (txq->tx_used_ring, tx_used + nb1,sizeof (struct ntb_used ) * nb2); +rte_io_wmb ();As both
txq->tx_used_ringand*txq->used_cntare physically reside in thePCI
Quoted 7 lines
device side,
rte_io_wmbis correct to ensure the ordering.drivers/raw/ntb/ntb.c ntb_enqueue_bufs(struct rte_rawdev *dev,
Quoted 5 lines
drivers/raw/ntb/ntb.c +0
-1*txq->used_cnt = txq->last_used; -rte_wmb ();/* update queue stats */ hw->ntb_xstats[NTB_TX_BYTES_ID + off] += bytes; @@ -789,8
Quoted 15 lines
+789,8 @@
Quoted 11 lines
ntb_dequeue_bufs(struct
rte_rawdev*dev,drivers/raw/ntb/ntb.c +1
-2sizeof(struct ntb_desc) * nb1);rte_memcpy (rxq->rx_desc_ring, rx_desc + nb1,sizeof (struct ntb_desc ) * nb2); +rte_io_wmb (); *rxq->avail_cnt = rxq->last_avail; -rte_wmb ();/* update queue stats */ off =NTB_XSTATS_NUM * ((size_t )context +1 ); --Quoted 1 line
2.17.1
Reviewed-by Gavin Hu <[email protected]>
Quoted 10 lines
-----Original Message-----
From: Li, Xiaoyun <[email protected]>
Sent: Monday, December 16, 2019 9:59 AM
To: Wu, Jingjing <[email protected]>
Cc: [email protected]; Maslekar, Omkar <[email protected]>; Li, Xiaoyun <[email protected]>; [email protected]
Subject: [PATCH v2] raw/ntb: fix write memory barrier issue
Quoted 8 lines
All buffers and ring info should be written before tail register update. This patch relocates the write memory barrier before updating tail register to avoid potential issues.
Fixes 11b5c7daf019 ("raw/ntb: add enqueue and dequeue functions")Signed-off-by Xiaoyun Li <[email protected]>
Quoted 33 lines
---
v2:
* Replacedrte_wmbwithrte_io_wmbsincerte_io_wmbis enough.--- drivers/raw/ntb/ntb.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)drivers/raw/ntb/ntb.c +2
-3@@ -683,8 +683,8 @@ ntb_enqueue_bufs(struct rte_rawdev *dev, sizeof(struct ntb_used) * nb1);rte_memcpy (txq->tx_used_ring, tx_used + nb1,sizeof (struct ntb_used ) * nb2); +rte_io_wmb (); *txq->used_cnt = txq->last_used; -rte_wmb ();/* update queue stats */ hw->ntb_xstats[NTB_TX_BYTES_ID + off] += bytes;@@ -789,8 +789,8 @@ ntb_dequeue_bufs(struct rte_rawdev *dev, sizeof(struct ntb_desc) * nb1);rte_memcpy (rxq->rx_desc_ring, rx_desc + nb1,sizeof (struct ntb_desc ) * nb2); +rte_io_wmb (); *rxq->avail_cnt = rxq->last_avail; -rte_wmb ();/* update queue stats */ off =NTB_XSTATS_NUM * ((size_t )context +1 ); --2.17.1
Quoted 9 lines
-----Original Message-----
From: Li, Xiaoyun <[email protected]>
Sent: Wednesday, December 4, 2019 11:19 PM
To: Wu, Jingjing <[email protected]>
Cc: [email protected]; Li, Xiaoyun <[email protected]>; [email protected]
Subject: [PATCH] raw/ntb: fix write memory barrier issue
Quoted 8 lines
All buffers and ring info should be written before tail register update. This patch relocates the write memory barrier before updating tail register to avoid potential issues.
Fixes 11b5c7daf019 ("raw/ntb: add enqueue and dequeue functions")Signed-off-by Xiaoyun Li <[email protected]>
26/12/2019 02:46, Wu, Jingjing:
Quoted 10 lines
From: Li, Xiaoyun <[email protected]>
Quoted 8 lines
All buffers and ring info should be written before tail register update. This patch relocates the write memory barrier before updating tail register to avoid potential issues.
Fixes 11b5c7daf019 ("raw/ntb: add enqueue and dequeue functions")Signed-off-by Xiaoyun Li <[email protected]>Acked-by Jingjing Wu <[email protected]>
v1 applied, thanks