From c893e0eaa4dedc90fafc9353ea00fc34ad4b6d42 Mon Sep 17 00:00:00 2001 From: William Cohen Date: Wed, 17 May 2023 10:38:31 -0400 Subject: [PATCH] Support newer kernels with struct module_memory The upstream kernel commit ac3b43283923440900b4f36ca5f9f0b1ca43b70e changed the structures for modules. The runtime printing of kernel information accessed information about modules and the fields in module structure. A test has been added to the autoconf list to determine the appropriate fields to get information about the module. --- buildrun.cxx | 2 ++ runtime/linux/autoconf-module_memory.c | 3 +++ runtime/linux/print.c | 6 ++++++ 3 files changed, 11 insertions(+) create mode 100644 runtime/linux/autoconf-module_memory.c diff --git a/buildrun.cxx b/buildrun.cxx index a4a254c7d..7f4ad860d 100644 --- a/buildrun.cxx +++ b/buildrun.cxx @@ -512,6 +512,8 @@ compile_pass (systemtap_session& s) output_autoconf(s, o, cs, "autoconf-module_layout.c", "STAPCONF_MODULE_LAYOUT", NULL); + output_autoconf(s, o, cs, "autoconf-module_memory.c", + "STAPCONF_MODULE_MEMORY", NULL); output_autoconf(s, o, cs, "autoconf-mod_kallsyms.c", "STAPCONF_MOD_KALLSYMS", NULL); output_exportconf(s, o2, "get_user_pages_remote", "STAPCONF_GET_USER_PAGES_REMOTE"); diff --git a/runtime/linux/autoconf-module_memory.c b/runtime/linux/autoconf-module_memory.c new file mode 100644 index 000000000..db04b8d2e --- /dev/null +++ b/runtime/linux/autoconf-module_memory.c @@ -0,0 +1,3 @@ +#include + +struct module_memory ml; diff --git a/runtime/linux/print.c b/runtime/linux/print.c index 57a157986..594b155be 100644 --- a/runtime/linux/print.c +++ b/runtime/linux/print.c @@ -361,6 +361,11 @@ static void _stp_print_kernel_info(char *sname, char *vstr, int ctx, int num_pro (unsigned long) (THIS_MODULE->core_layout.size - THIS_MODULE->core_layout.text_size)/1024, (unsigned long) (THIS_MODULE->core_layout.text_size)/1024, #else +#if STAPCONF_MODULE_MEMORY + (unsigned long) THIS_MODULE->mem[MOD_TEXT].base, + (unsigned long) (THIS_MODULE->mem[MOD_DATA].size)/1024, + (unsigned long) (THIS_MODULE->mem[MOD_TEXT].size)/1024, +#else #ifndef STAPCONF_GRSECURITY (unsigned long) THIS_MODULE->module_core, (unsigned long) (THIS_MODULE->core_size - THIS_MODULE->core_text_size)/1024, @@ -370,6 +375,7 @@ static void _stp_print_kernel_info(char *sname, char *vstr, int ctx, int num_pro (unsigned long) (THIS_MODULE->core_size_rw - THIS_MODULE->core_size_rx)/1024, (unsigned long) (THIS_MODULE->core_size_rx)/1024, #endif +#endif #endif ctx/1024, _stp_allocated_net_memory/1024, -- 2.39.1