Add experimental non-coherent DMA-BUF GPUDirect RDMA path - #37
Draft
ducphuc wants to merge 21 commits into
Draft
Conversation
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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. Thebranch 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:
When enabled, a non-coherent
FORCE_PCIEDMA-BUF export is admitted only when:pci_p2pdma_distance()accepts the GPU-to-importer path.The experimental option broadens only non-coherent
FORCE_PCIEexports. Itdoes 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_PCIErejection.Non-coherent
FORCE_PCIEexports remain rejected unless every runtimepredicate succeeds.
Instead, it introduces explicit, fail-closed policy checks around:
BAR1 is mapped through the importer DMA API for the experimental path rather than using the coherent path’s IOMMU bypass.
The existing
RmGpuDirectRdmaForceSPAoverride remains restricted to coherent GPUs. Enabling the experimental non-coherent path does not make the coherent-platform SPA translation override reachable for non-coherentFORCE_PCIEexports.The branch also serializes
FORCE_PCIEphysical-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:FORCE_PCIEexports retain their existing rejection;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:
NODEGPU-to-NIC topology;Observed results:
ib_write_bw --use_cuda_dmabufcompleted successfully on both GPUs.NET/IB/.../GDRDMA.PPCNT grp=0increased by only four frames and 576 octets per port during the NCCL workload.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:
validation/nccl-same-host-gdr-transport-2026-08-06.mdA positive, negative, stress, teardown, and physical-wire calibration
procedure for systems already provisioned with compatible CUDA userspace is
provided in:
validation/nccl-same-host-gdr-reproduction-plan.mdSource-level policy tests cover:
RmGpuDirectRdmaForceSPAselection;Run them with:
Hardware validation requested
This draft intentionally requests broader community validation.
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
nvidia-peermemis not required and is not the path being enabled.Review status
This should remain a draft until: