From patchwork Wed Feb 12 11:11:31 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Numan Siddique X-Patchwork-Id: 1236785 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 48HcRH0bt6z9s1x for ; Wed, 12 Feb 2020 22:11:54 +1100 (AEDT) Received: from localhost (localhost [127.0.0.1]) by fraxinus.osuosl.org (Postfix) with ESMTP id 3E6E885A73; Wed, 12 Feb 2020 11:11:53 +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 hosTq2Nss4iJ; Wed, 12 Feb 2020 11:11:52 +0000 (UTC) Received: from lists.linuxfoundation.org (lf-lists.osuosl.org [140.211.9.56]) by fraxinus.osuosl.org (Postfix) with ESMTP id 7A43884489; Wed, 12 Feb 2020 11:11:52 +0000 (UTC) Received: from lf-lists.osuosl.org (localhost [127.0.0.1]) by lists.linuxfoundation.org (Postfix) with ESMTP id 6A374C07FE; Wed, 12 Feb 2020 11:11:52 +0000 (UTC) X-Original-To: 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 C7678C0177 for ; Wed, 12 Feb 2020 11:11:49 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by whitealder.osuosl.org (Postfix) with ESMTP id C268A864A4 for ; Wed, 12 Feb 2020 11:11:49 +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 TImSdu3et2YK for ; Wed, 12 Feb 2020 11:11:48 +0000 (UTC) X-Greylist: domain auto-whitelisted by SQLgrey-1.7.6 Received: from relay11.mail.gandi.net (relay11.mail.gandi.net [217.70.178.231]) by whitealder.osuosl.org (Postfix) with ESMTPS id 0A2D286497 for ; Wed, 12 Feb 2020 11:11:47 +0000 (UTC) Received: from nummac.local (unknown [115.99.186.78]) (Authenticated sender: numans@ovn.org) by relay11.mail.gandi.net (Postfix) with ESMTPSA id 7A0E3100005; Wed, 12 Feb 2020 11:11:42 +0000 (UTC) From: numans@ovn.org To: dev@openvswitch.org Date: Wed, 12 Feb 2020 16:41:31 +0530 Message-Id: <20200212111131.374234-1-numans@ovn.org> X-Mailer: git-send-email 2.24.1 MIME-Version: 1.0 Subject: [ovs-dev] [PATCH ovn] ovn-controller: Fix memory issues due to lflow expr caching. 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" From: Numan Siddique The patch [1], which added caching of lflow expr introduced a memory leak. The patch [1] also didn't take care of deleting the expr from the cache for the deleted lflows. This results in those lflow exprs in cache hanging in forever. This patch also addresses these 2 issues. [1] - 8795bec737b9("ovn-controller: Cache logical flow expr tree for each lflow.") Fixes: 8795bec737b9("ovn-controller: Cache logical flow expr tree for each lflow.") Signed-off-by: Numan Siddique Acked-by: Dumitru Ceara --- controller/lflow.c | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/controller/lflow.c b/controller/lflow.c index 780aa9331..79d89131a 100644 --- a/controller/lflow.c +++ b/controller/lflow.c @@ -402,6 +402,11 @@ lflow_handle_changed_flows(struct lflow_ctx_in *l_ctx_in, /* Delete entries from lflow resource reference. */ lflow_resource_destroy_lflow(l_ctx_out->lfrr, &lflow->header_.uuid); + struct lflow_expr *le = + lflow_expr_get(l_ctx_out->lflow_expr_cache, lflow); + if (le) { + lflow_expr_delete(l_ctx_out->lflow_expr_cache, le); + } } } @@ -660,6 +665,8 @@ consider_logical_flow(const struct sbrec_logical_flow *lflow, expr = expr_normalize(expr); lflow_expr_add(l_ctx_out->lflow_expr_cache, lflow, expr); + } else { + expr_destroy(prereqs); } struct condition_aux cond_aux = { @@ -910,6 +917,21 @@ lflow_run(struct lflow_ctx_in *l_ctx_in, struct lflow_ctx_out *l_ctx_out) { COVERAGE_INC(lflow_run); + /* when lflow_run is called, it's possible that some of the logical flows + * are deleted. We need to delete the lflow expr cache for these lflows, + * otherwise, they will not be deleted at all. */ + const struct sbrec_logical_flow *lflow; + SBREC_LOGICAL_FLOW_TABLE_FOR_EACH_TRACKED (lflow, + l_ctx_in->logical_flow_table) { + if (sbrec_logical_flow_is_deleted(lflow)) { + struct lflow_expr *le = + lflow_expr_get(l_ctx_out->lflow_expr_cache, lflow); + if (le) { + lflow_expr_delete(l_ctx_out->lflow_expr_cache, le); + } + } + } + add_logical_flows(l_ctx_in, l_ctx_out); add_neighbor_flows(l_ctx_in->sbrec_port_binding_by_name, l_ctx_in->mac_binding_table, l_ctx_out->flow_table);