Auto merge of #97925 - the8472:cgroupv1, r=joshtriplett
Add cgroupv1 support to available_parallelism Fixes #97549 My dev machine uses cgroup v2 so I was only able to test that code path. So the v1 code path is written only based on documentation. I could use some help testing that it works on a machine with cgroups v1: ``` $ x.py build --stage 1 # quota.rs fn main() { println!("{:?}", std:🧵:available_parallelism()); } # assuming stage1 is linked in rustup $ rust +stage1 quota.rs # spawn a new cgroup scope for the current user $ sudo systemd-run -p CPUQuota="300%" --uid=$(id -u) -tdS # should print Ok(3) $ ./quota ``` If it doesn't work as expected an strace, the contents of `/proc/self/cgroups` and the structure of `/sys/fs/cgroups` would help.
This commit is contained in:
commit
e55c53c57e
3 changed files with 195 additions and 46 deletions
|
|
@ -1577,10 +1577,15 @@ fn _assert_sync_and_send() {
|
|||
///
|
||||
/// On Linux:
|
||||
/// - It may overcount the amount of parallelism available when limited by a
|
||||
/// process-wide affinity mask or cgroup quotas and cgroup2 fs or `sched_getaffinity()` can't be
|
||||
/// process-wide affinity mask or cgroup quotas and `sched_getaffinity()` or cgroup fs can't be
|
||||
/// queried, e.g. due to sandboxing.
|
||||
/// - It may undercount the amount of parallelism if the current thread's affinity mask
|
||||
/// does not reflect the process' cpuset, e.g. due to pinned threads.
|
||||
/// - If the process is in a cgroup v1 cpu controller, this may need to
|
||||
/// scan mountpoints to find the corresponding cgroup v1 controller,
|
||||
/// which may take time on systems with large numbers of mountpoints.
|
||||
/// (This does not apply to cgroup v2, or to processes not in a
|
||||
/// cgroup.)
|
||||
///
|
||||
/// On all targets:
|
||||
/// - It may overcount the amount of parallelism available when running in a VM
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue