kata.kernel-uvm: keep kernelconfig in-tree#2249
Conversation
c0b39b3 to
bc165ff
Compare
sespiros
left a comment
There was a problem hiding this comment.
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?
bc165ff to
64979da
Compare
64979da to
f816a01
Compare
|
@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 |
sespiros
left a comment
There was a problem hiding this comment.
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.configis ok but while reading code it helps me knowing exactly what config I am referring to (andkernelconfigalias makes me confused about where this package lives, the external or the internal package) - Rename
kernelconfig.gotokconfig.go(or even better plainconfig.go) and make them part of the internalkconfigpackage not the externalkernelconfigone. That would also allow you to drop the alias import everywhere. - since now
internal/kconfig/configmight be confusing, I would rename the test files tobase-configandbase-config-nvidia-gpu. - Rename
kernel-config-updatetocmd/update-basewhich 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/kernelconfigexternal package. This is thekernelconfigmain binary which runs during build time to create the final kernel configuration starting from the embedded base configuration.- the
cmd/update-basesub-command used to update the base kernel config from upstream - the
internal/kconfigpackage which contains the shared kernel config manipulation logic
sounds good, done
whoops, yes. Done. Should have been like that from the start, sorry, I moved that file around quite a lot 😄
opted instead to moving them into a separate internal
done |
f7c6220 to
6170df7
Compare
a1e0fa2 to
fa5f990
Compare
sespiros
left a comment
There was a problem hiding this comment.
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. 😄 |
| # 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. |
There was a problem hiding this comment.
This does not seem to be true.
There was a problem hiding this comment.
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 |
There was a problem hiding this comment.
Should we care about duplicate entries here, especially contradicting ones?
There was a problem hiding this comment.
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 "" |
There was a problem hiding this comment.
Should this fail loudly (or, which lines reach this point)?
There was a problem hiding this comment.
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.
| if strings.HasPrefix(line, "# CONFIG_") && strings.HasSuffix(line, " is not set") { | ||
| return line[2 : len(line)-11] | ||
| } |
There was a problem hiding this comment.
Maybe a regex with capture would be better here.
| 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) | ||
| } |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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.
fa5f990 to
cf62c5b
Compare
|
@burgerdev feel free to press merge if you're OK with the state. #2245 is already rebased on this. |
Don't worry, most of those 15,070 lines do not require review... 😅