Skip to contentSkip to conversation

app/test-crypto-perf: fix invalid mbuf next operation

PATCH Superseded Suanming Mou 4 participants 9 messages Jan 3, 2024 – Feb 1, 2024

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 app/test-crypto-perf: fix invalid mbuf next operation

In fill_multi_seg_mbuf(), when remaining_segments is 0, rte_mbuf m's next should pointer to NULL instead of a new rte_mbuf, that casues setting m->next as NULL out of the while loop to the invalid mbuf.

This commit fixes the invalid mbuf next operation.

Fixes bf9d6702eca9 ("app/crypto-perf: use single mempool")
---
 app/test-crypto-perf/cperf_test_common.c | 12 +++++++-----
 1 file changed, 7 insertions(+), 5 deletions(-)
app/test-crypto-perf/cperf_test_common.c +7 -5
index 932aab16df..ad2076dd2e 100644
@@ -72,13 +72,15 @@ fill_multi_seg_mbuf(struct rte_mbuf *m, struct rte_mempool *mp,
 		rte_mbuf_refcnt_set(m, 1);
 		next_mbuf = (struct rte_mbuf *) ((uint8_t *) m +
 					mbuf_hdr_size + segment_sz);
-		m->next = next_mbuf;
-		m = next_mbuf;
-		remaining_segments--;
 
+		remaining_segments--;
+		if (remaining_segments > 0) {
+			m->next = next_mbuf;
+			m = next_mbuf;
+		} else {
+			m->next = NULL;
+		}
 	} while (remaining_segments > 0);
-
-	m->next = NULL;
 }
 
 static void
Signature · 1 line
2.34.1
#1 lore raw

Hi Suanming,

Good catch. Please see inline.

Thanks,
Anoob

Quoted 29 lines

-----Original Message-----
From: Suanming Mou <[email protected]>
Sent: Wednesday, January 3, 2024 9:24 AM
To: Ciara Power <[email protected]>
Cc: [email protected]
Subject: [EXT] [PATCH] app/test-crypto-perf: fix invalid mbuf next operation

External Email

----------------------------------------------------------------------
In fill_multi_seg_mbuf(), when remaining_segments is 0, rte_mbuf m's next should pointer to NULL instead of a new rte_mbuf, that casues setting m->next as NULL out of the while loop to the invalid mbuf.

This commit fixes the invalid mbuf next operation.

Fixes bf9d6702eca9 ("app/crypto-perf: use single mempool")
---
 app/test-crypto-perf/cperf_test_common.c | 12 +++++++-----
 1 file changed, 7 insertions(+), 5 deletions(-)
app/test-crypto- renamed from app/test-crypto-perf/cperf_test_common.c +0 -0

perf/cperf_test_common.c
index 932aab16df..ad2076dd2e 100644

app/test-crypto-perf/cperf_test_common.c fill_multi_seg_mbuf(struct rte_mbuf *m, struct · line 78

Quoted 10 lines
app/test-crypto-perf/cperf_test_common.c +2 -3
@@ -72,13 +72,15 @@ fill_multi_seg_mbuf(struct rte_mbuf *m, struct
 rte_mempool *mp,
 		rte_mbuf_refcnt_set(m, 1);
 		next_mbuf = (struct rte_mbuf *) ((uint8_t *) m +
 					mbuf_hdr_size + segment_sz);
-		m->next = next_mbuf;
-		m = next_mbuf;
-		remaining_segments--;
 
+		remaining_segments--;
+		if (remaining_segments > 0) {

[Anoob] Would it make sense to move assignment of next_mbuf also to here? That way, the checks will become self explanatory.
next_mbuf = (struct rte_mbuf *) ((uint8_t *) m +
mbuf_hdr_size + segment_sz);

Quoted 13 lines
app/test-crypto-perf/cperf_test_common.c +5 -2
+			m->next = next_mbuf;
+			m = next_mbuf;
+		} else {
+			m->next = NULL;
+		}
 	} while (remaining_segments > 0);
-
-	m->next = NULL;
 }
 

static void
--
2.34.1

#2 lore raw

Hi,

Quoted 52 lines

-----Original Message-----
From: Anoob Joseph <[email protected]>
Sent: Wednesday, January 3, 2024 7:22 PM
To: Suanming Mou <[email protected]>
Cc: [email protected]; Ciara Power <[email protected]>
Subject: RE: [EXT] [PATCH] app/test-crypto-perf: fix invalid mbuf next operation

Hi Suanming,

Good catch. Please see inline.

Thanks,
Anoob

Quoted 38 lines

-----Original Message-----
From: Suanming Mou <[email protected]>
Sent: Wednesday, January 3, 2024 9:24 AM
To: Ciara Power <[email protected]>
Cc: [email protected]
Subject: [EXT] [PATCH] app/test-crypto-perf: fix invalid mbuf next operation

