# CPU usage during idle

## anthonywong

I had this posted on the Desktop Environments section earlier. It's probably more appropriate in this section after reading a couple of threads about CPU problems.

https://forums.gentoo.org/viewtopic.php?t=188334

I've been noticing lately that the CPU stayed constantly above 20% even when I'm just writing this forum. It's not a spike. It's strange to see the CPU looks like a rectangular block on the gkrellm2 monitor.

----------

## NeddySeagoon

anthonywong,

Use top or ps -Al to see where all your CPU time is going. You can have system jobs running (via cron) that stop your CPU being as idle as you expect

----------

## anthonywong

ran ps-Al and below is what i got. I've no idea how to interpret this

```
F S   UID   PID  PPID  C PRI  NI ADDR SZ WCHAN  TTY          TIME CMD

4 S     0     1     0  0  76   0 -   369 schedu ?        00:00:04 init

1 S     0     2     1  0 -40   0 -     0 migrat ?        00:00:00 migration/0

1 S     0     3     1  0  94  19 -     0 ksofti ?        00:00:00 ksoftirqd/0

1 S     0     4     1  0  65 -10 -     0 worker ?        00:00:00 events/0

1 S     0     5     4  0  65 -10 -     0 worker ?        00:00:00 kblockd/0

1 S     0     7     4  0  75   0 -     0 pdflus ?        00:00:00 pdflush

1 S     0     6     1  0  85   0 -     0 hub_th ?        00:00:00 khubd

1 S     0     8     4  0  75   0 -     0 pdflus ?        00:00:00 pdflush

1 S     0    10     4  0  75 -10 -     0 worker ?        00:00:00 aio/0

1 S     0     9     1  0  75   0 -     0 kswapd ?        00:00:02 kswapd0

1 S     0    11     1  0  85   0 -     0 jfsIOW ?        00:00:00 jfsIO

1 S     0    12     1  0  85   0 -     0 jfs_la ?        00:00:00 jfsCommit

1 S     0    13     1  0  85   0 -     0 jfs_sy ?        00:00:00 jfsSync

1 S     0    14     1  0  85   0 -     0 serio_ ?        00:00:00 kseriod

1 S     0    15     1  0  75   0 -     0 kjourn ?        00:00:00 kjournald

5 S     0   127     1  0  76   0 -   458 devfsd ?        00:00:00 devfsd

5 S     0  3216     1  0  75   0 -   435 schedu ?        00:00:00 syslog-ng

1 S     0  3328     1  0  77   0 -   372 schedu ?        00:00:00 dhcpcd

5 S     0  3426     1  0  78   0 -  1763 schedu ?        00:00:00 smbd

5 S     0  3428     1  0  76   0 -   945 schedu ?        00:00:00 nmbd

4 S     0  3486     1  0  76   0 -   401 schedu tty1     00:00:00 agetty

4 S     0  3487     1  0  75   0 -   401 schedu tty2     00:00:00 agetty

4 S     0  3488     1  0  75   0 -   401 schedu tty3     00:00:00 agetty

4 S     0  3489     1  0  75   0 -   401 schedu tty4     00:00:00 agetty

4 S     0  3490     1  0  75   0 -   401 schedu tty5     00:00:00 agetty

4 S     0  3491     1  0  76   0 -   401 schedu tty6     00:00:00 agetty

5 S     0  3507     1  0  77   0 -   632 schedu ?        00:00:00 kdm

4 S     0  3510  3507  3  75   0 - 23080 schedu ?        00:07:04 X

5 S     0  3511  3507  0  77   0 -   848 wait4  ?        00:00:00 kdm

4 S  1001  3592  3511  0  80   0 -   536 wait4  ?        00:00:00 Xsession

0 S  1001  3598  3592  0  76   0 -  1492 schedu ?        00:00:04 fluxbox

0 S  1001  3618  3598  0  76   0 -  3024 schedu ?        00:00:00 idesk

0 S  1001  3619  3598  2  75   0 -  4629 schedu ?        00:04:35 gkrellm2

0 S  1001  3624     1  0  76   0 -   759 schedu ?        00:00:00 esd

0 S  1001  3625  3618  0  75   0 -   538 wait4  ?        00:00:00 firefox

0 S  1001  3633  3625 10  75   0 - 15418 schedu ?        00:21:38 firefox-bin

1 S  1001  3637  3633  0  76   0 - 15418 schedu ?        00:00:00 firefox-bin

1 S  1001  3638  3637  0  76   0 - 15418 schedu ?        00:00:02 firefox-bin

0 S  1001  3640     1  0  76   0 -   963 schedu ?        00:00:00 gconfd-2

1 S  1001  3641  3637  0  75   0 - 15418 schedu ?        00:00:09 firefox-bin

0 S  1001  3698  3598  0  75   0 -   985 schedu ?        00:00:03 aterm

0 S  1001  3699  3698  0  76   0 -   587 wait4  pts/1    00:00:00 sh

0 T  1001  3733  3699  0  76   0 -   372 finish pts/1    00:00:00 pr

4 S     0  3739  3699  0  77   0 -   559 wait4  pts/1    00:00:00 su

4 S     0  3742  3739  0  75   0 -   587 wait4  pts/1    00:00:00 bash

0 S  1001  3788  3598  0  75   0 -  6313 schedu ?        00:00:07 gaim

1 S  1001  3861  3637  0  76   0 - 15418 schedu ?        00:00:00 firefox-bin

4 R     0  3862  3742  0  78   0 -   566 -      pts/1    00:00:00 ps

```

