From patchwork Thu Sep 16 12:56:55 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lorenzo Bianconi X-Patchwork-Id: 1528824 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@ozlabs.org Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=LKpW7rYF; dkim-atps=neutral Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=openvswitch.org (client-ip=140.211.166.138; helo=smtp1.osuosl.org; envelope-from=ovs-dev-bounces@openvswitch.org; receiver=) Received: from smtp1.osuosl.org (smtp1.osuosl.org [140.211.166.138]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 4H9HD91Y0Mz9svs for ; Thu, 16 Sep 2021 22:57:12 +1000 (AEST) Received: from localhost (localhost [127.0.0.1]) by smtp1.osuosl.org (Postfix) with ESMTP id E8E92834FE; Thu, 16 Sep 2021 12:57:09 +0000 (UTC) X-Virus-Scanned: amavisd-new at osuosl.org Received: from smtp1.osuosl.org ([127.0.0.1]) by localhost (smtp1.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id itgcLCqB9p8l; Thu, 16 Sep 2021 12:57:08 +0000 (UTC) Received: from lists.linuxfoundation.org (lf-lists.osuosl.org [140.211.9.56]) by smtp1.osuosl.org (Postfix) with ESMTPS id 29DF082C1E; Thu, 16 Sep 2021 12:57:07 +0000 (UTC) Received: from lf-lists.osuosl.org (localhost [127.0.0.1]) by lists.linuxfoundation.org (Postfix) with ESMTP id ED892C000F; Thu, 16 Sep 2021 12:57:06 +0000 (UTC) X-Original-To: ovs-dev@openvswitch.org Delivered-To: ovs-dev@lists.linuxfoundation.org Received: from smtp1.osuosl.org (smtp1.osuosl.org [IPv6:2605:bc80:3010::138]) by lists.linuxfoundation.org (Postfix) with ESMTP id 81E9EC000D for ; Thu, 16 Sep 2021 12:57:05 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by smtp1.osuosl.org (Postfix) with ESMTP id 6328682F32 for ; Thu, 16 Sep 2021 12:57:05 +0000 (UTC) X-Virus-Scanned: amavisd-new at osuosl.org Received: from smtp1.osuosl.org ([127.0.0.1]) by localhost (smtp1.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id 211INmX-SsQ5 for ; Thu, 16 Sep 2021 12:57:04 +0000 (UTC) X-Greylist: domain auto-whitelisted by SQLgrey-1.8.0 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [216.205.24.124]) by smtp1.osuosl.org (Postfix) with ESMTPS id 72DAD82F76 for ; Thu, 16 Sep 2021 12:57:04 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1631797023; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=u65sOaaXUwFmYFIDJck0+RAmsKAQfoYsln6L1LnDOAM=; b=LKpW7rYFfeP2NXkiTXWs4KIwslbGU1BtJAaJEkurlUKEo0i4IPF9ZwWP4q7Lhd8Bo0b2lh 4hxppL8OqS0F3aeGN+TVbrGx5l4ZtbbtsJ+a8S1b9lh4TVakY3cUzD7vQjPAEVGm7+at6E POzWnKuVNlg4QNtx+30CEGMrVDDFQb0= Received: from mail-ed1-f71.google.com (mail-ed1-f71.google.com [209.85.208.71]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-577-GeXUpKElMdOzXJQH4kOZhw-1; Thu, 16 Sep 2021 08:56:59 -0400 X-MC-Unique: GeXUpKElMdOzXJQH4kOZhw-1 Received: by mail-ed1-f71.google.com with SMTP id r11-20020aa7cfcb000000b003d4fbd652b9so5315522edy.14 for ; Thu, 16 Sep 2021 05:56:59 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=u65sOaaXUwFmYFIDJck0+RAmsKAQfoYsln6L1LnDOAM=; b=cQvYqC9zCcwxFwffsZJbRM0BwyxB4oNSryTAKc7n03lUuEof22egOVKcbsQ6/hetpV M/TgXLPwkPjLn/Dch8US3L7uT9MK+8KJiNxGTFG436lg7JSRqgH0mfFbn4oPNDl0qTpT iu3cDff/zdBU0MfCT0v4nnP/R32Y2zH0hVoZbzq9OaJNg5jZaSweswK+dPFlJybxx78j PU1XlenCxhj79iCS78FmA4DZvEa8g/zi6hUQ/ZfaNGA3fe78NUCNSIALFna2No7nvZIV xsd9o1hK3m08xaDhr1jPKa7KwmqpqB11w2j14fuPmU17bechI7Nq9HiUBjFjS5VVDeKV kr3g== X-Gm-Message-State: AOAM532aGudhflvrcDzI8wyPTQIgFxQXDg0pvzlNuwT9vJ3fVuA5qfZa d7Aw3xtzG9sLv5qLUl98BT7kDYLtkAQ1GG5/bdBgpMqwNwALN7VO6EnZdWpnlfLTjUOy+m6QLJb o/bIfd8peflB28/yudc4zaz8g0Tpg5Xy3sQ714UVWCYg70ZNdoajM0FhKPoiQ85cSYMuSeN3vnl lXek0H X-Received: by 2002:a50:d8c9:: with SMTP id y9mr4548993edj.79.1631797018371; Thu, 16 Sep 2021 05:56:58 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwBjvn/z/38twR5kGG3+RV9bhVc7uoIdWu7bW+a5DCLJCwO8RbK39Ae4Kh94KYre/sqd2C3uw== X-Received: by 2002:a50:d8c9:: with SMTP id y9mr4548976edj.79.1631797018129; Thu, 16 Sep 2021 05:56:58 -0700 (PDT) Received: from lore-desk.redhat.com (net-130-25-199-50.cust.vodafonedsl.it. [130.25.199.50]) by smtp.gmail.com with ESMTPSA id dc8sm1390114edb.28.2021.09.16.05.56.57 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 16 Sep 2021 05:56:57 -0700 (PDT) From: Lorenzo Bianconi To: ovs-dev@openvswitch.org Date: Thu, 16 Sep 2021 14:56:55 +0200 Message-Id: X-Mailer: git-send-email 2.31.1 MIME-Version: 1.0 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=lorenzo.bianconi@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Cc: dceara@redhat.com Subject: [ovs-dev] [PATCH ovn] controller: add memory accounting for if_status_mgr module 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" Introduce memory accounting for data structures in ovn-controller if_status_mgr module. Signed-off-by: Lorenzo Bianconi --- controller/if-status.c | 23 +++++++++++++++++++++++ controller/if-status.h | 3 +++ controller/ovn-controller.c | 1 + 3 files changed, 27 insertions(+) diff --git a/controller/if-status.c b/controller/if-status.c index 08fb50b87..cd544f9ff 100644 --- a/controller/if-status.c +++ b/controller/if-status.c @@ -18,6 +18,7 @@ #include "binding.h" #include "if-status.h" #include "ofctrl-seqno.h" +#include "simap.h" #include "lib/hmapx.h" #include "lib/util.h" @@ -85,6 +86,8 @@ struct ovs_iface { */ }; +static uint64_t ifaces_usage; + /* State machine manager for all local OVS interfaces. */ struct if_status_mgr { /* All local interfaces, mapping from 'iface-id' to 'struct ovs_iface'. */ @@ -345,6 +348,8 @@ ovs_iface_create(struct if_status_mgr *mgr, const char *iface_id, iface->id = xstrdup(iface_id); shash_add(&mgr->ifaces, iface_id, iface); ovs_iface_set_state(mgr, iface, state); + ifaces_usage += (strlen(iface_id) + sizeof *iface + + sizeof(struct shash_node)); return iface; } @@ -355,6 +360,8 @@ ovs_iface_destroy(struct if_status_mgr *mgr, struct ovs_iface *iface) if_state_names[iface->state]); hmapx_find_and_delete(&mgr->ifaces_per_state[iface->state], iface); shash_find_and_delete(&mgr->ifaces, iface->id); + ifaces_usage -= (strlen(iface->id) + sizeof *iface + + sizeof(struct shash_node)); free(iface->id); free(iface); } @@ -413,3 +420,19 @@ if_status_mgr_update_bindings(struct if_status_mgr *mgr, local_binding_set_down(bindings, iface->id, sb_readonly, ovs_readonly); } } + +void +if_status_mgr_get_memory_usage(struct if_status_mgr *mgr, + struct simap *usage) +{ + uint64_t ifaces_state_usage = 0; + for (size_t i = 0; i < ARRAY_SIZE(mgr->ifaces_per_state); i++) { + ifaces_state_usage += sizeof(struct hmapx_node) * + hmapx_count(&mgr->ifaces_per_state[i]); + } + + simap_increase(usage, "if_status_mgr_ifaces_usage-KB", + ROUND_UP(ifaces_usage, 1024) / 1024); + simap_increase(usage, "if_status_mgr_ifaces_state_usage-KB", + ROUND_UP(ifaces_state_usage, 1024) / 1024); +} diff --git a/controller/if-status.h b/controller/if-status.h index 51fe7c684..ff4aa760e 100644 --- a/controller/if-status.h +++ b/controller/if-status.h @@ -21,6 +21,7 @@ #include "binding.h" struct if_status_mgr; +struct simap; struct if_status_mgr *if_status_mgr_create(void); void if_status_mgr_clear(struct if_status_mgr *); @@ -33,5 +34,7 @@ void if_status_mgr_delete_iface(struct if_status_mgr *, const char *iface_id); void if_status_mgr_update(struct if_status_mgr *, struct local_binding_data *); void if_status_mgr_run(struct if_status_mgr *mgr, struct local_binding_data *, bool sb_readonly, bool ovs_readonly); +void if_status_mgr_get_memory_usage(struct if_status_mgr *mgr, + struct simap *usage); # endif /* controller/if-status.h */ diff --git a/controller/ovn-controller.c b/controller/ovn-controller.c index 0031a1035..fabe5e8c0 100644 --- a/controller/ovn-controller.c +++ b/controller/ovn-controller.c @@ -3457,6 +3457,7 @@ main(int argc, char *argv[]) lflow_cache_get_memory_usage(ctrl_engine_ctx.lflow_cache, &usage); ofctrl_get_memory_usage(&usage); + if_status_mgr_get_memory_usage(if_mgr, &usage); memory_report(&usage); simap_destroy(&usage); }