Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
htejun opened this issue Jun 19, 2023 · 0 comments

Comments

@htejun
Copy link

htejun commented Jun 19, 2023

KernelStats::cpu_time is a Vec<CpuTime> 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.

htejun added a commit to sched-ext/sched_ext that referenced this issue Jun 20, 2023
Neither procfs or fb_procfs can determine per-CPU utilization reliably with
CPU hot[un]plugs. Roll our own.

  eminence/procfs#274
  facebookincubator/below#8190
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant