On Wed, 15 Mar 2017 15:55:32 -0400
Steven Rostedt <[email protected]> wrote:

> From: "Steven Rostedt (VMware)" <[email protected]>
> 
> x86_64 has had fentry support for some time. I did not add support to x86_32
> as I was unsure if it will be used much in the future. It is still very much
> used, and there's issues with function graph tracing with gcc playing around
> with the mcount frames, causing function graph to panic. The fentry code
> does not have this issue, and is able to cope as there is no frame to mess
> up.
> 
> Note, this only add support for fentry when DYNAMIC_FTRACE is set. There's
> really no reason to not have that set, because the performance of the
> machine drops significantly when it's not enabled. I only keep
> !DYNAMIC_FTRACE around to test it off, as there's still some archs that have
> FTRACE but not DYNAMIC_FTRACE.
> 
> Signed-off-by: Steven Rostedt (VMware) <[email protected]>
> ---
>  arch/x86/Kconfig            |  2 +-
>  arch/x86/kernel/ftrace_32.S | 88 
> +++++++++++++++++++++++++++++++++++++++------
>  2 files changed, 79 insertions(+), 11 deletions(-)
> 
> diff --git a/arch/x86/Kconfig b/arch/x86/Kconfig
> index cc98d5a294ee..8c17146427ca 100644
> --- a/arch/x86/Kconfig
> +++ b/arch/x86/Kconfig
> @@ -127,7 +127,7 @@ config X86
>       select HAVE_EBPF_JIT                    if X86_64
>       select HAVE_EFFICIENT_UNALIGNED_ACCESS
>       select HAVE_EXIT_THREAD
> -     select HAVE_FENTRY                      if X86_64
> +     select HAVE_FENTRY                      if X86_64 || DYNAMIC_FTRACE
>       select HAVE_FTRACE_MCOUNT_RECORD
>       select HAVE_FUNCTION_GRAPH_TRACER
>       select HAVE_FUNCTION_TRACER
> diff --git a/arch/x86/kernel/ftrace_32.S b/arch/x86/kernel/ftrace_32.S
> index 8ca33d9806ac..4bf8223555cd 100644
> --- a/arch/x86/kernel/ftrace_32.S
> +++ b/arch/x86/kernel/ftrace_32.S
> @@ -9,27 +9,75 @@
>  #include <asm/export.h>
>  #include <asm/ftrace.h>
>  
> +
> +#ifdef CC_USING_FENTRY
> +# define function_hook       __fentry__
> +EXPORT_SYMBOL(__fentry__)
> +#else
> +# define function_hook       mcount
> +EXPORT_SYMBOL(mcount)
> +#endif
> +
> +/* mcount uses a frame pointer even if CONFIG_FRAME_POINTER is not set */
> +#if !defined(CC_USING_FENTRY) || defined(CONFIG_FRAME_POINTER)
> +# define USING_FRAME_POINTER
> +#endif
> +
> +#ifdef USING_FRAME_POINTER
> +# ifdef CC_USING_FENTRY
> +#  define MCOUNT_FRAME_SIZE          (4*4)   /* bp,ip and parent's  */
> +# else
> +#  define MCOUNT_FRAME_SIZE          4       /* just the bp         */
> +# endif
> +# define MCOUNT_FRAME                        1       /* using frame = true  
> */
> +#else
> +# define MCOUNT_FRAME_SIZE           0       /* no stack frame      */
> +# define MCOUNT_FRAME                        0       /* using frame = false 
> */
> +#endif

It seems that there is no use of MCOUNT_FRAME_SIZE below. Do we really need it?

Thanks,

-- 
Masami Hiramatsu <[email protected]>

Reply via email to