@@ -25,9 +25,11 @@
#include "compiler.h"
#include "daemon.h"
#include "dirs.h"
+#include "memory.h"
#include "openvswitch/dynamic-string.h"
#include "fatal-signal.h"
#include "openvswitch/poll-loop.h"
+#include "simap.h"
#include "stream.h"
#include "stream-ssl.h"
#include "unixctl.h"
@@ -99,12 +101,21 @@ main(int argc, char *argv[])
.ovnsb_idl_txn = ovsdb_idl_loop_run(&ovnsb_idl_loop),
};
+ memory_run();
+ if (memory_should_report()) {
+ struct simap usage = SIMAP_INITIALIZER(&usage);
+
+ /* Nothing special to report yet. */
+ memory_report(&usage);
+ simap_destroy(&usage);
+ }
gateway_run(&ctx);
binding_run(&ctx);
vtep_run(&ctx);
unixctl_server_run(unixctl);
unixctl_server_wait(unixctl);
+ memory_wait();
if (exiting) {
poll_immediate_wake();
}
@@ -38,6 +38,7 @@
#include "lflow.h"
#include "lib/vswitch-idl.h"
#include "lport.h"
+#include "memory.h"
#include "ofctrl.h"
#include "openvswitch/vconn.h"
#include "openvswitch/vlog.h"
@@ -54,6 +55,7 @@
#include "openvswitch/poll-loop.h"
#include "lib/bitmap.h"
#include "lib/hash.h"
+#include "simap.h"
#include "smap.h"
#include "sset.h"
#include "stream-ssl.h"
@@ -2679,6 +2681,15 @@ main(int argc, char *argv[])
restart = false;
bool sb_monitor_all = false;
while (!exiting) {
+ memory_run();
+ if (memory_should_report()) {
+ struct simap usage = SIMAP_INITIALIZER(&usage);
+
+ /* Nothing special to report yet. */
+ memory_report(&usage);
+ simap_destroy(&usage);
+ }
+
/* If we're paused just run the unixctl server and skip most of the
* processing loop.
*/
@@ -2960,6 +2971,7 @@ main(int argc, char *argv[])
ovsdb_idl_track_clear(ovs_idl_loop.idl);
loop_done:
+ memory_wait();
poll_block();
if (should_service_stop()) {
exiting = true;
@@ -33,7 +33,9 @@
#include "lib/ovn-nb-idl.h"
#include "lib/ovn-sb-idl.h"
#include "lib/ovn-util.h"
+#include "memory.h"
#include "openvswitch/poll-loop.h"
+#include "simap.h"
#include "smap.h"
#include "sset.h"
#include "stream.h"
@@ -1653,6 +1655,15 @@ main(int argc, char *argv[])
state.had_lock = false;
state.paused = false;
while (!exiting) {
+ memory_run();
+ if (memory_should_report()) {
+ struct simap usage = SIMAP_INITIALIZER(&usage);
+
+ /* Nothing special to report yet. */
+ memory_report(&usage);
+ simap_destroy(&usage);
+ }
+
if (!state.paused) {
if (!ovsdb_idl_has_lock(ovnsb_idl_loop.idl) &&
!ovsdb_idl_is_lock_contended(ovnsb_idl_loop.idl))
@@ -1727,6 +1738,7 @@ main(int argc, char *argv[])
unixctl_server_run(unixctl);
unixctl_server_wait(unixctl);
+ memory_wait();
if (exiting) {
poll_immediate_wake();
}
@@ -37,10 +37,12 @@
#include "lib/ovn-sb-idl.h"
#include "lib/ovn-util.h"
#include "lib/lb.h"
+#include "memory.h"
#include "ovn/actions.h"
#include "ovn/logical-fields.h"
#include "packets.h"
#include "openvswitch/poll-loop.h"
+#include "simap.h"
#include "smap.h"
#include "sset.h"
#include "svec.h"
@@ -13486,6 +13488,15 @@ main(int argc, char *argv[])
state.had_lock = false;
state.paused = false;
while (!exiting) {
+ memory_run();
+ if (memory_should_report()) {
+ struct simap usage = SIMAP_INITIALIZER(&usage);
+
+ /* Nothing special to report yet. */
+ memory_report(&usage);
+ simap_destroy(&usage);
+ }
+
if (!state.paused) {
if (!ovsdb_idl_has_lock(ovnsb_idl_loop.idl) &&
!ovsdb_idl_is_lock_contended(ovnsb_idl_loop.idl))
@@ -13557,6 +13568,7 @@ main(int argc, char *argv[])
unixctl_server_run(unixctl);
unixctl_server_wait(unixctl);
+ memory_wait();
if (exiting) {
poll_immediate_wake();
}
@@ -29,9 +29,11 @@
#include "lib/acl-log.h"
#include "lib/ovn-nb-idl.h"
#include "lib/ovn-util.h"
+#include "memory.h"
#include "packets.h"
#include "openvswitch/poll-loop.h"
#include "process.h"
+#include "simap.h"
#include "smap.h"
#include "sset.h"
#include "stream.h"
@@ -6825,6 +6827,15 @@ server_loop(struct ovsdb_idl *idl, int argc, char *argv[])
server_cmd_init(idl, &exiting);
for (;;) {
+ memory_run();
+ if (memory_should_report()) {
+ struct simap usage = SIMAP_INITIALIZER(&usage);
+
+ /* Nothing special to report yet. */
+ memory_report(&usage);
+ simap_destroy(&usage);
+ }
+
ovsdb_idl_run(idl);
if (!ovsdb_idl_is_alive(idl)) {
int retval = ovsdb_idl_get_last_error(idl);
@@ -6840,6 +6851,7 @@ server_loop(struct ovsdb_idl *idl, int argc, char *argv[])
break;
}
+ memory_wait();
ovsdb_idl_wait(idl);
unixctl_server_wait(server);
poll_block();
It is important to have memory reports in logs to track the state of OVN daemons. With this change we will see the dynamic of the memory consumption. We have no any specific information to report yet, but we have to call memory_report() to reply to all the incoming 'memory/show' requests. Not documenting 'memory/show' command as there is nothing to report there yet. This change will only add reports about memory usage growth to logs, e.g.: |memory|INFO|peak resident set size grew 50% in last 8 seconds, from 27548 kB to 41336 kB Signed-off-by: Ilya Maximets <i.maximets@ovn.org> --- Version 2: - Added forgotten memory_wait() calls. Oops. Wihtout them accidential call to 'memory/show' might hang. controller-vtep/ovn-controller-vtep.c | 11 +++++++++++ controller/ovn-controller.c | 12 ++++++++++++ ic/ovn-ic.c | 12 ++++++++++++ northd/ovn-northd.c | 12 ++++++++++++ utilities/ovn-nbctl.c | 12 ++++++++++++ 5 files changed, 59 insertions(+)