Saída de estado do processo não reconhecido no comando ps

4

Executando ps aux em Ubuntu 18.04 Vejo alguns processos com estado I , como em ...

root         1  0.0  0.0 225520  9144 ?        Ss   10:36   0:02 /sbin/init splash
root         2  0.0  0.0      0     0 ?        S    10:36   0:00 [kthreadd]
root         4  0.0  0.0      0     0 ?        I<   10:36   0:00 [kworker/0:0H]
root         6  0.0  0.0      0     0 ?        I<   10:36   0:00 [mm_percpu_wq]

No entanto, este estado não é mencionado em ps manpages:

PROCESS STATE CODES Here are the different values that the s, stat and state output specifiers (header "STAT" or "S") will display to describe the state of a process:

           D    uninterruptible sleep (usually IO)
           R    running or runnable (on run queue)
           S    interruptible sleep (waiting for an event to complete)
           T    stopped by job control signal
           t    stopped by debugger during the tracing
           W    paging (not valid since the 2.6.xx kernel)
           X    dead (should never be seen)
           Z    defunct ("zombie") process, terminated but not reaped by its parent

   For BSD formats and when the stat keyword is used, additional characters may be displayed:

           <    high-priority (not nice to other users)
           N    low-priority (nice to other users)
           L    has pages locked into memory (for real-time and custom IO)
           s    is a session leader
           l    is multi-threaded (using CLONE_THREAD, like NPTL pthreads do)
           +    is in the foreground process group

O que é esse estado I ?

    
por pkaramol 12.08.2018 / 10:34

1 resposta

5

Significa "Inativo"

    /* states beyond TASK_REPORT: */
    "I (idle)",             /* 0x80 */
Referência: O que o estado do processo do Linux "I" significa na saída superior?

Digging more in kernel sources I found that the record for I is TASK_REPORT_IDLE, which is returned from kernel guts (function __get_task_state) when process has status TASK_IDLE, which in fact is a combination of

#define TASK_IDLE   (TASK_UNINTERRUPTIBLE | TASK_NOLOAD)

Além disso, veja este commit no kernel intitulado: sched / wait: introduza TASK_NOLOAD e TASK_IDLE .

Currently people use TASK_INTERRUPTIBLE to idle kthreads and wait for 'work' because TASK_UNINTERRUPTIBLE contributes to the loadavg. Having all idle kthreads contribute to the loadavg is somewhat silly.

Now mostly this works OK, because kthreads have all their signals masked. However there's a few sites where this is causing problems and TASK_UNINTERRUPTIBLE should be used, except for that loadavg issue.

This patch adds TASK_NOLOAD which, when combined with TASK_UNINTERRUPTIBLE avoids the loadavg accounting.

As most of imagined usage sites are loops where a thread wants to idle, waiting for work, a helper TASK_IDLE is introduced.

NOTA: parece que foi adicionado ao kernel do Linux em 4.14-rc3 :

sched/debug: Add explicit TASK_IDLE printing

/ proc

Dado que isso vem do kernel do Linux, as ferramentas downstream como ps e top imediatamente podem exibir esse novo estado, I , sem precisar ser explicitamente informado, pois elas derivam suas informações de /proc .

Você pode ver o estado de /proc por meio do /proc/<PID>/stat :

$ cat /proc/10/stat
10 (lru-add-drain) S 2 0 0 0 -1 69247072 ....
                   ^--- state = S = Sleep

Referências

por 12.08.2018 / 10:50

Tags