From: Chengwen Feng <fengchengwen@huawei.com>
To: <thomas@monjalon.net>, <honest.jiang@foxmail.com>
Cc: <dev@dpdk.org>, <liuyonglong@huawei.com>, <vattunuru@marvell.com>
Subject: [PATCH v4 12/14] app/dma-perf: fix on-flight DMA when verify data
Date: Mon, 20 Oct 2025 12:11:03 +0800 [thread overview]
Message-ID: <20251020041105.1590-13-fengchengwen@huawei.com> (raw)
In-Reply-To: <20251020041105.1590-1-fengchengwen@huawei.com>
There maybe on-flight DMA when verify_data() because the DMA device
may still working when worker exit.
This commit add wait DMA complete stage before worker exit.
Fixes: 623dc9364dc6 ("app/dma-perf: introduce DMA performance test")
Cc: stable@dpdk.org
Signed-off-by: Chengwen Feng <fengchengwen@huawei.com>
---
app/test-dma-perf/benchmark.c | 71 ++++++++++++++++++++++-------------
1 file changed, 44 insertions(+), 27 deletions(-)
diff --git a/app/test-dma-perf/benchmark.c b/app/test-dma-perf/benchmark.c
index 6643ccc95f..4ce95d0f7b 100644
--- a/app/test-dma-perf/benchmark.c
+++ b/app/test-dma-perf/benchmark.c
@@ -19,7 +19,6 @@
#define MAX_DMA_CPL_NB 255
#define TEST_WAIT_U_SECOND 10000
-#define POLL_MAX 1000
#define CSV_LINE_DMA_FMT "Scenario %u,%u,%s,%u,%u,%u,%u,%.2lf,%" PRIu64 ",%.3lf,%.3lf\n"
#define CSV_LINE_CPU_FMT "Scenario %u,%u,NA,NA,NA,%u,%u,%.2lf,%" PRIu64 ",%.3lf,%.3lf\n"
@@ -293,6 +292,45 @@ do_dma_submit_and_poll(uint16_t dev_id, uint64_t *async_cnt,
worker_info->total_cpl += nr_cpl;
}
+static int
+do_dma_submit_and_wait_cpl(uint16_t dev_id, uint64_t async_cnt, bool use_ops)
+{
+#define MAX_WAIT_MSEC 1000
+#define MAX_POLL 1000
+#define DEQ_SZ 64
+ struct rte_dma_op *op[DEQ_SZ];
+ enum rte_dma_vchan_status st;
+ uint32_t poll_cnt = 0;
+ uint32_t wait_ms = 0;
+ uint16_t nr_cpl;
+
+ if (!use_ops)
+ rte_dma_submit(dev_id, 0);
+
+ if (rte_dma_vchan_status(dev_id, 0, &st) < 0) {
+ rte_delay_ms(MAX_WAIT_MSEC);
+ goto wait_cpl;
+ }
+
+ while (st == RTE_DMA_VCHAN_ACTIVE && wait_ms++ < MAX_WAIT_MSEC) {
+ rte_delay_ms(1);
+ rte_dma_vchan_status(dev_id, 0, &st);
+ }
+
+wait_cpl:
+ while ((async_cnt > 0) && (poll_cnt++ < MAX_POLL)) {
+ if (use_ops)
+ nr_cpl = rte_dma_dequeue_ops(dev_id, 0, op, DEQ_SZ);
+ else
+ nr_cpl = rte_dma_completed(dev_id, 0, MAX_DMA_CPL_NB, NULL, NULL);
+ async_cnt -= nr_cpl;
+ }
+ if (async_cnt > 0)
+ PRINT_ERR("Error: wait DMA %u failed!\n", dev_id);
+
+ return async_cnt == 0 ? 0 : -1;
+}
+
static inline int
do_dma_plain_mem_copy(void *p)
{
@@ -304,10 +342,8 @@ do_dma_plain_mem_copy(void *p)
const uint32_t buf_size = para->buf_size;
struct rte_mbuf **srcs = para->srcs;
struct rte_mbuf **dsts = para->dsts;
- uint16_t nr_cpl;
uint64_t async_cnt = 0;
uint32_t i;
- uint32_t poll_cnt = 0;
int ret;
worker_info->stop_flag = false;
@@ -338,13 +374,7 @@ do_dma_plain_mem_copy(void *p)
break;
}
- rte_dma_submit(dev_id, 0);
- while ((async_cnt > 0) && (poll_cnt++ < POLL_MAX)) {
- nr_cpl = rte_dma_completed(dev_id, 0, MAX_DMA_CPL_NB, NULL, NULL);
- async_cnt -= nr_cpl;
- }
-
- return 0;
+ return do_dma_submit_and_wait_cpl(dev_id, async_cnt, false);
}
static inline int
@@ -360,8 +390,6 @@ do_dma_sg_mem_copy(void *p)
const uint16_t dev_id = para->dev_id;
uint32_t nr_buf = para->nr_buf;
uint64_t async_cnt = 0;
- uint32_t poll_cnt = 0;
- uint16_t nr_cpl;
uint32_t i, j;
int ret;
@@ -397,13 +425,7 @@ do_dma_sg_mem_copy(void *p)
break;
}
- rte_dma_submit(dev_id, 0);
- while ((async_cnt > 0) && (poll_cnt++ < POLL_MAX)) {
- nr_cpl = rte_dma_completed(dev_id, 0, MAX_DMA_CPL_NB, NULL, NULL);
- async_cnt -= nr_cpl;
- }
-
- return 0;
+ return do_dma_submit_and_wait_cpl(dev_id, async_cnt, false);
}
static inline int
@@ -414,11 +436,11 @@ do_dma_enq_deq_mem_copy(void *p)
volatile struct worker_info *worker_info = &(para->worker_info);
struct rte_dma_op **dma_ops = para->dma_ops;
uint16_t kick_batch = para->kick_batch, sz;
- uint16_t enq, deq, poll_cnt;
- uint64_t tenq, tdeq;
const uint16_t dev_id = para->dev_id;
uint32_t nr_buf = para->nr_buf;
struct rte_dma_op *op[DEQ_SZ];
+ uint64_t tenq, tdeq;
+ uint16_t enq, deq;
uint32_t i;
worker_info->stop_flag = false;
@@ -454,11 +476,7 @@ do_dma_enq_deq_mem_copy(void *p)
break;
}
- poll_cnt = 0;
- while ((tenq != tdeq) && (poll_cnt++ < POLL_MAX))
- tdeq += rte_dma_dequeue_ops(dev_id, 0, op, DEQ_SZ);
-
- return 0;
+ return do_dma_submit_and_wait_cpl(dev_id, tenq - tdeq, true);
}
static inline int
@@ -614,7 +632,6 @@ setup_memory_env(struct test_configure *cfg, uint32_t nr_buf,
}
if (cfg->use_ops) {
-
nr_buf /= RTE_MAX(nb_src_sges, nb_dst_sges);
*dma_ops = rte_zmalloc(NULL, nr_buf * (sizeof(struct rte_dma_op *)),
RTE_CACHE_LINE_SIZE);
--
2.17.1
next prev parent reply other threads:[~2025-10-20 4:12 UTC|newest]
Thread overview: 64+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-08-11 10:54 [PATCH 0/9] bugfix and refactor of dma-perf Chengwen Feng
2025-08-11 10:54 ` [PATCH 1/9] app/dma-perf: fix use-after-free Chengwen Feng
2025-08-11 10:54 ` [PATCH 2/9] app/dma-perf: add global section for config file Chengwen Feng
2025-08-11 10:54 ` [PATCH 3/9] app/dma-perf: use argparse lib to parse argument Chengwen Feng
2025-08-11 10:54 ` [PATCH 4/9] app/dma-perf: refactor output csv Chengwen Feng
2025-08-11 10:54 ` [PATCH 5/9] app/dma-perf: support list DMA devices Chengwen Feng
2025-08-11 10:54 ` [PATCH 6/9] app/dma-perf: add more global config Chengwen Feng
2025-08-11 10:54 ` [PATCH 7/9] app/dma-perf: remove invalid or redundant field Chengwen Feng
2025-08-11 10:54 ` [PATCH 8/9] app/dma-perf: refactor load config function Chengwen Feng
2025-08-11 10:54 ` [PATCH 9/9] app/dma-perf: refactor benchmark function Chengwen Feng
2025-08-12 2:06 ` [PATCH 00/10] bugfix and refactor of dma-perf Chengwen Feng
2025-08-12 2:06 ` [PATCH 01/10] app/dma-perf: fix use-after-free Chengwen Feng
2025-08-12 2:07 ` [PATCH 02/10] app/dma-perf: add global section for config file Chengwen Feng
2025-08-12 2:07 ` [PATCH 03/10] app/dma-perf: use argparse lib to parse argument Chengwen Feng
2025-08-12 2:07 ` [PATCH 04/10] app/dma-perf: refactor output csv Chengwen Feng
2025-08-12 2:07 ` [PATCH 05/10] app/dma-perf: support list DMA devices Chengwen Feng
2025-08-12 2:07 ` [PATCH 06/10] app/dma-perf: add more global config Chengwen Feng
2025-08-12 2:07 ` [PATCH 07/10] app/dma-perf: remove invalid or redundant field Chengwen Feng
2025-08-12 2:07 ` [PATCH 08/10] app/dma-perf: refactor load config function Chengwen Feng
2025-08-12 2:07 ` [PATCH 09/10] app/dma-perf: refactor benchmark function Chengwen Feng
2025-08-12 2:07 ` [PATCH 10/10] app/dma-perf: support specific error info Chengwen Feng
2025-09-11 14:53 ` [EXTERNAL] [PATCH 00/10] bugfix and refactor of dma-perf Vamsi Krishna Attunuru
2025-09-17 3:33 ` [PATCH v2 " Chengwen Feng
2025-09-17 3:33 ` [PATCH v2 01/10] app/dma-perf: fix use-after-free Chengwen Feng
2025-09-17 3:33 ` [PATCH v2 02/10] app/dma-perf: add global section for config file Chengwen Feng
2025-09-17 3:33 ` [PATCH v2 03/10] app/dma-perf: use argparse lib to parse argument Chengwen Feng
2025-09-17 3:33 ` [PATCH v2 04/10] app/dma-perf: refactor output csv Chengwen Feng
2025-09-17 3:33 ` [PATCH v2 05/10] app/dma-perf: support list DMA devices Chengwen Feng
2025-09-17 3:33 ` [PATCH v2 06/10] app/dma-perf: add more global config Chengwen Feng
2025-09-17 3:33 ` [PATCH v2 07/10] app/dma-perf: remove invalid or redundant field Chengwen Feng
2025-09-17 3:33 ` [PATCH v2 08/10] app/dma-perf: refactor load config function Chengwen Feng
2025-09-17 3:33 ` [PATCH v2 09/10] app/dma-perf: refactor benchmark function Chengwen Feng
2025-09-17 3:33 ` [PATCH v2 10/10] app/dma-perf: support specific error info Chengwen Feng
2025-10-13 3:02 ` [PATCH v3 00/13] bugfix and refactor of dma-perf Chengwen Feng
2025-10-13 3:02 ` [PATCH v3 01/13] app/dma-perf: fix use-after-free Chengwen Feng
2025-10-13 7:55 ` Bruce Richardson
2025-10-13 8:15 ` fengchengwen
2025-10-13 3:02 ` [PATCH v3 02/13] app/dma-perf: add global section for config file Chengwen Feng
2025-10-13 3:02 ` [PATCH v3 03/13] app/dma-perf: use argparse lib to parse argument Chengwen Feng
2025-10-13 3:02 ` [PATCH v3 04/13] app/dma-perf: refactor output csv Chengwen Feng
2025-10-13 3:02 ` [PATCH v3 05/13] app/dma-perf: support list DMA devices Chengwen Feng
2025-10-13 3:02 ` [PATCH v3 06/13] app/dma-perf: add more global config Chengwen Feng
2025-10-13 3:02 ` [PATCH v3 07/13] app/dma-perf: remove invalid or redundant field Chengwen Feng
2025-10-13 3:02 ` [PATCH v3 08/13] app/dma-perf: refactor load config function Chengwen Feng
2025-10-13 3:02 ` [PATCH v3 09/13] app/dma-perf: refactor benchmark function Chengwen Feng
2025-10-13 3:02 ` [PATCH v3 10/13] app/dma-perf: support specific error info Chengwen Feng
2025-10-13 3:02 ` [PATCH v3 11/13] app/dma-perf: fix segment fault with large size Chengwen Feng
2025-10-13 3:02 ` [PATCH v3 12/13] app/dma-perf: fix on-flight DMA when verify data Chengwen Feng
2025-10-13 3:02 ` [PATCH v3 13/13] app/dma-perf: fix wrong stage to stop dmadev Chengwen Feng
2025-10-20 4:10 ` [PATCH v4 00/14] bugfix and refactor of dma-perf Chengwen Feng
2025-10-20 4:10 ` [PATCH v4 01/14] app/dma-perf: fix use-after-free Chengwen Feng
2025-10-20 4:10 ` [PATCH v4 02/14] app/dma-perf: add global section for config file Chengwen Feng
2025-10-20 4:10 ` [PATCH v4 03/14] app/dma-perf: use argparse lib to parse argument Chengwen Feng
2025-10-20 4:10 ` [PATCH v4 04/14] app/dma-perf: refactor output csv Chengwen Feng
2025-10-20 4:10 ` [PATCH v4 05/14] app/dma-perf: support list DMA devices Chengwen Feng
2025-10-20 4:10 ` [PATCH v4 06/14] app/dma-perf: add more global config Chengwen Feng
2025-10-20 4:10 ` [PATCH v4 07/14] app/dma-perf: remove invalid or redundant field Chengwen Feng
2025-10-20 4:10 ` [PATCH v4 08/14] app/dma-perf: refactor load config function Chengwen Feng
2025-10-20 4:11 ` [PATCH v4 09/14] app/dma-perf: refactor benchmark function Chengwen Feng
2025-10-20 4:11 ` [PATCH v4 10/14] app/dma-perf: support specific error info Chengwen Feng
2025-10-20 4:11 ` [PATCH v4 11/14] app/dma-perf: fix segment fault with large size Chengwen Feng
2025-10-20 4:11 ` Chengwen Feng [this message]
2025-10-20 4:11 ` [PATCH v4 13/14] app/dma-perf: fix wrong stage to stop dmadev Chengwen Feng
2025-10-20 4:11 ` [PATCH v4 14/14] app/dma-perf: refactor benchmark function Chengwen Feng
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20251020041105.1590-13-fengchengwen@huawei.com \
--to=fengchengwen@huawei.com \
--cc=dev@dpdk.org \
--cc=honest.jiang@foxmail.com \
--cc=liuyonglong@huawei.com \
--cc=thomas@monjalon.net \
--cc=vattunuru@marvell.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).