Closed Xeway closed 7 months ago
What environment are you running in?
My bad, fixed it with echo '+cpu' | sudo tee /sys/fs/cgroup/cgroup.subtree_control
.
If anyone passes by, instead of directly writing to cgroup.subtree_control
file, you can also add controllers with ToggleControllers
function.
Here's an example of how to use it to add memory and cpu controllers:
// Enable the memory and CPU controllers
if err := m.ToggleControllers([]string{"memory", "cpu"}, cgroup2.Enable); err != nil {
log.Fatal(err)
}
When I run:
go build && sudo ./my-program
, I get the error:open /sys/fs/cgroup/my_cgroup.slice/cpu.max: permission denied
. And in reality, the cpu.max file doesn't exists. I tried to create it but I always getpermission denied
even when I change chmod to 777 for/sys/fs/cgroup/my_cgroup.slice
directory.