Re: Net device byte statistics

From: Ben Greear (greearb@candelatech.com)
Date: Fri Jul 25 2003 - 19:08:46 EST


Jeff Sipek wrote:
> -----BEGIN PGP SIGNED MESSAGE-----
> Hash: SHA1
>
> On Friday 25 July 2003 17:55, jw schultz wrote:
>

>>My thought would be to use 96bits for each counter. In-kernel
>>code would run periodically doing something like this:
>>
>> curval = counter.in_kernel;
>> /* get it in a register for atomicity */
>> if (counter.user_low < curval)
>> ++counter.user_high;
>> counter.user_low = curval;

What about every 30 seconds or so, detect wraps, and bump the 'high' counter
if it wraps. (Check more often if you can wrap more than once in 30 secs).

Then, upon read by user-space (or whatever needs 64-bit counters):

1) check wrap
2) grab low bits and OR them with the high bits.
3) check wrap again. If wrap happened, try again. Assumption is it could never wrap
    more than once during the time you are checking.

I think this could give us very low overhead, and extremely precise 64-bit
reads. And, I think it would not need locks in the fast path..but I could
also be missing something :)

-- 
Ben Greear <greearb@candelatech.com>
Candela Technologies Inc  http://www.candelatech.com

- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/



This archive was generated by hypermail 2b29 : Thu Jul 31 2003 - 22:00:27 EST