External Email

----------------------------------------------------------------------
In fill_multi_seg_mbuf(), when remaining_segments is 0, rte_mbuf m's next should pointer to NULL instead of a new rte_mbuf, that casues setting m->next as NULL out of the while loop to the invalid mbuf.

This commit fixes the invalid mbuf next operation.

Fixes bf9d6702eca9 ("app/crypto-perf: use single mempool")
---
 app/test-crypto-perf/cperf_test_common.c | 12 +++++++-----
 1 file changed, 7 insertions(+), 5 deletions(-)
(quoted diff) +0 -0

b/app/test-crypto- perf/cperf_test_common.c index
932aab16df..ad2076dd2e 100644

app/test-crypto-perf/cperf_test_common.c +0 -3
@@ -72,13 +72,15 @@ fill_multi_seg_mbuf(struct rte_mbuf *m, struct
 rte_mempool *mp,
 		rte_mbuf_refcnt_set(m, 1);
 		next_mbuf = (struct rte_mbuf *) ((uint8_t *) m +
 					mbuf_hdr_size + segment_sz);
-		m->next = next_mbuf;
-		m = next_mbuf;
-		remaining_segments--;
 
Quoted 8 lines

app/test-crypto-perf/cperf_test_common.c fill_multi_seg_mbuf(struct rte_mbuf *m, struct rte_mempool *mp, · line 77

Quoted 2 lines
app/test-crypto-perf/cperf_test_common.c +2 -0
+		remaining_segments--;
+		if (remaining_segments > 0) {

[Anoob] Would it make sense to move assignment of next_mbuf also to here? That way, the checks will become self explanatory.
next_mbuf = (struct rte_mbuf *) ((uint8_t *) m +
mbuf_hdr_size + segment_sz);

Make sense. Maybe just like that:
m->next = (struct rte_mbuf *) ((uint8_t *) m +

  					mbuf_hdr_size + segment_sz);
		m = m->next;

What do you think?

Quoted 13 lines
Quoted 13 lines
app/test-crypto-perf/cperf_test_common.c +5 -2
+			m->next = next_mbuf;
+			m = next_mbuf;
+		} else {
+			m->next = NULL;
+		}
 	} while (remaining_segments > 0);
-
-	m->next = NULL;
 }
 

static void
--
2.34.1

#3 lore raw

Hi Suanming,

Please see inline.

Thanks,
Anoob

Quoted 72 lines

-----Original Message-----
From: Suanming Mou <[email protected]>
Sent: Wednesday, January 3, 2024 6:06 PM
To: Anoob Joseph <[email protected]>
Cc: [email protected]; Ciara Power <[email protected]>
Subject: RE: [EXT] [PATCH] app/test-crypto-perf: fix invalid mbuf next operation

Hi,

Quoted 54 lines

-----Original Message-----
From: Anoob Joseph <[email protected]>
Sent: Wednesday, January 3, 2024 7:22 PM
To: Suanming Mou <[email protected]>
Cc: [email protected]; Ciara Power <[email protected]>
Subject: RE: [EXT] [PATCH] app/test-crypto-perf: fix invalid mbuf next operation

Hi Suanming,

Good catch. Please see inline.

Thanks,
Anoob

Quoted 39 lines

-----Original Message-----
From: Suanming Mou <[email protected]>
Sent: Wednesday, January 3, 2024 9:24 AM
To: Ciara Power <[email protected]>
Cc: [email protected]
Subject: [EXT] [PATCH] app/test-crypto-perf: fix invalid mbuf next operation

External Email

--------------------------------------------------------------------
-- In fill_multi_seg_mbuf(), when remaining_segments is 0, rte_mbuf m's next should pointer to NULL instead of a new rte_mbuf, that casues setting m->next as NULL out of the while loop to the invalid mbuf.

This commit fixes the invalid mbuf next operation.

Fixes bf9d6702eca9 ("app/crypto-perf: use single mempool")
---
 app/test-crypto-perf/cperf_test_common.c | 12 +++++++-----
 1 file changed, 7 insertions(+), 5 deletions(-)
(quoted diff) +0 -0

b/app/test-crypto- perf/cperf_test_common.c index
932aab16df..ad2076dd2e 100644

