2

I'm using htop to monitor the CPU usage of my task. However, the CPU% value exceed 100% sometimes, which really confused me.

Some blogs explain that this is because I'm using a multi-core machine(this is true). If there are 8 (logic) cores, the max value of CPU% is gonna be 800%. CPU% over 100% means that my task is occupying more than one core.

But my question is: there is a column named CPU in htop window which shows the id of the core my task is running on. So how can the usage of this single core exceed 100%.

This is the screenshot. You can see the 84th core's usage is 375%!

  • 1
    I assume the CPU# field comes from the main thread, but the CPU% field comes from all threads. Obviously a multi-threaded process can be running on multiple cores at once, but the `CPU` field can only have one value, so you'd have to look at `htop` docs or source code to figure out how it picks that. In `/proc/`, a multi-threaded process has subdirectories for each thread of the task, so if it wanted it could find the list of CPUs for each thread at the time it checked each one. (So after context switches, it could find that multiple threads were running on the same core if it did that.) – Peter Cordes Nov 11 '22 at 07:10

0 Answers0