From: Tom Herbert <tom@herbertland.com>
To: <davem@davemloft.net>, <netdev@vger.kernel.org>, <tgraf@suug.ch>
Cc: <kernel-team@fb.com>
Subject: [PATCH net-next 2/3] rhashtable: allow lookup function to have compare function agument
Date: Mon, 13 Jul 2015 17:39:12 -0700 [thread overview]
Message-ID: <1436834353-1851565-3-git-send-email-tom@herbertland.com> (raw)
In-Reply-To: <1436834353-1851565-1-git-send-email-tom@herbertland.com>
Added rhashtable_lookup_fast_cmpfn which does a lookup in an rhash table
with the compare function being taken from an argument. This allows
different compare functions to be used on the same table.
Signed-off-by: Tom Herbert <tom@herbertland.com>
---
include/linux/rhashtable.h | 17 +++++++++++++----
1 file changed, 13 insertions(+), 4 deletions(-)
diff --git a/include/linux/rhashtable.h b/include/linux/rhashtable.h
index 8e27159..05171c3 100644
--- a/include/linux/rhashtable.h
+++ b/include/linux/rhashtable.h
@@ -526,9 +526,10 @@ static inline int rhashtable_compare(struct rhashtable_compare_arg *arg,
*
* Returns the first entry on which the compare function returned true.
*/
-static inline void *rhashtable_lookup_fast(
+static inline void *rhashtable_lookup_fast_cmpfn(
struct rhashtable *ht, const void *key,
- const struct rhashtable_params params)
+ const struct rhashtable_params params,
+ rht_obj_cmpfn_t obj_cmpfn)
{
struct rhashtable_compare_arg arg = {
.ht = ht,
@@ -544,8 +545,8 @@ static inline void *rhashtable_lookup_fast(
restart:
hash = rht_key_hashfn(ht, tbl, key, params);
rht_for_each_rcu(he, tbl, hash) {
- if (params.obj_cmpfn ?
- params.obj_cmpfn(&arg, rht_obj(ht, he)) :
+ if (obj_cmpfn ?
+ obj_cmpfn(&arg, rht_obj(ht, he)) :
rhashtable_compare(&arg, rht_obj(ht, he)))
continue;
rcu_read_unlock();
@@ -563,6 +564,14 @@ restart:
return NULL;
}
+static inline void *rhashtable_lookup_fast(
+ struct rhashtable *ht, const void *key,
+ const struct rhashtable_params params)
+{
+ return rhashtable_lookup_fast_cmpfn(ht, key, params,
+ params.obj_cmpfn);
+}
+
struct rht_insert_pos {
struct rhash_head __rcu *head;
struct rhash_head __rcu **pos;
--
1.8.1
next prev parent reply other threads:[~2015-07-14 0:39 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-07-14 0:39 [PATCH net-next 0/3] rhashtable: Wildcard and scored lookups Tom Herbert
2015-07-14 0:39 ` [PATCH net-next 1/3] rhashtable: Add a function for in order insertion in buckets Tom Herbert
2015-07-14 9:57 ` Herbert Xu
2015-07-14 16:42 ` Tom Herbert
2015-07-14 23:58 ` Herbert Xu
2015-07-15 0:59 ` Tom Herbert
2015-07-15 1:08 ` Herbert Xu
2015-07-14 0:39 ` Tom Herbert [this message]
2015-07-14 9:44 ` [PATCH net-next 2/3] rhashtable: allow lookup function to have compare function agument Thomas Graf
2015-07-14 15:43 ` Tom Herbert
2015-07-14 0:39 ` [PATCH net-next 3/3] rhashtable: Add scored lookups Tom Herbert
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=1436834353-1851565-3-git-send-email-tom@herbertland.com \
--to=tom@herbertland.com \
--cc=davem@davemloft.net \
--cc=kernel-team@fb.com \
--cc=netdev@vger.kernel.org \
--cc=tgraf@suug.ch \
/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.