-
Notifications
You must be signed in to change notification settings - Fork 240
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
cgroup: Optionally add process and task to a subsystems subset #203
Conversation
Need to rebase |
48526f0
to
2ea5283
Compare
@fuweid The PR is rebased 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.
see comments..
Does Update need to be have filters too?
// Add moves the provided process into the new cgroup | ||
func (c *cgroup) Add(process Process) error { | ||
return c.add(process, cgroupProcs) | ||
func (c *cgroup) Add(process Process, subsystems ...Name) error { |
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 update the inline function descriptions 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.
Done.
control.go
Outdated
// the cgroup subsystems. When giving AddProc a list of subsystem names, the process | ||
// id is only added to those subsystems, provided that they are active in the targeted | ||
// cgroup. | ||
AddProc(pid uint64, subsystems ...Name) error |
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.
declaration isn't consistent with the other two.. as it includes subsystems
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 original AddProc
declarartion was not consistent with the other methods as it had a named parameter (which is why I had to name the added one...). I'm fixing that too.
@@ -101,6 +101,50 @@ func TestAdd(t *testing.T) { | |||
} | |||
} | |||
|
|||
func TestAddFilteredSubsystems(t *testing.T) { |
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.
let's also test against nil filteredSubstems..
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.
Good point. Done.
In some cases, one may want to add processes and task only to certain subsystems in a cgroup. For example, when a cgroup is created to only limit a given subsystem usage, but leaves all other subsystems unconstrained, there may be a need to move a process to only the contrained cgroup subsystem while leaving it in another cgroup for other subsystems. This commit makes the Control interface process and task addition functions variadic, in order to pass an optional list of subsystems that behave as s subsystems filter. Signed-off-by: Samuel Ortiz <samuel.e.ortiz@protonmail.com>
2ea5283
to
80a7821
Compare
In some cases, one may want to add processes and task only to certain
subsystems in a cgroup. For example, when a cgroup is created to only
limit a given subsystem usage, but leaves all other subsystems
unconstrained, there may be a need to move a process to only the
contrained cgroup subsystem while leaving it in another cgroup for
other subsystems.
This commit makes the Control interface process and task addition
functions variadic, in order to pass an optional list of subsystems that
behave as s subsystems filter.
Signed-off-by: Samuel Ortiz samuel.e.ortiz@protonmail.com