[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <41d16737-6bdc-2def-402d-04d69127faf9@mojatatu.com>
Date: Fri, 9 Jun 2023 15:13:40 -0300
From: Pedro Tammela <pctammela@...atatu.com>
To: Jakub Kicinski <kuba@...nel.org>
Cc: netdev@...r.kernel.org, tgraf@...g.ch, herbert@...dor.apana.org.au,
davem@...emloft.net, dsahern@...nel.org, edumazet@...gle.com,
pabeni@...hat.com
Subject: Re: [RFC PATCH net-next 0/4] rhashtable: length helper for rhashtable
and rhltable
On 09/06/2023 14:36, Jakub Kicinski wrote:
> On Fri, 9 Jun 2023 12:13:28 -0300 Pedro Tammela wrote:
>> Whenever someone wants to retrieve the total number of elements in a
>> rhashtable/rhltable it needs to open code the access to 'nelems'.
>> Therefore provide a helper for such operation and convert two accesses as
>> an example.
>
> IMHO read of nelems is much more readable than len().
For the case of rhltable it requires:
atomic_read(rhltable->rt.nelems);
Which feels like it defeats the purpose of the dedicated rhltable type
in the first place.
But I must admit that there are no use cases in-tree AFAIK.
Another point is that having this sort of helper also conveys that it's
OK for a consumer to query this value at any time.
> I mean the name of the helper is not great. > IDK what length of a hashtable is. Feels like a Python-ism.
Well 'length' has been the term used in a few languages (Python, Rust,
Go, etc...) so it felt the most fitting. If you have any suggestions in
mind, do tell; Some that crossed my mind were:
- count
- size
- elems
- num
Powered by blists - more mailing lists