Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

tools/dma: Add dma_map_sg support

Support for dma_map_sg, add option '-m' to distinguish mode.

i) Users can set option '-m' to select mode:
DMA_MAP_BENCH_SINGLE_MODE=0, DMA_MAP_BENCH_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_BENCH_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_BENCH_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

Reviewed-by: Barry Song <baohua@kernel.org>
Signed-off-by: Qinxin Xia <xiaqinxin@huawei.com>
Signed-off-by: Marek Szyprowski <m.szyprowski@samsung.com>
Link: https://lore.kernel.org/r/20260225093800.3625054-4-xiaqinxin@huawei.com

authored by

Qinxin Xia and committed by
Marek Szyprowski
a54302cc a8d14dd6

+20 -3
+20 -3
tools/dma/dma_map_benchmark.c
··· 20 20 "FROM_DEVICE", 21 21 }; 22 22 23 + static char *mode[] = { 24 + "SINGLE_MODE", 25 + "SG_MODE", 26 + }; 27 + 23 28 int main(int argc, char **argv) 24 29 { 25 30 struct map_benchmark map; 26 31 int fd, opt; 27 32 /* default single thread, run 20 seconds on NUMA_NO_NODE */ 28 33 int threads = 1, seconds = 20, node = -1; 34 + /* default single map mode */ 35 + int map_mode = DMA_MAP_BENCH_SINGLE_MODE; 29 36 /* default dma mask 32bit, bidirectional DMA */ 30 37 int bits = 32, xdelay = 0, dir = DMA_MAP_BIDIRECTIONAL; 31 38 /* default granule 1 PAGESIZE */ ··· 40 33 41 34 int cmd = DMA_MAP_BENCHMARK; 42 35 43 - while ((opt = getopt(argc, argv, "t:s:n:b:d:x:g:")) != -1) { 36 + while ((opt = getopt(argc, argv, "t:s:n:b:d:x:g:m:")) != -1) { 44 37 switch (opt) { 45 38 case 't': 46 39 threads = atoi(optarg); ··· 63 56 case 'g': 64 57 granule = atoi(optarg); 65 58 break; 59 + case 'm': 60 + map_mode = atoi(optarg); 61 + break; 66 62 default: 67 63 return -1; 68 64 } 65 + } 66 + 67 + if (map_mode < 0 || map_mode >= DMA_MAP_BENCH_MODE_MAX) { 68 + fprintf(stderr, "invalid map mode, SINGLE_MODE:%d, SG_MODE: %d\n", 69 + DMA_MAP_BENCH_SINGLE_MODE, DMA_MAP_BENCH_SG_MODE); 70 + exit(1); 69 71 } 70 72 71 73 if (threads <= 0 || threads > DMA_MAP_MAX_THREADS) { ··· 126 110 map.dma_dir = dir; 127 111 map.dma_trans_ns = xdelay; 128 112 map.granule = granule; 113 + map.map_mode = map_mode; 129 114 130 115 if (ioctl(fd, cmd, &map)) { 131 116 perror("ioctl"); 132 117 exit(1); 133 118 } 134 119 135 - printf("dma mapping benchmark: threads:%d seconds:%d node:%d dir:%s granule: %d\n", 136 - threads, seconds, node, directions[dir], granule); 120 + printf("dma mapping benchmark(%s): threads:%d seconds:%d node:%d dir:%s granule:%d\n", 121 + mode[map_mode], threads, seconds, node, directions[dir], granule); 137 122 printf("average map latency(us):%.1f standard deviation:%.1f\n", 138 123 map.avg_map_100ns/10.0, map.map_stddev/10.0); 139 124 printf("average unmap latency(us):%.1f standard deviation:%.1f\n",