Skip to contentSkip to conversation

i40e Rx descriptor loads ordering

PATCH Superseded Ruifeng Wang 4 participants 17 messages Sep 6, 2021 – Nov 11, 2021 Network drivers

lore
Share & tools
lore
#0 lore raw

cover i40e Rx descriptor loads ordering

On Rx path, NIC fills Rx descriptor with data pertains to received packet.

A single descriptor consists of multiple words. Word1 has the bit that indicates readiness of descriptor for software to use. So word1 should be loaded before other words.

On architectures with weaker memory ordering, barrier is needed to ensure the ordering of loads.

This patch set fixed the risk on both scalar path and aarch64 vector path.

Ruifeng Wang (2):
net/i40e: fix risk in Rx descriptor read in NEON vector path net/i40e: fix risk in Rx descriptor read in scalar path

 drivers/net/i40e/i40e_rxtx.c          | 12 ++++++++++++
 drivers/net/i40e/i40e_rxtx_vec_neon.c |  8 ++++++++
 2 files changed, 20 insertions(+)
Signature · 1 line
2.25.1
#1 lore raw

PATCH 1/2 net/i40e: fix risk in Rx descriptor read in NEON vector path

Rx descriptor is 16B/32B in size and consists of multiple words. The word that includes DD field should be read first. Read result with DD bit set indicates the rest part in a descriptor is valid.

In NEON vector PMD, vector load loads two contiguous 8B of descriptor data into vector register. Given vector load ensures no 16B atomicity, read of the word that includes DD field could be reordered after read of other words. In this case, some words could be invalid data.

Read barrier is added after read of qword1 that includes DD field. And qword0 is reloaded to update vector register. This ensures what fetched is correct descriptor data.

Fixes ae0eb310f253 ("net/i40e: implement vector PMD for ARM")
---
 drivers/net/i40e/i40e_rxtx_vec_neon.c | 8 ++++++++
 1 file changed, 8 insertions(+)
