On Fri, 27 May 2022 23:40:03 -0400 Steven Rostedt <rostedt@xxxxxxxxxxx> wrote: > @@ -6830,6 +6960,10 @@ void ftrace_module_enable(struct module *mod) > if (ftrace_start_up) > cnt += referenced_filters(rec); > > + /* Weak functions should still be ignored */ > + if (!test_for_valid_rec(rec)) > + continue; This also needs to clear the other flags. As this is for module load, it does a two stage setup. That is to make the correct state of the ftrace locations in the module. As the updates to NOP is done before the text is set to RO, and if tracing is enabled/disabled during this time, it will trigger a BUG as it detects executable code running in RW text. To solve that, the initial setting of the records of the module is done with the DISABLE flag set, so they are ignored by the enabling and disabling of ftrace. All the module ftrace locations are set to NOP. This function is called after the text is set to ro and we enable the module functions based on the flags set. But if we are ignoring the record (as kvm has weak functions), we need to not only skip the setting of the code, but need to clear the flags to state they are not set. Otherwise it screws up the accounting of ftrace, and ftrace will WARN and disable itself. -- Steve > + > rec->flags &= ~FTRACE_FL_DISABLED; > rec->flags += cnt; >