linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [patch 0/2] x86, ptrace:  support for branch trace store(BTS)
@ 2007-11-29  8:14 Metzger, Markus T
  2007-11-29 23:59 ` Andrew Morton
  0 siblings, 1 reply; 22+ messages in thread
From: Metzger, Markus T @ 2007-11-29  8:14 UTC (permalink / raw)
  To: linux-kernel, mingo, hpa, tglx, ak
  Cc: Siddha, Suresh B, Metzger, Markus T, akpm

Support for Intel's last branch recording to ptrace. This gives
debuggers
access to this hardware feature and allows them to show an execution
trace
of the debugged application.

Last branch recording (see section 18.5 in the Intel 64 and IA-32
Architectures Software Developer's Manual) allows taking an execution
trace of the running application without instrumentation. When a branch
is executed, the hardware logs the source and destination address in a
cyclic buffer given to it by the OS.

This can be a great debugging aid. It shows you how exactly you got
where you currently are without requiring you to do lots of single
stepping and rerunning.

This patch manages the various buffers, configures the trace
hardware, disentangles the trace, and provides a user interface via
ptrace. On the high-level design:
- there is one optional trace buffer per thread_struct
- upon a context switch, the trace hardware is reconfigured to either
  disable tracing or to use the appropriate buffer for the new task.
  - tracing induces ~20% overhead as branch records are sent out on
    the bus. 
  - the hardware collects trace per processor. To disentangle the
    traces for different tasks, we use separate buffers and reconfigure
    the trace hardware.
- the low-level data layout is configured at cpu initialization time
  - different processors use different branch record formats


patch 1/2 contains the kernel changes
patch 2/2 contains changes to the ptrace man pages


So far, we incorporated mostly feedback from Andi Kleen. Is there any
more feedback that needs to be addressed?


regards,
markus.
---------------------------------------------------------------------
Intel GmbH
Dornacher Strasse 1
85622 Feldkirchen/Muenchen Germany
Sitz der Gesellschaft: Feldkirchen bei Muenchen
Geschaeftsfuehrer: Douglas Lusk, Peter Gleissner, Hannes Schwaderer
Registergericht: Muenchen HRB 47456 Ust.-IdNr.
VAT Registration No.: DE129385895
Citibank Frankfurt (BLZ 502 109 00) 600119052

This e-mail and any attachments may contain confidential material for
the sole use of the intended recipient(s). Any review or distribution
by others is strictly prohibited. If you are not the intended
recipient, please contact the sender and delete all copies.

^ permalink raw reply	[flat|nested] 22+ messages in thread
* [patch 0/2] x86, ptrace: support for branch trace store(BTS)
@ 2007-11-30 15:56 Markus Metzger
  0 siblings, 0 replies; 22+ messages in thread
From: Markus Metzger @ 2007-11-30 15:56 UTC (permalink / raw)
  To: ak, hpa, linux-kernel, mingo, tglx
  Cc: akpm, markus.t.metzger, markus.t.metzger, mtk-manpages,
	suresh.b.siddha, roland

Support for Intel's last branch recording to ptrace. This gives debuggers
access to this hardware feature and allows them to show an execution trace
of the debugged application.

Last branch recording (see section 18.5 in the Intel 64 and IA-32
Architectures Software Developer's Manual) allows taking an execution
trace of the running application without instrumentation. When a branch
is executed, the hardware logs the source and destination address in a
cyclic buffer given to it by the OS.

This can be a great debugging aid. It shows you how exactly you got
where you currently are without requiring you to do lots of single
stepping and rerunning.

This patch manages the various buffers, configures the trace
hardware, disentangles the trace, and provides a user interface via
ptrace. On the high-level design:
- there is one optional trace buffer per thread_struct
- upon a context switch, the trace hardware is reconfigured to either
  disable tracing or to use the appropriate buffer for the new task.
  - tracing induces ~20% overhead as branch records are sent out on
    the bus.
  - the hardware collects trace per processor. To disentangle the
    traces for different tasks, we use separate buffers and reconfigure
    the trace hardware.
- the low-level data layout is configured at cpu initialization time
  - different processors use different branch record formats

Opens:
- kernel interface

patch 1/2 contains the kernel changes
patch 2/2 contains changes to the ptrace man pages


regards,
markus.

^ permalink raw reply	[flat|nested] 22+ messages in thread
* [patch 0/2] x86, ptrace: support for branch trace store(BTS)
@ 2007-12-04 18:03 Markus Metzger
  0 siblings, 0 replies; 22+ messages in thread
From: Markus Metzger @ 2007-12-04 18:03 UTC (permalink / raw)
  To: ak, hpa, linux-kernel, mingo, tglx
  Cc: akpm, markus.t.metzger, markus.t.metzger, mtk.manpages, roland,
	suresh.b.siddha

Support for Intel's last branch recording to ptrace. This gives debuggers
access to this hardware feature and allows them to show an execution trace
of the debugged application.

Last branch recording (see section 18.5 in the Intel 64 and IA-32
Architectures Software Developer's Manual) allows taking an execution
trace of the running application without instrumentation. When a branch
is executed, the hardware logs the source and destination address in a
cyclic buffer given to it by the OS.

This can be a great debugging aid. It shows you how exactly you got
where you currently are without requiring you to do lots of single
stepping and rerunning.

This patch manages the various buffers, configures the trace
hardware, disentangles the trace, and provides a user interface via
ptrace. On the high-level design:
- there is one optional trace buffer per thread_struct
- upon a context switch, the trace hardware is reconfigured to either
  disable tracing or to use the appropriate buffer for the new task.
  - tracing induces ~20% overhead as branch records are sent out on
    the bus.
  - the hardware collects trace per processor. To disentangle the
    traces for different tasks, we use separate buffers and reconfigure
    the trace hardware.
- the low-level data layout is configured at cpu initialization time
  - different processors use different branch record formats
- the implementation is done in two layers
  - the lower layer implements the DS/BTS access
  - the higher layer implements a ptrace interface

Per-CPU tracing can be implemented on top of the lower layer.
A per-cpu array of DS pointers needs to be ds_allocate()'d and the
MSR_IA32_DS_AREA and MSR_IA32_DEBUGCTLMSR MSR's need to be properly
configured. Care needs to be taken to not interfere with the ptrace
use of the above MSR's.


patch 1/2 contains the kernel changes
patch 2/2 contains changes to the ptrace man pages


regards,
markus.

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

end of thread, other threads:[~2007-12-04 18:03 UTC | newest]

Thread overview: 22+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2007-11-29  8:14 [patch 0/2] x86, ptrace: support for branch trace store(BTS) Metzger, Markus T
2007-11-29 23:59 ` Andrew Morton
2007-11-30  9:57   ` Metzger, Markus T
2007-11-30 10:34     ` Andi Kleen
2007-11-30 15:45       ` Metzger, Markus T
2007-11-30 17:06         ` Ingo Molnar
2007-12-01  7:40           ` Ingo Molnar
2007-12-03 13:53             ` Markus Metzger
2007-12-03 15:17               ` Metzger, Markus T
2007-12-03 16:21               ` Andi Kleen
2007-12-03 16:45                 ` Ingo Molnar
2007-12-03 17:11                   ` Andi Kleen
2007-12-03 17:22                     ` Thomas Gleixner
2007-12-03 21:55                     ` Ingo Molnar
2007-12-03 22:02                       ` Andi Kleen
2007-12-04  8:52                 ` Metzger, Markus T
2007-11-30 10:54   ` Ingo Molnar
2007-11-30 15:48     ` Metzger, Markus T
2007-11-30 16:04   ` Michael Kerrisk
2007-11-30 16:08     ` Michael Kerrisk
2007-11-30 15:56 Markus Metzger
2007-12-04 18:03 Markus Metzger

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).