----------

## NeddySeagoon

anthonywong,

I'll refer you to man ps for details. Each line lists a current process on your system. Processes that have run to completion are not listed.

The interesting column is time, which shows the time that each live process has had the CPU in hours, minutes and seconds.

So init has had 40 sec, X has used 7 min 4 sec and so on. Firefox is the hog at 21 min 38 sec.

top produces a snapshot every few seconds sorted into CPU time used since the last snapshot, so processes at the top of the list in top are getting the CPU.

----------

## anthonywong

I had firefox opened since I booted the computer a couple of hours ago. I noticed that after running "ps" command again, firefox has been using 29 mins. Is that a good thing or bad thing? I know this sounds silly but i've no idea if my Gentoo is working as it should be or something is not right (as observed on the CPU usage pattern)

----------

## NeddySeagoon

anthonywong,

Run top in a window and watch these top few lines

```
top - 20:07:39 up  2:27,  6 users,  load average: 1.05, 1.07, 1.02

Tasks:  86 total,   2 running,  84 sleeping,   0 stopped,   0 zombie

Cpu(s):  2.3% us,  3.0% sy, 90.7% ni,  0.0% id,  0.0% wa,  4.0% hi,  0.0% si

Mem:   1037508k total,   917328k used,   120180k free,   304960k buffers

Swap:  2008116k total,        0k used,  2008116k free,   116972k cached
```

This shows time of day , uptime, number of users, (each open terminal is a user) load average of three different time periods. The load average is a measure of tasks ready to run in the period, so my 1.05 means I always had at least one task ready to run. Thats mostly Seti@Home, since its CPU intensive, its always ready to run.

For more details read man top.

----------

## anthonywong

Here's my current "top"

```
top - 03:29:31 up  4:55,  1 user,  load average: 0.47, 0.33, 0.28

Tasks:  63 total,   1 running,  48 sleeping,  14 stopped,   0 zombie

Cpu(s): 16.6% us,  1.3% sy,  0.0% ni, 81.8% id,  0.0% wa,  0.3% hi,  0.0% si

Mem:    124640k total,   118340k used,     6300k free,     8136k buffers

Swap:   506036k total,    25728k used,   480308k free,    38184k cached

```

Does this looked normal? 16% more or less CPU constantly even when I'm sitting back to watch my tv (not on my computer obviously)? sometimes it dips after a while. I was just thinking if I should upgrade xorg-x11 to version 6.7.0-r1 instead? Or perhaps unemerge firefox and emerge mozilla-firefox-bin instead?

----------

## NeddySeagoon

anthonywong,

I don't think there is a 'normal'. It looks harmless.

Packages that end in -bin are pre built binaries. They are not better that you would build yourself.

One of your (or more) of your processes is doing something but its nothing to worry about (unless you have been rooted) untill the system becomes unresponsive. That happens when the load gets up to about 4.

If you want to invesigate further, try closing things down and looking at the CPU load or watching the next 10 lines of top to see what is in the top 10 all the time.

----------

## HomerSimpson

The load average goes up when a process(s) that is ready to run is not able to run. This is how I understand it.

If this is correct, how do I tell what process is trying to run but can't? 

My load average is usually right around 1 (I have setiathome running) but I just noticed that it is at 3. It will drop to 2+ if I stop setiathome. Usually ithout seti it wil lbe less than 1. When I use ps -Al I can see that there are programs that are using time more than others but I am not seeing what is causing my load to be 3+ when it is normally 1. Are there more tools I can use to figure this out?

Thx

----------

