[ovs-dev] [PATCH 2/7] stopwatch: expose required api for event library

Gowrishankar Muthukrishnan gmuthukr at redhat.com
Tue Jun 2 10:09:44 UTC 2020


Timer notifications in event library require handling stopwatch
across one or more events, so share few required functions.

Signed-off-by: Gowrishankar Muthukrishnan <gmuthukr at redhat.com>
---
 lib/stopwatch.c | 20 +++++++++++++++++++-
 lib/stopwatch.h |  9 +++++++++
 2 files changed, 28 insertions(+), 1 deletion(-)

diff --git a/lib/stopwatch.c b/lib/stopwatch.c
index f560216..0858d72 100644
--- a/lib/stopwatch.c
+++ b/lib/stopwatch.c
@@ -463,7 +463,7 @@ stopwatch_thread(void *ign OVS_UNUSED)
     return NULL;
 }
 
-static void
+void
 stopwatch_exit(void)
 {
     struct shash_node *node, *node_next;
@@ -526,6 +526,24 @@ stopwatch_create(const char *name, enum stopwatch_units units)
 }
 
 void
+stopwatch_delete(const char *name)
+{
+    ovs_mutex_lock(&stopwatches_lock);
+    shash_find_and_delete(&stopwatches, name);
+    ovs_mutex_unlock(&stopwatches_lock);
+}
+
+unsigned int
+stopwatch_count(void)
+{
+    unsigned int n;
+    ovs_mutex_lock(&stopwatches_lock);
+    n = shash_count(&stopwatches);
+    ovs_mutex_unlock(&stopwatches_lock);
+    return n;
+}
+
+void
 stopwatch_start(const char *name, unsigned long long ts)
 {
     struct stopwatch_packet *pkt = stopwatch_packet_create(OP_START_SAMPLE);
diff --git a/lib/stopwatch.h b/lib/stopwatch.h
index 91abd64..2f8e56c 100644
--- a/lib/stopwatch.h
+++ b/lib/stopwatch.h
@@ -56,4 +56,13 @@ bool stopwatch_get_stats(const char *name, struct stopwatch_stats *stats);
 /* Block until all enqueued samples have been processed. */
 void stopwatch_sync(void);
 
+/* Delete stopwatch */
+void stopwatch_delete(const char *name);
+
+/* Count stopwatches */
+unsigned int stopwatch_count(void);
+
+/* Exit stopwatch */
+void stopwatch_exit(void);
+
 #endif /* stopwatch.h */
-- 
1.8.3.1



More information about the dev mailing list