Skip to content

Add experimental non-coherent DMA-BUF GPUDirect RDMA path - #37

Draft
ducphuc wants to merge 21 commits into
aikitoria:610.43.03-p2pfrom
ducphuc:feature/consumer-geforce-dmabuf-gdr
Draft

Add experimental non-coherent DMA-BUF GPUDirect RDMA path#37
ducphuc wants to merge 21 commits into
aikitoria:610.43.03-p2pfrom
ducphuc:feature/consumer-geforce-dmabuf-gdr

Conversation

@ducphuc

@ducphuc ducphuc commented Aug 7, 2026

Copy link
Copy Markdown

Add experimental non-coherent DMA-BUF GPUDirect RDMA path

Important

This is a draft/RFC and depends on #35, which in turn depends on #33. Until
#35 merges, this branch also contains its BAR1 runtime-coverage commits
through 26e1ff53. Review the DMA-BUF GDR commits after that point. The
branch will be rebased onto the updated upstream base after #35 is resolved.

Summary

Add a default-off experimental DMA-BUF GPUDirect RDMA path for non-coherent GPUs using runtime capabilities rather than a GPU, architecture, or device-ID allowlist.

The feature is enabled explicitly with:

NVreg_ExperimentalDmaBufP2P=1

When enabled, a non-coherent FORCE_PCIE DMA-BUF export is admitted only when:

  • static BAR1 is active and usable;
  • MIG is disabled;
  • the exported range is nonzero and wholly contained in static BAR1;
  • the importer uses an identity IOMMU domain;
  • the importer DMA mask covers the complete BAR1 resource; and
  • Linux pci_p2pdma_distance() accepts the GPU-to-importer path.

The experimental option broadens only non-coherent FORCE_PCIE exports. It
does not change the admission or mapping behavior of other mapping types. The
existing coherent DMA-BUF path and its topology behavior remain unchanged.

This implements an experimental kernel-side path relevant to #20 — GDR support for RTX 5090, but does not claim to close it because current consumer CUDA userspace applies a separate capability gate.

Why this is not a simple gate bypass

The change does not unconditionally remove the existing non-coherent
FORCE_PCIE rejection.

Non-coherent FORCE_PCIE exports remain rejected unless every runtime
predicate succeeds.

Instead, it introduces explicit, fail-closed policy checks around:

  • feature opt-in;
  • mapping type;
  • static BAR1 availability;
  • MIG exclusion;
  • overflow-safe aperture containment;
  • importer DMA-mask coverage;
  • IOMMU-domain type; and
  • Linux PCI P2PDMA topology acceptance.

BAR1 is mapped through the importer DMA API for the experimental path rather than using the coherent path’s IOMMU bypass.

The existing RmGpuDirectRdmaForceSPA override remains restricted to coherent GPUs. Enabling the experimental non-coherent path does not make the coherent-platform SPA translation override reachable for non-coherent FORCE_PCIE exports.

The branch also serializes FORCE_PCIE physical-address operations. These operations map or unmap BAR1 and update per-GPU RUSD statistics, so treating them like immutable default static-address configurations can race concurrent registration and deregistration.

CUDA userspace prerequisite

This kernel change is necessary on the validated GB206 system, but it is not sufficient by itself.

Stock CUDA userspace does not advertise the required DMA-BUF capability on the validated GeForce configuration, so stock userspace does not exercise the kernel path introduced by this PR. Investigation or modification of CUDA userspace is outside the scope of this change.

Harry Chen independently reported analogous userspace gating on RTX 5090 while investigating GPUDirect RDMA support:

The functional validation below used a userspace configuration that allowed the kernel path to be exercised. This PR does not document or provide a userspace modification procedure.

Default behavior

The registry option defaults to disabled.

With NVreg_ExperimentalDmaBufP2P=0:

  • non-coherent FORCE_PCIE exports retain their existing rejection;
  • the stock coherent path is unchanged; and
  • no device gains the experimental behavior automatically.

No chip-specific exception or consumer-product allowlist is introduced. Every driver-supported GPU is evaluated using the same runtime predicates.

Functional validation completed

Validated with:

  • two NVIDIA GeForce RTX 5060 Ti 16 GB GPUs;
  • NVIDIA ConnectX-6 Lx dual-port 25 GbE RoCE;
  • NODE GPU-to-NIC topology;
  • separate GPU and NIC IOMMU groups using identity domains;
  • driver 610.43.03 and kernel 7.0.0-29;
  • signed modules with verified hashes and srcversions;
  • CUDA 13.3 with a userspace configuration that allowed the kernel path to be exercised;
  • NCCL 2.30.7; and
  • nccl-tests 2.19.6 built with MPI.

