TODO.modules revision 1.7
11.7Schristos/* $NetBSD: TODO.modules,v 1.7 2016/09/27 22:54:57 christos Exp $ */ 21.1Spgoyette 31.1SpgoyetteSome notes on the limitations of our current (as of 7.99.35) module 41.1Spgoyettesubsystem. This list was triggered by an Email exchange between 51.1Spgoyettechristos and pgoyette. 61.1Spgoyette 71.7Schristos 1. Builtin drivers can't depend on modularized drivers (the modularized 81.7Schristos drivers are attempted to load as builtins). 91.1Spgoyette 101.1Spgoyette The assumption is that dependencies are loaded before those 111.1Spgoyette modules which depend on them. At load time, a module's 121.1Spgoyette undefined global symbols are resolved; if any symbols can't 131.1Spgoyette be resolved, the load fails. Similarly, if a module is 141.1Spgoyette included in (built-into) the kernel, all of its symbols must 151.1Spgoyette be resolvable by the linker, otherwise the link fails. 161.1Spgoyette 171.1Spgoyette There are ways around this (such as, having the parent 181.1Spgoyette module's initialization command recursively call the module 191.5Spgoyette load code), but they're often gross hacks. 201.5Spgoyette 211.5Spgoyette Another alternative (which is used by ppp) is to provide a 221.5Spgoyette "registration" mechanism for the "child" modules, and then when 231.5Spgoyette the need for a specific child module is encountered, use 241.5Spgoyette module_autoload() to load the child module. Of course, this 251.5Spgoyette requires that the parent module know about all potentially 261.5Spgoyette loadable children. 271.1Spgoyette 281.7Schristos 2. Currently, config(1) has no way to "no define" drivers 291.7Schristos XXX: I don't think this is true anymore. I think we can 301.7Schristos undefine drivers now, see MODULAR in amd64, which does 311.7Schristos no ath* and no select sppp* 321.7Schristos 331.7Schristos 3. It is not always obvious by their names which drivers/options 341.7Schristos correspond to which modules. 351.7Schristos 361.7Schristos 4. Right now critical drivers that would need to be pre-loaded (ffs, 371.7Schristos exec_elf64) are still built-in so that we don't need to alter the boot 381.7Schristos blocks to boot. 391.1Spgoyette 401.1Spgoyette This was a conscious decision by core@ some years ago. It is 411.1Spgoyette not a requirement that ffs or exec_* be built-in. The only 421.1Spgoyette requirement is that the root file-system's module must be 431.1Spgoyette available when the module subsystem is initialized, in order 441.1Spgoyette to load other modules. This can be accomplished by having the 451.1Spgoyette boot loader "push" the module at boot time. (It used to do 461.1Spgoyette this in all cases; currently the "push" only occurs if the 471.1Spgoyette booted filesystem is not ffs.) 481.1Spgoyette 491.7Schristos 5. Not all parent bus drivers are capable of rescan, so some drivers 501.7Schristos just have to be built-in. 511.1Spgoyette 521.7Schristos 6. Many (most?) drivers are not yet modularized 531.1Spgoyette 541.7Schristos 7. There's currently no provisions for autoconfig to figure out which 551.7Schristos modules are needed, and thus to load the required modules. 561.1Spgoyette 571.1Spgoyette In the "normal" built-in world, autoconfigure can only ask 581.1Spgoyette existing drivers if they're willing to manage (ie, attach) a 591.1Spgoyette device. Removing the built-in drivers tends to limit the 601.1Spgoyette availability of possible managers. There's currently no 611.1Spgoyette mechanism for identifying and loading drivers based on what 621.1Spgoyette devices might be found. 631.1Spgoyette 641.7Schristos 8. Even for existing modules, there are "surprise" dependencies with 651.7Schristos code that has not yet been modularized. 661.2Spgoyette 671.2Spgoyette For example, even though the bpf code has been modularized, 681.2Spgoyette there is some shared code in bpf_filter.c which is needed by 691.2Spgoyette both ipfilter and ppp. ipf is already modularized, but ppp 701.2Spgoyette is not. Thus, even though bpf_filter is modular, it MUST be 711.2Spgoyette included as a built-in module if you also have ppp in your 721.2Spgoyette configuration. 731.2Spgoyette 741.2Spgoyette Another example is sysmon_taskq module. It is required by 751.2Spgoyette other parts of the sysmon subsystem, including the 761.2Spgoyette "sysmon_power" module. Unfortunately, even though the 771.2Spgoyette sysmon_power code is modularized, it is referenced by the 781.2Spgoyette acpi code which has not been modularized. Therefore, if your 791.2Spgoyette configuration has acpi, then you must include the "sysmon_power" 801.2Spgoyette module built-in the kernel. And therefore your also need to 811.2Spgoyette have "sysmon_taskq" and "sysmon" built-in since "sysmon_power" 821.2Spgoyette rerefences them. 831.2Spgoyette 841.7Schristos 9. As a corollary to #8 above, having dependencies on modules from code 851.7Schristos which has not been modularized makes it extremely difficult to test 861.7Schristos the module code adequately. Testing of module code should include 871.7Schristos both testing-as-a-built-in module and testing-as-a-loaded-module, and 881.7Schristos all dependencies need to be identified. 891.7Schristos 901.7Schristos10. The current /stand/$ARCH/$VERSION/modules/ hierarchy won't scale as 911.7Schristos we get more and more modules. There are hundreds of potential device 921.7Schristos driver modules. 931.7Schristos 941.7Schristos11. There currently isn't any good way to handle attachment-specific 951.7Schristos modules. The build infrastructure (ie, sys/modules/Makefile) doesn't 961.7Schristos readily lend itself to bus-specific modules irrespective of $ARCH, 971.7Schristos and maintaining distrib/sets/lists/modules/* is awkward at best. 981.7Schristos 991.7Schristos Furthermore, devices such as ld(4), which can attach to a large set 1001.7Schristos of parent devices, need to be modified. The parent devices need to 1011.7Schristos provide a common attribute (for example, ld_bud), and the ld driver 1021.7Schristos should attach to that attribute rather than to each parent. But 1031.7Schristos currently, config(1) doesn't handle this - it doesn't allow an 1041.7Schristos attribute to be used as the device tree's pseudo-root. The current 1051.7Schristos directory structure where driver foo is split between ic/foo.c 1061.7Schristos and bus1/foo_bus1.c ... busn/foo_busn.c is annoying. It would be 1071.7Schristos better to switch to the FreeBSD model which puts all the driver 1081.7Schristos files in one directory. 1091.6Spgoyette 1101.7Schristos12. Item #11 gets even murkier when a particular parent can provide more 1111.7Schristos than one attribute. 112