Message ID | 1422603994-5836-2-git-send-email-kaber@trash.net |
---|---|
State | RFC |
Delegated to: | Pablo Neira |
Headers | show |
On 01/30/15 at 07:46am, Patrick McHardy wrote: > Remove some duplicated code by moving the restart label up a few > lines. Also use rcu_access_pointer() for the pointer comparison > instead of rht_dereference_rcu(). > > Signed-off-by: Patrick McHardy <kaber@trash.net> BTW, everything except the rcu_access_pointer() optimization is also covered in the "rhashtable fixes" series I posted. -- To unsubscribe from this list: send the line "unsubscribe netfilter-devel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
diff --git a/lib/rhashtable.c b/lib/rhashtable.c index aca6998..5f079f7 100644 --- a/lib/rhashtable.c +++ b/lib/rhashtable.c @@ -588,12 +588,12 @@ bool rhashtable_remove(struct rhashtable *ht, struct rhash_head *obj) rcu_read_lock(); tbl = rht_dereference_rcu(ht->tbl, ht); +restart: hash = head_hashfn(ht, tbl, obj); lock = bucket_lock(tbl, hash); spin_lock_bh(lock); -restart: pprev = &tbl->buckets[hash]; rht_for_each(he, tbl, hash) { if (he != obj) { @@ -613,14 +613,10 @@ restart: return true; } - if (tbl != rht_dereference_rcu(ht->future_tbl, ht)) { + if (tbl != rcu_access_pointer(ht->future_tbl)) { spin_unlock_bh(lock); tbl = rht_dereference_rcu(ht->future_tbl, ht); - hash = head_hashfn(ht, tbl, obj); - - lock = bucket_lock(tbl, hash); - spin_lock_bh(lock); goto restart; }
Remove some duplicated code by moving the restart label up a few lines. Also use rcu_access_pointer() for the pointer comparison instead of rht_dereference_rcu(). Signed-off-by: Patrick McHardy <kaber@trash.net> --- lib/rhashtable.c | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-)