20

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?"

ish
  • 138,666
  • 36
  • 303
  • 312
leemes
  • 911
  • 4
  • 12
  • 25
  • `top` shows more processes. The process in question belongs to `mdadm`, which is currently performing a resync as I found out. `top` shows the process under the name `md127_raid5` and `md127_resync`. The former is running since booting the system, the latter since resync has been triggered. So this turns the question in: "Why doesn't htop display the same processes than top?" – leemes Jun 02 '12 at 23:26

1 Answers1

24

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

ish
  • 138,666
  • 36
  • 303
  • 312
  • Thank you very much. This is something I wanted to know for years! And the solution is so simple... Thanks for the nice screenshots :) – leemes Jun 03 '12 at 00:12
  • 1
    The hotkey is H (shift+h). – glebm Aug 27 '13 at 22:06
  • 4
    @glebm (late, but I think it's worth to add ;) ): The hotkey for displaying _kernel_ threads is `K` (Shift+k). The hotkey `H` (Shift+h) displays (or hides, if already displayed) _userland_ threads. – Henning Kockerbeck Sep 24 '13 at 10:11
  • Can htop also hides all the idle processes like `top -i`? – alper Mar 09 '22 at 09:53