IOMMU Event Tracing - What It Is and How It Can Help Your Distro?
IOMMU Event Tracing - What It Is and How It Can Help Your Distro?
Enabling IOMMU event tracing will provide useful information about the
devices that are using IOMMU as well as as the changes that occur in device
assignments. In this talk, we will discuss the IOMMU event tracing feature and
how to enable and use it to trace events during boot-time and run-time. The
discussion will be focused on using the IOMMU tracing feature to get insight into
what's happening on a system in virtualized environments as devices get assigned
from host to virtual machines and vice versa. Linux kernel developers and users
can learn about a feature that can aid during development, maintenance, and support
of systems with IOMMU.
Advantages:
One single contiguous virtual memory region can be mapped to multiple non-contiguous physical memory
regions. IOMMU can make a non-contiguous memory region appear contiguous to a device (scatter/gather).
Scatter/gather optimizes streaming DMA performance for the I/O device
Memory isolation and protection: device can only access memory regions that are mapped for it.
• Hence faulty and/or malicious devices can't corrupt memory.
Memory isolation allows safe device assignment to a virtual machine without compromising host and other
guest OSes.
IOMMU enables 32-bit DMA capable non-DAC devices access to > 4GB memory.
IOMMU - support hardware interrupt re-mapping.
• extends limited hardware interrupts to software interrupts.
• interrupt remapping - primary uses are interrupt isolation and translation between interrupt domains, ex.
ioapic vs x2apic on x86
Disadvantages:
Latency in dynamic DMA mapping path, translation over head penalty.
IOTLB can alleviate translation overhead and most servers support IOMMU and IOTLB hardware.
IOMMU
Host Guest
Host Guest
Host Guest
Events in this group are triggered during run-time whenever devices are
attached to and detached from domains. e.g: When a device is detached
from host and attached to a guest.
This information provides insight into device assignment changes during run-
time.
IOMMU Map:
Format: IOMMU: iova=0x%016llx paddr=0x%016llx size=%zu
IOMMU Unmap:
Format: IOMMU: iova=0x%016llx size=%zu unmapped_size=%zu
trace_event=iommu
cd /sys/kernel/debug/trace/events
echo 1 > iommu/event_name_file
or
/sys/kernel/debug/tracing/trace
# tracer: nop
#
# entries-in-buffer/entries-written: 18/18 #P:8
#
# _-----=> irqs-off
# / _----=> need-resched
# | / _---=> hardirq/softirq
# || / _--=> preempt-depth
# ||| / delay
# TASK-PID CPU# |||| TIMESTAMP FUNCTION
# || | |||| | |
# tracer: nop
#
# entries-in-buffer/entries-written: 18/18 #P:8
#
# _-----=> irqs-off
# / _----=> need-resched
# | / _---=> hardirq/softirq
# || / _--=> preempt-depth
# ||| / delay
# TASK-PID CPU# |||| TIMESTAMP FUNCTION
# || | |||| | |
swapper/0-1 [000] .... 1.899609: add_device_to_group: IOMMU: groupID=0 device=0000:00:00.0
swapper/0-1 [000] .... 1.899619: add_device_to_group: IOMMU: groupID=1 device=0000:00:01.0
swapper/0-1 [000] .... 1.899624: add_device_to_group: IOMMU: groupID=2 device=0000:00:02.0
swapper/0-1 [000] .... 1.899629: add_device_to_group: IOMMU: groupID=3 device=0000:00:03.0
swapper/0-1 [000] .... 1.899634: add_device_to_group: IOMMU: groupID=4 device=0000:00:14.0
swapper/0-1 [000] .... 1.899642: add_device_to_group: IOMMU: groupID=5 device=0000:00:16.0
swapper/0-1 [000] .... 1.899647: add_device_to_group: IOMMU: groupID=6 device=0000:00:1a.0
swapper/0-1 [000] .... 1.899651: add_device_to_group: IOMMU: groupID=7 device=0000:00:1b.0
swapper/0-1 [000] .... 1.899656: add_device_to_group: IOMMU: groupID=8 device=0000:00:1c.0
swapper/0-1 [000] .... 1.899661: add_device_to_group: IOMMU: groupID=9 device=0000:00:1c.2
swapper/0-1 [000] .... 1.899668: add_device_to_group: IOMMU: groupID=10 device=0000:00:1c.3
swapper/0-1 [000] .... 1.899674: add_device_to_group: IOMMU: groupID=11 device=0000:00:1d.0
swapper/0-1 [000] .... 1.899682: add_device_to_group: IOMMU: groupID=12 device=0000:00:1f.0
swapper/0-1 [000] .... 1.899687: add_device_to_group: IOMMU: groupID=12 device=0000:00:1f.2
swapper/0-1 [000] .... 1.899692: add_device_to_group: IOMMU: groupID=12 device=0000:00:1f.3
swapper/0-1 [000] .... 1.899696: add_device_to_group: IOMMU: groupID=13 device=0000:02:00.0
swapper/0-1 [000] .... 1.899701: add_device_to_group: IOMMU: groupID=14 device=0000:03:00.0
swapper/0-1 [000] .... 1.899704: add_device_to_group: IOMMU: groupID=10 device=0000:04:00.0
00:00.0 Host bridge: Intel Corporation 4th Gen Core Processor DRAM Controller (rev 06)
00:01.0 PCI bridge: Intel Corporation Xeon E3-1200 v3/4th Gen Core Processor PCI Express x16 Controller (rev 06)
00:02.0 VGA compatible controller: Intel Corporation Xeon E3-1200 v3/4th Gen Core Processor Integrated Graphics
Controller (rev 06)
00:03.0 Audio device: Intel Corporation Xeon E3-1200 v3/4th Gen Core Processor HD Audio Controller (rev 06)
00:14.0 USB controller: Intel Corporation 8 Series/C220 Series Chipset Family USB xHCI (rev 05)
00:16.0 Communication controller: Intel Corporation 8 Series/C220 Series Chipset Family MEI Controller #1 (rev 04)
00:1a.0 USB controller: Intel Corporation 8 Series/C220 Series Chipset Family USB EHCI #2 (rev 05)
00:1b.0 Audio device: Intel Corporation 8 Series/C220 Series Chipset High Definition Audio Controller (rev 05)
00:1c.0 PCI bridge: Intel Corporation 8 Series/C220 Series Chipset Family PCI Express Root Port #1 (rev d5)
00:1c.2 PCI bridge: Intel Corporation 8 Series/C220 Series Chipset Family PCI Express Root Port #3 (rev d5)
00:1c.3 PCI bridge: Intel Corporation 82801 PCI Bridge (rev d5)
00:1d.0 USB controller: Intel Corporation 8 Series/C220 Series Chipset Family USB EHCI #1 (rev 05)
00:1f.0 ISA bridge: Intel Corporation H87 Express LPC Controller (rev 05)
00:1f.2 SATA controller: Intel Corporation 8 Series/C220 Series Chipset Family 6-port SATA Controller 1 [AHCI mode] (rev 05)
00:1f.3 SMBus: Intel Corporation 8 Series/C220 Series Chipset Family SMBus Controller (rev 05)
02:00.0 Network controller: Intel Corporation Wireless 7260 (rev 73)
03:00.0 Ethernet controller: Realtek Semiconductor Co., Ltd. RTL8111/8168/8411 PCI Express Gigabit Ethernet Controller
(rev 0c)
04:00.0 PCI bridge: ASMedia Technology Inc. ASM1083/1085 PCIe to PCI Bridge (rev 04)
GroupID=0 GroupID=10
Device=0000:00:00.0 GroupID=5 Device=0000:00:1c.3
Host bridge: Device=0000:00:16.0 PCI bridge:
DRAM Controller MEI controller PCIe Root Port #3
Device=0000:04:00.0
PCIe to PCI Bridge GroupID=13
GroupID=6 Device=0000:02:00.0
GroupID=1
Device=0000:00:1a.0 Network Controller
Device=0000:00:01.0
USB controller:
PCI bridge:
EHCI #2
PCIe x16 Controller GroupID=11
Device=0000:00:1d.0
USB controller:
GroupID=2 EHCI #1
GroupID=7 GroupID=14
Device=0000:00:02.0
Device=0000:00:1b.0 Device=0000:03:00.0
VGA compatible controller:
Audio device Ethernet Controller
Integrated Graphics
Controller
GroupID=12
Device=0000:00:1f.0
GroupID=8 ISA bridge
GroupID=3
Device=0000:00:1c.0 Device=0000:00:1f.2
Device=0000:00:03.0
PCI bridge: SATA Controller
Audio device
PCIe Root Port #1 Device=0000:00:1f.3
SMBus
GroupID=4
GroupID=9
Device=0000:00:14.0
Device=0000:00:1c.2
USB controller:
PCI bridge:
xHCI
PCIe Root Port #2
# tracer: nop
#
# entries-in-buffer/entries-written: 5689868/5689868 #P:8
#
# _-----=> irqs-off
# / _----=> need-resched
# | / _---=> hardirq/softirq
# || / _--=> preempt-depth
# ||| / delay
# TASK-PID CPU# |||| TIMESTAMP FUNCTION
# || | |||| | |
qemu-kvm-28546 [003] .... 1804.692631: attach_device_to_domain: IOMMU: device=0000:00:1c.0
qemu-kvm-28546 [003] .... 1804.692635: attach_device_to_domain: IOMMU: device=0000:00:1c.4
qemu-kvm-28546 [003] .... 1804.692643: attach_device_to_domain: IOMMU: device=0000:05:00.0
qemu-kvm-28546 [003] .... 1804.692666: detach_device_from_domain: IOMMU: device=0000:00:1c.0
qemu-kvm-28546 [003] .... 1804.692671: detach_device_from_domain: IOMMU: device=0000:00:1c.4
qemu-kvm-28546 [003] .... 1804.692676: detach_device_from_domain: IOMMU: device=0000:05:00.0
# tracer: nop
#
# entries-in-buffer/entries-written: 54/54 #P:8
#
# _-----=> irqs-off
# / _----=> need-resched
# | / _---=> hardirq/softirq
# || / _--=> preempt-depth
# ||| / delay
# TASK-PID CPU# |||| TIMESTAMP FUNCTION
# || | |||| | |
qemu-kvm-28546 [002] .... 1804.480679: map: IOMMU: iova=0x00000000000a0000
paddr=0x00000000446a0000 size=4096
qemu-kvm-28547 [006] .... 1809.032767: unmap: IOMMU: iova=0x00000000000c1000
size=4096 unmapped_size=4096
Debug:
IOMMU problems.
Device assignment problems.
Detect and solve performance problems.
BIOS and firmware problems related to IOMMU hardware and
firmware implementation.
Reference: http://lists.linuxfoundation.org/pipermail/iommu/2015-
January/011718.html
Physical address
0xf00bar000000
IOMMU
Device address
0xf000 Host
VM 1 VM 2 VM 3 VM 4
driver driver driver driver
Server 32-cores
VM 1 VM 2 VM 3 VM 4
driver driver V-NIC V-NIC