diff mbox series

[ovs-dev] Add memory reports to all OVN processes.

Message ID 20201217170548.632020-1-i.maximets@ovn.org
State Superseded
Headers show
Series [ovs-dev] Add memory reports to all OVN processes. | expand

Commit Message

Ilya Maximets Dec. 17, 2020, 5:05 p.m. UTC
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>
---
 controller-vtep/ovn-controller-vtep.c | 10 ++++++++++
 controller/ovn-controller.c           | 11 +++++++++++
 ic/ovn-ic.c                           | 11 +++++++++++
 northd/ovn-northd.c                   | 11 +++++++++++
 utilities/ovn-nbctl.c                 | 11 +++++++++++
 5 files changed, 54 insertions(+)

Comments

Ilya Maximets Dec. 17, 2020, 6:15 p.m. UTC | #1
On 12/17/20 6:05 PM, Ilya Maximets wrote:
> 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>
> ---
>  controller-vtep/ovn-controller-vtep.c | 10 ++++++++++
>  controller/ovn-controller.c           | 11 +++++++++++
>  ic/ovn-ic.c                           | 11 +++++++++++
>  northd/ovn-northd.c                   | 11 +++++++++++
>  utilities/ovn-nbctl.c                 | 11 +++++++++++
>  5 files changed, 54 insertions(+)

Sorry, forgot to add calls to memory_wait().  Fixed in v2:

https://patchwork.ozlabs.org/project/ovn/patch/20201217181427.639377-1-i.maximets@ovn.org/

best regards, Ilya Maximets.
diff mbox series

Patch

diff --git a/controller-vtep/ovn-controller-vtep.c b/controller-vtep/ovn-controller-vtep.c
index c13280bc0..b736b5f39 100644
--- a/controller-vtep/ovn-controller-vtep.c
+++ b/controller-vtep/ovn-controller-vtep.c
@@ -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,6 +101,14 @@  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);
diff --git a/controller/ovn-controller.c b/controller/ovn-controller.c
index 366fc9c06..70f1923b7 100644
--- a/controller/ovn-controller.c
+++ b/controller/ovn-controller.c
@@ -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.
          */
diff --git a/ic/ovn-ic.c b/ic/ovn-ic.c
index db9ef88da..eb8028728 100644
--- a/ic/ovn-ic.c
+++ b/ic/ovn-ic.c
@@ -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))
diff --git a/northd/ovn-northd.c b/northd/ovn-northd.c
index b377dffa1..8dd928743 100644
--- a/northd/ovn-northd.c
+++ b/northd/ovn-northd.c
@@ -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))
diff --git a/utilities/ovn-nbctl.c b/utilities/ovn-nbctl.c
index 94e7eedeb..33ea1101b 100644
--- a/utilities/ovn-nbctl.c
+++ b/utilities/ovn-nbctl.c
@@ -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);