@@ -144,6 +144,14 @@ func (p *setnsProcess) start() (retErr error) {
144
144
}
145
145
}
146
146
}
147
+ // Reset the inherited cpu affinity. Old kernels do that automatically, but
148
+ // new kernels remember the affinity that was set before the cgroup move.
149
+ // This is undesirable, because it inherits the systemd affinity when the container
150
+ // should really move to the container space cpus.
151
+ if err = unix .SchedSetaffinity (p .pid (), & unix.CPUSet {}); err != nil && err != unix .EINVAL && err != unix .ENODEV { //nolint:errorlint
152
+ return fmt .Errorf ("error resetting pid %d affinity: %w" , p .pid (), err )
153
+ }
154
+
147
155
if p .intelRdtPath != "" {
148
156
// if Intel RDT "resource control" filesystem path exists
149
157
_ , err := os .Stat (p .intelRdtPath )
@@ -419,6 +427,14 @@ func (p *initProcess) start() (retErr error) {
419
427
if err := p .manager .Apply (p .pid ()); err != nil {
420
428
return fmt .Errorf ("unable to apply cgroup configuration: %w" , err )
421
429
}
430
+
431
+ // Reset the inherited cpu affinity. Old kernels do that automatically, but
432
+ // new kernels remember the affinity that was set before the cgroup move.
433
+ // This is undesirable, because it inherits the systemd affinity when the container
434
+ // should really move to the container space cpus.
435
+ if err = unix .SchedSetaffinity (p .pid (), & unix.CPUSet {}); err != nil && err != unix .EINVAL && err != unix .ENODEV { //nolint:errorlint
436
+ return fmt .Errorf ("error resetting pid %d affinity: %w" , p .pid (), err )
437
+ }
422
438
if p .intelRdtManager != nil {
423
439
if err := p .intelRdtManager .Apply (p .pid ()); err != nil {
424
440
return fmt .Errorf ("unable to apply Intel RDT configuration: %w" , err )
0 commit comments