linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: "Markus Metzger" <markus.t.metzger@googlemail.com>
To: ak@suse.de, hpa@zytor.com, linux-kernel@vger.kernel.org,
	mingo@elte.hu, tglx@linutronix.de
Cc: akpm@linux-foundation.org, markus.t.metzger@googlemail.com,
	markus.t.metzger@intel.com, mtk.manpages@gmail.com,
	roland@redhat.com, suresh.b.siddha@intel.com
Subject: [patch 0/2] x86, ptrace: support for branch trace store(BTS)
Date: Tue, 4 Dec 2007 19:03:19 +0100	[thread overview]
Message-ID: <a430082a0712041003v676c14b7ma6351af57a1d9bf2@mail.gmail.com> (raw)

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.

             reply	other threads:[~2007-12-04 18:03 UTC|newest]

Thread overview: 22+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-12-04 18:03 Markus Metzger [this message]
  -- strict thread matches above, loose matches on Subject: below --
2007-11-30 15:56 [patch 0/2] x86, ptrace: support for branch trace store(BTS) Markus Metzger
2007-11-29  8:14 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

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=a430082a0712041003v676c14b7ma6351af57a1d9bf2@mail.gmail.com \
    --to=markus.t.metzger@googlemail.com \
    --cc=ak@suse.de \
    --cc=akpm@linux-foundation.org \
    --cc=hpa@zytor.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=markus.t.metzger@intel.com \
    --cc=mingo@elte.hu \
    --cc=mtk.manpages@gmail.com \
    --cc=roland@redhat.com \
    --cc=suresh.b.siddha@intel.com \
    --cc=tglx@linutronix.de \
    /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 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).