Skip to content
  • Steven Rostedt's avatar
    ftrace: function tracer with irqs disabled · b2a866f9
    Steven Rostedt authored
    
    
    Impact: disable interrupts during trace entry creation (as opposed to preempt)
    
    To help with performance, I set the ftracer to not disable interrupts,
    and only to disable preemption. If an interrupt occurred, it would not
    be traced, because the function tracer protects itself from recursion.
    This may be faster, but the trace output might miss some traces.
    
    This patch makes the fuction trace disable interrupts, but it also
    adds a runtime feature to disable preemption instead. It does this by
    having two different tracer functions. When the function tracer is
    enabled, it will check to see which version is requested (irqs disabled
    or preemption disabled). Then it will use the corresponding function
    as the tracer.
    
    Irq disabling is the default behaviour, but if the user wants better
    performance, with the chance of missing traces, then they can choose
    the preempt disabled version.
    
    Running hackbench 3 times with the irqs disabled and 3 times with
    the preempt disabled function tracer yielded:
    
    tracing type       times            entries recorded
    ------------      --------          ----------------
    irq disabled      43.393            166433066
                      43.282            166172618
                      43.298            166256704
    
    preempt disabled  38.969            159871710
                      38.943            159972935
                      39.325            161056510
    
    Average:
    
       irqs disabled:  43.324           166287462
    preempt disabled:  39.079           160300385
    
     preempt is 10.8 percent faster than irqs disabled.
    
    I wrote a patch to count function trace recursion and reran hackbench.
    
    With irq disabled: 1,150 times the function tracer did not trace due to
      recursion.
    with preempt disabled: 5,117,718 times.
    
    The thousand times with irq disabled could be due to NMIs, or simply a case
    where it called a function that was not protected by notrace.
    
    But we also see that a large amount of the trace is lost with the
    preempt version.
    
    Signed-off-by: default avatarSteven Rostedt <srostedt@redhat.com>
    Cc: Peter Zijlstra <peterz@infradead.org>
    Cc: Andrew Morton <akpm@linux-foundation.org>
    Cc: Steven Rostedt <srostedt@redhat.com>
    Signed-off-by: default avatarIngo Molnar <mingo@elte.hu>
    b2a866f9