drivers/net/i40e/i40e_rxtx_vec_neon.c +8 -0
index b2683fda60..71191c7cc8 100644
@@ -286,6 +286,14 @@ _recv_raw_pkts_vec(struct i40e_rx_queue *__rte_restrict rxq,
 		descs[1] =  vld1q_u64((uint64_t *)(rxdp + 1));
 		descs[0] =  vld1q_u64((uint64_t *)(rxdp));
 
+		/* Use acquire fence to order loads of descriptor qwords */
+		rte_atomic_thread_fence(__ATOMIC_ACQUIRE);
+		/* A.2 reload qword0 to make it ordered after qword1 load */
+		descs[3] = vld1q_lane_u64((uint64_t *)(rxdp + 3), descs[3], 0);
+		descs[2] = vld1q_lane_u64((uint64_t *)(rxdp + 2), descs[2], 0);
+		descs[1] = vld1q_lane_u64((uint64_t *)(rxdp + 1), descs[1], 0);
+		descs[0] = vld1q_lane_u64((uint64_t *)(rxdp), descs[0], 0);
+
 		/* B.1 load 4 mbuf point */
 		mbp1 = vld1q_u64((uint64_t *)&sw_ring[pos]);
 		mbp2 = vld1q_u64((uint64_t *)&sw_ring[pos + 2]);
Signature · 1 line
2.25.1
Reviewed-by on v1 1/2
#2 lore raw

Re: [dpdk-dev] [PATCH 1/2] net/i40e: fix risk in Rx descriptor read in NEON vector path

<snip>
Similar comments that I have to patch 2/2

Quoted 4 lines

Rx descriptor is 16B/32B in size and consists of multiple words. The word that includes DD field should be read first. Read result with DD bit set indicates the rest part in a descriptor is valid.

Suggest rewording as follows:
Rx descriptor is 16B/32B in size. If the DD bit is set, it indicates that the rest of the descriptor words have valid values. Hence, the word containing DD bit must be read first before reading the rest of the descriptor words.

Quoted 5 lines

In NEON vector PMD, vector load loads two contiguous 8B of descriptor data into vector register. Given vector load ensures no 16B atomicity, read of the word that includes DD field could be reordered after read of other words. In this case, some words could be invalid data.

"some words could contain invalid data"

Quoted 4 lines

Read barrier is added after read of qword1 that includes DD field. And qword0 is reloaded to update vector register. This ensures what fetched is correct descriptor data.

"This ensures that the fetched data is correct".

Suggest capturing the performance impact, so it is clearly documented.

Quoted 5 lines
Fixes ae0eb310f253 ("net/i40e: implement vector PMD for ARM")

With the above comments,

Quoted 30 lines
---
 drivers/net/i40e/i40e_rxtx_vec_neon.c | 8 ++++++++
 1 file changed, 8 insertions(+)
drivers/net/i40e/i40e_rxtx_vec_neon.c +6 -0
index b2683fda60..71191c7cc8 100644
@@ -286,6 +286,14 @@ _recv_raw_pkts_vec(struct i40e_rx_queue
 *__rte_restrict rxq,
 		descs[1] =  vld1q_u64((uint64_t *)(rxdp + 1));
 		descs[0] =  vld1q_u64((uint64_t *)(rxdp));
 
+		/* Use acquire fence to order loads of descriptor qwords */
+		rte_atomic_thread_fence(__ATOMIC_ACQUIRE);
+		/* A.2 reload qword0 to make it ordered after qword1 load */
+		descs[3] = vld1q_lane_u64((uint64_t *)(rxdp + 3), descs[3],
 0);
+		descs[2] = vld1q_lane_u64((uint64_t *)(rxdp + 2), descs[2],
 0);
+		descs[1] = vld1q_lane_u64((uint64_t *)(rxdp + 1), descs[1],

0);

drivers/net/i40e/i40e_rxtx_vec_neon.c +2 -1
+		descs[0] = vld1q_lane_u64((uint64_t *)(rxdp), descs[0], 0);
+
 		/* B.1 load 4 mbuf point */
 		mbp1 = vld1q_u64((uint64_t *)&sw_ring[pos]);
 		mbp2 = vld1q_u64((uint64_t *)&sw_ring[pos + 2]);
--

2.25.1

#3 lore raw

Re: [dpdk-dev] [PATCH 1/2] net/i40e: fix risk in Rx descriptor read in NEON vector path

Quoted 32 lines

-----Original Message-----
From: Honnappa Nagarahalli <[email protected]>
Sent: Wednesday, September 15, 2021 2:33 AM
To: Ruifeng Wang <[email protected]>; [email protected]
Cc: [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; nd <[email protected]>; Ruifeng Wang <[email protected]>; Honnappa Nagarahalli <[email protected]>; nd <[email protected]>
Subject: RE: [PATCH 1/2] net/i40e: fix risk in Rx descriptor read in NEON vector path

<snip>
Similar comments that I have to patch 2/2

Quoted 4 lines

Rx descriptor is 16B/32B in size and consists of multiple words. The word that includes DD field should be read first. Read result with DD bit set indicates the rest part in a descriptor is valid.

Suggest rewording as follows:
Rx descriptor is 16B/32B in size. If the DD bit is set, it indicates that the rest of the descriptor words have valid values. Hence, the word containing DD bit must be read first before reading the rest of the descriptor words.

Quoted 5 lines

In NEON vector PMD, vector load loads two contiguous 8B of descriptor data into vector register. Given vector load ensures no 16B atomicity, read of the word that includes DD field could be reordered after read of other words. In this case, some words could be invalid data.

"some words could contain invalid data"

Quoted 1 line
Quoted 6 lines
Quoted 3 lines

Read barrier is added after read of qword1 that includes DD field. And qword0 is reloaded to update vector register. This ensures what fetched is correct descriptor data.

"This ensures that the fetched data is correct".

Suggest capturing the performance impact, so it is clearly documented.

Added performance impact to commit message in v2.

Quoted 8 lines
Quoted 5 lines
Fixes ae0eb310f253 ("net/i40e: implement vector PMD for ARM")

With the above comments,

Thanks for your review.
Comments are addressed in v2.

Quoted 31 lines
Quoted 10 lines
---
 drivers/net/i40e/i40e_rxtx_vec_neon.c | 8 ++++++++
 1 file changed, 8 insertions(+)
drivers/net/i40e/i40e_rxtx_vec_neon.c +0 -0
index b2683fda60..71191c7cc8 100644

drivers/net/i40e/i40e_rxtx_vec_neon.c _recv_raw_pkts_vec(struct i40e_rx_queue · line 292

Quoted 7 lines
drivers/net/i40e/i40e_rxtx_vec_neon.c +3 -0
@@ -286,6 +286,14 @@ _recv_raw_pkts_vec(struct i40e_rx_queue
 *__rte_restrict rxq,
 		descs[1] =  vld1q_u64((uint64_t *)(rxdp + 1));
 		descs[0] =  vld1q_u64((uint64_t *)(rxdp));
 
+		/* Use acquire fence to order loads of descriptor qwords */
+		rte_atomic_thread_fence(__ATOMIC_ACQUIRE);
+		/* A.2 reload qword0 to make it ordered after qword1 load

*/

Quoted 13 lines
drivers/net/i40e/i40e_rxtx_vec_neon.c +3 -0
+		descs[3] = vld1q_lane_u64((uint64_t *)(rxdp + 3), descs[3],
 0);
+		descs[2] = vld1q_lane_u64((uint64_t *)(rxdp + 2), descs[2],
 0);
+		descs[1] = vld1q_lane_u64((uint64_t *)(rxdp + 1), descs[1],

0);

drivers/net/i40e/i40e_rxtx_vec_neon.c +2 -1
+		descs[0] = vld1q_lane_u64((uint64_t *)(rxdp), descs[0], 0);
+
 		/* B.1 load 4 mbuf point */
 		mbp1 = vld1q_u64((uint64_t *)&sw_ring[pos]);
 		mbp2 = vld1q_u64((uint64_t *)&sw_ring[pos + 2]);
--

2.25.1

#4 lore raw

PATCH 2/2 net/i40e: fix risk in Rx descriptor read in scalar path

In reply to Ruifeng Wang

Rx descriptor is 16B/32B in size and consists of multiple words. The word that includes DD field should be read first. Read result with DD bit set indicates the rest part in a descriptor is valid.

In functions for simple Rx, the descriptor is not read atomically in whole. On weaker ordered systems like aarch64, read of the word that includes DD field could be reordered after read of other words. In this case, some words could be invalid data.

Read barrier is inserted between read of the word with DD field and read of other words. The barrier ensures what fetched is correct descriptor data.

Fixes 7b0cf70135d1 ("net/i40e: support ARM platform")

---
The change should not impact performance on x86 as acquire fence is ignored on x86.

 drivers/net/i40e/i40e_rxtx.c | 12 ++++++++++++
 1 file changed, 12 insertions(+)
drivers/net/i40e/i40e_rxtx.c +12 -0
index 8329cbdd4e..c4cd6b6b60 100644
@@ -746,6 +746,12 @@ i40e_recv_pkts(void *rx_queue, struct rte_mbuf **rx_pkts, uint16_t nb_pkts)
 			break;
 		}
 
+		/**
+		 * Use acquire fence to ensure that qword1 which includes DD
+		 * bit is loaded before loading of other descriptor words.
+		 */
+		rte_atomic_thread_fence(__ATOMIC_ACQUIRE);
+
 		rxd = *rxdp;
 		nb_hold++;
 		rxe = &sw_ring[rx_id];
@@ -862,6 +868,12 @@ i40e_recv_scattered_pkts(void *rx_queue,
 			break;
 		}
 
+		/**
+		 * Use acquire fence to ensure that qword1 which includes DD
+		 * bit is loaded before loading of other descriptor words.
+		 */
+		rte_atomic_thread_fence(__ATOMIC_ACQUIRE);
+
 		rxd = *rxdp;
 		nb_hold++;
 		rxe = &sw_ring[rx_id];
Signature · 1 line
2.25.1
Reviewed-by on v1 2/2
#5 lore raw

Re: [dpdk-dev] [PATCH 2/2] net/i40e: fix risk in Rx descriptor read in scalar path

<snip>

Quoted 4 lines

Rx descriptor is 16B/32B in size and consists of multiple words. The word that includes DD field should be read first. Read result with DD bit set indicates the rest part in a descriptor is valid.

Suggest rewording as follows:
Rx descriptor is 16B/32B in size. If the DD bit is set, it indicates that the rest of the descriptor words have valid values. Hence, the word containing DD bit must be read first before reading the rest of the descriptor words.

Quoted 5 lines

In functions for simple Rx, the descriptor is not read atomically in whole. On weaker ordered systems like aarch64, read of the word that includes DD field could be reordered after read of other words.
In this case, some words could be invalid data.

Since the entire descriptor is not read atomically, on relaxed memory ordered systems like Aarch64, read of the word containing DD field could be reordered after read of other words.

Quoted 3 lines

Read barrier is inserted between read of the word with DD field and read of other words. The barrier ensures what fetched is correct descriptor data.

Suggest capturing the performance impact, so it is clearly documented.

Quoted 5 lines
Fixes 7b0cf70135d1 ("net/i40e: support ARM platform")

With the above comments,

Quoted 40 lines

---
The change should not impact performance on x86 as acquire fence is ignored on x86.

 drivers/net/i40e/i40e_rxtx.c | 12 ++++++++++++
 1 file changed, 12 insertions(+)
drivers/net/i40e/i40e_rxtx.c index renamed from drivers/net/i40e/i40e_rxtx.c +0 -0

8329cbdd4e..c4cd6b6b60 100644

drivers/net/i40e/i40e_rxtx.c +6 -0
@@ -746,6 +746,12 @@ i40e_recv_pkts(void *rx_queue, struct rte_mbuf
 **rx_pkts, uint16_t nb_pkts)
 			break;
 		}
 
+		/**
+		 * Use acquire fence to ensure that qword1 which includes DD
+		 * bit is loaded before loading of other descriptor words.
+		 */
+		rte_atomic_thread_fence(__ATOMIC_ACQUIRE);
+
 		rxd = *rxdp;
 		nb_hold++;
drivers/net/i40e/i40e_rxtx.c +6 -1
 		rxe = &sw_ring[rx_id];
@@ -862,6 +868,12 @@ i40e_recv_scattered_pkts(void *rx_queue,
 			break;
 		}
 
+		/**
+		 * Use acquire fence to ensure that qword1 which includes DD
+		 * bit is loaded before loading of other descriptor words.
+		 */
+		rte_atomic_thread_fence(__ATOMIC_ACQUIRE);
+
 		rxd = *rxdp;
 		nb_hold++;
 		rxe = &sw_ring[rx_id];
--

2.25.1

#6 lore raw

v2 cover i40e Rx descriptor loads ordering

In reply to Ruifeng Wang

On Rx path, NIC fills Rx descriptor with data pertains to received packet.

A single descriptor consists of multiple words. Word1 has the bit that indicates readiness of descriptor for software to use. So word1 should be loaded before other words.

On architectures with weaker memory ordering, barrier is needed to ensure the ordering of loads.

This patch set fixed the risk on both scalar path and aarch64 vector path.

v2:
Updated commit message. Performance impact added. (Honnappa)

Ruifeng Wang (2):
net/i40e: fix risk in Rx descriptor read in NEON vector path net/i40e: fix risk in Rx descriptor read in scalar path

 drivers/net/i40e/i40e_rxtx.c          | 12 ++++++++++++
 drivers/net/i40e/i40e_rxtx_vec_neon.c |  8 ++++++++
 2 files changed, 20 insertions(+)
Signature · 1 line
2.25.1
#7 lore raw

PATCH v2 1/2 net/i40e: fix risk in Rx descriptor read in NEON vector path

Rx descriptor is 16B/32B in size. If the DD bit is set, it indicates that the rest of the descriptor words have valid values. Hence, the word containing DD bit must be read first before reading the rest of the descriptor words.

In NEON vector PMD, vector load loads two contiguous 8B of descriptor data into vector register. Given vector load ensures no 16B atomicity, read of the word that includes DD field could be reordered after read of other words. In this case, some words could contain invalid data.

Read barrier is added after read of qword1 that includes DD field. And qword0 is reloaded to update vector register. This ensures that the fetched data is correct.

Testpmd single core test on N1SDP/ThunderX2 showed no performance drop.

Fixes ae0eb310f253 ("net/i40e: implement vector PMD for ARM")
---
 drivers/net/i40e/i40e_rxtx_vec_neon.c | 8 ++++++++
 1 file changed, 8 insertions(+)
drivers/net/i40e/i40e_rxtx_vec_neon.c +8 -0
index b2683fda60..71191c7cc8 100644
@@ -286,6 +286,14 @@ _recv_raw_pkts_vec(struct i40e_rx_queue *__rte_restrict rxq,
 		descs[1] =  vld1q_u64((uint64_t *)(rxdp + 1));
 		descs[0] =  vld1q_u64((uint64_t *)(rxdp));
 
+		/* Use acquire fence to order loads of descriptor qwords */
+		rte_atomic_thread_fence(__ATOMIC_ACQUIRE);
+		/* A.2 reload qword0 to make it ordered after qword1 load */
+		descs[3] = vld1q_lane_u64((uint64_t *)(rxdp + 3), descs[3], 0);
+		descs[2] = vld1q_lane_u64((uint64_t *)(rxdp + 2), descs[2], 0);
+		descs[1] = vld1q_lane_u64((uint64_t *)(rxdp + 1), descs[1], 0);
+		descs[0] = vld1q_lane_u64((uint64_t *)(rxdp), descs[0], 0);
+
 		/* B.1 load 4 mbuf point */
 		mbp1 = vld1q_u64((uint64_t *)&sw_ring[pos]);
 		mbp2 = vld1q_u64((uint64_t *)&sw_ring[pos + 2]);
Signature · 1 line
2.25.1
#8 lore raw

PATCH v2 2/2 net/i40e: fix risk in Rx descriptor read in scalar path

In reply to Ruifeng Wang

Rx descriptor is 16B/32B in size. If the DD bit is set, it indicates that the rest of the descriptor words have valid values. Hence, the word containing DD bit must be read first before reading the rest of the descriptor words.

Since the entire descriptor is not read atomically, on relaxed memory ordered systems like Aarch64, read of the word containing DD field could be reordered after read of other words.

Read barrier is inserted between read of the word with DD field and read of other words. The barrier ensures that the fetched data is correct.

Testpmd single core test showed no performance drop on x86 or N1SDP. On ThunderX2, 22% performance regression was observed.

Fixes 7b0cf70135d1 ("net/i40e: support ARM platform")
---
 drivers/net/i40e/i40e_rxtx.c | 12 ++++++++++++
 1 file changed, 12 insertions(+)
drivers/net/i40e/i40e_rxtx.c +12 -0
index 8329cbdd4e..c4cd6b6b60 100644
@@ -746,6 +746,12 @@ i40e_recv_pkts(void *rx_queue, struct rte_mbuf **rx_pkts, uint16_t nb_pkts)
 			break;
 		}
 
+		/**
+		 * Use acquire fence to ensure that qword1 which includes DD
+		 * bit is loaded before loading of other descriptor words.
+		 */
+		rte_atomic_thread_fence(__ATOMIC_ACQUIRE);
+
 		rxd = *rxdp;
 		nb_hold++;
 		rxe = &sw_ring[rx_id];
@@ -862,6 +868,12 @@ i40e_recv_scattered_pkts(void *rx_queue,
 			break;
 		}
 
+		/**
+		 * Use acquire fence to ensure that qword1 which includes DD
+		 * bit is loaded before loading of other descriptor words.
+		 */
+		rte_atomic_thread_fence(__ATOMIC_ACQUIRE);
+
 		rxd = *rxdp;
 		nb_hold++;
 		rxe = &sw_ring[rx_id];
Signature · 1 line
2.25.1
#9 lore raw

Re: [dpdk-dev] [dpdk-stable] [PATCH v2 2/2] net/i40e: fix risk in Rx descriptor read in scalar path

Quoted 9 lines · Ruifeng Wang

Rx descriptor is 16B/32B in size. If the DD bit is set, it indicates that the rest of the descriptor words have valid values. Hence, the word containing DD bit must be read first before reading the rest of the descriptor words.

Since the entire descriptor is not read atomically, on relaxed memory ordered systems like Aarch64, read of the word containing DD field could be reordered after read of other words.

Quoted 7 lines

Read barrier is inserted between read of the word with DD field and read of other words. The barrier ensures that the fetched data is correct.

Testpmd single core test showed no performance drop on x86 or N1SDP. On ThunderX2, 22% performance regression was observed.

Is 22% performance drop value correct? That is a big drop, is it acceptable?

Is this performance drop valid for all Arm scalar datapath, or is it specific to ThunderX2?

Quoted 5 lines
Fixes 7b0cf70135d1 ("net/i40e: support ARM platform")
#10 lore raw

Re: [dpdk-dev] [dpdk-stable] [PATCH v2 2/2] net/i40e: fix risk in Rx descriptor read in scalar path

<snip>

Quoted 15 lines · Ruifeng Wang
Quoted 13 lines

Rx descriptor is 16B/32B in size. If the DD bit is set, it indicates that the rest of the descriptor words have valid values. Hence, the word containing DD bit must be read first before reading the rest of the descriptor words.

Since the entire descriptor is not read atomically, on relaxed memory ordered systems like Aarch64, read of the word containing DD field could be reordered after read of other words.

Read barrier is inserted between read of the word with DD field and read of other words. The barrier ensures that the fetched data is correct.

Quoted 5 lines
Quoted 3 lines

Testpmd single core test showed no performance drop on x86 or N1SDP. On ThunderX2, 22% performance regression was observed.

Is 22% performance drop value correct? That is a big drop, is it acceptable?

Agree, it is a big drop. Fixing it will require using the barrier less frequently. For ex: read 4 descriptors (4 words containing the DD bits) before using the barrier.

Quoted 3 lines

Is this performance drop valid for all Arm scalar datapath, or is it specific to ThunderX2?

This is specific to ThunderX2. N1 CPU does not see any impact. A72 is not tested. Considering that the ThunderXx line of CPUs are not in further development, and it is scalar path, I would not suggest to make further changes to the code.

It would be good to test this on Kunpeng servers and get some feedback.

Quoted 6 lines
Quoted 6 lines
Fixes 7b0cf70135d1 ("net/i40e: support ARM platform")
#11 lore raw

Re: [dpdk-dev] [dpdk-stable] [PATCH v2 2/2] net/i40e: fix risk in Rx descriptor read in scalar path

Quoted 21 lines · Honnappa Nagarahalli

<snip>

Quoted 15 lines · Ruifeng Wang
Quoted 13 lines

Rx descriptor is 16B/32B in size. If the DD bit is set, it indicates that the rest of the descriptor words have valid values. Hence, the word containing DD bit must be read first before reading the rest of the descriptor words.

Since the entire descriptor is not read atomically, on relaxed memory ordered systems like Aarch64, read of the word containing DD field could be reordered after read of other words.

Read barrier is inserted between read of the word with DD field and read of other words. The barrier ensures that the fetched data is correct.

Quoted 5 lines
Quoted 3 lines

Testpmd single core test showed no performance drop on x86 or N1SDP. On ThunderX2, 22% performance regression was observed.

Is 22% performance drop value correct? That is a big drop, is it acceptable?

Quoted 8 lines

Agree, it is a big drop. Fixing it will require using the barrier less frequently. For ex: read 4 descriptors (4 words containing the DD bits) before using the barrier.

Quoted 3 lines

Is this performance drop valid for all Arm scalar datapath, or is it specific to ThunderX2?

This is specific to ThunderX2. N1 CPU does not see any impact. A72 is not tested. Considering that the ThunderXx line of CPUs are not in further development, and it is scalar path, I would not suggest to make further changes to the code.

It would be good to test this on Kunpeng servers and get some feedback.

Hi Connor, Yisen, Lijun,

Can you please check this patch? I don't know if you are using i40e nic on your platform but if you do can you please test it?

Overall this patch cause a big performance drop on Arm for i40e, I just want to be sure this is not impacting any user negatively.

Quoted 8 lines
Quoted 7 lines
Quoted 7 lines
Fixes 7b0cf70135d1 ("net/i40e: support ARM platform")
#12 lore raw

Re: [dpdk-dev] [dpdk-stable] [PATCH v2 2/2] net/i40e: fix risk in Rx descriptor read in scalar path

Quoted 52 lines

-----Original Message-----
From: Yigit, Ferruh <[email protected]>
Sent: Tuesday, October 12, 2021 12:27 AM
To: Honnappa Nagarahalli <[email protected]>; Ruifeng Wang <[email protected]>; [email protected]; Min Hu (Connor) <[email protected]>; Yisen Zhuang <[email protected]>; Lijun Ou <[email protected]>
Cc: Xing, Beilei <[email protected]>; Zhang, Qi Z <[email protected]>; Richardson, Bruce <[email protected]>; [email protected]; [email protected]; [email protected]; [email protected]; nd <[email protected]>; [email protected]
Subject: Re: [dpdk-stable] [PATCH v2 2/2] net/i40e: fix risk in Rx descriptor read in scalar path

Quoted 16 lines · Honnappa Nagarahalli

<snip>

Quoted 15 lines · Ruifeng Wang
Quoted 13 lines

Rx descriptor is 16B/32B in size. If the DD bit is set, it indicates that the rest of the descriptor words have valid values. Hence, the word containing DD bit must be read first before reading the rest of the descriptor words.

Since the entire descriptor is not read atomically, on relaxed memory ordered systems like Aarch64, read of the word containing DD field could be reordered after read of other words.

Read barrier is inserted between read of the word with DD field and read of other words. The barrier ensures that the fetched data is correct.

Quoted 6 lines
Quoted 5 lines
Quoted 3 lines

Testpmd single core test showed no performance drop on x86 or N1SDP. On ThunderX2, 22% performance regression was observed.

Is 22% performance drop value correct? That is a big drop, is it acceptable?

Agree, it is a big drop. Fixing it will require using the barrier less frequently.

For ex: read 4 descriptors (4 words containing the DD bits) before using the barrier.

Quoted 5 lines
Quoted 4 lines

Is this performance drop valid for all Arm scalar datapath, or is it specific to ThunderX2?

This is specific to ThunderX2. N1 CPU does not see any impact. A72 is not

tested. Considering that the ThunderXx line of CPUs are not in further development, and it is scalar path, I would not suggest to make further changes to the code.

Quoted 2 lines

It would be good to test this on Kunpeng servers and get some feedback.

Quoted 7 lines

Hi Connor, Yisen, Lijun,

Can you please check this patch? I don't know if you are using i40e nic on your platform but if you do can you please test it?

Overall this patch cause a big performance drop on Arm for i40e, I just want to be sure this is not impacting any user negatively.

Folks:
This patch has been dropped from dpdk-next-net-intel, as still waiting for your confirm. Btw Patch 1/2 was still in dpdk-next-net-intel.
Thanks
Qi

Quoted 9 lines
Quoted 9 lines
Quoted 8 lines
Quoted 8 lines
Fixes 7b0cf70135d1 ("net/i40e: support ARM platform")
#13 lore raw

Re: [dpdk-dev] [dpdk-stable] [PATCH v2 2/2] net/i40e: fix risk in Rx descriptor read in scalar path

Quoted 81 lines

-----Original Message-----
From: Zhang, Qi Z <[email protected]>
Sent: Tuesday, October 19, 2021 7:15 PM
To: Yigit, Ferruh <[email protected]>; Honnappa Nagarahalli <[email protected]>; Ruifeng Wang <[email protected]>; [email protected]; Min Hu (Connor) <[email protected]>; Yisen Zhuang <[email protected]>; Lijun Ou <[email protected]>
Cc: Xing, Beilei <[email protected]>; Richardson, Bruce <[email protected]>; [email protected]; [email protected]; [email protected]; [email protected]; nd <[email protected]>; [email protected]
Subject: RE: [dpdk-stable] [PATCH v2 2/2] net/i40e: fix risk in Rx descriptor read in scalar path

Quoted 4 lines

-----Original Message-----
From: Yigit, Ferruh <[email protected]>
Sent: Tuesday, October 12, 2021 12:27 AM
To: Honnappa Nagarahalli <[email protected]>; Ruifeng

Wang

Quoted 2 lines

<[email protected]>; [email protected]; Min Hu (Connor) <[email protected]>; Yisen Zhuang <[email protected]>;

Lijun Ou

Quoted 9 lines

<[email protected]>
Cc: Xing, Beilei <[email protected]>; Zhang, Qi Z <[email protected]>; Richardson, Bruce <[email protected]>; [email protected]; [email protected]; [email protected]; [email protected]; nd <[email protected]>; [email protected]
Subject: Re: [dpdk-stable] [PATCH v2 2/2] net/i40e: fix risk in Rx descriptor read in scalar path

Quoted 18 lines
Quoted 17 lines · Honnappa Nagarahalli

<snip>

Quoted 16 lines · Ruifeng Wang
Quoted 14 lines

Rx descriptor is 16B/32B in size. If the DD bit is set, it indicates that the rest of the descriptor words have valid values. Hence, the word containing DD bit must be read first before reading the rest of the descriptor words.

Since the entire descriptor is not read atomically, on relaxed memory ordered systems like Aarch64, read of the word containing DD field could be reordered after read of other words.

Read barrier is inserted between read of the word with DD field and read of other words. The barrier ensures that the fetched data is correct.

Testpmd single core test showed no performance drop on x86 or

N1SDP.

Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 2 lines

On ThunderX2, 22% performance regression was observed.

Is 22% performance drop value correct? That is a big drop, is it

acceptable?

Quoted 15 lines
Quoted 1 line

Agree, it is a big drop. Fixing it will require using the barrier less frequently.

For ex: read 4 descriptors (4 words containing the DD bits) before using the barrier.

Quoted 6 lines
Quoted 4 lines

Is this performance drop valid for all Arm scalar datapath, or is it specific to ThunderX2?

This is specific to ThunderX2. N1 CPU does not see any impact. A72 is not

tested. Considering that the ThunderXx line of CPUs are not in further development, and it is scalar path, I would not suggest to make further changes to the code.

Quoted 2 lines

It would be good to test this on Kunpeng servers and get some feedback.

Quoted 7 lines

Hi Connor, Yisen, Lijun,

Can you please check this patch? I don't know if you are using i40e nic on your platform but if you do can you please test it?

Overall this patch cause a big performance drop on Arm for i40e, I just want to be sure this is not impacting any user negatively.

Quoted 7 lines

Folks:
This patch has been dropped from dpdk-next-net-intel, as still
waiting for your confirm.
Btw Patch 1/2 was still in dpdk-next-net-intel.
Thanks
Qi

Hi Qi, Ferruh,

Do you have any suggestion on how to progress this patch?
It is fixing possible violation of hardware access from architecture point of view. Negative performance impact may happen because barriers are added.
I don't think we received objections until now.

Thanks,
Ruifeng

Quoted 9 lines
Quoted 9 lines
Quoted 9 lines
Quoted 8 lines
Quoted 8 lines
Fixes 7b0cf70135d1 ("net/i40e: support ARM platform")
#14 lore raw

RE: [dpdk-stable] [PATCH v2 2/2] net/i40e: fix risk in Rx descriptor read in scalar path

Hi Ferruh,

Quoted 50 lines
Quoted 4 lines
Quoted 4 lines

-----Original Message-----
From: Yigit, Ferruh <[email protected]>
Sent: Tuesday, October 12, 2021 12:27 AM
To: Honnappa Nagarahalli <[email protected]>; Ruifeng

Quoted 9 lines

Wang

Quoted 2 lines

<[email protected]>; [email protected]; Min Hu (Connor) <[email protected]>; Yisen Zhuang <[email protected]>;

Lijun Ou

Quoted 5 lines

<[email protected]>
Cc: Xing, Beilei <[email protected]>; Zhang, Qi Z <[email protected]>; Richardson, Bruce <[email protected]>; [email protected]; [email protected]; [email protected]; [email protected];

nd

Quoted 21 lines
Quoted 21 lines

<[email protected]>; [email protected]
Subject: Re: [dpdk-stable] [PATCH v2 2/2] net/i40e: fix risk in Rx descriptor read in scalar path

Quoted 16 lines · Honnappa Nagarahalli

<snip>

Quoted 15 lines · Ruifeng Wang
Quoted 13 lines

Rx descriptor is 16B/32B in size. If the DD bit is set, it indicates that the rest of the descriptor words have valid values. Hence, the word containing DD bit must be read first before reading the rest of the descriptor words.

Since the entire descriptor is not read atomically, on relaxed memory ordered systems like Aarch64, read of the word containing DD field could be reordered after read of other words.

Read barrier is inserted between read of the word with DD field and read of other words. The barrier ensures that the fetched data is correct.

Quoted 8 lines
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line

Testpmd single core test showed no performance drop on x86 or

N1SDP.

Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 2 lines

On ThunderX2, 22% performance regression was observed.

Is 22% performance drop value correct? That is a big drop, is it

acceptable?

Quoted 1 line
Quoted 1 line

Agree, it is a big drop. Fixing it will require using the barrier less

frequently.

Quoted 6 lines
Quoted 6 lines

For ex: read 4 descriptors (4 words containing the DD bits) before using the barrier.

Quoted 4 lines
Quoted 4 lines

Is this performance drop valid for all Arm scalar datapath, or is it specific to ThunderX2?

Quoted 16 lines
Quoted 7 lines
Quoted 7 lines
Quoted 2 lines

This is specific to ThunderX2. N1 CPU does not see any impact. A72 is not

tested. Considering that the ThunderXx line of CPUs are not in further development, and it is scalar path, I would not suggest to make further changes to the code.

Quoted 2 lines

It would be good to test this on Kunpeng servers and get some

feedback.

Quoted 8 lines
Quoted 8 lines

Hi Connor, Yisen, Lijun,

Can you please check this patch? I don't know if you are using i40e nic on your platform but if you do can you please test it?

Overall this patch cause a big performance drop on Arm for i40e, I just want to be sure this is not impacting any user negatively.

I cannot speak for vendors. But my test on a Huawei aarch64 server showed no performance drop. NIC in use is XXV710.
Just FYI.

Thanks,
Ruifeng

Quoted 28 lines
Quoted 8 lines

Folks:
This patch has been dropped from dpdk-next-net-intel, as still
waiting for your confirm.
Btw Patch 1/2 was still in dpdk-next-net-intel.
Thanks
Qi

Hi Qi, Ferruh,

Do you have any suggestion on how to progress this patch?
It is fixing possible violation of hardware access from architecture point of view.
Negative performance impact may happen because barriers are added. I don't think we received objections until now.

Thanks,
Ruifeng

Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Fixes 7b0cf70135d1 ("net/i40e: support ARM platform")
Reviewed-by Honnappa Nagarahalli

<[email protected]>

Quoted 1 line
Quoted 1 line
Quoted 1 line
Applied
#15 lore raw

RE: [PATCH v2 2/2] net/i40e: fix risk in Rx descriptor read in scalar path

In reply to Ruifeng Wang
Quoted 68 lines

-----Original Message-----
From: Ruifeng Wang <[email protected]>
Sent: Wednesday, September 15, 2021 4:34 PM
To: [email protected]
Cc: Xing, Beilei <[email protected]>; Zhang, Qi Z <[email protected]>; Richardson, Bruce <[email protected]>; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; Ruifeng Wang <[email protected]>
Subject: [PATCH v2 2/2] net/i40e: fix risk in Rx descriptor read in scalar path

Rx descriptor is 16B/32B in size. If the DD bit is set, it indicates that the rest of the descriptor words have valid values. Hence, the word containing DD bit must be read first before reading the rest of the descriptor words.

Since the entire descriptor is not read atomically, on relaxed memory ordered systems like Aarch64, read of the word containing DD field could be reordered after read of other words.

Read barrier is inserted between read of the word with DD field and read of other words. The barrier ensures that the fetched data is correct.

Testpmd single core test showed no performance drop on x86 or N1SDP. On ThunderX2, 22% performance regression was observed.

Fixes 7b0cf70135d1 ("net/i40e: support ARM platform")
---
 drivers/net/i40e/i40e_rxtx.c | 12 ++++++++++++
 1 file changed, 12 insertions(+)
drivers/net/i40e/i40e_rxtx.c index renamed from drivers/net/i40e/i40e_rxtx.c +0 -0

8329cbdd4e..c4cd6b6b60 100644

drivers/net/i40e/i40e_rxtx.c +6 -0
@@ -746,6 +746,12 @@ i40e_recv_pkts(void *rx_queue, struct rte_mbuf
 **rx_pkts, uint16_t nb_pkts)
 			break;
 		}
 
+		/**
+		 * Use acquire fence to ensure that qword1 which includes DD
+		 * bit is loaded before loading of other descriptor words.
+		 */
+		rte_atomic_thread_fence(__ATOMIC_ACQUIRE);
+
 		rxd = *rxdp;
 		nb_hold++;
drivers/net/i40e/i40e_rxtx.c +6 -1
 		rxe = &sw_ring[rx_id];
@@ -862,6 +868,12 @@ i40e_recv_scattered_pkts(void *rx_queue,
 			break;
 		}
 
+		/**
+		 * Use acquire fence to ensure that qword1 which includes DD
+		 * bit is loaded before loading of other descriptor words.
+		 */
+		rte_atomic_thread_fence(__ATOMIC_ACQUIRE);
+
 		rxd = *rxdp;
 		nb_hold++;
 		rxe = &sw_ring[rx_id];
--
Quoted 1 line

2.25.1

Applied to dpdk-next-net-intel.

Thanks
Qi

Applied
#16 lore raw
In reply to Ruifeng Wang
Quoted 31 lines

-----Original Message-----
From: Ruifeng Wang <[email protected]>
Sent: Wednesday, September 15, 2021 4:34 PM
To: [email protected]
Cc: Xing, Beilei <[email protected]>; Zhang, Qi Z <[email protected]>; Richardson, Bruce <[email protected]>; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; Ruifeng Wang <[email protected]>
Subject: [PATCH v2 0/2] i40e Rx descriptor loads ordering

On Rx path, NIC fills Rx descriptor with data pertains to received packet.

A single descriptor consists of multiple words. Word1 has the bit that indicates readiness of descriptor for software to use. So word1 should be loaded before other words.

On architectures with weaker memory ordering, barrier is needed to ensure the ordering of loads.

This patch set fixed the risk on both scalar path and aarch64 vector path.

v2:
Updated commit message. Performance impact added. (Honnappa)

Ruifeng Wang (2):
net/i40e: fix risk in Rx descriptor read in NEON vector path net/i40e: fix risk in Rx descriptor read in scalar path

Quoted 6 lines
 drivers/net/i40e/i40e_rxtx.c          | 12 ++++++++++++
 drivers/net/i40e/i40e_rxtx_vec_neon.c |  8 ++++++++
 2 files changed, 20 insertions(+)

--
2.25.1

Applied to dpdk-next-net-intel.

Thanks
Qi