patches for DPDK stable branches
 help / color / mirror / Atom feed
* [PATCH] app/test-regex: fix incorrect number of matches
@ 2022-03-09 23:41 Gerry Gribbon
  2022-03-14 11:17 ` Thomas Monjalon
  0 siblings, 1 reply; 2+ messages in thread
From: Gerry Gribbon @ 2022-03-09 23:41 UTC (permalink / raw)
  To: orika; +Cc: dev, yuvalav, stable

Depending on number of jobs specified on command line, part of the
data buffer may not get searched, resulting in incorrect number of
matches being reported.

Additional change to ensure the "All Matches" summary outputs the
correct match start locations in the supplied data buffer.

Fixes: de06137cb295 ("app/regex: add RegEx test application")
Cc: yuvalav@mellanox.com
Cc: stable@dpdk.org

Signed-off-by: Gerry Gribbon <ggribbon@nvidia.com>
Acked-by: Ori Kam <orika@nvidia.com>
---
 app/test-regex/main.c | 38 ++++++++++++++++++++++++++++----------
 1 file changed, 28 insertions(+), 10 deletions(-)

diff --git a/app/test-regex/main.c b/app/test-regex/main.c
index ab8a3e56e7..7c014b2210 100644
--- a/app/test-regex/main.c
+++ b/app/test-regex/main.c
@@ -382,10 +382,13 @@ run_regex(void *args)
 	char *data_buf = rgxc->data_buf;
 	long data_len = rgxc->data_len;
 	long job_len = rgxc->job_len;
-
+	long remainder;
+	long act_job_len = 0;
+	bool last_job = false;
 	char *buf = NULL;
 	uint32_t actual_jobs = 0;
 	uint32_t i;
+	uint32_t job_id;
 	uint16_t qp_id;
 	uint16_t dev_id = 0;
 	uint8_t nb_matches;
@@ -456,9 +459,16 @@ run_regex(void *args)
 		/* Assign each mbuf with the data to handle. */
 		actual_jobs = 0;
 		pos = 0;
+		remainder = data_len % nb_jobs;
+
 		/* Allocate the jobs and assign each job with an mbuf. */
 		for (i = 0; (pos < data_len) && (i < nb_jobs) ; i++) {
-			long act_job_len = RTE_MIN(job_len, data_len - pos);
+			act_job_len = RTE_MIN(job_len, data_len - pos);
+
+			if (i == (nb_jobs - 1)) {
+				last_job = true;
+				act_job_len += remainder;
+			}
 
 			ops[i] = rte_malloc(NULL, sizeof(*ops[0]) +
 					nb_max_matches *
@@ -478,7 +488,12 @@ run_regex(void *args)
 				if (ops[i]->mbuf) {
 					rte_pktmbuf_attach_extbuf(ops[i]->mbuf,
 					&buf[pos], 0, act_job_len, &shinfo);
-					ops[i]->mbuf->data_len = job_len;
+
+					if (!last_job)
+						ops[i]->mbuf->data_len = job_len;
+					else
+						ops[i]->mbuf->data_len = act_job_len;
+
 					ops[i]->mbuf->pkt_len = act_job_len;
 				}
 			}
@@ -506,6 +521,9 @@ run_regex(void *args)
 			qp = &qps[qp_id];
 			qp->total_enqueue = 0;
 			qp->total_dequeue = 0;
+			/* Re-set user id after dequeue to match data in mbuf. */
+			for (job_id = 0 ; job_id < nb_jobs; job_id++)
+				qp->ops[job_id]->user_id = job_id;
 		}
 		do {
 			update = false;
@@ -551,10 +569,10 @@ run_regex(void *args)
 	for (qp_id = 0; qp_id < nb_qps; qp_id++) {
 		qp = &qps[qp_id];
 		time = (long double)qp->cycles / rte_get_timer_hz();
-		printf("Core=%u QP=%u Job=%ld Bytes Time=%Lf sec Perf=%Lf "
+		printf("Core=%u QP=%u Job=%ld Bytes Last Job=%ld Bytes Time=%Lf sec Perf=%Lf "
 		       "Gbps\n", rte_lcore_id(), qp_id + qp_id_base,
-		       job_len, time,
-		       (((double)actual_jobs * job_len * nb_iterations * 8)
+		       job_len, act_job_len, time,
+		       (((double)data_len * nb_iterations * 8)
 		       / time) / 1000000000.0);
 	}
 
@@ -587,10 +605,10 @@ run_regex(void *args)
 			qp->total_matches += nb_matches;
 			match = qp->ops[d_ind % actual_jobs]->matches;
 			for (i = 0; i < nb_matches; i++) {
-				printf("start = %ld, len = %d, rule = %d\n",
-						match->start_offset +
-						d_ind * job_len,
-						match->len, match->rule_id);
+				printf("start = %d, len = %d, rule = %d\n",
+					match->start_offset +
+					(int)(qp->ops[d_ind % actual_jobs]->user_id * job_len),
+					match->len, match->rule_id);
 				match++;
 			}
 		}
-- 
2.25.1


^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [PATCH] app/test-regex: fix incorrect number of matches
  2022-03-09 23:41 [PATCH] app/test-regex: fix incorrect number of matches Gerry Gribbon
@ 2022-03-14 11:17 ` Thomas Monjalon
  0 siblings, 0 replies; 2+ messages in thread
From: Thomas Monjalon @ 2022-03-14 11:17 UTC (permalink / raw)
  To: Gerry Gribbon; +Cc: orika, dev, yuvalav, stable

10/03/2022 00:41, Gerry Gribbon:
> Depending on number of jobs specified on command line, part of the
> data buffer may not get searched, resulting in incorrect number of
> matches being reported.
> 
> Additional change to ensure the "All Matches" summary outputs the
> correct match start locations in the supplied data buffer.
> 
> Fixes: de06137cb295 ("app/regex: add RegEx test application")
> Cc: yuvalav@mellanox.com
> Cc: stable@dpdk.org
> 
> Signed-off-by: Gerry Gribbon <ggribbon@nvidia.com>
> Acked-by: Ori Kam <orika@nvidia.com>

Applied, thanks.




^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2022-03-14 11:17 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-03-09 23:41 [PATCH] app/test-regex: fix incorrect number of matches Gerry Gribbon
2022-03-14 11:17 ` Thomas Monjalon

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).