From nobody Mon Feb 9 15:08:40 2026 Received: from canpmsgout08.his.huawei.com (canpmsgout08.his.huawei.com [113.46.200.223]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 2979F32D44B for ; Mon, 22 Dec 2025 15:33:22 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=113.46.200.223 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1766417604; cv=none; b=E8pHiHBjzuk9mjtUt3DdBps4P8r6ttiFluXrcePOkO4Z87plmb9oqSSUqZY6MNzU7j495oF24WqHDO1o3QOHDx5ZsQzIBLsqgH33lEhGw5pgC1FVhSDUTsfE+88yfw8Z/XlZTw4zEavXCeHzViVbYp4ILoMDmNzg2CRKunLYB7Y= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1766417604; c=relaxed/simple; bh=VNXPhfrOvZBh1UB58HP3yaLCp6REoMsvb4uoZRGnOn8=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=P6efIFSudcBqq2y22c59bpNi7gzAWQ8V4eMY/NZWdXJmJNilC3wFx3SkVgBqk4+wxE13oWWN8NO+z+l/c1A8rIgbtfA+KwGNzoa/tuEZ+62H7inI5yJotRR1K1DPrsiG8AAGk8hBs/4GNpCpGDPEp5lOsPc7qJqf+CIxS8a1BI0= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=huawei.com; spf=pass smtp.mailfrom=huawei.com; dkim=pass (1024-bit key) header.d=huawei.com header.i=@huawei.com header.b=Oi6rC7rE; arc=none smtp.client-ip=113.46.200.223 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=huawei.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=huawei.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=huawei.com header.i=@huawei.com header.b="Oi6rC7rE" dkim-signature: v=1; a=rsa-sha256; d=huawei.com; s=dkim; c=relaxed/relaxed; q=dns/txt; h=From; bh=9B2/v5pOCvFdYbTALgJXOXDiEuIrsZcDluGt7zDPl1M=; b=Oi6rC7rEfC6ZtN0yjn7t5mZvrDIYZ4U5rXs19elbCq9QBym2ezQZOhDZlaXwfkiDTWR6lKAOr LF6lCCoscOJu144IVmYA1QcrL81UpVtZsQbYlaM26L+CVsJykzKn4lYR8eWjNDQmCj362Ru4TxP AeiNNsAOUV5vPguzOgFi4+g= Received: from mail.maildlp.com (unknown [172.19.163.15]) by canpmsgout08.his.huawei.com (SkyGuard) with ESMTPS id 4dZhsc6WywzmV7t; Mon, 22 Dec 2025 23:30:12 +0800 (CST) Received: from kwepemj200003.china.huawei.com (unknown [7.202.194.15]) by mail.maildlp.com (Postfix) with ESMTPS id 66C9840565; Mon, 22 Dec 2025 23:33:19 +0800 (CST) Received: from localhost.huawei.com (10.90.31.46) by kwepemj200003.china.huawei.com (7.202.194.15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1544.11; Mon, 22 Dec 2025 23:33:18 +0800 From: Qinxin Xia To: <21cnbao@gmail.com>, , , CC: , , , , , Barry Song Subject: [PATCH v5 3/3] tools/dma: Add dma_map_sg support Date: Mon, 22 Dec 2025 23:32:46 +0800 Message-ID: <20251222153246.2220659-4-xiaqinxin@huawei.com> X-Mailer: git-send-email 2.33.0 In-Reply-To: <20251222153246.2220659-1-xiaqinxin@huawei.com> References: <20251222153246.2220659-1-xiaqinxin@huawei.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-ClientProxiedBy: kwepems100002.china.huawei.com (7.221.188.206) To kwepemj200003.china.huawei.com (7.202.194.15) Content-Type: text/plain; charset="utf-8" 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=3D0, DMA_MAP_BENCH_SG_MODE:=3D1 (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 Signed-off-by: Qinxin Xia --- tools/dma/dma_map_benchmark.c | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/tools/dma/dma_map_benchmark.c b/tools/dma/dma_map_benchmark.c index dd0ed528e6df..39102330a43f 100644 --- a/tools/dma/dma_map_benchmark.c +++ b/tools/dma/dma_map_benchmark.c @@ -26,6 +26,8 @@ int main(int argc, char **argv) int fd, opt; /* default single thread, run 20 seconds on NUMA_NO_NODE */ int threads =3D 1, seconds =3D 20, node =3D -1; + /* default single map mode */ + int map_mode =3D DMA_MAP_BENCH_SINGLE_MODE; /* default dma mask 32bit, bidirectional DMA */ int bits =3D 32, xdelay =3D 0, dir =3D DMA_MAP_BIDIRECTIONAL; /* default granule 1 PAGESIZE */ @@ -33,7 +35,7 @@ int main(int argc, char **argv) =20 int cmd =3D DMA_MAP_BENCHMARK; =20 - while ((opt =3D getopt(argc, argv, "t:s:n:b:d:x:g:")) !=3D -1) { + while ((opt =3D getopt(argc, argv, "t:s:n:b:d:x:g:m:")) !=3D -1) { switch (opt) { case 't': threads =3D atoi(optarg); @@ -56,11 +58,20 @@ int main(int argc, char **argv) case 'g': granule =3D atoi(optarg); break; + case 'm': + map_mode =3D atoi(optarg); + break; default: return -1; } } =20 + if (map_mode < 0 || map_mode >=3D DMA_MAP_BENCH_MODE_MAX) { + fprintf(stderr, "invalid map mode, SINGLE_MODE:%d, SG_MODE: %d\n", + DMA_MAP_BENCH_SINGLE_MODE, DMA_MAP_BENCH_SG_MODE); + exit(1); + } + if (threads <=3D 0 || threads > DMA_MAP_MAX_THREADS) { fprintf(stderr, "invalid number of threads, must be in 1-%d\n", DMA_MAP_MAX_THREADS); @@ -110,13 +121,15 @@ int main(int argc, char **argv) map.dma_dir =3D dir; map.dma_trans_ns =3D xdelay; map.granule =3D granule; + map.map_mode =3D map_mode; =20 if (ioctl(fd, cmd, &map)) { perror("ioctl"); exit(1); } =20 - printf("dma mapping benchmark: threads:%d seconds:%d node:%d dir:%s granu= le: %d\n", + printf("dma mapping mode: %d\n", map_mode); + printf("dma mapping benchmark: threads:%d seconds:%d node:%d dir:%s granu= le/sg_nents: %d\n", threads, seconds, node, directions[dir], granule); printf("average map latency(us):%.1f standard deviation:%.1f\n", map.avg_map_100ns/10.0, map.map_stddev/10.0); --=20 2.33.0