From: Ingo Molnar <mingo@elte.hu>
To: "Metzger, Markus T" <markus.t.metzger@intel.com>
Cc: ak@suse.de, hpa@zytor.com, linux-kernel@vger.kernel.org,
tglx@linutronix.de, markus.t.metzger@gmail.com, "Siddha,
Suresh B" <suresh.b.siddha@intel.com>,
roland@redhat.com, akpm@linux-foundation.org,
mtk.manpages@gmail.com, Alan Stern <stern@rowland.harvard.edu>
Subject: Re: x86, ptrace: support for branch trace store(BTS)
Date: Wed, 12 Dec 2007 12:03:30 +0100 [thread overview]
Message-ID: <20071212110330.GD1611@elte.hu> (raw)
In-Reply-To: <029E5BE7F699594398CA44E3DDF554440115D3C5@swsmsx413.ger.corp.intel.com>
* Metzger, Markus T <markus.t.metzger@intel.com> wrote:
> Andi suggested to make this a sysctl.
that's just as arbitrary ...
> Would it be safe to drop the artificial limit and let the limit be the
> available memory?
no, that would be a DoS :-/
mlock() is rlimit controlled and is available to unprivileged users - up
to a small amount of memory can be locked down. But i agree that mlock()
can be problematic - see below.
> > There's also no real mechanism that i can see to create a guaranteed
> > flow of this information between the debugger and debuggee (unless i
> > missed something), the code appears to overflow the array, and
> > destroy earlier entries, right? That's "by design" for debugging,
> > but quite a limitation for instrumentation which might want to have
> > a reliable stream of the data (and would like the originating task
> > to block until the debugger had an opportunity to siphoon out the
> > data).
>
> That's correct as well. My focus is on debugging. And that's actually
> the most useful behavior in that case. I'm not sure what you mean with
> 'instrumentation'.
the branch trace can be used to generate a very finegrained
profile/histogram of code execution - even of rarely executed codepaths
which cannot be captured via timer/perf-counter based profiling.
another potential use would be for call graph coverage testing. (which
currently requires compiler-inserted calls - would be much nicer if we
could do this via the hardware.)
etc. Branch tracing isnt just for debugging i think - as long as the
framework is flexible enough.
> The actual physical memory consumption will be worse (or at best
> equal) compared to kalloc()ed memory, since we need to pin down entire
> pages, whereas kalloc() would allocate just the memory that is
> actually needed.
i agree that mlock() has problems. A different model would be: no mlock
and no get_user_pages() - something quite close to what you have
already. Data is streamed out of the internal (hardware-filled,
kmalloc()-ed, user-inaccessible) buffer, we stop task execution until it
is copied to the larger, user-provided buffer. The debugging feature you
are interested in could be enabled as a special-case of this mechanism:
if the user-space buffer is not larger than the hardware buffer then no
streaming is needed, you can just capture into the kernel buffer.
User-space would have to do a PTRACE_BTS_DRAIN_BUFFER call (or something
like that) to get the "final portion" of the branch trace out into the
user-space buffer. [which, in your debugging special-case, would the
full internal buffer.]
that way the kmalloc()-ed buffer becomes an internal detail of buffering
that you rarely have to be aware of. (it could still be queried - like
your patch does it now.)
or something else that is intelligent. Basically, what we'd like to have
is a future-proof, extensible approach that does not necessarily stop at
debugging and integrates this hardware capability into Linux
intelligently.
Ingo
next prev parent reply other threads:[~2007-12-12 11:04 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2007-12-10 11:38 [patch 1/4] x86: remove bad comment Markus Metzger
2007-12-10 20:20 ` x86, ptrace: support for branch trace store(BTS) Ingo Molnar
2007-12-11 10:34 ` Metzger, Markus T
2007-12-11 14:53 ` Ingo Molnar
2007-12-12 9:18 ` Metzger, Markus T
2007-12-12 11:03 ` Ingo Molnar [this message]
2007-12-12 12:23 ` Metzger, Markus T
2007-12-13 10:29 ` Ingo Molnar
2007-12-13 12:51 ` Metzger, Markus T
2007-12-13 13:08 ` Ingo Molnar
2007-12-13 16:06 ` Metzger, Markus T
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=20071212110330.GD1611@elte.hu \
--to=mingo@elte.hu \
--cc=ak@suse.de \
--cc=akpm@linux-foundation.org \
--cc=hpa@zytor.com \
--cc=linux-kernel@vger.kernel.org \
--cc=markus.t.metzger@gmail.com \
--cc=markus.t.metzger@intel.com \
--cc=mtk.manpages@gmail.com \
--cc=roland@redhat.com \
--cc=stern@rowland.harvard.edu \
--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).