coverage: Add coverage_try_clear() for performance-critical threads.
authorAlex Wang <alexw@nicira.com>
Thu, 13 Aug 2015 18:31:49 +0000 (11:31 -0700)
committerAlex Wang <alexw@nicira.com>
Tue, 25 Aug 2015 23:21:36 +0000 (16:21 -0700)
commitfbe0962b28808a24fc2bff8b5d17cb0c46756c59
treecade54bafa5ab1dd8d9e2e37357dc44ffe118e55
parentd1cec3c6e3fc02d3750633116b62634a44e83f33
coverage: Add coverage_try_clear() for performance-critical threads.

For performance-critical threads like pmd threads, we currently make them
never call coverage_clear() to avoid contention over the global mutex
'coverage_mutex'.  So, even though pmd thread still keeps updating their
thread-local coverage count, the count is never attributed to the global
total.  But it is useful to have them available.

This commit makes this happen by implementing a non-contending version
of the clear function, coverage_try_clear().  The function will use
the ovs_mutex_trylock() and return immediately if the mutex cannot
be acquired.  Since threads like pmd thread are always busy-looping,
the lock will eventually be acquired.

Requested-by: Ilya Maximets <i.maximets@samsung.com>
Signed-off-by: Alex Wang <alexw@nicira.com>
Acked-by: Ilya Maximets <i.maximets@samsung.com>
Acked-by: Ben Pfaff <blp@nicira.com>
Acked-by: Daniele Di Proietto <diproiettod@vmware.com
lib/coverage.c
lib/coverage.h
lib/dpif-netdev.c