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 1 commit 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

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  <jackjaymckay@gmail.com>
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