提交 4376cac6 编写于 作者: S Steven Rostedt 提交者: Steven Rostedt

ftrace: Do not disable interrupts for modules in mcount update

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: NSteven Rostedt <rostedt@goodmis.org>
上级 e4a3f541
...@@ -3318,7 +3318,7 @@ static int ftrace_process_locs(struct module *mod, ...@@ -3318,7 +3318,7 @@ static int ftrace_process_locs(struct module *mod,
{ {
unsigned long *p; unsigned long *p;
unsigned long addr; unsigned long addr;
unsigned long flags; unsigned long flags = 0; /* Shut up gcc */
mutex_lock(&ftrace_lock); mutex_lock(&ftrace_lock);
p = start; p = start;
...@@ -3336,12 +3336,18 @@ static int ftrace_process_locs(struct module *mod, ...@@ -3336,12 +3336,18 @@ static int ftrace_process_locs(struct module *mod,
} }
/* /*
* Disable interrupts to prevent interrupts from executing * We only need to disable interrupts on start up
* code that is being modified. * 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); ftrace_update_code(mod);
local_irq_restore(flags); if (!mod)
local_irq_restore(flags);
mutex_unlock(&ftrace_lock); mutex_unlock(&ftrace_lock);
return 0; return 0;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册