On 02/11/2020 08:06, Barry Song wrote:
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

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

Cc: Joerg Roedel <[email protected]>
Cc: Will Deacon <[email protected]>
Cc: Shuah Khan <[email protected]>
Cc: Christoph Hellwig <[email protected]>
Cc: Marek Szyprowski <[email protected]>
Cc: Robin Murphy <[email protected]>
Signed-off-by: Barry Song <[email protected]>
---
-v3:
   * fix build issues reported by 0day kernel test robot
-v2:
   * add PCI support; v1 supported platform devices only
   * replace ssleep by msleep_interruptible() to permit users to exit
     benchmark before it is completed
   * many changes according to Robin's suggestions, thanks! Robin
     - add standard deviation output to reflect the worst case
     - check users' parameters strictly like the number of threads
     - make cache dirty before dma_map
     - fix unpaired dma_map_page and dma_unmap_single;
     - remove redundant "long long" before ktime_to_ns();
     - use devm_add_action()

  kernel/dma/Kconfig         |   8 +
  kernel/dma/Makefile        |   1 +
  kernel/dma/map_benchmark.c | 296 +++++++++++++++++++++++++++++++++++++
  3 files changed, 305 insertions(+)
  create mode 100644 kernel/dma/map_benchmark.c

diff --git a/kernel/dma/Kconfig b/kernel/dma/Kconfig
index c99de4a21458..949c53da5991 100644
--- a/kernel/dma/Kconfig
+++ b/kernel/dma/Kconfig
@@ -225,3 +225,11 @@ config DMA_API_DEBUG_SG
          is technically out-of-spec.
If unsure, say N.
+
+config DMA_MAP_BENCHMARK
+       bool "Enable benchmarking of streaming DMA mapping"
+       help
+         Provides /sys/kernel/debug/dma_map_benchmark that helps with testing
+         performance of dma_(un)map_page.

Since this is a driver, any reason for which it cannot be loadable? If so, it seems any functionality would depend on DEBUG FS, I figure that's just how we work for debugfs.

Thanks,
John

+
+         See tools/testing/selftests/dma/dma_map_benchmark.c
diff --git a/kernel/dma/Makefile b/kernel/dma/Makefile
index dc755ab68aab..7aa6b26b1348 100644
--- a/kernel/dma/Makefile
+++ b/kernel/dma/Makefile
_______________________________________________
iommu mailing list
[email protected]
https://lists.linuxfoundation.org/mailman/listinfo/iommu

Reply via email to