* [PATCH] app/dma-perf: validate copied memory
@ 2023-08-10 10:07 Gowrishankar Muthukrishnan
0 siblings, 0 replies; 2+ messages in thread
From: Gowrishankar Muthukrishnan @ 2023-08-10 10:07 UTC (permalink / raw)
To: dev; +Cc: anoobj, Cheng Jiang, Gowrishankar Muthukrishnan
Validate copied memory to ensure DMA copy did not fail.
Signed-off-by: Gowrishankar Muthukrishnan <gmuthukrishn@marvell.com>
Change-Id: I9f888c061f3d077f6b7b2d8a66c6a7cb7e5f2437
---
app/test-dma-perf/benchmark.c | 23 +++++++++++++++++++++--
app/test-dma-perf/main.c | 16 +++++++++++-----
app/test-dma-perf/main.h | 2 +-
3 files changed, 33 insertions(+), 8 deletions(-)
diff --git a/app/test-dma-perf/benchmark.c b/app/test-dma-perf/benchmark.c
index 0601e0d171..9e5b5dc770 100644
--- a/app/test-dma-perf/benchmark.c
+++ b/app/test-dma-perf/benchmark.c
@@ -12,6 +12,7 @@
#include <rte_dmadev.h>
#include <rte_malloc.h>
#include <rte_lcore.h>
+#include <rte_random.h>
#include "main.h"
@@ -306,7 +307,7 @@ setup_memory_env(struct test_configure *cfg, struct rte_mbuf ***srcs,
struct rte_mbuf ***dsts)
{
unsigned int buf_size = cfg->buf_size.cur;
- unsigned int nr_sockets;
+ unsigned int nr_sockets, i;
uint32_t nr_buf = cfg->nr_buf;
nr_sockets = rte_socket_count();
@@ -360,10 +361,15 @@ setup_memory_env(struct test_configure *cfg, struct rte_mbuf ***srcs,
return -1;
}
+ for (i = 0; i < nr_buf; i++) {
+ memset(rte_pktmbuf_mtod((*srcs)[i], void *), rte_rand(), buf_size);
+ memset(rte_pktmbuf_mtod((*dsts)[i], void *), 0, buf_size);
+ }
+
return 0;
}
-void
+int
mem_copy_benchmark(struct test_configure *cfg, bool is_dma)
{
uint16_t i;
@@ -381,6 +387,7 @@ mem_copy_benchmark(struct test_configure *cfg, bool is_dma)
uint32_t avg_cycles_total;
float mops, mops_total;
float bandwidth, bandwidth_total;
+ int ret = 0;
if (setup_memory_env(cfg, &srcs, &dsts) < 0)
goto out;
@@ -454,6 +461,16 @@ mem_copy_benchmark(struct test_configure *cfg, bool is_dma)
rte_eal_mp_wait_lcore();
+ for (i = 0; i < cfg->nr_buf; i++) {
+ if (memcmp(rte_pktmbuf_mtod(srcs[i], void *),
+ rte_pktmbuf_mtod(dsts[i], void *),
+ cfg->buf_size.cur) != 0) {
+ printf("Copy validation fails for buffer number %d\n", i);
+ ret = -1;
+ goto out;
+ }
+ }
+
mops_total = 0;
bandwidth_total = 0;
avg_cycles_total = 0;
@@ -505,4 +522,6 @@ mem_copy_benchmark(struct test_configure *cfg, bool is_dma)
rte_dma_stop(ldm->dma_ids[i]);
}
}
+
+ return ret;
}
diff --git a/app/test-dma-perf/main.c b/app/test-dma-perf/main.c
index de37120df6..bbba06ec1b 100644
--- a/app/test-dma-perf/main.c
+++ b/app/test-dma-perf/main.c
@@ -86,20 +86,24 @@ output_header(uint32_t case_id, struct test_configure *case_cfg)
output_csv(true);
}
-static void
+static int
run_test_case(struct test_configure *case_cfg)
{
+ int ret = 0;
+
switch (case_cfg->test_type) {
case TEST_TYPE_DMA_MEM_COPY:
- mem_copy_benchmark(case_cfg, true);
+ ret = mem_copy_benchmark(case_cfg, true);
break;
case TEST_TYPE_CPU_MEM_COPY:
- mem_copy_benchmark(case_cfg, false);
+ ret = mem_copy_benchmark(case_cfg, false);
break;
default:
printf("Unknown test type. %s\n", case_cfg->test_type_str);
break;
}
+
+ return ret;
}
static void
@@ -144,8 +148,10 @@ run_test(uint32_t case_id, struct test_configure *case_cfg)
case_cfg->scenario_id++;
printf("\nRunning scenario %d\n", case_cfg->scenario_id);
- run_test_case(case_cfg);
- output_csv(false);
+ if (run_test_case(case_cfg) < 0)
+ printf("\nTest fails! skipping this scenario.\n");
+ else
+ output_csv(false);
if (var_entry->op == OP_ADD)
var_entry->cur += var_entry->incr;
diff --git a/app/test-dma-perf/main.h b/app/test-dma-perf/main.h
index 12bc3f4e3f..57a9f71a06 100644
--- a/app/test-dma-perf/main.h
+++ b/app/test-dma-perf/main.h
@@ -59,6 +59,6 @@ struct test_configure {
uint8_t scenario_id;
};
-void mem_copy_benchmark(struct test_configure *cfg, bool is_dma);
+int mem_copy_benchmark(struct test_configure *cfg, bool is_dma);
#endif /* _MAIN_H_ */
--
2.25.1
^ permalink raw reply [flat|nested] 2+ messages in thread
* [PATCH] app/dma-perf: validate copied memory
@ 2023-08-10 10:55 Gowrishankar Muthukrishnan
0 siblings, 0 replies; 2+ messages in thread
From: Gowrishankar Muthukrishnan @ 2023-08-10 10:55 UTC (permalink / raw)
To: dev; +Cc: anoobj, Cheng Jiang, Gowrishankar Muthukrishnan
Validate copied memory to ensure DMA copy did not fail.
Fixes: 623dc9364dc ("app/dma-perf: introduce DMA performance test")
Signed-off-by: Gowrishankar Muthukrishnan <gmuthukrishn@marvell.com>
---
v2:
- patch issue fixed.
---
app/test-dma-perf/benchmark.c | 23 +++++++++++++++++++++--
app/test-dma-perf/main.c | 16 +++++++++++-----
app/test-dma-perf/main.h | 2 +-
3 files changed, 33 insertions(+), 8 deletions(-)
diff --git a/app/test-dma-perf/benchmark.c b/app/test-dma-perf/benchmark.c
index 0601e0d171..9e5b5dc770 100644
--- a/app/test-dma-perf/benchmark.c
+++ b/app/test-dma-perf/benchmark.c
@@ -12,6 +12,7 @@
#include <rte_dmadev.h>
#include <rte_malloc.h>
#include <rte_lcore.h>
+#include <rte_random.h>
#include "main.h"
@@ -306,7 +307,7 @@ setup_memory_env(struct test_configure *cfg, struct rte_mbuf ***srcs,
struct rte_mbuf ***dsts)
{
unsigned int buf_size = cfg->buf_size.cur;
- unsigned int nr_sockets;
+ unsigned int nr_sockets, i;
uint32_t nr_buf = cfg->nr_buf;
nr_sockets = rte_socket_count();
@@ -360,10 +361,15 @@ setup_memory_env(struct test_configure *cfg, struct rte_mbuf ***srcs,
return -1;
}
+ for (i = 0; i < nr_buf; i++) {
+ memset(rte_pktmbuf_mtod((*srcs)[i], void *), rte_rand(), buf_size);
+ memset(rte_pktmbuf_mtod((*dsts)[i], void *), 0, buf_size);
+ }
+
return 0;
}
-void
+int
mem_copy_benchmark(struct test_configure *cfg, bool is_dma)
{
uint16_t i;
@@ -381,6 +387,7 @@ mem_copy_benchmark(struct test_configure *cfg, bool is_dma)
uint32_t avg_cycles_total;
float mops, mops_total;
float bandwidth, bandwidth_total;
+ int ret = 0;
if (setup_memory_env(cfg, &srcs, &dsts) < 0)
goto out;
@@ -454,6 +461,16 @@ mem_copy_benchmark(struct test_configure *cfg, bool is_dma)
rte_eal_mp_wait_lcore();
+ for (i = 0; i < cfg->nr_buf; i++) {
+ if (memcmp(rte_pktmbuf_mtod(srcs[i], void *),
+ rte_pktmbuf_mtod(dsts[i], void *),
+ cfg->buf_size.cur) != 0) {
+ printf("Copy validation fails for buffer number %d\n", i);
+ ret = -1;
+ goto out;
+ }
+ }
+
mops_total = 0;
bandwidth_total = 0;
avg_cycles_total = 0;
@@ -505,4 +522,6 @@ mem_copy_benchmark(struct test_configure *cfg, bool is_dma)
rte_dma_stop(ldm->dma_ids[i]);
}
}
+
+ return ret;
}
diff --git a/app/test-dma-perf/main.c b/app/test-dma-perf/main.c
index e5bccc27da..f917be4216 100644
--- a/app/test-dma-perf/main.c
+++ b/app/test-dma-perf/main.c
@@ -86,20 +86,24 @@ output_header(uint32_t case_id, struct test_configure *case_cfg)
output_csv(true);
}
-static void
+static int
run_test_case(struct test_configure *case_cfg)
{
+ int ret = 0;
+
switch (case_cfg->test_type) {
case TEST_TYPE_DMA_MEM_COPY:
- mem_copy_benchmark(case_cfg, true);
+ ret = mem_copy_benchmark(case_cfg, true);
break;
case TEST_TYPE_CPU_MEM_COPY:
- mem_copy_benchmark(case_cfg, false);
+ ret = mem_copy_benchmark(case_cfg, false);
break;
default:
printf("Unknown test type. %s\n", case_cfg->test_type_str);
break;
}
+
+ return ret;
}
static void
@@ -144,8 +148,10 @@ run_test(uint32_t case_id, struct test_configure *case_cfg)
case_cfg->scenario_id++;
printf("\nRunning scenario %d\n", case_cfg->scenario_id);
- run_test_case(case_cfg);
- output_csv(false);
+ if (run_test_case(case_cfg) < 0)
+ printf("\nTest fails! skipping this scenario.\n");
+ else
+ output_csv(false);
if (var_entry->op == OP_ADD)
var_entry->cur += var_entry->incr;
diff --git a/app/test-dma-perf/main.h b/app/test-dma-perf/main.h
index f65e264378..658f22f673 100644
--- a/app/test-dma-perf/main.h
+++ b/app/test-dma-perf/main.h
@@ -59,6 +59,6 @@ struct test_configure {
uint8_t scenario_id;
};
-void mem_copy_benchmark(struct test_configure *cfg, bool is_dma);
+int mem_copy_benchmark(struct test_configure *cfg, bool is_dma);
#endif /* MAIN_H */
--
2.25.1
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2023-08-10 10:55 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-08-10 10:07 [PATCH] app/dma-perf: validate copied memory Gowrishankar Muthukrishnan
2023-08-10 10:55 Gowrishankar Muthukrishnan
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).