2

From the answer to this question, it is given that the fifth field of /proc/modules is the load state of the module and can be either Live or Loading or Unloading. However in my Ubuntu 14.04 system and some other systems, I could find only the value Live for this field. Is it true that the field can have other values too?

Community
  • 1
  • 1
Jackzz
  • 1,417
  • 4
  • 24
  • 53

2 Answers2

4

There are 3 possible states for this field:

  • Live
  • Loading
  • Unloading

You can see this in kernel sources, in kernel/module.c file:

/* Informative for users. */
seq_printf(m, " %s",
           mod->state == MODULE_STATE_GOING ? "Unloading" :
           mod->state == MODULE_STATE_COMING ? "Loading" :
           "Live");

The description of mod->state can be found in enum module_state, in include/linux/module.h:

enum module_state {
    MODULE_STATE_LIVE,      /* Normal state. */
    MODULE_STATE_COMING,    /* Full formed, running module_init. */
    MODULE_STATE_GOING,     /* Going away. */
    MODULE_STATE_UNFORMED,  /* Still setting it up. */
};
Sam Protsenko
  • 14,045
  • 4
  • 59
  • 75
2

It's possible for the field to have other values, but these are transitional states and you would have a hard time spotting them from outside the kernel. The Loading state for example only persists from the time the module has been fully loaded into memory until its initialization is complete. Typically, this would take only microseconds.

Gil Hamilton
  • 11,973
  • 28
  • 51