From: Qinxin Xia <xiaqinxin@huawei.com>
To: Barry Song <21cnbao@gmail.com>
Cc: <yangyicong@huawei.com>, <hch@lst.de>, <iommu@lists.linux.dev>,
<jonathan.cameron@huawei.com>, <prime.zeng@huawei.com>,
<fanghao11@huawei.com>, <linux-kernel@vger.kernel.org>,
<linuxarm@huawei.com>
Subject: Re: [PATCH v2 4/4] dma mapping benchmark:add support for dma_map_sg
Date: Wed, 7 May 2025 17:18:41 +0800 [thread overview]
Message-ID: <ddee8f35-0bf9-44e3-b84d-f1a833032da5@huawei.com> (raw)
In-Reply-To: <CAGsJ_4z9oYtCkdXqk=s+F4ZFrjCan+-AuGqRQDeQcXcswPzaHw@mail.gmail.com>
在 2025/5/7 10:44, Barry Song 写道:
> On Tue, May 6, 2025 at 3:01 PM Qinxin Xia <xiaqinxin@huawei.com> wrote:
>> Support 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
>>
>> Signed-off-by: Qinxin Xia <xiaqinxin@huawei.com>
> Either merge this into the previous patch or use the correct prefix in the
> subject to differentiate patch 3 from patch 4. For example: selftests/dma
Okay, I'll fix this in the next version.
Thanks!
>> ---
>> 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..036ddb5ac862 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_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);
>> --
>> 2.33.0
>>
> Thanks
> Barry
next prev parent reply other threads:[~2025-05-07 9:18 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-05-06 3:00 [PATCH v2 0/4] dma mapping benchmark: add " Qinxin Xia
2025-05-06 3:00 ` [PATCH v2 1/4] dma-mapping: benchmark: Add padding to ensure uABI remained consistent Qinxin Xia
2025-05-07 1:52 ` Barry Song
2025-05-07 2:08 ` Barry Song
2025-05-07 9:10 ` Qinxin Xia
2025-05-07 9:09 ` Qinxin Xia
2025-05-06 3:00 ` [PATCH v2 2/4] dma mapping benchmark: modify the framework to adapt to more map modes Qinxin Xia
2025-05-07 2:30 ` Barry Song
2025-05-07 9:14 ` Qinxin Xia
2025-05-06 3:00 ` [PATCH v2 3/4] dma-mapping: benchmark: add support for dma_map_sg Qinxin Xia
2025-05-07 2:39 ` Barry Song
2025-05-07 9:17 ` Qinxin Xia
2025-05-06 3:01 ` [PATCH v2 4/4] dma mapping benchmark:add " Qinxin Xia
2025-05-07 2:44 ` Barry Song
2025-05-07 9:18 ` Qinxin Xia [this message]
2025-05-06 12:20 ` [PATCH v2 0/4] dma mapping benchmark: add " ALOK TIWARI
2025-05-06 12:25 ` Qinxin Xia
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=ddee8f35-0bf9-44e3-b84d-f1a833032da5@huawei.com \
--to=xiaqinxin@huawei.com \
--cc=21cnbao@gmail.com \
--cc=fanghao11@huawei.com \
--cc=hch@lst.de \
--cc=iommu@lists.linux.dev \
--cc=jonathan.cameron@huawei.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linuxarm@huawei.com \
--cc=prime.zeng@huawei.com \
--cc=yangyicong@huawei.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®