Message ID | 1525268700-10631-4-git-send-email-changbin.du@intel.com (mailing list archive) |
---|---|
State | New, archived |
Headers | show |
On Wed, 2 May 2018 21:44:58 +0800 changbin.du@intel.com wrote: > From: Changbin Du <changbin.du@intel.com> > > This patch add a new kernel hacking option NO_AUTO_INLINE. Selecting > this option will prevent the compiler from optimizing the kernel by > auto-inlining functions not marked with the inline keyword. > > With this option, only functions explicitly marked with "inline" will > be inlined. This will allow the function tracer to trace more functions > because it only traces functions that the compiler has not inlined. > > Signed-off-by: Changbin Du <changbin.du@intel.com> > Cc: Steven Rostedt <rostedt@goodmis.org> I'm fine with this patch if others are OK with it too. Acked-by: Steven Rostedt (VMware) <rostedt@goodmis.org> -- Steve > > --- > v2: Some grammar updates from Steven. > --- > Makefile | 6 ++++++ > lib/Kconfig.debug | 18 ++++++++++++++++++ > 2 files changed, 24 insertions(+) > > diff --git a/Makefile b/Makefile > index 619a85a..eb694f6 100644 > --- a/Makefile > +++ b/Makefile > @@ -775,6 +775,12 @@ KBUILD_CFLAGS += $(call cc-option, -femit-struct-debug-baseonly) \ > $(call cc-option,-fno-var-tracking) > endif > > +ifdef CONFIG_NO_AUTO_INLINE > +KBUILD_CFLAGS += $(call cc-option, -fno-inline-functions) \ > + $(call cc-option, -fno-inline-small-functions) \ > + $(call cc-option, -fno-inline-functions-called-once) > +endif > + > ifdef CONFIG_FUNCTION_TRACER > ifndef CC_FLAGS_FTRACE > CC_FLAGS_FTRACE := -pg > diff --git a/lib/Kconfig.debug b/lib/Kconfig.debug > index c40c7b7..ab55801 100644 > --- a/lib/Kconfig.debug > +++ b/lib/Kconfig.debug > @@ -198,6 +198,24 @@ config GDB_SCRIPTS > instance. See Documentation/dev-tools/gdb-kernel-debugging.rst > for further details. > > +config NO_AUTO_INLINE > + bool "Disable compiler auto-inline optimizations" > + default n > + help > + This will prevent the compiler from optimizing the kernel by > + auto-inlining functions not marked with the inline keyword. > + With this option, only functions explicitly marked with > + "inline" will be inlined. This will allow the function tracer > + to trace more functions because it only traces functions that > + the compiler has not inlined. > + > + Enabling this function can help debugging a kernel if using > + the function tracer. But it can also change how the kernel > + works, because inlining functions may change the timing, > + which could make it difficult while debugging race conditions. > + > + If unsure, select N. > + > config ENABLE_WARN_DEPRECATED > bool "Enable __deprecated logic" > default y -- To unsubscribe from this list: send the line "unsubscribe linux-kbuild" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
On Wed, May 2, 2018 at 9:44 AM, <changbin.du@intel.com> wrote: > From: Changbin Du <changbin.du@intel.com> > > This patch add a new kernel hacking option NO_AUTO_INLINE. Selecting > this option will prevent the compiler from optimizing the kernel by > auto-inlining functions not marked with the inline keyword. > > With this option, only functions explicitly marked with "inline" will > be inlined. This will allow the function tracer to trace more functions > because it only traces functions that the compiler has not inlined. > > Signed-off-by: Changbin Du <changbin.du@intel.com> > Cc: Steven Rostedt <rostedt@goodmis.org> Should this be closer to CONFIG_OPTIMIZE_INLINING or possibly mutually exclusive with it? Arnd -- To unsubscribe from this list: send the line "unsubscribe linux-kbuild" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
On Wed, May 02, 2018 at 04:27:47PM -0400, Arnd Bergmann wrote: > On Wed, May 2, 2018 at 9:44 AM, <changbin.du@intel.com> wrote: > > From: Changbin Du <changbin.du@intel.com> > > > > This patch add a new kernel hacking option NO_AUTO_INLINE. Selecting > > this option will prevent the compiler from optimizing the kernel by > > auto-inlining functions not marked with the inline keyword. > > > > With this option, only functions explicitly marked with "inline" will > > be inlined. This will allow the function tracer to trace more functions > > because it only traces functions that the compiler has not inlined. > > > > Signed-off-by: Changbin Du <changbin.du@intel.com> > > Cc: Steven Rostedt <rostedt@goodmis.org> > > Should this be closer to CONFIG_OPTIMIZE_INLINING or > possibly mutually exclusive with it? > They are not related I think. CONFIG_OPTIMIZE_INLINING only has effect on functions which are explicitly marked as inline. > Arnd
On Thu, 3 May 2018 21:00:13 +0800 "Du, Changbin" <changbin.du@intel.com> wrote: > On Wed, May 02, 2018 at 04:27:47PM -0400, Arnd Bergmann wrote: > > On Wed, May 2, 2018 at 9:44 AM, <changbin.du@intel.com> wrote: > > > From: Changbin Du <changbin.du@intel.com> > > > > > > This patch add a new kernel hacking option NO_AUTO_INLINE. Selecting > > > this option will prevent the compiler from optimizing the kernel by > > > auto-inlining functions not marked with the inline keyword. > > > > > > With this option, only functions explicitly marked with "inline" will > > > be inlined. This will allow the function tracer to trace more functions > > > because it only traces functions that the compiler has not inlined. > > > > > > Signed-off-by: Changbin Du <changbin.du@intel.com> > > > Cc: Steven Rostedt <rostedt@goodmis.org> > > > > Should this be closer to CONFIG_OPTIMIZE_INLINING or > > possibly mutually exclusive with it? > > > They are not related I think. CONFIG_OPTIMIZE_INLINING only has effect on > functions which are explicitly marked as inline. > Agreed, as OPTIMIZE_INLINING is to make functions marked inline not to be inlined. And I just noticed (doing a git grep), that that config is now only available in arch/x86. Maybe it always was, but sparc undefines it for vclock_gettime.c. $ git grep OPTIMIZE_INLIN arch/sparc/vdso/vdso32/vclock_gettime.c:#undef CONFIG_OPTIMIZE_INLINING arch/x86/Kconfig.debug:config OPTIMIZE_INLINING arch/x86/configs/i386_defconfig:CONFIG_OPTIMIZE_INLINING=y arch/x86/configs/x86_64_defconfig:CONFIG_OPTIMIZE_INLINING=y arch/x86/entry/vdso/vdso32/vclock_gettime.c:#undef CONFIG_OPTIMIZE_INLINING include/linux/compiler-gcc.h: !defined(CONFIG_OPTIMIZE_INLINING) || (__GNUC__ < 4) kernel/configs/tiny.config:CONFIG_OPTIMIZE_INLINING=y -- Steve -- To unsubscribe from this list: send the line "unsubscribe linux-kbuild" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
diff --git a/Makefile b/Makefile index 619a85a..eb694f6 100644 --- a/Makefile +++ b/Makefile @@ -775,6 +775,12 @@ KBUILD_CFLAGS += $(call cc-option, -femit-struct-debug-baseonly) \ $(call cc-option,-fno-var-tracking) endif +ifdef CONFIG_NO_AUTO_INLINE +KBUILD_CFLAGS += $(call cc-option, -fno-inline-functions) \ + $(call cc-option, -fno-inline-small-functions) \ + $(call cc-option, -fno-inline-functions-called-once) +endif + ifdef CONFIG_FUNCTION_TRACER ifndef CC_FLAGS_FTRACE CC_FLAGS_FTRACE := -pg diff --git a/lib/Kconfig.debug b/lib/Kconfig.debug index c40c7b7..ab55801 100644 --- a/lib/Kconfig.debug +++ b/lib/Kconfig.debug @@ -198,6 +198,24 @@ config GDB_SCRIPTS instance. See Documentation/dev-tools/gdb-kernel-debugging.rst for further details. +config NO_AUTO_INLINE + bool "Disable compiler auto-inline optimizations" + default n + help + This will prevent the compiler from optimizing the kernel by + auto-inlining functions not marked with the inline keyword. + With this option, only functions explicitly marked with + "inline" will be inlined. This will allow the function tracer + to trace more functions because it only traces functions that + the compiler has not inlined. + + Enabling this function can help debugging a kernel if using + the function tracer. But it can also change how the kernel + works, because inlining functions may change the timing, + which could make it difficult while debugging race conditions. + + If unsure, select N. + config ENABLE_WARN_DEPRECATED bool "Enable __deprecated logic" default y