bug: CPU usage misses other processes that share the same CPU limit (cgroup v2)
@DanielleMaywood đang làm issue này rồi.
Từ ngày 23/10/2026.
Đánh giá
- Độ khó
- 3/5
- Thời gian dự kiến
- 1-2 ngày
- Mức phù hợp với người mới
- 67/100
- Loại issue
- Lỗi
- Độ rõ ràng
- Đặc tả rõ ràng
- Mức độ hoạt động
- Sôi nổi
- Công nghệ
- go, linux
- Lĩnh vực
- observability
Hướng nghiên cứu
Read the CPU limit and usage handling behind ContainerCPU(), then compare it with the memory cgroup selection described in #39. Update CPU usage selection to use the cgroup with the applicable limit, and check that usage remains unchanged when the process cgroup has the limit or no limit exists. The expected reproduction is about 4.3/12 cores (36%) in the reported nested cgroup setup.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
Summary
This is the CPU version of #38.
clistat gets the CPU limit from the nearest parent cgroup that has one. But it reads CPU usage from the process's own cgroup. Other cgroups under that parent use the same limit, but their usage is not counted. So clistat can show the container as almost idle when it is busy.
This often happens when a container runs other containers inside it. The process is in /init.scope and the inner containers are in /docker/<id>. Both are under the container root, which has the limit.
Why this is wrong
- A cgroup's
cpu.statincludes CPU time from all cgroups below it. In the kernel, each cgroup's CPU time is added to its parent's (cgroup_base_stat_flush()inkernel/cgroup/rstat.c, v6.17). If you only want a cgroup's own time, there is a separate file,cpu.stat.local. - A limit in
cpu.maxapplies to the cgroup and everything below it (cgroup v2 docs).
So to see how close we are to the limit, we must read usage from the cgroup that has the limit.
How to reproduce
We used a sysbox container on cgroup v2. The container root has a 12-core limit (cpu.max is 1200000 100000). /init.scope has no limit, and the process is in /init.scope. Then we ran 4 busy loops in an inner container:
docker run -d --name cpuhog alpine sh -c 'for i in 1 2 3 4; do (while :; do :; done) & done; wait'
| What we measured (over 2 seconds) | Cores used |
|---|---|
| Container root | 4.3 |
/docker |
4.01 |
/init.scope |
0.01 |
ContainerCPU() on main (a2db32a) |
0.009/12 cores (0%) |
What should happen
clistat should show about 4.3/12 cores (36%).
How to fix it
Do the same thing #39 does for memory. Find the cgroup that has the CPU limit, then read CPU usage from that same cgroup. If the process's own cgroup has the limit, or there is no limit, nothing changes.
The nearest limit is not always the one that matters. That is a separate problem, covered in #40.
Generated by Coder Agents on behalf of @DanielleMaywood.
- Ngôn ngữ chính
- Go
- Star
- 11
- Fork
- 2
- Merge trung bình
- 2 ngày 21 giờ
- Pull request đã merge (30 ngày)
- 1
Chuẩn bị môi trường
Dự án này không cung cấp dev container, Dockerfile hay hướng dẫn đóng góp, nên bạn cần tự thiết lập môi trường: hãy bắt đầu từ README và xem hướng dẫn đóng góp lần đầu của chúng tôi để biết các bước chung.
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Issue khác của coder/clistat
-
Bug
Độ khó 4/5 3-5 ngày Mức phù hợp với người mới 48/100
-
feat: add directory-level disk usage statsCó thể làm lại được Pull request cho issue này đã bị đóng mà không được merge. Đang mởenhancement
Độ khó 5/5 Hơn một tuần Mức phù hợp với người mới 35/100
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 45/100
Tất cả issue của coder/clistat
Issue tương tự
-
bug
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 77/100
teradata-labs/loom#574 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
cli: name the CRID when saved link limits fail after publish; soften plain-republish mint warningĐang mởenhancement pr-polish-followup priority: low
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 74/100
layervai/qurl-integrations#1994 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
[Bug]: `Match exec "step ssh check-host %h"` causes SSH connections through ProxyJump to hangĐang mởbug needs triage
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 74/100
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 70/100
CycloneDX/cyclonedx-go#304 ·
-
[Bug]: snowflake_share fails to read a share attached to a listing with target accounts ('TARGETED ACCOUNTS' in the "to" column)Có thể đã có người làm @akhil9tiet đã nhận hôm nay. Đang mởbug
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 84/100
snowflakedb/terraform-provider-snowflake#5366 · 2 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày