kbuild: create force-deps for fixdep for recordmcount
cover kbuild: create force-deps for fixdep for recordmcount
While doing a ktest patchcheck on several patches I've pulled, an update to recordmcount caused ftrace to fail. This is because ktest does a make mrproper for the first patch, but just uses the dependencies for the patches after that. But one of the patches modified both the way recordmcount worked, and what ftrace expected in the kernel. Since modification of recordmcount does not force updates to all object files, the expectation that ftrace had on the object files was incorrect and caused ftrace to fail.
This is an RFC to modify fixdep to allow addition of files that would be added as dependencies to all objects in the kernel.
Thoughts?
Steven Rostedt (2):
kbuild: Add force-deps to fixdep
ftrace/kbuild: Add recordmcount files to force full build
----
scripts/Kbuild.include | 3 ++- scripts/Makefile.build | 6 ++++-- scripts/basic/fixdep.c | 18 ++++++++++++++++-- 3 files changed, 22 insertions(+), 5 deletions(-)
RFC PATCH 1/2 kbuild: Add force-deps to fixdep
From: Steven Rostedt <[email protected]>
Allow some files to cause a full recompile of the kernel. There are some cases where all objects in the kernel may indirectly depend on a tool or script. A force-deps option has been added to fixdep to allow a list of files to be passed in to add them to the dependency of kernel files that are not found by gcc -MD option.
--- scripts/Kbuild.include | 3 ++- scripts/Makefile.build | 4 ++-- scripts/basic/fixdep.c | 18 ++++++++++++++++-- 3 files changed, 20 insertions(+), 5 deletions(-)
scripts/Kbuild.include +2 -1
@@ -210,7 +210,8 @@ if_changed = $(if $(strip $(any-prereq) $(arg-check)), \ if_changed_dep = $(if $(strip $(any-prereq) $(arg-check) ), \ @set -e; \ $(echo-cmd) $(cmd_$(1)); \ - scripts/basic/fixdep $(depfile) $@ '$(make-cmd)' > $(dot-target).tmp;\ + scripts/basic/fixdep $(depfile) $@ '$(make-cmd)' \ + "$(force-deps)" > $(dot-target).tmp; \ rm -f $(depfile); \ mv -f $(dot-target).tmp $(dot-target).cmd)
scripts/Makefile.build +2 -2
@@ -272,8 +272,8 @@ define rule_cc_o_c $(cmd_modversions) \ $(call echo-cmd,record_mcount) \ $(cmd_record_mcount) \ - scripts/basic/fixdep $(depfile) $@ '$(call make-cmd,cc_o_c)' > \ - $(dot-target).tmp; \ + scripts/basic/fixdep $(depfile) $@ '$(call make-cmd,cc_o_c)' \ + "$(force-deps)" > $(dot-target).tmp; \ rm -f $(depfile); \ mv -f $(dot-target).tmp $(dot-target).cmd endef
scripts/basic/fixdep.c +16 -2
@@ -62,7 +62,7 @@* * It is invoked as * -* fixdep <depfile> <target> <cmdline> +* fixdep <depfile> <target> <cmdline> [<force-deps>] * * and will read the dependency file <depfile> *
@@ -91,6 +91,9 @@* unrelated CONFIG_ options all over the place, it's not an * efficiency problem either. * +* An optional <force-deps> may also be added to include a list of +* files that are forced dependencies. +* * (Note: it'd be easy to port over the complete mkdep state machine, * but I don't think the added complexity is worth it) */
@@ -123,6 +126,7 @@char *target;char *depfile;char *cmdline; +char *forced;static void usage (void ) {
@@ -333,6 +337,7 @@ static void parse_dep_file(void *map, size_t len)clear_config (); first =1 ; + again:while (m < end) {while (m < end && (*m ==' ' || *m =='\\' || *m =='\n' )) m++;
@@ -362,6 +367,13 @@ static void parse_dep_file(void *map, size_t len) first =0 ; m = p +1 ; } +if (forced) { + m = forced; + end = m +strlen (m); + forced =NULL ; + goto again; + } +printf ("\n%s: $(deps_%s)\n\n" , target, target);printf ("$(deps_%s):\n" , target); }
@@ -418,12 +430,14 @@ int main(int argc, char *argv[]) {traps (); -if (argc !=4 ) +if (argc !=4 && argc !=5 )usage (); depfile = argv[1 ]; target = argv[2 ]; cmdline = argv[3 ]; +if (argc ==5 ) + forced = argv[4 ];print_cmdline ();print_deps ();
Signature · 1 line
1.7.2.3
RFC PATCH 2/2 ftrace/kbuild: Add recordmcount files to force full build
In reply to Steven RostedtFrom: Steven Rostedt <[email protected]>
Modifications to recordmcount must be performed on all object files to stay consistent with what the kernel code may expect. Add the recordmcount files to the force-deps to make sure any change to them causes a full recompile.
--- scripts/Makefile.build | 2 ++ 1 files changed, 2 insertions(+), 0 deletions(-)
scripts/Makefile.build +2 -0
@@ -252,6 +252,7 @@ sub_cmd_record_mcount = \ if [ $(@) != "scripts/mod/empty.o" ]; then \ $(objtree)/scripts/recordmcount "$(@)"; \ fi; +force-deps += $(srctree)/scripts/recordmcount.c $(srctree)/scripts/recordmcount.h else sub_cmd_record_mcount = set -e ; perl $(srctree)/scripts/recordmcount.pl "$(ARCH)" \ "$(if $(CONFIG_CPU_BIG_ENDIAN),big,little)" \
@@ -259,6 +260,7 @@ sub_cmd_record_mcount = set -e ; perl $(srctree)/scripts/recordmcount.pl "$(ARCH "$(OBJDUMP)" "$(OBJCOPY)" "$(CC) $(KBUILD_CFLAGS)" \ "$(LD)" "$(NM)" "$(RM)" "$(MV)" \ "$(if $(part-of-module),1,0)" "$(@)"; +force-deps += $(srctree)/scripts/recordmcount.pl endif cmd_record_mcount = \ if [ "$(findstring -pg,$(_c_flags))" = "-pg" ]; then \
Signature · 1 line
1.7.2.3
Re: [RFC][PATCH 2/2] ftrace/kbuild: Add recordmcount files to force full build
Quoted 25 lines · Steven Rostedt
From: Steven Rostedt <[email protected]>
Modifications to recordmcount must be performed on all object files to stay consistent with what the kernel code may expect. Add the recordmcount files to the force-deps to make sure any change to them causes a full recompile.
Signed-off-by Steven Rostedt <[email protected]>--- scripts/Makefile.build | 2 ++ 1 files changed, 2 insertions(+), 0 deletions(-)scripts/Makefile.build +1
-0@@ -252,6 +252,7 @@ sub_cmd_record_mcount = \ if [ $(@) != "scripts/mod/empty.o" ]; then \ $(objtree)/scripts/recordmcount "$(@)"; \ fi; +force-deps += $(srctree)/scripts/recordmcount.c $(srctree)/scripts/recordmcount.h else sub_cmd_record_mcount = set -e ; perl $(srctree)/scripts/recordmcount.pl "$(ARCH)" \ "$(if $(CONFIG_CPU_BIG_ENDIAN),big,little)" \
scripts/Makefile.build sub_cmd_record_mcount = set -e ; perl $(srctree)/scripts/recordmcount.pl "$(ARCH · line 266
Quoted 7 lines
scripts/Makefile.build +1
-0@@ -259,6 +260,7 @@ sub_cmd_record_mcount = set -e ; perl $(srctree)/scripts/recordmcount.pl "$(ARCH "$(OBJDUMP)" "$(OBJCOPY)" "$(CC) $(KBUILD_CFLAGS)" \ "$(LD)" "$(NM)" "$(RM)" "$(MV)" \ "$(if $(part-of-module),1,0)" "$(@)"; +force-deps += $(srctree)/scripts/recordmcount.pl endif cmd_record_mcount = \ if [ "$(findstring -pg,$(_c_flags))" = "-pg" ]; then \
We could add recordmcount.c as a dependency in scripts/Makefile.build directly, without playing with fixdep, like this (untested):
scripts/Makefile.build +4 -2
@@ -268,6 +268,7 @@ sub_cmd_record_mcount = \ if [ $(@) != "scripts/mod/empty.o" ]; then \ $(objtree)/scripts/recordmcount "$(@)"; \ fi; +recordmcount_source := $(srctree)/scripts/recordmcount.c else sub_cmd_record_mcount = set -e ; perl $(srctree)/scripts/recordmcount.pl "$(ARCH)" \ "$(if $(CONFIG_CPU_BIG_ENDIAN),big,little)" \
@@ -275,6 +276,7 @@ sub_cmd_record_mcount = set -e ; perl $(srctree)/scripts/recordmcount.pl "$(ARCH "$(OBJDUMP)" "$(OBJCOPY)" "$(CC) $(KBUILD_CFLAGS)" \ "$(LD)" "$(NM)" "$(RM)" "$(MV)" \ "$(if $(part-of-module),1,0)" "$(@)"; +recordmcount_source := $(srctree)/scripts/recordmcount.pl endif cmd_record_mcount = \ if [ "$(findstring -pg,$(_c_flags))" = "-pg" ]; then \
@@ -295,13 +297,13 @@ define rule_cc_o_c endef # Built-in and composite module parts -$(obj)/%.o: $(src)/%.c FORCE +$(obj)/%.o: $(src)/%.c $(recordmcount_source) FORCE $(call cmd,force_checksrc) $(call if_changed_rule,cc_o_c) # Single-part modules are special since we need to mark them in $(MODVERDIR) -$(single-used-m): $(obj)/%.o: $(src)/%.c FORCE +$(single-used-m): $(obj)/%.o: $(src)/%.c $(recordmcount_source) FORCE $(call cmd,force_checksrc) $(call if_changed_rule,cc_o_c) @{ echo $(@:.o=.ko); echo $@; } > $(MODVERDIR)/$(@F:.o=.mod)
Michal
Re: [RFC][PATCH 2/2] ftrace/kbuild: Add recordmcount files to force full build
Quoted 2 lines · Michal Marek
We could add
recordmcount.cas a dependency inscripts/Makefile.builddirectly, without playing with fixdep, like this (untested):
I actually tried this first, and it didn't seem to work. I'll go ahead and give it another try (maybe I did something wrong). But I do prefer this over my fixdep change.
Thanks, I'll let you know the outcome.
-- Steve
Quoted 39 lines
scripts/Makefile.build +4
-2@@ -268,6 +268,7 @@ sub_cmd_record_mcount = \ if [ $(@) != "scripts/mod/empty.o" ]; then \ $(objtree)/scripts/recordmcount "$(@)"; \ fi; +recordmcount_source := $(srctree)/scripts/recordmcount.c else sub_cmd_record_mcount = set -e ; perl $(srctree)/scripts/recordmcount.pl "$(ARCH)" \ "$(if $(CONFIG_CPU_BIG_ENDIAN),big,little)" \@@ -275,6 +276,7 @@ sub_cmd_record_mcount = set -e ; perl $(srctree)/scripts/recordmcount.pl "$(ARCH "$(OBJDUMP)" "$(OBJCOPY)" "$(CC) $(KBUILD_CFLAGS)" \ "$(LD)" "$(NM)" "$(RM)" "$(MV)" \ "$(if $(part-of-module),1,0)" "$(@)"; +recordmcount_source := $(srctree)/scripts/recordmcount.pl endif cmd_record_mcount = \ if [ "$(findstring -pg,$(_c_flags))" = "-pg" ]; then \@@ -295,13 +297,13 @@ define rule_cc_o_c endef # Built-in and composite module parts -$(obj)/%.o: $(src)/%.c FORCE +$(obj)/%.o: $(src)/%.c $(recordmcount_source) FORCE $(call cmd,force_checksrc) $(call if_changed_rule,cc_o_c) # Single-part modules are special since we need to mark them in $(MODVERDIR) -$(single-used-m): $(obj)/%.o: $(src)/%.c FORCE +$(single-used-m): $(obj)/%.o: $(src)/%.c $(recordmcount_source) FORCE $(call cmd,force_checksrc) $(call if_changed_rule,cc_o_c) @{ echo $(@:.o=.ko); echo $@; } > $(MODVERDIR)/$(@F:.o=.mod)Michal
Re: [RFC][PATCH 2/2] ftrace/kbuild: Add recordmcount files to force full build
Quoted 10 lines · Steven Rostedt
Quoted 2 lines · Michal Marek
We could add
recordmcount.cas a dependency inscripts/Makefile.builddirectly, without playing with fixdep, like this (untested):I actually tried this first, and it didn't seem to work. I'll go ahead and give it another try (maybe I did something wrong). But I do prefer this over my fixdep change.
Thanks, I'll let you know the outcome.
Awesome! This worked. I wonder what screw up I did to keep mine from working? Anyway, I made a single change to your patch:
-recordmcount_source := $(srctree)/scripts/recordmcount.c +recordmcount_source := $(srctree)/scripts/recordmcount.c \
+ $(srctree)/scripts/recordmcount.h
Could you send me your Signed-off-by, and I'll add this to the beginning of my patch queue.
Thanks!
-- Steve
Re: [RFC][PATCH 2/2] ftrace/kbuild: Add recordmcount files to force full build
Quoted 2 lines · Steven Rostedt
Awesome! This worked. I wonder what screw up I did to keep mine from working?
Bah! I forgot to add the $() around the variable that I used.
/me is embarrassed.
-- Steve
Re: [RFC][PATCH 2/2] ftrace/kbuild: Add recordmcount files to force full build
In reply to Steven RostedtQuoted 6 lines · Steven Rostedt
Quoted 5 lines · Steven Rostedt
Quoted 2 lines · Michal Marek
We could add
recordmcount.cas a dependency inscripts/Makefile.builddirectly, without playing with fixdep, like this (untested):
Quoted 7 lines
Quoted 5 lines
I actually tried this first, and it didn't seem to work. I'll go ahead and give it another try (maybe I did something wrong). But I do prefer this over my fixdep change.
Thanks, I'll let you know the outcome.
Awesome! This worked.
Great.
Quoted 10 lines
I wonder what screw up I did to keep mine from working? Anyway, I made a single change to your patch:
(quoted diff) +2
-1-recordmcount_source := $(srctree)/scripts/recordmcount.c +recordmcount_source := $(srctree)/scripts/recordmcount.c \ + $(srctree)/scripts/recordmcount.hCould you send me your Signed-off-by, and I'll add this to the beginning of my patch queue.
Michal
[tip:perf/core] ftrace/kbuild: Add recordmcount files to force full build
In reply to Michal MarekCommit-ID: d6971822c288ce5547190c6f812cc978d6520777 Gitweb: http://git.kernel.org/tip/d6971822c288ce5547190c6f812cc978d6520777 Author: Michal Marek <[email protected]> AuthorDate: Tue, 17 May 2011 15:36:46 +0200 Committer: Steven Rostedt <[email protected]> CommitDate: Thu, 19 May 2011 07:58:28 -0400
ftrace/kbuild: Add recordmcount files to force full build
Modifications to recordmcount must be performed on all object files to stay consistent with what the kernel code may expect. Add the recordmcount files to the main dependencies to make sure any change to them causes a full recompile.
--- scripts/Makefile.build | 7 +++++-- 1 files changed, 5 insertions(+), 2 deletions(-)
scripts/Makefile.build +5 -2
@@ -255,6 +255,8 @@ sub_cmd_record_mcount = \ if [ $(@) != "scripts/mod/empty.o" ]; then \ $(objtree)/scripts/recordmcount $(RECORDMCOUNT_FLAGS) "$(@)"; \ fi; +recordmcount_source := $(srctree)/scripts/recordmcount.c \ + $(srctree)/scripts/recordmcount.h else sub_cmd_record_mcount = set -e ; perl $(srctree)/scripts/recordmcount.pl "$(ARCH)" \ "$(if $(CONFIG_CPU_BIG_ENDIAN),big,little)" \
@@ -262,6 +264,7 @@ sub_cmd_record_mcount = set -e ; perl $(srctree)/scripts/recordmcount.pl "$(ARCH "$(OBJDUMP)" "$(OBJCOPY)" "$(CC) $(KBUILD_CFLAGS)" \ "$(LD)" "$(NM)" "$(RM)" "$(MV)" \ "$(if $(part-of-module),1,0)" "$(@)"; +recordmcount_source := $(srctree)/scripts/recordmcount.pl endif cmd_record_mcount = \ if [ "$(findstring -pg,$(_c_flags))" = "-pg" ]; then \
@@ -282,13 +285,13 @@ define rule_cc_o_c endef # Built-in and composite module parts -$(obj)/%.o: $(src)/%.c FORCE +$(obj)/%.o: $(src)/%.c $(recordmcount_source) FORCE $(call cmd,force_checksrc) $(call if_changed_rule,cc_o_c) # Single-part modules are special since we need to mark them in $(MODVERDIR) -$(single-used-m): $(obj)/%.o: $(src)/%.c FORCE +$(single-used-m): $(obj)/%.o: $(src)/%.c $(recordmcount_source) FORCE $(call cmd,force_checksrc) $(call if_changed_rule,cc_o_c) @{ echo $(@:.o=.ko); echo $@; } > $(MODVERDIR)/$(@F:.o=.mod)
[tip:perf/core] ftrace/kbuild: Add recordmcount files to force full build
In reply to Michal MarekCommit-ID: 44e6a2069122dbec29d25b8ced3f59f5626a97d7 Gitweb: http://git.kernel.org/tip/44e6a2069122dbec29d25b8ced3f59f5626a97d7 Author: Michal Marek <[email protected]> AuthorDate: Tue, 17 May 2011 15:36:46 +0200 Committer: Steven Rostedt <[email protected]> CommitDate: Tue, 17 May 2011 10:41:08 -0400
ftrace/kbuild: Add recordmcount files to force full build
Modifications to recordmcount must be performed on all object files to stay consistent with what the kernel code may expect. Add the recordmcount files to the main dependencies to make sure any change to them causes a full recompile.
--- scripts/Makefile.build | 7 +++++-- 1 files changed, 5 insertions(+), 2 deletions(-)
scripts/Makefile.build +5 -2
@@ -252,6 +252,8 @@ sub_cmd_record_mcount = \ if [ $(@) != "scripts/mod/empty.o" ]; then \ $(objtree)/scripts/recordmcount "$(@)"; \ fi; +recordmcount_source := $(srctree)/scripts/recordmcount.c \ + $(srctree)/scripts/recordmcount.h else sub_cmd_record_mcount = set -e ; perl $(srctree)/scripts/recordmcount.pl "$(ARCH)" \ "$(if $(CONFIG_CPU_BIG_ENDIAN),big,little)" \
@@ -259,6 +261,7 @@ sub_cmd_record_mcount = set -e ; perl $(srctree)/scripts/recordmcount.pl "$(ARCH "$(OBJDUMP)" "$(OBJCOPY)" "$(CC) $(KBUILD_CFLAGS)" \ "$(LD)" "$(NM)" "$(RM)" "$(MV)" \ "$(if $(part-of-module),1,0)" "$(@)"; +recordmcount_source := $(srctree)/scripts/recordmcount.pl endif cmd_record_mcount = \ if [ "$(findstring -pg,$(_c_flags))" = "-pg" ]; then \
@@ -279,13 +282,13 @@ define rule_cc_o_c endef # Built-in and composite module parts -$(obj)/%.o: $(src)/%.c FORCE +$(obj)/%.o: $(src)/%.c $(recordmcount_source) FORCE $(call cmd,force_checksrc) $(call if_changed_rule,cc_o_c) # Single-part modules are special since we need to mark them in $(MODVERDIR) -$(single-used-m): $(obj)/%.o: $(src)/%.c FORCE +$(single-used-m): $(obj)/%.o: $(src)/%.c $(recordmcount_source) FORCE $(call cmd,force_checksrc) $(call if_changed_rule,cc_o_c) @{ echo $(@:.o=.ko); echo $@; } > $(MODVERDIR)/$(@F:.o=.mod)