Observed results:

  • CUDA device memory exported successfully through DMA-BUF.
  • mlx5 successfully registered the exported DMA-BUF memory; no legacy pointer-based MR fallback was observed.
  • ib_write_bw --use_cuda_dmabuf completed successfully on both GPUs.
  • Two-rank NCCL formed a single communicator using separate GPUs.
  • NCCL established connectors using NET/IB/.../GDRDMA.
  • Collectives completed successfully from 64 MiB through 1 GiB.
  • RDMA activity increased at workload scale.
  • ConnectX-6 Lx IEEE 802.3 MAC counters read through MFT PPCNT grp=0 increased by only four frames and 576 octets per port during the NCCL workload.
  • The workload-scale RDMA activity combined with negligible external MAC activity is consistent with ConnectX internal forwarding. The required physical-wire counter calibration remains follow-up validation, so this is not presented as proof of the adapter-internal route.
  • No new Xid, assertion, IOMMU fault, AER error, BAR1 failure, or mlx5 reset was observed during the validated run.

This establishes functional operation of the experimental path on the recorded GB206/ConnectX-6 Lx configuration. Concurrency stress, broader hardware coverage, translated-IOMMU rejection testing, physical-wire counter calibration, and extended lifecycle validation remain outstanding.

The executed evidence is documented in:

A positive, negative, stress, teardown, and physical-wire calibration
procedure for systems already provisioned with compatible CUDA userspace is
provided in:

Source-level policy tests cover:

  • feature disabled;
  • coherent-path exclusion;
  • coherent-only RmGpuDirectRdmaForceSPA selection;
  • mapping-type requirements;
  • static BAR1 and MIG conditions;
  • inside, spanning, outside, empty, and overflowing ranges;
  • importer DMA-mask coverage;
  • identity-IOMMU requirements; and
  • rejected and accepted P2PDMA distances.

Run them with:

make -C tests clean check

Hardware validation requested

This draft intentionally requests broader community validation.

Dimension Validated Requested
GPU RTX 5060 Ti / GB206 GB202/203/205, Ada, Ampere, other supported GPUs
NIC ConnectX-6 Lx ConnectX-5/6 Dx/7 and other DMA-BUF importers
Topology NODE PHB, PIX, PXB, and cross-root/cross-socket SYS where accepted by host topology
IOMMU Identity/passthrough Confirm safe rejection with translated IOMMU
Workload perftest and NCCL Multi-host NCCL, GDS/cuFile, additional RDMA applications
Counter calibration Negligible MAC deltas during same-host NCCL Physical-wire control producing workload-scale MAC deltas
Concurrency Basic application operation Parallel registration/deregistration stress
Lifecycle Normal teardown Extended stress, reload, suspend/resume, and reboot

Please include module provenance, userspace provenance, topology and IOMMU evidence, complete endpoint logs, actual NCCL connector lines, counter deltas, cleanup results, and kernel-health logs. The reproduction plan defines the requested evidence and classification criteria.

Known limitations

  • Experimental and disabled by default.
  • Stock CUDA userspace does not exercise the experimental kernel path on the validated 610-series GeForce configuration; userspace investigation or modification is outside the scope of this PR.
  • Requires static BAR1 and rejects ranges outside its usable window.
  • Requires an identity IOMMU domain.
  • MIG is excluded.
  • Only GB206 with ConnectX-6 Lx in NODE topology has completed the full recorded validation.
  • Other GPUs, NICs, topologies, translated IOMMU, GDS, VF-to-VF, and multi-host operation remain validation follow-ups.
  • nvidia-peermem is not required and is not the path being enabled.

Review status

This should remain a draft until:

  • the design and fail-closed policy receive review;
  • the default-off negative control is independently reproduced;
  • physical-wire counter calibration is completed before claiming adapter-internal forwarding;
  • concurrent registration/deregistration stress is completed; and
  • additional GPU, NIC, or topology results establish whether any further restrictions are required.

