Skip to content

Commit 4567745

Browse files
lzufalconrostedt
authored andcommitted
ftrace: Speed up recordmcount
cmd_record_mcount is used to locate the _mcount symbols in the object files, only the files compiled with -pg has the _mcount symbol, so, it is only needed for such files, but the current cmd_record_mcount is used for all of the object files, so, we need to fix it and speed it up. Since -pg may be removed by the method used in kernel/trace/Makefile: ORIG_CFLAGS := $(KBUILD_CFLAGS) KBUILD_CFLAGS = $(subst -pg,,$(ORIG_CFLAGS)) Or may be removed by the method used in arch/x86/kernel/Makefile: CFLAGS_REMOVE_file.o = -pg So, we must check the last variable stores the compiling flags, that is c_flags(Please refer to cmd_cc_o_c and rule_cc_o_c defined in scripts/Makefile.build) and since the CFLAGS_REMOVE_file.o is already filtered in _c_flags(Please refer to scripts/Makefile.lib) and _c_flags has less symbols, therefore, we only need to check _c_flags. --------------- Changes from v1: o Don't touch Makefile for CONFIG_FTRACE_MCOUNT_RECORD is enough o Use _c_flags intead of KBUILD_CFLAGS to cover CONFIG_REMOVE_file.o = -pg (feedback from Steven Rostedt <[email protected]>) Acked-by: Michal Marek <[email protected]> Signed-off-by: Wu Zhangjin <[email protected]> LKML-Reference: <3dc8cddf022eb7024f9f2cf857529a15bee8999a.1288196498.git.wuzhangjin@gmail.com> [ changed if [ .. == .. ] to if [ .. = .. ] to handle dash environments ] Signed-off-by: Steven Rostedt <[email protected]>
1 parent ae51ce9 commit 4567745

File tree

1 file changed

+9
-4
lines changed

1 file changed

+9
-4
lines changed

scripts/Makefile.build

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -214,17 +214,22 @@ ifdef BUILD_C_RECORDMCOUNT
214214
# The empty.o file is created in the make process in order to determine
215215
# the target endianness and word size. It is made before all other C
216216
# files, including recordmcount.
217-
cmd_record_mcount = if [ $(@) != "scripts/mod/empty.o" ]; then \
218-
$(objtree)/scripts/recordmcount "$(@)"; \
219-
fi;
217+
sub_cmd_record_mcount = \
218+
if [ $(@) != "scripts/mod/empty.o" ]; then \
219+
$(objtree)/scripts/recordmcount "$(@)"; \
220+
fi;
220221
else
221-
cmd_record_mcount = set -e ; perl $(srctree)/scripts/recordmcount.pl "$(ARCH)" \
222+
sub_cmd_record_mcount = set -e ; perl $(srctree)/scripts/recordmcount.pl "$(ARCH)" \
222223
"$(if $(CONFIG_CPU_BIG_ENDIAN),big,little)" \
223224
"$(if $(CONFIG_64BIT),64,32)" \
224225
"$(OBJDUMP)" "$(OBJCOPY)" "$(CC) $(KBUILD_CFLAGS)" \
225226
"$(LD)" "$(NM)" "$(RM)" "$(MV)" \
226227
"$(if $(part-of-module),1,0)" "$(@)";
227228
endif
229+
cmd_record_mcount = \
230+
if [ "$(findstring -pg,$(_c_flags))" = "-pg" ]; then \
231+
$(sub_cmd_record_mcount) \
232+
fi;
228233
endif
229234

230235
define rule_cc_o_c

0 commit comments

Comments
 (0)