Skip to content

Comments

internal/providers: Only load kernel modules when actually necessary#2164

Merged
prestist merged 1 commit intocoreos:mainfrom
chewi:kmod-built-in
Dec 9, 2025
Merged

internal/providers: Only load kernel modules when actually necessary#2164
prestist merged 1 commit intocoreos:mainfrom
chewi:kmod-built-in

Conversation

@chewi
Copy link
Contributor

@chewi chewi commented Nov 21, 2025

If the modules are built-in, attempting to load them with modprobe will cause a fatal error. Having them built-in makes kernel debugging easier.

I didn't touch the vmur (zvm) module as I'm not familiar with that.

Copy link

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request introduces a sensible optimization to avoid loading kernel modules with modprobe if they are already available (e.g., built-in). The approach of checking for the existence of a device file in /sys is correct. However, the error handling for the os.Stat call is incomplete in all the modified files. It only handles the os.IsNotExist case and silently ignores other potential errors, which could lead to unexpected behavior. My review includes suggestions to make the error handling more robust.

If the modules are built-in, attempting to load them with modprobe will
cause a fatal error. Having them built-in makes kernel debugging easier.

I didn't touch the vmur (zvm) module as I'm not familiar with that.

Signed-off-by: James Le Cuirot <jlecuirot@microsoft.com>
Copy link
Collaborator

@prestist prestist left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Makes sense to check before loading, I was going to push for unit tests, but after fumbling through it locally its not very helpful.

We should probably document a link for each path in a comment above? so that if for what ever reason it changes we can quickly find docs on it wdyt?

Otherwise these changes make sense and we can land them.

@chewi
Copy link
Contributor Author

chewi commented Dec 9, 2025

We should probably document a link for each path in a comment above? so that if for what ever reason it changes we can quickly find docs on it wdyt?

Sorry for the wait. I've had a good look, but I can't find these documented anywhere. You can't even easily tell from looking at the kernel code. I just determined them by loading the modules and having a look. Like I said, it's not the end of the world if they do change.

Copy link
Collaborator

@prestist prestist left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@chewi thank you for looking for the docs; Okay well since that was my only hesitation lets go ahead and get this landed; thank you for working on this!

🚀

@prestist prestist merged commit 4da272e into coreos:main Dec 9, 2025
10 checks passed
@chewi chewi deleted the kmod-built-in branch December 10, 2025 11:56
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.

3 participants