Htop when using cpu limits

Hello, I have a small question as I’m trying to determine if something is normal, but I can’t seem to find information anywhere.

I’m on a Raspberry Pi 4, using the latest 64-bit version of Bookworm.

I have a container that I want to limit to using only one CPU and dedicate that CPU to the container. So I used the following commands:

sudo lxc config set App limits.cpu 0-0
sudo lxc config set App limits.cpu.allowance 100ms/100ms

Now, what I’m wondering is that when I’m observing the values in htop, everything seems fine; I can see that only one of my four cores is working.

But I also see some processes that go way beyond 100% utilization (some can go from 150% to 250%). Does this mean that it’s actually using more than one core, or is it attempting to use more than one? My searches on Google didn’t yield anything conclusive, but then again, maybe I didn’t use the right keywords.

Thanks in advance.

With limits.cpu=0-0, it will be pinned on the first CPU core, so can’t really exceed one CPU.

The kernel doesn’t really ever report the CPU usage in percent, so it’s a bit of math in tools like top/htop that attempts to convert seconds of CPU time over some amount of time into percentages, this can occasionally be a bit wrong.

It’s also not completely impossible that you’re using more than a full CPU as while the scheduler is restricted to that one CPU for the processes inside that container, the kernel itself still uses all CPU threads as it sees fit. So some in-kernel filesystem or device interactions would likely happen on other CPUs. This may result in user+kernel time for a given process to exceed more than a full CPU worth of user time.

1 Like