ducphuc and others added 21 commits August 4, 2026 11:27
BAR1 mappings already select SYS_COH or SYS_NONCOH before PTE construction, so the PEER-aperture rewrites and bar1BusAddr base assignment were unreachable. Keep the live BAR1 DMA address encoder unchanged.
Keep BAR1 reads and writes enabled, but encode the atomics field as DEFAULT instead of implicitly disabling it with 0x11. Preserve the branch-wide BAR1 protocol policy, including qualifying PCIe-only datacenter GPUs, and retain registry-key precedence.
Use the reduced page-array path only for non-empty, overflow-safe ranges that are hugepage aligned, exactly sized in hugepages, and contained in one hugetlb VMA. Fall back to the existing base-page path for every other layout.
Report leftover mappings and mappings that outlive their I/O VA space without triggering a debug breakpoint. Use the portable NvU64 format for mappingCount and retain null-safe teardown.
Dynamic-granularity page arrays already use the OS page size, so pass PageCount directly when unregistering them. The RM-to-OS conversion is only correct for ordinary RM-granularity arrays on 64K-page systems.
Match the inactive nv-reg.h mirror to the kernel-open definition. Only os-registry.c instantiates the active table, so this is source hygiene and does not change runtime behavior.
Keep IOMMU passthrough required while translated-IOMMU scatterlist merging remains unsafe, document the hugetlb eligibility fallback, and replace the broad ACS override recommendation with scoped upstream controls and an isolation warning.
Mailbox P2P setup used to assert-and-continue, so a failure while
programming the HSHUB peer masks or setting up the mailboxes left
half-programmed peer state behind. Convert the setup path to return
status and unwind on failure: tear down partially set up mailboxes,
invalidate peer masks programmed for a fresh mapping, and restore the
peer bookkeeping. When taking an additional reference on an existing
mapping, a failure only drops the newly taken references and leaves the
mapping intact.
Allow default-enabled GPUs to place static BAR1 above fixed console and mailbox mappings when the remaining aperture covers all aligned client framebuffer memory. Preserve the tested GB206 partial-window exception without generalizing partial coverage to other implementations.

Validate external BAR1 mapping addresses against the DMA window so spanning and outside allocations fail safely. Document the current CUDA API rejection behavior and add a source-level policy truth-table test.
Report coherence from the actual system-memory window again, but keep non-coherent Blackwell devices out of the static-BAR1 PCI P2PDMA registration path. Static BAR1 is also the GPU peer aperture there, and P2PDMA registration replaces its pagemap operations.

This intentionally leaves device P2PDMA unavailable on non-coherent Blackwell datacenter GPUs. It matches this branch’s effective behavior and does not remove GPU-to-GPU P2P support.
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Allow every property-enabled GPU to use display-aware static BAR1 when runtime geometry leaves nonzero aligned client-FB and static-window ranges. Remove the GB206 implementation check while retaining the same inside-window behavior and fail-closed spanning/outside rejection.

Keep the GB206 record as the validated partial-coverage example without treating it as an eligibility allowlist.
Static physical addresses normally allow nv_dma_buf_get_phys_addresses() and nv_dma_buf_put_phys_addresses() to skip the API and GPU locks because the memory descriptor is immutable.

FORCE_PCIE is different: it maps and unmaps the BAR1 aperture and updates per-GPU RUSD statistics. Take the lock for every non-default mapping type so concurrent registration and deregistration cannot race the RUSD seqlock.
Define a default-off policy for non-coherent FORCE_PCIE DMA-BUF exports without a chip, architecture, or device-ID allowlist. Evaluate every driver-supported GPU using runtime static-BAR1, BAR, MIG, mapping-type, and coherence predicates.

Add standalone tests for admission, overflow-safe BAR1 range containment, importer DMA-mask coverage, identity-IOMMU requirements, and Linux P2PDMA distance. Preserve the existing coherent path.
Allow the explicitly enabled non-coherent path to report and admit FORCE_PCIE exports only when static BAR1 is active, BAR1 is usable, and MIG is disabled. Require every exported range to be nonzero and wholly contained in static BAR1 using overflow-safe checks.

Validate address translation before modifying ranges and unwind aperture mappings on every failure. Preserve the stock coherent export path and all existing ownership and memory-type validation.

Keep RmGpuDirectRdmaForceSPA restricted to coherent GPUs when relaxing the non-coherent FORCE_PCIE rejection: it is a coherent-platform hypervisor workaround, not a DMA-BUF GDR capability requirement, and must stay unreachable for non-coherent GPUs. Express both admission decisions as policy macros (DMABUF_GDR_NONCOHERENT_ALLOWED, DMABUF_GDR_USE_GRDMA_SPA) with regression coverage for all four FORCE_PCIE/coherent/forceSPA combinations.
Admit the experimental non-coherent path only when the importer uses an identity IOMMU domain, its DMA mask covers BAR1, and Linux pci_p2pdma_distance() accepts the complete path, including valid NODE topologies.

Map BAR1 through the importer DMA API with skipIommu disabled. Keep the existing coherent topology decisions and IOMMU-bypass behavior unchanged.
Document successful ib_write_bw and NCCL NET/IB/GDRDMA operation on two RTX 5060 Ti GPUs with a ConnectX-6 Lx in NODE topology.

Record the required private CUDA userspace capability patch, exact NCCL environment, module and library identities, MAC-counter evidence, default-off registry option, and unvalidated hardware and topology scope.
Provide a reproducible positive, negative, stress, teardown, and physical-wire calibration matrix for the default-off non-coherent DMA-BUF GDR path.

Require module and patched-libcuda provenance, runtime topology gates, both GPUs, actual NCCL GDRDMA connectors, labeled counter evidence, and post-test kernel and GPU health.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant