summaryrefslogtreecommitdiff
path: root/vswitchd
diff options
context:
space:
mode:
authorBen Pfaff <blp@nicira.com>2012-05-08 15:44:21 -0700
committerBen Pfaff <blp@nicira.com>2012-05-22 10:32:05 -0700
commit0d085684619be0baef309957a3d7410a23cb5f27 (patch)
tree212ad7c9bd8e67c80065da7ed1968f6a5bd5af61 /vswitchd
parent44bac24ba5d22fe238bd96702707eb2029efec41 (diff)
downloadopenvswitch-0d085684619be0baef309957a3d7410a23cb5f27.tar.gz
Add support for tracking and logging daemon memory usage.
Signed-off-by: Ben Pfaff <blp@nicira.com>
Diffstat (limited to 'vswitchd')
-rw-r--r--vswitchd/bridge.c12
-rw-r--r--vswitchd/bridge.h6
-rw-r--r--vswitchd/ovs-vswitchd.c12
3 files changed, 29 insertions, 1 deletions
diff --git a/vswitchd/bridge.c b/vswitchd/bridge.c
index 0c78f946c..d72095207 100644
--- a/vswitchd/bridge.c
+++ b/vswitchd/bridge.c
@@ -2228,6 +2228,18 @@ bridge_wait(void)
}
}
}
+
+/* Adds some memory usage statistics for bridges into 'usage', for use with
+ * memory_report(). */
+void
+bridge_get_memory_usage(struct simap *usage)
+{
+ struct bridge *br;
+
+ HMAP_FOR_EACH (br, node, &all_bridges) {
+ ofproto_get_memory_usage(br->ofproto, usage);
+ }
+}
/* QoS unixctl user interface functions. */
diff --git a/vswitchd/bridge.h b/vswitchd/bridge.h
index ecd6ff5f0..c1b0a2b52 100644
--- a/vswitchd/bridge.h
+++ b/vswitchd/bridge.h
@@ -1,4 +1,4 @@
-/* Copyright (c) 2008, 2009, 2010, 2011 Nicira, Inc.
+/* Copyright (c) 2008, 2009, 2010, 2011, 2012 Nicira, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -16,6 +16,8 @@
#ifndef VSWITCHD_BRIDGE_H
#define VSWITCHD_BRIDGE_H 1
+struct simap;
+
void bridge_init(const char *remote);
void bridge_exit(void);
@@ -23,4 +25,6 @@ void bridge_run(void);
void bridge_run_fast(void);
void bridge_wait(void);
+void bridge_get_memory_usage(struct simap *usage);
+
#endif /* bridge.h */
diff --git a/vswitchd/ovs-vswitchd.c b/vswitchd/ovs-vswitchd.c
index f97df8d62..8ef3b10e7 100644
--- a/vswitchd/ovs-vswitchd.c
+++ b/vswitchd/ovs-vswitchd.c
@@ -34,12 +34,14 @@
#include "dpif.h"
#include "dummy.h"
#include "leak-checker.h"
+#include "memory.h"
#include "netdev.h"
#include "openflow/openflow.h"
#include "ovsdb-idl.h"
#include "poll-loop.h"
#include "process.h"
#include "signals.h"
+#include "simap.h"
#include "stream-ssl.h"
#include "stream.h"
#include "stress.h"
@@ -93,6 +95,15 @@ main(int argc, char *argv[])
if (signal_poll(sighup)) {
vlog_reopen_log_file();
}
+ memory_run();
+ if (memory_should_report()) {
+ struct simap usage;
+
+ simap_init(&usage);
+ bridge_get_memory_usage(&usage);
+ memory_report(&usage);
+ simap_destroy(&usage);
+ }
bridge_run_fast();
bridge_run();
bridge_run_fast();
@@ -100,6 +111,7 @@ main(int argc, char *argv[])
netdev_run();
signal_wait(sighup);
+ memory_wait();
bridge_wait();
unixctl_server_wait(unixctl);
netdev_wait();