Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 2 additions & 10 deletions libcontainer/process_linux.go
Original file line number Diff line number Diff line change
Expand Up @@ -184,16 +184,8 @@ func tryResetCPUAffinity(pid int) {
//
// So we can just pass a very large array of set cpumask bits and the
// kernel will silently convert that to the correct value very cheaply.

// Ideally, we would just set the array to 0xFF...FF. Unfortunately, the
// size depends on the architecture. It is also a private newtype, so we
// can't use (^0) or generics since those require us to be able to name the
// type. However, we can just underflow the zero value instead.
// TODO: Once <https://golang.org/cl/698015> is merged, switch to that.
cpuset := unix.CPUSet{}
for i := range cpuset {
cpuset[i]-- // underflow to 0xFF..FF
}
var cpuset unix.CPUSet
cpuset.Fill() // set all bits
if err := unix.SchedSetaffinity(pid, &cpuset); err != nil {
logrus.WithError(
os.NewSyscallError("sched_setaffinity", err),
Expand Down