Skip to contentSkip to conversation

Use -mcount-record for dynamic ftrace

PATCH New Andi Kleen 1 participant 1 message Nov 2, 2016 Kbuild

lore
Share & tools
lore

Andi Kleen

author
#0 lore raw

PATCH 1/1 Use -mcount-record for dynamic ftrace

From: Andi Kleen <[email protected]>

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.

---
 scripts/Makefile.build | 6 ++++++
 1 file changed, 6 insertions(+)
scripts/Makefile.build +6 -0
index de46ab03f063..2d7467076411 100644
@@ -212,6 +212,11 @@ cmd_modversions =								\
 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
 ifdef BUILD_C_RECORDMCOUNT
 ifeq ("$(origin RECORDMCOUNT_WARN)", "command line")
   RECORDMCOUNT_FLAGS = -w
@@ -241,6 +246,7 @@ cmd_record_mcount =						\
 		$(sub_cmd_record_mcount)			\
 	fi;
 endif
+endif
 
 ifdef CONFIG_STACK_VALIDATION
 ifneq ($(SKIP_STACK_VALIDATION),1)
Signature · 1 line
2.5.5