containers / common

Location for shared common files in github.com/containers repos.
Apache License 2.0
193 stars 201 forks source link

cgroup cpuset is not set correctly #2229

Closed mmmmaeda closed 2 weeks ago

mmmmaeda commented 2 weeks ago

The cpuset value setting for cgroup is not set correctly.

In Podman, there are the following issues: https://github.com/containers/podman/issues/24465

The value specified using the --cpuset-cpus option during pod creation is not set correctly as shown below.

$ podman pod create --cpuset-cpus 0 my-pod f5ebcc851517c729f34c27bfe895cf09afc8a51bab055c8244cdb876a8e67e2c

$ journalctl | grep f5ebcc851517c729f34c27bfe895cf09afc8a51bab055c8244cdb876a8e67e2c | grep cpuset systemd[2274]: user-libpod_pod_f5ebcc851517c729f34c27bfe895cf09afc8a51bab055c8244cdb876a8e67e2c.slice: Failed to set 'cpuset.cpus' attribute on '/user.slice/user-1000.slice/user@1000.service/user.slice/ user-libpod_pod_f5ebcc851517c729f34c27bfe895cf09afc8a51bab055c8244cdb876a8e67e2c.slice' to '4-5': Numerical result out of range

In the following, the value of CpusetCpus is being converted to bits as a string, not as a numerical value. https://github.com/containers/common/blob/main/pkg/cgroups/systemd_linux.go#L182

The following conversion function is required. https://github.com/opencontainers/runc/blob/main/libcontainer/cgroups/systemd/cpuset.go#L14