Skip to content

Commit 3b15cdc

Browse files
samitolvanenkees
authored andcommitted
tracing: move function tracer options to Kconfig
Move function tracer options to Kconfig to make it easier to add new methods for generating __mcount_loc, and to make the options available also when building kernel modules. Note that FTRACE_MCOUNT_USE_* options are updated on rebuild and therefore, work even if the .config was generated in a different environment. Signed-off-by: Sami Tolvanen <[email protected]> Acked-by: Steven Rostedt (VMware) <[email protected]> Signed-off-by: Kees Cook <[email protected]> Link: https://lore.kernel.org/r/[email protected]
1 parent e71ba94 commit 3b15cdc

File tree

3 files changed

+26
-16
lines changed

3 files changed

+26
-16
lines changed

Makefile

Lines changed: 8 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -851,19 +851,21 @@ KBUILD_CFLAGS += $(DEBUG_CFLAGS)
851851
export DEBUG_CFLAGS
852852

853853
ifdef CONFIG_FUNCTION_TRACER
854-
ifdef CONFIG_FTRACE_MCOUNT_RECORD
855-
# gcc 5 supports generating the mcount tables directly
856-
ifeq ($(call cc-option-yn,-mrecord-mcount),y)
857-
CC_FLAGS_FTRACE += -mrecord-mcount
858-
export CC_USING_RECORD_MCOUNT := 1
859-
endif
854+
ifdef CONFIG_FTRACE_MCOUNT_USE_CC
855+
CC_FLAGS_FTRACE += -mrecord-mcount
860856
ifdef CONFIG_HAVE_NOP_MCOUNT
861857
ifeq ($(call cc-option-yn, -mnop-mcount),y)
862858
CC_FLAGS_FTRACE += -mnop-mcount
863859
CC_FLAGS_USING += -DCC_USING_NOP_MCOUNT
864860
endif
865861
endif
866862
endif
863+
ifdef CONFIG_FTRACE_MCOUNT_USE_RECORDMCOUNT
864+
ifdef CONFIG_HAVE_C_RECORDMCOUNT
865+
BUILD_C_RECORDMCOUNT := y
866+
export BUILD_C_RECORDMCOUNT
867+
endif
868+
endif
867869
ifdef CONFIG_HAVE_FENTRY
868870
ifeq ($(call cc-option-yn, -mfentry),y)
869871
CC_FLAGS_FTRACE += -mfentry
@@ -873,12 +875,6 @@ endif
873875
export CC_FLAGS_FTRACE
874876
KBUILD_CFLAGS += $(CC_FLAGS_FTRACE) $(CC_FLAGS_USING)
875877
KBUILD_AFLAGS += $(CC_FLAGS_USING)
876-
ifdef CONFIG_DYNAMIC_FTRACE
877-
ifdef CONFIG_HAVE_C_RECORDMCOUNT
878-
BUILD_C_RECORDMCOUNT := y
879-
export BUILD_C_RECORDMCOUNT
880-
endif
881-
endif
882878
endif
883879

884880
# We trigger additional mismatches with less inlining

kernel/trace/Kconfig

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -602,6 +602,22 @@ config FTRACE_MCOUNT_RECORD
602602
depends on DYNAMIC_FTRACE
603603
depends on HAVE_FTRACE_MCOUNT_RECORD
604604

605+
config FTRACE_MCOUNT_USE_PATCHABLE_FUNCTION_ENTRY
606+
bool
607+
depends on FTRACE_MCOUNT_RECORD
608+
609+
config FTRACE_MCOUNT_USE_CC
610+
def_bool y
611+
depends on $(cc-option,-mrecord-mcount)
612+
depends on !FTRACE_MCOUNT_USE_PATCHABLE_FUNCTION_ENTRY
613+
depends on FTRACE_MCOUNT_RECORD
614+
615+
config FTRACE_MCOUNT_USE_RECORDMCOUNT
616+
def_bool y
617+
depends on !FTRACE_MCOUNT_USE_PATCHABLE_FUNCTION_ENTRY
618+
depends on !FTRACE_MCOUNT_USE_CC
619+
depends on FTRACE_MCOUNT_RECORD
620+
605621
config TRACING_MAP
606622
bool
607623
depends on ARCH_HAVE_NMI_SAFE_CMPXCHG

scripts/Makefile.build

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -178,8 +178,7 @@ cmd_modversions_c = \
178178
fi
179179
endif
180180

181-
ifdef CONFIG_FTRACE_MCOUNT_RECORD
182-
ifndef CC_USING_RECORD_MCOUNT
181+
ifdef CONFIG_FTRACE_MCOUNT_USE_RECORDMCOUNT
183182
# compiler will not generate __mcount_loc use recordmcount or recordmcount.pl
184183
ifdef BUILD_C_RECORDMCOUNT
185184
ifeq ("$(origin RECORDMCOUNT_WARN)", "command line")
@@ -206,8 +205,7 @@ recordmcount_source := $(srctree)/scripts/recordmcount.pl
206205
endif # BUILD_C_RECORDMCOUNT
207206
cmd_record_mcount = $(if $(findstring $(strip $(CC_FLAGS_FTRACE)),$(_c_flags)), \
208207
$(sub_cmd_record_mcount))
209-
endif # CC_USING_RECORD_MCOUNT
210-
endif # CONFIG_FTRACE_MCOUNT_RECORD
208+
endif # CONFIG_FTRACE_MCOUNT_USE_RECORDMCOUNT
211209

212210
ifdef CONFIG_STACK_VALIDATION
213211
ifneq ($(SKIP_STACK_VALIDATION),1)

0 commit comments

Comments
 (0)