redhat/configs: enable DMA map benchmark
JIRA: https://issues.redhat.com/browse/RHEL-592 Upstream Status: RHEL-only
Overview
The DMA map benchmark is implemented by the kernel/dma/map_benchmark.c driver and controlled by CONFIG_DMA_MAP_BENCHMARK. It can be bound explicitly to any given platform or PCI device, and allows userspace to measure DMA map/unmap performance.
Enabling this driver helps verify DMA map/unmap sanity at a basic level, and also detect notable performance degradation.
The driver cannot be built as a standalone module because it depends on unexported symbols, so the only option is to enable it as a built-in module.
Unless a device is bound, the driver has minimal impact over the kernel. During initialization, the driver just registers itself as a PCI driver and a platform driver, and does nothing else. The kernel is 4K larger with the driver included.
Kernel size impact
The bloat-o-meter
output below shows the kernel size impact for both
the regular kernel and the debug kernel.
kernel-automotive-5.14.0-aarch64.config
# ./scripts/bloat-o-meter vmlinux.original vmlinux.dma_map_benchmark
add/remove: 13/1 grow/shrink: 4/0 up/down: 4085/-8 (4077)
Function old new delta
do_map_benchmark - 820 +820
map_benchmark_thread - 688 +688
map_benchmark_ioctl - 688 +688
_entry 259160 259600 +440
map_benchmark_pci_driver - 384 +384
map_benchmark_fops - 272 +272
map_benchmark_platform_driver - 200 +200
__map_benchmark_probe - 168 +168
map_benchmark_init - 112 +112
_entry_ptr 47120 47200 +80
__func__ 98819 98899 +80
map_benchmark_cleanup - 48 +48
map_benchmark_remove_debugfs - 32 +32
map_benchmark_platform_probe - 32 +32
map_benchmark_pci_probe - 32 +32
e843419@01ca_00003429_13b0 - 8 +8
__already_done 579 580 +1
e843419@0a01_00012fa1_608 8 - -8
Total: Before=32690567, After=32694644, chg +0.01%
kernel-automotive-5.14.0-aarch64-debug.config
# ./scripts/bloat-o-meter vmlinux.original vmlinux.dma_map_benchmark
add/remove: 13/2 grow/shrink: 4/0 up/down: 4221/-16 (4205)
Function old new delta
do_map_benchmark - 772 +772
map_benchmark_ioctl - 736 +736
map_benchmark_thread - 728 +728
map_benchmark_pci_driver - 480 +480
_entry 275792 276232 +440
map_benchmark_fops - 272 +272
map_benchmark_platform_driver - 200 +200
__map_benchmark_probe - 168 +168
map_benchmark_init - 112 +112
_entry_ptr 50144 50224 +80
__func__ 112507 112587 +80
map_benchmark_cleanup - 48 +48
map_benchmark_remove_debugfs - 32 +32
map_benchmark_platform_probe - 32 +32
map_benchmark_pci_probe - 32 +32
e843419@05de_0000a986_458 - 8 +8
__already_done 595 596 +1
e843419@02bd_000056ba_504 8 - -8
e843419@0247_000046c0_6258 8 - -8
Total: Before=90963355, After=90967560, chg +0.00%
Basic usage / examples
The commit that introduced the userspace test tools, 76793257, provides some basic/generic instructions.
To be able to bind the dma_map_benchmark
driver to a device,
it's important to update the driver_override
property of the
device first.
Compiling the userspace tool
make -C tools/testing/selftests/dma/
SA8540P examples
Platform device
[root@dhcp19-243-183 ~]# echo dma_map_benchmark > /sys/bus/platform/devices/platform-framebuffer.0/driver_override
[root@dhcp19-243-183 ~]# echo platform-framebuffer.0 > /sys/bus/platform/drivers/dma_map_benchmark/bind
[root@dhcp19-243-183 ~]# ls -l /sys/kernel/debug/dma_map_benchmark
-rw-------. 1 root root 0 Jan 1 02:31 /sys/kernel/debug/dma_map_benchmark
[root@dhcp19-243-183 ~]# ./dma_map_benchmark -t 10 -s 10
dma mapping benchmark: threads:10 seconds:10 node:-1 dir:BIDIRECTIONAL granule: 1
average map latency(us):2.2 standard deviation:84.0
average unmap latency(us):2.3 standard deviation:109.0
PCI device
[root@dhcp19-243-183 ~]# lspci
0002:00:00.0 PCI bridge: Qualcomm Technologies, Inc Device 010e
0002:01:00.0 PCI bridge: PMC-Sierra Inc. Device 4028
0002:01:00.1 Bridge: PMC-Sierra Inc. Device 4028
0002:01:00.2 System peripheral: PMC-Sierra Inc. Device 4028
0002:02:00.0 PCI bridge: PMC-Sierra Inc. Device 4028
0002:02:01.0 PCI bridge: PMC-Sierra Inc. Device 4028
0002:03:00.0 Processing accelerators: Qualcomm Technologies, Inc Device a100
0002:81:00.0 Ethernet controller: Aquantia Corp. AQC107 NBase-T/IEEE 802.3bz Ethernet Controller [AQtion] (rev 02)
[root@dhcp19-243-183 ~]# echo dma_map_benchmark > "/sys/bus/pci/devices/0002:03:00.0/driver_override"
[root@dhcp19-243-183 ~]# echo "0002:03:00.0" > /sys/bus/pci/drivers/dma_map_benchmark/bind
[root@dhcp19-243-183 ~]# ./dma_map_benchmark -t 10 -s 10
dma mapping benchmark: threads:10 seconds:10 node:-1 dir:BIDIRECTIONAL granule: 1
average map latency(us):1.2 standard deviation:75.9
average unmap latency(us):1.5 standard deviation:84.8
Signed-off-by: Radu Rendec rrendec@redhat.com