[ltt-dev] LTTng specialized probes
Mathieu Desnoyers
compudj at krystal.dyndns.org
Thu Oct 9 12:15:33 EDT 2008
* Martin Bligh (mbligh at google.com) wrote:
> > <core event header, aligned on 32 bits>
> > 1-bit opt. ext. TSC (active if a 27-bits TSC overflow is detected)
> > 27-bits TSC
> > 4-bits event ID (ID #7 reserved to specify (optional) extended event ID,
> > ID #6 reserved to specify both ext. event ID and event
> > size)
>
> That's pretty much exactly what ktrace had. You don't need to reserve
> a bit for the TSC overflow, that can be an event, which gives you
> 31 events instead of 16 ?
>
Ah, oops, IDs #7 and #6 should have been IDs #16 and #15 (forgot a bit
here).
> However, the problem with this is you're no longer separating the
> ringbuffer layer (and timing) from the event tracing layer, or at
> least not on a byte boundary.
>
Yes, there is the problem of separation of the two layers, but there is
more than that : if we use a separate event to write the extended TSC
value, we will have to do this when writing an event in a lockless
scheme :
- Do
- read write offset
- Read TSC, compare to per-buffer "last_tsc"
- If 27-bit overflow, write large TSC event
- Do
- read write offset
- read TSC
- compute event size
- while cmpxchg write offset fails
- write per-buffer "last-tsc"
- continue (restart loop)
- compute event size
- while cmpxchg write offset fails
- write per-buffer "last-tsc"
By doing this, we actually have to do 3 TSC reads when we detect an
overflow intead of a single one. Also, we open the window for an
infinite loop if for some weird reason the TSC read becomes slower than
a 27-bits overflow (with virtualization you never know what will bite
you...).
However, I like your idea of using this "ext. TSC" bit as an event bit.
We could do :
(32-bits alignment)
27-bits TSC
5-bits event ID
ID #31 reserved to specify extended event ID
ID #30 reserved to specify both ext. event ID and event size
ID #29 reserved to specify ext. event ID, event size and ext. TSC
<ext.>
16-bits event ID (opt)
16-bits event size (opt) size = 65535 to specify large event size
64-bits TSC (opt) (aligned on sizeof (void *))
32-bits large event size (opt) (aligned on 32-bits)
(event payload aligned on sizeof(void *))
Which lets us put the extended TSC in the same event header by using the
ext. event ID in that case to encode the event ID. This would leave us
29 IDs available (0-28) and would not require any 3-TSC reads algorithm
(which could cause an infinite loop) to deal with overflow.
Mathieu
--
Mathieu Desnoyers
OpenPGP key fingerprint: 8CD5 52C3 8E3C 4140 715F BA06 3F25 A8FE 3BAE 9A68
More information about the lttng-dev
mailing list