Linux Kernel Architecture

(Jacob Rumans) #1

Chapter7:Modules


❑ percpupoints to per-CPU data that belong to the module. It is initialized when the module is
loaded.
❑ argsis a pointer to the command-line arguments passed to the module during loading.

7.3.2 Dependencies and References


Arelationshipexists between two modules A and B if B uses functions provided by A. This relationship
canbeviewedintwodifferentways.


  1. B depends on A. B cannot be loaded unless A is already resident in kernel memory.

  2. A references B. In other words, B cannot be removed from the kernel unless A has been
    removed — or unless all other modules that reference B have disappeared. In the kernel,
    this kind of relationship is described asA uses B.


To correctly manage these dependencies, the kernel needs to introduce a further data structure:

kernel/modules.c
struct module_use
{
struct list_head list;
struct module *module_which_uses;
};

The dependency network is set up together with themodules_which_use_meelement of themoduledata
structure. A new instance ofmodule_useis created for each module A that uses functions in module B.
This instance is added to themodules_which_use_melist of B.module_which_usespoints to themodule
instance of A. On the basis of this information, the kernel can easily find out which other kernel modules
are used by a particular module.

As the relationship described is not immediately clear, Figure 7-3 provides a graphic example to illustrate
the situation.

ip_nat_ftp iptable_nat ip_conntrack ip_conntrack_ftp ip_tables

modules_which_use_me

module_use->list module_use->module_which_uses

Figure 7-3: Data structures for managing dependencies between modules.
Free download pdf