Skip to content
  • Steven Rostedt's avatar
    ftrace/x86: Add support for -mfentry to x86_64 · d57c5d51
    Steven Rostedt authored
    If the kernel is compiled with gcc 4.6.0 which supports -mfentry,
    then use that instead of mcount.
    
    With mcount, frame pointers are forced with the -pg option and we
    get something like:
    
    <can_vma_merge_before>:
           55                      push   %rbp
           48 89 e5                mov    %rsp,%rbp
           53                      push   %rbx
           41 51                   push   %r9
           e8 fe 6a 39 00          callq  ffffffff81483d00 <mcount>
           31 c0                   xor    %eax,%eax
           48 89 fb                mov    %rdi,%rbx
           48 89 d7                mov    %rdx,%rdi
           48 33 73 30             xor    0x30(%rbx),%rsi
           48 f7 c6 ff ff ff f7    test   $0xfffffffff7ffffff,%rsi
    
    With -mfentry, frame pointers are no longer forced and the call looks
    like this:
    
    <can_vma_merge_before>:
           e8 33 af 37 00          callq  ffffffff81461b40 <__fentry__>
           53                      push   %rbx
           48 89 fb                mov    %rdi,%rbx
           31 c0                   xor    %eax,%eax
           48 89 d7                mov    %rdx,%rdi
           41 51                   push   %r9
           48 33 73 30             xor    0x30(%rbx),%rsi
           48 f7 c6 ff ff ff f7    test   $0xfffffffff7ffffff,%rsi
    
    This adds the ftrace hook at the beginning of the function before a
    frame is set up, and allows the function callbacks to be able to access
    parameters. As kprobes now can use function tracing (at least on x86)
    this speeds up the kprobe hooks that are at the beginning of the
    function.
    
    Link: http://lkml.kernel.org/r/20120807194100.130477900@goodmis.org
    
    
    
    Acked-by: default avatarIngo Molnar <mingo@kernel.org>
    Reviewed-by: default avatarMasami Hiramatsu <masami.hiramatsu.pt@hitachi.com>
    Cc: Andi Kleen <andi@firstfloor.org>
    Signed-off-by: default avatarSteven Rostedt <rostedt@goodmis.org>
    d57c5d51