1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
//! Core enumeration and thread pinning — the helpers you need to stand up your
//! own thread-per-core runtime around a [`Pool`](crate::Pool).
pub use CoreId;
/// The cores this process may run on, sorted by id, with duplicates removed.
///
/// This is the affinity mask, not the machine: under `taskset` or a cgroup
/// cpuset only the permitted cores are returned, and that is the right set to
/// put workers on.
/// Pin the calling thread to `core`. Returns whether the kernel accepted it.
///
/// Call it inside each thread's closure before you build that thread's runtime,
/// so the ring and everything allocated after it belong to that core.
/// The `/proc/irq/<n>/smp_affinity` mask that names exactly `cpu`:
/// comma-separated 32-bit hex words, most significant first.
///
/// `scripts/tune-nic.sh` writes the same format, so a worker's log line and the
/// IRQ it should be fed by can be compared by eye.
///
/// ```
/// assert_eq!(compio_pool::cpu::affinity_mask(3), "00000008");
/// assert_eq!(compio_pool::cpu::affinity_mask(35), "00000008,00000000");
/// ```