Open hejiahang929 opened 3 months ago
Hi @hejiahang929
Thank you for your report!
I have tried to reproduce this on my environment with LXC and found no issues. But I have an idea what can be different in your case.
Please, provide the following information.
(from the host)
ls -la /proc/self/ns
cat /sys/fs/cgroup/cgroup.controllers
mount | grep cgroup
uname -a
(from the container/k8s pod)
ls -la /proc/self/ns
cat /sys/fs/cgroup/cgroup.controllers
Hi @mihalicyn Thank you for your reply!
follow is the information:
lrwxrwxrwx 1 root root 0 Mar 27 17:32 cgroup -> cgroup:[4026531835] lrwxrwxrwx 1 root root 0 Mar 27 17:32 ipc -> ipc:[4026531839] lrwxrwxrwx 1 root root 0 Mar 27 17:32 mnt -> mnt:[4026531840] lrwxrwxrwx 1 root root 0 Mar 27 17:32 net -> net:[4026532008] lrwxrwxrwx 1 root root 0 Mar 27 17:32 pid -> pid:[4026531836] lrwxrwxrwx 1 root root 0 Mar 27 17:32 pid_for_children -> pid:[4026531836] lrwxrwxrwx 1 root root 0 Mar 27 17:32 user -> user:[4026531837] lrwxrwxrwx 1 root root 0 Mar 27 17:32 uts -> uts:[4026531838]
cat /proc/cgroups
cpuset 5 66 1 cpu 8 215 1 cpuacct 8 215 1 blkio 9 215 1 memory 12 351 1 devices 7 200 1 freezer 2 66 1 net_cls 10 66 1 perf_event 3 66 1 net_prio 10 66 1 hugetlb 4 66 1 pids 6 215 1 rdma 11 66 1
tmpfs on /sys/fs/cgroup type tmpfs (ro,nosuid,nodev,noexec,mode=755) cgroup on /sys/fs/cgroup/systemd type cgroup (rw,nosuid,nodev,noexec,relatime,xattr,release_agent=/usr/lib/systemd/systemd-cgroups-agent,name=systemd) cgroup on /sys/fs/cgroup/freezer type cgroup (rw,nosuid,nodev,noexec,relatime,freezer) cgroup on /sys/fs/cgroup/perf_event type cgroup (rw,nosuid,nodev,noexec,relatime,perf_event) cgroup on /sys/fs/cgroup/hugetlb type cgroup (rw,nosuid,nodev,noexec,relatime,hugetlb) cgroup on /sys/fs/cgroup/cpuset type cgroup (rw,nosuid,nodev,noexec,relatime,cpuset) cgroup on /sys/fs/cgroup/pids type cgroup (rw,nosuid,nodev,noexec,relatime,pids) cgroup on /sys/fs/cgroup/devices type cgroup (rw,nosuid,nodev,noexec,relatime,devices) cgroup on /sys/fs/cgroup/cpu,cpuacct type cgroup (rw,nosuid,nodev,noexec,relatime,cpu,cpuacct) cgroup on /sys/fs/cgroup/blkio type cgroup (rw,nosuid,nodev,noexec,relatime,blkio) cgroup on /sys/fs/cgroup/net_cls,net_prio type cgroup (rw,nosuid,nodev,noexec,relatime,net_cls,net_prio) cgroup on /sys/fs/cgroup/rdma type cgroup (rw,nosuid,nodev,noexec,relatime,rdma) cgroup on /sys/fs/cgroup/memory type cgroup (rw,nosuid,nodev,noexec,relatime,memory)
Linux cgpcc01n010237206001.sncloud.com 4.18.0-80.11.1.el7.centos.sn11.x86_64 #1 SMP Mon Feb 24 20:34:03 CST 2020 x86_64 x86_64 x86_64 GNU/Linux
lrwxrwxrwx 1 root root 0 Mar 27 17:37 cgroup -> cgroup:[4026531835] lrwxrwxrwx 1 root root 0 Mar 27 17:37 ipc -> ipc:[4026533334] lrwxrwxrwx 1 root root 0 Mar 27 17:37 mnt -> mnt:[4026533336] lrwxrwxrwx 1 root root 0 Mar 27 17:37 net -> net:[4026532008] lrwxrwxrwx 1 root root 0 Mar 27 17:37 pid -> pid:[4026533337] lrwxrwxrwx 1 root root 0 Mar 27 17:37 pid_for_children -> pid:[4026533337] lrwxrwxrwx 1 root root 0 Mar 27 17:37 user -> user:[4026531837] lrwxrwxrwx 1 root root 0 Mar 27 17:37 uts -> uts:[4026531838]
cat /proc/cgroups
cpuset 4 45 1 cpu 5 174 1 cpuacct 5 174 1 blkio 3 174 1 memory 8 1109 1 devices 7 160 1 freezer 11 45 1 net_cls 2 45 1 perf_event 10 45 1 net_prio 2 45 1 hugetlb 9 45 1 pids 12 174 1 rdma 6 45 1
I'am also dealing with the same problem/bug.
Container shows correct /proc/cpuinfo, but wrong /proc/stat.
The container uses 5 CPUs. The host has 32 CPUs.
Below is the discussed info:
# cat /proc/cpuinfo |grep processor|wc -l
5
# cat /proc/stat |grep -e 'cpu[[:digit:]]'|wc -l
32
# cat /sys/devices/system/cpu/online
0-4
# ls -la /proc/self/ns
total 0
dr-x--x--x 2 root root 0 Apr 26 07:17 .
dr-xr-xr-x 9 root root 0 Apr 26 07:17 ..
lrwxrwxrwx 1 root root 0 Apr 26 07:17 cgroup -> 'cgroup:[4026533046]'
lrwxrwxrwx 1 root root 0 Apr 26 07:17 ipc -> 'ipc:[4026533044]'
lrwxrwxrwx 1 root root 0 Apr 26 07:17 mnt -> 'mnt:[4026533042]'
lrwxrwxrwx 1 root root 0 Apr 26 07:17 net -> 'net:[4026533048]'
lrwxrwxrwx 1 root root 0 Apr 26 07:17 pid -> 'pid:[4026533045]'
lrwxrwxrwx 1 root root 0 Apr 26 07:17 pid_for_children -> 'pid:[4026533045]'
lrwxrwxrwx 1 root root 0 Apr 26 07:17 time -> 'time:[4026531834]'
lrwxrwxrwx 1 root root 0 Apr 26 07:17 time_for_children -> 'time:[4026531834]'
lrwxrwxrwx 1 root root 0 Apr 26 07:17 user -> 'user:[4026533041]'
lrwxrwxrwx 1 root root 0 Apr 26 07:17 uts -> 'uts:[4026533043]'
# cat /sys/fs/cgroup/cgroup.controllers
cpuset cpu io memory hugetlb pids rdma misc
# lxcfs --version
"6.0.0"
# ls -la /proc/self/ns
total 0
dr-x--x--x 2 root root 0 Apr 26 10:17 .
dr-xr-xr-x 9 root root 0 Apr 26 10:17 ..
lrwxrwxrwx 1 root root 0 Apr 26 10:17 cgroup -> 'cgroup:[4026531835]'
lrwxrwxrwx 1 root root 0 Apr 26 10:17 ipc -> 'ipc:[4026531839]'
lrwxrwxrwx 1 root root 0 Apr 26 10:17 mnt -> 'mnt:[4026531841]'
lrwxrwxrwx 1 root root 0 Apr 26 10:17 net -> 'net:[4026531840]'
lrwxrwxrwx 1 root root 0 Apr 26 10:17 pid -> 'pid:[4026531836]'
lrwxrwxrwx 1 root root 0 Apr 26 10:17 pid_for_children -> 'pid:[4026531836]'
lrwxrwxrwx 1 root root 0 Apr 26 10:17 time -> 'time:[4026531834]'
lrwxrwxrwx 1 root root 0 Apr 26 10:17 time_for_children -> 'time:[4026531834]'
lrwxrwxrwx 1 root root 0 Apr 26 10:17 user -> 'user:[4026531837]'
lrwxrwxrwx 1 root root 0 Apr 26 10:17 uts -> 'uts:[4026531838]'
# cat /sys/fs/cgroup/cgroup.controllers
cpuset cpu io memory hugetlb pids rdma misc
# mount | grep cgroup
cgroup2 on /sys/fs/cgroup type cgroup2 (rw,nosuid,nodev,noexec,relatime)
# uname -a
Linux x.y.gr 6.8.7-300.fc40.x86_64 #1 SMP PREEMPT_DYNAMIC Wed Apr 17 19:21:08 UTC 2024 x86_64 GNU/Linux
# cat /proc/cpuinfo |grep processor|wc -l
32
# cat /proc/stat |grep -e 'cpu[[:digit:]]'|wc -l
32
# cat /sys/devices/system/cpu/online
0-31
# journalctl -u lxcfs|tail -25
-- Boot 06a3613662a147e9acfd441611416f34 --
Apr 26 02:19:30 x.y.gr systemd[1]: Starting lxcfs.service - FUSE filesystem for LXC...
Apr 26 02:19:30 x.y.gr systemd[1]: Started lxcfs.service - FUSE filesystem for LXC.
Apr 26 02:19:30 x.y.gr lxcfs[2028]: Starting LXCFS at /usr/bin/lxcfs
Apr 26 02:19:30 x.y.gr lxcfs[2028]: Running constructor lxcfs_init to reload liblxcfs
Apr 26 02:19:30 x.y.gr lxcfs[2028]: mount namespace: 5
Apr 26 02:19:30 x.y.gr lxcfs[2028]: hierarchies:
Apr 26 02:19:30 x.y.gr lxcfs[2028]: 0: fd: 6: cpuset,cpu,io,memory,hugetlb,pids,rdma,misc
Apr 26 02:19:30 x.y.gr lxcfs[2028]: Kernel supports pidfds
Apr 26 02:19:30 x.y.gr lxcfs[2028]: Kernel supports swap accounting
Apr 26 02:19:30 x.y.gr lxcfs[2028]: api_extensions:
Apr 26 02:19:30 x.y.gr lxcfs[2028]: - cgroups
Apr 26 02:19:30 x.y.gr lxcfs[2028]: - sys_cpu_online
Apr 26 02:19:30 x.y.gr lxcfs[2028]: - proc_cpuinfo
Apr 26 02:19:30 x.y.gr lxcfs[2028]: - proc_diskstats
Apr 26 02:19:30 x.y.gr lxcfs[2028]: - proc_loadavg
Apr 26 02:19:30 x.y.gr lxcfs[2028]: - proc_meminfo
Apr 26 02:19:30 x.y.gr lxcfs[2028]: - proc_stat
Apr 26 02:19:30 x.y.gr lxcfs[2028]: - proc_swaps
Apr 26 02:19:30 x.y.gr lxcfs[2028]: - proc_uptime
Apr 26 02:19:30 x.y.gr lxcfs[2028]: - proc_slabinfo
Apr 26 02:19:30 x.y.gr lxcfs[2028]: - shared_pidns
Apr 26 02:19:30 x.y.gr lxcfs[2028]: - cpuview_daemon
Apr 26 02:19:30 x.y.gr lxcfs[2028]: - loadavg_daemon
Apr 26 02:19:30 x.y.gr lxcfs[2028]: - pidfds
# dnf list installed|grep lxc
incus.x86_64 6.0.0-0.1.fc40 @copr:copr.fedorainfracloud.org:ganto:lxc4
incus-agent.x86_64 6.0.0-0.1.fc40 @copr:copr.fedorainfracloud.org:ganto:lxc4
incus-client.x86_64 6.0.0-0.1.fc40 @copr:copr.fedorainfracloud.org:ganto:lxc4
incus-selinux.noarch 6.0.0-0.1.fc40 @copr:copr.fedorainfracloud.org:ganto:lxc4
lxc-libs.x86_64 6.0.0-0.1.fc40 @copr:copr.fedorainfracloud.org:ganto:lxc4
lxc-templates.noarch 6.0.0-0.1.fc40 @copr:copr.fedorainfracloud.org:ganto:lxc4
lxcfs.x86_64 6.0.0-0.1.fc40 @copr:copr.fedorainfracloud.org:ganto:lxc4
I can get correct information from /proc/cpuinfo and /sys/devices/system/cpu/online, but can't get the correct information from /proc/stat, The information from /proc/stat is all cpus on hosts. Is there any missing configuration?
/proc/cpuinfo
/sys/devices/system/cpu/online
/proc/stat
lxcfs --version
"5.0.4"
systemctl status lxcfs ● lxcfs.service - FUSE filesystem for LXC Loaded: loaded (/usr/lib/systemd/system/lxcfs.service; enabled; vendor preset: disabled) Active: active (running) since Thu 2024-03-14 19:38:44 CST; 1h 18min ago Docs: man:lxcfs(1) Main PID: 1296 (lxcfs) Tasks: 6 Memory: 31.6M CGroup: /system.slice/lxcfs.service └─1296 /usr/bin/lxcfs -l --enable-cfs --enable-pidfd /var/lib/lxc/lxcfs/
mount info