Skip to content

kata.kernel-uvm: keep kernelconfig in-tree#2249

Merged
burgerdev merged 2 commits intomainfrom
ch/keep-kernelconfig-in-tree
Mar 17, 2026
Merged

kata.kernel-uvm: keep kernelconfig in-tree#2249
burgerdev merged 2 commits intomainfrom
ch/keep-kernelconfig-in-tree

Conversation

@charludo
Copy link
Copy Markdown
Collaborator

@charludo charludo commented Mar 12, 2026

Don't worry, most of those 15,070 lines do not require review... 😅

@charludo charludo added the no changelog PRs not listed in the release notes label Mar 12, 2026
@charludo charludo force-pushed the ch/keep-kernelconfig-in-tree branch from c0b39b3 to bc165ff Compare March 12, 2026 14:05
Copy link
Copy Markdown
Collaborator

@sespiros sespiros left a comment

Choose a reason for hiding this comment

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

Thanks for the changes. I did a pass. Also a question, why do we have to keep both the upstream kernel config in-tree under nodeinstaller/internal/kernelconfig and the modified one under packages/by-name/kata/kernel-uvm, is the intent for both to be reviewable in a diff for instance?

Comment thread nodeinstaller/internal/kernelconfig/kernel-config-update/main.go Outdated
Comment thread nodeinstaller/internal/kernelconfig/kernel-config-update/main.go Outdated
@charludo charludo force-pushed the ch/keep-kernelconfig-in-tree branch from bc165ff to 64979da Compare March 16, 2026 12:30
@charludo charludo requested a review from sespiros March 16, 2026 12:30
@charludo charludo force-pushed the ch/keep-kernelconfig-in-tree branch from 64979da to f816a01 Compare March 16, 2026 15:07
@charludo
Copy link
Copy Markdown
Collaborator Author

@sespiros I pretty heavily reworked this. The actual generating of the final config now happens at build time of the kernel-uvm package. This also allows, as you suggested, to pass additional config options, e.g. setting the ACPI debug mode, without an additional patch or config file.

Both The upstream and expected configs are still kept in-tree; the latter ones are only used by the unit tests executed when building .#base.kernelconfig.

Copy link
Copy Markdown
Collaborator

@sespiros sespiros left a comment

Choose a reason for hiding this comment

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

Thanks for the changes! I got confused a bit about the overall structure so I am adding some suggestions in case you want to adopt any:

  • I would rename the internal package to kconfig. config is ok but while reading code it helps me knowing exactly what config I am referring to (and kernelconfig alias makes me confused about where this package lives, the external or the internal package)
  • Rename kernelconfig.go to kconfig.go (or even better plain config.go) and make them part of the internal kconfig package not the external kernelconfig one. That would also allow you to drop the alias import everywhere.
  • since now internal/kconfig/config might be confusing, I would rename the test files to base-config and base-config-nvidia-gpu.
  • Rename kernel-config-update to cmd/update-base which a) is the standard naming for Go multi-binary layout and also make it clear that this kernelconfig subcommand updates the base kernel configs (and the test files but ok).

So you end up with a cleaner layout

  • tools/kernelconfig external package. This is the kernelconfig main binary which runs during build time to create the final kernel configuration starting from the embedded base configuration.
  • the cmd/update-base sub-command used to update the base kernel config from upstream
  • the internal/kconfig package which contains the shared kernel config manipulation logic

Comment thread packages/scripts.nix Outdated
Comment thread tools/kernelconfig/main.go
@charludo
Copy link
Copy Markdown
Collaborator Author

I would rename the internal package to kconfig. config is ok but while reading code it helps me knowing exactly what config I am referring to (and kernelconfig alias makes me confused about where this package lives, the external or the internal package)

sounds good, done

Rename kernelconfig.go to kconfig.go (or even better plain config.go) and make them part of the internal kconfig package not the external kernelconfig one. That would also allow you to drop the alias import everywhere.

whoops, yes. Done. Should have been like that from the start, sorry, I moved that file around quite a lot 😄

since now internal/kconfig/config might be confusing, I would rename the test files to base-config and base-config-nvidia-gpu.

