Open
Description
I'm using lxcfs 4.0.7. I created an container whit lxcfs proc files mount, then kicked off a process while true;do echo test > /dev/null;done
. In container, top
command showed the correct %cpu information, while ps
always showed 0.0
. However when not using lxcfs, ps
worked well.
Steps
start lxcfs
`/usr/local/bin/lxcfs -l --enable-cfs --enable-pidfd /var/lib/lxc/lxcfs
start docker container
docker run -it -m 128m --cpus=1 --rm \
-v /var/lib/lxc/lxcfs/proc/cpuinfo:/proc/cpuinfo:rw \
-v /var/lib/lxc/lxcfs/proc/diskstats:/proc/diskstats:rw \
-v /var/lib/lxc/lxcfs/proc/meminfo:/proc/meminfo:rw \
-v /var/lib/lxc/lxcfs/proc/stat:/proc/stat:rw \
-v /var/lib/lxc/lxcfs/proc/swaps:/proc/swaps:rw \
-v /var/lib/lxc/lxcfs/proc/loadavg:/proc/loadavg:rw \
-v /var/lib/lxc/lxcfs/proc/uptime:/proc/uptime:rw \
-v /var/lib/lxc/lxcfs/sys/devices/system/cpu/online:/sys/devices/system/cpu/online:rw \
-v /var/lib/lxc:/var/lib/lxc:rshared \
centos:7 /bin/bash
test
top
shows 100.0
, while ps
shows 0.0
for process 16
[root@af61796cf0ed /]# while true; do echo test > /dev/null;done &
[1] 16
[root@af61796cf0ed /]# top -b -n 1
top - 03:06:17 up 0 min, 0 users, load average: 0.00, 0.00, 0.00
Tasks: 3 total, 2 running, 1 sleeping, 0 stopped, 0 zombie
%Cpu(s): 12.0 us, 0.0 sy, 0.0 ni, 88.0 id, 0.0 wa, 0.0 hi, 0.0 si, 0.0 st
KiB Mem : 131072 total, 127272 free, 3800 used, 0 buff/cache
KiB Swap: 0 total, 0 free, 0 used. 127272 avail Mem
PID USER PR NI VIRT RES SHR S %CPU %MEM TIME+ COMMAND
16 root 20 0 11840 396 0 R 100.0 0.3 0:03.40 bash
1 root 20 0 11840 2984 2588 S 0.0 2.3 0:00.04 bash
17 root 20 0 56064 3696 3248 R 0.0 2.8 0:00.00 top
[root@af61796cf0ed /]# ps aux
USER PID %CPU %MEM VSZ RSS TTY STAT START TIME COMMAND
root 1 0.0 2.2 11840 2984 pts/0 Ss 03:05 0:00 /bin/bash
root 16 0.0 0.3 11840 396 pts/0 R 03:06 0:09 /bin/bash
root 18 0.0 2.6 51744 3416 pts/0 R+ 03:06 0:00 ps aux
test without lxcfs
top
shows 100.0, and ps
shows 102
root@dev:~# docker run -it -m 128m --cpus=1 centos:7 /bin/bash
WARNING: Your kernel does not support swap limit capabilities or the cgroup is not mounted. Memory limited without swap.
[root@0d6cb011e598 /]# while true; do echo test > /dev/null;done &
[1] 16
[root@0d6cb011e598 /]# top -b -n 1
top - 03:09:29 up 7 days, 15:12, 0 users, load average: 2.07, 1.79, 1.42
Tasks: 3 total, 2 running, 1 sleeping, 0 stopped, 0 zombie
%Cpu(s): 15.4 us, 10.6 sy, 0.0 ni, 73.2 id, 0.0 wa, 0.0 hi, 0.8 si, 0.0 st
KiB Mem : 16260516 total, 1436644 free, 1152404 used, 13671468 buff/cache
KiB Swap: 0 total, 0 free, 0 used. 14788144 avail Mem
PID USER PR NI VIRT RES SHR S %CPU %MEM TIME+ COMMAND
16 root 20 0 11840 396 0 R 100.0 0.0 0:05.02 bash
1 root 20 0 11840 2912 2516 S 0.0 0.0 0:00.03 bash
17 root 20 0 56064 3656 3212 R 0.0 0.0 0:00.00 top
[root@0d6cb011e598 /]# ps aux
USER PID %CPU %MEM VSZ RSS TTY STAT START TIME COMMAND
root 1 0.2 0.0 11840 2912 pts/0 Ss 03:09 0:00 /bin/bash
root 16 102 0.0 11840 396 pts/0 R 03:09 0:07 /bin/bash
root 18 0.0 0.0 51744 3392 pts/0 R+ 03:09 0:00 ps aux
[root@0d6cb011e598 /]#