-
Notifications
You must be signed in to change notification settings - Fork 260
proc_fuse: fix proc_stat_read reporting host cpu count under cgroup v2 #687
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
Conversation
@last-las can you edit your commit message to include the required Signed-off-by line? (see CONTRIBUTING.md) |
Signed-off-by: Quanjin Lin <[email protected]>
6fccfda
to
255b7a7
Compare
done! |
@mihalicyn can you take a look? |
on cgroups v2 only, host cpu usage is bleeding into container htop cpu bar, and i think (but haven't tested) that this will fix it 👍 (this does not happen on cgroups v1. on proxmox8 i was switching to cgroups v1 to avoid this issue, but proxmox9 dropped support for cgroups v1) |
Hi @last-las, thanks for working on this and preparing a PR. I was thinking about this way too, before. But my concern was and is that if we handle this like that, what we end up with is incorrect
will still be taken from a host, isn't it? So the question is then should we instead go and make a proper kernel support for that CPU time accounting (as it was in cgroupv1) or just apply this half-measure? Could you elaborate why this cpu-filtering-only solution even works for you? What kind of use-case do you have for this |
Hi @divinity76, please can you also share your use-case for this |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In general, if it helps users I see no problem merging this after we discuss use cases.
virtualized HestiaCP instances trigger high-cpu-usage-warning-emails to the registered HestiaCP admin when the hypervisor CPU usage is high, it shouldn't. Ideally, HestiaCP should not see the hypervisor cpu usage at all. htop also report the host cpu usage, not the virtual cpu usage, when humans inspect manually. this does not happen with cgroups v1. |
sry for the late
I agree that the perfect solution would be to support it in the kernel.
|
cgroup v2 doesn't have a file similar to
cpuacct.usage_all
. Therefore, theproc_stat_read
in cgroup v2 always falls back to the host's /proc/stat. As a result, the CPU count reported by this file is incorrect, e.g. issues #593 and #654.However, the similar
proc_cpuinfo_read
function does report the right CPU counts. It works by filtering the host's file using bothcpuset.cpus
andcpu.max
. This patch fixesproc_stat_read
by using the same method.