• S
    ftrace: Replace tramp_hash with old_*_hash to save space · fef5aeee
    Steven Rostedt (Red Hat) 提交于
    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: NSteven Rostedt <rostedt@goodmis.org>
    fef5aeee
ftrace.h 26.9 KB