forked from openvswitch/ovs
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
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 <[email protected]>
- Loading branch information
1 parent
16e9d4f
commit 38c6ecb
Showing
4 changed files
with
45 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters