lxcfs icon indicating copy to clipboard operation
lxcfs copied to clipboard

Does lxcfs have plans to support cpu-shares and cpu-quota?

Open agile6v opened this issue 8 years ago • 15 comments

Hello.

Lxcfs currently does not support the CPU views requested by the cpu-shares and cpu-quota in the container. Is there plan support?

Regards. agile6v

agile6v avatar May 21 '18 15:05 agile6v

Not sure how that'd get rendered in cpuinfo

stgraber avatar May 22 '18 13:05 stgraber

Please refer to the implementation of the JDK10. @stgraber

agile6v avatar May 22 '18 15:05 agile6v

@agile6v I don't see how this maps to /proc/cpuinfo fields which is what LXCFS generates for its CPU view.

stgraber avatar May 22 '18 18:05 stgraber

@stgraber I understand your doubts. If I run a container with --cpuset-cpus parameter, then the CPU view seen in the container is bound by this container, but the CPU resource is used by this container alone? Obviously not. If so, I think a container with --cpu-shares & --cpu-quota parameter can randomly display corresponding number of CPU in the container.

agile6v avatar May 23 '18 06:05 agile6v

If I understand it correctly that you'd like to reduce the number of visible CPUs based on cpu.shares or cpu.cfs_{quota,period}_us, I'd be interested in it as well.

@stgraber, could you please elaborate on what problems do you see with /proc/cpuinfo? I think it could calculate the number of available CPUs based on shares/quotas/cpuset, then copy only as many CPUs from the host's /proc/cpuinfo and ignore the rest. It works like this even now, just with cpuset, doesn't it?

/proc/stat would be more complicated, I think. Since a container can utilize more CPUs than we might want to be visible, the usage counters from hidden CPUs would somehow need to be added to the visible CPUs. It should be possible with #244 merged in.

I'm probably going to be experimenting with this.

aither64 avatar Jun 21 '18 09:06 aither64

@aither64 Hi, I think this feature is a very useful, is there something new about your experimenting?

zexi avatar Oct 15 '18 13:10 zexi

Yes, I have it implemented, but I haven't gotten around to cleaning it up and making a PR yet. It works with CPU quotas set e.g. using lxc.cgroup.cpu.cfs_{quota,period}_us, CPU shares didn't make sense to me.

aither64 avatar Oct 15 '18 14:10 aither64

@aither64 Thanks for your reply. As expected, I tested this feature and it works. It would be nice if make your implemented merged.

zexi avatar Oct 16 '18 09:10 zexi

@agile6v HI, I try to use lxcfs with cpu-view feature, It seems not work for me. I use docker:

docker run -it --rm -m 256m --cpu-quota 1000 \ -v /var/lib/lxcfs/proc/cpuinfo:/proc/cpuinfo:rw \ -v /var/lib/lxcfs/proc/diskstats:/proc/diskstats:rw \ -v /var/lib/lxcfs/proc/meminfo:/proc/meminfo:rw \ -v /var/lib/lxcfs/proc/stat:/proc/stat:rw \ -v /var/lib/lxcfs/proc/swaps:/proc/swaps:rw \ -v /var/lib/lxcfs/proc/uptime:/proc/uptime:rw \ centos:latest /bin/sh

I don't know why , would you like to give a simple prompt ? Thanks~

lijiaocn avatar Jan 10 '19 10:01 lijiaocn

@lijiaocn Sorry. I have not tried this feature yet.

agile6v avatar Jan 10 '19 13:01 agile6v

What exactly is not implemented? PR 260 says

This patchset reduces the number of CPUs visible in /proc/cpuinfo and /proc/stat based on CPU quotas configured e.g. using lxc.cgroup.cpu.cfs_{quota,period}_us. If qoutas aren't set, it falls back to the current behaviour.

how does docker implement "--cpu-quota" ?

hallyn avatar Jun 07 '19 17:06 hallyn

@lijiaocn Hello, I have the same problem,have u resolved it?

StephenLiuYa avatar Mar 30 '20 06:03 StephenLiuYa

This is implemented now and can be used with --enable-cfs.

brauner avatar Mar 30 '20 08:03 brauner

@brauner Hi, I use the --enable-cfs , get right cpu count in top command, but the /proc/stat file is still wrong

StephenLiuYa avatar Mar 31 '20 08:03 StephenLiuYa

@brauner I use the tag3.1.2 and get the right result, but user the lastest tag the result is still wrong

StephenLiuYa avatar Mar 31 '20 08:03 StephenLiuYa