]> git.proxmox.com Git - mirror_ovs.git/commitdiff
ovsdb-server: fix monitor counters reported by memory/show
authorAndy Zhou <azhou@ovn.org>
Thu, 4 Feb 2016 04:57:32 +0000 (20:57 -0800)
committerAndy Zhou <azhou@ovn.org>
Fri, 5 Feb 2016 22:03:20 +0000 (14:03 -0800)
Commit 4c2809787cdbc774 (ovsdb-monitor: add json cache) introduced
an optimization that allows jsonrpc session to share monitors.
However, the memory/show implementation was not updated to match the
implementation; it still assumes that each jsonrpc session uses its
own monitor, thus are likely to over reporting the number.

This patch fix the bug and reports the actual number of monitor used
by the ovsdb-server.

Signed-off-by: Andy Zhou <azhou@ovn.org>
Acked-by: Ben Pfaff <blp@ovn.org>
ovsdb/jsonrpc-server.c
ovsdb/monitor.c
ovsdb/monitor.h
ovsdb/ovsdb-server.c

index 20657025128d4c780096c4a97fec7f2d1e973a32..ee2026eb79ccfe38ba889796abe5b2f498da7051 100644 (file)
@@ -533,7 +533,6 @@ ovsdb_jsonrpc_session_get_memory_usage(const struct ovsdb_jsonrpc_session *s,
                                        struct simap *usage)
 {
     simap_increase(usage, "triggers", hmap_count(&s->triggers));
-    simap_increase(usage, "monitors", hmap_count(&s->monitors));
     simap_increase(usage, "backlog", jsonrpc_session_get_backlog(s->js));
 }
 
index 0dde54e2a628355320ccc6e42ad5efeeb1cc8095..5ae9cdbda4f39d1ee731e32a4fdcc39623acc33b 100644 (file)
@@ -1145,6 +1145,14 @@ ovsdb_monitor_destroy_callback(struct ovsdb_replica *replica)
     }
 }
 
+/* Add some memory usage statics for monitors into 'usage', for use with
+ * memory_report().  */
+void
+ovsdb_monitor_get_memory_usage(struct simap *usage)
+{
+    simap_put(usage, "monitors", hmap_count(&ovsdb_monitors));
+}
+
 static const struct ovsdb_replica_class ovsdb_jsonrpc_replica_class = {
     ovsdb_monitor_commit,
     ovsdb_monitor_destroy_callback,
index d6e9635e613c324f3fe0cbca43406bde466a8750..fb104354130c639e4ddd87b6e2c65b05c09d602f 100644 (file)
@@ -77,4 +77,6 @@ bool ovsdb_monitor_needs_flush(struct ovsdb_monitor *dbmon,
                                uint64_t next_transaction);
 
 void ovsdb_monitor_get_initial(const struct ovsdb_monitor *dbmon);
+
+void ovsdb_monitor_get_memory_usage(struct simap *usage);
 #endif
index 231ba2fb7dfad0fd72c4e19788256acaf40f831b..fa662b19abc5a50fb45f3a7e2cda650a8b6256b4 100644 (file)
@@ -35,6 +35,7 @@
 #include "jsonrpc-server.h"
 #include "list.h"
 #include "memory.h"
+#include "monitor.h"
 #include "ovsdb.h"
 #include "ovsdb-data.h"
 #include "ovsdb-types.h"
@@ -138,6 +139,7 @@ main_loop(struct ovsdb_jsonrpc_server *jsonrpc, struct shash *all_dbs,
 
             simap_init(&usage);
             ovsdb_jsonrpc_server_get_memory_usage(jsonrpc, &usage);
+            ovsdb_monitor_get_memory_usage(&usage);
             SHASH_FOR_EACH(node, all_dbs) {
                 struct db *db = node->data;
                 ovsdb_get_memory_usage(db->db, &usage);