cgroup: add BPF probe for v1 fallback and improve GCS error diagnostic#2716
Open
jiechen0826 wants to merge 2 commits intomicrosoft:mainfrom
Open
cgroup: add BPF probe for v1 fallback and improve GCS error diagnostic#2716jiechen0826 wants to merge 2 commits intomicrosoft:mainfrom
jiechen0826 wants to merge 2 commits intomicrosoft:mainfrom
Conversation
782b8c8 to
ed9fc20
Compare
helsaawy
reviewed
May 4, 2026
ed9fc20 to
24115fd
Compare
init.c: Probe BPF_CGROUP_DEVICE before committing to cgroup v2. If the kernel lacks CONFIG_CGROUP_BPF (e.g. Yocto 6.1), fall back to v1. Also add has_v1_controllers() guard and hcsshim.cgroup=v1 kernel parameter. cmd/gcs/main.go: Improve fatal error message when the v1 memory controller is absent (CONFIG_MEMCG_V1 disabled, e.g. kernel 6.18+) to point at the kernel config and the v2 + BPF alternative. Signed-off-by: Jie Chen <jiechen3@microsoft.com>
On Ubuntu 6.17 kernels, the vsock read in init_entropy() returns ENOMEM after hv_sock module load when transport buffers are not yet initialized. Since init runs as PID 1, die() triggers a kernel panic. Change all die() calls in init_entropy() to warn()+dmesgWarn()+return/break so the UVM can boot without entropy seeding. Entropy improves randomness quality but is not required for UVM operation. Tested: Ubuntu 6.17.0-1008-azure kernel boots successfully with this fix. Without it, sandbox creation fails with 'context deadline exceeded' as the GCS never starts. Signed-off-by: Jie Chen <jiechen3@microsoft.com>
b24e7a1 to
a9feab8
Compare
helsaawy
approved these changes
May 5, 2026
msscotb
approved these changes
May 6, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
On Yocto kernels (e.g. 6.1.153.1-microsoft-standard), the kernel supports the
cgroup2filesystem but lacksCONFIG_CGROUP_BPF. When init mounts cgroup v2 and finds controllers, it commits to v2. Later, runc triesBPF_PROG_QUERYonBPF_CGROUP_DEVICEand getsENOSYS, causing container creation to fail.Separately, on ARM kernels with
CONFIG_MEMCG_V1disabled (e.g. 6.18+), the GCS crashes with a generic error when the v1 memory controller is absent, making it hard to diagnose.On Ubuntu 6.17 kernels, the vsock
read()ininit_entropy()returnsENOMEMafterhv_sockmodule load when transport buffers are not yet initialized. Since init runs as PID 1, thedie()call triggers a kernel panic, preventing the UVM from booting.Fix
init.c (commit 1): Before committing to cgroup v2, probe BPF cgroup support by issuing
BPF_PROG_QUERYwithattach_type = BPF_CGROUP_DEVICEon the cgroup root fd. If the kernel returnsENOSYSorEINVAL(no BPF support), unmount cgroup2 and fall back to v1. Also add amountedcounter ininit_cgroups_v1()to die cleanly when no v1 controllers are available, and addhcsshim.cgroup=v1kernel parameter to force v1.main.go (commit 1): Improve the fatal error message when the v1 memory controller is absent to point at
CONFIG_MEMCG_V1and the cgroup v2 +CONFIG_CGROUP_BPFalternative.init.c (commit 2): Make entropy seeding non-fatal by replacing
die()withwarn()+dmesgWarn()+ early return/break. The UVM can function without entropy seeding.Testing
ENOSYSfrom BPF probe, falls back to v1, LCOW smoke test passesfailed to connect to entropy socket: context deadline exceeded