All of lore.kernel.org
 help / color / mirror / Atom feed
From: Patrick McHardy <kaber@trash.net>
To: herbert@gondor.apana.org.au
Cc: tgraf@suug.ch, davem@davemloft.net, David.Laight@ACULAB.COM,
	ying.xue@windriver.com, paulmck@linux.vnet.ibm.com,
	netdev@vger.kernel.org, netfilter-devel@vger.kernel.org
Subject: [PATCH 1/9] rhashtable: simplify rhashtable_remove()
Date: Fri, 30 Jan 2015 07:46:26 +0000	[thread overview]
Message-ID: <1422603994-5836-2-git-send-email-kaber@trash.net> (raw)
In-Reply-To: <1422603994-5836-1-git-send-email-kaber@trash.net>

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(-)

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;
 	}
 
-- 
2.1.0

  reply	other threads:[~2015-01-30  7:46 UTC|newest]

Thread overview: 21+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-01-30  7:46 [PATCH 0/9 WIP] nf_tables: set extensions and dynamic updates Patrick McHardy
2015-01-30  7:46 ` Patrick McHardy [this message]
2015-01-30 16:36   ` [PATCH 1/9] rhashtable: simplify rhashtable_remove() Thomas Graf
2015-01-30  7:46 ` [PATCH 2/9] nftables: reject NFT_SET_ELEM_INTERVAL_END flag for non-interval sets Patrick McHardy
2015-01-30 17:31   ` Pablo Neira Ayuso
2015-01-30 17:55     ` Patrick McHardy
2015-01-30 18:00       ` Pablo Neira Ayuso
2015-01-30  7:46 ` [PATCH 3/9] nftables: nft_rbtree: fix locking Patrick McHardy
2015-01-30 10:52   ` Pablo Neira Ayuso
2015-01-30  7:46 ` [PATCH 4/9] netfilter: nf_tables: add set extensions Patrick McHardy
2015-01-30  7:46 ` [PATCH 5/9] netfilter: nf_tables: convert hash and rbtree to " Patrick McHardy
2015-01-30  7:46 ` [PATCH 6/9] netfilter: nf_tables: add set timeout support Patrick McHardy
2015-01-30  7:46 ` [PATCH 7/9] netfilter: nft_hash: add support for timeouts Patrick McHardy
2015-01-31  4:29   ` Herbert Xu
2015-01-31 12:16     ` Patrick McHardy
2015-01-30  7:46 ` [PATCH 8/9] netfilter: nft_lookup: add missing attribute validation for NFTA_LOOKUP_SET_ID Patrick McHardy
2015-01-30  7:46 ` [PATCH 9/9] netfilter: nf_tables: add support for dynamic set updates Patrick McHardy
2015-01-30  9:28   ` Herbert Xu
2015-01-30 10:08     ` Patrick McHardy
2015-01-30 10:18       ` Herbert Xu
2015-01-30 11:29         ` Herbert Xu

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1422603994-5836-2-git-send-email-kaber@trash.net \
    --to=kaber@trash.net \
    --cc=David.Laight@ACULAB.COM \
    --cc=davem@davemloft.net \
    --cc=herbert@gondor.apana.org.au \
    --cc=netdev@vger.kernel.org \
    --cc=netfilter-devel@vger.kernel.org \
    --cc=paulmck@linux.vnet.ibm.com \
    --cc=tgraf@suug.ch \
    --cc=ying.xue@windriver.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.