[ovs-dev] [PATCH v3 ovn 4/4] controller: binding: add memory accounting for local_lports and related_lports

Dumitru Ceara dceara at redhat.com
Fri Oct 8 14:50:57 UTC 2021


On 9/25/21 12:19 AM, Lorenzo Bianconi wrote:
> Introduce memory accounting for:
> - binding local_lports map
> - binding related_lports map
> 
> Signed-off-by: Lorenzo Bianconi <lorenzo.bianconi at redhat.com>
> ---
>  controller/binding.c        | 59 +++++++++++++++++++++++++++++++++++++
>  controller/binding.h        |  5 ++++
>  controller/ovn-controller.c |  5 ++--
>  3 files changed, 67 insertions(+), 2 deletions(-)
> 
> diff --git a/controller/binding.c b/controller/binding.c
> index 661b4bb24..ec1e8bec7 100644
> --- a/controller/binding.c
> +++ b/controller/binding.c
> @@ -39,6 +39,31 @@
>  
>  VLOG_DEFINE_THIS_MODULE(binding);
>  
> +static uint64_t local_lports_usage;
> +static uint64_t related_lports_usage;
> +
> +static void
> +sset_mem_update(uint64_t *usage, struct sset *set,
> +                const char *name, bool erase)
> +{
> +    struct sset_node *node = sset_find(set, name);
> +
> +    if (!node && !erase) { /* add new element */
> +        *usage += (sizeof *node + strlen(name));
> +    } else if (node && erase) { /* remove an element */
> +        *usage -= (sizeof *node + strlen(name));
> +    }
> +}
> +
> +static void
> +sset_mem_clear(struct sset *set, uint64_t *usage)
> +{
> +    const char *name;
> +    SSET_FOR_EACH (name, set) {
> +        sset_mem_update(usage, set, name, true);
> +    }
> +}
> +

I'm not too sure about this.  These functions are very generic.  I think
this should be part of the sset code itself.  Maybe a sset should just
automatically (or if configured) track all the memory it owns?  What do
you think?

Thanks,
Dumitru



More information about the dev mailing list