diff mbox series

[2/4] trace: avoid calling cc-option -mrecord-mcount for every Makefile

Message ID patch-2.thread-aa7b8d.git-de935bace15a.your-ad-here.call-01533557518-ext-9465@work.hours (mailing list archive)
State New, archived
Headers show
Series ftrace build improvements | expand

Commit Message

Vasily Gorbik Aug. 6, 2018, 1:17 p.m. UTC
Currently if CONFIG_FTRACE_MCOUNT_RECORD is enabled -mrecord-mcount
compiler flag support is tested for every Makefile.

Top 4 cc-option usages:
    511 -mrecord-mcount
     11  -fno-stack-protector
      9 -Wno-override-init
      2 -fsched-pressure

To address that move cc-option from scripts/Makefile.build to top Makefile
and export CC_USING_RECORD_MCOUNT to be used in original place.

While doing that also add -mrecord-mcount to CC_FLAGS_FTRACE (if gcc
actually supports it).

Signed-off-by: Vasily Gorbik <gor@linux.ibm.com>
---
 Makefile               | 7 +++++++
 scripts/Makefile.build | 9 +++------
 2 files changed, 10 insertions(+), 6 deletions(-)

Comments

Andi Kleen Aug. 6, 2018, 6:07 p.m. UTC | #1
On Mon, Aug 06, 2018 at 03:17:44PM +0200, Vasily Gorbik wrote:
> Currently if CONFIG_FTRACE_MCOUNT_RECORD is enabled -mrecord-mcount
> compiler flag support is tested for every Makefile.

Good catch.  Does it make a measurable compile time difference?

> 
> Top 4 cc-option usages:
>     511 -mrecord-mcount
>      11  -fno-stack-protector
>       9 -Wno-override-init
>       2 -fsched-pressure
> 
> To address that move cc-option from scripts/Makefile.build to top Makefile
> and export CC_USING_RECORD_MCOUNT to be used in original place.
> 
> While doing that also add -mrecord-mcount to CC_FLAGS_FTRACE (if gcc
> actually supports it).
> 
> Signed-off-by: Vasily Gorbik <gor@linux.ibm.com>

Acked-by: Andi Kleen <ak@linux.intel.com>

-Andi
--
To unsubscribe from this list: send the line "unsubscribe linux-kbuild" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Vasily Gorbik Aug. 7, 2018, 11:59 a.m. UTC | #2
On Mon, Aug 06, 2018 at 11:07:40AM -0700, Andi Kleen wrote:
> On Mon, Aug 06, 2018 at 03:17:44PM +0200, Vasily Gorbik wrote:
> > Currently if CONFIG_FTRACE_MCOUNT_RECORD is enabled -mrecord-mcount
> > compiler flag support is tested for every Makefile.
> 
> Good catch.  Does it make a measurable compile time difference?
> 

A bit more than couple of seconds, but it does make a difference for a
delta build:
with patch:
real    0m9.405s
user    0m6.966s
sys     0m2.287s

without:
real    0m12.153s
user    0m9.058s
sys     0m3.026s

with -j48 on s390 24 cores lpar:
with patch:
real    0m1.949s
user    0m7.034s
sys     0m2.400s

without:
real    0m2.255s
user    0m9.243s
sys     0m3.266s

> > 
> > Top 4 cc-option usages:
> >     511 -mrecord-mcount

--
To unsubscribe from this list: send the line "unsubscribe linux-kbuild" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
diff mbox series

Patch

diff --git a/Makefile b/Makefile
index 503f533277c7..621ebdbfbf89 100644
--- a/Makefile
+++ b/Makefile
@@ -743,6 +743,13 @@  ifdef CONFIG_FUNCTION_TRACER
 ifndef CC_FLAGS_FTRACE
 CC_FLAGS_FTRACE := -pg
 endif
+ifdef CONFIG_FTRACE_MCOUNT_RECORD
+  # gcc 5 supports generating the mcount tables directly
+  ifeq ($(call cc-option-yn,-mrecord-mcount),y)
+    CC_FLAGS_FTRACE	+= -mrecord-mcount
+    export CC_USING_RECORD_MCOUNT := 1
+  endif
+endif
 ifdef CONFIG_HAVE_FENTRY
   ifeq ($(call cc-option-yn, -mfentry),y)
     CC_FLAGS_FTRACE	+= -mfentry
diff --git a/scripts/Makefile.build b/scripts/Makefile.build
index 514ed63ff571..42ecb8cf7666 100644
--- a/scripts/Makefile.build
+++ b/scripts/Makefile.build
@@ -206,11 +206,8 @@  cmd_modversions_c =								\
 endif
 
 ifdef CONFIG_FTRACE_MCOUNT_RECORD
-# 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
+ifndef CC_USING_RECORD_MCOUNT
+# compiler will not generate __mcount_loc use recordmcount or recordmcount.pl
 ifdef BUILD_C_RECORDMCOUNT
 ifeq ("$(origin RECORDMCOUNT_WARN)", "command line")
   RECORDMCOUNT_FLAGS = -w
@@ -239,7 +236,7 @@  cmd_record_mcount =						\
 	     "$(CC_FLAGS_FTRACE)" ]; then			\
 		$(sub_cmd_record_mcount)			\
 	fi;
-endif # -record-mcount
+endif # CC_USING_RECORD_MCOUNT
 endif # CONFIG_FTRACE_MCOUNT_RECORD
 
 ifdef CONFIG_STACK_VALIDATION