[ovs-dev] [PATCH v5 ovn] controller: add memory accounting for local_datapath

Numan Siddique numans at ovn.org
Wed Nov 17 22:24:37 UTC 2021


On Fri, Nov 5, 2021 at 9:40 AM Dumitru Ceara <dceara at redhat.com> wrote:
>
> On 10/21/21 11:47 AM, Lorenzo Bianconi wrote:
> > Similar to if-status-mgr, track memory allocated for local_datapath.
> >
> > Signed-off-by: Lorenzo Bianconi <lorenzo.bianconi at redhat.com>
> > ---
>
> Looks good to me, thanks!
>
> Acked-by: Dumitru Ceara <dceara at redhat.com>

Thanks Lorenzo and Dumitru.

I applied this patch to the main branch.  Before applying I did the
below changes which just reorganizes the code.

--------------
diff --git a/controller/local_data.c b/controller/local_data.c
index 251ed294f..86050f335 100644
--- a/controller/local_data.c
+++ b/controller/local_data.c
@@ -41,6 +41,9 @@ static void add_local_datapath__(
     int depth, const struct sbrec_datapath_binding *,
     const struct sbrec_chassis *, struct hmap *local_datapaths,
     struct hmap *tracked_datapaths);
+static void local_datapath_peer_port_add(
+    struct local_datapath *, const struct sbrec_port_binding *local,
+    const struct sbrec_port_binding *remote);

 static struct tracked_datapath *tracked_datapath_create(
     const struct sbrec_datapath_binding *dp,
@@ -161,26 +164,6 @@ add_local_datapath(struct ovsdb_idl_index
*sbrec_datapath_binding_by_key,
                          tracked_datapaths);
 }

-static void
-local_datapath_peer_port_add(struct local_datapath *ld,
-                             const struct sbrec_port_binding *local,
-                             const struct sbrec_port_binding *remote)
-{
-    ld->n_peer_ports++;
-    if (ld->n_peer_ports > ld->n_allocated_peer_ports) {
-        size_t old_n_ports = ld->n_allocated_peer_ports;
-        ld->peer_ports =
-            x2nrealloc(ld->peer_ports,
-                       &ld->n_allocated_peer_ports,
-                       sizeof *ld->peer_ports);
-        local_datapath_usage +=
-            (ld->n_allocated_peer_ports - old_n_ports) *
-            sizeof *ld->peer_ports;
-    }
-    ld->peer_ports[ld->n_peer_ports - 1].local = local;
-    ld->peer_ports[ld->n_peer_ports - 1].remote = remote;
-}
-
 void
 add_local_datapath_peer_port(
     const struct sbrec_port_binding *pb,
@@ -287,6 +270,13 @@ remove_local_datapath_external_port(struct
local_datapath *ld,
     }
 }

+void
+local_datapath_memory_usage(struct simap *usage)
+{
+    simap_increase(usage, "local_datapath_usage-KB",
+                   ROUND_UP(local_datapath_usage, 1024) / 1024);
+}
+
 /* track datapath functions. */
 struct tracked_datapath *
 tracked_datapath_add(const struct sbrec_datapath_binding *dp,
@@ -595,9 +585,22 @@ tracked_datapath_create(const struct
sbrec_datapath_binding *dp,
     return t_dp;
 }

-void
-local_datapath_memory_usage(struct simap *usage)
+static void
+local_datapath_peer_port_add(struct local_datapath *ld,
+                             const struct sbrec_port_binding *local,
+                             const struct sbrec_port_binding *remote)
 {
-    simap_increase(usage, "local_datapath_usage-KB",
-                   ROUND_UP(local_datapath_usage, 1024) / 1024);
+    ld->n_peer_ports++;
+    if (ld->n_peer_ports > ld->n_allocated_peer_ports) {
+        size_t old_n_ports = ld->n_allocated_peer_ports;
+        ld->peer_ports =
+            x2nrealloc(ld->peer_ports,
+                       &ld->n_allocated_peer_ports,
+                       sizeof *ld->peer_ports);
+        local_datapath_usage +=
+            (ld->n_allocated_peer_ports - old_n_ports) *
+            sizeof *ld->peer_ports;
+    }
+    ld->peer_ports[ld->n_peer_ports - 1].local = local;
+    ld->peer_ports[ld->n_peer_ports - 1].remote = remote;
 }
diff --git a/controller/local_data.h b/controller/local_data.h
index 6e7253738..287f95af0 100644
--- a/controller/local_data.h
+++ b/controller/local_data.h
@@ -150,11 +150,9 @@ bool get_chassis_tunnel_ofport(const struct hmap
*chassis_tunnels,

 void chassis_tunnels_destroy(struct hmap *chassis_tunnels);
 void local_datapath_memory_usage(struct simap *usage);
-void
-add_local_datapath_external_port(struct local_datapath *ld,
-                                 char *logical_port, const void *data);
-void
-remove_local_datapath_external_port(struct local_datapath *ld,
-                                    char *logical_port);
+void add_local_datapath_external_port(struct local_datapath *ld,
+                                      char *logical_port, const void *data);
+void remove_local_datapath_external_port(struct local_datapath *ld,
+                                         char *logical_port);

------------------

Thanks
Numan

>
>
> _______________________________________________
> dev mailing list
> dev at openvswitch.org
> https://mail.openvswitch.org/mailman/listinfo/ovs-dev
>


More information about the dev mailing list