Re: [PATCH] Use -mcount-record for dynamic ftrace

Steven Rostedt
2015-04-13T19:32:16Z

On Sun, 12 Apr 2015 17:54:27 -0700
Andi Kleen <andi@firstfloor.org> wrote:

> From: Andi Kleen <ak@linux.intel.com>
>
> gcc 5 supports a new -mcount-record option to generate ftrace
> tables directly. This avoids the need to run record_mcount
> manually.
>
> Use this option when available.
>
> It also has a -mcount-nop option to generate the mcount calls
> as nops. So far that is not implemented, but it could be used
> to optimize patching at boot up.

Interesting. But I can't accept this until I can test it. I don't have
the time to build gcc from scratch, and currently none of my boxes have
a gcc 5 install.

I wonder who's responsible for
https://www.kernel.org/pub/tools/crosstool/files/bin/x86_64/

If they can add a i386/x86_64 build for gcc5 I'll be happy to download
it and test this patch.

Thanks,

-- Steve

>
> Signed-off-by: Andi Kleen <ak@linux.intel.com>
> ---
> scripts/Makefile.build | 6 ++++++
> 1 file changed, 6 insertions(+)
>
> diff --git a/scripts/Makefile.build b/scripts/Makefile.build
> index 01df30a..f258e9b 100644
> --- a/scripts/Makefile.build
> +++ b/scripts/Makefile.build
> @@ -210,6 +210,11 @@ cmd_modversions = \
> fi;
> endif
>
> +# gcc 5 supports generating the mcount tables directly
> +ifneq ($(call cc-option,-mrecord-mcount,y),y)
> +KBUILD_CFLAGS += -mrecord-mcount
> +else
> +# else do it all manually
> ifdef CONFIG_FTRACE_MCOUNT_RECORD
> ifdef BUILD_C_RECORDMCOUNT
> ifeq ("$(origin RECORDMCOUNT_WARN)", "command line")
> @@ -240,6 +245,7 @@ cmd_record_mcount = \
> $(sub_cmd_record_mcount) \
> fi;
> endif
> +endif
>
> define rule_cc_o_c
> $(call echo-cmd,checksrc) $(cmd_checksrc) \