Thread (4 messages) flat view 4 messages, 4 authors, 2003-07-07

RFC: another approach for 64-bit network stats

From: Patrick McHardy <hidden>
Date: 2003-07-07 13:51:22
Also in: lkml

This patch implements a lockless aproach for 64-bit netstatistics with 
only a very rare
racecondition. On 64 bit system, nothing is changed. On 32 bit system 
the (32bit) counter
is checked periodically for overflows. The overflows are saved in 
counter_high. To detect
overflows, we need to save the counter value when last checked 
(counter_last), so there is
a 4byte overhead per 64bit counter. The 32-bit values can be accessed as 
before through
stats->counter, the 64bit values are accessed through a macro 
NETSTAT64(stats, counter).
Accessing the 64bit values contains the before mentioned race-condition, 
when the counters
are synced while they are read and an overflow occured the value could 
be of 4gb. However
the next read will return the correct value and with gigabit speed we 
only need to sync every ~30s,
so thats much better than racing on every counter update (using 64bit 
counters directly) and
potentially damaging the counter permanently. The race could be avoided 
by locking syncs and
reads (not normal counter updates). The patch only breaks binary 
interfaces, all in-kernel users
can continue to use the 32bit values until they have been changed, 
userspace software just
needs recompilation, device drivers don't need any changes at all.

Comments ?

Bye,
Patrick

Attachments

Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help