]> git.lizzy.rs Git - rust.git/commit - src/tools/miri
Auto merge of #97925 - the8472:cgroupv1, r=joshtriplett
authorbors <bors@rust-lang.org>
Sat, 23 Jul 2022 13:33:56 +0000 (13:33 +0000)
committerbors <bors@rust-lang.org>
Sat, 23 Jul 2022 13:33:56 +0000 (13:33 +0000)
commite55c53c57e953a4f5716461dbaf4af5d623d80da
tree8b73737293b99669118647a024ceb51c2e2ee047
parent2e43d068ced2162bc57da332094c06604bc1b191
parent2e33c812e8b1bea563893f17ff5edcb7023d5d41
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::thread::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.
library/std/src/lib.rs
library/std/src/sys/unix/thread.rs
library/std/src/thread/mod.rs