]> git.openfabrics.org - ~emulex/infiniband.git/commitdiff
ftrace: Do not disable interrupts for modules in mcount update
authorSteven Rostedt <srostedt@redhat.com>
Sat, 25 Jun 2011 03:28:13 +0000 (23:28 -0400)
committerSteven Rostedt <rostedt@goodmis.org>
Fri, 8 Jul 2011 02:39:38 +0000 (22:39 -0400)
When I mounted an NFS directory, it caused several modules to be loaded. At the
time I was running the preemptirqsoff tracer, and it showed the following
output:

# tracer: preemptirqsoff
#
# preemptirqsoff latency trace v1.1.5 on 2.6.33.9-rt30-mrg-test
# --------------------------------------------------------------------
# latency: 1177 us, #4/4, CPU#3 | (M:preempt VP:0, KP:0, SP:0 HP:0 #P:4)
#    -----------------
#    | task: modprobe-19370 (uid:0 nice:0 policy:0 rt_prio:0)
#    -----------------
#  => started at: ftrace_module_notify
#  => ended at:   ftrace_module_notify
#
#
#                  _------=> CPU#
#                 / _-----=> irqs-off
#                | / _----=> need-resched
#                || / _---=> hardirq/softirq
#                ||| / _--=> preempt-depth
#                |||| /_--=> lock-depth
#                |||||/     delay
#  cmd     pid   |||||| time  |   caller
#     \   /      ||||||   \   |   /
modprobe-19370   3d....    0us!: ftrace_process_locs <-ftrace_module_notify
modprobe-19370   3d.... 1176us : ftrace_process_locs <-ftrace_module_notify
modprobe-19370   3d.... 1178us : trace_hardirqs_on <-ftrace_module_notify
modprobe-19370   3d.... 1178us : <stack trace>
 => ftrace_process_locs
 => ftrace_module_notify
 => notifier_call_chain
 => __blocking_notifier_call_chain
 => blocking_notifier_call_chain
 => sys_init_module
 => system_call_fastpath

That's over 1ms that interrupts are disabled on a Real-Time kernel!

Looking at the cause (being the ftrace author helped), I found that the
interrupts are disabled before the code modification of mcounts into nops. The
interrupts only need to be disabled on start up around this code, not when
modules are being loaded.

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

index c997f7371c65f1ebc707b17b426126422492ab4d..df93392aad89a29a0d6f805960981c48c0c4ba88 100644 (file)
@@ -3318,7 +3318,7 @@ static int ftrace_process_locs(struct module *mod,
 {
        unsigned long *p;
        unsigned long addr;
-       unsigned long flags;
+       unsigned long flags = 0; /* Shut up gcc */
 
        mutex_lock(&ftrace_lock);
        p = start;
@@ -3336,12 +3336,18 @@ static int ftrace_process_locs(struct module *mod,
        }
 
        /*
-        * Disable interrupts to prevent interrupts from executing
-        * code that is being modified.
+        * We only need to disable interrupts on start up
+        * because we are modifying code that an interrupt
+        * may execute, and the modification is not atomic.
+        * But for modules, nothing runs the code we modify
+        * until we are finished with it, and there's no
+        * reason to cause large interrupt latencies while we do it.
         */
-       local_irq_save(flags);
+       if (!mod)
+               local_irq_save(flags);
        ftrace_update_code(mod);
-       local_irq_restore(flags);
+       if (!mod)
+               local_irq_restore(flags);
        mutex_unlock(&ftrace_lock);
 
        return 0;