app/test-crypto-perf/cperf_test_common.c +0 -3
@@ -72,13 +72,15 @@ fill_multi_seg_mbuf(struct rte_mbuf *m, struct
 rte_mempool *mp,
 		rte_mbuf_refcnt_set(m, 1);
 		next_mbuf = (struct rte_mbuf *) ((uint8_t *) m +
 					mbuf_hdr_size + segment_sz);
-		m->next = next_mbuf;
-		m = next_mbuf;
-		remaining_segments--;
 
Quoted 8 lines

app/test-crypto-perf/cperf_test_common.c fill_multi_seg_mbuf(struct rte_mbuf *m, struct rte_mempool *mp, · line 77

Quoted 2 lines
app/test-crypto-perf/cperf_test_common.c +2 -0
+		remaining_segments--;
+		if (remaining_segments > 0) {

[Anoob] Would it make sense to move assignment of next_mbuf also to here? That way, the checks will become self explanatory.
next_mbuf = (struct rte_mbuf *) ((uint8_t *) m +
mbuf_hdr_size + segment_sz);

Quoted 6 lines

Make sense. Maybe just like that:
m->next = (struct rte_mbuf *) ((uint8_t *) m +

  					mbuf_hdr_size + segment_sz);
		m = m->next;

What do you think?

[Anoob] Yes. That's even better.

I think we can have line lengths upto 100 characters now. In case you find it easier to put in single line.

Quoted 14 lines
Quoted 14 lines
Quoted 14 lines
app/test-crypto-perf/cperf_test_common.c +5 -2
+			m->next = next_mbuf;
+			m = next_mbuf;
+		} else {
+			m->next = NULL;
+		}
 	} while (remaining_segments > 0);
-
-	m->next = NULL;
 }
 

static void
--
2.34.1

#4 lore raw
Quoted 95 lines

-----Original Message-----
From: Anoob Joseph <[email protected]>
Sent: Wednesday, January 3, 2024 11:43 PM
To: Suanming Mou <[email protected]>
Cc: [email protected]; Ciara Power <[email protected]>
Subject: RE: [EXT] [PATCH] app/test-crypto-perf: fix invalid mbuf next operation

Hi Suanming,

Please see inline.

Thanks,
Anoob

Quoted 79 lines

-----Original Message-----
From: Suanming Mou <[email protected]>
Sent: Wednesday, January 3, 2024 6:06 PM
To: Anoob Joseph <[email protected]>
Cc: [email protected]; Ciara Power <[email protected]>
Subject: RE: [EXT] [PATCH] app/test-crypto-perf: fix invalid mbuf next operation

Hi,

Quoted 55 lines

-----Original Message-----
From: Anoob Joseph <[email protected]>
Sent: Wednesday, January 3, 2024 7:22 PM
To: Suanming Mou <[email protected]>
Cc: [email protected]; Ciara Power <[email protected]>
Subject: RE: [EXT] [PATCH] app/test-crypto-perf: fix invalid mbuf next operation

Hi Suanming,

Good catch. Please see inline.

Thanks,
Anoob

Quoted 40 lines

-----Original Message-----
From: Suanming Mou <[email protected]>
Sent: Wednesday, January 3, 2024 9:24 AM
To: Ciara Power <[email protected]>
Cc: [email protected]
Subject: [EXT] [PATCH] app/test-crypto-perf: fix invalid mbuf next operation

External Email

------------------------------------------------------------------
--
-- In fill_multi_seg_mbuf(), when remaining_segments is 0, rte_mbuf m's next should pointer to NULL instead of a new rte_mbuf, that casues setting m->next as NULL out of the while loop to the invalid mbuf.

This commit fixes the invalid mbuf next operation.

Fixes bf9d6702eca9 ("app/crypto-perf: use single mempool")
---
 app/test-crypto-perf/cperf_test_common.c | 12 +++++++-----
 1 file changed, 7 insertions(+), 5 deletions(-)
(quoted diff) +0 -0

b/app/test-crypto- perf/cperf_test_common.c index
932aab16df..ad2076dd2e 100644

app/test-crypto-perf/cperf_test_common.c +0 -3
@@ -72,13 +72,15 @@ fill_multi_seg_mbuf(struct rte_mbuf *m, struct
 rte_mempool *mp,
 		rte_mbuf_refcnt_set(m, 1);
 		next_mbuf = (struct rte_mbuf *) ((uint8_t *) m +
 					mbuf_hdr_size + segment_sz);
-		m->next = next_mbuf;
-		m = next_mbuf;
-		remaining_segments--;
 
Quoted 8 lines

app/test-crypto-perf/cperf_test_common.c fill_multi_seg_mbuf(struct rte_mbuf *m, struct rte_mempool *mp, · line 77

Quoted 2 lines
app/test-crypto-perf/cperf_test_common.c +2 -0
+		remaining_segments--;
+		if (remaining_segments > 0) {

[Anoob] Would it make sense to move assignment of next_mbuf also to here? That way, the checks will become self explanatory.
next_mbuf = (struct rte_mbuf *) ((uint8_t *) m +
mbuf_hdr_size + segment_sz);

Make sense. Maybe just like that:
m->next = (struct rte_mbuf *) ((uint8_t *) m +

  					mbuf_hdr_size + segment_sz);
		m = m->next;
Quoted 6 lines
Quoted 1 line

What do you think?

[Anoob] Yes. That's even better.

I think we can have line lengths upto 100 characters now. In case you find it easier to put in single line.

OK, thanks for the suggestion.

Quoted 15 lines
Quoted 15 lines
Quoted 15 lines
Quoted 15 lines
app/test-crypto-perf/cperf_test_common.c +5 -2
+			m->next = next_mbuf;
+			m = next_mbuf;
+		} else {
+			m->next = NULL;
+		}
 	} while (remaining_segments > 0);
-
-	m->next = NULL;
 }
 

