All of lore.kernel.org
 help / color / mirror / Atom feed
* [RFC PATCH 0/4] ftrace: Add use of -mfentry for x86_64
@ 2012-08-07 19:38 Steven Rostedt
  2012-08-07 19:38 ` [RFC PATCH 1/4] ftrace: Make recordmcount.c handle __fentry__ Steven Rostedt
                   ` (4 more replies)
  0 siblings, 5 replies; 25+ messages in thread
From: Steven Rostedt @ 2012-08-07 19:38 UTC (permalink / raw)
  To: linux-kernel
  Cc: Ingo Molnar, Andrew Morton, Thomas Gleixner, Frederic Weisbecker,
	Masami Hiramatsu, Linus Torvalds, Andi Kleen

[-- Attachment #1: Type: text/plain, Size: 1764 bytes --]


This is an RFC patch set that makes gcc use the -mfentry option with
-pg. This will set the ftrace 'hook' to the beginning of the function
and also remove the requirement that -pg enables frame pointers.

This has a couple of benefits (and probably more).

1) removal of the frame pointer requirement makes for smaller and faster code.

2) Having the function trace hook at the beginning of the function instead
 of after the frame is set up, gives the function tracing callbacks access
 to the parameters. This means that kprobes can take advantage of this.
 When a kprobe is set on top of a ftrace hook (nop), it will automatically
 use the function tracing callback. This makes it into an 'optimized' probe
 as there's no need to hit a breakpoint and trigger the probe that way.
 The function tracing code can do the work for it. Note, optimized probes
 are only allowed with !PREEMPT, but a ftrace optimize probe is allowed
 in any context (another benefit).

This only implements fentry for x86_64.

Steven Rostedt (4):
      ftrace: Make recordmcount.c handle __fentry__
      ftrace: Add -mfentry to Makefile on function tracer
      ftrace: Do not test frame pointers if -mfentry is used
      ftrace/x86: Add support for -mfentry to x86_64

----
 Makefile                             |    6 +++++-
 arch/x86/Kconfig                     |    1 +
 arch/x86/include/asm/ftrace.h        |    7 ++++++-
 arch/x86/kernel/entry_64.S           |   18 +++++++++++++++++-
 arch/x86/kernel/x8664_ksyms_64.c     |    6 +++++-
 kernel/trace/Kconfig                 |    5 +++++
 kernel/trace/trace_functions_graph.c |    5 ++++-
 scripts/recordmcount.h               |    4 +++-
 8 files changed, 46 insertions(+), 6 deletions(-)

