Skip to contentSkip to conversation

ftrace: Remove recursion between recordmcount and scripts/mod/empty

GIT PULL In review Steven Rostedt 2 participants 4 messages Oct 18, 2010 Kbuild

lore
Share & tools
lore
#0 lore raw

Ingo,

Please pull the latest tip/perf/recordmcount tree, which can be found at:

git://git.kernel.org/pub/scm/linux/kernel/git/rostedt/linux-2.6-trace.git
tip/perf/recordmcount

Steven Rostedt (1):
ftrace: Remove recursion between recordmcount and scripts/mod/empty

----

 scripts/Makefile.build |    6 +++++-
 1 files changed, 5 insertions(+), 1 deletions(-)
---------------------------
commit 0ae78b8f70eccd69febf70c688d15ae1253303e0
Author: Steven Rostedt <[email protected]>
Date:   Mon Oct 18 14:42:00 2010 -0400

ftrace: Remove recursion between recordmcount and scripts/mod/empty

When DYNAMIC_FTRACE is enabled and we use the C version of recordmcount, all objects are run through the recordmcount program to create a separate section that stores all the callers of mcount.

The build process has a special file: scripts/mod/empty.o. This is built from empty.c which is literally an empty file (except for a single comment). This file is used to find information about the target elf format, like endianness and word size.

The problem comes up when we need to build recordmcount. The build process requires that empty.o is built first. The build rules for empty.o will try to execute recordmcount on the empty.o file. We get an error that recordmcount does not exist.

To avoid this recursion, the build file will skip running recordmcount if the file that it is building is script/mod/empty.o.

Perhaps a new rule is needed, or we may open-code empty.o build.

scripts/Makefile.build +5 -1
index 4db60b2..9f2d5b4 100644
@@ -210,7 +210,11 @@ endif
 
 ifdef CONFIG_FTRACE_MCOUNT_RECORD
 ifdef BUILD_C_RECORDMCOUNT
-cmd_record_mcount = $(objtree)/scripts/recordmcount "$(@)";
+# Due to recursion, we must skip the empty.o file
+#  TBD: Find a better way to do this.
+cmd_record_mcount = if [ $(@) != "scripts/mod/empty.o" ]; then			\
+			$(objtree)/scripts/recordmcount "$(@)";			\
+		    fi;
 else
 cmd_record_mcount = set -e ; perl $(srctree)/scripts/recordmcount.pl "$(ARCH)" \
 	"$(if $(CONFIG_CPU_BIG_ENDIAN),big,little)" \
#1 lore raw

RFC 1/1 better fix? (was: Re: [PATCH][GIT PULL] ftrace: Remove recursion between recordmcount and scripts/mod/empty)

On Mon, 2010-10-18 at 14:53 -0400, Steven Rostedt wrote:

Just calling attention to this...

Quoted 8 lines
scripts/Makefile.build +0 -0
index 4db60b2..9f2d5b4 100644
@@ -210,7 +210,11 @@ endif
 
 ifdef CONFIG_FTRACE_MCOUNT_RECORD

scripts/Makefile.build endif · line 220

Quoted 10 lines
scripts/Makefile.build +5 -1
 ifdef BUILD_C_RECORDMCOUNT
-cmd_record_mcount = $(objtree)/scripts/recordmcount "$(@)";
+# Due to recursion, we must skip the empty.o file
+#  TBD: Find a better way to do this.
+cmd_record_mcount = if [ $(@) != "scripts/mod/empty.o" ]; then			\
+			$(objtree)/scripts/recordmcount "$(@)";			\
+		    fi;
 else
 cmd_record_mcount = set -e ; perl $(srctree)/scripts/recordmcount.pl "$(ARCH)" \
 	"$(if $(CONFIG_CPU_BIG_ENDIAN),big,little)" \

This is pretty much a hack, would adding a patch like the following be a better idea?

-- Steve

scripts/Makefile.build +16 -5
index 9f2d5b4..86e360a 100644
@@ -210,11 +210,7 @@ endif
 
 ifdef CONFIG_FTRACE_MCOUNT_RECORD
 ifdef BUILD_C_RECORDMCOUNT
