eminence / eminence/procfs

No way to match `KernelStats::cpu_time` entries to CPUs when CPUs are hot [un]plugged

Open
#274 0 comments 1 reaction 0 assignees View on GitHub
Dominant language
Rust
Stars
445
Forks
134
PR merge metrics
No merged PRs in 30d

Description

`KernelStats::cpu_time` is a `Vec` where each entry shows the per-CPU utilization information from `/proc/stat`. However, it discards the CPU index from `/proc/stat` making it impossible to match the utilization to the originating CPU. For example, here's `/proc/stat` on a QEMU instance w/ 4 CPUs:

```
# cat /proc/stat
cpu 113613 21 2406 5547556 641 0 144 0 0 0
cpu0 26133 18 1309 2725972 370 0 134 0 0 0
cpu1 32707 2 422 2709984 266 0 2 0 0 0
cpu2 28312 0 587 67 0 0 7 0 0 0
cpu3 26460 0 86 111532 5 0 0 0 0 0
```

After taking cpu2 offline with `echo 0 > /sys/devices/system/cpu/cpu2/online`, the file looks as follows:

```
# cat /proc/stat
cpu 113618 21 2412 8207884 686 0 145 0 0 0
cpu0 26136 18 1312 2733593 371 0 135 0 0 0
cpu1 32708 2 424 2717609 268 0 2 0 0 0
cpu3 26460 0 87 119161 6 0 0 0 0 0
```

`KernelStats::cpu_time` will contain 3 entries but without any way to reliably find out which three CPUs are being reported. Corroborating other sources doesn't really work as there may be intervening hot[un]plug operations between reads.

It seems like `KernelStats::cpu_time`, instead of being a Vec, should be keyed with CPU ID read from `/proc/stat`.

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.