[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: Number of Procs



On Wed, Jan 08, 2014 at 11:40:36AM -0200, Hudson Flavio Meneses Lacerda wrote:
> Hi.
> 
> Sometimes, the system raises a lot of processes, causing considerable
> delay to respond any input action. This moment, there are 312 processes
> running (in a personal laptop - Debian testing). Here is a partial view
> of "top":
> 
> [...]
>     1 root      20   0  2880  636  600 S  0,0  0,1   0:00.92 init
>     2 root      20   0     0    0    0 S  0,0  0,0   0:00.00 kthreadd
>     5 root       0 -20     0    0    0 S  0,0  0,0   0:00.00 kworker/0:0H
>     7 root      rt   0     0    0    0 S  0,0  0,0   0:00.00 posixcputmr/0
>     8 root      20   0     0    0    0 S  0,0  0,0   0:00.00 kclksetdelayd
>     9 root      20   0     0    0    0 S  0,0  0,0   0:00.00 kcmosdelayd
>    10 root      rt   0     0    0    0 S  0,0  0,0   0:00.00 migration/0
>    11 root      20   0     0    0    0 S  0,0  0,0   0:00.12 rcu_preempt
>    12 root      20   0     0    0    0 S  0,0  0,0   0:00.00 rcu_bh
>    13 root      20   0     0    0    0 S  0,0  0,0   0:00.00 rcu_sched
>    14 root      rt   0     0    0    0 S  0,0  0,0   0:00.00 watchdog/0
>    15 root       0 -20     0    0    0 S  0,0  0,0   0:00.00 khelper
>    16 root      20   0     0    0    0 S  0,0  0,0   0:00.00 kdevtmpfs
>    17 root       0 -20     0    0    0 S  0,0  0,0   0:00.00 netns
>    18 root       0 -20     0    0    0 S  0,0  0,0   0:00.00 writeback
>    19 root       0 -20     0    0    0 S  0,0  0,0   0:00.00 kintegrityd
>    20 root       0 -20     0    0    0 S  0,0  0,0   0:00.00 bioset
>    21 root       0 -20     0    0    0 S  0,0  0,0   0:00.00 kblockd
>    22 root     -51   0     0    0    0 S  0,0  0,0   0:00.20 irq/10-acpi
>    23 root      20   0     0    0    0 S  0,0  0,0   0:00.25 kworker/0:1
>    24 root      20   0     0    0    0 S  0,0  0,0   0:00.00 khungtaskd
>    25 root      20   0     0    0    0 S  0,0  0,0   0:00.48 kswapd0
>    26 root      25   5     0    0    0 S  0,0  0,0   0:00.00 ksmd
>    27 root      20   0     0    0    0 S  0,0  0,0   0:00.00 fsnotify_mark
>    28 root       0 -20     0    0    0 S  0,0  0,0   0:00.00 crypto
>    33 root       0 -20     0    0    0 S  0,0  0,0   0:00.00 kthrotld
>    36 root     -76   0     0    0    0 S  0,0  0,0   0:00.03 irq/1-i8042
>    37 root     -91   0     0    0    0 S  0,0  0,0   0:00.00 irq/8-rtc0
>    38 root      20   0     0    0    0 S  0,0  0,0   0:00.00 mce-notify
>    39 root       0 -20     0    0    0 S  0,0  0,0   0:00.00 deferwq
>    43 root      20   0     0    0    0 S  0,0  0,0   0:00.00 kworker/0:2
>   135 root      20   0     0    0    0 S  0,0  0,0   0:00.00 khubd
>   136 root       0 -20     0    0    0 S  0,0  0,0   0:00.00 ata_sff
>   137 root     -81   0     0    0    0 S  0,0  0,0   0:00.00 irq/20-uhci_hcd
>   138 root     -51   0     0    0    0 S  0,0  0,0   0:00.12 irq/21-ehci_hcd
>   144 root     -51   0     0    0    0 S  0,0  0,0   0:00.00 irq/17-mmc0
> [...]
> 
> 
> What causes this large amount of simultaneous services? How to select
> only the essential ones, or make them run distributed in time, so that
> they do not overload the processor?

There are various things to note here. All the processes you've shown
here are in state "S" (eighth column). That means that, though they
exist, the processor is not actually working on them at the moment.
Unless you have a 312-core machine (or similar), it is not possible to
actually run 312 processes at once. Instead, the linux kernel uses
"Cooperative Multitasking". One process will be given some time on a
processor and then, after a period of time or when that process yields
control of the processor (for example, if the process is waiting for
data to come from a disk, then there's nothing for the CPU to do), the
kernel will suspend that process and pick another one. The choosing of
when to switch processes and which processes to pick when several are
wanting the CPU, is performed by the scheduler.

It is perfectly normal to have many processes. It's also, however,
possible to have "too many" processes? How many is too many? This is
where Linux's concept of "load average" comes into play. Calculating 
"load average" is a complex task, but the numbers SHOULD come out that a
load average equal to the number of CPUs is a perfectly-loaded system.
Run "uptime" and you'll see the load average over the last 1, 5 and 15
minutes. If these numbers are high, you have a busy system.

Attachment: signature.asc
Description: Digital signature


Reply to: