简体   繁体   中英

Load state of a module in /proc/modules

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?

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. */
};

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM