Thread (10 messages) 10 messages, 2 authors, 2018-05-24

Re: semantics of rhashtable and sysvipc

From: Linus Torvalds <torvalds@linux-foundation.org>
Date: 2018-05-24 17:53:39
Also in: lkml

On Thu, May 24, 2018 at 10:23 AM Davidlohr Bueso [off-list ref] wrote:
         tbl = bucket_table_alloc(ht, size, GFP_KERNEL);
-       if (tbl == NULL)
-               return -ENOMEM;
+       if (unlikely(tbl == NULL)) {
+               size = min(size, HASH_DEFAULT_SIZE) / 2;
+
+               tbl = bucket_table_alloc(ht, size, GFP_KERNEL);
+               if (tbl == NULL)
+                       tbl = bucket_table_alloc_retry(ht, size,
GFP_KERNEL);
+       }
This doesn't seem to be taking 'param->min_size' into account.

I'm not sure that matters, but right now, if you have nelem_hint set and a
min_size, the min_size is honored (if you have just min_size it's already
ignored because the rhashtable always starts with HASH_DEFAULT_SIZE). So I
could imagine that somebody uses it to guarantee something. The docs say
that "min_size" is the minimum size for *shrinking* not for initializing,
so I guess it's debatable.

Also, wouldn't it make sense to make this all be a while loop? Or are you
just depending on the knowledge that HASH_DEFAULT_SIZE / 2 is already
guaranteed to be so small that there's no point? A comment to that effect
would be good, perhaps.

                    Linus
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help