tracing: ignore FTRACE_FL_DISABLED while walking dyn_ftrace records
PATCH 1/1 tracing: ignore FTRACE_FL_DISABLED while walking dyn_ftrace records
ftrace_shutdown() checks for sanity of ftrace records
and if dyn_ftrace->flags is not zero, it will warn.
It can happen that 'flags' are set to FTRACE_FL_DISABLED at this point, since some module was loaded, but before ftrace_module_enable() cleared the flags for this module.
In other words the module.c is doing:ftrace_module_init(mod); // calls ftrace_update_code() that sets flags=FTRACE_FL_DISABLED ... // here ftrace_shutdown() is called that warns, since
err = prepare_coming_module(mod); // didn't have a chance to clear FTRACE_FL_DISABLED
Fix it by ignoring disabled records.
It's similar to what __ftrace_hash_rec_update() is already doing.
--- kernel/trace/ftrace.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
kernel/trace/ftrace.c +1 -1
@@ -2763,7 +2763,7 @@ static int ftrace_shutdown(struct ftrace_ops *ops, int command)struct dyn_ftrace *rec;do_for_each_ftrace_rec (pg, rec) { -if (FTRACE_WARN_ON_ONCE (rec->flags)) +if (FTRACE_WARN_ON_ONCE (rec->flags & ~FTRACE_FL_DISABLED ))pr_warn (" %pS flags:%lx\n" , (void *)rec->ip, rec->flags); }while_for_each_ftrace_rec ();
Signature · 1 line
2.8.0
Steven Rostedt
maintainerQuoted 6 lines · On Mon, 7 Nov 2016 15:14:20 -0800 Alexei Starovoitov <[email protected]> wrote:
ftrace_shutdown()checks for sanity of ftrace records
and ifdyn_ftrace->flagsis not zero, it will warn.
It can happen that 'flags' are set toFTRACE_FL_DISABLEDat this point, since some module was loaded, but beforeftrace_module_enable()cleared the flags for this module.
Quoted 8 lines
In other words the
module.cis doing:ftrace_module_init(mod); // callsftrace_update_code()that sets flags=FTRACE_FL_DISABLED ... // hereftrace_shutdown()is called that warns, since
err =prepare_coming_module(mod); // didn't have a chance to clearFTRACE_FL_DISABLEDFix it by ignoring disabled records.
It's similar to what__ftrace_hash_rec_update()is already doing.
Alexei,
Do you have a clear reproducer of this bug?
-- Steve
Quoted 18 lines
Signed-off-by Alexei Starovoitov <[email protected]>--- kernel/trace/ftrace.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)kernel/trace/ftrace.c +1
-1@@ -2763,7 +2763,7 @@ static int ftrace_shutdown(struct ftrace_ops *ops, int command)struct dyn_ftrace *rec;do_for_each_ftrace_rec (pg, rec) { -if (FTRACE_WARN_ON_ONCE (rec->flags)) +if (FTRACE_WARN_ON_ONCE (rec->flags & ~FTRACE_FL_DISABLED ))pr_warn (" %pS flags:%lx\n" , (void *)rec->ip, rec->flags); }while_for_each_ftrace_rec ();
Quoted 14 lines · Steven Rostedt
Quoted 11 lines · On Mon, 7 Nov 2016 15:14:20 -0800 Alexei Starovoitov <[email protected]> wrote:
ftrace_shutdown()checks for sanity of ftrace records
and ifdyn_ftrace->flagsis not zero, it will warn.
It can happen that 'flags' are set toFTRACE_FL_DISABLEDat this point, since some module was loaded, but beforeftrace_module_enable()cleared the flags for this module.In other words the
module.cis doing:ftrace_module_init(mod); // callsftrace_update_code()that sets flags=FTRACE_FL_DISABLED ... // hereftrace_shutdown()is called that warns, since
err =prepare_coming_module(mod); // didn't have a chance to clearFTRACE_FL_DISABLED
Quoted 7 lines
Quoted 3 lines
Fix it by ignoring disabled records.
It's similar to what__ftrace_hash_rec_update()is already doing.Alexei,
Do you have a clear reproducer of this bug?
Nope. No reproducer. It's very rare. Only stack trace that I posted earlier. Since it kills ftrace everything that depends on it later spews a ton of other warnings. So it's an important fix.