Ubuntu – Why doesn’t htop display the same processes as top

command linecpu loadsoftware-recommendationtop

I have a home server sometimes running at a high CPU usage rate of about 50 to 70 percents.

In htop, my favorite process manager, I can sort the processes by CPU usage, but often there isn't any process consuming more than 0 % CPU. On the other side, htop displays the whole CPU usage of the system which is about 50 percents, as said before.

I guess that there is an easy explanation for this, but I don't know it.

Maybe there are some hidden processes? But even running it as root doesn't show more processes.

EDIT:

I looked into top, which is showing (at least) two more processes:

  230 root      20   0     0    0    0 R 37.4  0.0 107:06.59 md127_raid5                                          
20403 root      35  15     0    0    0 D  9.6  0.0   2:45.78 md127_resync   

So my mdadm raid is currently resyncing, which has been confirmed when I displayed /proc/mdstat. (See first comment.)

So this turns the question in: "Why doesn't htop display the same processes than top?"

Best Answer

Why doesn't htop display the same processes than top?

Because htop hides kernel threads by default, while top doesn't. You can switch this option off in F2-settings in htop.

  1. Before:

    enter image description here

  2. Uncheck the Hide kernel threads setting, press Esc to leave screen instead of F10.

    enter image description here

  3. Notice the new number of kthr (kthreads) at the cursor, and all the new k... processes that have shown up. You can sort these by CPU, etc. as usual. Apart from the name (begins with a k, has a / towards the end), you can also identify kernel threads by their very low PIDs (notice the 1, 2, 3...17 in the screenshot?)

    enter image description here