app/regex: fix mbuf size for multi-segment buffer
authorRaslan Darawsheh <rasland@nvidia.com>
Tue, 5 Jul 2022 08:09:16 +0000 (11:09 +0300)
committerThomas Monjalon <thomas@monjalon.net>
Tue, 5 Jul 2022 20:19:03 +0000 (22:19 +0200)
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: stable@dpdk.org
Signed-off-by: Raslan Darawsheh <rasland@nvidia.com>
Acked-by: Ori Kam <orika@nvidia.com>
app/test-regex/main.c

index fe90e11..351c36a 100644 (file)
@@ -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");