-
Notifications
You must be signed in to change notification settings - Fork 269
Add awareness of cpusets (cgroup) #1576
Description
Shadow may be restricted to run on a subset of CPUs by assigning it to a cpuset. (see cpuset(7)).
While after #1575 Shadow checks the initial cpu affinity, afaict from sched_getaffinity(2), the mask returned by sched_getaffinity can include CPUs that aren't actually in the process's cpuset, and if we try to call sched_setaffinity to a cpu not in that set, it'll fail with EINVAL.
i.e. IIUC, if Shadow is run in a restricted cpuset and tries to pin to a cpu outside of that set, sched_setaffinity will fail. Shadow will log the error and continue on without pinning.
It'd be nice if instead Shadow also considered the set of eligible CPUs in the cpuset cgroup. AFAICT the only interface the kernel exposes for getting that set of cpus is by parsing /proc/<pid>/status, Cpus_allowed or Cpus_allowed_list.