-
Notifications
You must be signed in to change notification settings - Fork 4
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Kernel: Multiverse not usable in loadable kernel modules #3
Comments
A similar problem may also arise in userspace when a program using multiverse includes a (static) library that also uses the plugin.. |
Let's forget how the multiverse code looks like at the moment - it's not carved into stone. module support IMHO: Multiverse is a (really exotic) compiler feature and it sounds unnatural to me to optimize code I don't know :-) @mcgrof , @agraf - What's your opinion? Do you see an immediate benefit of using multiverse in modules? static libraries |
Yes, some kind of Okay, static libraries are probably not a real problem ;) The scenario I thought of: Program A uses Library B. Both use Multiverse. Where is |
A library should not call |
As loading a module does call the constructors of the module (at least if For now I would suggest, the following: step 1) use multiverse in a kernel without module support to get it working. In this stage, we can and should do first measurements. 2) make multiverse_init() idempotent and call it from the module (or mix it into the module loading code). Ignore unloading of modules for the sake of simplicity as this could become a little bit more ugly. |
Module support should be hard and a selling point should be ease of integration, so the more complex that becomes the harder I think folks will like it. I've had to also think about module support for the alternative to compiler multiverse support which I had worked on: linker tables. Upon review it would seem that other than addressing things on module init a typical solution to hard module problems which also rely on some kernel internals is to address hacks on find_module_sections() and use a special ELF section. Refer to find_module_sections() on kernel/module.c. This is for instance how jump labels are supported on modules, refer to references with "__jump_table". This is also how we support constructors on modules -- refer to ".ctors" references. That said, using custom ELF sections is a pain in the ass currently, but linker tables actually helps address these shortcomings by enabling custom ELF sections to be declared only using C code. My current linker-table implementation does not yet support modules but this is how I'd go about it. We'd add parsing custom module linker table sections once so custom linker tables would then always be parsed. I've rebased my latest code to next-20170620 but I haven't build tested this yet. I will have to respin soon based on the last feedback I got back in January, I have not gotten a chance since then to go back to it. If this seems like a viable strategy let me know. I should also note that linker tables can also supplement multiverse when compiler support is not present, however it would require code specific binary patching. Concurrency is certainly an issue that would need to be addressed, but perhaps jump labels are an example of a model to follow. What's the status of this git tree BTW -- could it soon be made public? |
👍
It's already public and has moved to |
Multiverse holds a list of all multiversed functions at runtime. The list is populated during startup by the generated
__multiverse_init
constructor functions. The functionmultiverse_init
gathers the additional runtime information (called manually once at startup).This approach is problematic when using multiverse in loadable kernel modules as they can be loaded at any time (after
multiverse_init
) and unloaded (leaving an invalid entry in themv_information
list, corrupting it).The text was updated successfully, but these errors were encountered: