DPDK patches and discussions
 help / color / mirror / Atom feed
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 v3 13/13] app/dma-perf: fix wrong stage to stop dmadev
Date: Mon, 13 Oct 2025 11:02:36 +0800	[thread overview]
Message-ID: <20251013030236.3861-14-fengchengwen@huawei.com> (raw)
In-Reply-To: <20251013030236.3861-1-fengchengwen@huawei.com>

The benchmark do stop-dmadev at last, it has two problem:
1. it still invoke stop-dmadev when something wrong before
   config-dmadev.
2. the dmadev may working but the memory are freed.

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 | 36 +++++++++++++++++++++++++----------
 1 file changed, 26 insertions(+), 10 deletions(-)

diff --git a/app/test-dma-perf/benchmark.c b/app/test-dma-perf/benchmark.c
index 8e755c2afa..4bdd3ca598 100644
--- a/app/test-dma-perf/benchmark.c
+++ b/app/test-dma-perf/benchmark.c
@@ -763,6 +763,25 @@ verify_data(struct test_configure *cfg, struct rte_mbuf **srcs, struct rte_mbuf
 	return 0;
 }
 
+static void
+stop_dev(struct test_configure *cfg, bool *stopped)
+{
+	struct lcore_dma_map_t *lcore_dma_map;
+	uint32_t i;
+
+	if (*stopped)
+		return;
+
+	if (cfg->test_type == TEST_TYPE_DMA_MEM_COPY) {
+		for (i = 0; i < cfg->num_worker; i++) {
+			lcore_dma_map = &cfg->dma_config[i].lcore_dma_map;
+			printf("Stopping dmadev %d\n", lcore_dma_map->dma_id);
+			rte_dma_stop(lcore_dma_map->dma_id);
+		}
+	}
+	*stopped = true;
+}
+
 int
 mem_copy_benchmark(struct test_configure *cfg)
 {
@@ -778,6 +797,7 @@ mem_copy_benchmark(struct test_configure *cfg)
 	float bandwidth, bandwidth_total;
 	unsigned int lcore_id = 0;
 	uint32_t avg_cycles_total;
+	bool dev_stopped = false;
 	uint32_t avg_cycles = 0;
 	float mops, mops_total;
 	float memory = 0;
@@ -840,7 +860,7 @@ mem_copy_benchmark(struct test_configure *cfg)
 		    vchan_dev->tdir == RTE_DMA_DIR_MEM_TO_DEV) {
 			if (attach_ext_buffer(vchan_dev, lcores[i], cfg->is_sg,
 					      (nr_sgsrc/nb_workers), (nr_sgdst/nb_workers)) < 0)
-				goto out;
+				goto stop_dev;
 		}
 
 		rte_eal_remote_launch(get_work_function(cfg), (void *)(lcores[i]), lcore_id);
@@ -875,6 +895,8 @@ mem_copy_benchmark(struct test_configure *cfg)
 
 	rte_eal_mp_wait_lcore();
 
+	stop_dev(cfg, &dev_stopped);
+
 	ret = verify_data(cfg, srcs, dsts, nr_buf);
 	if (ret != 0)
 		goto out;
@@ -900,8 +922,10 @@ mem_copy_benchmark(struct test_configure *cfg)
 	output_csv(CSV_TOTAL_LINE_FMT, cfg->scenario_id, nr_buf, memory * nb_workers,
 			(avg_cycles_total * (float) 1.0) / nb_workers, bandwidth_total, mops_total);
 
-out:
+stop_dev:
+	stop_dev(cfg, &dev_stopped);
 
+out:
 	for (k = 0; k < nb_workers; k++) {
 		struct rte_mbuf **sbuf = NULL, **dbuf = NULL;
 		vchan_dev = &cfg->dma_config[k].vchan_dev;
@@ -955,13 +979,5 @@ mem_copy_benchmark(struct test_configure *cfg)
 		lcores[i] = NULL;
 	}
 
-	if (cfg->test_type == TEST_TYPE_DMA_MEM_COPY) {
-		for (i = 0; i < nb_workers; i++) {
-			lcore_dma_map = &cfg->dma_config[i].lcore_dma_map;
-			printf("Stopping dmadev %d\n", lcore_dma_map->dma_id);
-			rte_dma_stop(lcore_dma_map->dma_id);
-		}
-	}
-
 	return ret;
 }
-- 
2.17.1


      parent reply	other threads:[~2025-10-13  3:04 UTC|newest]

Thread overview: 49+ 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   ` Chengwen Feng [this message]

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=20251013030236.3861-14-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).