-
Notifications
You must be signed in to change notification settings - Fork 275
fix: Discover /dev/nvidia-modeset instead of assuming it exists
#388
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
ehfd
wants to merge
1
commit into
NVIDIA:main
Choose a base branch
from
ehfd:ehfd
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+2
−3
Open
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
what's the rational for this change? I'm not sure if it's necessary for the purpose of this PR.
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The old code hard-coded the modeset entry:
modeset.id = makedev(NV_DEVICE_MAJOR, NV_MODESET_DEVICE_MINOR);has_modeset = 1; so/dev/nvidia-modesetwas listed unconditionally, even when the node doesn't exist on the host (i.e. thenvidia-modesetkernel module isn't loaded). Usingfind_device_nodemakes the entry conditional on the device actually being present: it stats the node and warn-and-skips onENOENTinstead of registering a device that would later fail to mount, and it records the realst_rdevrather than assuming the fixed major/minor. It also matches hownvidia-uvmandnvidia-uvm-toolsare discovered in the same function, just above.So, it's a sanity fix that closes a real source of failure.
/dev/nvidia-modesetis a userspace-created device, like/dev/nvidia-uvmor/dev/nvidia-uvm-tools. It should work identically.Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Full code around the edit location:
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Per the original logic the existence of a modeset device is a prerequisite. But the after this change it is no longer true. Have you seen a real failure case? If not I'd rather keep the original logic intact.
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Explanation:
The original logic doesn't check for the device — that's the part I'd like to correct.
Before this change,
lookup_devices()registered the node unconditionally: a fixedmakedev(NV_DEVICE_MAJOR, NV_MODESET_DEVICE_MINOR)andhas_modeset = 1, with no stat anywhere. The existence check happens later, at mount time —mount_device()stats the source (xstat(), src/nvc_mount.c:222) and returnsNULLif it isn't there, which sendsnvc_driver_mount()togoto failand aborts the container start.So the prerequisite isn't "a modeset device exists". It's "a modeset device exists, or the container fails to start."
The failure case: a host where
/dev/nvidia-modesetwas never created. The driver doesn't register control nodes with devtmpfs, so on a headless host that's simply the state until something creates them. A container requestingdisplaythere, withnvidia-container-cliinvoked without--load-kmods, fails to start — on a node that isn't required for anything else it asked for.That's rare today only because
displayis rare. It stops being rare with the other half of this PR: once the gate includesgraphics, every graphics container on such a host takes the same hard failure. That's why the change is in this PR rather than standing alone — it's the guard that makes widening the gate safe, not a cleanup.After the change the node behaves exactly like
nvidia-uvmandnvidia-uvm-toolsimmediately above it:find_device_node()stats it, warnsmissing device %sand skips onENOENT, and records the realst_rdevinstead of assuming 195:254 — which is also whatmount_device()validates against (s.st_rdev != dev->id).Ordering is unchanged.
nvc_init()runsload_kernel_modules()underOPT_LOAD_KMODS(src/nvc.c:423), and the CLI callslibnvc.init()at src/cli/configure.c:304, beforedriver_info_new()at :323. So--load-kmodsstill creates the node before discovery looks for it. The only behavior that changes is the genuinely-absent case, which goes from "abort the container start" to "warn and skip".There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.