lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20250616111644.0000565b@huawei.com>
Date: Mon, 16 Jun 2025 11:16:44 +0100
From: Jonathan Cameron <Jonathan.Cameron@...wei.com>
To: Qinxin Xia <xiaqinxin@...wei.com>
CC: <21cnbao@...il.com>, <m.szyprowski@...sung.com>, <robin.murphy@....com>,
	<yangyicong@...wei.com>, <hch@....de>, <iommu@...ts.linux.dev>,
	<prime.zeng@...wei.com>, <fanghao11@...wei.com>,
	<linux-kernel@...r.kernel.org>, <linuxarm@...wei.com>
Subject: Re: [RESEND PATCH v4 4/4] selftests/dma: Add dma_map_sg support for
 dma_map_benchmark

On Sat, 14 Jun 2025 22:34:54 +0800
Qinxin Xia <xiaqinxin@...wei.com> wrote:

> 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).

shown

> 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@...alhost]# ./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@...alhost]# ./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@...nel.org>
> Signed-off-by: Qinxin Xia <xiaqinxin@...wei.com>
Looks fine to me.
Reviewed-by: Jonathan Cameron <jonathan.cameron@...wei.com>

> ---
>  tools/testing/selftests/dma/dma_map_benchmark.c | 16 ++++++++++++++--
>  1 file changed, 14 insertions(+), 2 deletions(-)
> 
> diff --git a/tools/testing/selftests/dma/dma_map_benchmark.c b/tools/testing/selftests/dma/dma_map_benchmark.c
> index b12f1f9babf8..c37cbc7e8766 100644
> --- a/tools/testing/selftests/dma/dma_map_benchmark.c
> +++ b/tools/testing/selftests/dma/dma_map_benchmark.c
> @@ -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_BENCH_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_BENCH_MODE_MAX) {
> +		fprintf(stderr, "invalid map mode, DMA_MAP_BENCH_SINGLE_MODE:%d, DMA_MAP_BENCH_SG_MODE:%d\n",
> +			DMA_MAP_BENCH_SINGLE_MODE, DMA_MAP_BENCH_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);


Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