[Carry 3962] Support process.scheduler#4025
Conversation
ecd3e1a to
8d1145b
Compare
libcontainer/process_linux.go
Outdated
|
|
||
| func (p *setnsProcess) start() (retErr error) { | ||
| defer p.messageSockPair.parent.Close() | ||
|
|
There was a problem hiding this comment.
unrelated; please remove
libcontainer/setns_init_linux.go
Outdated
| if errors.Is(err, unix.EPERM) { | ||
| return fmt.Errorf("error setting scheduler(please check you have appropriate privileges or valid cpus config): %w", err) |
There was a problem hiding this comment.
If you do want to distinguish between the two cases for EPERM, maybe it makes sense to check if we have cpus set first.
Also, maybe move this code into a separate function (setupScheduler), as we have the same 8 lines of code in both setns_init_linux.go and standard_init_linux.go
There was a problem hiding this comment.
maybe it makes sense to check if we have
cpusset first.
I also considered it when writing the code, but there is another corner case is that if the cpus value includes all cpus in the machine, it will be no error. So I don't want to check cpus value.
3087839 to
dc3aa07
Compare
Thanks, there are all resolved, PTAL. |
| return nil | ||
| } | ||
| if s.Policy == "" { | ||
| return fmt.Errorf("scheduler policy is required") |
| niceValue := s.Nice | ||
| if niceValue < -20 || niceValue > 19 { | ||
| return fmt.Errorf("invalid scheduler.nice: %d", niceValue) |
There was a problem hiding this comment.
I think it's better to use s.Nice directly (drop the intermediate variable) here.
There was a problem hiding this comment.
I think the original author used an intermediate variable because repeating config.Scheduler.Nice three times was too much.
But, just in case an intermediate variable is preferred, it is better to limit its scope:
if n := s.Nice; n < -20 || n > 19 {
return fmt.Errorf("invalid scheduler.nice: %d", n)
}
libcontainer/init_linux.go
Outdated
| if config.Cgroups.CpusetCpus == "" { | ||
| return errors.New("please check you have appropriate privileges to set process scheduler") | ||
| } |
There was a problem hiding this comment.
Maybe don't make this a special case.
I.e. something like
if err := unix.SchedSetAttr(0, attr, 0); err != nil {
if errors.Is(err, unix.EPERM) && config.Cgroups.CpusetCpus != "" {
return errors.New("process scheduler can not be used together with AllowedCPUs")
}
return fmt.Errorf("error setting scheduler: %w", err)
}
kolyshkin
left a comment
There was a problem hiding this comment.
Left some nits.
Also, you can add Co-authored-by: ... footer.
eded31e to
25b3d41
Compare
fd43bb2 to
cf74bfc
Compare
Spec: opencontainers/runtime-spec#1188 Fix: opencontainers#3895 Co-authored-by: lifubang <lifubang@acmcoder.com> Signed-off-by: utam0k <k0ma@utam0k.jp> Signed-off-by: lifubang <lifubang@acmcoder.com>
cf74bfc to
770728e
Compare
(this is a carry of #3962)
Spec: opencontainers/runtime-spec#1188
Close: #3895 #3962