2
0
mirror of https://github.com/openvswitch/ovs synced 2025-09-05 00:35:33 +00:00

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
This commit is contained in:
Alex Wang
2015-08-13 11:31:49 -07:00
parent d1cec3c6e3
commit fbe0962b28
3 changed files with 32 additions and 4 deletions

View File

@@ -88,6 +88,7 @@ void coverage_counter_register(struct coverage_counter*);
void coverage_init(void);
void coverage_log(void);
void coverage_clear(void);
void coverage_try_clear(void);
void coverage_run(void);
#endif /* coverage.h */