On Mon, Jul 29, 2024 at 09:46:17AM +0800, Youling Tang wrote:The number of lines of code is not important, the main point is to
1. Previous version implementation: array mode (see link 1) :But there's also method zero --- keep things the way they are, and
Advantages:
- Few changes, simple principle, easy to understand code.
Disadvantages:
- Each modified module needs to maintain an array, more code.
2. Current implementation: explicit call subinit in initcall (see link 2) :
Advantages:
- Direct use of helpes macros, the subinit call sequence is
intuitive, and the implementation is relatively simple.
Disadvantages:
- helper macros need to be implemented compared to array mode.
3. Only one module_subinit per file (not implemented, see link 3) :
Advantage:
- No need to display to call subinit.
Disadvantages:
- Magic order based on Makefile makes code more fragile,
- Make sure that each file has only one module_subinit,
- It is not intuitive to know which subinits the module needs
and in what order (grep and Makefile are required),
- With multiple subinits per module, it would be difficult to
define module_{subinit, subexit} by MODULE, and difficult to
rollback when initialization fails (I haven't found a good way
to do this yet).
Personally, I prefer the implementation of method two.
don't try to add a new astraction.
Advantage:
-- Code has worked for decades, so it is very well tested
-- Very easy to understand and maintain
Disadvantage
--- A few extra lines of C code.
which we need to weigh against the other choices.
- Ted