All of lore.kernel.org
 help / color / mirror / Atom feed
From: Steven Rostedt <rostedt@goodmis.org>
To: LKML <linux-kernel@vger.kernel.org>,
	linux-kbuild <linux-kbuild@vger.kernel.org>
Cc: Michal Marek <mmarek@suse.cz>,
	"H. Peter Anvin" <hpa@linux.intel.com>,
	Andrew Morton <akpm@linux-foundation.org>,
	Andi Kleen <andi@firstfloor.org>, Ingo Molnar <mingo@elte.hu>,
	Frederic Weisbecker <fweisbec@gmail.com>
Subject: RFC: How to handle function tracing, frame pointers and -mfentry?
Date: Fri, 27 Apr 2012 14:46:39 -0400	[thread overview]
Message-ID: <1335552399.28106.228.camel@gandalf.stny.rr.com> (raw)

I have code that implements -mfentry for the function tracer.

For those that are unfamiliar with this, it was introduced into gcc in
4.6.0 for x86 only. Used with the -pg option, it replaces mcount with
fentry, and is placed at the first instruction of a function (instead of
after the frame has been built, as mcount does).

So what's my problem?  With -mfentry, function tracer does not depend on
frame pointers. As frame pointers may add overhead, some distros
(Debian) has disabled frame pointers from their kernels and with that,
has also disabled function tracing.

Currently, function tracing selects CONFIG_FRAME_POINTER for various
archs (including x86), as the kernel will not compile without it, if
function tracing is enabled. But if -mfentry is available with the
compiler, it does not have this dependency. The kernel will compile fine
with -pg -mfentry and without frame pointers.

My question is, how do I remove the dependency in kconfig based on the
compiler?

I've tried a few things and here's some ideas:

1) Have kconfig detect if -mfentry is supported with the current
compiler. If it is, then enable a "auto" config called
CONFIG_CC_HAS_FENTRY, and allow function tracer be able to select
FRAME_POINTER if that's not defined.

I actually got this to work, but it only works if the host compiler is
the same as the compiler building the kernel. Which in lots of cases is
not (my default setup does not have this).

2) Remove the select entirely. On build, if the compiler fails because
it does not support -pg running without frame pointers, have a big error
message telling the user they can't have function tracing without frame
pointers and that they either need to enable frame pointers or disable
function tracing.

3) Add frame pointers silently if gcc fails to build with gcc -pg.

I personally do not really care which approach is taken (or a new
approach that I didn't list). I just want to be able to build a kernel
with function tracing and without frame pointers on x86.

Thanks,

-- Steve



             reply	other threads:[~2012-04-27 18:46 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-04-27 18:46 Steven Rostedt [this message]
2012-04-27 19:43 ` RFC: How to handle function tracing, frame pointers and -mfentry? Steven Rostedt
2012-04-27 20:27 ` Sam Ravnborg
2012-04-27 20:31   ` H. Peter Anvin
2012-04-27 20:57     ` Steven Rostedt
2012-04-27 21:11       ` H. Peter Anvin
2012-04-27 21:27         ` Steven Rostedt
2012-04-28  8:36 ` Andi Kleen
2012-04-28  8:50   ` Sam Ravnborg
2012-04-28  9:11     ` Sam Ravnborg
2012-04-28 12:16       ` Andi Kleen
2012-04-28 16:34   ` H. Peter Anvin

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1335552399.28106.228.camel@gandalf.stny.rr.com \
    --to=rostedt@goodmis.org \
    --cc=akpm@linux-foundation.org \
    --cc=andi@firstfloor.org \
    --cc=fweisbec@gmail.com \
    --cc=hpa@linux.intel.com \
    --cc=linux-kbuild@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mingo@elte.hu \
    --cc=mmarek@suse.cz \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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.