[PATCH] ftrace: Speed up recordmcount

From: Wu Zhangjin
Date: Wed Oct 27 2010 - 06:40:21 EST


From: Wu Zhangjin <wuzhangjin@xxxxxxxxx>

cmd_record_mcount is only needed for the targets who are compiled with
-pg, so, only define it when CONFIG_FTRACE_MCOUNT_RECORD is defined and
only use it for the targets who are compiled with -pg.

Signed-off-by: Wu Zhangjin <wuzhangjin@xxxxxxxxx>
---
Makefile | 11 ++++++++---
scripts/Makefile.build | 26 ++++++++++++++++----------
2 files changed, 24 insertions(+), 13 deletions(-)

diff --git a/Makefile b/Makefile
index 3e43805..60d7a87 100644
--- a/Makefile
+++ b/Makefile
@@ -576,9 +576,14 @@ endif
ifdef CONFIG_FUNCTION_TRACER
KBUILD_CFLAGS += -pg
ifdef CONFIG_DYNAMIC_FTRACE
- ifdef CONFIG_HAVE_C_RECORDMCOUNT
- BUILD_C_RECORDMCOUNT := y
- export BUILD_C_RECORDMCOUNT
+ ifdef CONFIG_FTRACE_MCOUNT_RECORD
+ DEFINE_CMD_RECORD_MCOUNT := y
+ export DEFINE_CMD_RECORD_MCOUNT
+
+ ifdef CONFIG_HAVE_C_RECORDMCOUNT
+ BUILD_C_RECORDMCOUNT := y
+ export BUILD_C_RECORDMCOUNT
+ endif
endif
endif
endif
diff --git a/scripts/Makefile.build b/scripts/Makefile.build
index 5ad25e1..ceb5175 100644
--- a/scripts/Makefile.build
+++ b/scripts/Makefile.build
@@ -208,22 +208,28 @@ cmd_modversions = \
fi;
endif

-ifdef CONFIG_FTRACE_MCOUNT_RECORD
+ifdef DEFINE_CMD_RECORD_MCOUNT
ifdef BUILD_C_RECORDMCOUNT
# Due to recursion, we must skip empty.o.
# The empty.o file is created in the make process in order to determine
# the target endianness and word size. It is made before all other C
# files, including recordmcount.
-cmd_record_mcount = if [ $(@) != "scripts/mod/empty.o" ]; then \
- $(objtree)/scripts/recordmcount "$(@)"; \
- fi;
+cmd_record_mcount = \
+ if [ "$(findstring -pg,$(KBUILD_CFLAGS))" == "-pg" ]; then \
+ if [ $(@) != "scripts/mod/empty.o" ]; then \
+ $(objtree)/scripts/recordmcount "$(@)"; \
+ fi; \
+ fi;
else
-cmd_record_mcount = set -e ; perl $(srctree)/scripts/recordmcount.pl "$(ARCH)" \
- "$(if $(CONFIG_CPU_BIG_ENDIAN),big,little)" \
- "$(if $(CONFIG_64BIT),64,32)" \
- "$(OBJDUMP)" "$(OBJCOPY)" "$(CC) $(KBUILD_CFLAGS)" \
- "$(LD)" "$(NM)" "$(RM)" "$(MV)" \
- "$(if $(part-of-module),1,0)" "$(@)";
+cmd_record_mcount = \
+ if [ "$(findstring -pg,$(KBUILD_CFLAGS))" == "-pg" ]; then \
+ set -e ; perl $(srctree)/scripts/recordmcount.pl "$(ARCH)" \
+ "$(if $(CONFIG_CPU_BIG_ENDIAN),big,little)" \
+ "$(if $(CONFIG_64BIT),64,32)" \
+ "$(OBJDUMP)" "$(OBJCOPY)" "$(CC) $(KBUILD_CFLAGS)" \
+ "$(LD)" "$(NM)" "$(RM)" "$(MV)" \
+ "$(if $(part-of-module),1,0)" "$(@)"; \
+ fi;
endif
endif

--
1.7.1

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/