-
Notifications
You must be signed in to change notification settings - Fork 2.2k
libcontainer/intelrdt: support explicit assignment to root CLOS #4854
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
Conversation
@@ -287,7 +287,7 @@ func intelrdtCheck(config *configs.Config) error { | |||
return fmt.Errorf("intelRdt is specified in config, but Intel RDT is not enabled") | |||
} | |||
|
|||
if config.IntelRdt.ClosID == "." || config.IntelRdt.ClosID == ".." || strings.Contains(config.IntelRdt.ClosID, "/") { | |||
if config.IntelRdt.ClosID == "." || config.IntelRdt.ClosID == ".." || (config.IntelRdt.ClosID != "/" && strings.Contains(config.IntelRdt.ClosID, "/")) { |
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.
Can be simplified to len > 1
?
if config.IntelRdt.ClosID == "." || config.IntelRdt.ClosID == ".." || (config.IntelRdt.ClosID != "/" && strings.Contains(config.IntelRdt.ClosID, "/")) { | |
if config.IntelRdt.ClosID == "." || config.IntelRdt.ClosID == ".." || (len(config.IntelRdt.ClosID) > 1 && strings.Contains(config.IntelRdt.ClosID, "/")) { |
(but maybe it's less readable, IDK)
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.
Personally, I find that less obviouls, kinda obfuscating that we're looking for /
as a special value. But let others comment on this, too...
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.
Reading the spec, I think what @kolyshkin suggested is slightly more readable for me. /
is a special value, so something that is more than one char and contains a /
is clearly not just a /
in my mind.
I think I'd split it in two different error cases, one for "." and "..", the other for this. But this is really a personal preference.
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.
Fair enough, I changed the code along these lines. However, I changed it to switch-case to make it shorter and more readable (imo)
Ready for review, opencontainers/runtime-spec#1289 was merged. |
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.
Can we have a unit test?
d0b9477
to
748abd3
Compare
Check. I added comprehensive unit tests for the IntelRdt validation as a separate commit. |
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.
This almost lgtm, left a few suggestions to see if it can be slightly simpler
type intelRdtStatus struct { | ||
sync.Once | ||
rdtEnabled bool | ||
catEnabled bool | ||
mbaEnabled bool | ||
} | ||
|
||
var intelRdt = &intelRdtStatus{} |
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.
I think the methods and the struct might be better on a different file in this package now, it's growing.
However, do we need so much plumbing? Can't we have package-level bool variables just assigned with the result of intelrdt.IsEnabled()
(and friends)? I'm not sure if this can change at runtime (it seems it doesn't) nor what the isEnabled() check does, but if that works, it seems simpler.
What do you think?
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.
Thanks @rata. This was exactly my initial implementation. However, I changed it in order to not cause ANY functional changes (other than the if logic). IOW, reason for the extensive plumbing here is to only do the discovery if the container config specifies linux.intelRdt
(that involves parsing mounts and reading files from sysfs, for example)
I don't know how critical this really is for runc so I'm fully ok to do the simple thing you suggested. Thoughts @rata @kolyshkin @AkihiroSuda ?
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.
Oh, right, no, let's keep this then. intelrdt is quite slow, let's do it conditional. But maybe move the methods and that to another file :)
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.
Check. They're now in a separate file (libcontainer/configs/validate/intelrdt.go
)
@@ -287,7 +287,7 @@ func intelrdtCheck(config *configs.Config) error { | |||
return fmt.Errorf("intelRdt is specified in config, but Intel RDT is not enabled") | |||
} | |||
|
|||
if config.IntelRdt.ClosID == "." || config.IntelRdt.ClosID == ".." || strings.Contains(config.IntelRdt.ClosID, "/") { | |||
if config.IntelRdt.ClosID == "." || config.IntelRdt.ClosID == ".." || (config.IntelRdt.ClosID != "/" && strings.Contains(config.IntelRdt.ClosID, "/")) { |
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.
Reading the spec, I think what @kolyshkin suggested is slightly more readable for me. /
is a special value, so something that is more than one char and contains a /
is clearly not just a /
in my mind.
I think I'd split it in two different error cases, one for "." and "..", the other for this. But this is really a personal preference.
Makes it possible e.g. to enable monitoring (linux.intelRdt.enableMonitoring) without creating a CLOS (resctrl group) for the container. Implements opencontainers/runtime-spec#1289. Signed-off-by: Markus Lehtonen <[email protected]>
Signed-off-by: Markus Lehtonen <[email protected]>
748abd3
to
ba68a17
Compare
Updated:
|
Why do I get a linter error about missing package comment (in the new file)? None of the existing files have package comments 🤔 |
@marquiz not sure, but let's ignore them for now :) |
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.
LGTM, thanks!
@marquiz the linter is failing due to this PR now. Can you fix it? |
Linter is failing due to this PR (I thought it wasn't related, as before it was failing due to files not changed here)
Add package comment to make revive pass muster. Signed-off-by: Markus Lehtonen <[email protected]>
0ae05e6
to
7628194
Compare
The linter failure had nothing to do with this PR, except that it added a new file and the linter started to complain about package comments because of this. Most of the packages in runc don't have package comments but because we lint with However, I now added |
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.
LGTM. Thanks for the doc one-liner to fix the linter :)
Makes it possible e.g. to enable monitoring
(linux.intelRdt.enableMonitoring) without creating a CLOS (resctrl group) for the container.
Implements opencontainers/runtime-spec#1289.