* Paolo Bonzini <pbonzini@xxxxxxxxxx> wrote: > On 05/23/2011 01:38 PM, Ingo Molnar wrote: > > Later on even this could be removed: using section tricks we can put init > > functions into a section > > This is not kernel space, the C library provides a way to do that > with __attribute__((constructor))... Yeah, that would certainly work for simple things but there's several reasons why explicit control over initcalls is preferred in a tool like tools/kvm/ over __attribute__((constructor)): - C constructors run before main() so any generic environment that tools/kvm/ might want to set up is not available yet - including but not limited to the command line arguments. - C constructors have random limitations like apparently not being executed if the constructor is linked into a .a static library. - It has advantages to have explicit control over initcalls - that way debugging and other instrumentation can be added freely. For example the kernel has a debug_initcall boot parameter to print the initcalls as they are executed. They can also be traced. - The kernel has several classes of initcalls with different call priority, i'm not aware of an equivalent __attribute__((constructor)) capability. We could also do more sophisticated layers of initcalls or an explicit initcall dependency tree, should the need arise. Using .section tricks directly isnt particularly complex and the result is rather flexible, well-defined and visible. Thanks, Ingo -- To unsubscribe from this list: send the line "unsubscribe kvm" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html