From patchwork Wed Sep 16 18:01:23 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Han Zhou X-Patchwork-Id: 1365742 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 4BsJkP5Y3rz9sSW for ; Thu, 17 Sep 2020 11:08:29 +1000 (AEST) Received: from localhost (localhost [127.0.0.1]) by fraxinus.osuosl.org (Postfix) with ESMTP id A0BBB86C4F; Wed, 16 Sep 2020 18:01:46 +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 Yxe1bL-4L5s7; Wed, 16 Sep 2020 18:01:46 +0000 (UTC) Received: from lists.linuxfoundation.org (lf-lists.osuosl.org [140.211.9.56]) by fraxinus.osuosl.org (Postfix) with ESMTP id 10710845D5; Wed, 16 Sep 2020 18:01:46 +0000 (UTC) Received: from lf-lists.osuosl.org (localhost [127.0.0.1]) by lists.linuxfoundation.org (Postfix) with ESMTP id EB6C5C0864; Wed, 16 Sep 2020 18:01:45 +0000 (UTC) X-Original-To: dev@openvswitch.org Delivered-To: ovs-dev@lists.linuxfoundation.org Received: from fraxinus.osuosl.org (smtp4.osuosl.org [140.211.166.137]) by lists.linuxfoundation.org (Postfix) with ESMTP id 6F640C0051 for ; Wed, 16 Sep 2020 18:01:44 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by fraxinus.osuosl.org (Postfix) with ESMTP id 689BC86C43 for ; Wed, 16 Sep 2020 18:01:44 +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 rnONj1ZQXZMk for ; Wed, 16 Sep 2020 18:01:43 +0000 (UTC) X-Greylist: domain auto-whitelisted by SQLgrey-1.7.6 Received: from relay1-d.mail.gandi.net (relay1-d.mail.gandi.net [217.70.183.193]) by fraxinus.osuosl.org (Postfix) with ESMTPS id 3B059845D5 for ; Wed, 16 Sep 2020 18:01:43 +0000 (UTC) X-Originating-IP: 73.241.94.255 Received: from localhost.localdomain.localdomain (unknown [73.241.94.255]) (Authenticated sender: hzhou@ovn.org) by relay1-d.mail.gandi.net (Postfix) with ESMTPSA id 8BB8B240008; Wed, 16 Sep 2020 18:01:40 +0000 (UTC) From: Han Zhou To: dev@openvswitch.org Date: Wed, 16 Sep 2020 11:01:23 -0700 Message-Id: <1600279283-7597-2-git-send-email-hzhou@ovn.org> X-Mailer: git-send-email 2.1.0 In-Reply-To: <1600279283-7597-1-git-send-email-hzhou@ovn.org> References: <1600279283-7597-1-git-send-email-hzhou@ovn.org> Cc: Han Zhou Subject: [ovs-dev] [PATCH ovn v3 2/2] lflow.c: Release ref_lflow_node as soon as it is not needed. 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: , MIME-Version: 1.0 Errors-To: ovs-dev-bounces@openvswitch.org Sender: "dev" If a resource doesn't have any lflows referencing it any more, the node ref_lflow_node in lflow_resource_ref.ref_lflow_table should be removed and released. Otherwise, the table could keep growing in some scenarios, until a recompute is triggered. Now that the chance of triggering recompute is lower and there are more resources references maintained (for type port-binding), this problem is more likely to happen than before. This patch fixes the problem by releasing the node as soon as it is not needed. Fixes: d2aa2c7cafe ("ovn-controller: Maintain resource references for logical flows.") Signed-off-by: Han Zhou Acked-by: Dumitru Ceara Acked-by: Numan Siddique --- controller/lflow.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/controller/lflow.c b/controller/lflow.c index db078d2..b549067 100644 --- a/controller/lflow.c +++ b/controller/lflow.c @@ -292,6 +292,10 @@ lflow_resource_destroy_lflow(struct lflow_resource_ref *lfrr, LIST_FOR_EACH_SAFE (lrln, next, list_node, &lfrn->lflow_ref_head) { ovs_list_remove(&lrln->list_node); hmap_remove(&lrln->rlfn->lflow_uuids, &lrln->hmap_node); + if (hmap_is_empty(&lrln->rlfn->lflow_uuids)) { + hmap_remove(&lfrr->ref_lflow_table, &lrln->rlfn->node); + ref_lflow_node_destroy(lrln->rlfn); + } free(lrln); } free(lfrn);