Re: [RFC PATCH 1/2 v2] Unified trace buffer
From: Mathieu Desnoyers
Date: Thu Sep 25 2008 - 14:30:40 EST
* Steven Rostedt (rostedt@xxxxxxxxxxx) wrote:
>
> On Thu, 25 Sep 2008, Mathieu Desnoyers wrote:
> >
> > Is there a reason to use delta between events rather than simply write
> > the 27 LSBs that I would have missed ?
>
> One answer is that your counter wrap problem is extended.
>
> That is, you have 27 bits of time between each event to not worry about
> wraps. But if you go against the page itself, the last event on that page
> is more likely to suffer.
>
You can do the exact same thing and manage to keep the absolute time.
You just have to adapt the reader like this : (this would be for
per-event cycle count in the 32 LSBs, slight bitmask adaptation needed
for 27 bits only).
keep a 64 bits TSC value in a per-buffer variable. The previous value is
always re-used for the next read.
let's call it :
tf->buffer.tsc (u64)
read_event() would look like :
u32 timetamp = read_event_timetamp();
if(timestamp < (0xFFFFFFFFULL & tf->buffer.tsc)) {
/* overflow */
tf->buffer.tsc = ((tf->buffer.tsc & 0xFFFFFFFF00000000ULL)
+ 0x100000000ULL) | (u64)timestamp;
} else {
/* no overflow */
tf->buffer.tsc = (tf->buffer.tsc & 0xFFFFFFFF00000000ULL)
| (u64)timestamp;
}
This will detect 32 bits overflow and keep the tf->buffer.tsc in sync
with the TSC representation on the traced machine as long as events are
less then 27 bits apart. A "full tsc" header can also be easily managed
with this by updating the tf->buffer.tsc value completely when such
event is met.
Mathieu
> -- Steve
>
--
Mathieu Desnoyers
OpenPGP key fingerprint: 8CD5 52C3 8E3C 4140 715F BA06 3F25 A8FE 3BAE 9A68
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/