File tree Expand file tree Collapse file tree 1 file changed +5
-15
lines changed Expand file tree Collapse file tree 1 file changed +5
-15
lines changed Original file line number Diff line number Diff line change 8282libcrun_reset_cpu_affinity_mask (pid_t pid , libcrun_error_t * err )
8383{
8484 int ret ;
85+ cpu_set_t mask ;
8586
8687 /* Reset the inherited cpu affinity. Old kernels do that automatically, but
8788 new kernels remember the affinity that was set before the cgroup move.
8889 This is undesirable, because it inherits the systemd affinity when the container
8990 should really move to the container space cpus.
90-
91- The sched_setaffinity call will always return an error (EINVAL or ENODEV);
92- when used like this. This is expected and part of the backward compatibility.
93-
94- Ignore ENOSYS as well, as it might be blocked by seccomp.
95-
9691 See: https://issues.redhat.com/browse/OCPBUGS-15102 */
97- ret = sched_setaffinity (pid , 0 , NULL );
98- if (LIKELY (ret < 0 ))
99- {
100- if (LIKELY (errno == EINVAL || errno == ENODEV || errno == ENOSYS ))
101- return 0 ;
102-
103- return crun_make_error (err , errno , "failed to reset affinity" );
104- }
105-
92+ memset (& mask , 0xFF , sizeof (cpu_set_t ));
93+ ret = sched_setaffinity (pid , sizeof (mask ), & mask );
94+ if (UNLIKELY (ret < 0 ))
95+ return crun_make_error (err , errno , "sched_setaffinity" );
10696 return 0 ;
10797}
10898
You can’t perform that action at this time.
0 commit comments