-
Notifications
You must be signed in to change notification settings - Fork 71
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
Use of late_initcall_sync broke build on RHEL7 kernels #37
Comments
@solardiz which kernel are you using? I've checked the following one and don't have any issue:
|
A much older RHEL7'ish kernel. Can you perhaps simply have LKRG build revert to the old behavior when building for RHEL7 kernels older than 3.10.0-1160? Perhaps if anyone ever builds LKRG into a RHEL7 kernel, they'll do so for a current RHEL7 kernel and thus have at least the version you tested above. We could also revert to the old behavior on some upstream kernels (perhaps at least <= 3.10), but in practice for old kernels like this only RHEL7 matters. |
Here's a weird workaround: +++ b/src/p_lkrg_main.c
@@ -15,6 +15,10 @@
*
*/
+#undef MODULE
+#include <linux/init.h>
+#define MODULE
+
#include "p_lkrg_main.h"
unsigned int log_level = 3; Somehow that header only defines those things when non- |
Oh, that workaround makes the module build without warnings, but then loading it does nothing - so I guess I suspect it's similar on some upstream kernels (e.g., various 3.x), where LKRG currently builds with the warnings, and loading it doesn't actually enable it. We probably do need to identify the kernel version where that changed. |
Maybe this is the cleanest fix? - +++ b/src/p_lkrg_main.c
@@ -678,7 +678,11 @@ static void __exit p_lkrg_deregister(void) {
}
+#ifdef MODULE
+module_init(p_lkrg_register);
+#else
late_initcall_sync(p_lkrg_register);
+#endif
module_exit(p_lkrg_deregister);
module_param(log_level, uint, 0000); (Works on the old RHEL7'ish kernel here.) Is there a good enough reason for us to prefer |
@solardiz thanks for that research! |
@Adam-pi3 We already know |
I think we might have some misunderstanding what I mean by "somehow desired". LKRG should be loaded in the system after kernel is fully initialized, or at least after that phase of initialization when it is stable to have presumptions which LKRG have (e.g. .text section is not going to be modified without going to the official API like JUMP_LABEL and/or FTRACE). Some of the kernel modules might also install KPROBEs which is incompatible with LKRG (unless they are optimized to be FTRACE-based Probes). Taking this into account, it is "safer" to load LKRG in the last possible stage. Linux kernel defines the following priority of module loading (based on: https://elixir.bootlin.com/linux/latest/source/include/linux/module.h):
Some kernel also defines: some of them don't define |
I guess those uses are in drivers compiled into the kernel, not loaded as modules. Notice how that would be consistent with the comment you quoted, and with So mix fix is actually correct, resulting in the exact same behavior on older kernels that we have on newer ones, and leaving the latter unchanged. |
We switched to using late_initcall_sync() in order to have LKRG initialize sufficiently late when it's linked into the kernel. That change was a no-op when building/loading LKRG as a module on recent kernels, because their module.h defines late_initcall_sync() as an alias for module_init(). However, it broke LKRG on some older kernels, where late_initcall_sync() wasn't defined for modules at all. This commit fixes that by explicitly using module_init() when building LKRG as a module. This change is a no-op on recent kernels. Fixes #37, updates ddc14c6
Building an LKRG revision after ddc14c6 on a CentOS 7 system (deliberately not up to date, has an older RHEL7'ish kernel) results in these warnings:
Despite of these, the build completes, but I wouldn't expect the module to work right (didn't try loading it).
We probably need to make our use of
late_initcall_sync
conditional upon kernel versions that support it.The text was updated successfully, but these errors were encountered: