All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v2] Makefile: Add option to disable gcc automatic inlining
@ 2012-10-07 19:18 Ezequiel Garcia
  2012-10-07 22:21 ` Andi Kleen
  2012-10-07 22:30 ` richard -rw- weinberger
  0 siblings, 2 replies; 6+ messages in thread
From: Ezequiel Garcia @ 2012-10-07 19:18 UTC (permalink / raw)
  To: linux-kernel; +Cc: Tim Bird, mmarek, sam, rientjes, Ezequiel Garcia

The new option is CONFIG_CC_DISABLE_AUTO_INLINE and it's
located at:
  * Kernel hacking
    * Disable gcc automatic inlining

This option appends this options CFLAGS:

-fno-default-inline
-fno-inline
-fno-inline-small-functions
-fno-indirect-inlining
-fno-inline-functions-called-once

It's still not clear which of these really work and which doesn't.
Just in case, just disable all of them.

Signed-off-by: Ezequiel Garcia <elezegarcia@gmail.com>
---
Changes from v1:
 * Change define name to CONFIG_CC_XXX
 * Disable all options that refer to inlining

This work is part of CELF Workgroup Project:
"Kernel_dynamic_memory_allocation_tracking_and_reduction":
http://elinux.org/Kernel_dynamic_memory_allocation_tracking_and_reduction

 Makefile             |    8 ++++++++
 kernel/trace/Kconfig |    4 ++++
 2 files changed, 12 insertions(+), 0 deletions(-)

diff --git a/Makefile b/Makefile
index ddf5be9..3169603 100644
--- a/Makefile
+++ b/Makefile
@@ -561,6 +561,14 @@ else
 KBUILD_CFLAGS	+= -O2
 endif
 
+ifdef CONFIG_CC_DISABLE_AUTO_INLINE
+KBUILD_CFLAGS	+= -fno-default-inline \
+		   -fno-inline \
+		   -fno-inline-small-functions \
+		   -fno-indirect-inlining \
+		   -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 8c4c070..144da36 100644
--- a/kernel/trace/Kconfig
+++ b/kernel/trace/Kconfig
@@ -128,6 +128,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


^ permalink raw reply related	[flat|nested] 6+ messages in thread

* Re: [PATCH v2] Makefile: Add option to disable gcc automatic inlining
  2012-10-07 19:18 [PATCH v2] Makefile: Add option to disable gcc automatic inlining Ezequiel Garcia
@ 2012-10-07 22:21 ` Andi Kleen
  2012-10-07 22:34   ` Ezequiel Garcia
  2012-10-07 22:30 ` richard -rw- weinberger
  1 sibling, 1 reply; 6+ messages in thread
From: Andi Kleen @ 2012-10-07 22:21 UTC (permalink / raw)
  To: Ezequiel Garcia; +Cc: linux-kernel, Tim Bird, mmarek, sam, rientjes

Ezequiel Garcia <elezegarcia@gmail.com> writes:

> The new option is CONFIG_CC_DISABLE_AUTO_INLINE and it's
> located at:
>   * Kernel hacking
>     * Disable gcc automatic inlining

You don't state anywhere why you want that?

-Andi

-- 
ak@linux.intel.com -- Speaking for myself only

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH v2] Makefile: Add option to disable gcc automatic inlining
  2012-10-07 19:18 [PATCH v2] Makefile: Add option to disable gcc automatic inlining Ezequiel Garcia
  2012-10-07 22:21 ` Andi Kleen
@ 2012-10-07 22:30 ` richard -rw- weinberger
  2012-10-07 22:35   ` Ezequiel Garcia
  2012-10-10  2:52   ` Ezequiel Garcia
  1 sibling, 2 replies; 6+ messages in thread
From: richard -rw- weinberger @ 2012-10-07 22:30 UTC (permalink / raw)
  To: Ezequiel Garcia; +Cc: linux-kernel, Tim Bird, mmarek, sam, rientjes

On Sun, Oct 7, 2012 at 9:18 PM, Ezequiel Garcia <elezegarcia@gmail.com> wrote:
> The new option is CONFIG_CC_DISABLE_AUTO_INLINE and it's
> located at:
>   * Kernel hacking
>     * Disable gcc automatic inlining

Can you guarantee that this will still produce a valid kernel?
AFAIK we have some functions which have to be inlined in any case.

-- 
Thanks,
//richard

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH v2] Makefile: Add option to disable gcc automatic inlining
  2012-10-07 22:21 ` Andi Kleen
