Home | History | Annotate | Line # | Download | only in doc
TODO.modules revision 1.6
      1  1.6  pgoyette /* $NetBSD: TODO.modules,v 1.6 2016/09/27 22:27:50 pgoyette Exp $ */
      2  1.1  pgoyette 
      3  1.1  pgoyette Some notes on the limitations of our current (as of 7.99.35) module
      4  1.1  pgoyette subsystem.  This list was triggered by an Email exchange between
      5  1.1  pgoyette christos and pgoyette.
      6  1.1  pgoyette 
      7  1.1  pgoyette 1. Builtin drivers can't depend on modularized drivers (the modularized
      8  1.1  pgoyette    drivers are attempted to load as builtins).
      9  1.1  pgoyette 
     10  1.1  pgoyette 	The assumption is that dependencies are loaded before those
     11  1.1  pgoyette 	modules which depend on them.  At load time, a module's
     12  1.1  pgoyette 	undefined global symbols are resolved;  if any symbols can't
     13  1.1  pgoyette 	be resolved, the load fails.  Similarly, if a module is
     14  1.1  pgoyette 	included in (built-into) the kernel, all of its symbols must
     15  1.1  pgoyette 	be resolvable by the linker, otherwise the link fails.
     16  1.1  pgoyette 
     17  1.1  pgoyette 	There are ways around this (such as, having the parent
     18  1.1  pgoyette 	module's initialization command recursively call the module
     19  1.5  pgoyette 	load code), but they're often gross hacks.
     20  1.5  pgoyette 
     21  1.5  pgoyette 	Another alternative (which is used by ppp) is to provide a
     22  1.5  pgoyette 	"registration" mechanism for the "child" modules, and then when
     23  1.5  pgoyette 	the need for a specific child module is encountered, use
     24  1.5  pgoyette 	module_autoload() to load the child module.  Of course, this
     25  1.5  pgoyette 	requires that the parent module know about all potentially
     26  1.5  pgoyette 	loadable children.
     27  1.1  pgoyette 
     28  1.1  pgoyette 2. Currently, config(1) has no way to "no define" drivers
     29  1.1  pgoyette 
     30  1.1  pgoyette 3. It is not always obvious by their names which drivers/options
     31  1.1  pgoyette    correspond to which modules.
     32  1.1  pgoyette 
     33  1.1  pgoyette 4. Right now critical drivers that would need to be pre-loaded (ffs,
     34  1.1  pgoyette    exec_elf64) are still built-in so that we don't need to alter the boot
     35  1.1  pgoyette    blocks to boot.
     36  1.1  pgoyette 
     37  1.1  pgoyette 	This was a conscious decision by core@ some years ago.  It is
     38  1.1  pgoyette 	not a requirement that ffs or exec_* be built-in.  The only
     39  1.1  pgoyette 	requirement is that the root file-system's module must be
     40  1.1  pgoyette 	available when the module subsystem is initialized, in order
     41  1.1  pgoyette 	to load other modules.  This can be accomplished by having the
     42  1.1  pgoyette 	boot loader "push" the module at boot time.  (It used to do
     43  1.1  pgoyette 	this in all cases; currently the "push" only occurs if the
     44  1.1  pgoyette 	booted filesystem is not ffs.)
     45  1.1  pgoyette 
     46  1.1  pgoyette 5. Not all parent bus drivers are capable of rescan, so some drivers
     47  1.1  pgoyette    just have to be built-in.
     48  1.1  pgoyette 
     49  1.1  pgoyette 6. Many (most?) drivers are not yet modularized
     50  1.1  pgoyette 
     51  1.1  pgoyette 7. There's currently no provisions for autoconfig to figure out which
     52  1.1  pgoyette    modules are needed, and thus to load the required modules.
     53  1.1  pgoyette 
     54  1.1  pgoyette 	In the "normal" built-in world, autoconfigure can only ask
     55  1.1  pgoyette 	existing drivers if they're willing to manage (ie, attach) a
     56  1.1  pgoyette 	device.  Removing the built-in drivers tends to limit the
     57  1.1  pgoyette 	availability of possible managers.  There's currently no
     58  1.1  pgoyette 	mechanism for identifying and loading drivers based on what
     59  1.1  pgoyette 	devices might be found.
     60  1.1  pgoyette 
     61  1.2  pgoyette 8. Even for existing modules, there are "surprise" dependencies with
     62  1.2  pgoyette    code that has not yet been modularized.
     63  1.2  pgoyette 
     64  1.2  pgoyette 	For example, even though the bpf code has been modularized,
     65  1.2  pgoyette 	there is some shared code in bpf_filter.c which is needed by
     66  1.2  pgoyette 	both ipfilter and ppp.  ipf is already modularized, but ppp
     67  1.2  pgoyette 	is not.  Thus, even though bpf_filter is modular, it MUST be
     68  1.2  pgoyette 	included as a built-in module if you also have ppp in your
     69  1.2  pgoyette 	configuration.
     70  1.2  pgoyette 
     71  1.2  pgoyette 	Another example is sysmon_taskq module.  It is required by
     72  1.2  pgoyette 	other parts of the sysmon subsystem, including the
     73  1.2  pgoyette 	"sysmon_power" module.  Unfortunately, even though the
     74  1.2  pgoyette 	sysmon_power code is modularized, it is referenced by the
     75  1.2  pgoyette 	acpi code which has not been modularized.  Therefore, if your
     76  1.2  pgoyette 	configuration has acpi, then you must include the "sysmon_power"
     77  1.2  pgoyette 	module built-in the kernel.  And therefore your also need to
     78  1.2  pgoyette 	have "sysmon_taskq" and "sysmon" built-in since "sysmon_power"
     79  1.2  pgoyette 	rerefences them.
     80  1.2  pgoyette 
     81  1.2  pgoyette 9. As a corollary to #8 above, having dependencies on modules from code
     82  1.2  pgoyette    which has not been modularized makes it extremely difficult to test
     83  1.2  pgoyette    the module code adequately.  Testing of module code should include
     84  1.2  pgoyette    both testing-as-a-built-in module and testing-as-a-loaded-module, and
     85  1.2  pgoyette    all dependencies need to be identified.
     86  1.3  pgoyette 
     87  1.6  pgoyette 10.The current /stand/$ARCH/$VERSION/modules/ hierarchy won't scale as
     88  1.6  pgoyette    we get more and more modules.  There are hundreds of potential device
     89  1.6  pgoyette    driver modules.
     90  1.6  pgoyette 
     91  1.6  pgoyette 11.There currently isn't any good way to handle attachment-specific
     92  1.6  pgoyette    modules.  The build infrastructure (ie, sys/modules/Makefile) doesn't
     93  1.6  pgoyette    readily lend itself to bus-specific modules irrespective of $ARCH,
     94  1.6  pgoyette    and maintaining distrib/sets/lists/modules/* is awkward at best.
     95  1.6  pgoyette 
     96  1.6  pgoyette    Furthermore, devices such as ld(4), which can attach to a large set
     97  1.6  pgoyette    of parent devices, need to be modified.  The parent devices need to
     98  1.6  pgoyette    provide a common attribute (for example, ld_bud), and the ld driver
     99  1.6  pgoyette    should attach to that attribute rather than to each parent.  But
    100  1.6  pgoyette    currently, config(1) doesn't handle this - it doesn't allow an
    101  1.6  pgoyette    attribute to be used as the device tree's pseudo-root.
    102  1.6  pgoyette 
    103  1.6  pgoyette 12.Item #11 gets even murkier when a particular parent can provide more
    104  1.6  pgoyette    than one attribute.
    105