LKMs – viewing /proc/modules

Posted in How To's by Shafkat Shahzad, M.Sc - Senior Technical Content Manager on December 13th, 2009

Welcome to the tutorial guide. The guide will provide a user with advise and guidance on how to view proc/modules.

In order to see the presently loaded LKMs, please run following code:

cat /proc/modules

You will view a line similar to mentioned below:

serial 28204 0

In order to fully understand this, please note that
-the left column is the name of the LKM, which is normally the name of the object file from which you loaded it, minus the “.o” suffix.
-The “28204″ is the size in bytes of the LKM in memory.
-The “0″ is the use count and it tells how many things presently depend on the LKM being loaded. Typical

Please note that the LKM maintains this count, but the module manager uses it to decide whether to permit an unload. There is an exception to the above description of the use count. You may see -1 in the use count column. -1 means that this LKM does not use counts to determine when it is OK to unload. Instead, the LKM has registered a subroutine that the module manager can call that will return an indication of whether or not it is OK to unload the LKM.

Let’s have a look at another example:

lp 5280 2 (unused)
parport_pc 7552 1
parport 7600 3 [lp parport_pc]

In the example, you will see that there is a number 3 there and there is some text in square brackets. The information or text in square brackets describes dependencies. The information in brackets is modules and modules lp and parport_pc refer to addresses within module parport (via external symbols that parport exports). So lp and parport_pc are “dependent” on (and are “dependencies of”) parport.

It is also good to know that a user cannot unload an LKM that has dependencies, though the dependencies can be removed by unloading the dependent LKMs.

The “(unused)” legend means the LKM has never been used, i.e. it has never been in a state where it could not be unloaded. The kernel tracks this information for one simple reason: to assist in automatic LKM unloading policy. In a system where LKMs are loaded and unloaded automatically, you don’t want to automatically load an LKM and then, before the person who needed it loaded has a chance to use it, unload it because it is not in use.
Let’s have a look at LKM which is in a deleted state. It is as provided below:

mydriver 8154 0 (deleted)

The LKM as mentioned in the example is in a deleted state and it means is that the LKM is in the process of being unloaded. You can no longer load LKMs that depend on it, but it’s still present in the system. Unloading an LKM is usually close to instantaneous, so if you see this status, you probably have a broken LKM. Its cleanup routine probably got into an infinite loop or stall or crashed. The only way to clear this is to do a reboot.

If you followed advise and guidance as provide in this tutorial guide then you would have successfully learnt about LKM proc/modules.

Bookmark Us
  • Digg
  • Sphinn
  • del.icio.us
  • Facebook
  • Mixx
  • Google
  • MisterWong
  • Netvouz
  • Reddit
  • Slashdot
  • Spurl
  • StumbleUpon
  • Technorati
  • Wists

Leave a Comment