From c8652a488b15367e371e7903763e5de9dd977db4 Mon Sep 17 00:00:00 2001 From: Ezequiel Garcia Date: Fri, 23 Nov 2012 10:44:37 -0300 Subject: [PATCH] Makefile: Add option to disable gcc automatic inlining The new option is CONFIG_CC_DISABLE_AUTO_INLINE and it's located at: * Kernel hacking * Disable gcc automatic inlining This option appends 'no-inline-small-functions' option to CFLAGS. It's important -if not necessary- to trace memory allocations with ftrace kmem events. Allocations are traced through _RET_IP_ macro, which in turn only works accurately if gcc don't inline. Without this patch you will trace callsites like kstrdup, instead of the real caller. Other related compiler options exist, but this one's enough to solve the problem. Moreover, some options have shown to break the compilation. Signed-off-by: Ezequiel Garcia --- Makefile | 4 ++++ kernel/trace/Kconfig | 4 ++++ 2 files changed, 8 insertions(+), 0 deletions(-) diff --git a/Makefile b/Makefile index a1ccf22..da52356 100644 --- a/Makefile +++ b/Makefile @@ -575,6 +575,10 @@ else KBUILD_CFLAGS += -O2 endif +ifdef CONFIG_CC_DISABLE_AUTO_INLINE +KBUILD_CFLAGS += -fno-inline-small-functions -fno-inline-functions-called-once +endif + include $(srctree)/arch/$(SRCARCH)/Makefile ifdef CONFIG_READABLE_ASM diff --git a/kernel/trace/Kconfig b/kernel/trace/Kconfig index 4cea4f4..5e87af0 100644 --- a/kernel/trace/Kconfig +++ b/kernel/trace/Kconfig @@ -138,6 +138,10 @@ config TRACING_SUPPORT depends on STACKTRACE_SUPPORT default y +config CC_DISABLE_AUTO_INLINE + bool "Disable gcc automatic inlining" + default n + if TRACING_SUPPORT menuconfig FTRACE -- 1.7.8.6