David S. Miller wrote:
From: Andi Kleen <ak@xxxxxxx>
Date: Wed, 11 Jun 2003 14:08:03 +0200
Another way is to just store jiffies (= 10 or 1ms accuracy)
This should be nearly zero cost and accurate enough at least for TCP.
TCP doesn't use it Andi. SO_RECVSTAMP etc. uses it and that
MUST be accurate.
People, start approaching this from an actually implementable
angle, not one's that have no basis in reality :)
I think we need a generic method to get something like the
TSC..ie very fast, very precise.
Then, we need a way to turn this into the time-of-day.
After that, we can calculate time-of-day in a lazy manner.
Something like:
/* In driver or as early as possible */
skb->rx_stamp = getCurTSC();
skb->flags |= (RX_STAMP_IS_NOT_YET_CONVERTED);
....
/* somebody wants to know what time of day rx-stamp was */
if (skb->flags & (RX_STAMP_IS_NOT_YET_CONVERTED)) {
skb->rx_stamp = do_gettimeofday() - ((getCurTSC() - skb->rx_stamp) *
(magic-conversion-to-timeval-units));
skb->flags &= ~(RX_STAMP_IS_NOT_YET_CONVERTED);
}
/* rx_stamp is now relative to time-of-day */
But, Dave mentioned TSC is not always good to use, and it won't work at all
on older cpus, so the getCurTSC() thing probably needs to be a macro...
Seems like this macro would be useful in lots of places...pktgen for
instance :)
Ben
--
Ben Greear <greearb@xxxxxxxxxxxxxxx> <Ben_Greear AT excite.com>
President of Candela Technologies Inc http://www.candelatech.com
ScryMUD: http://scry.wanfear.com http://scry.wanfear.com/~greear
|