static void
--
2.34.1

#5 lore raw

PATCH v2 1/1 app/test-crypto-perf: fix invalid mbuf next operation

In reply to Suanming Mou

In fill_multi_seg_mbuf(), when remaining_segments is 0, rte_mbuf m's next should pointer to NULL instead of a new rte_mbuf, that causes setting m->next as NULL out of the while loop to the invalid mbuf.

This commit fixes the invalid mbuf next operation.

Fixes bf9d6702eca9 ("app/crypto-perf: use single mempool")

---

v2: move next_mbuf inside remaining_segments check.

---
 app/test-crypto-perf/cperf_test_common.c | 15 +++++++--------
 1 file changed, 7 insertions(+), 8 deletions(-)
app/test-crypto-perf/cperf_test_common.c +7 -8
index 932aab16df..b3bf9f67e8 100644
@@ -49,7 +49,6 @@ fill_multi_seg_mbuf(struct rte_mbuf *m, struct rte_mempool *mp,
 {
 	uint16_t mbuf_hdr_size = sizeof(struct rte_mbuf);
 	uint16_t remaining_segments = segments_nb;
-	struct rte_mbuf *next_mbuf;
 	rte_iova_t next_seg_phys_addr = rte_mempool_virt2iova(obj) +
 			 mbuf_offset + mbuf_hdr_size;
 
@@ -70,15 +69,15 @@ fill_multi_seg_mbuf(struct rte_mbuf *m, struct rte_mempool *mp,
 		m->nb_segs = segments_nb;
 		m->port = 0xff;
 		rte_mbuf_refcnt_set(m, 1);
-		next_mbuf = (struct rte_mbuf *) ((uint8_t *) m +
-					mbuf_hdr_size + segment_sz);
-		m->next = next_mbuf;
-		m = next_mbuf;
-		remaining_segments--;
 
+		remaining_segments--;
+		if (remaining_segments > 0) {
+			m->next = (struct rte_mbuf *)((uint8_t *) m + mbuf_hdr_size + segment_sz);
+			m = m->next;
+		} else {
+			m->next = NULL;
+		}
 	} while (remaining_segments > 0);
-
-	m->next = NULL;
 }
 
 static void
Signature · 1 line
2.34.1
Acked-by on v2 1/1
#6 lore raw
Quoted 9 lines

In fill_multi_seg_mbuf(), when remaining_segments is 0, rte_mbuf m's next should pointer to NULL instead of a new rte_mbuf, that causes setting m->next as NULL out of the while loop to the invalid mbuf.

This commit fixes the invalid mbuf next operation.

Fixes bf9d6702eca9 ("app/crypto-perf: use single mempool")
Acked-by on v2 1/1
#7 lore raw
In reply to Suanming Mou
Quoted 17 lines

-----Original Message-----
From: Suanming Mou <[email protected]>
Sent: Thursday, January 4, 2024 2:24 AM
To: [email protected]; Power, Ciara <[email protected]>
Cc: [email protected]
Subject: [PATCH v2] app/test-crypto-perf: fix invalid mbuf next operation

In fill_multi_seg_mbuf(), when remaining_segments is 0, rte_mbuf m's next should pointer to NULL instead of a new rte_mbuf, that causes setting m-

Quoted 1 line

next as NULL out of the while loop to the invalid mbuf.

This commit fixes the invalid mbuf next operation.

Fixes bf9d6702eca9 ("app/crypto-perf: use single mempool")
Quoted 9 lines

---

v2: move next_mbuf inside remaining_segments check.

---
 app/test-crypto-perf/cperf_test_common.c | 15 +++++++--------
 1 file changed, 7 insertions(+), 8 deletions(-)
#8 lore raw
In reply to Suanming Mou
Quoted 10 lines

In fill_multi_seg_mbuf(), when remaining_segments is 0, rte_mbuf m's next should pointer to NULL instead of a new rte_mbuf, that causes setting m->next as NULL out of the while loop to the invalid mbuf.

This commit fixes the invalid mbuf next operation.

Fixes bf9d6702eca9 ("app/crypto-perf: use single mempool")

Cc: [email protected]
Applied to dpdk-next-crypto
Thanks.