lkml.org 
[lkml]   [2007]   [Dec]   [10]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: x86, ptrace: support for branch trace store(BTS)

[ Cc:-ed Alan Stern a'ka kwatch fame - Alan might be interested in this
too. ]

hi Markus,

finally had time to take a closer look at the design of your
Branch-Trace-Support-via-ptrace-on-x86 patchset. I think we'll need to
work some more on general API issues.

here's the current proposed API:

+ case PTRACE_BTS_MAX_BUFFER_SIZE:
+ case PTRACE_BTS_ALLOCATE_BUFFER:
+ case PTRACE_BTS_GET_BUFFER_SIZE:
+ case PTRACE_BTS_READ_RECORD:
+ case PTRACE_BTS_CONFIG:
+ case PTRACE_BTS_STATUS:

i can see a couple of open questions:

1) PTRACE_BTS_MAX_BUFFER_SIZE

why is a trace buffer size limit visible to user-space? It's 4000
entries right now:

#define PTRACE_BTS_BUFFER_MAX 4000

it would be more flexible if user-space could offer arbitrary sized
buffers, which the kernel would attempt to mlock(). Then those pages
could be fed to the BTS MSR. I.e. there should be no hard limit in the
API, other than a natural resource limit.

2) struct bts_struct

the structure of it is hardwired:

the basic unit is an array of bts_struct:

+struct bts_struct {
+ enum bts_qualifier qualifier;
+ union {
+ /* BTS_BRANCH */
+ struct {
+ long from_ip;
+ long to_ip;
+ } lbr;
+ /* BTS_TASK_ARRIVES or
+ BTS_TASK_DEPARTS */
+ unsigned long long timestamp;
+ } variant;
+};

while other CPUs (on other architectures, etc.) might have a different
raw format for the trace entries. So it would be better to implement BTS
support in kernel/ptrace.c with a general trace format, and to provide a
cross-arch API (only implemented by arch/x86 in the beginning) to
translate the 'raw' trace entries into the general format.

3)

it would certainly be useful for some applications to have a large
"virtual" trace buffer and a small "real" trace buffer. The kernel would
use BTS high-watermark interrupts to feed the real trace buffer into the
larger "virtual" trace buffer. This way we wouldnt even have to use
mlock() to pin down the trace buffer.

Ingo


\
 
 \ /
  Last update: 2007-12-10 21:23    [W:0.155 / U:0.248 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site