• Steven Rostedt's avatar
    ftrace: fix dyn ftrace filter selection · 32464779
    Steven Rostedt authored
    Impact: clean up and fix for dyn ftrace filter selection
    
    The previous logic of the dynamic ftrace selection of enabling
    or disabling functions was complex and incorrect. This patch simplifies
    the code and corrects the usage. This simplification also makes the
    code more robust.
    
    Here is the correct logic:
    
      Given a function that can be traced by dynamic ftrace:
    
      If the function is not to be traced, disable it if it was enabled.
      (this is if the function is in the set_ftrace_notrace file)
    
      (filter is on if there exists any functions in set_ftrace_filter file)
    
      If the filter is on, and we are enabling functions:
        If the function is in set_ftrace_filter, enable it if it is not
          already enabled.
        If the function is not in set_ftrace_filter, disable it if it is not
          already disabled.
    
      Otherwise, if the filter is off and we are enabling function tracing:
        Enable the function if it is not already enabled.
    
      Otherwise, if we are disabling function tracing:
        Disable the function if it is not already disabled.
    
    This code now sets or clears the ENABLED flag in the record, and at the
    end it will enable the function if the flag is set, or disable the function
    if the flag is cleared.
    
    The parameters for the function that does the above logic is also
    simplified. Instead of passing in confusing "new" and "old" where
    they might be swapped if the "enabled" flag is not set. The old logic
    even had one of the above always NULL and had to be filled in. The new
    logic simply passes in one parameter called "nop". A "call" is calculated
    in the code, and at the end of the logic, when we know we need to either
    disable or enable the function, we can then use the "nop" and "call"
    properly.
    
    This code is more robust than the previous version.
    Signed-off-by: default avatarSteven Rostedt <srostedt@redhat.com>
    Signed-off-by: default avatarIngo Molnar <mingo@elte.hu>
    32464779
ftrace.c 30.3 KB