Skip to content

Conversation

@kolyshkin
Copy link
Contributor

@kolyshkin kolyshkin commented Oct 29, 2025

This is an alternative to #47, implementing ideas I left as review comments in there.

First, we can reasonably expect the first three fields of cpuacct.usage_all to be cpu user system, even for future kernels, and if we see something different, it doesn't make sense to continue. So check that the header is as expected, and error out otherwise.

Second, if we have more than 3 values, and we've checked that the first 3 are as expected (cpu user system), we can safely ignore extra columns. This fixes an issue on a custom kernel from Tencent, which
adds a few extra columns (see 1), as reported in #46.

Add tests for both cases.

Fixes: #46.

@kolyshkin kolyshkin added this to the 0.0.6 milestone Oct 29, 2025
@kolyshkin
Copy link
Contributor Author

@lifubang PTAL

Copy link
Member

@cyphar cyphar left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As @AkihiroSuda said, it would be nice if the commit message and/or test mentioned that this is necessary because of out-of-tree patches in Tencent's kernels, but otherwise LGTM.

First, we can reasonably expect the first three fields of
cpuacct.usage_all to be "cpu user system", even for future kernels,
and if we see something different, it doesn't make sense to continue.
So check that the header is as expected, and error out otherwise.

Second, if we have more than 3 values, and we've checked that the first
3 are as expected ("cpu user system"), we can safely ignore extra
columns. This fixes an issue on a custom kernel from Tencent, which
adds a few extra columns (see [1]), as reported in issue 46.

Add tests for both cases.

Fixes issue 46.

[1]: OpenCloudOS/TencentOS-kernel-0@0b66781
Reported-by: vimiix <[email protected]>
Signed-off-by: Kir Kolyshkin <[email protected]>
@kolyshkin kolyshkin requested a review from AkihiroSuda October 30, 2025 19:17
@kolyshkin kolyshkin changed the title fs: improve cpuacct.usage_all parsing fs: fix/improve cpuacct.usage_all parsing Oct 30, 2025
@kolyshkin
Copy link
Contributor Author

@lifubang PTAL 🙏🏻

@AkihiroSuda AkihiroSuda merged commit e0c56cb into opencontainers:main Oct 31, 2025
14 checks passed
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.

kubelet fails to start due to cgroups CPU stat parsing failed in k8s 1.34

4 participants