AI & HPC Infrastructure9 min readLinux 6.12 LTS

Diagnosing PCIe topology, IOMMU groups & GPUDirect RDMA bottlenecks on Linux

Why an 8-GPU + RoCEv2/InfiniBand node quietly falls back from 400 Gb/s peer-to-peer DMA to host-memory bounce buffers — and how to prove it from Linux sysfs.

1. Start at physical link width and speed before touching NCCL flags

Before tuning collective environment variables on a slow multi-GPU node, verify that every accelerator and RDMA NIC actually trained at its rated PCIe generation and lane width. Reseating risers, thermal retimer drift, or bifurcation mismatches routinely drop a Gen5 x16 endpoint to x8 or Gen3 without crashing the OS.

# Compare LnkCap (rated capability) against LnkSta (negotiated link state)
lspci -vvv -d 10de: | grep -E "^[0-9a-f]{2}:|LnkCap:|LnkSta:"
lspci -vvv -d 15b3: | grep -E "^[0-9a-f]{2}:|LnkCap:|LnkSta:"

Any line showing LnkSta: Speed 16GT/s (downgraded), Width x8 (downgraded) cuts unidirectional BAR/DMA bandwidth in half before a single packet reaches the fabric. Also inspect AER (Advanced Error Reporting) counters under /sys/bus/pci/devices/<bdf>/aer_dev_correctable — sustained receiver or replay-timer errors explain intermittent collective timeouts that vanish under single-GPU microbenchmarks.

2. Reading the PCIe switch & NUMA topology matrix

GPUDirect RDMA achieves line-rate zero-copy transfers only when the RDMA NIC (mlx5_0) and target GPU sit beneath a dedicated PCIe switch (PIX / PXB), avoiding traversal across the CPU root complex (NODE) or inter-socket QPI/UPI/Infinity Fabric interconnect (SYS).

$ nvidia-smi topo -m
        GPU0    GPU1    mlx5_0  mlx5_1  CPU Affinity    NUMA Affinity
GPU0     X      NV12    PIX     SYS     0-31            0
GPU1    NV12     X      PIX     SYS     0-31            0
mlx5_0  PIX     PIX      X      SYS
mlx5_1  SYS     SYS     SYS      X

Binding a rank on GPU0 to mlx5_1 (SYS) forces every RDMA payload across CPU sockets and host memory controllers, collapsing throughput by 50–75% even when nvidia-peermem or dma-buf is loaded.

3. The silent killer: PCIe ACS and IOMMU translation overhead

Even when a GPU and NIC share the exact same physical PCIe switch (PIX), peer-to-peer DMA can still silently detour up to the CPU root complex and back down if PCIe Access Control Services (ACS) Upstream Forwarding (SrcValid / ReqRedir / CmpltRedir) is enabled on the switch downstream ports.

Why do server BIOS defaults enable ACS? Because hardware virtualization (VFIO / KVM device passthrough) relies on ACS to isolate each slot into its own IOMMU group so guest VMs cannot DMA directly into sibling devices, routing every transaction through the host IOMMU for IOVA translation.

# Check IOMMU groupings and whether ACS redirect bits are active on PCIe bridges
for g in /sys/kernel/iommu_groups/*; do
  echo "Group ${g##*/}: $(ls -1 $g/devices | tr '\n' ' ')"
done

lspci -vvv | grep -E "^[0-9a-f]{2}:|ACSCtl:"

On bare-metal training or HPC nodes (where untrusted multi-tenant VM passthrough is not used), booting with iommu=pt (passthrough mode for host DMA) and disabling ACS redirect on the dedicated GPU/NIC PCIe switch ports allows direct switch-level peer-to-peer TLP routing without root-complex hairpins.

4. Verifying dma-buf / GPUDirect RDMA with ib_write_bw

Prove the path quantitatively at the RDMA verbs layer before launching a distributed training job. Modern Linux 6.12 kernels and user stacks support standard dma-buf export alongside nvidia-peermem:

# 1. Host RAM -> NIC baseline on NUMA node 0
numactl --cpunodebind=0 --membind=0 ib_write_bw -d mlx5_0 -s 65536 -D 10 --report_gbits

# 2. GPU0 BAR / HBM -> NIC zero-copy GPUDirect RDMA path
numactl --cpunodebind=0 ib_write_bw -d mlx5_0 --use_cuda=0 --use_cuda_dmabuf -s 65536 -D 10 --report_gbits

While running step 2, watch PCIe root-port counters (perf uncore / pcm-pcie). On a working PIX P2P path with ACS redirect off, NIC-to-GPU writes stay inside the PCIe switch fabric and host DRAM write bandwidth remains flat near zero.

Questions engineers ask

What is the difference between dma-buf GPUDirect RDMA and nvidia-peermem?

nvidia-peermem uses a proprietary out-of-tree peer-memory hook into the InfiniBand core. Linux dma-buf (exported via dmabuf_fd and ibv_reg_dmabuf_mr) uses the upstream Linux kernel buffer-sharing subsystem, eliminating module symbol mismatches across kernel upgrades on supported GPU stacks.

Should we disable IOMMU completely on bare-metal GPU servers?

Prefer iommu=pt (passthrough) over disabling IOMMU hardware entirely in BIOS: iommu=pt bypasses per-DMA IOVA page-table walks for host drivers (restoring full PCIe throughput) while keeping interrupt remapping and optional VFIO capability available.

Why does ib_write_bw pass at full speed on 1 GPU, then NCCL all-reduce stalls at 8 GPUs?

Single-pair ib_write_bw tests one queue pair on one PCIe switch. Eight-GPU collectives stress simultaneous bidirectional traffic, PFC/ECN congestion control on RoCEv2 ToR switches, and rail-to-GPU NUMA binding mismatches.

Hands-on courses covering this stack

More technical articles

Want a practitioner to look at your trace or board?

Book a free 60-minute technical session for your engineering team, or scope a private cohort adapted to your kernel tree and hardware.

Free technical session