app/dma-perf: fix physical address seg-fault
PATCH 1/1 app/dma-perf: fix physical address seg-fault
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 VA address and not PA.
this fix checks the iova mode and invokes rte_memcpy with the right arguments.
Bugzilla ID: 1269
---
tested for both va and pa
CMD:
PA: dpdk-test-dma-perf --iova-mode=pa -- --config test.ini
VA: dpdk-test-dma-perf --iova-mode=va -- --config test.ini
DC: dpdk-test-dma-perf --iova-mode=dc -- --config test.ini
Log: fails for dc mode EAL: invalid parameters for --iova-mode
test.ini:
``` [case1] type=CPU_MEM_COPY mem_size=10 buf_size=64,8192,2,MUL src_numa_node=0 dst_numa_node=0 cache_flush=0 test_seconds=2 lcore = 7 eal_args=--in-memory --no-pci ``` --- app/test-dma-perf/benchmark.c | 39 +++++++++++++++++++++++++++-------- 1 file changed, 30 insertions(+), 9 deletions(-)
app/test-dma-perf/benchmark.c +30 -9
@@ -279,6 +279,10 @@ do_cpu_mem_copy(void *p)struct rte_mbuf **srcs = para->srcs;struct rte_mbuf **dsts = para->dsts;uint32_t i; +bool isAddrPaMode = false; + +if (rte_eal_iova_mode () ==RTE_IOVA_PA ) + isAddrPaMode = true; worker_info->stop_flag = false; worker_info->ready_flag = true;
@@ -286,16 +290,33 @@ do_cpu_mem_copy(void *p)while (!worker_info->start_flag) ; -while (1 ) { -for (i =0 ; i < nr_buf; i++) { -/* 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); - worker_info->total_cpl++; +if (true == isAddrPaMode) { +while (1 ) { +for (i =0 ; i < nr_buf; i++) { + void *src = rte_pktmbuf_mtod(dsts[i], void *); + void *dst = rte_pktmbuf_mtod(srcs[i], void *); + +/* copy buffer form src to dst */ +rte_memcpy (dst, + src, + (size_t )buf_size); + worker_info->total_cpl++; + } +if (worker_info->stop_flag) +break ; + } + }else { +while (1 ) { +for (i =0 ; i < nr_buf; i++) { +/* 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); + worker_info->total_cpl++; + } +if (worker_info->stop_flag) +break ; } -if (worker_info->stop_flag) -break ; }return 0 ;
Signature · 1 line
2.34.1
Hi Vipin,
Thanks for the update. Please see inline.
Thanks,
Anoob
Quoted 98 lines
-----Original Message-----
From: Vipin Varghese <[email protected]>
Sent: Wednesday, August 16, 2023 12:48 PM
To: [email protected]; [email protected]
Cc: [email protected]; [email protected]; [email protected]
Subject: [EXT] [PATCH] app/dma-perf: fix physical address seg-faultExternal Email
----------------------------------------------------------------------
do_cpu_mem_copyuses DPDK APIrte_mbuf_data_iovato 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 becauserte_memcpyVA address and not PA.this fix checks the iova mode and invokes
rte_memcpywith the right arguments.Bugzilla ID: 1269
Fixes 623dc9364dc6 ("app/dma-perf: introduce DMA performance test")Signed-off-by Vipin Varghese <[email protected]>---
tested for both va and pa
CMD:
PA: dpdk-test-dma-perf --iova-mode=pa -- --config test.ini
VA: dpdk-test-dma-perf --iova-mode=va -- --config test.ini
DC: dpdk-test-dma-perf --iova-mode=dc -- --config test.iniLog: fails for dc mode
EAL: invalid parameters for --iova-modetest.ini:
``` [case1] type=CPU_MEM_COPY mem_size=10 buf_size=64,8192,2,MUL src_numa_node=0 dst_numa_node=0 cache_flush=0 test_seconds=2 lcore = 7 eal_args=--in-memory --no-pci ``` --- app/test-dma-perf/benchmark.c | 39 +++++++++++++++++++++++++++---- ---- 1 file changed, 30 insertions(+), 9 deletions(-)app/test-dma- renamed from app/test-dma-perf/benchmark.c +0
-0
perf/benchmark.cindex0601e0d171..5573acc9f9100644app/test-dma-perf/benchmark.c +18
-7@@ -279,6 +279,10 @@ do_cpu_mem_copy(void *p)struct rte_mbuf **srcs = para->srcs;struct rte_mbuf **dsts = para->dsts;uint32_t i; +bool isAddrPaMode = false; + +if (rte_eal_iova_mode () ==RTE_IOVA_PA ) + isAddrPaMode = true; worker_info->stop_flag = false; worker_info->ready_flag = true;@@ -286,16 +290,33 @@ do_cpu_mem_copy(void *p)while (!worker_info->start_flag) ; -while (1 ) { -for (i =0 ; i < nr_buf; i++) { -/* 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); - worker_info->total_cpl++; + if (true == isAddrPaMode) { +while (1 ) { +for (i =0 ; i < nr_buf; i++) { +void *src =rte_pktmbuf_mtod (dsts[i], void *); +void *dst =rte_pktmbuf_mtod (srcs[i], void *); + +/* copy buffer form src to dst */ +rte_memcpy (dst, + src, + (size_t )buf_size); + worker_info->total_cpl++; + } +if (worker_info->stop_flag) +break ;
app/test-dma-perf/benchmark.c do_cpu_mem_copy(void *p) · line 320
Quoted 10 lines
app/test-dma-perf/benchmark.c +8
-0+ } + }else { +while (1 ) { +for (i =0 ; i < nr_buf; i++) { +/* 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);
[Anoob] Even in case of VA as IOVA, rte_pktmbuf_mtod() should work, right? I was imagining a simple replacement of ' rte_mbuf_data_iova' with 'rte_pktmbuf_mtod' as the fix.
Quoted 12 lines
app/test-dma-perf/benchmark.c +4
-3+ worker_info->total_cpl++; + } +if (worker_info->stop_flag) +break ; } -if (worker_info->stop_flag) -break ; }return 0 ; --2.34.1
[AMD Official Use Only - General]
Quoted 126 lines
-----Original Message-----
From: Anoob Joseph <[email protected]>
Sent: Wednesday, August 16, 2023 12:57 PM
To: Varghese, Vipin <[email protected]>
Cc: Yigit, Ferruh <[email protected]>; [email protected]; [email protected]; [email protected]; [email protected]; Jerin Jacob Kollanukkaran <[email protected]>
Subject: RE: [EXT] [PATCH] app/dma-perf: fix physical address seg-faultCaution: This message originated from an External Source. Use proper caution when opening attachments, clicking links, or responding.
Hi Vipin,
Thanks for the update. Please see inline.
Thanks,
AnoobQuoted 106 lines
-----Original Message-----
From: Vipin Varghese <[email protected]>
Sent: Wednesday, August 16, 2023 12:48 PM
To: [email protected]; [email protected]
Cc: [email protected]; [email protected]; [email protected]
Subject: [EXT] [PATCH] app/dma-perf: fix physical address seg-faultExternal Email
----------------------------------------------------------------------
do_cpu_mem_copyuses DPDK APIrte_mbuf_data_iovato 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 becauserte_memcpyVA address and not PA.this fix checks the iova mode and invokes
rte_memcpywith the right arguments.Bugzilla ID: 1269
Fixes 623dc9364dc6 ("app/dma-perf: introduce DMA performance test")Signed-off-by Vipin Varghese <[email protected]>---
tested for both va and pa
CMD:
PA: dpdk-test-dma-perf --iova-mode=pa -- --config test.ini
VA: dpdk-test-dma-perf --iova-mode=va -- --config test.ini
DC: dpdk-test-dma-perf --iova-mode=dc -- --config test.iniLog: fails for dc mode
EAL: invalid parameters for --iova-modetest.ini:
``` [case1] type=CPU_MEM_COPY mem_size=10 buf_size=64,8192,2,MUL src_numa_node=0 dst_numa_node=0 cache_flush=0 test_seconds=2 lcore = 7 eal_args=--in-memory --no-pci ``` --- app/test-dma-perf/benchmark.c | 39 +++++++++++++++++++++++++++---- ---- 1 file changed, 30 insertions(+), 9 deletions(-)app/test-dma- renamed from app/test-dma-perf/benchmark.c +0
-0
perf/benchmark.cindex0601e0d171..5573acc9f9100644app/test-dma-perf/benchmark.c +26
-7@@ -279,6 +279,10 @@ do_cpu_mem_copy(void *p)struct rte_mbuf **srcs = para->srcs;struct rte_mbuf **dsts = para->dsts;uint32_t i; +bool isAddrPaMode = false; + +if (rte_eal_iova_mode () ==RTE_IOVA_PA ) + isAddrPaMode = true; worker_info->stop_flag = false; worker_info->ready_flag = true;@@ -286,16 +290,33 @@ do_cpu_mem_copy(void *p)while (!worker_info->start_flag) ; -while (1 ) { -for (i =0 ; i < nr_buf; i++) { -/* 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); - worker_info->total_cpl++; + if (true == isAddrPaMode) { +while (1 ) { +for (i =0 ; i < nr_buf; i++) { +void *src =rte_pktmbuf_mtod (dsts[i], + void *); +void *dst =rte_pktmbuf_mtod (srcs[i], + void *); + +/* copy buffer form src to dst */ +rte_memcpy (dst, + src, + (size_t )buf_size); + worker_info->total_cpl++; + } +if (worker_info->stop_flag) +break ; + } + } else { +while (1 ) { +for (i =0 ; i < nr_buf; i++) { +/* copy buffer form src to dst */ + rte_memcpy((void
Quoted 8 lines
app/test-dma-perf/benchmark.c do_cpu_mem_copy(void *p) · line 322
Quoted 4 lines
app/test-dma-perf/benchmark.c +2
-0*)(uintptr_t)rte_mbuf_data_iova(dsts[i]), + (void *)(uintptr_t)rte_mbuf_data_iova(srcs[i]), + (size_t)buf_size);[Anoob] Even in case of VA as IOVA,
rte_pktmbuf_mtod()should work, right? I was imagining a simple replacement of 'rte_mbuf_data_iova' with 'rte_pktmbuf_mtod' as the fix.
Ferruh and myself believe the rte_mbuf_data_iova should have been working for both PA and VA. But internally does not.
I think what you are recommending is for both PA and VA just use rte_pktmbuf_mtod for both. Thus we can avoid the check itself.
Quoted 13 lines
Quoted 13 lines
app/test-dma-perf/benchmark.c +4
-3+ worker_info->total_cpl++; + } +if (worker_info->stop_flag) +break ; } -if (worker_info->stop_flag) -break ; }return 0 ; --2.34.1
PATCH v2 1/1 app/dma-perf: fix physical address seg-fault
In reply to Vipin Varghesedo_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
---
v2:
- suggest use of pktmbuf_mtod for both va and pa.
tested for both va and pa
CMD:
PA: dpdk-test-dma-perf --iova-mode=pa -- --config test.ini
VA: dpdk-test-dma-perf --iova-mode=va -- --config test.ini
DC: dpdk-test-dma-perf --iova-mode=dc -- --config test.ini
Log: fails for dc mode EAL: invalid parameters for --iova-mode
test.ini:
``` [case1] type=CPU_MEM_COPY mem_size=10 buf_size=64,8192,2,MUL src_numa_node=0 dst_numa_node=0 cache_flush=0 test_seconds=2 lcore = 7 eal_args=--in-memory --no-pci ``` --- app/test-dma-perf/benchmark.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-)
app/test-dma-perf/benchmark.c +5 -2
@@ -288,9 +288,12 @@ do_cpu_mem_copy(void *p)while (1 ) {for (i =0 ; i < nr_buf; i++) { + 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]), +rte_memcpy (dst, + src, (size_t )buf_size); worker_info->total_cpl++; }
Signature · 1 line
2.34.1
PATCH v2 1/1 app/dma-perf: fix physical address seg-fault
In reply to Vipin Varghesedo_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
---
v2:
- suggest use of pktmbuf_mtod for both va and pa.
tested for both va and pa
CMD:
PA: dpdk-test-dma-perf --iova-mode=pa -- --config test.ini
VA: dpdk-test-dma-perf --iova-mode=va -- --config test.ini
DC: dpdk-test-dma-perf --iova-mode=dc -- --config test.ini
Log: fails for dc mode EAL: invalid parameters for --iova-mode
test.ini:
``` [case1] type=CPU_MEM_COPY mem_size=10 buf_size=64,8192,2,MUL src_numa_node=0 dst_numa_node=0 cache_flush=0 test_seconds=2 lcore = 7 eal_args=--in-memory --no-pci ``` --- app/test-dma-perf/benchmark.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-)
app/test-dma-perf/benchmark.c +5 -2
@@ -288,9 +288,12 @@ do_cpu_mem_copy(void *p)while (1 ) {for (i =0 ; i < nr_buf; i++) { + 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]), +rte_memcpy (dst, + src, (size_t )buf_size); worker_info->total_cpl++; }
Signature · 1 line
2.34.1
PATCH v2 1/1 app/dma-perf: fix physical address seg-fault
In reply to Vipin Varghesedo_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
---
v2:
- suggest use of pktmbuf_mtod for both va and pa.
tested for both va and pa
CMD:
PA: dpdk-test-dma-perf --iova-mode=pa -- --config test.ini
VA: dpdk-test-dma-perf --iova-mode=va -- --config test.ini
DC: dpdk-test-dma-perf --iova-mode=dc -- --config test.ini
Log: fails for dc mode EAL: invalid parameters for --iova-mode
test.ini:
``` [case1] type=CPU_MEM_COPY mem_size=10 buf_size=64,8192,2,MUL src_numa_node=0 dst_numa_node=0 cache_flush=0 test_seconds=2 lcore = 7 eal_args=--in-memory --no-pci ``` --- app/test-dma-perf/benchmark.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-)
app/test-dma-perf/benchmark.c +4 -3
@@ -288,10 +288,11 @@ do_cpu_mem_copy(void *p)while (1 ) {for (i =0 ; i < nr_buf; i++) { + 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)
Signature · 1 line
2.34.1
Quoted 52 lines · Vipin Varghese
do_cpu_mem_copyuses DPDK APIrte_mbuf_data_iovato 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 becauserte_memcpyuses VA address and not PA.This fix invokes
rte_pktmbuf_mtodfor both src and dst.Bugzilla ID: 1269
Fixes 623dc9364dc6 ("app/dma-perf: introduce DMA performance test")Signed-off-by Vipin Varghese <[email protected]>Suggested-by Anoob Joseph <[email protected]>---
v2:
- suggest use ofpktmbuf_mtodfor both va and pa.tested for both va and pa
CMD:
PA: dpdk-test-dma-perf --iova-mode=pa -- --config test.ini
VA: dpdk-test-dma-perf --iova-mode=va -- --config test.ini
DC: dpdk-test-dma-perf --iova-mode=dc -- --config test.iniLog: fails for dc mode
EAL: invalid parameters for --iova-modetest.ini:
``` [case1] type=CPU_MEM_COPY mem_size=10 buf_size=64,8192,2,MUL src_numa_node=0 dst_numa_node=0 cache_flush=0 test_seconds=2 lcore = 7 eal_args=--in-memory --no-pci ``` --- app/test-dma-perf/benchmark.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-)app/test-dma-perf/benchmark.c +0
-0
app/test-dma-perf/benchmark.c do_cpu_mem_copy(void *p) · line 292
Quoted 5 lines
app/test-dma-perf/benchmark.c +2
-0@@ -288,10 +288,11 @@ do_cpu_mem_copy(void *p)while (1 ) {for (i =0 ; i < nr_buf; i++) { + void *src = rte_pktmbuf_mtod(dsts[i], void *); + void *dst = rte_pktmbuf_mtod(srcs[i], void *);
Use _const_ in fast path if src and dst in not changing as better optimization hint to compiler.
Quoted 7 lines
do_cpu_mem_copyuses DPDK APIrte_mbuf_data_iovato 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 becauserte_memcpyuses VA address and not PA.This fix invokes
rte_pktmbuf_mtodfor both src and dst.
Quoted 8 lines
Bugzilla ID: 1269
Fixes 623dc9364dc6 ("app/dma-perf: introduce DMA performance test")Signed-off-by Vipin Varghese <[email protected]>Suggested-by Anoob Joseph <[email protected]>
Hi,
Quoted 59 lines
-----Original Message-----
From: Vipin Varghese <[email protected]>
Sent: Wednesday, August 16, 2023 5:42 PM
To: [email protected]; [email protected]; [email protected]
Cc: [email protected]; Jiang, Cheng1 <[email protected]>; [email protected]
Subject: [PATCH v2] app/dma-perf: fix physical address seg-fault
do_cpu_mem_copyuses DPDK APIrte_mbuf_data_iovato 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 becauserte_memcpyuses VA address and not PA.This fix invokes
rte_pktmbuf_mtodfor both src and dst.Bugzilla ID: 1269
Fixes 623dc9364dc6 ("app/dma-perf: introduce DMA performance test")Signed-off-by Vipin Varghese <[email protected]>Suggested-by Anoob Joseph <[email protected]>---
v2:
- suggest use ofpktmbuf_mtodfor both va and pa.tested for both va and pa
CMD:
PA: dpdk-test-dma-perf --iova-mode=pa -- --config test.ini
VA: dpdk-test-dma-perf --iova-mode=va -- --config test.ini
DC: dpdk-test-dma-perf --iova-mode=dc -- --config test.iniLog: fails for dc mode
EAL: invalid parameters for --iova-modetest.ini:
``` [case1] type=CPU_MEM_COPY mem_size=10 buf_size=64,8192,2,MUL src_numa_node=0 dst_numa_node=0 cache_flush=0 test_seconds=2 lcore = 7 eal_args=--in-memory --no-pci ``` --- app/test-dma-perf/benchmark.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-)app/test-dma- renamed from app/test-dma-perf/benchmark.c +0
-0
perf/benchmark.cindex0601e0d171..1d1c9bde99100644
app/test-dma-perf/benchmark.c do_cpu_mem_copy(void *p) · line 293
Quoted 6 lines
app/test-dma-perf/benchmark.c +3
-0@@ -288,10 +288,11 @@ do_cpu_mem_copy(void *p)while (1 ) {for (i =0 ; i < nr_buf; i++) { + void *src = rte_pktmbuf_mtod(dsts[i], void *); + void *dst = rte_pktmbuf_mtod(srcs[i], void *); +
Thank you for fixing it.
Sorry that I missed the discussion earlier.
Thanks,
Cheng
[AMD Official Use Only - General]
Hi Jerrin,
Apologies for the delay, I missed on the comment
```
> for (i = 0; i < nr_buf; i++) {
> + void *src = rte_pktmbuf_mtod(dsts[i], void *);
> + void *dst = rte_pktmbuf_mtod(srcs[i], void *);
Use _const_ in fast path if src and dst in not changing as better optimization hint to compiler.
```Thanks for the suggestion, but may I ask this differently rte_memcpy is defined with always_inline and all places where src used is with const *. Hence I have different view there as setting const * for always_inline definition has the same effect too.
Quoted 87 lines
-----Original Message-----
From: Jiang, Cheng1 <[email protected]>
Sent: Thursday, September 21, 2023 7:58 AM
To: Varghese, Vipin <[email protected]>; [email protected]; [email protected]; [email protected]
Cc: Yigit, Ferruh <[email protected]>; [email protected]
Subject: RE: [PATCH v2] app/dma-perf: fix physical address seg-faultCaution: This message originated from an External Source. Use proper caution when opening attachments, clicking links, or responding.
Hi,
Quoted 59 lines
-----Original Message-----
From: Vipin Varghese <[email protected]>
Sent: Wednesday, August 16, 2023 5:42 PM
To: [email protected]; [email protected]; [email protected]
Cc: [email protected]; Jiang, Cheng1 <[email protected]>; [email protected]
Subject: [PATCH v2] app/dma-perf: fix physical address seg-fault
do_cpu_mem_copyuses DPDK APIrte_mbuf_data_iovato 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 becauserte_memcpyuses VA address and not PA.This fix invokes
rte_pktmbuf_mtodfor both src and dst.Bugzilla ID: 1269
Fixes 623dc9364dc6 ("app/dma-perf: introduce DMA performance test")Signed-off-by Vipin Varghese <[email protected]>Suggested-by Anoob Joseph <[email protected]>---
v2:
- suggest use ofpktmbuf_mtodfor both va and pa.tested for both va and pa
CMD:
PA: dpdk-test-dma-perf --iova-mode=pa -- --config test.ini
VA: dpdk-test-dma-perf --iova-mode=va -- --config test.ini
DC: dpdk-test-dma-perf --iova-mode=dc -- --config test.iniLog: fails for dc mode
EAL: invalid parameters for --iova-modetest.ini:
``` [case1] type=CPU_MEM_COPY mem_size=10 buf_size=64,8192,2,MUL src_numa_node=0 dst_numa_node=0 cache_flush=0 test_seconds=2 lcore = 7 eal_args=--in-memory --no-pci ``` --- app/test-dma-perf/benchmark.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-)app/test-dma- renamed from app/test-dma-perf/benchmark.c +0
-0
perf/benchmark.cindex0601e0d171..1d1c9bde99100644app/test-dma-perf/benchmark.c do_cpu_mem_copy(void *p) · line 293
Quoted 6 lines
app/test-dma-perf/benchmark.c +3
-0@@ -288,10 +288,11 @@ do_cpu_mem_copy(void *p)while (1 ) {for (i =0 ; i < nr_buf; i++) { + void *src = rte_pktmbuf_mtod(dsts[i], void *); + void *dst = rte_pktmbuf_mtod(srcs[i], void *); +Thank you for fixing it.
Sorry that I missed the discussion earlier.Reviewed-by Cheng Jiang <[email protected]>Thanks,
Cheng
Quoted 15 lines · Vipin
[AMD Official Use Only - General]
Hi Jerrin,
Apologies for the delay, I missed on the comment
``` > for (i = 0; i < nr_buf; i++) { > + void *src = rte_pktmbuf_mtod(dsts[i], void *); > + void *dst = rte_pktmbuf_mtod(srcs[i], void *); Use _const_ in fast path if src and dst in not changing as better optimization hint to compiler. ```
Quoted 1 line
Thanks for the suggestion, but may I ask this differently
rte_memcpyis defined withalways_inlineand all places where src used is withconst *. Hence I have different view there assetting const * for always_inline definition has the same effect too.
Yeah, most likely. However, Is the above behavior is documented in gcc/clang? if not, the compiler is free to change as it deemed to fit based on the register allocation and optimization flags etc.
PATCH v3 1/1 app/dma-perf: fix physical address seg-fault
In reply to Vipin Varghesedo_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
---
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(-)
app/test-dma-perf/benchmark.c +4 -3
@@ -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)
Signature · 1 line
2.34.1
Quoted 8 lines · Vipin Varghese
do_cpu_mem_copyuses DPDK APIrte_mbuf_data_iovato 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 becauserte_memcpyuses VA address and not PA.This fix invokes
rte_pktmbuf_mtodfor both src and dst.Bugzilla ID: 1269
Quoted 9 lines
Fixes 623dc9364dc6 ("app/dma-perf: introduce DMA performance test")Signed-off-by Vipin Varghese <[email protected]>Suggested-by Anoob Joseph <[email protected]>Suggested-by Jerin Jacob <[email protected]>
Thomas Monjalon
Applied24/10/2023 04:16, lihuisong (C):
Quoted 13 lines · Vipin Varghese
Quoted 11 lines
do_cpu_mem_copyuses DPDK APIrte_mbuf_data_iovato 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 becauserte_memcpyuses VA address and not PA.This fix invokes
rte_pktmbuf_mtodfor both src and dst.Bugzilla ID: 1269
Fixes 623dc9364dc6 ("app/dma-perf: introduce DMA performance test")
Quoted 7 lines
Quoted 6 lines
Signed-off-by Vipin Varghese <[email protected]>Suggested-by Anoob Joseph <[email protected]>Suggested-by Jerin Jacob <[email protected]>Acked-by Huisong Li <[email protected]>
Adding some missing acks.
Applied, thanks.