[-- Attachment #2: This is a digitally signed message part --]
[-- Type: application/pgp-signature, Size: 836 bytes --]

^ permalink raw reply	[flat|nested] 25+ messages in thread
* [RFC][PATCH 0/4] ftrace: Use -mfentry when supported (this is for x86_64 right now)
@ 2011-02-09 20:02 Steven Rostedt
  2011-02-09 20:02 ` [RFC][PATCH 4/4] ftrace/x86: Add support for -mfentry to x86_64 Steven Rostedt
  0 siblings, 1 reply; 25+ messages in thread
From: Steven Rostedt @ 2011-02-09 20:02 UTC (permalink / raw)
  To: linux-kernel
  Cc: Ingo Molnar, Andrew Morton, Thomas Gleixner, Frederic Weisbecker,
	H. Peter Anvin, Mathieu Desnoyers, Andi Kleen, Masami Hiramatsu

Thanks to Andi Kleen gcc 4.6.0 now supports -mfentry with the -pg option
to place a call to __fentry__ at the very beginning of the function
instead of after the fact.

The old way:

00000000000000c4 <atomic_long_add>:
      c4:       55                      push   %rbp
      c5:       48 89 e5                mov    %rsp,%rbp
      c8:       e8 00 00 00 00          callq  cd <atomic_long_add+0x9>
                        c9: R_X86_64_PC32       mcount-0x4
      cd:       f0 48 01 3e             lock add %rdi,(%rsi)
      d1:       c9                      leaveq 
      d2:       c3                      retq   

The new way:

000000000000009e <atomic_long_add>:
      9e:       e8 00 00 00 00          callq  a3 <atomic_long_add+0x5>
                        9f: R_X86_64_PC32       __fentry__-0x4
      a3:       55                      push   %rbp
      a4:       48 89 e5                mov    %rsp,%rbp
      a7:       f0 48 01 3e             lock add %rdi,(%rsi)
      ab:       5d                      pop    %rbp
      ac:       c3                      retq   

Note, with -mfentry, frame pointers is no longer required
by the function tracer. But this patch series still requires
FRAME_POINTER to be set, since I need to figure out a good way to
enable FRAME_POINTER only if gcc doesn't support this. But that can
come later.

With the new __fentry__, we could possible record the parameters
of a function call. This may take some work, and perhaps be
a little like kprobes. But it is doable.

This is still just RFC. I only wrote the code to support x86_64
even though gcc 4.6.0 also supports i386. I figured I would post
this first to get peoples reactions before converting
i386 too. Other archs can soon follow.

-- Steve

The following patches are in:

  git://git.kernel.org/pub/scm/linux/kernel/git/rostedt/linux-2.6-trace.git

    branch: rfc/tracing/fentry


Steven Rostedt (4):
      ftrace: Make recordmcount.c handle __fentry__
      ftrace: Add -mfentry to Makefile on function tracer
      ftrace: Do not test frame pointers if -mfentry is used
      ftrace/x86: Add support for -mfentry to x86_64

----
 Makefile                             |    6 +++++-
 arch/x86/Kconfig                     |    1 +
 arch/x86/include/asm/ftrace.h        |    7 ++++++-
 arch/x86/kernel/entry_64.S           |   17 ++++++++++++++++-
 arch/x86/kernel/x8664_ksyms_64.c     |    6 +++++-
 kernel/trace/Kconfig                 |    5 +++++
 kernel/trace/trace_functions_graph.c |    5 ++++-
 scripts/recordmcount.h               |    4 +++-
 8 files changed, 45 insertions(+), 6 deletions(-)

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

end of thread, other threads:[~2012-08-27 17:06 UTC | newest]

Thread overview: 25+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-08-07 19:38 [RFC PATCH 0/4] ftrace: Add use of -mfentry for x86_64 Steven Rostedt
2012-08-07 19:38 ` [RFC PATCH 1/4] ftrace: Make recordmcount.c handle __fentry__ Steven Rostedt
2012-08-07 23:57   ` John Reiser
2012-08-08  0:05     ` Steven Rostedt
2012-08-27 17:03   ` [tip:perf/core] " tip-bot for Steven Rostedt
2012-08-07 19:38 ` [RFC PATCH 2/4] ftrace: Add -mfentry to Makefile on function tracer Steven Rostedt
2012-08-27 17:04   ` [tip:perf/core] " tip-bot for Steven Rostedt
2012-08-07 19:38 ` [RFC PATCH 3/4] ftrace: Do not test frame pointers if -mfentry is used Steven Rostedt
2012-08-08  4:34   ` Masami Hiramatsu
2012-08-08 12:49     ` Steven Rostedt
2012-08-09  2:58       ` Masami Hiramatsu
2012-08-09  3:45       ` Linus Torvalds
2012-08-09  3:57         ` Steven Rostedt
2012-08-09  4:15         ` H. Peter Anvin
2012-08-09 12:37         ` Andi Kleen
2012-08-27 17:05   ` [tip:perf/core] " tip-bot for Steven Rostedt
2012-08-07 19:38 ` [RFC PATCH 4/4] ftrace/x86: Add support for -mfentry to x86_64 Steven Rostedt
2012-08-09  8:34   ` Masami Hiramatsu
2012-08-09 13:46   ` Steven Rostedt
2012-08-09 13:48     ` Steven Rostedt
2012-08-10  7:45     ` Masami Hiramatsu
2012-08-27 17:06   ` [tip:perf/core] " tip-bot for Steven Rostedt
2012-08-07 20:23 ` [RFC PATCH 0/4] ftrace: Add use of -mfentry for x86_64 H. Peter Anvin
2012-08-13  8:42   ` Ingo Molnar
  -- strict thread matches above, loose matches on Subject: below --
2011-02-09 20:02 [RFC][PATCH 0/4] ftrace: Use -mfentry when supported (this is for x86_64 right now) Steven Rostedt
2011-02-09 20:02 ` [RFC][PATCH 4/4] ftrace/x86: Add support for -mfentry to x86_64 Steven Rostedt

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.