@ 2012-10-07 22:34   ` Ezequiel Garcia
  0 siblings, 0 replies; 6+ messages in thread
From: Ezequiel Garcia @ 2012-10-07 22:34 UTC (permalink / raw)
  To: Andi Kleen; +Cc: linux-kernel, Tim Bird, mmarek, sam, rientjes

On Sun, Oct 7, 2012 at 7:21 PM, Andi Kleen <andi@firstfloor.org> wrote:
> Ezequiel Garcia <elezegarcia@gmail.com> writes:
>
>> The new option is CONFIG_CC_DISABLE_AUTO_INLINE and it's
>> located at:
>>   * Kernel hacking
>>     * Disable gcc automatic inlining
>
> You don't state anywhere why you want that?
>

This is 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.

Perhaps I should explain this better in the commit message?

Thanks for reviewing,

    Ezequiel

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH v2] Makefile: Add option to disable gcc automatic inlining
  2012-10-07 22:30 ` richard -rw- weinberger
@ 2012-10-07 22:35   ` Ezequiel Garcia
  2012-10-10  2:52   ` Ezequiel Garcia
  1 sibling, 0 replies; 6+ messages in thread
From: Ezequiel Garcia @ 2012-10-07 22:35 UTC (permalink / raw)
  To: richard -rw- weinberger; +Cc: linux-kernel, Tim Bird, mmarek, sam, rientjes

On Sun, Oct 7, 2012 at 7:30 PM, richard -rw- weinberger
<richard.weinberger@gmail.com> wrote:
> On Sun, Oct 7, 2012 at 9:18 PM, Ezequiel Garcia <elezegarcia@gmail.com> wrote:
>> The new option is CONFIG_CC_DISABLE_AUTO_INLINE and it's
>> located at:
>>   * Kernel hacking
>>     * Disable gcc automatic inlining
>
> Can you guarantee that this will still produce a valid kernel?
> AFAIK we have some functions which have to be inlined in any case.
>

Not sure what you mean by "valid" kernel. I'm using a kernel with
this, of course.
If you mean always_inline attribute: that's a whole different story.
This option only disables *automatic* inlining.

   Ezequiel

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH v2] Makefile: Add option to disable gcc automatic inlining
  2012-10-07 22:30 ` richard -rw- weinberger
  2012-10-07 22:35   ` Ezequiel Garcia
@ 2012-10-10  2:52   ` Ezequiel Garcia
  1 sibling, 0 replies; 6+ messages in thread
From: Ezequiel Garcia @ 2012-10-10  2:52 UTC (permalink / raw)
  To: richard -rw- weinberger; +Cc: linux-kernel, Tim Bird, mmarek, sam, rientjes

Hey Richard,

On Sun, Oct 7, 2012 at 7:30 PM, richard -rw- weinberger
<richard.weinberger@gmail.com> wrote:
> On Sun, Oct 7, 2012 at 9:18 PM, Ezequiel Garcia <elezegarcia@gmail.com> wrote:
>> The new option is CONFIG_CC_DISABLE_AUTO_INLINE and it's
>> located at:
>>   * Kernel hacking
>>     * Disable gcc automatic inlining
>
> Can you guarantee that this will still produce a valid kernel?
> AFAIK we have some functions which have to be inlined in any case.
>

As a matter of fact, you're right... this breaks compilation on my
desktop machine.
I guess I'll have to give it a respin :-(

Thanks for the feedback.

    Ezequiel

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2012-10-10  2:52 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-10-07 19:18 [PATCH v2] Makefile: Add option to disable gcc automatic inlining Ezequiel Garcia
2012-10-07 22:21 ` Andi Kleen
2012-10-07 22:34   ` Ezequiel Garcia
2012-10-07 22:30 ` richard -rw- weinberger
2012-10-07 22:35   ` Ezequiel Garcia
2012-10-10  2:52   ` Ezequiel Garcia

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.