app/regex: fix mbuf size for multi segemnt buffers

Message ID 20220705080917.13784-1-rasland@nvidia.com (mailing list archive)
State Accepted, archived
Delegated to: Thomas Monjalon
Headers
Series app/regex: fix mbuf size for multi segemnt buffers |

Checks

Context Check Description
ci/checkpatch success coding style OK
ci/Intel-compilation success Compilation OK
ci/intel-Testing success Testing PASS
ci/github-robot: build success github build: passed
ci/iol-aarch64-unit-testing success Testing PASS
ci/iol-intel-Performance success Performance Testing PASS
ci/iol-intel-Functional success Functional Testing PASS
ci/iol-aarch64-compile-testing success Testing PASS
ci/iol-x86_64-compile-testing success Testing PASS
ci/iol-x86_64-unit-testing success Testing PASS
ci/iol-abi-testing success Testing PASS

Commit Message

Raslan Darawsheh July 5, 2022, 8:09 a.m. UTC
  When allocating multi segmented buffers, and in case there is
a remainder in total buf len, the actual job len might be more
than expected job_len.

This adds additional space in the mbuf in the multi seg case,
to allow the remaining memory to be stored in one segment.

Fixes: c1d1b94eec58 ("app/regex: fix number of matches")
Cc: ggribbon@nvidia.com
Cc: stable@dpdk.org

Signed-off-by: Raslan Darawsheh <rasland@nvidia.com>
Acked-by: Ori Kam <orika@nvidia.com>
---
 app/test-regex/main.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
  

Comments

Thomas Monjalon July 5, 2022, 8:20 p.m. UTC | #1
05/07/2022 10:09, Raslan Darawsheh:
> When allocating multi segmented buffers, and in case there is
> a remainder in total buf len, the actual job len might be more
> than expected job_len.
> 
> This adds additional space in the mbuf in the multi seg case,
> to allow the remaining memory to be stored in one segment.
> 
> Fixes: c1d1b94eec58 ("app/regex: fix number of matches")
> Cc: ggribbon@nvidia.com
> Cc: stable@dpdk.org
> 
> Signed-off-by: Raslan Darawsheh <rasland@nvidia.com>
> Acked-by: Ori Kam <orika@nvidia.com>

Applied (with fixed typo in title), thanks.
  

Patch

diff --git a/app/test-regex/main.c b/app/test-regex/main.c
index 7c014b2210..db6a315abe 100644
--- a/app/test-regex/main.c
+++ b/app/test-regex/main.c
@@ -412,8 +412,8 @@  run_regex(void *args)
 	mbuf_mp = rte_pktmbuf_pool_create(mbuf_pool,
 			rte_align32pow2(nb_jobs * nb_qps * nb_segs),
 			0, 0, (nb_segs == 1) ? MBUF_SIZE :
-			(rte_align32pow2(job_len) / nb_segs +
-			RTE_PKTMBUF_HEADROOM),
+			(rte_align32pow2(job_len + (data_len % nb_jobs)) /
+			 nb_segs + RTE_PKTMBUF_HEADROOM),
 			rte_socket_id());
 	if (mbuf_mp == NULL) {
 		printf("Error, can't create memory pool\n");