dma mapping benchmark: add support for dma_map_sg
Subsystems (3)
Qinxin Xia
maintainercover dma mapping benchmark: add support for dma_map_sg
Modify the framework to adapt to more map modes, add benchmark support for dma_map_sg, and add support sg map mode in ioctl.
The result:
[root@localhost]# ./dma_map_benchmark -m 1 -g 8 -t 8 -s 30 -d 2 dma mapping mode: DMA_MAP_SG_MODE dma mapping benchmark: threads:8 seconds:30 node:-1 dir:FROM_DEVICE granule/sg_nents: 8 average map latency(us):1.4 standard deviation:0.3 average unmap latency(us):1.3 standard deviation:0.3 [root@localhost]# ./dma_map_benchmark -m 0 -g 8 -t 8 -s 30 -d 2 dma mapping mode: DMA_MAP_SINGLE_MODE dma mapping benchmark: threads:8 seconds:30 node:-1 dir:FROM_DEVICE granule/sg_nents: 8 average map latency(us):1.0 standard deviation:0.3 average unmap latency(us):1.3 standard deviation:0.5
---
Qinxin Xia (3):
dma-mapping: benchmark: modify the framework to adapt to more map
modes
dma-mapping: benchmark: add support for dma_map_sg dma-mapping benchmark:add support for dma_map_sg
include/linux/map_benchmark.h | 7 + kernel/dma/map_benchmark.c | 224 ++++++++++++++++-- .../testing/selftests/dma/dma_map_benchmark.c | 16 +- 3 files changed, 222 insertions(+), 25 deletions(-)
--
2.33.0
Qinxin Xia
maintainerPATCH 1/3 dma mapping benchmark: modify the framework to adapt to more map modes
In this patch map_benchmark abstract in four interface: prepare, unprepare, do_map, do_unmap. When there's a new mode to add, need four steps:
1) Add the mode in map_benchmark.h
2) Defines the mode param, like struct dma_xxx_map_param, and this object will be return in prepare and as input parameter in other ops;
3) Defines the ops functions:prepare, unprepare, do_map, do_unmap.
4) Add the new mode in dma_map_benchmark_ops.
--- include/linux/map_benchmark.h | 6 ++ kernel/dma/map_benchmark.c | 122 +++++++++++++++++++++++++++------- 2 files changed, 105 insertions(+), 23 deletions(-)
include/linux/map_benchmark.h +6 -0
@@ -15,6 +15,11 @@#define DMA_MAP_TO_DEVICE 1#define DMA_MAP_FROM_DEVICE 2 +enum { +DMA_MAP_SINGLE_MODE , +DMA_MAP_MODE_MAX +}; +struct map_benchmark {__u64 avg_map_100ns;/* average map latency in 100ns */ __u64 map_stddev;/* standard deviation of map latency */
@@ -27,5 +32,6 @@ struct map_benchmark {__u32 dma_dir;/* DMA data direction */ __u32 dma_trans_ns;/* time for DMA transmission in ns */ __u32 granule;/* how many PAGE_SIZE will do map/unmap once a time */ + __u8 map_mode; /* the mode of dma map */ };#endif /* _KERNEL_DMA_BENCHMARK_H */
kernel/dma/map_benchmark.c +99 -23
165 lines not on this page · raw message
Signature · 1 line
2.33.0
Qinxin Xia
maintainerPATCH 2/3 dma-mapping: benchmark: add support for dma_map_sg
In reply to Qinxin XiaSupport for dma scatter-gather mapping and is intended for testing mapping performance. It achieves by introducing the dma_sg_map_param structure and related functions, which enable the implementation of scatter-gather mapping preparation, mapping, and unmapping operations. Additionally, the dma_map_benchmark_ops array is updated to include operations for scatter-gather mapping. This commit aims to provide a wider range of mapping performance test to cater to different scenarios.
--- include/linux/map_benchmark.h | 1 + kernel/dma/map_benchmark.c | 102 ++++++++++++++++++++++++++++++++++ 2 files changed, 103 insertions(+)
include/linux/map_benchmark.h +1 -0
@@ -17,6 +17,7 @@enum {DMA_MAP_SINGLE_MODE , +DMA_MAP_SG_MODE ,DMA_MAP_MODE_MAX };
kernel/dma/map_benchmark.c +102 -0
116 lines not on this page · raw message
Signature · 1 line
2.33.0
Qinxin Xia
maintainerPATCH 3/3 dma mapping benchmark:add support for dma_map_sg
In reply to Qinxin XiaSupport for dma_map_sg, add option '-m' to distinguish mode.
i) Users can set option '-m' to select mode:
DMA_MAP_SINGLE_MODE=0, DMA_MAP_SG_MODE:=1
(The mode is also show in the test result).
ii) Users can set option '-g' to set sg_nents
(total count of entries in scatterlist)
the maximum number is 1024. Each of sg buf size is PAGE_SIZE. e.g
[root@localhost]# ./dma_map_benchmark -m 1 -g 8 -t 8 -s 30 -d 2 dma mapping mode: DMA_MAP_SG_MODE
dma mapping benchmark: threads:8 seconds:30 node:-1 dir:FROM_DEVICE granule/sg_nents: 8
average map latency(us):1.4 standard deviation:0.3 average unmap latency(us):1.3 standard deviation:0.3 [root@localhost]# ./dma_map_benchmark -m 0 -g 8 -t 8 -s 30 -d 2 dma mapping mode: DMA_MAP_SINGLE_MODE
dma mapping benchmark: threads:8 seconds:30 node:-1 dir:FROM_DEVICE granule/sg_nents: 8
average map latency(us):1.0 standard deviation:0.3 average unmap latency(us):1.3 standard deviation:0.5
--- tools/testing/selftests/dma/dma_map_benchmark.c | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-)
tools/testing/selftests/dma/dma_map_benchmark.c +14 -2
@@ -27,6 +27,7 @@ int main(int argc, char **argv)int fd, opt;/* default single thread, run 20 seconds on NUMA_NO_NODE */ int threads =1 , seconds =20 , node =-1 ; +int map_mode =DMA_MAP_SINGLE_MODE ;/* default dma mask 32bit, bidirectional DMA */ int bits =32 , xdelay =0 , dir =DMA_MAP_BIDIRECTIONAL ;/* default granule 1 PAGESIZE */
@@ -34,7 +35,7 @@ int main(int argc, char **argv)int cmd =DMA_MAP_BENCHMARK ; -while ((opt =getopt (argc, argv,"t:s:n:b:d:x:g:" )) !=-1 ) { +while ((opt =getopt (argc, argv,"t:s:n:b:d:x:g:m:" )) !=-1 ) {switch (opt) {case 't' : threads =atoi (optarg);
@@ -57,11 +58,20 @@ int main(int argc, char **argv)case 'g' : granule =atoi (optarg);break ; +case 'm' : + map_mode =atoi (optarg); +break ;default :return -1 ; } } +if (map_mode >=DMA_MAP_MODE_MAX ) { +fprintf (stderr,"invalid map mode, DMA_MAP_SINGLE_MODE:%d, DMA_MAP_SG_MODE:%d\n" , +DMA_MAP_SINGLE_MODE ,DMA_MAP_SG_MODE ); +exit (1 ); + } +if (threads <=0 || threads >DMA_MAP_MAX_THREADS ) {fprintf (stderr,"invalid number of threads, must be in 1-%d\n" ,DMA_MAP_MAX_THREADS );
@@ -111,13 +121,15 @@ int main(int argc, char **argv) map.dma_dir = dir; map.dma_trans_ns = xdelay; map.granule = granule; + map.map_mode = map_mode;if (ioctl (fd, cmd, &map)) {perror ("ioctl" );exit (1 ); } -printf ("dma mapping benchmark: threads:%d seconds:%d node:%d dir:%s granule: %d\n" , +printf ("dma mapping mode: %d\n" , map_mode); +printf ("dma mapping benchmark: threads:%d seconds:%d node:%d dir:%s granule/sg_nents: %d\n" , threads, seconds, node, dir[directions], granule);printf ("average map latency(us):%.1f standard deviation:%.1f\n" , map.avg_map_100ns/10.0 , map.map_stddev/10.0 );
Signature · 1 line
2.33.0