summaryrefslogtreecommitdiff
path: root/m4
diff options
context:
space:
mode:
authorJesse Gross <jesse@nicira.com>2010-07-28 18:20:43 -0700
committerJesse Gross <jesse@nicira.com>2010-08-20 19:44:46 -0700
commit38c6ecbc8d3664daed077617bb3b3508ba8aa767 (patch)
treeac2a55af87e9833409b3b80265ae0de867ec5a53 /m4
parent16e9d4f64f4ad7adf3e5f619e65a2045282b3969 (diff)
downloadopenvswitch-38c6ecbc8d3664daed077617bb3b3508ba8aa767.tar.gz
datpath: Avoid reporting half updated statistics.
We enforce mutual exclusion when updating statistics by disabling bottom halves and only writing to per-CPU state. However, reading requires looking at the statistics for foreign CPUs, which could be in the process of updating them since there isn't a lock. This means we could get garbage values for 64-bit values on 32-bit machines or byte counts that don't correspond to packet counts, etc. This commit introduces a sequence lock for statistics values to avoid this problem. Getting a write lock is very cheap - it only requires incrementing a counter plus a memory barrier (which is compiled away on x86) to acquire or release the lock and will never block. On read we spin until the sequence number hasn't changed in the middle of the operation, indicating that the we have a consistent set of values. Signed-off-by: Jesse Gross <jesse@nicira.com>
Diffstat (limited to 'm4')
0 files changed, 0 insertions, 0 deletions