From patchwork Thu Dec 17 17:05:48 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ilya Maximets X-Patchwork-Id: 1417793 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=openvswitch.org (client-ip=140.211.166.137; helo=fraxinus.osuosl.org; envelope-from=ovs-dev-bounces@openvswitch.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=ovn.org Received: from fraxinus.osuosl.org (smtp4.osuosl.org [140.211.166.137]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 4CxdgC0M5Sz9sW0 for ; Fri, 18 Dec 2020 04:05:59 +1100 (AEDT) Received: from localhost (localhost [127.0.0.1]) by fraxinus.osuosl.org (Postfix) with ESMTP id 70CDA87604; Thu, 17 Dec 2020 17:05:57 +0000 (UTC) X-Virus-Scanned: amavisd-new at osuosl.org Received: from fraxinus.osuosl.org ([127.0.0.1]) by localhost (.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id EHimNHb53_Sz; Thu, 17 Dec 2020 17:05:56 +0000 (UTC) Received: from lists.linuxfoundation.org (lf-lists.osuosl.org [140.211.9.56]) by fraxinus.osuosl.org (Postfix) with ESMTP id 5C47A875E0; Thu, 17 Dec 2020 17:05:56 +0000 (UTC) Received: from lf-lists.osuosl.org (localhost [127.0.0.1]) by lists.linuxfoundation.org (Postfix) with ESMTP id 4A089C0893; Thu, 17 Dec 2020 17:05:56 +0000 (UTC) X-Original-To: ovs-dev@openvswitch.org Delivered-To: ovs-dev@lists.linuxfoundation.org Received: from whitealder.osuosl.org (smtp1.osuosl.org [140.211.166.138]) by lists.linuxfoundation.org (Postfix) with ESMTP id 65EDCC013B for ; Thu, 17 Dec 2020 17:05:55 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by whitealder.osuosl.org (Postfix) with ESMTP id 5496F871CD for ; Thu, 17 Dec 2020 17:05:55 +0000 (UTC) X-Virus-Scanned: amavisd-new at osuosl.org Received: from whitealder.osuosl.org ([127.0.0.1]) by localhost (.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id figYHuUiFJFz for ; Thu, 17 Dec 2020 17:05:53 +0000 (UTC) X-Greylist: domain auto-whitelisted by SQLgrey-1.7.6 Received: from relay2-d.mail.gandi.net (relay2-d.mail.gandi.net [217.70.183.194]) by whitealder.osuosl.org (Postfix) with ESMTPS id D245487136 for ; Thu, 17 Dec 2020 17:05:52 +0000 (UTC) X-Originating-IP: 78.45.89.65 Received: from im-t490s.redhat.com (ip-78-45-89-65.net.upcbroadband.cz [78.45.89.65]) (Authenticated sender: i.maximets@ovn.org) by relay2-d.mail.gandi.net (Postfix) with ESMTPSA id 7FB7340005; Thu, 17 Dec 2020 17:05:50 +0000 (UTC) From: Ilya Maximets To: ovs-dev@openvswitch.org Date: Thu, 17 Dec 2020 18:05:48 +0100 Message-Id: <20201217170548.632020-1-i.maximets@ovn.org> X-Mailer: git-send-email 2.25.4 MIME-Version: 1.0 Cc: Ilya Maximets Subject: [ovs-dev] [PATCH ovn] Add memory reports to all OVN processes. X-BeenThere: ovs-dev@openvswitch.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: ovs-dev-bounces@openvswitch.org Sender: "dev" 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 --- 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(+) 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);