-# Due to recursion, we must skip the empty.o file
-#  TBD: Find a better way to do this.
-cmd_record_mcount = if [ $(@) != "scripts/mod/empty.o" ]; then			\
-			$(objtree)/scripts/recordmcount "$(@)";			\
-		    fi;
+cmd_record_mcount = $(objtree)/scripts/recordmcount "$(@)";
 else
 cmd_record_mcount = set -e ; perl $(srctree)/scripts/recordmcount.pl "$(ARCH)" \
 	"$(if $(CONFIG_CPU_BIG_ENDIAN),big,little)" \
@@ -236,11 +232,26 @@ define rule_cc_o_c
 	mv -f $(dot-target).tmp $(dot-target).cmd
 endef
 
+define rule_cc_o_c_notrace
+	$(call echo-cmd,checksrc) $(cmd_checksrc)			  \
+	$(call echo-cmd,cc_o_c) $(cmd_cc_o_c);				  \
+	$(cmd_modversions)						  \
+	scripts/basic/fixdep $(depfile) $@ '$(call make-cmd,cc_o_c)' >    \
+	                                              $(dot-target).tmp;  \
+	rm -f $(depfile);						  \
+	mv -f $(dot-target).tmp $(dot-target).cmd
+endef
+
 # Built-in and composite module parts
 $(obj)/%.o: $(src)/%.c FORCE
 	$(call cmd,force_checksrc)
 	$(call if_changed_rule,cc_o_c)
 
+# Due to recursion, recordmcount must not be called on empty.o
+$(objtree)/scripts/mod/empty.o: $(srctree)/scripts/mod/empty.c
+	$(call cmd,force_checksrc)
+	$(call if_changed_rule,cc_o_c_notrace)
+
 # Single-part modules are special since we need to mark them in $(MODVERDIR)
 
 $(single-used-m): $(obj)/%.o: $(src)/%.c FORCE
#2 lore raw

Re: [RFC] better fix? (was: Re: [PATCH][GIT PULL] ftrace: Remove recursion between recordmcount and scripts/mod/empty)

Quoted 10 lines · Steven Rostedt

On Mon, 2010-10-18 at 14:53 -0400, Steven Rostedt wrote:

Just calling attention to this...

Quoted 6 lines
scripts/Makefile.build +0 -0
index 4db60b2..9f2d5b4 100644
@@ -210,7 +210,11 @@ endif
 
Quoted 15 lines

scripts/Makefile.build endif · line 220

Quoted 12 lines
scripts/Makefile.build +5 -1
 ifdef CONFIG_FTRACE_MCOUNT_RECORD
 ifdef BUILD_C_RECORDMCOUNT
-cmd_record_mcount = $(objtree)/scripts/recordmcount "$(@)";
+# Due to recursion, we must skip the empty.o file
+#  TBD: Find a better way to do this.
+cmd_record_mcount = if [ $(@) != "scripts/mod/empty.o" ]; then			\
+			$(objtree)/scripts/recordmcount "$(@)";			\
+		    fi;
 else
 cmd_record_mcount = set -e ; perl $(srctree)/scripts/recordmcount.pl "$(ARCH)" \
 	"$(if $(CONFIG_CPU_BIG_ENDIAN),big,little)" \

This is pretty much a hack, would adding a patch like the following be a better idea?

I prefer the hack above...
It is obvious what it does. And the hack is simple.

An additional comment about the origin of empty.o is needed. Only very few people knows that we generate empty.o in scripts/

Sam

#3 lore raw

Re: [RFC] better fix? (was: Re: [PATCH][GIT PULL] ftrace: Remove recursion between recordmcount and scripts/mod/empty)

Quoted 2 lines · Sam Ravnborg

An additional comment about the origin of empty.o is needed. Only very few people knows that we generate empty.o in scripts/

OK, how are you with this comment?

# Due to recursion, we must skip the empty.o file.
# 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.

-- Steve