]> git.proxmox.com Git - mirror_ubuntu-artful-kernel.git/commit - kernel/trace/ftrace.c
ftrace: Replace tramp_hash with old_*_hash to save space
authorSteven Rostedt (Red Hat) <rostedt@goodmis.org>
Thu, 24 Jul 2014 16:25:47 +0000 (12:25 -0400)
committerSteven Rostedt <rostedt@goodmis.org>
Wed, 10 Sep 2014 14:48:45 +0000 (10:48 -0400)
commitfef5aeeee9e3717e7aea991a7ae9ff6a7a2d4c85
tree1f74c6eb67ec987361f32e3d891132ecc5b1aa68
parente1effa0144a1ddf5b456c388ffaf784f3c5163fd
ftrace: Replace tramp_hash with old_*_hash to save space

Allowing function callbacks to declare their own trampolines requires
that each ftrace_ops that has a trampoline must have some sort of
accounting that keeps track of which ops has a trampoline attached
to a record.

The easy way to solve this was to add a "tramp_hash" that created a
hash entry for every function that a ops uses with a trampoline.
But since we can have literally tens of thousands of functions being
traced, that means we need tens of thousands of descriptors to map
the ops to the function in the hash. This is quite expensive and
can cause enabling and disabling the function graph tracer to take
some time to start and stop. It can take up to several seconds to
disable or enable all functions in the function graph tracer for this
reason.

The better approach albeit more complex, is to keep track of how ops
are being enabled and disabled, and use that along with the counting
of the number of ops attached to records, to determive what ops has
a trampoline attached to a record at enabling and disabling of
tracing.

To do this, the tramp_hash has been replaced with an old_filter_hash
and old_notrace_hash, which get the copy of the ops filter_hash and
notrace_hash respectively. The old hashes is kept until the ops has
been modified or removed and the old hashes are used with the logic
of the accounting to determine the ops that have the trampoline of
a record. The reason this has less of a footprint is due to the trick
that an "empty" hash in the filter_hash means "all functions" and
an empty hash in the notrace hash means "no functions" in the hash.

This is much more efficienct, doesn't have the delay, and takes up
much less memory, as we do not need to map all the functions but
just figure out which functions are mapped at the time it is
enabled or disabled.

Signed-off-by: Steven Rostedt <rostedt@goodmis.org>
include/linux/ftrace.h
kernel/trace/ftrace.c