1

https://www.opsdash.com/blog/cpu-usage-linux.html

COMPONENTS OF CPU USAGE

So what “types of tasks” are there? The obvious ones are “user” and “system”:

System: The CPU is running kernel code. This includes device drivers and kernel modules.

User: The CPU is running code in user-mode. This includes your application code. Note that if an application tries to read from disk or write to network, it actually goes to sleep while the kernel performs that work, and wakes up the application again.

Idle: And when there is really nothing the kernel can do, it just as to waste away this slice of time. Technically, when the runnable queue is empty and there are no I/O operations going on, the CPU usage is marked as idle.

Am I understanding correctly that user, system, and idle percentage would always add up to 100%?

closed as off-topic by Ipor Sircer, DopeGhoti, Rui F Ribeiro, Julie Pelletier, Romeo Ninov Jun 15 '18 at 5:42

This question appears to be off-topic. The users who voted to close gave this specific reason:

  • "Requests for learning materials (tutorials, how-tos etc.) are off topic. The only exception is questions about where to find official documentation (e.g. POSIX specifications). See the Help Center and our Community Meta for more information." – Ipor Sircer, DopeGhoti, Rui F Ribeiro, Julie Pelletier, Romeo Ninov
If this question can be reworded to fit the rules in the help center, please edit the question.

2

The possible states depends on the OS (Linux or Unix, variants and releases).

All possible states values sum up to 100 % because they are computed that way.

In addition the the main states user, system and idle, a notable state which level can be significant is stolen, where the CPU is used by another VM running on the same hardware. Other states are the ones used to wait for some I/Os to complete (wait), and software and hardware interrupts.

  • "All possible states values sum up to 100 %" okay thats was my source of confusion. thank you – ealeon Jun 14 '18 at 17:53
2

Actually, no. There are other types of CPU usage as well. If you execute sar -u ALL you can see cpu usage

00:00:01        CPU      %usr     %nice      %sys   %iowait    %steal      %irq     %soft    %guest     %idle
00:10:01        all     89.42      0.00      0.28      0.00      0.00      0.00      0.02      0.00     10.28

As the auther notes, there are other types of cpu usage, including User Space programs (%usr), niced process time (%usr) (not sure how this is calculated), kernel space programs (%sys), time spent waiting for I/O (disks) (%iowait), time spent stealing cycles from one cpu (%steal), and interrupt requests (%irq, %soft). If the cpu is doing none of these things, it is considered idle (%idle). The sum of these should always be 100%.

  • right, i didnt mention those types for the sake of simplicity of the question. So basically the summation of all CPU usage types will never be more than 100% but it can be less than 100%, correct? – ealeon Jun 14 '18 at 17:52
  • 1
    @ealeon Their sum should always be exactly 100%. – Timothy Pulliam Jun 14 '18 at 17:53

Not the answer you're looking for? Browse other questions tagged or ask your own question.