On 11/2/21 20:50, Dumitru Ceara wrote:
> On 10/14/21 1:46 PM, Ilya Maximets wrote:
>> Added new function to return memory usage statistics for database
>> objects inside IDL.  Statistics similar to what ovsdb-server reports.
>> Not counting _Server database as it should be small, hence doesn't
>> worth adding extra code to the ovsdb-cs module.  Can be added later
>> if needed.
>>
>> ovs-vswitchd is a user in OVS, but this API will be mostly useful for
>> OVN daemons.
>>
>> Signed-off-by: Ilya Maximets <i.maxim...@ovn.org>
>> ---
>>  lib/ovsdb-idl.c   | 24 ++++++++++++++++++++++++
>>  lib/ovsdb-idl.h   |  3 +++
>>  vswitchd/bridge.c |  2 ++
>>  3 files changed, 29 insertions(+)
>>
>> diff --git a/lib/ovsdb-idl.c b/lib/ovsdb-idl.c
>> index 383a601f6..b22492d5e 100644
>> --- a/lib/ovsdb-idl.c
>> +++ b/lib/ovsdb-idl.c
>> @@ -42,6 +42,7 @@
>>  #include "openvswitch/poll-loop.h"
>>  #include "openvswitch/shash.h"
>>  #include "skiplist.h"
>> +#include "simap.h"
>>  #include "sset.h"
>>  #include "svec.h"
>>  #include "util.h"
>> @@ -465,6 +466,29 @@ ovsdb_idl_wait(struct ovsdb_idl *idl)
>>      ovsdb_cs_wait(idl->cs);
>>  }
>>  
>> +/* Returns memory usage statistics. */
>> +void
>> +ovsdb_idl_get_memory_usage(struct ovsdb_idl *idl, struct simap *usage)
>> +{
>> +    unsigned int cells = 0;
>> +
>> +    if (!idl) {
>> +        return;
>> +    }
>> +
>> +    for (size_t i = 0; i < idl->class_->n_tables; i++) {
>> +        struct ovsdb_idl_table *table = &idl->tables[i];
>> +        unsigned int n_columns = shash_count(&table->columns);
> 
> Nit: even though this is also constant time we already have the number
> of columns stored in the table class, we could instead do:
> 
> unsigned int n_columns = table->class_->n_columns;
> 
> I guess this can be fixed up at apply time, therefore:
> 
> Acked-by: Dumitru Ceara <dce...@redhat.com>

Thanks, Han and Dumitru!
I made the above change and applied the patch.

Best regards, Ilya Maximets.
_______________________________________________
dev mailing list
d...@openvswitch.org
https://mail.openvswitch.org/mailman/listinfo/ovs-dev

Reply via email to