tech-kern archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

re: Modules loading modules?



On Mon, 26 Jul 2010, matthew green wrote:


it seems to me the root problem is that module_mutex is held while
calling into the module startup routines.

thus, the right solution is to remove this requirement.

Yes, that's what is needed.

But it sounds a lot simpler than it is. Among other issues, we'd need to ensure that we continue to detect circular dependencies between both sets of required modules. And, since we call the module startup routine for a required module _before_ we call it for the required module, we would need to release and then reacquire the mutex, all the while being sure that the data structures don't get changed out from under us.

We would end up with something like this sequence,where module A requires A1 and A2, and module B requires B1 and B2, and hopefully (B1 != A && B2 != A) (which would be a hidden circular dependency).

        mutex_enter()
        load module A
                load required module A1
                        mutex_exit()
                        call A1's init routine
                        mutex_enter()
                load required module A2
                        mutex_exit()
                        call A2's init routine
                                mutex_enter()
                                load module B
                                        load required module B1
                                                mutex_exit()
                                                call B1's init routine
                                                mutex_enter()
                                        load required module B2
                                                mutex_exit()
                                                call B2's init routine
                                                mutex_enter()
                                        mutex_exit()
                                        call B's init routine
                                        mutex_enter()
                                mutex_exit()
                        mutex_enter()
                mutex_exit()
                call A's init routine
                mutex_enter()
        mutex_exit()



-------------------------------------------------------------------------
| Paul Goyette     | PGP Key fingerprint:     | E-mail addresses:       |
| Customer Service | FA29 0E3B 35AF E8AE 6651 | paul at whooppee.com    |
| Network Engineer | 0786 F758 55DE 53BA 7731 | pgoyette at juniper.net |
| Kernel Developer |                          | pgoyette at netbsd.org  |
-------------------------------------------------------------------------


Home | Main Index | Thread Index | Old Index