> -----Original Message----- > From: John Garry > Sent: Tuesday, November 10, 2020 9:39 PM > To: Song Bao Hua (Barry Song) <song.bao.hua@xxxxxxxxxxxxx>; > iommu@xxxxxxxxxxxxxxxxxxxxxxxxxx; hch@xxxxxx; robin.murphy@xxxxxxx; > m.szyprowski@xxxxxxxxxxx > Cc: linux-kselftest@xxxxxxxxxxxxxxx; Will Deacon <will@xxxxxxxxxx>; Joerg > Roedel <joro@xxxxxxxxxx>; Linuxarm <linuxarm@xxxxxxxxxx>; xuwei (O) > <xuwei5@xxxxxxxxxx>; Shuah Khan <shuah@xxxxxxxxxx> > Subject: Re: [PATCH v3 1/2] dma-mapping: add benchmark support for > streaming DMA APIs > > On 10/11/2020 08:10, Song Bao Hua (Barry Song) wrote: > > Hello Robin, Christoph, > > Any further comment? John suggested that "depends on DEBUG_FS" should > be added in Kconfig. > > I am collecting more comments to send v4 together with fixing this minor > issue :-) > > > > Thanks > > Barry > > > >> -----Original Message----- > >> From: Song Bao Hua (Barry Song) > >> Sent: Monday, November 2, 2020 9:07 PM > >> To: iommu@xxxxxxxxxxxxxxxxxxxxxxxxxx; hch@xxxxxx; > robin.murphy@xxxxxxx; > >> m.szyprowski@xxxxxxxxxxx > >> Cc: Linuxarm <linuxarm@xxxxxxxxxx>; linux-kselftest@xxxxxxxxxxxxxxx; > xuwei > >> (O) <xuwei5@xxxxxxxxxx>; Song Bao Hua (Barry Song) > >> <song.bao.hua@xxxxxxxxxxxxx>; Joerg Roedel <joro@xxxxxxxxxx>; Will > Deacon > >> <will@xxxxxxxxxx>; Shuah Khan <shuah@xxxxxxxxxx> > >> Subject: [PATCH v3 1/2] dma-mapping: add benchmark support for > streaming > >> DMA APIs > >> > >> Nowadays, there are increasing requirements to benchmark the > performance > >> of dma_map and dma_unmap particually while the device is attached to an > >> IOMMU. > >> > >> This patch enables the support. Users can run specified number of threads > to > >> do dma_map_page and dma_unmap_page on a specific NUMA node with > the > >> specified duration. Then dma_map_benchmark will calculate the average > >> latency for map and unmap. > >> > >> A difficulity for this benchmark is that dma_map/unmap APIs must run on a > >> particular device. Each device might have different backend of IOMMU or > >> non-IOMMU. > >> > >> So we use the driver_override to bind dma_map_benchmark to a particual > >> device by: > >> For platform devices: > >> echo dma_map_benchmark > > /sys/bus/platform/devices/xxx/driver_override > >> echo xxx > /sys/bus/platform/drivers/xxx/unbind > >> echo xxx > /sys/bus/platform/drivers/dma_map_benchmark/bind > >> > > Hi Barry, > > >> For PCI devices: > >> echo dma_map_benchmark > > >> /sys/bus/pci/devices/0000:00:01.0/driver_override > >> echo 0000:00:01.0 > /sys/bus/pci/drivers/xxx/unbind echo 0000:00:01.0 > > >> /sys/bus/pci/drivers/dma_map_benchmark/bind > > Do we need to check if the device to which we attach actually has DMA > mapping capability? Hello John, I'd like to think checking this here would be overdesign. We just give users the freedom to bind any device they care about to the benchmark driver. Usually that means a real hardware either behind an IOMMU or through a direct mapping. if for any reason users put a wrong "device", that is the choice of users. Anyhow, the below code will still handle it properly and users will get a report in which everything is zero. +static int map_benchmark_thread(void *data) +{ ... + dma_addr = dma_map_single(map->dev, buf, PAGE_SIZE, DMA_BIDIRECTIONAL); + if (unlikely(dma_mapping_error(map->dev, dma_addr))) { + pr_err("dma_map_single failed on %s\n", dev_name(map->dev)); + ret = -ENOMEM; + goto out; + } ... +} > > >> > >> Cc: Joerg Roedel <joro@xxxxxxxxxx> > >> Cc: Will Deacon <will@xxxxxxxxxx> > >> Cc: Shuah Khan <shuah@xxxxxxxxxx> > >> Cc: Christoph Hellwig <hch@xxxxxx> > >> Cc: Marek Szyprowski <m.szyprowski@xxxxxxxxxxx> > >> Cc: Robin Murphy <robin.murphy@xxxxxxx> > >> Signed-off-by: Barry Song <song.bao.hua@xxxxxxxxxxxxx> > >> --- > > Thanks, > John Thanks Barry