CPU limits settings are not being followed

Hi, I’m using Arch Linux. I have a container running with Ubuntu in it. I followed this guide to enable resource limits on the container.

Here is the output from lxc config show my-ubuntu:

architecture: x86_64
config:
  image.architecture: amd64
  image.description: ubuntu 24.04 LTS amd64 (release) (20240710)
  image.label: release
  image.os: ubuntu
  image.release: noble
  image.serial: "20240710"
  image.type: squashfs
  image.version: "24.04"
  limits.cpu: "1"
  limits.memory: 1024MB
  volatile.base_image: 7b285c64ffc20f507c69d817df21889b53a6326b6a71e347232cf3efd013ab5a
  volatile.cloud-init.instance-id: c26b9fde-f2f9-46e9-8f40-815ab4e4cf65
  volatile.eth0.host_name: veth9e5c78b1
  volatile.eth0.hwaddr: 00:16:3e:03:ae:6d
  volatile.idmap.base: "0"
  volatile.idmap.current: '[{"Isuid":true,"Isgid":false,"Hostid":1000000,"Nsid":0,"Maprange":1000000000},{"Isuid":false,"Isgid":true,"Hostid":1000000,"Nsid":0,"Maprange":1000000000}]'
  volatile.idmap.next: '[{"Isuid":true,"Isgid":false,"Hostid":1000000,"Nsid":0,"Maprange":1000000000},{"Isuid":false,"Isgid":true,"Hostid":1000000,"Nsid":0,"Maprange":1000000000}]'
  volatile.last_state.idmap: '[]'
  volatile.last_state.power: RUNNING
  volatile.uuid: 53127fce-f918-4420-a1fc-de773784d2f7
  volatile.uuid.generation: 53127fce-f918-4420-a1fc-de773784d2f7
devices: {}
ephemeral: false
profiles:
- default
- 1cpu1gb
stateful: false
description: ""

Container’s memory:

root@my-ubuntu:~# free -h        
               total        used        free      shared  buff/cache   available
Mem:           976Mi        46Mi       735Mi       164Ki       189Mi       929Mi
Swap:          976Mi          0B       976Mi

My CPU:

root@my-ubuntu:~# lscpu
Architecture:             x86_64
  CPU op-mode(s):         32-bit, 64-bit
  Address sizes:          46 bits physical, 48 bits virtual
  Byte Order:             Little Endian
CPU(s):                   12
  On-line CPU(s) list:    3
  Off-line CPU(s) list:   0-2,4-11
Vendor ID:                GenuineIntel
  Model name:             Intel(R) Core(TM) i5-14500
    CPU family:           6
    Model:                191
    Thread(s) per core:   2
    Core(s) per socket:   6
    Socket(s):            1
    Stepping:             2
    CPU(s) scaling MHz:   29%
    CPU max MHz:          5000.0000
    CPU min MHz:          800.0000
    BogoMIPS:             5224.00

It shows CPU(s): 12. And, well, the output is the same on my host machine, so I think something is not set up correctly. Maybe some cgroup stuff?

How do I diagnose and fix this?

Welcome!

See here, Memory limits ignored for instances. · Issue #1059 · lxc/incus · GitHub
Are you facing a case where the limits are not actually enforced, or that the reporting tools do not show correctly the new limits?

The liblxcfs project is the one that hides information from the system so that it appears differently in the container.

In my case, the memory is showing correctly. It’s only the CPU.

If you mean the limit is being set, but not reported correctly. How can I verify it to be sure? Maybe any other tool than htop/lscpu?

This clearly shows that you are getting a single CPU (id 3).
lscpu can still tell that your system has 12 CPUs, but you’ll see that the other 11 threads are offline for this container.

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.