opted instead to moving them into a separate internal base package from which their embeddings are exported to the main and kconfig packages. Would have preferred to just do this in the main, but alas, import cycle with kconfig.

Rename kernel-config-update to cmd/update-base which a) is the standard naming for Go multi-binary layout and also make it clear that this kernelconfig subcommand updates the base kernel configs (and the test files but ok).

done

@charludo charludo force-pushed the ch/keep-kernelconfig-in-tree branch from f7c6220 to 6170df7 Compare March 17, 2026 06:16
@charludo charludo requested a review from sespiros March 17, 2026 07:25
@charludo charludo force-pushed the ch/keep-kernelconfig-in-tree branch from a1e0fa2 to fa5f990 Compare March 17, 2026 07:42
Copy link
Copy Markdown
Collaborator

@sespiros sespiros left a comment

Choose a reason for hiding this comment

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

Thanks. wrt your comment about unset, iiuc from https://docs.kernel.org/kbuild/kconfig-language.html having a config as # CONFIG_FOO is not set or having it as CONFIG_FOO=n is functionally equivalent so the unset mechanism is probably not needed.

@charludo
Copy link
Copy Markdown
Collaborator Author

Thanks. wrt your comment about unset, iiuc from https://docs.kernel.org/kbuild/kconfig-language.html having a config as # CONFIG_FOO is not set or having it as CONFIG_FOO=n is functionally equivalent so the unset mechanism is probably not needed.

Ah, fair. Well, I guess the mechanism with unset as it is now reduces diffs slightly. Theoretically. 😄

Comment on lines +10 to +11
# The source of the main module of this repo. We filter for Go files so that
# changes in the other parts of this repo don't trigger a rebuild.
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

This does not seem to be true.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Ah, whoops. Then it's also wrong where I copied it from 😆
Fixed.

c.lines = append(c.lines, line)
key := parseKey(line)
if key != "" {
c.index[key] = len(c.lines) - 1
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Should we care about duplicate entries here, especially contradicting ones?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

We probably do not need to care; last entry wins. But, I've added a check that will fail if a duplicate is encountered.

if strings.HasPrefix(line, "# CONFIG_") && strings.HasSuffix(line, " is not set") {
return line[2 : len(line)-11]
}
return ""
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Should this fail loudly (or, which lines reach this point)?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Each one of these 5, for example:


#
# General setup
#

IMO it's fine. The assumption is, lines start with CONFIG_ or # CONFIG_, or are irrelevant.

Added a check anyways for empty/comment lines.

Comment on lines +46 to +48
if strings.HasPrefix(line, "# CONFIG_") && strings.HasSuffix(line, " is not set") {
return line[2 : len(line)-11]
}
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Maybe a regex with capture would be better here.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

done

Comment on lines +68 to +74
config, err := kconfig.OverrideConfig(upstreamData, cfgInfo.isGPU)
if err != nil {
log.Fatalf("failed to parse upstream config: %v", err)
}
if err := os.WriteFile(targetFile, config.Marshal(), 0o644); err != nil {
log.Fatalf("failed to write target config: %v", err)
}
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

If the testdata is written with OverrideConfig, does it make sense to test OverrideConfig with the test data? Looks liek this will trivially be true?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

This will trivially be true if the testdata is up-to-date. If the test data is out-of date (not running codegen after kata update, manual changes,... building kernelconfig and in turn kata.kernel-uvm will fail. Same mechanism as with the kataconfig.

@charludo charludo force-pushed the ch/keep-kernelconfig-in-tree branch from fa5f990 to cf62c5b Compare March 17, 2026 12:34
@charludo charludo requested a review from burgerdev March 17, 2026 12:36
@charludo
Copy link
Copy Markdown
Collaborator Author

@burgerdev feel free to press merge if you're OK with the state. #2245 is already rebased on this.

@burgerdev burgerdev merged commit 3b2b4ca into main Mar 17, 2026
24 of 25 checks passed
@burgerdev burgerdev deleted the ch/keep-kernelconfig-in-tree branch March 17, 2026 14:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

no changelog PRs not listed in the release notes

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants