network statistics in SMP
    Ulrich Spörlein 
    uqs at spoerlein.net
       
    Sat Dec 19 11:27:13 UTC 2009
    
    
  
On Tue, 15.12.2009 at 13:13:28 -0500, John Baldwin wrote:
> On Tuesday 15 December 2009 12:45:13 pm Harti Brandt wrote:
> > I see. I was also thinking along these lines, but was not sure whether it 
> > is worth the trouble. I suppose this does not help to implement 64-bit 
> > counters on 32-bit architectures, though, because you cannot read them 
> > reliably without locking to sum them up, right?
> 
> Either that or you just accept that you have a small race since it is only stats. :)
This might be stupid, but can we not easily *read* 64bit counters
on 32bit machines like this:
do {
    h1 = read_upper_32bits;
    l1 = read_lower_32bits;
    h2 = read_upper_32bits;
    l2 = read_lower_32bits; /* not needed */
} while (h1 != h2);
sum64 = (h1<<32) + l1;
or something like that? If h2 does not change between readings, no
wrap-around has occured. If l1 was read in between the readings of h1
and h2, the code above is sound. Right?
Regards,
Uli
    
    
More information about the freebsd-arch
mailing list