Subject: Re: [PATCH] macvlan: lockless tx path

From: Ben Greear <[email-masked]>
Date: Wed, 10 Nov 2010 15:46:04 -0800

On 11/10/2010 03:36 PM, Eric Dumazet wrote:
> Le mercredi 10 novembre 2010 à 14:53 -0800, Ben Greear a écrit :
>
>> I did similar, and then wrote extra code to detect a 64-bit kernel and if
>> so assume that the counters wrap at 64 bits so I didn't have to poll so
>> often to make sure I didn't miss a wrap for a 10G NIC.  If instead one wraps at 33
>> bits and the other at 36, there is no way for me to deal with the wrap
>> properly w/out explicitly knowing about that 33 and 36.
>>
>
> How do you define 'wrap around' ? Maybe your definition is wrong.

Maybe so.  My algorithm looks like:

  // uint64 accum;
  // uint32 old;
  // uint32 new;
  if (old > new) {
      // This assumes counters wrap at 32 bits (ie, 0xFFFFFFFF).
      accum += ((uint32)(0xFFFFFFFF) - old) + new;
  }
  else if (old < new) {
      accum += new - old;
  }
  old = new;

...

Is there some way I can do this w/out the (0xFFFFFFFF - old),
and thus the assumption of 32-bit counters?

Thanks,
Ben

-- 
Ben Greear <[email-masked]>
Candela Technologies Inc  http://www.candelatech.com