Thread (15 messages) 15 messages, 4 authors, 2015-12-09

Re: [PATCH net-next v2 2/5] rhashtable: add function to replace an element

From: Herbert Xu <herbert@gondor.apana.org.au>
Date: 2015-12-08 09:40:18

David Miller [off-list ref] wrote:
From: Tom Herbert <redacted>
Date: Tue, 1 Dec 2015 15:11:09 -0800
quoted
+     lock = rht_bucket_lock(tbl, hash);
+
+     spin_lock_bh(lock);
+
+     pprev = &tbl->buckets[hash];
+     rht_for_each(he, tbl, hash) {
+             if (he != obj_old) {
+                     pprev = &he->next;
+                     continue;
+             }
+
+             rcu_assign_pointer(obj_new->next, obj_old->next);
+             rcu_assign_pointer(*pprev, obj_new);
+             err = 0;
+             break;
Are you sure this works fine in the presence of both parallel readers and
table expansion passes?
Good question.

What's more this is something that can be easily implemented
outside of rhashtable, i.e., by hashing a pointer to the actual
object rather than the object itself.  So I'd like to see some
pretty good reasons for penny-pinching on memory and adding more
complexity to rhashtable.

Cheers,
-- 
Email: Herbert Xu [off-list ref]
Home Page: http://gondor.apana.org.au/~herbert/
PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help