Updated check_config with cgroupv2 controllers#41897
Conversation
d06f3f6 to
8ba4858
Compare
|
Thanks! @AkihiroSuda @tianon ptal 🤗 |
contrib/check-config.sh
Outdated
There was a problem hiding this comment.
This file (fairly consistently) uses camelCase for variables (and snake_case for functions). I think we should also consider it a failure case if we don't find the referenced file:
| cgroupv2_controller_loc="/sys/fs/cgroup/cgroup.controllers" | |
| # Prints available cgroupv2 controllers if the file exists | |
| if test -f "$cgroupv2_controller_loc"; then | |
| mapfile -t cgroupv2_controllers < $cgroupv2_controller_loc | |
| wrap_good "- cgroupv2 controllers" "${cgroupv2_controllers[*]}" | |
| else | |
| echo "$cgroupv2_controller_loc not found." | |
| fi | |
| cgroupv2ControllersFile='/sys/fs/cgroup/cgroup.controllers' | |
| if [ -s "$cgroupv2ControllersFile" ]; then | |
| mapfile -t cgroupv2Controllers < "$cgroupv2ControllersFile" | |
| wrap_good '- cgroupv2 controllers' "${cgroupv2Controllers[*]}" | |
| else | |
| wrap_warning "warning: missing '$cgroupv2ControllersFile'" | |
| fi |
There was a problem hiding this comment.
My bad, I'll update the variable names to camelCase and create the warning if the file doesn't exist.
contrib/check-config.sh
Outdated
There was a problem hiding this comment.
we should confirm that the file contains the following controllers:
- cpu
- cpuset
- memory
- io
- pids
There was a problem hiding this comment.
I'll update it to show if the file has cpu,cpuset,memory,io,pids enabled or missing similar to other checks.
|
Can we also check existence of freezer? |
@AkihiroSuda The doc mentions cgroup.freezer file https://www.kernel.org/doc/html/latest/admin-guide/cgroup-v2.html#core-interface-files. But I don't see the file |
|
|
AkihiroSuda
left a comment
There was a problem hiding this comment.
Thanks, but could you squash commits
fb5643d to
c155c9f
Compare
Done |
|
Thanks for updating! @tianon ptal |
contrib/check-config.sh
Outdated
There was a problem hiding this comment.
Sorry for the delay -- this needs a rebase, but I think we can also simplify this a bit (and make sure it's still POSIX compatible, per #42410, which the mapfile-based implementation is not) with something like the following:
| cgroupv2ControllerFile="/sys/fs/cgroup/cgroup.controllers" | |
| # Prints available cgroupv2 controllers if the file exists | |
| if test -f "$cgroupv2ControllerFile"; then | |
| mapfile -t cgroupv2Controllers < $cgroupv2ControllerFile | |
| echo "- cgroupv2 controllers:" | |
| controllersv2=($cgroupv2Controllers) | |
| [[ " ${controllersv2[@]} " =~ " io " ]] && wrap_good " - IO" "available" || wrap_bad " - IO" "missing" | |
| [[ " ${controllersv2[@]} " =~ " cpu " ]] && wrap_good " - CPU" "available" || wrap_bad " - CPU" "missing" | |
| [[ " ${controllersv2[@]} " =~ " cpuset " ]] && wrap_good " - CPUSET" "available" || wrap_bad " - CPUSET" "missing" | |
| [[ " ${controllersv2[@]} " =~ " pids " ]] && wrap_good " - PIDs" "available" || wrap_bad " - PIDs" "missing" | |
| [[ " ${controllersv2[@]} " =~ " memory " ]] && wrap_good " - MEMORY" "available" || wrap_bad " - MEMORY" "missing" | |
| else | |
| echo wrap_warning "warning: missing '$cgroupv2ControllerFile'" | |
| fi | |
| #check if cgroup.freeze exists in subdir | |
| [ -n "$(find /sys/fs/cgroup -type f -name "cgroup.freeze" 2> /dev/null)" ] && wrap_good '- cgroupv2 freezer' 'available' || wrap_bad '- cgroupv2 freezer' 'missing' | |
| cgroupv2ControllerFile='/sys/fs/cgroup/cgroup.controllers' | |
| if [ -f "$cgroupv2ControllerFile" ]; then | |
| echo ' Controllers:' | |
| for controller in cpu cpuset io memory pids; do | |
| if grep -qE '(^| )'"$controller"'($| )' "$cgroupv2ControllerFile"; then | |
| echo " - $(wrap_good "$controller" 'available')" | |
| else | |
| echo " - $(wrap_bad "$controller" 'missing')" | |
| fi | |
| done | |
| else | |
| wrap_bad "$cgroupv2ControllerFile" 'nonexistent??' | |
| fi |
I'm also not wild about the unbounded find /sys/fs/cgroup -- I think if we can't find a better way to check whether the cgroup freezer is available then we should probably just leave a TODO comment instead (or not worry about it -- can any of these actually be usefully disabled?). 😕 😞
There was a problem hiding this comment.
Yes, That makes sense. I'll rebase and update the checks for controllers in POSIX. As for the freezer check I'm not sure if we can disable it. I'll have to read about it. I can try to find a better way to do the check or I'll update it with aTODO. Is that okay?
|
@thaJeztah @tianon Sorry for the late response. I'll get right on it. |
c155c9f to
a3e3d37
Compare
tianon
left a comment
There was a problem hiding this comment.
Just two really minor nits but otherwise this LGTM! Thank you! 🎉
(I'm happy to push these changes myself if you'd rather or if that'd be helpful for you. 👍)
contrib/check-config.sh
Outdated
There was a problem hiding this comment.
| #TODO check if cgroup.freeze exists in subdir | |
| # TODO find an efficient way to check if cgroup.freeze exists in subdir |
contrib/check-config.sh
Outdated
There was a problem hiding this comment.
| echo "$(wrap_good 'cgroup hierarchy' 'cgroupv2')" | |
| wrap_good 'cgroup hierarchy' 'cgroupv2' |
Signed-off-by: gunadhya <6939749+gunadhya@users.noreply.github.com> Added cgroupv2 controller check Modified comment
a3e3d37 to
aff02db
Compare
|
@tianon I've updated the pr with new changes. |
thaJeztah
left a comment
There was a problem hiding this comment.
LGTM, thanks!!
perhaps we should create a tracking issue for the todo (in case someone wants to work on that)




Fixes #41874
- What I did
Added cgroupv2 available controllers and check for CONFIG_CGROUP_BPF in contrib/check-config.sh
- How I did it
- How to verify it
Output :
Ran on Linux 5.4.0-62-generic
- Description for the changelog
Update in contrib/check-config.sh cgroupv2 controllers and CONFIG_CGROUP_BPF
- A picture of a cute animal (not mandatory but encouraged)