diff options
author | Steven Rostedt <srostedt@redhat.com> | 2011-07-14 23:02:27 -0400 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@suse.de> | 2011-10-16 14:14:55 -0700 |
commit | 9374622a9923b2343ee2f5083ebe6c51fcc914c5 (patch) | |
tree | e8bb3d4a219b791361b4c9d716350d17be0b7d8f /kernel/configs.c | |
parent | d7f04c486e494bf96166ff53b0957369e32509c6 (diff) | |
download | kernel_samsung_aries-9374622a9923b2343ee2f5083ebe6c51fcc914c5.zip kernel_samsung_aries-9374622a9923b2343ee2f5083ebe6c51fcc914c5.tar.gz kernel_samsung_aries-9374622a9923b2343ee2f5083ebe6c51fcc914c5.tar.bz2 |
ftrace: Fix regression where ftrace breaks when modules are loaded
commit f7bc8b61f65726ff98f52e286b28e294499d7a08 upstream.
Enabling function tracer to trace all functions, then load a module and
then disable function tracing will cause ftrace to fail.
This can also happen by enabling function tracing on the command line:
ftrace=function
and during boot up, modules are loaded, then you disable function tracing
with 'echo nop > current_tracer' you will trigger a bug in ftrace that
will shut itself down.
The reason is, the new ftrace code keeps ref counts of all ftrace_ops that
are registered for tracing. When one or more ftrace_ops are registered,
all the records that represent the functions that the ftrace_ops will
trace have a ref count incremented. If this ref count is not zero,
when the code modification runs, that function will be enabled for tracing.
If the ref count is zero, that function will be disabled from tracing.
To make sure the accounting was working, FTRACE_WARN_ON()s were added
to updating of the ref counts.
If the ref count hits its max (> 2^30 ftrace_ops added), or if
the ref count goes below zero, a FTRACE_WARN_ON() is triggered which
disables all modification of code.
Since it is common for ftrace_ops to trace all functions in the kernel,
instead of creating > 20,000 hash items for the ftrace_ops, the hash
count is just set to zero, and it represents that the ftrace_ops is
to trace all functions. This is where the issues arrise.
If you enable function tracing to trace all functions, and then add
a module, the modules function records do not get the ref count updated.
When the function tracer is disabled, all function records ref counts
are subtracted. Since the modules never had their ref counts incremented,
they go below zero and the FTRACE_WARN_ON() is triggered.
The solution to this is rather simple. When modules are loaded, and
their functions are added to the the ftrace pool, look to see if any
ftrace_ops are registered that trace all functions. And for those,
update the ref count for the module function records.
Reported-by: Thomas Gleixner <tglx@linutronix.de>
Signed-off-by: Steven Rostedt <rostedt@goodmis.org>
Diffstat (limited to 'kernel/configs.c')
0 files changed, 0 insertions, 0 deletions