Skip to content

fix: rmmod unloads nvidia before dependent nvidia-peermem - #965

Open
andrewwhitecdw wants to merge 1 commit into
NVIDIA:mainfrom
andrewwhitecdw:bugfix/nvidia-driver-rmmod-unloads-nvidia-before-dependent
Open

fix: rmmod unloads nvidia before dependent nvidia-peermem#965
andrewwhitecdw wants to merge 1 commit into
NVIDIA:mainfrom
andrewwhitecdw:bugfix/nvidia-driver-rmmod-unloads-nvidia-before-dependent

Conversation

@andrewwhitecdw

Copy link
Copy Markdown

This PR addresses the following issue in rhel8/nvidia-driver: rmmod unloads nvidia before dependent nvidia-peermem.

Changes

  • rhel8/nvidia-driver: rmmod unloads nvidia before dependent nvidia-peermem.

Details

--- a/rhel8/nvidia-driver
+++ b/rhel8/nvidia-driver
@@ -1,14 +1,14 @@
-    if [ -f /sys/module/nvidia_uvm/refcnt ]; then
-        nvidia_uvm_refs=$(< /sys/module/nvidia_uvm/refcnt)
-        rmmod_args+=("nvidia-uvm")
-        ((++nvidia_deps))
-    fi
-    if [ -f /sys/module/nvidia/refcnt ]; then
-        nvidia_refs=$(< /sys/module/nvidia/refcnt)
-        rmmod_args+=("nvidia")
-    fi
-    if [ -f /sys/module/nvidia_peermem/refcnt ]; then
-        nvidia_peermem_refs=$(< /sys/module/nvidia_peermem/refcnt)
-        rmmod_args+=("nvidia-peermem")
-        ((++nvidia_deps))
-    fi
+    if [ -f /sys/module/nvidia_uvm/refcnt ]; then
+        nvidia_uvm_refs=$(< /sys/module/nvidia_uvm/refcnt)
+        rmmod_args+=("nvidia-uvm")
+        ((++nvidia_deps))
+    fi
+    if [ -f /sys/module/nvidia_peermem/refcnt ]; then
+        nvidia_peermem_refs=$(< /sys/module/nvidia_peermem/refcnt)
+        rmmod_args+=("nvidia-peermem")
+        ((++nvidia_deps))
+    fi
+    if [ -f /sys/module/nvidia/refcnt ]; then
+        nvidia_refs=$(< /sys/module/nvidia/refcnt)
+        rmmod_args+=("nvidia")
+    fi

Tests

  • rhel8/tests/test_unload_order.sh
--- /dev/null
+++ b/rhel8/tests/test_unload_order.sh
@@ -0,0 +1,20 @@
+#!/bin/bash
+set -eu
+
+script_dir=$(dirname "$(readlink -f \"$0\")")
+driver_file=\"$script_dir/../nvidia-driver\"
+
+peermem_line=$(grep -n 'rmmod_args+=(\"nvidia-peermem\")' \"$driver_file\" | head -n1 | cut -d: -f1 || true)
+nvidia_line=$(grep -n 'rmmod_args+=(\"nvidia\")' \"$driver_file\" | head -n1 | cut -d: -f1 || true)
+
+if [[ -z \"$peermem_line\" ]] || [[ -z \"$nvidia_line\" ]]; then
+    echo \"FAIL: could not locate rmmod_args entries\"
+    exit 1
+fi
+
+if [[ \"$peermem_line\" -gt \"$nvidia_line\" ]]; then
+    echo \"FAIL: nvidia-peermem is added after nvidia in rmmod_args\"
+    exit 1
+fi
+
+echo \"PASS\"

Contributor guidelines

Per this repo's CONTRIBUTING.md:

  • All commits are signed off (Signed-off-by trailer, DCO).

Signed-off-by: andrewwhitecdw <andrewwhitecdw@users.noreply.github.com>
@copy-pr-bot

copy-pr-bot Bot commented Aug 13, 2026

Copy link
Copy Markdown

This pull request requires additional validation before any workflows can run on NVIDIA's runners.

Pull request vetters can view their responsibilities here.

Contributors can view more details about this message here.

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