Re: [RFC PATCH 1/3] Unified trace buffer

From: Linus Torvalds
Date: Wed Sep 24 2008 - 16:32:47 EST




On Wed, 24 Sep 2008, Martin Bligh wrote:
>
> If we just record the TSC unshifted, in 27 bits, at 4GHz, that gives us
> about 1/30 of a second? So we either shift, use > 27 bits, or record
> at least 30 events a second, none of which I like much ...

No, we don't shift (we don't want to lose precision), and we don't use
more than 27 bits by default.

the TSC at each entry should be a _delta_. It's the difference from the
last one. And if you get less than 30 events per second, and you need a
bigger difference, you insert an extra "sync" tracepoint that has a 59-bit
thing (27 bits _plus_ the extra 'data').

Yes, it adds 8 bytes (assuming that minimal format), but it does so only
for any trace event that is more than 1/30th of a second from its previous
one. IOW, think of this not in bytes, but in bytes-per-second. It adds at
most 8*30=240 bytes per second, but what it _saves_ is that when you have
tens of thousands of events, it shaves 4 bytes FOR EACH EVENT.

See?

Also, quite often, the clock won't be running at 4GHz even if the CPU
might. Intel already doesn't make the TSC be the nominal frequency, and
other architectures with TSC's have long had the TSC be something like a
"divide-by-16" clock rather than every single cycle because it's more
power-efficient.

So there is often a built-in shift, and I doubt we'll see 10GHz TSC's even
if we see 10GHz CPU's (which many people consider unlikely anyway, but
I'm not going to bet against technology).

Linus
--
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/