Re: [RFC PATCH net-next 0/4] rhashtable: length helper for rhashtable and rhltable

From
Pedro Tammela <hidden>
Date
2023-06-09 18:13:47
Reply to
Jakub Kicinski, 2023-06-09
On 09/06/2023 14:36, Jakub Kicinski wrote:
On Fri,  9 Jun 2023 12:13:28 -0300 Pedro Tammela wrote:
quoted
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

Thread (9 messages) 9 messages, 3 authors, last reply 2023-06-09
Keyboard shortcuts
hback out one level
jnext message in thread / next series-diff position
kprevious message in thread / previous series-diff position
ldrill in
Escclose help / fold thread tree
?toggle this help