[v3] app/dma-perf: fix physical address seg-fault

Message ID 20231019041956.609-1-vipin.varghese@amd.com (mailing list archive)
State Accepted, archived
Delegated to: Thomas Monjalon
Headers
Series [v3] app/dma-perf: fix physical address seg-fault |

Checks

Context Check Description
ci/loongarch-compilation success Compilation OK
ci/checkpatch success coding style OK
ci/loongarch-unit-testing success Unit Testing PASS
ci/github-robot: build success github build: passed
ci/Intel-compilation success Compilation OK
ci/intel-Testing success Testing PASS
ci/intel-Functional success Functional PASS
ci/iol-broadcom-Functional success Functional Testing PASS
ci/iol-mellanox-Performance success Performance Testing PASS
ci/iol-broadcom-Performance success Performance Testing PASS
ci/iol-intel-Performance success Performance Testing PASS
ci/iol-intel-Functional success Functional Testing PASS
ci/iol-compile-amd64-testing success Testing PASS
ci/iol-unit-arm64-testing success Testing PASS
ci/iol-compile-arm64-testing success Testing PASS
ci/iol-unit-amd64-testing success Testing PASS

Commit Message

Vipin Varghese Oct. 19, 2023, 4:19 a.m. UTC
  do_cpu_mem_copy uses DPDK API rte_mbuf_data_iova to return
the start of the virtual address for both src and dst.
But in case of iova mode set as PA, this results in seg-fault.
This is because rte_memcpy uses VA address and not PA.

This fix invokes `rte_pktmbuf_mtod` for both src and dst.

Bugzilla ID: 1269
Fixes: 623dc9364dc6 ("app/dma-perf: introduce DMA performance test")
Cc: cheng1.jiang@intel.com

Cc: stable@dpdk.org

Signed-off-by: Vipin Varghese <vipin.varghese@amd.com>
Suggested-by: Anoob Joseph <anoobj@marvell.com>
Suggested-by: Jerin Jacob <jerinj@marvell.com>

---

v2:
 - suggest use of pktmbuf_mtod for both va and pa by Anoob.

V3:
 - add const to src suggested by Jerin.
---
 app/test-dma-perf/benchmark.c | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)
  

Comments

lihuisong (C) Oct. 24, 2023, 2:16 a.m. UTC | #1
在 2023/10/19 12:19, Vipin Varghese 写道:
> do_cpu_mem_copy uses DPDK API rte_mbuf_data_iova to return
> the start of the virtual address for both src and dst.
> But in case of iova mode set as PA, this results in seg-fault.
> This is because rte_memcpy uses VA address and not PA.
>
> This fix invokes `rte_pktmbuf_mtod` for both src and dst.
>
> Bugzilla ID: 1269
> Fixes: 623dc9364dc6 ("app/dma-perf: introduce DMA performance test")
> Cc: cheng1.jiang@intel.com
>
> Cc: stable@dpdk.org
>
> Signed-off-by: Vipin Varghese <vipin.varghese@amd.com>
> Suggested-by: Anoob Joseph <anoobj@marvell.com>
> Suggested-by: Jerin Jacob <jerinj@marvell.com>
>
Acked-by: Huisong Li <lihuisong@huawei.com>
  
Thomas Monjalon Nov. 14, 2023, 2:27 p.m. UTC | #2
24/10/2023 04:16, lihuisong (C):
> 
> 在 2023/10/19 12:19, Vipin Varghese 写道:
> > do_cpu_mem_copy uses DPDK API rte_mbuf_data_iova to return
> > the start of the virtual address for both src and dst.
> > But in case of iova mode set as PA, this results in seg-fault.
> > This is because rte_memcpy uses VA address and not PA.
> >
> > This fix invokes `rte_pktmbuf_mtod` for both src and dst.
> >
> > Bugzilla ID: 1269
> > Fixes: 623dc9364dc6 ("app/dma-perf: introduce DMA performance test")
> > Cc: cheng1.jiang@intel.com
> >
> > Cc: stable@dpdk.org
> >
> > Signed-off-by: Vipin Varghese <vipin.varghese@amd.com>
> > Suggested-by: Anoob Joseph <anoobj@marvell.com>
> > Suggested-by: Jerin Jacob <jerinj@marvell.com>
> >
> Acked-by: Huisong Li <lihuisong@huawei.com>

Adding some missing acks.

Applied, thanks.
  

Patch

diff --git a/app/test-dma-perf/benchmark.c b/app/test-dma-perf/benchmark.c
index 0601e0d171..9b1f58c78c 100644
--- a/app/test-dma-perf/benchmark.c
+++ b/app/test-dma-perf/benchmark.c
@@ -288,10 +288,11 @@  do_cpu_mem_copy(void *p)
 
 	while (1) {
 		for (i = 0; i < nr_buf; i++) {
+			const void *src = rte_pktmbuf_mtod(dsts[i], void *);
+			void *dst = rte_pktmbuf_mtod(srcs[i], void *);
+
 			/* copy buffer form src to dst */
-			rte_memcpy((void *)(uintptr_t)rte_mbuf_data_iova(dsts[i]),
-				(void *)(uintptr_t)rte_mbuf_data_iova(srcs[i]),
-				(size_t)buf_size);
+			rte_memcpy(dst, src, (size_t)buf_size);
 			worker_info->total_cpl++;
 		}
 		if (worker_info->stop_flag)