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

Read cpu.stat regardless if controller enabled. #348

Open
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

jay-mckay
Copy link

The unified hierarchy provides the cpu.stat file for every cgroup, regardless if the CPU controller is enabled (in fact, setting the systemd property CPUAccounting=True does not enable this controller because of this fact). It provides the usage_usec, user_usec, and system_usec by default. Instead of reading the stat for each enabled controller (CPU and memory), just attempt to read them each time the Stat() function is called.

Attempting to read the memory.stat file even if memory accounting is not enabled seems insignificant (some other files always have a read attempt, such as memory.current), and eliminates finding and looping over enabled controllers.

resolves #347

jay-mckay and others added 3 commits September 3, 2024 13:22
The unified hierarchy provides the cpu.stat file for every cgroup,
regardless if the CPU controller is enabled (in fact, setting the
systemd property CPUAccounting=True does not enable this controller
because of this fact). It provides the usage_usec, user_usec,
and system_usec by default. Instead of reading the stat for each
enabled controller (CPU and memory), just attempt to read them
each time the Stat() function is called.

Attempting to read the memory.stat file even if memory accounting
is not enabled seems insignificant (some other files always have
a read attempt, such as memory.current), and eliminates finding and
looping over enabled controllers.

Resolves: containerd#347

Signed-off-by: Jackson McKay  <[email protected]>
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

Successfully merging this pull request may close these issues.

Support cgroup v2 CPU stats when controller not enabled
1 participant