Skip to content

Commit

Permalink
ovsdb-server: fix monitor counters reported by memory/show
Browse files Browse the repository at this point in the history
Commit 4c28097 (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 <[email protected]>
Acked-by: Ben Pfaff <[email protected]>
  • Loading branch information
azhou-nicira committed Feb 5, 2016
1 parent 9aad5a5 commit e0c73ed
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 1 deletion.
1 change: 0 additions & 1 deletion ovsdb/jsonrpc-server.c
Original file line number Diff line number Diff line change
Expand Up @@ -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));
}

Expand Down
8 changes: 8 additions & 0 deletions ovsdb/monitor.c
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
2 changes: 2 additions & 0 deletions ovsdb/monitor.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
2 changes: 2 additions & 0 deletions ovsdb/ovsdb-server.c
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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);
Expand Down

0 comments on commit e0c73ed

Please sign in to comment.