Processes in D state

From OpenVZ Virtuozzo Containers Wiki
Revision as of 13:45, 11 June 2006 by Vass (talk | contribs) (Initial edition of article)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search

If there are a lot of processes in D state in your system, then something is wrong with it. What is "D state" and process state in generally? A process in Linux can be in several states: runing state, sleeping state and others. Running process runs on a CPU just now, Sleeping process waits for its turn on CPU or for some other event. Using ps command you can obtain information about state of each process in the system: STAT column shows that:

[root@dhcp0-56 ovz-utils]# ps a
  PID TTY      STAT   TIME COMMAND
 4975 tty1     Ss+    0:00 /sbin/mingetty tty1
 4976 tty2     Ss+    0:00 /sbin/mingetty tty2
 6202 pts/0    Ss+    0:01 -bash
10312 pts/1    Ss     0:00 -bash
  639 pts/1    R+     0:00 ps a

First big S stands for Sleeping, R stands for runing ("+" means that the process is foreground and small "s" means that the process is session leader, but it isn't relevant in our discussion). D state occurs then the process is in uninterruptable disk sleep. This state is bad, because you can't do anything with the process in D state. Fortunately, process normally remains in such state not for long. If you have a heap of D state processes than some logic in system is disrupt. The very important thing then is to determine, where this unlucky sleep occurs. It is easy to do with ps command with l option. WCHAN column shows the name of the kernel function where the process is sleeping:

[root@dhcp0-56 ~]# ps axl | grep D
F   UID   PID  PPID PRI  NI    VSZ   RSS WCHAN  STAT TTY        TIME COMMAND
vass     13478  7.2  0.0   1732   624 pts/1    D+   17:36   0:00 find ./

Then you have problem with D state processes always attach this information to the report, that you send to developers.