From patchwork Thu Mar 12 03:49:41 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Herbert Xu X-Patchwork-Id: 449296 X-Patchwork-Delegate: davem@davemloft.net Return-Path: X-Original-To: patchwork-incoming@ozlabs.org Delivered-To: patchwork-incoming@ozlabs.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 780091401AC for ; Thu, 12 Mar 2015 14:49:53 +1100 (AEDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752766AbbCLDtu (ORCPT ); Wed, 11 Mar 2015 23:49:50 -0400 Received: from ringil.hengli.com.au ([178.18.16.133]:53947 "EHLO ringil.hengli.com.au" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751107AbbCLDtn (ORCPT ); Wed, 11 Mar 2015 23:49:43 -0400 Received: from gondolin.me.apana.org.au ([192.168.0.6]) by norbury.hengli.com.au with esmtp (Exim 4.80 #3 (Debian)) id 1YVu7x-0006aD-KQ; Thu, 12 Mar 2015 14:49:41 +1100 Received: from herbert by gondolin.me.apana.org.au with local (Exim 4.80) (envelope-from ) id 1YVu7x-0003mE-G7; Thu, 12 Mar 2015 14:49:41 +1100 Subject: [PATCH 4/4] rhashtable: Remove obj_raw_hashfn References: <20150312034923.GA14415@gondor.apana.org.au> To: Thomas Graf , netdev@vger.kernel.org Message-Id: From: Herbert Xu Date: Thu, 12 Mar 2015 14:49:41 +1100 Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org Now that the only caller of obj_raw_hashfn is head_hashfn, we can simply kill it and fold it into the latter. This patch also moves the common shift from head_hashfn/key_hashfn into rht_bucket_index. Signed-off-by: Herbert Xu Acked-by: Thomas Graf --- lib/rhashtable.c | 25 +++++++------------------ 1 file changed, 7 insertions(+), 18 deletions(-) -- To unsubscribe from this list: send the line "unsubscribe netdev" 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 838cccc..6ffc793 100644 --- a/lib/rhashtable.c +++ b/lib/rhashtable.c @@ -63,36 +63,25 @@ static void *rht_obj(const struct rhashtable *ht, const struct rhash_head *he) static u32 rht_bucket_index(const struct bucket_table *tbl, u32 hash) { - return hash & (tbl->size - 1); -} - -static u32 obj_raw_hashfn(struct rhashtable *ht, - const struct bucket_table *tbl, const void *ptr) -{ - u32 hash; - - if (unlikely(!ht->p.key_len)) - hash = ht->p.obj_hashfn(ptr, tbl->hash_rnd); - else - hash = ht->p.hashfn(ptr + ht->p.key_offset, ht->p.key_len, - tbl->hash_rnd); - - return hash >> HASH_RESERVED_SPACE; + return (hash >> HASH_RESERVED_SPACE) & (tbl->size - 1); } static u32 key_hashfn(struct rhashtable *ht, const struct bucket_table *tbl, const void *key) { return rht_bucket_index(tbl, ht->p.hashfn(key, ht->p.key_len, - tbl->hash_rnd) >> - HASH_RESERVED_SPACE); + tbl->hash_rnd)); } static u32 head_hashfn(struct rhashtable *ht, const struct bucket_table *tbl, const struct rhash_head *he) { - return rht_bucket_index(tbl, obj_raw_hashfn(ht, tbl, rht_obj(ht, he))); + const char *ptr = rht_obj(ht, he); + + return likely(ht->p.key_len) ? + key_hashfn(ht, tbl, ptr + ht->p.key_offset) : + rht_bucket_index(tbl, ht->p.obj_hashfn(ptr, tbl->hash_rnd)); } #ifdef CONFIG_PROVE_LOCKING