tracing: remove superfluous sub instructions
PATCH 1/1 tracing: remove superfluous sub instructions
hi,
I think there's no need for substracting MCOUNT_INSN_SIZE from the IP parameter before calling the function trace (/graph) handler.
Maybe I overlooked something, but all the IP usage I saw ended up in the kallsyms_lookup function, which does the lookup using the functions' start/end boundaries to find the correct symbol for pointer.
Thus it seems to me there's no point in substracting the MCOUNT_INSN_SIZE value from the IP parameter.
I tested for x86_64 and got proper results, I believe it's the same case for x86_32.
wbr,
jirka
--- arch/x86/kernel/entry_32.S | 3 --- arch/x86/kernel/entry_64.S | 3 --- 2 files changed, 0 insertions(+), 6 deletions(-)
arch/x86/kernel/entry_32.S +0 -3
@@ -1122,7 +1122,6 @@ ENTRY(ftrace_caller) pushl %edx movl 0xc(%esp), %eax movl 0x4(%ebp), %edx - subl $MCOUNT_INSN_SIZE, %eax .globl ftrace_call ftrace_call:
@@ -1168,7 +1167,6 @@ trace: pushl %edx movl 0xc(%esp), %eax movl 0x4(%ebp), %edx - subl $MCOUNT_INSN_SIZE, %eax call *ftrace_trace_function
@@ -1191,7 +1189,6 @@ ENTRY(ftrace_graph_caller) movl 0xc(%esp), %edx lea 0x4(%ebp), %eax movl (%ebp), %ecx - subl $MCOUNT_INSN_SIZE, %edx call prepare_ftrace_return popl %edx popl %ecx
arch/x86/kernel/entry_64.S +0 -3
@@ -75,7 +75,6 @@ ENTRY(ftrace_caller) movq 0x38(%rsp), %rdi movq 8(%rbp), %rsi - subq $MCOUNT_INSN_SIZE, %rdi GLOBAL(ftrace_call) call ftrace_stub
@@ -115,7 +114,6 @@ trace: movq 0x38(%rsp), %rdi movq 8(%rbp), %rsi - subq $MCOUNT_INSN_SIZE, %rdi call *ftrace_trace_function
@@ -136,7 +134,6 @@ ENTRY(ftrace_graph_caller) leaq 8(%rbp), %rdi movq 0x38(%rsp), %rsi movq (%rbp), %rdx - subq $MCOUNT_INSN_SIZE, %rsi call prepare_ftrace_return
Quoted 12 lines · Jiri Olsa
hi,
I think there's no need for substracting
MCOUNT_INSN_SIZEfrom the IP parameter before calling the function trace (/graph) handler.Maybe I overlooked something, but all the IP usage I saw ended up in the
kallsyms_lookupfunction, which does the lookup using the functions' start/end boundaries to find the correct symbol for pointer.Thus it seems to me there's no point in substracting the
MCOUNT_INSN_SIZEvalue from the IP parameter.
Quoted 8 lines
I tested for
x86_64and got proper results, I believe it's the same case forx86_32.wbr,
jirkaSigned-off-by Jiri Olsa <[email protected]>
Well, that sounds right after all. If we are only interested in the symbol, the instruction that follows "call mcount" is still relevant as it must belong to the same function.
Steve?
Steven Rostedt
NAKQuoted 20 lines · Frederic Weisbecker
Quoted 19 lines · Jiri Olsa
hi,
I think there's no need for substracting
MCOUNT_INSN_SIZEfrom the IP parameter before calling the function trace (/graph) handler.Maybe I overlooked something, but all the IP usage I saw ended up in the
kallsyms_lookupfunction, which does the lookup using the functions' start/end boundaries to find the correct symbol for pointer.Thus it seems to me there's no point in substracting the
MCOUNT_INSN_SIZEvalue from the IP parameter.I tested for
x86_64and got proper results, I believe it's the same case forx86_32.wbr,
jirka
Quoted 7 lines
Quoted 1 line
Signed-off-by Jiri Olsa <[email protected]>Well, that sounds right after all. If we are only interested in the symbol, the instruction that follows "call mcount" is still relevant as it must belong to the same function.
Steve?
NAK, it will break function triggers/probes. The "func:traceon" and "func:traceoff". They compare the ip to the call location of mcount.
-- Steve
Quoted 27 lines · Steven Rostedt
Quoted 26 lines · Frederic Weisbecker
Quoted 12 lines · Jiri Olsa
hi,
I think there's no need for substracting
MCOUNT_INSN_SIZEfrom the IP parameter before calling the function trace (/graph) handler.Maybe I overlooked something, but all the IP usage I saw ended up in the
kallsyms_lookupfunction, which does the lookup using the functions' start/end boundaries to find the correct symbol for pointer.Thus it seems to me there's no point in substracting the
MCOUNT_INSN_SIZEvalue from the IP parameter.Quoted 8 lines
I tested for
x86_64and got proper results, I believe it's the same case forx86_32.wbr,
jirkaSigned-off-by Jiri Olsa <[email protected]>Well, that sounds right after all. If we are only interested in the symbol, the instruction that follows "call mcount" is still relevant as it must belong to the same function.
Quoted 8 lines
Quoted 1 line
Steve?
NAK, it will break function triggers/probes. The "func:traceon" and "func:traceoff". They compare the ip to the call location of mcount.
-- Steve
ops, missed this one..
would it make sense to update the IP inside the function_trace_probe_call function to save one instruction in the entry code used by all? or it's not worth it..
jirka
Quoted 5 lines · Jiri Olsa
ops, missed this one..
would it make sense to update the IP inside the
function_trace_probe_callfunction to save one instruction in the entry code used by all? or it's not worth it..
That would require function_trace_probe_call() to handle arch dependencies. I would like to keep arch dependent code in the arch subsystem when possible.
This change only saves a subtraction to a register. It only gets called if we are tracing functions. This modification is far into the noise that is caused by the tracer. I don't think it is worth it as it will cause head aches with knowing how to handle the ip from the users of the function tracer.
I do plan on making the function tracer a bit more generic for common users. I would like to keep the ip at the call site of mcount.
-- Steve