Re: 64-bit fields in struct net_device_stats

From: Lincoln Dale (
Date: Mon Jun 16 2003 - 00:47:13 EST

At 11:12 PM 15/06/2003 -0400, Zwane Mwaikambo wrote:
> > suggested to use per cpu stats and overflow into a global counter. (Thanks
> > Zwane) This might be a better idea - the problem is, the counter won't be
> > 100% accurate at all times. The degree of inaccuracy will vary with the
> > threshold value. On the other hand, if the threshold is relatively low, no
> > one will notice the difference these days.
>This would be one method of doing updates and for stats it would be fine,
>however feel free to look into other ways...

why not a set of counters which are toggled between.

         struct netdevice... {
           uint64 tx_pkts_counter[2];
           uint64 tx_octets_counter[2];
           uint64 rx_pkts_counter[2];
           uint64 rx_octets_counter[2];
           int counter_bounce;

where readers simply do something like:
         tx_bytes +=

and writer(s) alternate between updating one uint64 and an alternate one?

in this manner, you don't need to do any special synchronization or atomic
updates or have any dependency on any particular architecture being able to
do atomic 64-bit ops.



To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to
More majordomo info at
Please read the FAQ at

This archive was generated by hypermail 2b29 : Mon Jun 23 2003 - 22:00:17 EST